Repository navigation
agentHost: keep a promoted session's read state in sync with its chat - #344129
Merged
Sandeep Somavarapu (sandy081) merged 3 commits intoOct 26, 2026
Merged
Sandeep Somavarapu (sandy081) merged 3 commits into
Sandeep Somavarapu (sandy081) merged 3 commits into
Conversation
Promoting a chat created its new session unread while the chat kept its own read flag. Clients mark a session read through its main chat, and the host only synchronized the session on an unread-to-read chat transition, so the session stayed unread and every session list refresh showed it unread again. A promoted session now takes the read state of the chats it takes, and a read of a session's sole aggregate chat repairs a session left unread, for loaded and unloaded sessions alike. Multi-chat sessions keep an explicitly unread session on redundant chat reads. Fixes #344128 Co-authored-by: Copilot <[email protected]>
Alexandru Dima (alexdima)
requested a review
from Sandeep Somavarapu (sandy081)
October 25, 2026 12:12
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused fixes preserve multi-chat behavior and include regression coverage for both repair paths, promotion, and restart persistence.
No open issues 🎉
What changed in this PR
Fixes #344128 by keeping promoted Agent Host sessions’ read state consistent with their participating chats, preventing unread indicators from returning after refresh.
Changes:
- Derive a promoted session’s initial read state from its chats, excluding hidden and tool chats.
- Repair inconsistent single-chat sessions on redundant read actions in both loaded and unloaded paths, while preserving multi-chat behavior.
- Add four regression tests covering promotion, repair, and restart persistence.
No actionable issues were identified.
| File | Description |
|---|---|
src/vs/platform/agentHost/test/node/agentService.test.ts |
Tests unloaded-session repair and promotion across restart. |
src/vs/platform/agentHost/test/node/agentHostStateManager.test.ts |
Tests loaded-session repair and promoted read-state aggregation. |
src/vs/platform/agentHost/node/agentService.ts |
Allows redundant reads to repair unloaded single-chat sessions. |
src/vs/platform/agentHost/node/agentHostStateManager.ts |
Initializes promoted read state and repairs loaded single-chat sessions. |
Review effort: Balanced
The stuck unread state shows in the listSessions reply, which every client applies over its own read state, so the promotion regression test asserts that reply after the promotion, after a restart and after a restore, rather than the in-memory session state only. Refs #344128 Co-authored-by: Copilot <[email protected]>
This was referenced Oct 25, 2026
Alexandru Dima (alexdima)
added a commit
that referenced
this pull request
Oct 25, 2026
…`ripple why` (#344148) ripple: depend on the content of files that root paths name A string such as `'src/main.ts'` in a test's fake GitHub tree names an existing module from the repository root, and ripple linked it like a dynamic import: to the node standing for the whole module, which depends on all of it and on everything it loads. So that test depended on all that the Electron main process starts, the agent host included, and #344129, which only changes agent host code, ran it alone in WebKit on macOS. Of the 670 commits of the last week, 175 selected that test this way, and 31 selected `fuzzyScorer.test.ts`, whose `URI.file(...)` fixtures name workbench modules. No module specifier is a path from the repository root, so code reads the file that such a string names, or the string only looks like a path. It now reads the file, like the folders that tests read by path: the code depends on the file's content, also for a module, but not on what the module loads. Relative and path alias strings, such as entry points, still reach what the module loads. On the same 670 commits, 190 select fewer tests and none select more; on 63 of them, the browser test runners have nothing left to run. The README's replay table had drifted since earlier changes; it now shows the current numbers. `ripple why --test PATH --base REV [--head REV]` prints how a change reaches a test that it selects: the path from the test's code to what the change changed, through declarations, whole modules, packages and globals, and the code whose use of a name opened each instance method on the way. It shares the search of `reaches_from`, so it follows the same rules as selection. Co-authored-by: Copilot <[email protected]>
Sandeep Somavarapu (sandy081)
approved these changes
Oct 26, 2026
Dirk Bäumer (dbaeumer)
approved these changes
Oct 26, 2026
Sandeep Somavarapu (sandy081)
deleted the
agents/vscode-insiders-session-unread-issue
branch
October 26, 2026 11:09
Sandeep Somavarapu (sandy081)
added a commit
that referenced
this pull request
Oct 26, 2026
* agentHost: keep session read state consistent when chats move Moving chats into another session (transferChats), promoting chats (promoteChats, source side) or moving a session under another (transferSession) recomputed only the activity bits of the affected sessions. The session-owned IsRead flag stayed as it was, so a source left with only read chats stayed unread (and the multi-chat redundant-read guard kept it so), and a destination that received an unread chat stayed read for listSessions consumers. After each of these moves the host now marks every affected session read exactly when all its chats counting toward its read state are, through session/isReadChanged, which is persisted like any other host read change. Reorders are unchanged. Follow-up to #344129 (#344128). Co-authored-by: Copilot <[email protected]> * agentHost: keep an explicit Mark as Unread when only read chats move A move now changes a session's read flag only when it takes an unread chat counting toward read state along: the destination (transferChats, transferSession) becomes unread, and the source (transferChats, promoteChats) read once all its remaining counted chats are. Moving only read chats leaves both flags alone, so a session the user marked unread as a whole stays unread instead of being recomputed as read. Co-authored-by: Copilot <[email protected]> * agentHost: test that promoting a read chat keeps an explicit Mark as Unread A session marked unread as a whole stays unread when only read chats are promoted out of it. Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
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.
Fixes #344128
Problem
A session created with Promote to Session goes back to unread constantly: every
listSessionsrefresh marks it unread again, even right after the user opened it. The issue has the wire-level evidence from an Insiders AHP log: the session is announced withstatus: 1while its only chat hasstatus: 33, and all 18 refreshes between 09:42Z and 12:22Z report the same.There are two causes:
status: SessionStatus.Idle(noIsRead), but the promoted chat keeps its ownIsReadbit. Every other path keeps a single-chat session's read state equal to its chat's: the catalog resolver,SessionIsReadChanged, and restore.chat/isReadChanged), and the host updates the session only when that chat goes from unread to read. The promoted chat is already read, so the read is a no-op and the session stays unread.Changes
AgentHostStateManager.promoteChats: the new session is read if all the chats it takes are read. Tool and hidden chats don't count, same as everywhere else. As a result,root/sessionAddedcarries the right status from the start.AgentHostStateManager) and the unloaded path (AgentService). This repairs sessions already in the bad state the next time the user opens them. With a single chat, the "explicitly marked unread" state that the guard protects can't exist:SessionIsReadChanged(false)andmarkUnreadContributionalso mark the sole chat unread. Multi-chat sessions keep the guard. The existing testonly the last unread aggregate chat promotes its session to readstill checks that.Not changed, on purpose
listSessionsoverlays it. The new service test shows this: after a restart the session is listed read even without the fix.transferChats/transferSession) doesn't recalculate either session's read flag. That's a related but separate path; I'm happy to follow up.How to test
Manual (Insiders build with
"chat.agentHost.moveChats.enabled": true):Automated: four new tests, each one fails without the fix and passes with it.
AgentHostStateManager›a promoted session is read exactly when the chats it takes areannounced['copilot:/promoted']:false, expectedtrueAgentHostStateManager›a redundant read of a sole chat repairs a session left unreadsession/isReadChanged;sessionIsRead: falseAgentService›a redundant read of the sole chat of an unloaded session repairs a session left unreadsessionRead: falseAgentService›a promoted session is listed read exactly when its chat is, also after a restart(realmoveChat→newSession; asserts thelistSessionsreply that clients apply, after promotion, after a host restart and after restore)promoted[0]:{ chat: true, session: false }, expectedsession: true. That's the exact state in the issue's logs. Restart and restore already pass.Validation
npm run typecheck-client: passed./scripts/test.sh --run src/vs/platform/agentHost/test/node/agentHostStateManager.test.ts --grep "read|promot": 16 passing, 0 failing./scripts/test.sh --run src/vs/platform/agentHost/test/node/agentService.test.ts --grep "a promoted session|promotes and persists the session when the last unread chat becomes read|a chat read toggle|passive chat read|a redundant read of the sole chat|read toggle|promot" --timeout 30000: 60 passing, 0 failingnpm run eslint -- <the 4 changed files>: passed, no warnings4f383697191): 4 failing (as expected), with the diffs in the table above.Commits:
40a0d6d71d7is the fix plus tests.665322c5df7makes the promotion regression test assert thelistSessionsreply rather than only in-memory state.