Description
Running opencode -c in a directory that has never had a session causes the TUI to hang. The process becomes unresponsive and must be killed with kill -9.
This worked correctly in 1.4.11 and broke sometime between then and 1.14.18.
Root cause
The --continue flag seeds the router with an initial { type: "session", sessionID: "dummy" } route to prevent a visual flash when resuming a session (introduced in 65b2a10e9 / #23037). When no sessions exist in the directory:
- The session route component eagerly fetches
GET /session/dummy, which fails server-side validation ("dummy" doesn't start with "ses")
- The
createEffect in App() that is responsible for replacing the dummy route with the real most-recent session never fires, because there are no sessions to match against
- The TUI stays stuck on the broken dummy session screen with no way to recover
Relevant code: packages/opencode/src/cli/cmd/tui/app.tsx lines 151-159 (initial route) and lines 345-366 (continue redirect effect).
Steps to reproduce
cd into a directory that has never had an opencode session (e.g. mktemp -d)
- Run
opencode -c
- TUI hangs indefinitely
- Process requires
kill -9 to terminate
Plugins
None
OpenCode version
1.14.18
Operating System
macOS (Apple Silicon) -- likely affects all platforms
Terminal
Ghostty
Description
Running
opencode -cin a directory that has never had a session causes the TUI to hang. The process becomes unresponsive and must be killed withkill -9.This worked correctly in
1.4.11and broke sometime between then and1.14.18.Root cause
The
--continueflag seeds the router with an initial{ type: "session", sessionID: "dummy" }route to prevent a visual flash when resuming a session (introduced in65b2a10e9/ #23037). When no sessions exist in the directory:GET /session/dummy, which fails server-side validation ("dummy"doesn't start with"ses")createEffectinApp()that is responsible for replacing the dummy route with the real most-recent session never fires, because there are no sessions to match againstRelevant code:
packages/opencode/src/cli/cmd/tui/app.tsxlines 151-159 (initial route) and lines 345-366 (continue redirect effect).Steps to reproduce
cdinto a directory that has never had an opencode session (e.g.mktemp -d)opencode -ckill -9to terminatePlugins
None
OpenCode version
1.14.18
Operating System
macOS (Apple Silicon) -- likely affects all platforms
Terminal
Ghostty