Skip to content

Register compact command in slash commands palette and registry - #1265

Open
nordicnode wants to merge 1 commit into
CodebuffAI:mainfrom
nordicnode:feat-compact-slash-command
Open

Register compact command in slash commands palette and registry#1265
nordicnode wants to merge 1 commit into
CodebuffAI:mainfrom
nordicnode:feat-compact-slash-command

Conversation

@nordicnode

Copy link
Copy Markdown

Summary

  • Register the /compact (and alias /summarize) slash command in cli/src/data/slash-commands.ts and cli/src/commands/command-registry.ts.
  • Enables user discovery and autocomplete for manual context compaction to reclaim token budget.
  • Implements handleCompactCommand in cli/src/commands/compact.ts with early empty-history bailout (Nothing to compact — the conversation is empty.) and mid-turn queue safety (params.addToQueue).
  • Adds unit test coverage in cli/src/commands/__tests__/compact-command.test.ts (8 test cases) and updates cli/src/commands/__tests__/command-args.test.ts.

Test plan

[✓] bun test --config=/dev/null --preload ../sdk/test/setup-env.ts src/commands/__tests__/compact-command.test.ts
[✓] bun test --config=/dev/null --preload ../sdk/test/setup-env.ts src/commands/__tests__/router-input.test.ts
[✓] bun test --config=/dev/null --preload ../sdk/test/setup-env.ts src/commands/__tests__/command-args.test.ts
[✓] bun test --config=/dev/null --preload ../sdk/test/setup-env.ts src/data/slash-commands.test.ts
[✓] bun run --cwd cli typecheck
[✓] bun run build:sdk
[✓] bun freebuff/cli/build.ts 0.0.0-ci
[✓] bun cli/scripts/smoke-binary.ts cli/bin/freebuff
[✓] PR hygiene check passed

- Add compact slash command with summarize alias to ALL_SLASH_COMMANDS in cli/src/data/slash-commands.ts.
- Define compact command in ALL_COMMANDS via defineCommand in cli/src/commands/command-registry.ts.
- Implement handleCompactCommand in cli/src/commands/compact.ts with empty-history guard and mid-turn queue safety.
- Add unit test coverage in cli/src/commands/__tests__/compact-command.test.ts (8 test cases) and track in command-args.test.ts.
@codebuff-team

Copy link
Copy Markdown
Contributor

Nice, focused change that follows the established command pattern (mirrors export-conversation/copy-conversation style handlers) and comes with solid test coverage in compact-command.test.ts covering empty-history bailout, streaming queue, chain-in-progress queue, and alias resolution via findCommand/parseCommandInput. Registration in both slash-commands.ts (palette) and command-registry.ts (dispatch) is consistent and the command-args.test.ts update correctly reflects the new no-args command.

One thing worth double-checking before porting: handleCompactCommand in cli/src/commands/compact.ts doesn't perform any compaction itself — it just calls params.sendMessage({ content: '/compact', agentMode }), i.e. it forwards the literal string /compact as a chat message and relies on the agent runtime to recognize and act on it. If that server-side/agent-side interpretation doesn't already exist, this PR only adds UI discoverability without any actual compaction happening — the message would just be echoed as normal chat input. Please confirm (or link) where /compact is already special-cased in the agent runtime; if it isn't, this needs a companion change there.

Minor nit: the setTimeout(() => params.scrollToLatest(), 0) after sendMessage isn't awaited or covered by tests — worth confirming this pattern matches other commands (e.g. export-conversation.ts) for consistency.

Overall the CLI-side wiring is clean and in scope; flag the backend-behavior assumption for the maintainer doing the port.

@codebuff-team codebuff-team added bot:triaged Classified by the community triage bot pr:port-candidate Worth porting into the private source tree labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:triaged Classified by the community triage bot pr:port-candidate Worth porting into the private source tree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants