Skip to content

fix(tui): handle --continue in directories with no prior sessions#23439

Open
rmk40 wants to merge 1 commit intoanomalyco:devfrom
rmk40:fix/continue-hang-no-sessions
Open

fix(tui): handle --continue in directories with no prior sessions#23439
rmk40 wants to merge 1 commit intoanomalyco:devfrom
rmk40:fix/continue-hang-no-sessions

Conversation

@rmk40
Copy link
Copy Markdown
Contributor

@rmk40 rmk40 commented Apr 19, 2026

Issue for this PR

Closes #23437

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

opencode -c hangs indefinitely in directories with no prior sessions.

The --continue flag seeds the router with a placeholder session route (sessionID: "dummy") to prevent a visual flash before the real session loads. When no sessions exist, the session component eagerly fetches GET /session/dummy (which fails validation), and the continue effect never replaces the placeholder route because there is no session to match against. The TUI gets stuck.

This PR makes three changes:

  1. Extracts CONTINUE_PLACEHOLDER_ID constant in context/route.tsx so the sentinel value is defined once and imported by both consumers. Prevents silent breakage if either site is changed independently.

  2. Guards the session route fetch in routes/session/index.tsx to skip the eager session.get() call while the route still holds the placeholder. The continue effect in App() replaces it with a real session or home.

  3. Adds a no-match fallback in the continue effect in app.tsx. When no root session exists, it waits for sync.status === "complete" (to avoid false negatives at "partial"), then navigates to home. Also navigates home on fork failure instead of leaving the user on the placeholder.

How did you verify your code works?

Reproduced the hang in a fresh temp directory with opencode -c. After the fix, the TUI starts on the home screen instead of hanging. Also verified that opencode -c in a directory with existing sessions still navigates directly to the most recent session without a flash.

Screenshots / recordings

N/A — no UI change, behavior fix only.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

- Extract CONTINUE_PLACEHOLDER_ID constant in context/route.tsx so the
  sentinel value is defined once and shared by both consumers
- Guard session route fetch to skip eager session.get() while the route
  holds the placeholder, preventing invalid GET /session/dummy requests
- Add no-match fallback in the continue effect: wait for sync complete
  before concluding no sessions exist, then navigate to home
- Navigate home on fork failure instead of leaving user on placeholder
- Flatten else branches to use early returns per style guide

Closes anomalyco#23437
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opencode -c hangs indefinitely in directories with no prior sessions

1 participant