test(cli): Cover rewind selection and confirm flow#5044
Conversation
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
wenshao
left a comment
There was a problem hiding this comment.
The handleRewindConfirm branch where (userItem as HistoryItemUser).promptId is falsy (AppContainer.tsx:2562-2567 — "Cannot restore files: this turn was created before file checkpointing was enabled.") has no test coverage. The rewindUserItem helper always provides a promptId, so this error path is unreachable from the current tests. Consider adding a case that passes a user item without promptId and asserts the error message.
— qwen3.7-max via Qwen Code /review
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
|
@qwen-code /triage |
|
Thanks for the PR! Template looks good ✓ — all required sections present, bilingual, linked to #4187. On direction: clearly aligned. Issue #4187 explicitly calls for automated coverage of the rewind selector and On approach: the scope matches the issue's acceptance criteria closely. The Moving on to code review and testing. 🔍 中文说明感谢贡献! 模板完整 ✓ — 所有必需部分齐全,双语,已关联 #4187。 方向:明确对齐。Issue #4187 明确要求为 #4064 引入的 rewind selector 和 方案:范围与 issue 的验收标准紧密对应。 进入代码审查和测试 🔍 — Qwen Code · qwen3.7-max |
2a. Code ReviewReviewed the diff against the source implementations of RewindSelector.test.tsx — the new tests fill real gaps:
AppContainer.test.tsx — the
No critical issues found. No AGENTS.md violations — follows existing test conventions (collocated 2b. Test ExecutionThis is a test-only PR with no user-visible behavior changes, so tmux UI capture is N/A. Verification is the test suite itself: All green. ✅ 中文说明2a. 代码审查对照 RewindSelector.test.tsx — 新增测试填补了真实缺口:
AppContainer.test.tsx —
未发现关键问题。无 AGENTS.md 违规——遵循现有测试约定(collocated 2b. 测试执行这是纯测试 PR,无用户可见行为变更,tmux UI 捕获为 N/A。验证即为测试套件本身:所有测试通过,typecheck 通过。✅ — Qwen Code · qwen3.7-max |
|
This is a clean, well-scoped test coverage PR. It closes #4187 by adding regression tests for the two rewind surfaces from #4064 — What I liked:
No concerns. The diff is test-only, follows existing conventions, and all 99 tests + typecheck pass. Approving. ✅ 中文说明这是一个干净、范围合理的测试覆盖 PR。它关闭 #4187,为 #4064 引入的两个 rewind 表面—— 优点:
无顾虑。纯测试变更,遵循现有约定,99 个测试 + typecheck 全部通过。 批准。✅ — Qwen Code · qwen3.7-max |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
Runtime verification (real CLI in tmux + mutation testing)Verdict: solid test-only PR — the new tests pass, are not flaky, have real teeth (they catch regressions in the production rewind code), and assert behavior that matches the real CLI. Recommend merge. One tiny optional follow-up below. Since this is a test-only change (+453 lines, no production code), "verification" means three things beyond "does CI go green": do the tests actually exercise the code paths they claim (teeth), do they assert correct behavior, and are they stable. I checked all three. Harness
1. Tests pass and are stable
2. The tests have teeth (mutation testing)I injected a targeted bug into the production rewind code for each major branch and confirmed the matching test fails (genuine assertion failures, not compile errors), then reverted. A test that stays green under a real bug is vacuous coverage — none of these are.
6/6 mutations across both files were caught. The tests genuinely lock down the rewind orchestration and the selector's key handling. 3. The tests assert real behavior (tmux cross-check)To make sure the assertions aren't internally-consistent-but-wrong, I drove the actual rewind flow in the real TUI (two prompts →
Every behavior the tests assert reproduces in the real CLI. Minor (optional, non-blocking)Of the 10 user-facing messages in ConclusionThe PR does what it claims for #4187: it adds focused, non-flaky regression coverage for the rewind selector and the rewind-confirm orchestration, the coverage is real (mutation-proven), and it matches actual CLI behavior. Looks good to merge. 中文版(点击展开)本地真实运行验证(tmux 真实 CLI + 变异测试)结论:这是一个扎实的纯测试 PR——新增测试通过、不 flaky、有真正的“咬合力”(能抓住生产 rewind 代码的回归),且断言的行为与真实 CLI 一致。建议合并。 下面有一个很小的可选 follow-up。 由于这是纯测试改动(+453 行,无生产代码),“验证”除了“CI 是否变绿”之外还意味着三件事:测试是否真的覆盖了它声称的代码路径(咬合力)、是否断言了正确的行为、是否稳定。我把这三点都查了。 测试环境
1. 测试通过且稳定
2. 测试有“咬合力”(变异测试)我针对每个主要分支往生产 rewind 代码里注入一个有针对性的 bug,确认对应测试失败(是真正的断言失败,不是编译错误),然后还原。一个在真实 bug 下仍然变绿的测试就是空覆盖——这里没有一个是空的。
两个文件共 6/6 变异全部被抓住。测试确实锁住了 rewind 编排逻辑和 selector 的按键处理。 3. 测试断言的是真实行为(tmux 交叉验证)为确认断言不是“自洽但错误”,我在真实 TUI 里走了一遍 rewind 流程(两个 prompt →
测试断言的每个行为都能在真实 CLI 中复现。 次要(可选,不阻塞合并)
结论这个 PR 实现了 #4187 的目标:为 rewind selector 和 rewind-confirm 编排增加了聚焦、不 flaky 的回归覆盖,覆盖是真实的(变异测试已证明),且与真实 CLI 行为一致。可以合并。 |
What this PR does
This PR adds focused regression coverage for the rewind selector flow and the rewind confirmation orchestration. The tests now cover selector navigation and cancel paths, restore option fallback states, the restoring keypress guard, and the main rewind confirmation branches for code, conversation, combined restore, no-client fallback, compressed turns, and file restore failures.
Why it's needed
Issue #4187 tracks missing automated coverage for rewind behavior that was previously verified manually. These paths coordinate UI state, file checkpoint restore, API history truncation, buffer prefill, and chat recording updates, so focused tests reduce the risk of future regressions leaving files and conversation history out of sync.
Reviewer Test Plan
How to verify
Run
cd packages/cli && npx vitest run src/ui/components/RewindSelector.test.tsx src/ui/AppContainer.test.tsxand expect both test files to pass, including the new rewind selector and handleRewindConfirm cases. Runnpm run typecheckfrom the repository root and expect TypeScript checks to complete successfully across workspaces.Evidence (Before & After)
N/A. This is a non-user-visible test coverage change.
Tested on
Environment (optional)
Node.js v22.22.3, npm 10.9.8.
Risk & Scope
Linked Issues
Closes #4187
中文说明
What this PR does
这个 PR 为 rewind selector 流程和 rewind confirm 编排逻辑增加了聚焦的回归测试。测试现在覆盖 selector 导航和取消路径、restore options 的 fallback 状态、restoring 状态下的按键屏蔽,以及 code、conversation、both restore、no-client fallback、compressed turn、file restore failure 等主要 rewind confirm 分支。
Why it's needed
Issue #4187 追踪的是 rewind 行为缺少自动化覆盖的问题,此前这些路径主要依赖手工验证。这些路径会同时协调 UI 状态、文件 checkpoint 恢复、API history 截断、buffer 预填和 chat recording 更新,因此聚焦测试可以降低未来回归导致文件和对话历史状态不一致的风险。
Reviewer Test Plan
How to verify
运行
cd packages/cli && npx vitest run src/ui/components/RewindSelector.test.tsx src/ui/AppContainer.test.tsx,预期两个测试文件都通过,并包含新增的 rewind selector 和 handleRewindConfirm 用例。然后在仓库根目录运行npm run typecheck,预期所有 workspace 的 TypeScript 检查成功完成。Evidence (Before & After)
N/A。这是非用户可见的测试覆盖改动。
Tested on
Environment (optional)
Node.js v22.22.3,npm 10.9.8。
Risk & Scope
Linked Issues
Closes #4187