Skip to content

fix(tui): auto-submit --prompt once agents and models load - #51137

Closed
ibuildthecloud wants to merge 1 commit into
anomalyco:devfrom
ibuildthecloud:fix-prompt-autosubmit
Closed

ibuildthecloud wants to merge 1 commit into
anomalyco:devfrom
ibuildthecloud:fix-prompt-autosubmit

Conversation

@ibuildthecloud

Copy link
Copy Markdown

Issue for this PR

Closes #51135

Type of change

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

What does this PR do?

opencode --prompt stopped auto-submitting on the home screen in 2.0. The home auto-submit effect runs once and only waits for local.model.ready, which just means model.json was read. It usually fires before agents and models arrive from the server, so submit() returns early at if (!agent) return false and never retries.

The session route's copy of this effect already handles this race (#38260, #40913) by also waiting for local.model.catalogReady and a resolved agent and model. Home never got those checks, so this adds the same ones.

How did you verify your code works?

Added a test in packages/tui/test/app-lifecycle.test.tsx that holds back /api/agent until the draft is on screen, then checks the prompt is sent exactly once. It fails on v2 and passes with this change. bun typecheck passes in packages/tui.

Screenshots / recordings

N/A (no visual change)

Checklist

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

🤖 Generated with Claude Code

`opencode --prompt "..."` stopped auto-submitting on the home screen in
2.0: the text lands in the composer but the user has to press Enter.

The home route auto-submits --prompt from an effect that fires once (it
sets `sent = true` before calling `submit()`). It waits only for
`local.model.ready`, which means the model.json preferences file was read,
not that the server has returned agents and models. That read usually wins
the race, so `submitInner()` returns early at `if (!agent) return false`
and the effect never retries.

The home effect originally also waited for `sync.ready` (b312928,
anomalyco#7476); 0fa9e50 ("refactor(tui): reduce legacy sync usage") dropped
that. The session route's copy of the same auto-submit already fixed this
race in anomalyco#38260 (wait for a resolved agent and model) and anomalyco#40913 (wait for
`local.model.catalogReady`), but home was never updated. Use the same
conditions here.

Add a regression test that delays /api/agent until the draft is visible.

Closes anomalyco#51135

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

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

@thdxr
thdxr changed the base branch from v2 to dev October 10, 2026 19:17
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.

tui: --prompt no longer auto-submits in 2.0

1 participant