fix: improve session management and prevent duplicate session creation #100
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔧 Fix: Session Management Issues in ADK Web UI
📋 Overview
This PR addresses multiple session management issues in the ADK Web UI that were causing poor user experience, including duplicate session creation, invalid session handling, and inconsistent session state management across components.
🐛 Issues Fixed
1. Agent Selection Creates New Sessions Instead of Reusing Existing Sessions
Problem: When switching between agents, new sessions were always created even when existing sessions were available.
Solution: Modified
selectApp()
method inchat.component.ts
to:lastUpdateTime
Files Changed:
src/app/components/chat/chat.component.ts
2. Invalid Session URL Handling
Problem: When URL contained invalid session IDs, the system would create new sessions instead of redirecting to valid ones.
Solution: Enhanced error handling in session retrieval to:
Files Changed:
src/app/components/chat/chat.component.ts
3. Session Tab Not Updating on Agent Change
Problem: When switching agents, the Sessions tab would not refresh to show sessions for the newly selected agent.
Solution: Implemented
OnChanges
lifecycle hook inSessionTabComponent
:ngOnChanges()
method to detectappName
anduserId
changesFiles Changed:
src/app/components/session-tab/session-tab.component.ts
4. Page Load Session Validation Missing
Problem: When loading pages with invalid session IDs in URL, no validation occurred, leading to broken states.
Solution: Added
validateAndFixSessionUrl()
method:Files Changed:
src/app/components/chat/chat.component.ts
5. Duplicate Session Creation on Session Deletion
Problem: When deleting the last session, multiple new sessions were created due to
window.location.reload()
triggering multiple components.Solution: Replaced
window.location.reload()
withcreateSessionAndReset()
:Files Changed:
src/app/components/chat/chat.component.ts
6. Backend URL Configuration
Problem: Runtime configuration pointed to wrong port (8000 instead of 8080).
Solution: Updated runtime configuration:
backendUrl
fromhttp://localhost:8000
tohttp://localhost:8080
Files Changed:
src/assets/config/runtime-config.json
🔄 Technical Details
Session Reuse Logic
Session Validation on Page Load
Sessions Tab Auto-Update
🧪 Testing
Manual Testing Scenarios
Expected Behavior
📊 Impact
Before
After
🚨 Breaking Changes
None. All changes are backward compatible and improve existing functionality without changing public APIs.
📝 Additional Notes
Logging Added
Error Handling Improved
🔗 Related Issues
This PR addresses user experience issues related to:
✅ Checklist
Summary: This PR significantly improves the ADK Web UI session management system by implementing intelligent session reuse, proper validation, and consistent component behavior, resulting in a much better user experience.