Repository navigation
fix(tui): auto-submit --prompt once agents and models load - #51137
Closed
ibuildthecloud wants to merge 1 commit into
Closed
ibuildthecloud wants to merge 1 commit into
ibuildthecloud wants to merge 1 commit into
Conversation
`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>
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #51135
Type of change
What does this PR do?
opencode --promptstopped auto-submitting on the home screen in 2.0. The home auto-submit effect runs once and only waits forlocal.model.ready, which just means model.json was read. It usually fires before agents and models arrive from the server, sosubmit()returns early atif (!agent) return falseand never retries.The session route's copy of this effect already handles this race (#38260, #40913) by also waiting for
local.model.catalogReadyand 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.tsxthat holds back/api/agentuntil the draft is on screen, then checks the prompt is sent exactly once. It fails onv2and passes with this change.bun typecheckpasses inpackages/tui.Screenshots / recordings
N/A (no visual change)
Checklist
🤖 Generated with Claude Code