Description
Starting the interactive TUI with both --session and --prompt selects the existing session, but the supplied prompt is never submitted to that session. This makes resumed interactive invocations silently start without the requested work.
The behavior reproduces in 1.17.15 and 1.18.3 and is still present on the current dev branch.
Reproduction
-
Create a session:
opencode run 'Reply with exactly BASELINE_READY'
-
Resume it with a prompt:
opencode -s <session-id> --prompt 'Reply with exactly RESUME_READY'
-
Wait for the TUI to initialize.
Expected: RESUME_READY is submitted as a new user turn and the model responds.
Actual: the session opens, but the supplied prompt is not persisted or submitted. --mini behaves the same way. Sending Enter after startup does not reliably submit the supplied prompt either.
Root cause
packages/opencode/src/cli/cmd/tui.ts forwards args.prompt into the TUI arguments. The home route seeds and auto-submits args.prompt after sync and model initialization. When args.sessionID is present, however, packages/tui/src/app.tsx navigates to the session route without carrying that prompt. The session route only knows how to seed route.prompt and does not perform the startup auto-submit used by the home route.
Suggested fix
- Carry the startup prompt when navigating to a session selected by
--session or --continue.
- In the session route, seed and submit that startup prompt exactly once after the prompt ref, session synchronization, and model state are ready, matching the home route's readiness gates.
- Add a regression test proving
opencode -s <id> --prompt <text> submits one new user turn, while opencode -s <id> remains unchanged.
Description
Starting the interactive TUI with both
--sessionand--promptselects the existing session, but the supplied prompt is never submitted to that session. This makes resumed interactive invocations silently start without the requested work.The behavior reproduces in 1.17.15 and 1.18.3 and is still present on the current
devbranch.Reproduction
Create a session:
opencode run 'Reply with exactly BASELINE_READY'Resume it with a prompt:
Wait for the TUI to initialize.
Expected:
RESUME_READYis submitted as a new user turn and the model responds.Actual: the session opens, but the supplied prompt is not persisted or submitted.
--minibehaves the same way. Sending Enter after startup does not reliably submit the supplied prompt either.Root cause
packages/opencode/src/cli/cmd/tui.tsforwardsargs.promptinto the TUI arguments. The home route seeds and auto-submitsargs.promptafter sync and model initialization. Whenargs.sessionIDis present, however,packages/tui/src/app.tsxnavigates to the session route without carrying that prompt. The session route only knows how to seedroute.promptand does not perform the startup auto-submit used by the home route.Suggested fix
--sessionor--continue.opencode -s <id> --prompt <text>submits one new user turn, whileopencode -s <id>remains unchanged.