Skip to content

feat(tui): add /undo as an alias for /rewind (#698)#747

Merged
gnanam1990 merged 2 commits into
mainfrom
fix/undo-command
Jul 20, 2026
Merged

feat(tui): add /undo as an alias for /rewind (#698)#747
gnanam1990 merged 2 commits into
mainfrom
fix/undo-command

Conversation

@gnanam1990

@gnanam1990 gnanam1990 commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #698.

/undo was never registered as a command, so typing it fell through to commandUnknown. Zero already has /rewind, which restores workspace files to a checkpoint and truncates the session — exactly "undo".

Change

Add /undo to the /rewind command's aliases, using the same alias mechanism already used by /quit/exit, /find/search, and /mcp-status/mcp. resolveCommand matches aliases, so /undo now 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/tui only. One line of behavior. No change to any existing command.

Testing

  • TestUndoAliasesRewind: /undo resolves to the same command kind as /rewind, and parseCommand("/undo latest") yields commandRewind with text=latest. Confirmed to fail without the alias (it resolves to commandUnknown).
  • 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 --check all clean.

Summary by CodeRabbit

  • New Features
    • Added /undo as an alias for the existing /rewind command.
    • Supports undoing the latest action with /undo latest.
    • The new alias is displayed in command help and usage information.

/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.
@gnanam1990 gnanam1990 mentioned this pull request Jul 19, 2026
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: df9032a8-4369-463f-b763-35879eef4075

📥 Commits

Reviewing files that changed from the base of the PR and between a053a6a and ecce5d9.

📒 Files selected for processing (1)
  • internal/tui/commands_test.go

Walkthrough

The TUI adds /undo as an alias for /rewind and adds end-to-end coverage for alias resolution and argument parsing.

Changes

Undo command alias

Layer / File(s) Summary
Register and validate the undo alias
internal/tui/commands.go, internal/tui/commands_test.go
The /rewind command registers /undo; tests verify shared command resolution, rewind parsing, and preserved text arguments.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: anandh8x, kevincodex1, vasanthdev2004

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change: adding /undo as an alias for /rewind.
Linked Issues check ✅ Passed The PR satisfies issue #698 by wiring /undo to the existing /rewind command and adding coverage.
Out of Scope Changes check ✅ Passed The changes stay scoped to the requested /undo alias and its tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/undo-command

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ce4a996 and a053a6a.

📒 Files selected for processing (2)
  • internal/tui/commands.go
  • internal/tui/commands_test.go

Comment thread internal/tui/commands_test.go
@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Zero automated PR review

Verdict: No blockers found

Blockers

  • None found.

Validation

  • [pass] Diff hygiene: git diff --check
  • [pass] Tests: go test ./...
  • [pass] Build: go run ./cmd/zero-release build
  • [pass] Smoke build: go run ./cmd/zero-release smoke

Scope

Head: ecce5d937479
Changed files (2): internal/tui/commands.go, internal/tui/commands_test.go

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.
@gnanam1990

Copy link
Copy Markdown
Collaborator Author

Added in ecce5d9parseCommand("/undo 123") now asserts the numeric-<sequence> form resolves to commandRewind with the argument intact, alongside the existing /undo latest case.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
🧩 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.go

Length 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.go

Length 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.go

Length of output: 33445


@gnanam1990 Reviewed the update, including parseCommand("/undo 123"). The alias is correctly wired through resolution, dispatch, autocomplete, and help; both latest and numeric sequence arguments are preserved. No findings.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@anandh8x anandh8x left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Vasanthdev2004 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gnanam1990
gnanam1990 merged commit 8c6d302 into main Jul 20, 2026
9 checks passed
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.

add /undo command

3 participants