Skip to content

TUI: --prompt is dropped when resuming with --session #37536

Description

@pacaplan

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

  1. Create a session:

    opencode run 'Reply with exactly BASELINE_READY'
  2. Resume it with a prompt:

    opencode -s <session-id> --prompt 'Reply with exactly RESUME_READY'
  3. 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions