Skip to content

refactor(commands): move /stats and /login onto StatefulCommand - #2128

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

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

Conversation

@will-lamerton

Copy link
Copy Markdown
Member

PR 4 of the command-dispatcher sequence (#2098, #2114, #2116, #2122).

What changed

  • /stats and /login are now StatefulCommands in source/commands/{stats.tsx,login.ts}. handlers/stats-handler.ts and handlers/login-handler.ts are deleted, and the dispatcher's handler chain loses both steps.
  • CommandCompletion gains {until: Promise<void>} for a command that keeps running in a live component. The command resolves the promise from the component's close callback, and the dispatcher hands the prompt back when it settles. The dispatcher does not wait on it, so handleMessageSubmission still returns right after the component mounts, as before. Commands no longer reach onCommandComplete from inside a callback.
  • CommandContext gains setLiveComponent, setLiveComponentCapturesInput and setIsToolExecuting.
  • /login without a known target returns its usage through {show}, the same route the old stub's handler result took (queued, then completion after the render delay).
  • CLAUDE.md is updated.

Behaviour

No change intended:

  • /stats captures input and leaves a static snapshot when closed. /stats reset and its usage error behave as before.
  • /login codex|copilot [name] (and /codex-login, /copilot-login) sets tool-executing, mounts the device flow, and on finish clears it and reports success or error.

One timing detail: completion now lands one microtask after the close callback rather than inside it. Nothing reads app state between the two.

Tests

  • command-dispatcher.spec.ts:
    • /stats stays incomplete until its card closes, then releases input and completes once.
    • /login COPILOT Work Copilot keeps the provider name, toggles tool-executing, reports the error and completes when the flow finishes.
    • /login github shows the usage like a read-only command.
  • stats.spec.tsx now checks for run instead of the stub's handler.
  • Existing app-util.spec tests for stats capture/close, stats reset and every login alias 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/hooks, source/app/sections, source/plain and source/components/stats (1406 tests).

🤖 Generated with Claude Code

Both mount a live component and finish when it closes. They now return
{until: promise} and the dispatcher hands the prompt back when it
settles, instead of each handler calling onCommandComplete from its
close callback. CommandContext gains the live-component setters and
setIsToolExecuting. /login without a known target returns its usage
through {show}, as the stub handler's result was shown before. The
stats and login handlers are deleted.

No behaviour change.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions github-actions Bot added the area:tui Terminal UI label Nov 11, 2026
@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

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 98feabf into main Nov 11, 2026
19 checks passed
@will-lamerton
will-lamerton deleted the refactor/command-dispatcher-live branch November 11, 2026 19:38
jay23606 added a commit to jay23606/nanocoder that referenced this pull request Nov 12, 2026
…-Collective#2128)

Both mount a live component and finish when it closes. They now return
{until: promise} and the dispatcher hands the prompt back when it
settles, instead of each handler calling onCommandComplete from its
close callback. CommandContext gains the live-component setters and
setIsToolExecuting. /login without a known target returns its usage
through {show}, as the stub handler's result was shown before. The
stats and login handlers are deleted.

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