Repository navigation
Description
Summary
Starting a session in a new worktree shows the "This session cannot be found" panel a second or two after Send, while the worktree is still being created. It's easy to hit when the worktree strategy runs a setup step (here a plugin runs make install-dev, so POST /api/worktree takes about 60 s). With a near-instant worktree the window is too short to notice.
If the user acts on the panel (for example, closes the tab), the session is never created, even though the worktree is.
Versions
- OpenCode (Rune)
0.0.0-dev-527, macOS arm64 - Sidecar
opencode-cli0.0.0-dev-1390 - Code references below are from
devat 3f997ef
Steps to reproduce
- Use a worktree strategy whose
createtakes about 30–60 s, for example a plugin that runs a dependency install aftergit worktree add. - On the new-session page, choose New worktree and send a prompt.
- Keep the pending session open and hover its tab, or let the stream reconnect, before the worktree is ready.
Expected: the pending session keeps showing "Starting session" until the worktree is ready, then lands.
Actual: the tab switches to "This session cannot be found / This tab points to a session that no longer exists on this server".
Evidence (server log)
Two worktree starts, two minutes apart, both with a worktree create of about 57 s:
| Send | Page read GET /api/session/<id>/message |
Worktree ready | Session created | |
|---|---|---|---|---|
| Start A | 08:28:22.4 | 08:28:23.8 → 404 | 08:29:19.7 | 08:29:19 (shown again later) |
| Start B | 08:30:23.2 | 08:30:26.7 → 404 | 08:31:21.1 | never (the user had closed the tab) |
At the moment of Send, every new session (worktree or not) also gets 404s on /api/session/<id>/inbox, /permission and /form. For a normal session the create lands within about a second, so the later page read succeeds and nothing shows.
Cause
- Page reads aren't skipped for a pending start.
open_nowskips reads for a starting session (apps/desktop/src/session/meta/open.rs:132). Other paths that read the newest page don't:prefetch_sessionon tab or sidebar hover (session/pages/mod.rs:444) andreload_sessionon reconnect (open.rs:203). When the read 404s and the session is on screen, the pages handler callssession_state::missing(apps/desktop/src/session/pages/mod.rs:640) without checkingself.queue.starts.has(&key.id), so the tab resolves toResolution::NotFound. NotFoundis sticky. InResolution::step(apps/desktop/src/session/meta/state.rs:64), onlyResolvingandUnreachablemove toReadyonKnown. So even afterpromote_start, the tab keeps the not-found panel until it is closed and reopened.- The panel's "Close Tab" can drop the start. While the panel shows, the start is still in
Start::Worktree. Closing or leaving it means the laterWorktreeMadefinds no start, so the session is never created, but the worktree stays. - Minor:
begin_startopens the session before registering the start. It callsshow_start(and soopen_now) beforequeue.starts.step(id, Event::Begin{..})(apps/desktop/src/workspace/lifecycle/new_session/mod.rs:363-365). The same is true for theExistingpath at lines 349–352. As a result theopen.rs:132guard never applies on the first open, which causes the immediate/inbox,/permissionand/form404s.
Suggested fix
- In
begin_start(both paths), insert intoqueue.startsbeforeshow_start, soopen_now's guard applies. - In the pages error handler (
pages/mod.rs:623and:640), treat a 404 for a session inqueue.startsas "not yet" rather thanmissing. Alternatively, makeprefetch_sessionandreload_sessionskip sessions inqueue.starts. - Optionally, let
Known(orpromote_start) move aNotFoundtab back toReady, so a session that turns up after all recovers without reopening its tab.
Found by reading the code and the server log, not with a debugger: the exact read that 404'd (hover prefetch or reconnect reload) wasn't captured on the client.
Activity
fix(desktop): prevent not-found panel while new worktree is creating
Hona commentedon Dec 3, 2026
Fixed in PR #2293 (merged into
devat3745cfc2f).Pending new-worktree starts are now registered in
queue.startsbeforeopen_nowruns, page and reconnect reads skip sessions still inqueue.starts, 404 responses for pending starts no longer transition the tab to "This session cannot be found" (while genuine 404 and deleted sessions still do), pending starts are preserved across memory sweeps, and server-confirmed promotion or landed pages recoverResolution::NotFoundtoReady.Verification: Checked locally on Windows with
pwsh scripts/guardrails.ps1(11/11),cargo check -j 1 -p opencode-desktop, andcargo clippy -j 1 -p opencode-desktop --no-deps, and validated across macOS, Linux, and Windows CI builds on PR #2293. Not verified interactively against a live slow-worktree server on hardware—please reopen if anything still flashes or gets stuck.fix(desktop): prevent not-found panel while new worktree is creating (a…