Skip to content

fix(desktop): heal bound views after stale runtime (salvage of #98876) - #99664

Merged
teknium1 merged 3 commits into
mainfrom
fix/98683-runtime-gone-latch
Aug 31, 2026
Merged

teknium1 merged 3 commits into
mainfrom
fix/98683-runtime-gone-latch

Conversation

@teknium1

Copy link
Copy Markdown
Collaborator

Salvages #98876 by @JoaoMarcos44 (cherry-picked, authorship preserved). Refs #98683.

What this fixes

The session view's background pollers (status/approval/goal, driven by the 5s process.list poll in apps/desktop/src/store/composer-status.ts) receive gateway 4001 "session not found" when their bound runtime id has been reaped/rotated. The existing gone-latch stops the poll storm, but nothing ever carries the gateway's "resume the stored session" verdict to the view — the window stays bound to a phantom runtime for the rest of its life, cycling the session view through loading and remounting the composer + clarify cards.

This PR adds store/runtime-gone.ts: on the 4001 verdict it latches once per runtime id and pulls the same recovery levers the session.reclaimed push path already uses — unbindTileRuntime (re-arms the tile's resume effect) and requestSessionResume for the primary chat (the only thing that bypasses its alreadyActive skip). Consecutive heals are capped at 3 per stored session (refunded when a binding proves healthy), so a reap-on-sight backend can't be turned into a resume loop.

Cherry-picked commits (authorship preserved)

  • fix(desktop): latch dead runtime recovery across remounts (was 9b5ea64)
  • fix(desktop): retain session remount polling reset (was 3dadfcc)
  • fix(desktop): satisfy import ordering (was 7d390b8)

Dropped from the original PR, and why

  • docs: clarify stale runtime investigation (2976e96) and the docs/forensics/issue-98683-stale-runtime.md file added by the first commit — forensics notes containing Windows temp paths; investigation artifacts don't belong in the repo. The file was stripped from the cherry-pick; the code diff is otherwise identical to the original PR (net: 3 files, +287).

Verification

  • vitest run --project ui src/store/runtime-gone.test.ts — 9/9 passed
  • vitest run --project ui src/store/composer-status.test.ts — 19/19 passed
  • npm run typecheck (all three tsconfigs) — clean
  • eslint on all four touched files — clean
  • scripts/audit_pr_attribution.py --fix — all contributor emails mapped

Live repro: vitest/jsdom A/B against the real stores (desktop Playwright lane disabled per #76627; renderer-only change) — a throwaway harness bound a tile + active session to a dead runtime and drove refreshBackgroundProcesses into a gateway rejecting session not found. Before (origin/main d10ef89): TILE_RUNTIME_AFTER_4001=runtime-dead, RESUME_REQUEST=null — view stays bound to the phantom runtime. After (this branch): TILE_RUNTIME_AFTER_4001=undefined, RESUME_REQUEST={"sequence":1,"sessionId":"stored-1"} — binding cleared and resume requested. Transient-error leg (timeout) verified to leave the binding alone.

Sibling issue #98455 (generic status-stack remount reset) is intentionally out of scope, matching the original PR.

Infographic

Heal bound views after stale runtime

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 959c3a8 — fix(desktop): satisfy import ordering

⚠️ Warnings

OSV vulnerability scan · View job

6 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 2m28s vs 4m6s (-39.8%). 2 job(s) slower, 3 faster, 1 unchanged.

  • OSV scan / Scan lockfiles / osv-scan: -8.0s
  • OSV scan / Emit review status: -5.0s
  • JS & TS checks / JS & TS checks: -5.0s
  • Detect affected areas: +5.0s
  • Check no committed infographics / check-no-committed-infographics: +1.0s

@alt-glitch alt-glitch added type/bug Something isn't working 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 labels Aug 31, 2026
@teknium1
teknium1 merged commit c631b48 into main Aug 31, 2026
33 checks passed
@teknium1
teknium1 deleted the fix/98683-runtime-gone-latch branch August 31, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants