Skip to content

opencode -c hangs indefinitely in directories with no prior sessions #23437

@rmk40

Description

@rmk40

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:

  1. The session route component eagerly fetches GET /session/dummy, which fails server-side validation ("dummy" doesn't start with "ses")
  2. 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
  3. 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

  1. cd into a directory that has never had an opencode session (e.g. mktemp -d)
  2. Run opencode -c
  3. TUI hangs indefinitely
  4. Process requires kill -9 to terminate

Plugins

None

OpenCode version

1.14.18

Operating System

macOS (Apple Silicon) -- likely affects all platforms

Terminal

Ghostty

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type
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