Skip to content

feat(tui): add /snapshots command to list and restore captured snapshots#2690

Merged
dgageot merged 3 commits intodocker:mainfrom
dgageot:board/0e9887fd12e1e4fd
May 7, 2026
Merged

feat(tui): add /snapshots command to list and restore captured snapshots#2690
dgageot merged 3 commits intodocker:mainfrom
dgageot:board/0e9887fd12e1e4fd

Conversation

@dgageot
Copy link
Copy Markdown
Member

@dgageot dgageot commented May 7, 2026

Adds a new /snapshots slash command that opens a dialog showing every snapshot captured during the current session and lets the user restore any of them (or the original pre-agent state).

What it does

  • /snapshots opens a modal listing the captured snapshots with their file counts, plus an <original> entry for the pre-agent state.
  • Inside the dialog: / (or j/k, g/G, home/end) navigate, r restores the highlighted snapshot, Esc closes without changing anything.
  • Restoring snapshot N reverts every snapshot taken after N (i.e. workspace returns to the state at the end of snapshot N). Restoring <original> reverts everything.
  • The command (and /undo) are hidden from both the palette and the slash-command parser when snapshots aren't enabled, so the UI stays uncluttered for users who haven't opted in.

Implementation

  • Adds ListSnapshots and ResetSnapshot operations alongside the existing UndoLastSnapshot, plumbed through pkg/hooks/builtins, pkg/runtime, and pkg/app.
  • A single snapshotRuntime interface in pkg/app captures all four runtime methods (SnapshotsEnabled, undo, list, reset); runtimes that don't support snapshots simply don't implement it and the related commands disappear automatically.
  • popHistoryTail (renamed from truncateAfter) clears popped slots in the backing array so the dropped file lists can be GC'd.
  • The dialog itself stays small: no key-map struct, no second pass over the renderer, the body and help-keys derive from len(fileCounts).

Docs & tests

  • docs/features/tui/index.md updated.
  • New tests cover ListSnapshots, ResetSnapshot, the no-op cases, the disabled-snapshots filtering of /undo and /snapshots, and that App.SnapshotsEnabled() answers the runtime-capability question without needing an active session.

@dgageot dgageot requested a review from a team as a code owner May 7, 2026 10:13
@dgageot dgageot merged commit e720bf9 into docker:main May 7, 2026
8 checks passed
@docker-agent
Copy link
Copy Markdown

PR Review Failed — The review agent encountered an error and could not complete the review. View logs.

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