Skip to content

Add chat.message fallback for /dcp-compress when host skips command registration - #610

Open
1kUnD0G wants to merge 1 commit into
Opencode-DCP:masterfrom
1kUnD0G:fix/chat-message-compress-fallback
Open

Add chat.message fallback for /dcp-compress when host skips command registration#610
1kUnD0G wants to merge 1 commit into
Opencode-DCP:masterfrom
1kUnD0G:fix/chat-message-compress-fallback

Conversation

@1kUnD0G

@1kUnD0G 1kUnD0G commented Aug 21, 2026

Copy link
Copy Markdown

Fixes #609

Problem

On recent OpenCode versions (post Effect-refactor), the slash-command list is built as a one-shot snapshot in packages/opencode/src/command/index.ts before plugin config hooks run. DCP registers /dcp-compress inside its config hook, so the registration lands after the snapshot was taken and never gets picked up: the command is missing from autocomplete and typing it manually just sends a plain user message.

Fix

Add a "chat.message" hook as a fallback path:

  • When a user message's first non-ignored/non-synthetic text part starts with /dcp-compress, run the same manual-trigger flow as the slash command (handleManualTriggerCommand -> state.manualMode = "compress-pending" -> state.pendingManualTrigger), which the existing applyPendingManualTrigger consumes on the next messages transform.
  • Normalize the stored text to the canonical /dcp-compress [focus] marker so downstream pruning/summary logic sees exactly what the slash-command path emits.
  • Skip when state.pendingManualTrigger already exists (the real slash-command path ran and set it), when commands.enabled is false, or when compress permission resolves to deny.

This makes /dcp-compress work even when the host never registered the command, with zero behavior change on hosts where registration works normally.

Verification

  • npm run build passes (tsup + tsc).
  • Full test suite: 103/103 pass.
  • Behavioral check against the built bundle:
    • plain messages are untouched;
    • /dcp-compress <focus> fetches session state, sets the pending trigger, and normalizes the marker;
    • a second invocation while a trigger is pending is skipped;
    • ignored/synthetic parts are not intercepted.
  • README documents the snapshot-timing caveat and the opencode.json workaround for restoring autocomplete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/dcp-compress slash command not registered on recent OpenCode versions (command snapshot timing)

1 participant