Repository navigation
agentHost: open, navigate, and search long chats on demand - #349287
Draft
Osvaldo Ortega (osortega) wants to merge 2 commits into
Draft
Osvaldo Ortega (osortega) wants to merge 2 commits into
Osvaldo Ortega (osortega) wants to merge 2 commits into
Conversation
Page older turns on demand so opening a long chat does not exceed the relay message limit. Keep each subscriber's history window independent and preserve the transcript, checkpoints, and pending sends across reconnects. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues can start canceled prompts after reauthentication, prevent paginated subagent calls from opening child chats, and leave turns completed during disconnection without restore checkpoints.
3 open issues
What changed in this PR
This PR adds on-demand history paging to Agent Host relay chats, reducing opening payloads that can exceed the relay’s message limit. Local subscriptions continue to load full history.
Changes:
- Request the latest 10 completed turns over the relay, with subscription-specific cursors and byte-bounded pages.
- Load older turns through scrolling or keyboard navigation while preserving reading position, focus, and active responses.
- Update reconnect recovery and checkpoint handling, with regression tests and accessibility guidance.
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/test/common/chatService/chatService.test.ts |
Tests prepending history and reconciling local requests. |
src/vs/workbench/contrib/chat/test/browser/widget/chatListWidget.test.ts |
Tests paging gestures, scroll anchoring, and focus preservation. |
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts |
Tests page loading, reconnect history, and checkpoint boundaries. |
src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostSnapshotController.test.ts |
Tests checkpoint prepends during undo and restoration. |
src/vs/workbench/contrib/chat/common/model/chatViewModel.ts |
Distinguishes historical insertions from new sends. |
src/vs/workbench/contrib/chat/common/model/chatModel.ts |
Exposes paging and preserves pending edit events during insertions. |
src/vs/workbench/contrib/chat/common/chatSessionsService.ts |
Adds paging and history-ownership contracts. |
src/vs/workbench/contrib/chat/common/chatService/remoteChatSessionRestorer.ts |
Prepends older history without disrupting live responses. |
src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts |
Avoids new-send UI effects for historical insertions. |
src/vs/workbench/contrib/chat/browser/widget/chatListWidget.ts |
Triggers paging from navigation and preserves scroll position. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionHandler.ts |
Forwards paging through cloud-session wrappers. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSnapshotController.ts |
Adds older checkpoints while preserving undo boundaries. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts |
Coordinates paging, history reconciliation, and safe truncation. |
src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.ts |
Documents keyboard navigation for older messages. |
src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts |
Tests cursor isolation, size limits, authorization, and replay. |
src/vs/platform/agentHost/test/electron-browser/agentHostProtocolClient.test.ts |
Tests paged subscriptions and pending-prompt recovery. |
src/vs/platform/agentHost/node/protocolServerHandler.ts |
Serves subscription-specific pages and bounded reconnect responses. |
src/vs/platform/agentHost/node/chatHistoryView.ts |
Implements cursor tracking and count- and byte-bounded pages. |
src/vs/platform/agentHost/node/agentHostStateManager.ts |
Allocates distinct sequence numbers for subscription baselines. |
src/vs/platform/agentHost/common/state/agentSubscription.ts |
Tracks pending starts and checks delivery across history pages. |
src/vs/platform/agentHost/common/agentService.ts |
Adds an optional connection API for fetching older turns. |
src/vs/platform/agentHost/browser/agentHostProtocolClient.ts |
Requests relay pages and verifies pending sends during recovery. |
src/vs/platform/agentHost/AGENTS.md |
Documents paging and reconnect invariants. |
Review effort: Balanced
Comment on lines
+2874
to
+2876
| for (const { channel, clientSeq, action } of this._subscriptionManager.getPendingActions()) { | ||
| if (action.type === ActionType.ChatTurnStarted && (expired.pendingTurns.has(clientSeq) || expired.unsentTurns.has(clientSeq))) { | ||
| this.dispatchAction(channel, action, this._clientId, clientSeq); |
Comment on lines
+854
to
+855
| const previousIds = reason === 'page' ? new Set(previous.map(turn => turn.id)) : undefined; | ||
| const older = previousIds ? window.filter(turn => !previousIds.has(turn.id)) : []; |
Comment on lines
+3096
to
+3101
| const older = chatSession.reconcileHistory(chat, turns => turnsToHistory(backendSession, turns, this._config.agentId, this._config.connectionAuthority, | ||
| this._createTurnModelLookup(sessionResource, lastTurnModelSelection(state)?.id), this._chatErrorContext(sessionResource), | ||
| this._config.connection.initializeResult.get()?.terminalCommandPrefix, this._config.connection.resourceUris, | ||
| turn => this._getTurnErrorDetails(sessionResource, turn, allowTurnResume), | ||
| turns.at(-1) === chat.turns.at(-1) ? readAgentContextUsage(state, chat.turns.at(-1)?.usage) : undefined, | ||
| this._managedPluginRetryTarget(backendSession, chatURI)), reason); |
List prompt previews without transferring replies. Open a contiguous, read-only window around a gutter or Find selection while leaving the live chat subscribed. Fall back to the loaded transcript when the host does not advertise history navigation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Screenshot ChangesBase: Changed (15)Errored (1)Fixtures that failed to render — no screenshot was produced.
|
This was referenced Nov 20, 2026
This branch has not been deployed
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.

Opening a long chat could disconnect the relay before it displayed the first reply. The client now opens at the latest messages (up to ten completed turns, with a byte budget) rather than requesting every reply. The gutter can still list every prompt, and Find can reach older replies. Neither requires downloading the rest of the transcript in the background.
Companion protocol draft: microsoft/agent-host-protocol#620.
listChatTurns,readChatTurns, andsearchChatTurnsare optional reads. They do not move the live subscription. The client uses them only when the chat advertiseshistoryNavigation; without it, Find reports results for loaded messages only.How to review and test
Use a client and host built from this branch and a remote chat with at least 100 turns retained by the host. Pick a word that appears only in an early reply.
Verification
Limits
The transcript remains virtualized. Manually visited neighboring pages are kept until another jump or return to latest; this is not a fixed-size cache. Opening the gutter builds all title rows. Search reports incomplete results if it hits the worker time or concurrency limit. This change does not raise the relay limit or change authentication.