Don't show Used n references when opening an old session#297152
Don't show Used n references when opening an old session#297152daviddossett wants to merge 2 commits intomainfrom
Used n references when opening an old session#297152Conversation
|
@roblourens @justschen this went out of my comfort zone pretty quickly. Is this the right approach make sure |
There was a problem hiding this comment.
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
modeInfotoISerializableChatRequestDataand include it in request export/deserialize paths. - Extend the chat session operation log schema to track
modeInfomutations. - Adjust the references-part rendering logic to fall back to session mode when
modeInfois 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
modeInfois 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 withmodeInfopresent 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(),
src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts
Outdated
Show resolved
Hide resolved
Used n references when opening an old session
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
1249110 to
c5ca3c4
Compare
| let isAgent = false; | ||
| if (request) { | ||
| if (request.modeInfo) { | ||
| isAgent = request.modeInfo.modeId === ChatModeKind.Agent; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Thanks, knew this didn't feel good
Fixes "Used n references" buttons appearing on restored agent-mode chats.
Problem
modeInfowas never serialized when saving chat sessions. When restoring old chats,modeInfowas alwaysundefined, so the checkmodeInfo?.modeId === ChatModeKind.AgentinchatListRenderer.tsalways evaluated tofalse, causing the "Used n references" button to show even for agent-mode sessions.Fix
Persist
modeInfo— AddedmodeInfotoISerializableChatRequestData,toExport(),_deserializeRequest(), and the operation log schema so it survives across save/restore cycles.Fallback for old sessions — For sessions saved before this change (no
modeInfoon the request), fall back to the session-leveldelegate.currentChatMode()which reflects the persistedinputModel.mode.