Skip to content

fix(desktop): rebind mounted sessions after ws reconnect - #101531

Open
FalconOrtiz wants to merge 1 commit into
NousResearch:mainfrom
FalconOrtiz:fix/fe-101408-ws-reconnect-detach
Open

FalconOrtiz wants to merge 1 commit into
NousResearch:mainfrom
FalconOrtiz:fix/fe-101408-ws-reconnect-detach

Conversation

@FalconOrtiz

Copy link
Copy Markdown

Why

After a desktop WebSocket drop (1006), reconnect could leave a mounted pane painted from warm cache while the gateway still held that session on the drop sentinel. Typed input never reached prompt accepted, and a pending approval.pending frame was lost until the user remounted the chat (#101408).

Scope

  • use-session-tile-delegate.ts: warm resumeTile always runs session.activate (restores pending_approval); falls through to cold session.resume when activate proves the runtime dead.
  • use-session-actions/index.ts: a timed-out / transient warm session.activate falls through to cold session.resume instead of returning on degraded cache.
  • Focused tests for both paths.

Out of scope: gateway orphan-reap / transport ownership changes.

Tradeoffs

Warm tile reuse now pays one session.activate round-trip. That matches the primary resume path and is the cheapest way to prove transport attachment.

Blast Radius

Desktop renderer only (apps/desktop). Affects tiled sessions and primary warm reconnect. Safe failure mode is cold resume.

Verification

cd apps/desktop
npm run test:ui -- src/app/contrib/hooks/use-session-tile-delegate.test.ts
# 14 passed, exit 0

npm run test:ui -- src/app/session/hooks/use-session-actions.test.tsx -t "falls through to session.resume when warm activate times out"
# 1 passed, exit 0

Closes #101408

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/desktop Electron desktop app (apps/desktop/*) area/sessions Session lifecycle, resume, persistence, history sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Sep 2, 2026
@Enough1122

Copy link
Copy Markdown

AI code review — automated review for reference; please use your judgment.

Overall: Warm tile bindings are rebound via session.activate before reuse: cache warmth is not transport attachment, and after a WS drop the map can be re-seeded while the gateway parks the session on the drop sentinel (#101408).

Correctness:

  • apps/desktop/src/app/contrib/hooks/use-session-tile-delegate.ts:rebindWarmRuntime — omit_messages: true + cols: 96 light rebind; restores pending approvals into the prompt store; missing (old backend) and ok both reuse, dead falls through to cold session.resume after deleting the stale mapping. Re-checked after the prefetch await (second warm path), closing the race.
  • use-session-actions/index.ts — non-gone errors (timeouts/blips) now drop only the stored→runtime mapping and fall through to session.resume instead of publishing a live-looking warm cache that drops typed input.
  • Tests pin activate-before-reuse, approval restoration, dead-runtime cold fall-through, and timeout → session.resume with $activeSessionId landing on the fresh runtime.

Non-blocking nit:

  • Every warm reuse now costs one session.activate RPC, and every blip costs a full session.resume; correct trade (a dropped keystroke is worse than an RPC), but reconnect storms will show as resume churn in logs.

Verdict: LGTM.

@FalconOrtiz

Copy link
Copy Markdown
Author

Requesting squash-merge per engineer agreement (2026-09-04): AI-review merge-ready pack; nits non-blocking; no rewrites.

This PR is in the agreed pack with #101523 #101528 #101529 #101530 #101531 #101537 #101544 #101547 #101548 #101549 #101551.

Out of pack (do not block this merge): #101564, #101796/#101091, #101318.

Warm tile reuse and a timed-out primary activate left panes painted while
the gateway still held the session on the drop sentinel. Activate (or fall
through to resume) so typed input and pending approvals attach again.

Co-authored-by: Cursor <cursoragent@cursor.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/desktop Electron desktop app (apps/desktop/*) P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Desktop: after ws drop (1006), reconnect leaves one mounted session detached — typed input silently dropped, pending approval frame lost

3 participants