Repository navigation
agentHost: keep session read state consistent when chats move - #344244
Merged
Sandeep Somavarapu (sandy081) merged 3 commits intoOct 26, 2026
Merged
Conversation
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]>
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]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The narrowly scoped changes reuse existing read-state mechanisms and include regression coverage for each affected operation.
No open issues 🎉
What changed in this PR
This PR extends the earlier promotion read-state fix to other chat moves, keeping Agent Host session read flags consistent with their participating chats.
Changes:
- Recalculates affected sessions’ read flags after transfers and promotions, using existing read-change actions for notification and persistence.
- Adds eight regression tests covering move behavior, restart and restore persistence, and unchanged read state after reordering.
- Documents the read-state rules for moves.
No actionable findings remain.
| File | Description |
|---|---|
src/vs/platform/agentHost/test/node/agentService.test.ts |
Tests listed read state after moves, restarts, restores, and reorders. |
src/vs/platform/agentHost/test/node/agentHostStateManager.test.ts |
Tests aggregate read flags and emitted read-change actions. |
src/vs/platform/agentHost/node/agentHostStateManager.ts |
Synchronizes affected sessions’ read flags after moves. |
src/vs/platform/agentHost/AGENTS.md |
Documents move-related read-state behavior. |
Review effort: Balanced
…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]>
Sandeep Somavarapu (sandy081)
enabled auto-merge (squash)
October 26, 2026 10:46
Benjamin Christopher Simmonds (benibenj)
approved these changes
Oct 26, 2026
Sandeep Somavarapu (sandy081)
deleted the
agents/move-keeps-read-state
branch
October 26, 2026 12:08
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.
Follow-up to #344129 (#344128).
Problem
#344129 makes Promote to Session keep the new session's read state right. Its description lists what it leaves alone: moving chats into an existing session doesn't recalculate either session's read flag. Promotion has the same problem on the source side.
A session's read flag (
IsRead) belongs to the session.transferChats,promoteChatsandtransferSession(Move Chats Block 4, #341788) recompute only the activity bits from the chats (_applySessionAggregate→_mergeSessionStatus). Since #339732 nothing else recalculates the flag after a move:listSessionsreply while it's loaded.vscode/moveSession→transferSession) leaves the destination read.Changes
AgentHostStateManager: a move now updates read flags only when it takes an unread chat along. Tool and hidden chats don't count (isChatInSessionReadAggregate).transferChats,transferSession): becomes unread.transferChats,promoteChats): becomes read once all its remaining chats are read.session/isReadChanged. Clients see it in the same synchronous step as the move.SessionFlagsContribution), not in the move's database transaction.AGENTS.mdMoves section now says this.How to test
Agents window with
"chat.agentHost.moveChats.enabled": true, Copilot CLI sessions:session/isReadChangedright aftersession/chatsReordered.The Agents window's own sessions list already treats a session with an unread chat as unread, so it shows bugs 2 and 4 correctly even before the fix. They're wrong in the host's
listSessionsreply, which the service tests check.Validation
assert.deepStrictEqual. All fail without the fix except three that check behaviour which must not change: the reorder test and the two marked-unread tests. The marked-unread tests failed against this PR's first version, which made such sessions read.session/isReadChangedenvelopes.moveChat/moveSession): whatlistSessionsreports after the move, after a host restart and after restore, for a chat move, a promotion, a session move and a reorder../scripts/test.sh --runGlob "vs/platform/agentHost/test/node/**/*.test.js": passed, 13534 passing, 0 failing, 75 pending.transferChats/transferSession/promoteChats, count tool or hidden chats (moved or staying), drop the source or destination update, dispatch when nothing changed, or drop the "an unread chat moved" condition.npm run eslint -- <changed .ts files>: passed.npm run typecheck-client: passed.COPILOT_HOME, Claude/Codex disabled; the scenario above before and after the fix, including a window reload.