Skip to content

fix(tui): stop fetching placeholder session id on --continue - #47555

Open
woodsonl wants to merge 5 commits into
anomalyco:devfrom
woodsonl:tui-continue-dummy-id
Open

fix(tui): stop fetching placeholder session id on --continue#47555
woodsonl wants to merge 5 commits into
anomalyco:devfrom
woodsonl:tui-continue-dummy-id

Conversation

@woodsonl

@woodsonl woodsonl commented Sep 6, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #47556

Type of change

  • Bug fix

What does this PR do?

opencode --continue seeds a placeholder session route with sessionID: "dummy" (from #31049). The session route eagerly fetches that id and the server 400s because ids must start with ses_. With OPENCODE_FAST_BOOT=1 the route mounts before the continue effect runs, so the error shows on every cold start.

This PR seeds sessionID: "" instead and skips the eager fetch when the id is empty — no request fires for the placeholder, and the continue effect still resolves the real id and navigates. It also makes explicit --session win over -c when both are passed, and navigates home instead of showing a blank screen when -c has no previous session.

Two smaller fixes picked up while testing: ModelsDev User-Agent is now built per request instead of at import time (OPENCODE_CLIENT set at runtime by acp.ts was invisible to the frozen constant — this was breaking a core test), and an unused USER_AGENT const in installation/index.ts is dropped.

How did you verify your code works?

Added packages/tui/test/app-lifecycle.test.tsx: pins OPENCODE_FAST_BOOT=1, delays the /session response, and asserts no request to /session/dummy happens and the eventual fetch targets the real session id. Confirmed the test fails on dev and passes here. Package test suites (tui 194, core 1097, opencode 3594, session-ui 83) and bun turbo typecheck all pass. Manually ran --continue against a seeded server and confirmed the session renders with no /session/dummy request in the server log.

Checklist

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

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@woodsonl
woodsonl force-pushed the tui-continue-dummy-id branch from 92ca961 to de91ed0 Compare September 7, 2026 16:37
The -c flag seeded the route with sessionID "dummy" as a layout
placeholder. The session route's eager fetch then issued requests
against an id the server rejects (SessionID schema requires the
"ses" prefix), surfacing as an error toast / "Unexpected server
error" on startup.

Seed an empty id instead and skip the eager session fetch for empty
ids; the continue effect navigates to the real id once the session
list resolves, re-triggering the fetch exactly once.

Also escape the zero-width-space CSS content value in session-ui so
Tailwind receives the intended \200B escape (the raw \2 was parsed
as a deprecated octal escape and emitted a control character).
USER_AGENT was computed at module import, freezing Flag.OPENCODE_CLIENT
before entrypoints that set it at runtime (e.g. acp). Derive it per
request so the header reflects the actual client. Pin OPENCODE_CLIENT
in models.test.ts so the /cli assertion no longer depends on the
developer shell exporting the variable.
No consumers; userAgent(client) stays as the live helper. Deriving per
request (as core models-dev now does) avoids freezing OPENCODE_CLIENT
at import time.
The continue effect navigated to the most recent session regardless of
an explicit --session id, so opencode -c -s <id> raced onMount's
navigation and could land on the wrong session. Skip the continue
effect when --session is given.

Also route -c to home when no resumable session exists, instead of
leaving a blank placeholder route. An explicit --session that cannot
resolve is untouched (server reports it through the session route).
Poll for the resolved-id fetch instead of a fixed sleep, restore
OPENCODE_FAST_BOOT in finally, and assert every /session/:id request
carries the valid resolved id rather than only excluding the literal
"dummy" placeholder.
@woodsonl
woodsonl force-pushed the tui-continue-dummy-id branch from de91ed0 to 9160c4f Compare September 8, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opencode --continue fails with "Unexpected server error" (TUI fetches /session/dummy)

1 participant