Skip to content

sessions: Persist read state per chat - #339500

Merged
Sandeep Somavarapu (sandy081) merged 15 commits into
mainfrom
sandy081/agents/multi-chat-read-status-display
Oct 4, 2026
Merged

Sandeep Somavarapu (sandy081) merged 15 commits into
mainfrom
sandy081/agents/multi-chat-read-status-display

Conversation

@sandy081

Copy link
Copy Markdown
Member

Summary

Persist and display exact read state for every user-visible chat in an Agents Window session.

  • Adds Agent Host protocol and database support for default-chat and peer-chat read state.
  • Shows unread state on individual chat rows while retaining a session-level aggregate.
  • Routes session-row Mark as Read and Mark as Unread actions to the main chat.
  • Excludes hidden, tool, and subagent chats from the session read aggregate.
  • Preserves explicit session-level unread state even after all chats have been viewed.
  • Restores legacy sessions without treating absent per-chat metadata as unread.
  • Allows the active default chat to be marked read before full session-state hydration.
  • Updates documentation, fixtures, protocol recordings, and unit coverage.

Behavioral details

  • IChat.isRead represents the exact state shown for each chat row.
  • ISession.isRead remains the separately persisted session aggregate.
  • Any unread normal user-visible chat forces the aggregate unread.
  • Reading every chat does not clear an explicitly stored session-level unread state.
  • Single-chat sessions continue to share the session read state.
  • For legacy data without defaultChatIsRead, the default chat inherits the stored session read state during restore.

Validation

  • npm run compile — passed.
  • npm run hygiene — passed.
  • npm run eslint -- src/vs/platform/agentHost/node/agentService.ts src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts src/vs/platform/agentHost/test/node/agentService.test.ts src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts — passed.
  • ./scripts/test.sh --run src/vs/platform/agentHost/test/node/agentService.test.ts --grep "restores (an unread default chat with an unread session aggregate|a legacy read session with its default chat read)" — 2 passing.
  • ./scripts/test.sh --run src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts — 378 passing, 11 pending.
  • Live self-host verification passed for opening a legacy read multi-chat session and restoring it after restart.
  • Reproduced the previous-build regression against a reconstructed copy of live profile data: an active read session restored unread; the fixed build path preserves the legacy read state.

One broader peer chat catalog persistence run had 54 passing tests and one unrelated, deterministic recovery-membership assertion failure in the existing cold session, recovery completed case.

Store peer read state in the Agent Host chat catalog, restore missing state as read, and project each chat's status throughout the Agents Window.

Co-authored-by: Copilot <[email protected]>
Adopt the merged AHP compact chat status contract, persist exact read state for every chat, and keep the session aggregate consistent across activation, archive, restore, and explicit read operations.

Co-authored-by: Copilot <[email protected]>
Make per-session Mark as Read and Mark as Unread follow the main chat state shown by the row while preserving the independent session aggregate.

Co-authored-by: Copilot <[email protected]>
Update database fixtures, unit expectations, and AHP snapshots for the current payload version and per-chat read-state transitions.

Co-authored-by: Copilot <[email protected]>
Provide exact chat read state for every rename-test peer fixture used by the Sessions list renderer.

Co-authored-by: Copilot <[email protected]>
Allow default-chat read updates before session-state hydration and preserve legacy session read state when per-chat metadata is absent.\n\nCo-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 3, 2026 19:59
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.141.0 milestone Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 5983cda0 Current: d5f03137

Changed (2)

sessions/accountMenu/WeeklyLimitOnly/Light
Before After
before after
chat/aiCustomizations/aiCustomizationManagementEditor/DiscoverPluginsLoadingMore/Light
Before After
before after

2 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details.

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.

Copilot review overview

🟡 Changes recommended

Hidden chats affect aggregates, failed read requests are not retried, and recovery can discard persisted peer read state.

Review effort: Balanced
Findings: 3 Medium severity

Open (3)
What changed in this PR

Adds persistent per-chat read state to Agent Host sessions while preserving the independent session-level aggregate.

Changes:

  • Persists and synchronizes default and peer-chat read state across protocol, database, catalog, and recovery paths.
  • Displays exact unread state per chat and routes session read actions to the main chat.
  • Expands documentation, unit tests, fixtures, and E2E snapshots.
File Description
src/​vs/​platform/​agentHost/​browser/​agentHostProtocolClient.ts Handles protocol read-state updates.
src/​vs/​platform/​agentHost/​common/​agent.ts Extends Agent Host chat contracts.
src/​vs/​platform/​agentHost/​common/​state/​sessionState.ts Defines chat read metadata and aggregation.
src/​vs/​platform/​agentHost/​node/​agentHostCatalogListReader.ts Reads persisted catalog state.
src/​vs/​platform/​agentHost/​node/​agentHostCatalogProjection.ts Projects per-chat read state.
src/​vs/​platform/​agentHost/​node/​agentHostCatalogSourceResolver.ts Reconciles catalog read state.
src/​vs/​platform/​agentHost/​node/​agentHostDatabase.ts Migrates and stores chat read state.
src/​vs/​platform/​agentHost/​node/​agentHostPeerChatStore.ts Persists peer-chat read state.
src/​vs/​platform/​agentHost/​node/​agentHostStateManager.ts Synchronizes chat and aggregate state.
src/​vs/​platform/​agentHost/​node/​agentService.ts Integrates read state with restoration and catalogs.
src/​vs/​platform/​agentHost/​node/​chatContributions/​builtInChatContributions.ts Registers read-state contributions.
src/​vs/​platform/​agentHost/​node/​chatContributions/​chatArchive/​chatArchiveContribution.ts Coordinates archive and read state.
src/​vs/​platform/​agentHost/​node/​chatContributions/​chatRead/​chatReadContribution.ts Implements chat-read handling.
src/​vs/​platform/​agentHost/​node/​chatContributions/​markUnread/​markUnreadContribution.ts Implements unread transitions.
src/​vs/​platform/​agentHost/​node/​protocolServerHandler.ts Exposes read operations over AHP.
src/​vs/​platform/​agentHost/​test/​electron-browser/​agentHostProtocolClient.test.ts Tests protocol client behavior.
src/​vs/​platform/​agentHost/​test/​node/​agentHostCatalogListReader.test.ts Tests catalog read-state loading.
src/​vs/​platform/​agentHost/​test/​node/​agentHostCatalogProjection.test.ts Tests catalog projections.
src/​vs/​platform/​agentHost/​test/​node/​agentHostCatalogSourceResolver.test.ts Tests catalog reconciliation.
src/​vs/​platform/​agentHost/​test/​node/​agentHostDatabase.test.ts Tests database migration and persistence.
src/​vs/​platform/​agentHost/​test/​node/​agentHostPeerChatStore.test.ts Tests peer-chat persistence.
src/​vs/​platform/​agentHost/​test/​node/​agentHostStateManager.test.ts Tests aggregate invariants.
src/​vs/​platform/​agentHost/​test/​node/​agentHostToolCallTelemetry.test.ts Updates telemetry fixtures.
src/​vs/​platform/​agentHost/​test/​node/​agentHostTurnHangTelemetry.test.ts Updates hang telemetry fixtures.
src/​vs/​platform/​agentHost/​test/​node/​agentHostTurnTelemetry.test.ts Updates turn telemetry fixtures.
src/​vs/​platform/​agentHost/​test/​node/​agentService.test.ts Tests restore and catalog behavior.
src/​vs/​platform/​agentHost/​test/​node/​agentSideEffects.test.ts Updates side-effect coverage.
src/​vs/​platform/​agentHost/​test/​node/​chatContributions.test.ts Tests read-state contributions.
src/​vs/​platform/​agentHost/​test/​node/​e2e/​providers/​__snapshots__/​Agent_Host_E2E___Claude_retains_context_across_consecutive_turns.traffic.ahp.yaml Updates Claude AHP snapshot.
src/​vs/​platform/​agentHost/​test/​node/​e2e/​providers/​__snapshots__/​Agent_Host_E2E___Codex_retains_context_across_consecutive_turns.traffic.ahp.yaml Updates Codex AHP snapshot.
src/​vs/​platform/​agentHost/​test/​node/​e2e/​providers/​__snapshots__/​Agent_Host_E2E___Copilot__Copilot-specific__resumes_a_failed_turn_in_place.traffic.ahp.yaml Updates failed-turn AHP snapshot.
src/​vs/​platform/​agentHost/​test/​node/​e2e/​providers/​__snapshots__/​Agent_Host_E2E___Copilot_retained_background_subagent_completes_repeated_follow-up_turns.traffic.ahp.yaml Updates subagent AHP snapshot.
src/​vs/​platform/​agentHost/​test/​node/​e2e/​providers/​__snapshots__/​Agent_Host_E2E___Copilot_retains_context_across_consecutive_turns.traffic.ahp.yaml Updates Copilot AHP snapshot.
src/​vs/​platform/​agentHost/​test/​node/​e2e/​suites/​multiChatSuite.ts Covers multi-chat read behavior.
src/​vs/​platform/​agentHost/​test/​node/​protocolServerHandler.test.ts Tests protocol read commands.
src/​vs/​sessions/​SESSIONS.md Documents read-state semantics.
src/​vs/​sessions/​browser/​parts/​chatCompositeBar.ts Renders exact chat unread state.
src/​vs/​sessions/​common/​contextkeys.ts Clarifies read context semantics.
src/​vs/​sessions/​contrib/​providers/​agentHost/​AGENT_HOST_SESSIONS_PROVIDER.md Documents provider behavior.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​baseAgentHostSessionsProvider.ts Maps and updates Agent Host read state.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​localAgentHostSessionsProvider.ts Routes local read operations.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​localAgentHostSessionsProvider.test.ts Tests provider read-state behavior.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​browser/​remoteAgentHostSessionsProvider.ts Routes remote read operations.
src/​vs/​sessions/​contrib/​sessions/​browser/​media/​sessionsList.css Styles unread chat rows.
src/​vs/​sessions/​contrib/​sessions/​browser/​views/​sessionsList.ts Displays chat and aggregate unread state.
src/​vs/​sessions/​contrib/​sessions/​browser/​views/​sessionsViewActions.ts Routes session-row read actions.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​automationsView.test.ts Updates automation read-state coverage.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsActions.test.ts Tests read actions.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsList.test.ts Tests unread list rendering.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsListContextMenu.test.ts Tests context-menu state.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsListFixtureUtils.ts Adds fixture read-state support.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsListTestUtils.ts Extends list test utilities.
src/​vs/​sessions/​contrib/​sessions/​test/​browser/​sessionsRename.test.ts Updates session test fixtures.
src/​vs/​sessions/​services/​sessions/​browser/​sessionsManagementService.ts Targets main chats for read actions.
src/​vs/​sessions/​services/​sessions/​browser/​sessionsService.ts Automatically reads active chats.
src/​vs/​sessions/​services/​sessions/​common/​sessionContextKeys.ts Publishes main-chat read context.
src/​vs/​sessions/​services/​sessions/​common/​sessionsManagement.ts Updates management contracts.
src/​vs/​sessions/​services/​sessions/​common/​sessionsProvider.ts Adds provider chat-read API.
src/​vs/​sessions/​services/​sessions/​test/​browser/​sessionNavigation.test.ts Updates navigation fixtures.
src/​vs/​sessions/​services/​sessions/​test/​browser/​sessionsManagementService.test.ts Tests automatic and explicit transitions.
src/​vs/​sessions/​services/​sessions/​test/​common/​sessionContextKeys.test.ts Tests read context keys.
src/​vs/​sessions/​services/​sessions/​test/​common/​testSessionBuilder.ts Supports mutable test read state.
src/​vs/​sessions/​test/​browser/​chatCompositeBar.test.ts Tests per-tab unread rendering.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Wait for the terminal chat unread action before E2E turns are treated as drained, and complete component-fixture main-chat read-state mocks.

Co-authored-by: Copilot <[email protected]>
Exclude hidden chats from aggregate read state, preserve recovered peer read metadata, and retry automatic read transitions after provider startup no-ops.

Co-authored-by: Copilot <[email protected]>
Wait for the current turn's unread action after its terminal notification, while allowing host-local turns to opt out of an action they intentionally do not emit. Regenerate AHP traffic snapshots so read-state changes remain in the originating round.

Co-authored-by: Copilot <[email protected]>
@sandy081
Sandeep Somavarapu (sandy081) marked this pull request as ready for review October 3, 2026 23:32
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Benjamin Christopher Simmonds (@benibenj)

Matched files:

  • src/vs/sessions/browser/parts/chatCompositeBar.ts

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/sessions/services/sessions/browser/sessionsManagementService.ts
  • src/vs/sessions/services/sessions/browser/sessionsService.ts
  • src/vs/sessions/services/sessions/common/sessionContextKeys.ts
  • src/vs/sessions/services/sessions/common/sessionsManagement.ts
  • src/vs/sessions/services/sessions/common/sessionsProvider.ts
  • src/vs/sessions/services/sessions/test/browser/sessionNavigation.test.ts
  • src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts
  • src/vs/sessions/services/sessions/test/common/sessionContextKeys.test.ts
  • src/vs/sessions/services/sessions/test/common/testSessionBuilder.ts

Regenerate the Windows-only consecutive-turn snapshot with unread actions in their originating rounds. Match the selected-model assertion to its prompt-bearing request so later background requests cannot change the observed model.

Co-authored-by: Copilot <[email protected]>
@sandy081
Sandeep Somavarapu (sandy081) merged commit 0817aaa into main Oct 4, 2026
75 of 77 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the sandy081/agents/multi-chat-read-status-display branch October 4, 2026 01:12
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.

3 participants