Skip to content

Fix chat persistence issue on session restart in Agents Window#324456

Open
sandy081 wants to merge 1 commit into
mainfrom
agents/agents-window-restart-chat-bug
Open

Fix chat persistence issue on session restart in Agents Window#324456
sandy081 wants to merge 1 commit into
mainfrom
agents/agents-window-restart-chat-bug

Conversation

@sandy081

@sandy081 sandy081 commented Jul 6, 2026

Copy link
Copy Markdown
Member

This pull request addresses a bug in the Agents Window where closed chats in non-active sessions reappear after restarting VS Code.

Changes Made

  • Updated the _saveSessionStates method to persist the state of non-visible sessions, ensuring that closed chats are correctly saved and restored.
  • Modified the _onDidChangeSessions method to remove a session's state from _sessionStates when the session is deleted, preventing stale data from accumulating.
  • Added a regression test to verify that closed chats in non-active sessions remain closed after a restart.

Verification

  • Typechecked the changes, confirming no errors in the modified files.
  • Conducted a layers check, which passed without issues.

This fix ensures that the chat state is accurately maintained across sessions, improving user experience and consistency.

Copilot AI review requested due to automatic review settings July 6, 2026 09:18
@sandy081 sandy081 enabled auto-merge (squash) July 6, 2026 09:18
@sandy081 sandy081 self-assigned this Jul 6, 2026
@sandy081 sandy081 added this to the 1.128.0 milestone Jul 6, 2026
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@lszomoru

Matched files:

  • src/vs/sessions/services/sessions/browser/sessionsService.ts
  • src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  • _saveSessionStates now also persists closed-chat / last-active-chat state for sessions not currently visible in the grid, with grid-placement fields (visibleOrder, isActive, isSticky) stripped.
  • _onDidChangeSessions now deletes a session's entry from _sessionStates when 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

Comment thread src/vs/sessions/services/sessions/browser/sessionsService.ts
Comment thread src/vs/sessions/services/sessions/browser/sessionsService.ts
@sandy081 sandy081 added the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label Jul 6, 2026
@vs-code-engineering

Copy link
Copy Markdown
Contributor

This PR will be automatically cherry-picked to release/1.128 when merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants