Skip to content

fix(desktop): prevent not-found panel while new worktree is creating - #2293

Merged
Hona merged 1 commit into
devfrom
fix/new-worktree-not-found
Dec 3, 2026
Merged

Hona merged 1 commit into
devfrom
fix/new-worktree-not-found

Conversation

@Hona

@Hona Hona commented Dec 3, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #2276.

When starting a session in a new worktree whose setup takes longer than a moment, speculative or reconnect reads could hit GET /api/session/<id>/message before the worktree finished and the session existed on the server, turning the pending tab into the sticky "This session cannot be found" panel.

Changes

  • Register pending starts before opening (apps/desktop/src/workspace/lifecycle/new_session/mod.rs): Split show_start into prepare_start + open_now so start and both begin_start paths insert into queue.starts before calling open_now, letting open_now's pending-start guard skip premature /inbox, /permission, /form, /children, and /jobs reads. Complete those live-open reads and window_opened in promote_start once the server proves the session exists.
  • Skip page/session reads while starting (apps/desktop/src/session/pages/mod.rs, apps/desktop/src/session/pages/shown.rs, apps/desktop/src/session/meta/open.rs): Guard prefetch_page, reload_session, open_page, read_shown_session, resync_view, and App::open's held check against queue.starts.has(id) so tab/sidebar hover, switching away and back, and SSE reconnects keep showing the pending creating state cleanly without firing 404s.
  • Protect pending starts from 404 NotFound and allow recovery (apps/desktop/src/session/pages/mod.rs, apps/desktop/src/session/meta/state.rs): Ignore 404 page errors in poll_pages and session_state::missing while queue.starts.has(id) (leaving genuine 404 and deleted sessions unchanged). Allow explicit server proof (session_state::known, called from promote_start and landed pages, never from session_state::poll) to move Resolution::NotFound back to Resolution::Ready.
  • Keep pending starts out of memory sweeps (apps/desktop/src/shell/memory_reclaim.rs): Retain sessions in queue.starts during tab-close and periodic sweeps so long worktree setups do not lose their local prompt transcript.

Verification

  • Verified locally on Windows: pwsh scripts/guardrails.ps1 (11/11 passed), cargo check -j 1 -p opencode-desktop, and cargo clippy -j 1 -p opencode-desktop --no-deps (zero warnings in touched files).
  • Not run interactively on live GUI hardware or locally on macOS/Linux; cross-platform builds validated by GitHub Actions CI.

Copilot AI balanced review requested due to automatic review settings December 3, 2026 12:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Register pending starts in queue.starts before open_now runs, skip
page/session reads and 404 not-found transitions while a start is still
in flight, retain pending starts across memory reclamation, and allow
server-confirmed promotion or landed pages to recover Resolution::NotFound
to Ready.

Fixes #2276
@Hona
Hona force-pushed the fix/new-worktree-not-found branch from 0dcf86a to 87be6a7 Compare December 3, 2026 12:20
@Hona
Hona merged commit 3745cfc into dev Dec 3, 2026
8 checks passed
@Hona
Hona deleted the fix/new-worktree-not-found branch December 3, 2026 12:40
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.

New-worktree session shows "This session cannot be found" while its worktree is still being created

2 participants