Fix chat persistence issue on session restart in Agents Window#324456
Open
sandy081 wants to merge 1 commit into
Open
Fix chat persistence issue on session restart in Agents Window#324456sandy081 wants to merge 1 commit into
sandy081 wants to merge 1 commit into
Conversation
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @lszomoruMatched files:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the Agents Window (vs/sessions) where chats closed in a session that isn't currently visible in the grid would reappear after restarting VS Code. Previously, _saveSessionStates only persisted the state of grid-visible sessions, so a session switched out of the grid lost its closed-chat set on save. The fix additionally persists the per-session state of non-visible sessions (stripping grid-placement fields so they aren't restored into the grid) and cleans up state for removed sessions.
Changes:
_saveSessionStatesnow also persists closed-chat / last-active-chat state for sessions not currently visible in the grid, with grid-placement fields (visibleOrder,isActive,isSticky) stripped._onDidChangeSessionsnow deletes a session's entry from_sessionStateswhen the session is removed, preventing stale accumulation.- Added a regression test verifying that a chat closed in a non-active session stays closed across a restart.
Show a summary per file
| File | Description |
|---|---|
src/vs/sessions/services/sessions/browser/sessionsService.ts |
Persists non-visible session state on save and prunes state for removed sessions. |
src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts |
Adds a regression test for closed chats in a non-active session surviving a restart. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Medium
Contributor
|
This PR will be automatically cherry-picked to |
benibenj
approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request addresses a bug in the Agents Window where closed chats in non-active sessions reappear after restarting VS Code.
Changes Made
_saveSessionStatesmethod to persist the state of non-visible sessions, ensuring that closed chats are correctly saved and restored._onDidChangeSessionsmethod to remove a session's state from_sessionStateswhen the session is deleted, preventing stale data from accumulating.Verification
This fix ensures that the chat state is accurately maintained across sessions, improving user experience and consistency.