Skip to content

refactor(commands): move /compact and /context-max onto StatefulCommand - #2133

Merged
will-lamerton merged 2 commits into
mainfrom
refactor/command-dispatcher-compact
Nov 11, 2026
Merged

will-lamerton merged 2 commits into
mainfrom
refactor/command-dispatcher-compact

Conversation

@will-lamerton

Copy link
Copy Markdown
Member

PR 5a of the command-dispatcher sequence (#2098, #2114, #2116, #2122, #2128). The create subcommands follow in 5b, after #2132.

What changed

  • /compact and /context-max are now StatefulCommands that hold their own logic in source/commands/{compact,context-max}.ts.
    • handlers/compact-handler.ts and handlers/context-max-handler.ts are deleted.
    • The dispatcher's handler chain loses both steps.
  • These were the last createStubCommand stubs, so create-stub-command.ts is deleted. No built-in command module is an empty stub any more.
  • Timer completions are gone from these commands. Each setTimeout(() => onCommandComplete?.(), DELAY_COMMAND_COMPLETE_MS) (10 in compact, 4 in context-max) is now a returned 'done-after-render'. Each immediate onCommandComplete?.() is a returned 'done'. The one remaining after-render timer lives in the dispatcher's completeCommand.
  • CommandContext gains setMessages, client, providerConfig and onceThreshold. The dispatcher passes the ?threshold= value it parsed through to the command, so /compact ?threshold=80 keeps its gate.
  • The flag list from the old compact.ts stub stays as the command's doc comment.
  • CLAUDE.md is updated.

Behaviour

No change intended. Both commands read the same split arguments as before: the post-override tokens for /compact, the raw split for /context-max.

Tests

  • context-max-handler.spec.ts moves to source/commands/context-max.spec.ts. It calls contextMaxCommand.run, keeps the same assertions, and also checks the completion it returns.
  • New dispatcher specs:
    • /context-max 64k sets the session limit and completes after render.
    • /compact with no messages completes at once.
    • /compact --auto-off completes after render.
  • Existing app-util.spec compact tests pass unchanged, including both ?threshold= gate cases and ?context-max.
  • 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 the auto-compact and inline-override utils (1486 tests).

🤖 Generated with Claude Code

Their logic moves from app/utils/handlers/ into the command modules,
which were the last createStubCommand stubs, so create-stub-command.ts is
deleted. Every completion that was a setTimeout(onCommandComplete, 100)
is now a returned 'done-after-render', and the immediate ones 'done'.
CommandContext gains setMessages, client, providerConfig and
onceThreshold, which the dispatcher now passes through for /compact
?threshold=.

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.

…atcher-compact

# Conflicts:
#	source/app/utils/command-dispatcher.spec.ts
@will-lamerton
will-lamerton merged commit 0395ac5 into main Nov 11, 2026
18 checks passed
@will-lamerton
will-lamerton deleted the refactor/command-dispatcher-compact branch November 11, 2026 21:02
jay23606 added a commit to jay23606/nanocoder that referenced this pull request Nov 12, 2026
…nd (Nano-Collective#2133)

Their logic moves from app/utils/handlers/ into the command modules,
which were the last createStubCommand stubs, so create-stub-command.ts is
deleted. Every completion that was a setTimeout(onCommandComplete, 100)
is now a returned 'done-after-render', and the immediate ones 'done'.
CommandContext gains setMessages, client, providerConfig and
onceThreshold, which the dispatcher now passes through for /compact
?threshold=.

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