feat(queue): support queuing /compact#3
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 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".
| } | ||
|
|
||
| if (op.kind === "compact") { | ||
| await tuiCommand("session_compact") |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
thanks ! |
Summary
This PR adds support for queuing OpenCode's built-in TUI
/compactcommand.New supported forms:
/queue /compact/queue front /compactThis 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
/compactis a built-in TUI command, not a regular session slash command. Because of that, replaying it through the existingclient.session.command(...)path does not work the same way as user-defined commands such as/review.This PR treats
/compactas a dedicated queue item so it can be handled through the appropriate OpenCode APIs.Changes
/queue /compactand/queue front /compactexplicitly./compactarguments and attachments instead of silently dropping them.client.session.summarize(...), targeting the original session ID./queue /compactrequests through the TUI command path.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 /compactexecution still goes through the TUI command path so it behaves like OpenCode's built-in/compactcommand when the session is already idle.Validation
npm run typecheckgit diff --check/queue /compactand/queue front /compactin person, and it worked well.Notes
This PR intentionally documents only the prefix forms:
/queue /compact/queue front /compactIt does not document
/compact /queue, because OpenCode may consume built-in slash commands in the TUI before they reach plugin hooks.