Repository navigation
fix undo/redo interactions in agent host - #320650
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a hang/crash in agent-host chat sessions when users click Redo after restoring a checkpoint by implementing real per-checkpoint undo/redo navigation in AgentHostSnapshotController, ensuring the Redo drain loop always makes progress and terminates.
Changes:
- Implement
undoInteraction()andredoInteraction()to move the checkpoint cursor by one step per invocation. - Factor shared cursor/file-state movement into a new
_navigateToCheckpointIndex()helper and reuse it fromrestoreSnapshot(). - Add unit tests covering single-step undo and redo draining to HEAD (regression guard against infinite loops).
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSnapshotController.ts | Implements checkpoint cursor navigation for undo/redo and reuses shared navigation in restore logic to prevent redo drain infinite loops. |
| src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostSnapshotController.test.ts | Adds regression tests verifying stepwise undo and that redo draining reaches HEAD and terminates. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
Justin Chen (justschen)
marked this pull request as ready for review
June 9, 2026 20:18
Justin Chen (justschen)
enabled auto-merge (squash)
June 9, 2026 20:19
Connor Peet (connor4312)
approved these changes
Jun 9, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fix window crash when redoing agent-host checkpoints
Problem: Clicking Redo after restoring a checkpoint in an agent-host session crashed the window.
AgentHostSnapshotController.redoInteraction()was a no-op, but the Redo action drains in a loop:Since
canRedois derived from the checkpoint cursor and the no-op never advanced it, the loop spun forever on the main thread → hang/crash. It only reproduced after a restore/undo, since that's the only timecanRedoistrue.Fix: Implement
undoInteraction()/redoInteraction()to move the checkpoint cursor one step, sharing a new_navigateToCheckpointIndex()helper thatrestoreSnapshot()also uses. Each redo advances the cursor monotonically toward HEAD, socanRedois guaranteed to flipfalseand the loop terminates.Tests: Added two unit tests — single-step undo, and redo draining that stops at HEAD (regression guard for the infinite loop).