tui: after the background service restarts, --session TUIs show the home screen and --prompt is submitted again
Summary
When the background service (opencode serve --service) restarts, attached TUIs started with --session <id> can come back on the home screen instead of their session, and a TUI started with --prompt submits that prompt again into a new session. With many TUIs on one service, one restart produced many blank panes and duplicate sessions that re-ran their launch prompt.
Environment
- opencode version: 2.2.0 (latest channel)
- OS: macOS, Darwin 27.0.0 arm64
- Terminal: herdr multiplexer (TERM=xterm-256color, COLORTERM=truecolor)
- Shell: /bin/zsh
- Install/channel: release binary at ~/.opencode/bin/opencode; the service runs under launchd with KeepAlive
- Active plugins: project plugins under
.opencode/plugin/(tool hooks, instruction filter, a compaction restore, a Slack bridge) and herdr's TUI/session-state plugins under~/.config/opencode/
Reproduction
- Run the background service:
opencode serve --service(here under launchd with KeepAlive). - In several terminals, start TUIs on existing sessions, some with a launch prompt:
opencode --auto --session <ses_id> <dir> --prompt "<message>". Let each prompt's turn finish. - Send SIGTERM to the service process; launchd starts a new
serve --serviceabout 12 s later. - Look at each TUI after it reconnects.
Expected Behavior
Each TUI reconnects to the new service and shows the session named by --session. A --prompt given at startup is submitted once, at startup, and never again on reconnect.
Actual Behavior
On 2026-11-14 (service killed 23:06:58Z, restarted 23:07:10Z), 26 of 45 attached TUIs showed the home screen; their sessions still existed and kept running on the service, but were no longer shown. Each of the 5 TUIs whose argv carried --prompt submitted that prompt again at 23:07:12Z into a new session, on the home screen's model (the most recent entry in model.json, not the session's model). Four of those then fell back to the home screen; one stayed on the new session. The other 19 TUIs stayed on their session. Recovery was /exit and a fresh opencode --session <id> <dir> in each pane.
An earlier restart test on an isolated instance (own XDG_STATE_HOME/XDG_DATA_HOME and port, 2026-11-10) reconnected a single TUI to its session normally, so the drop appears intermittent or load-dependent.
Additional Context
- The terminal title on the dropped panes was
OpenCode(home screen) instead ofOC | <session title>. - Herdr's TUI plugin reports only route changes to a session, so the multiplexer still associated each dropped pane with its old session.
- Workarounds on our side: a repository default model, and a post-restart tool that relaunches dropped panes.
Thanks for the detailed report and the timeline. I think this is a duplicate of #59542. Your report seems to combine two known bugs that together explain what you saw:
- Home screen after the restart. When a TUI resumes a session and one session read fails for a passing reason, the TUI goes home and does not retry the read (#59542). #61243 described your setup: many TUIs on one background service that restarts. It was closed as a duplicate of #59542. The open PR #59543 retries these reads.
--promptsent again. After starting with--session <id> --prompt <text>, the first home view opened later submits the startup prompt again into a new session (#63839). The open PR #63979 makes--promptused only once. So a TUI that dropped home re-sent its launch prompt, on the home screen's model.
Possible duplicates and closely related issues, ordered from most to least likely:
- #59542: a failed session read sends the TUI home with no retry (fix proposed in #59543).
- #63839:
--promptis submitted again by the first home view after starting with--session(fix proposed in #63979). - #61243: the same drop home with many TUIs on one restarting service; closed as a duplicate of #59542.
- #60839: the same drop to the start screen after sleep/wake reconnects, with many TUIs on one service.
I'm closing this issue now as a duplicate of #59542. Please add your details there, such as the 26 of 45 count and the restart timing. If the --prompt part looks different from #63839, add a note there too. If you think this is a different problem, reply here and the issue will be reopened.