Skip to content

fix pinned sessions dropping from list when chat models unload (#325448)#325536

Open
lucastaylr wants to merge 4 commits into
microsoft:mainfrom
lucastaylr:fix/pinned-sessions-unload-325448
Open

fix pinned sessions dropping from list when chat models unload (#325448)#325536
lucastaylr wants to merge 4 commits into
microsoft:mainfrom
lucastaylr:fix/pinned-sessions-unload-325448

Conversation

@lucastaylr

Copy link
Copy Markdown

Fixes #325448:

  • onDidDisposeSession was treated as removing the session from the Agent Sessions list when a chat model unloaded from memory. Refresh the local session list from live + history instead, so unloaded sessions stay visible until they are actually deleted.

Added Unit Tests:

  • covers unload-but-still-in-history (session stays listed)
  • covers dispose + deleted from history (session is removed)

…soft#325448)

onDidDisposeSession means the in-memory model was released, not that the session was deleted. Refresh the local session list from live + history instead of removing the item.
Copilot AI review requested due to automatic review settings July 13, 2026 06:08
@lucastaylr

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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

Refreshes local sessions from live and historical data when models unload, preventing pinned sessions from disappearing.

Changes:

  • Rebuilds session items after disposal events.
  • Adds tests for unloaded and deleted sessions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
localAgentSessionsController.ts Refreshes sessions after model disposal.
localAgentSessionsController.test.ts Tests unload and deletion behavior.

Make refresh generation-aware so an older in-flight refresh cannot overwrite a newer live+history result after dispose, and cover the out-of-order completion case in tests.

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Coalesce overlapping refreshes and verify models remain active after asynchronous detail conversion, preventing stale work from removing sessions restored from history.

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment on lines 73 to 74
const newResources = new ResourceSet(newItems.map(i => i.resource));
const addedOrUpdated: LocalChatSessionItem[] = [];

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

doRefresh() only reported brand-new resources in addedOrUpdated, so content changes discovered during a rebuild (such as the live-to-history transition on model unload) updated the item map without notifying consumers. Diff existing items with isEqual and include changed ones in the delta.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session disappears from pinned list, then reappears randomly

3 participants