feat(tui): add /undo as an alias for /rewind (#698)#747
Conversation
/undo was unregistered and fell through to commandUnknown. Add it to the /rewind command's aliases (the same mechanism /quit, /find, /mcp-status use), so it dispatches to the existing rewind handler with args intact.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 1 minute Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe TUI adds ChangesUndo command alias
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/tui/commands_test.go`:
- Around line 1000-1001: Add a regression assertion alongside the existing
parseCommand("/undo latest") test in commands_test.go, covering a numeric
argument such as "/undo 123". Verify it produces commandRewind and preserves
"123" as parsed.text.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7b95b205-6bac-4474-b07f-2673995c880e
📒 Files selected for processing (2)
internal/tui/commands.gointernal/tui/commands_test.go
Zero automated PR reviewVerdict: No blockers found Blockers
Validation
ScopeHead: This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality. |
Add a parseCommand("/undo 123") assertion so both the latest and numeric
<sequence> forms of the /rewind contract are exercised through the alias.
|
Added in ecce5d9 — @coderabbitai review |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== PR diff =='
git diff --find-renames origin/"$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')" ...HEAD -- internal/tui/commands.go internal/tui/commands_test.go || true
echo '== Recent relevant commits =='
git log --oneline -8 -- internal/tui/commands.go internal/tui/commands_test.go
echo '== File structure =='
ast-grep outline internal/tui/commands.go --items all
ast-grep outline internal/tui/commands_test.go --items all --match 'TestUndoAliasesRewind|parseCommand|resolve'
echo '== Alias and command resolution references =='
rg -n -C 5 -P 'commandRewind|"/rewind"|"/undo"|func\s+(parseCommand|resolveCommand)\s*\(' internal/tui
echo '== Focused test block =='
rg -n -A 55 -B 8 -P 'func\s+TestUndoAliasesRewind\s*\(' internal/tui/commands_test.goLength of output: 15722 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== Command parsing, resolution, listing, and help implementation =='
sed -n '380,535p' internal/tui/commands.go
echo '== Command name list call sites (autocomplete/discoverability) =='
rg -n -C 6 -P '\blistCommandNames\s*\(' internal/tui
echo '== Help rendering call sites =='
rg -n -C 5 -P '\b(formatCommandHelp(Line|Lines)|formatGroupedCommandHelp(Lines)?)\s*\(' internal/tui
echo '== Existing alias-focused tests and command-list/help tests =='
rg -n -C 8 -P 'aliases|alias|listCommandNames|formatCommandHelp|GroupedCommandHelp|/find|/resume' internal/tui/*_test.go
echo '== PR commit patches =='
git show --format=fuller --find-renames --stat a053a6a -- internal/tui/commands.go internal/tui/commands_test.go
git show --format=fuller --find-renames --stat ecce5d9 -- internal/tui/commands.go internal/tui/commands_test.go
git show --format= --find-renames a053a6a -- internal/tui/commands.go internal/tui/commands_test.go
git show --format= --find-renames ecce5d9 -- internal/tui/commands.go internal/tui/commands_test.goLength of output: 63908 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== Autocomplete implementation and alias matching =='
rg -n -A 100 -B 10 -P 'func\s+(matchCommandSuggestions|commandSuggestion|suggestionNames)\s*\(' internal/tui
echo '== Command submission/dispatch context =='
sed -n '4270,4350p' internal/tui/model.go
rg -n -A 55 -B 10 -P 'func\s+.*(submit|handle).*Command|parseCommand\s*\(' internal/tui/model.go
echo '== Relevant autocomplete test coverage =='
sed -n '1,85p' internal/tui/autocomplete_test.go
sed -n '65,115p' internal/tui/commands_test.goLength of output: 33445
✅ Action performedReview finished.
|
anandh8x
left a comment
There was a problem hiding this comment.
No actionable findings. The /undo alias correctly resolves to the existing rewind command, preserves bare, latest, and numeric-sequence forms, and integrates with the existing help/autocomplete alias machinery. All reported CI checks pass.
Vasanthdev2004
left a comment
There was a problem hiding this comment.
Approving. /undo is added as an alias on the /rewind definition, which the resolver already honors (the same aliases path used by /find, /sc, /quit at commands.go:427). The test is end-to-end: it asserts /undo resolves to the rewind command, that /undo latest and /undo 123 parse to commandRewind with the argument intact, and that bare /undo is no longer commandUnknown. Small and correct, with no behavior change to /rewind itself.
Summary
Closes #698.
/undowas never registered as a command, so typing it fell through tocommandUnknown. Zero already has/rewind, which restores workspace files to a checkpoint and truncates the session — exactly "undo".Change
Add
/undoto the/rewindcommand'saliases, using the same alias mechanism already used by/quit→/exit,/find→/search, and/mcp-status→/mcp.resolveCommandmatches aliases, so/undonow dispatches to the existing rewind handler with its arguments intact (/undo,/undo latest,/undo <sequence>), and it appears in command autocomplete/help for free.Scope
internal/tuionly. One line of behavior. No change to any existing command.Testing
TestUndoAliasesRewind:/undoresolves to the same command kind as/rewind, andparseCommand("/undo latest")yieldscommandRewindwithtext=latest. Confirmed to fail without the alias (it resolves tocommandUnknown).make fmt-check,go vet ./...,go test -race ./internal/tui/...,go run ./cmd/zero-release build,go run ./cmd/zero-release smoke,govulncheck,git diff HEAD --checkall clean.Summary by CodeRabbit
/undoas an alias for the existing/rewindcommand./undo latest.