Skip to content

feat(queue): support queuing /compact#3

Merged
mirsella merged 2 commits into
mirsella:mainfrom
Simpidbit:main
Jun 10, 2026
Merged

feat(queue): support queuing /compact#3
mirsella merged 2 commits into
mirsella:mainfrom
Simpidbit:main

Conversation

@Simpidbit

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for queuing OpenCode's built-in TUI /compact command.

New supported forms:

  • /queue /compact
  • /queue front /compact
    This makes it possible to schedule a compact operation while the current agent run is still busy, instead of waiting for the session to become idle first.

Why

/compact is a built-in TUI command, not a regular session slash command. Because of that, replaying it through the existing client.session.command(...) path does not work the same way as user-defined commands such as /review.
This PR treats /compact as a dedicated queue item so it can be handled through the appropriate OpenCode APIs.

Changes

  • Add a new internal compact queue item kind.
  • Parse /queue /compact and /queue front /compact explicitly.
  • Reject unsupported /compact arguments and attachments instead of silently dropping them.
  • Replay queued compact items with client.session.summarize(...), targeting the original session ID.
  • Execute immediate idle /queue /compact requests through the TUI command path.
  • Document the new syntax in the README.

Implementation Notes

Queued replay uses client.session.summarize(...) instead of a TUI command event because TUI commands operate on the focused session, while queued work must target the original session that created the queue item.
Immediate /queue /compact execution still goes through the TUI command path so it behaves like OpenCode's built-in /compact command when the session is already idle.

Validation

  • npm run typecheck
  • git diff --check
  • I tried the /queue /compact and /queue front /compact in person, and it worked well.

Notes

This PR intentionally documents only the prefix forms:

  • /queue /compact
  • /queue front /compact
    It does not document /compact /queue, because OpenCode may consume built-in slash commands in the TUI before they reach plugin hooks.

@mirsella

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1202f2c60a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread index.ts Outdated
}

if (op.kind === "compact") {
await tuiCommand("session_compact")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the TUI command id accepted by OpenCode

When /queue /compact is used while the session is idle, this path sends session_compact to client.tui.executeCommand, but OpenCode's TUI command event type lists the executable command as session.compact while session_compact is only the keybind config name. In that idle prefix-command scenario, the new /compact support will fail instead of compacting; the queued replay path already bypasses this by calling session.summarize directly.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against latest anomalyco/opencode at 97e713e8a. The review conclusion is false for client.tui.executeCommand: packages/opencode/src/server/routes/instance/httpapi/handlers/tui.ts defines commandAliases.session_compact = "session.compact", and executeCommand publishes that alias mapping. The canonical event id is indeed session.compact, but session_compact is the accepted HTTP execute-command input alias. I kept the PR on session_compact and added a named constant so this is explicit.

@mirsella mirsella merged commit e8ef705 into mirsella:main Jun 10, 2026
1 check passed
@mirsella

Copy link
Copy Markdown
Owner

thanks !

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.

2 participants