Skip to content

agent host: hydrate snapshot controller for Restore Checkpoint#319051

Merged
connor4312 merged 2 commits into
mainfrom
connor4312/318251
May 29, 2026
Merged

agent host: hydrate snapshot controller for Restore Checkpoint#319051
connor4312 merged 2 commits into
mainfrom
connor4312/318251

Conversation

@connor4312
Copy link
Copy Markdown
Member

agent host: hydrate snapshot controller for Restore CheckpointCurrently the AgentHostSnapshotController never has any checkpoints torestore to when "Restore Checkpoint" is invoked, so the removed requeststays visible in the chat UI. This fix wires up hydration end-to-end andsimplifies the controller's bookkeeping along the way.- Seed a request-level checkpoint for every historical turn on session open, not only turns with file edits. Without this, restoreSnapshot for any turn that lacked tool calls fell through with "No checkpoint found" and _setDisabledRequests was never called.- Always populate _pendingHistoryTurns from the protocol state (previously gated on hasTurnsWithEdits), and stop using Event.once on onDidCreateModel to wait for the chat model ΓÇö the once subscription was being consumed by an unrelated model created first, leaving the controller un-hydrated. Now we synchronously hydrate when the model already exists, otherwise listen until the matching session arrives.- Make ensureRequestCheckpoint advance _currentCheckpointIndex to the new checkpoint. Previously the cursor stayed put, so requestDisablement marked the in-flight request as disabled (the new checkpoint sat "forward" of the cursor) and the next call would splice it away.- Simplify to one checkpoint per request. Multiple tool calls in the same request now fold their edits into a single checkpoint via a seenToolCallIds Set, and restoreSnapshot/getSnapshotUri/ getSnapshotContents ignore the stopId parameter. canUndo/canRedo derive purely from cursor position ΓÇö undo/redo is request-level, available whenever any checkpoint exists.- Add tests covering: in-flight request isn't disabled, restore of a no-edit request marks it disabled, stale forward branch is spliced on new request after restore-to-start, and multi-tool-call edits undo together.Fixes #318251 message generated by Copilot)

Currently the AgentHostSnapshotController never has any checkpoints to
restore to when "Restore Checkpoint" is invoked, so the removed request
stays visible in the chat UI. This fix wires up hydration end-to-end and
simplifies the controller's bookkeeping along the way.

- Seed a request-level checkpoint for every historical turn on session
  open, not only turns with file edits. Without this, restoreSnapshot
  for any turn that lacked tool calls fell through with "No checkpoint
  found" and _setDisabledRequests was never called.
- Always populate _pendingHistoryTurns from the protocol state
  (previously gated on hasTurnsWithEdits), and stop using Event.once on
  onDidCreateModel to wait for the chat model — the once subscription
  was being consumed by an unrelated model created first, leaving the
  controller un-hydrated. Now we synchronously hydrate when the model
  already exists, otherwise listen until the matching session arrives.
- Make ensureRequestCheckpoint advance _currentCheckpointIndex to the
  new checkpoint. Previously the cursor stayed put, so requestDisablement
  marked the in-flight request as disabled (the new checkpoint sat
  "forward" of the cursor) and the next call would splice it away.
- Simplify to one checkpoint per request. Multiple tool calls in the
  same request now fold their edits into a single checkpoint via a
  seenToolCallIds Set, and restoreSnapshot/getSnapshotUri/
  getSnapshotContents ignore the stopId parameter. canUndo/canRedo
  derive purely from cursor position — undo/redo is request-level,
  available whenever any checkpoint exists.
- Add tests covering: in-flight request isn't disabled, restore of a
  no-edit request marks it disabled, stale forward branch is spliced on
  new request after restore-to-start, and multi-tool-call edits undo
  together.

Fixes #318251

(Commit message generated by Copilot)
Copilot AI review requested due to automatic review settings May 29, 2026 20:25
@connor4312 connor4312 enabled auto-merge (squash) May 29, 2026 20:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes “Restore Checkpoint” for agent-host chat sessions by ensuring snapshot state is properly hydrated from protocol history and by simplifying checkpoint tracking to request-level undo/redo, so restored (removed) requests are correctly hidden in the UI.

Changes:

  • Seed request-level checkpoints for all historical turns (including no-edit turns) and hydrate them when the chat model becomes available.
  • Simplify snapshot bookkeeping to one checkpoint per request and fold tool-call edits into that checkpoint.
  • Add/extend tests for no-edit restore behavior, forward-branch splicing, and multi-tool-call undo.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostSnapshotController.test.ts Adds coverage for request-level checkpoint semantics, no-edit restores, branch splicing, and multi-tool-call undo.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSnapshotController.ts Switches to one checkpoint per request, adjusts disablement/undo semantics, and updates snapshot URI/content behavior.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts Stores all historical turns for hydration and fixes eager snapshot-controller creation so hydration reliably occurs for the correct session.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 3

roblourens
roblourens previously approved these changes May 29, 2026
- Fold multiple tool-call edits to the same file in one request into a single net before/after pair (mergeFileEdit). Without this, _writeCheckpointContent applied duplicate writes in parallel and raced.

- Refresh stale 'sentinel' wording in session handler comments.

(Commit message generated by Copilot)
@connor4312 connor4312 merged commit 1091536 into main May 29, 2026
25 checks passed
@connor4312 connor4312 deleted the connor4312/318251 branch May 29, 2026 21:27
@vs-code-engineering vs-code-engineering Bot added this to the 1.123.0 milestone May 29, 2026
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.

AgentHost: Restore Checkpoint doesn't hide removed requests

5 participants