Skip to content

Don't show Used n references when opening an old session#297152

Closed
daviddossett wants to merge 2 commits intomainfrom
daviddossett/persist-modeinfo-serialization
Closed

Don't show Used n references when opening an old session#297152
daviddossett wants to merge 2 commits intomainfrom
daviddossett/persist-modeinfo-serialization

Conversation

@daviddossett
Copy link
Collaborator

Fixes "Used n references" buttons appearing on restored agent-mode chats.

Problem

modeInfo was never serialized when saving chat sessions. When restoring old chats, modeInfo was always undefined, so the check modeInfo?.modeId === ChatModeKind.Agent in chatListRenderer.ts always evaluated to false, causing the "Used n references" button to show even for agent-mode sessions.

Fix

  1. Persist modeInfo — Added modeInfo to ISerializableChatRequestData, toExport(), _deserializeRequest(), and the operation log schema so it survives across save/restore cycles.

  2. Fallback for old sessions — For sessions saved before this change (no modeInfo on the request), fall back to the session-level delegate.currentChatMode() which reflects the persisted inputModel.mode.

@daviddossett
Copy link
Collaborator Author

daviddossett commented Feb 24, 2026

@roblourens @justschen this went out of my comfort zone pretty quickly. Is this the right approach make sure Used n references doesn't show back up on reload/opening an existing session?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Persists per-request chat modeInfo into the chat session serialization/mutation-log format so restored sessions retain the correct mode context (notably to avoid showing “Used n references” for agent-mode history).

Changes:

  • Add modeInfo to ISerializableChatRequestData and include it in request export/deserialize paths.
  • Extend the chat session operation log schema to track modeInfo mutations.
  • Adjust the references-part rendering logic to fall back to session mode when modeInfo is absent (backcompat for older sessions).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/vs/workbench/contrib/chat/common/model/chatSessionOperationLog.ts Adds modeInfo to the request mutation-log schema so it is persisted in the incremental session log.
src/vs/workbench/contrib/chat/common/model/chatModel.ts Extends serialized request shape and ensures modeInfo is exported and revived on restore.
src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts Uses modeInfo (or a fallback) to suppress references UI for agent-mode sessions on restore.
Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/chat/common/model/chatModel.ts:2644

  • modeInfo is now part of the persisted request data (toExport() + _deserializeRequest() + operation log). There doesn’t appear to be a unit test that covers a save/restore roundtrip with modeInfo present and missing (backcompat). Adding a test in the existing chat model serialization/normalization test suite would help prevent regressions like the one this PR fixes.
					agent: agentJson,
					timestamp: r.timestamp,
					confirmation: r.confirmation,
					editedFileEvents: r.editedFileEvents,
					modelId: r.modelId,
					modeInfo: r.modeInfo,
					...r.response?.toJSON(),

@daviddossett daviddossett marked this pull request as draft February 26, 2026 17:12
@rzhao271 rzhao271 modified the milestones: February 2026, March 2026 Feb 27, 2026
@daviddossett daviddossett changed the title Persist modeInfo in chat session serialization Don't show Used n references when opening an old session Mar 3, 2026
Fixes 'Used n references' buttons appearing on restored agent-mode chats.

- Add modeInfo to ISerializableChatRequestData
- Serialize modeInfo in toExport() and restore in _deserializeRequest()
- Add modeInfo to operation log schema
- Fall back to session-level mode for old sessions without persisted modeInfo
@daviddossett daviddossett force-pushed the daviddossett/persist-modeinfo-serialization branch from 1249110 to c5ca3c4 Compare March 3, 2026 17:41
let isAgent = false;
if (request) {
if (request.modeInfo) {
isAgent = request.modeInfo.modeId === ChatModeKind.Agent;
Copy link
Member

Choose a reason for hiding this comment

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

This is not quite right because you can send a request to a participant while being "in agent mode". I'm going to do a slightly different fix, it's my fault this is messy

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, knew this didn't feel good

roblourens added a commit that referenced this pull request Mar 4, 2026
roblourens added a commit that referenced this pull request Mar 4, 2026
roblourens added a commit that referenced this pull request Mar 4, 2026
* Don't show Used n references when opening an old session
Alternate fix for #297152

* Don't show Used n references when opening an old session
Alternate fix for #297152
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.

4 participants