Repository navigation
Description
Version: VS Code Insiders 1.147.0-insider (54ab794), Linux x64. Agents window, Copilot CLI agent host session, default sessions.chatTimeline.display (gutter).
Steps to reproduce
- Have an agent host session with many turns (I used 100 turns, each editing a few files).
- Turn on
chat.agentHost.ahpJsonlLoggingEnabledso the protocol traffic is visible. - Open the session in the Agents window, switch to another session, then switch back. Repeat.
What happens
Each time the session is shown, the window subscribes to the turn changeset of every prompt: 100 subscribe requests for changeset/turn/<id> within 9-16 ms. After switching away, all 100 are unsubscribed. Switching back subscribes all 100 again.
On each first subscribe, the agent host recomputes that turn's diffs from the session database (computeTurnChangeset), even when nothing changed since the last time. Each turn then sends a snapshot plus statusChanged and contentChanged actions back to the window.
From the AHP log of one run (100 turns, 3 opens):
| Subscribe bursts | 3 × 100 subscribes, each burst in 9-16 ms, with 2 × 100 unsubscribes in between |
| Host time to answer all 100 per open | 932 ms, 891 ms, 641 ms after the burst (last statusChanged) |
Host → window on changeset/turn/* |
300 channel/snapshot (106 KB), 300 changeset/contentChanged (73 KB), 300 changeset/statusChanged (69 KB): 247 KB in 900 messages, about 300 messages per open |
| Status actions in the whole log | 102 computing, 212 recomputing, 312 ready |
The work grows with the number of prompts. It's repeated on every switch, and it competes with the session's own restore and rendering on the host and in the window.
Expected
Showing a session shouldn't subscribe to and recompute the diffs of every historical turn. At most, it should fetch what's visible, and reuse results for completed turns that haven't changed.
Where it comes from
PromptTimelineWidgetContrib._createRailusesmodel.promptTicksfor the gutter rail: one tick per prompt, uncapped.PromptTimelineModel._withDiffStatscreates a derived per tick that calls_statForRequests→_diffsForRequest→IChatResponseFileChangesService.getChangesForRequest(...).read(reader).AgentHostResponseFileChangesProvider._createDiffsObservablereads_subscribeChangeset(turnChangesetUri), so each tick holds a turn changeset subscription.- On the host,
AgentHostChangesetCoordinator.onFirstSubscriber(Turn branch) callscomputeTurnChangeset(..., 'fileEditTracker')whenever the session is loaded.onLastSubscriberonly drops the subscription._computeTurnChangesetalways marks the changeset computing and recomputes.
The gutter rail uses tick.stat only in the flyout rows: the +N −M badge, the reviewable class and its tab stop, and the diff button's label. The resting dots don't use it. So the stats of all prompts are fetched while the flyout is usually hidden. The ruler rail does draw stat bars, but it uses the capped model.ticks.
Possible directions
- Read the per-prompt stats only while the gutter flyout is revealed, or provide them from one session-level per-turn summary instead of one changeset subscription per turn.
- On the host, reuse a
Readyturn changeset for a completed turn on resubscribe instead of recomputing it. While a turn is unsubscribed,_onTrackedEditsChangedandonToolCallEditsAppliedskip it, so the host would need to mark such turns stale rather than trust the old result.
🤖 Authored with GitHub Copilot on behalf of Benjamin Christopher Simmonds (@benibenj).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
sandy081 commentedon Nov 20, 2026
This now also affects editor windows. Since #349181 the same gutter is on by default in editor-window chat views and chat editors, so opening a long agent-host chat there subscribes to every turn's changeset. With about 5,000 prompts the agent host stalled for over 20 seconds, dropped the window, and repeated it on reconnect, hanging every chat meanwhile. #349432 turns the timeline off by default as a stopgap.
Where it comes from:
PromptTimelineModel.promptTicksgoes through_withDiffStats, whose outer derived reads every tick, so every prompt's stat is observed as soon as the rail mounts, even while the list is collapsed.getChangesForRequest. For agent-host chats,AgentHostResponseFileChangesProvider._subscribeChangesetholds a<chat>/changeset/turn/<id>subscription for as long as it is observed (Show per-turn file changes summary for agent host chat responses #323215, reshaped in agentHost: avoid recomputing unchanged turn diffs #337273).Measured in Code - OSS with a mock agent host (per-turn changeset subscribes when the chat opens, with the timeline on): Agents window, 30 prompts: 30. Editor window, 1,001 prompts: 1,001, and another 1,001 when the chat moves into a chat editor. With the timeline off: 4.
Suggested fix: compute
tick.statonly for the flyout rows that are on screen while the flyout is revealed, and release them when it collapses. The ruler needs the same, since each bucketed tick aggregates all of its prompts (46 subscribes for 30 prompts). A prototype with tests is ready to share: the gutter reports its visible rows and the model computes stats only for those. A contrib test mounts a 500-prompt chat and observes 0 prompts while collapsed and only the on-screen rows when revealed.Osvaldo Ortega (@osortega) for the timeline, Bhavya U (@bhavyaus) and Karthik Nadig (@karthiknadig) for review. Benjamin Christopher Simmonds (@benibenj) and roblourens: a stat read probably shouldn't need a live per-turn subscription at all, and tearing down and resubscribing thousands of them on reconnect stalls the host.
Written by GitHub Copilot on behalf of Sandeep Somavarapu (@sandy081)
chat: turn the prompt timeline off by default (microsoft#349432)
connor4312 commentedon Nov 20, 2026
mirroring Slack