Compare commits

...
2 Commits
Author SHA1 Message Date
KRATOS ecce5d9374 test(tui): cover the /undo numeric-sequence form (#698 review)
Add a parseCommand("/undo 123") assertion so both the latest and numeric
<sequence> forms of the /rewind contract are exercised through the alias.
2026-07-19 11:06:45 +05:30
KRATOS a053a6a8f0 feat(tui): add /undo as an alias for /rewind (#698)
/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.
2026-07-19 10:51:09 +05:30
2 changed files with 26 additions and 0 deletions

No files matched your search

+1
View File
@@ -253,6 +253,7 @@ var commandDefinitions = []commandDefinition{
},
{
name: "/rewind",
aliases: []string{"/undo"},
usage: "/rewind [latest|<sequence>]",
group: commandGroupSession,
description: "Restore workspace files to a checkpoint and truncate the session.",
+25
View File
@@ -985,6 +985,31 @@ func TestParseBackgroundTerminalCommands(t *testing.T) {
}
}
// /undo is an alias for /rewind (issue #698): previously it fell through to
// commandUnknown.
func TestUndoAliasesRewind(t *testing.T) {
rewind, ok := resolveCommand("/rewind")
if !ok {
t.Fatal("expected /rewind to resolve")
}
alias, ok := resolveCommand("/undo")
if !ok || alias.kind != rewind.kind {
t.Fatalf("expected /undo to alias /rewind, got ok=%v command=%#v", ok, alias)
}
// End-to-end: a typed /undo dispatches to the rewind handler with args intact,
// for both the "latest" and numeric-<sequence> forms of the /rewind contract.
if parsed := parseCommand("/undo latest"); parsed.kind != commandRewind || parsed.text != "latest" {
t.Fatalf("parseCommand(%q) = %#v, want commandRewind with text=latest", "/undo latest", parsed)
}
if parsed := parseCommand("/undo 123"); parsed.kind != commandRewind || parsed.text != "123" {
t.Fatalf("parseCommand(%q) = %#v, want commandRewind with text=123", "/undo 123", parsed)
}
// Guard: without the alias it would be commandUnknown.
if parsed := parseCommand("/undo"); parsed.kind == commandUnknown {
t.Fatal("/undo resolved to commandUnknown — the alias is not wired")
}
}
func TestCommandSelectionRequiresInputFromUsage(t *testing.T) {
cases := []struct {
name string