Skip to content

fix(tui): defer queued agent and model selection until delivery - #54779

Closed
pedropombeiro wants to merge 4 commits into
anomalyco:devfrom
pedropombeiro:queue-selection
Closed

pedropombeiro wants to merge 4 commits into
anomalyco:devfrom
pedropombeiro:queue-selection

Conversation

@pedropombeiro

@pedropombeiro pedropombeiro commented Oct 12, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #48356.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Fixes the existing queue interaction: selecting Plan and pressing Ctrl+X, then Enter no longer changes an active Build task. Queued prompts capture the selected agent, model, and variant and apply them when delivered. Configured commands queued with the keybinding use the same deferred selection.

The runner prepares the target selection before consuming the input. Failed preparation leaves it pending and cancellable. API callers can supply optional agent and model fields; omitted fields retain existing behavior. Steered selections apply at the next safe step boundary.

This PR does not add a /queue slash command.

How did you verify your code works?

  • bun run check passed across all 36 type-check tasks.
  • 302 core runner/prompt/configured-command tests passed, including queue and steer delivery, cancellation, replay, and unavailable selections.
  • All four focused TUI tests passed: the queue keybinding, queued configured commands, unavailable models, and rejected-admission draft recovery.
  • The earlier full TUI run reported five timeout failures and one unhandled error. All affected tests passed on a focused rerun.
  • Documentation build passed. Schema, HTTP admission, and generated-contract checks passed during development.

Screenshots / recordings

The automated review includes before/after screenshots and confirms the queue-keybinding fix with a simulated model. Screenshots courtesy of the OpenCode review bot.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@pedropombeiro pedropombeiro changed the title fix(tui): defer queued agent and model selection until delivery feat(tui): add /queue with deferred agent and model selection Oct 12, 2026

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This fixes the problem. I checked it with opencode-drive and the simulated model: during a Build turn held on a shell call, I pressed Shift+Tab to Plan and queued a prompt with Ctrl+X, Enter. On the base, the session switches to Plan at once and the rest of the running Build turn finishes as Plan. With this PR the running turn stays on Build, and the switch to Plan happens only when the queued prompt is delivered. /queue <message> behaves the same way. The 22 core runner tests matching "queued" pass, the server queue test passes, and the core and TUI type checks are clean.

Public API changes, all additions and backwards compatible:

  • POST /session/{id}/prompt and POST /session/{id}/command accept optional agent and model (with variant). The same fields are added to the generated client's SessionPromptInput/SessionCommandInput and to the OpenAPI spec.
  • Session.Inbox.UserPayload gains optional agent and model, which are stored with the inbox entry.
  • The plugin CommandInvocation.prompt (effect and promise) gains optional agent and model.
  • The TUI adds a built-in /queue <message> command. It takes priority over any user-configured command named queue.
  • One behaviour change: configured commands with an agent/model, sent with delivery: "queue", no longer switch the session straight away.

The main thing to fix: the new TUI test's unavailable case is flaky (see the inline comment). One behaviour to note: the API also accepts agent/model on steer delivery, which then switches the agent or model mid-turn. If that isn't intended, please reject or ignore these fields unless delivery is queue.

Before

After

@pedropombeiro pedropombeiro changed the title feat(tui): add /queue with deferred agent and model selection fix(tui): defer queued agent and model selection until delivery Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: v2 SDK: bind agent/model/variant options to queued prompts

1 participant