Background
PR #4064 added two large rewind-related code paths with no direct test coverage:
-
packages/cli/src/ui/components/RewindSelector.tsx (≈239 LOC) — a 3-phase Ink component:
- Pick list — select which user turn to rewind to
- Restore options — choose code/conversation/both with async diff stats loading
- Legacy confirm — Y/N fallback when
fileCheckpointingEnabled is false
Plus an isRestoring keypress-guard state surfaced as a Spinner while onRewind is awaited.
-
packages/cli/src/ui/AppContainer.tsx#handleRewindConfirm (~140 LOC) — orchestrates the post-selection flow:
- Pre-validates conversation truncation before touching files for
'both' mode
- Routes the file-restore call (with proper
truncateHistory flag)
- Surfaces no-client / partial-failure / unrecoverable-snapshot errors via the history manager
- Skips conversation truncation when file restore partially fails (avoids inconsistent state)
- Falls through to a clean error path when the whole flow throws
The component / orchestration have been manually verified end-to-end via tmux-driven REPL sessions (see PR #4064 "Automated verification results" section), but there is no automated regression coverage.
Why this is a follow-up, not part of #4064
Both surfaces require similar testing scaffolding the repo does not yet use:
- An
ink-testing-library setup (rendering, keypress simulation, snapshot/text assertion) for RewindSelector
- A heavier
AppContainer mock harness — config / geminiClient / historyManager / fileHistoryService — for handleRewindConfirm
Building both layers together is the right shape (≈350-500 LOC of new test code plus a one-time pattern pass for ink-testing patterns) but bundling it into the rewind PR (already 30+ commits and several review rounds) significantly delays the merge for in-session functionality that has been manually verified.
Acceptance criteria
RewindSelector.test.tsx
handleRewindConfirm tests (in AppContainer.test.tsx or a focused harness)
Related
🤖 Generated with Qwen Code
Background
PR #4064 added two large rewind-related code paths with no direct test coverage:
packages/cli/src/ui/components/RewindSelector.tsx(≈239 LOC) — a 3-phase Ink component:fileCheckpointingEnabledis falsePlus an
isRestoringkeypress-guard state surfaced as aSpinnerwhileonRewindis awaited.packages/cli/src/ui/AppContainer.tsx#handleRewindConfirm(~140 LOC) — orchestrates the post-selection flow:'both'modetruncateHistoryflag)The component / orchestration have been manually verified end-to-end via tmux-driven REPL sessions (see PR #4064 "Automated verification results" section), but there is no automated regression coverage.
Why this is a follow-up, not part of #4064
Both surfaces require similar testing scaffolding the repo does not yet use:
ink-testing-librarysetup (rendering, keypress simulation, snapshot/text assertion) forRewindSelectorAppContainermock harness — config / geminiClient / historyManager / fileHistoryService — forhandleRewindConfirmBuilding both layers together is the right shape (≈350-500 LOC of new test code plus a one-time pattern pass for ink-testing patterns) but bundling it into the rewind PR (already 30+ commits and several review rounds) significantly delays the merge for in-session functionality that has been manually verified.
Acceptance criteria
RewindSelector.test.tsxRestoreOptioncorrectlygetDiffStatssuccess populates the(+N -M in K files)detail stringgetDiffStatsrejection falls back to undefineddiffStatswithout crashingisRestoringblocks all keypresses including Escape (per the upstream-parity decision in PR feat(rewind): add file restoration support to /rewind command #4064)fileCheckpointingEnabledis falsegetRestoreOptions(...)doesn't include code/bothhandleRewindConfirmtests (inAppContainer.test.tsxor a focused harness)'both'mode with file restore failure skips conversation truncation'both'mode with file restore success still truncates conversation'code'only mode does NOT truncate history'conversation'only mode does NOT callgetFileHistoryService().rewind'conversation'shows error and returns;'both'flips into code-only with the warning history itemhistoryManager.addItemoftype: 'error'apiTruncateIndex < 0adds the t-wrapped error and bailsRelated
handleRewindConfirm:🤖 Generated with Qwen Code