Skip to content

fix(tui): wait for agent and model before auto-submitting --prompt - #51938

Merged
rekram1-node merged 1 commit into
v2from
prompt-auto-submit
Sep 28, 2026
Merged

rekram1-node merged 1 commit into
v2from
prompt-auto-submit

Conversation

@rekram1-node

Copy link
Copy Markdown
Member

Type of change

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

What does this PR do?

opencode --prompt <text> fills the home screen prompt but often never sends it.

The home screen auto-submitted once model preferences were loaded (local.model.ready), but submit also needs the selected agent. When the agent list arrived later, submit returned early without sending, and because the auto-submit only runs once, the prompt was never retried.

The home screen now waits for the same readiness the session screen already requires before sending a startup prompt: the model catalog, the current agent, and the current model.

How did you verify your code works?

  • Added home startup prompt is submitted exactly once to packages/tui/test/app-lifecycle.test.tsx. It fails without the fix and passes with it; the full file passes.
  • bun typecheck in packages/tui.
  • Ran the TUI with --prompt against a local server; the prompt is sent.

Checklist

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

The home screen submitted --prompt once model preferences loaded, but submit
also needs the selected agent. When the agent list arrived later, submit
returned without sending and the prompt was never retried. Wait for the same
readiness the session screen already requires.
@rekram1-node
rekram1-node merged commit 8c1ce95 into v2 Sep 28, 2026
9 of 10 checks passed
@rekram1-node
rekram1-node deleted the prompt-auto-submit branch September 28, 2026 20:41
FrozenPandaz pushed a commit to nrwl/nx that referenced this pull request Nov 27, 2026
## Current Behavior

With OpenCode 2.x installed, the agentic flow of `nx migrate
--run-migrations` can't start the agent. Nx launches every OpenCode with
the 1.x arguments, and 2.x rejects one of them:

```
Unrecognized flag: --agent in command opencode
```

OpenCode exits at once and the migrate run stays active.

## Expected Behavior

Nx reads `opencode --version` and launches 1.x and 2.x with the
arguments each accepts. A 2.x session starts on OpenCode's Build agent
with Nx's instructions, even when a user config hides Build or makes it
a subagent.

Nx refuses OpenCode 2.x before 2.0.19 and prerelease builds, and asks
the user to install a stable release, 2.0.19 or later. It then falls
back to another installed agent, if there is one, and says why it
skipped OpenCode.

## Related Issue(s)

Fixes #38022

NXC-5300

## Implementation Notes

- The 2.x full-screen command has no `--agent`, and its UI sends
`--prompt` with the first listed agent. Nx makes Build the default agent
and gives it Nx's instructions through `OPENCODE_CONFIG_CONTENT`, which
outranks user config files.
- The same config pins Build's default `mode` and `hidden` values, so a
user config can't move another agent ahead of it.
- `--standalone` keeps the session off OpenCode's shared server, which
keeps the config of the session that started it.
- `opencode mini --agent` would select an agent directly. It wasn't used
because its UI differs from the 1.x one and it reads its working
directory from `PWD`.
- Releases before 2.0.19 can leave the starting prompt unsent
(anomalyco/opencode#51938). A prerelease version such as
`0.0.0-beta-19507` doesn't show whether the build has that fix.
- Admin-managed OpenCode settings load after Nx's config and can still
override Build. The session can then stay open after the run ends.
- Real migrate runs passed on OpenCode 1.19.6, 2.0.27, 2.0.32, 2.1.4,
2.2.7, 2.3.2, 2.4.1 and 2.4.2.
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.

1 participant