Skip to content

refactor(commands): move /checkpoint load, /resume and /retry onto StatefulCommand - #2122

Merged
will-lamerton merged 1 commit into
mainfrom
refactor/command-dispatcher-session
Nov 11, 2026
Merged

will-lamerton merged 1 commit into
mainfrom
refactor/command-dispatcher-session

Conversation

@will-lamerton

Copy link
Copy Markdown
Member

PR 3 of the command-dispatcher sequence (#2098, #2114, then #2116 for case-insensitive names).

What changed

  • /retry, /resume, /checkpoint now hold their own logic in source/commands/{retry,resume,checkpoint}. handlers/session-handler.ts, handlers/retry-handler.ts (and its spec) and handlers/checkpoint-load-handler.ts are deleted, and the dispatcher's handler chain loses those three steps.
  • CommandContext gains:
    • argText: the raw text after the command name, so /retry keeps its quote-aware parsing (--model "a b") and /resume and /checkpoint keep their raw split.
    • provider and model.
    • enterCheckpointLoadMode.
    • enterSessionSelectorMode, resumeSession and switchModel. These are optional, so the "not available in this context" messages still show.
    • submitChatMessage.
  • CommandCompletion gains two values:
    • 'handed-off': something the command started completes it. /retry hands off to the retried chat turn; a bare /checkpoint load hands off to the picker.
    • {show}: output shown exactly the way a read-only command's result is (queued on a microtask, completion after the render delay). /checkpoint returns its other subcommands this way, so it is one command instead of a render command plus an intercept.
  • The old handler body is exported as runCheckpointSubcommand.
  • CLAUDE.md is updated.

Behaviour

No change intended:

  • /retry still never signals completion itself.
  • /resume completes after the session switch finishes.
  • A bare /checkpoint load or restore (exact lowercase, exactly one argument) opens the picker; everything else renders as before.
  • /sessions and /history reach /resume through the alias table (fix(commands): match built-in slash command names in any case #2116).

Tests

  • command-dispatcher.spec.ts:
    • /retry hands off and never completes, and the dispatcher doesn't signal completion either. This replaces retry-handler.spec.ts.
    • /retry keeps a quoted --model value whole.
    • /checkpoint load with no checkpoints, and /checkpoint restore opening the picker without completing.
    • /checkpoint help shows like a read-only command.
  • checkpoint.spec.tsx now calls runCheckpointSubcommand instead of checkpointCommand.handler, with the same assertions throughout.
  • useAppHandlers.spec.tsx:
    • It now registers lazyCommands, as the app does at init and as app-util.spec already does, because /resume resolves through the registry.
    • Its /resume switch test polls on a 5 ms timer (up to 2 s) instead of 50 setImmediate turns, because loading the command module is real I/O. The assertions are unchanged.
  • All existing app-util.spec resume and retry tests pass unchanged.
  • Ran tsc --noEmit, biome check ., knip and knip --production --include files. AVA passes over source/app/utils, source/commands, commands.spec.ts, source/session (911 tests), plus source/hooks, source/app/sections and source/plain (640 tests).

🤖 Generated with Claude Code

…atefulCommand

Their logic moves from app/utils/handlers/ into the command modules, and
the session, checkpoint and retry handlers are deleted. CommandContext
gains argText (the raw text after the name, for quote-aware or raw-split
parsing), provider, model, the checkpoint and session setters,
switchModel and submitChatMessage. CommandCompletion gains 'handed-off'
(a chat turn or picker completes the command) and {show} (output shown
the way a read-only command's result is), which /checkpoint uses for
every subcommand except a bare load/restore.

No behaviour change.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

No changeset found

This PR does not add a changeset, so it will not appear in the changelog or trigger a release.

If the change is user-facing, add one:

pnpm changeset

Pick a bump (patch / minor / major) and write the changelog entry in our usual voice ("Added X... Thanks to @you. Closes #123."), then commit the generated .changeset/*.md file.

If this PR is docs-only or a chore that needs no release note, you can ignore this — or run pnpm changeset --empty to record that intentionally.

@github-actions github-actions Bot added the area:tui Terminal UI label Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

nc-review could not produce a verdict this run (agent exit 1). This is a problem with the review agent, not with your pull request. A maintainer can retry with /re-review.

@will-lamerton
will-lamerton merged commit f7dc45f into main Nov 11, 2026
19 checks passed
@will-lamerton
will-lamerton deleted the refactor/command-dispatcher-session branch November 11, 2026 19:21
jay23606 added a commit to jay23606/nanocoder that referenced this pull request Nov 12, 2026
…atefulCommand (Nano-Collective#2122)

Their logic moves from app/utils/handlers/ into the command modules, and
the session, checkpoint and retry handlers are deleted. CommandContext
gains argText (the raw text after the name, for quote-aware or raw-split
parsing), provider, model, the checkpoint and session setters,
switchModel and submitChatMessage. CommandCompletion gains 'handed-off'
(a chat turn or picker completes the command) and {show} (output shown
the way a read-only command's result is), which /checkpoint uses for
every subcommand except a bare load/restore.

No behaviour change.

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tui Terminal UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant