Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop,web): contain renderer memory growth and recover from renderer OOM crashes #5148

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/5148/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

The desktop renderer OOMs at V8's heap ceiling (~3.7 GB) on long sessions and dies to a white screen (#1686, and the claudeissues mirror users keep hitting). The window frame survives, the renderer doesn't, and agents keep running invisibly behind a dead UI.

Investigation on current main found three renderer-side growth/recovery gaps:

  1. Live context-window.updated rows accumulate forever. Providers stream these continuously; consumers only ever read the latest value per turn (walking backwards). The server already collapses them in snapshots (dropStaleContextWindowActivities, #4791) but deliberately left live events untouched — so a long-running session still retains thousands of rows per thread client-side. The reducer now applies the same per-turn collapse on the live path, with identical malformed-row semantics (an unresolvable row never replaces a resolvable one, so the meter can always derive a value).
  2. The sidebar pins up to 10 fully hydrated live thread subscriptions. Each prewarmed row holds every message and activity of its thread, growing as agents work, for as long as the row is visible — the 5-minute idle TTL never fires. Dropped to 3. Cold opens still render instantly from the cached snapshot, then transition to live.
  3. render-process-gone only logged. The window now reloads on crashed/oom/abnormal-exit, bounded to 3 attempts per rolling minute so a boot-crash can't reload-loop. The backend is a separate process and unaffected, so a reload fully rehydrates — the white screen becomes a ~1s blip instead of data loss.

No user-visible behavior change outside crash recovery itself.

Companion to #5147 (server-side OOM containment). Long term, the real fix is moving tool.completed payloads out of the hot paths entirely.

Verification:

  • 2 new reducer tests (same-turn collapse incl. malformed rows and cross-turn retention; malformed update never displaces a resolvable row)
  • client-runtime suite 510 passed, web suite 1754 passed, desktop suite 406 passed
  • typecheck (client-runtime, web, desktop, mobile), lint, format clean

Built by Claude Fable 5 in Claude Code.

🤖 Generated with Claude Code


Note

Medium Risk Changes live event reduction and desktop crash recovery paths; bounded reload limits boot-loop risk, but incorrect collapse rules could affect context-window display or thread activity history.

Overview Targets renderer heap growth and dead UI after V8 OOM on long desktop sessions without changing normal UX except when the renderer actually crashes.

Client thread state: On live thread.activity-appended, resolvable context-window.updated rows for the same turn now collapse to the newest (matching server snapshot dropStaleContextWindowActivities). Malformed rows do not replace earlier resolvable ones. This cuts thousands of redundant activity rows per thread over long agent runs.

Web sidebar: SIDEBAR_THREAD_PREWARM_LIMIT drops from 10 → 3, reducing how many visible rows keep full live thread-detail subscriptions (messages + activities) in memory.

Desktop main window: render-process-gone for crashed / oom / abnormal-exit triggers a bounded reload (500ms delay, max 3 attempts per rolling 60s), so users get a brief rehydrate instead of a permanent white screen while the backend keeps running.

Tests cover context-window collapse semantics in threadReducer.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 2d46b9522071705f165467a66c1c0e24952b7976. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Fix renderer memory growth and recover from renderer OOM crashes in desktop and web

  • Adds auto-reload recovery to the desktop DesktopWindow renderer: on crashed, oom, or abnormal-exit, waits 500ms then reloads, up to 3 times per 60s window before giving up and logging only.
  • Reduces the sidebar thread prewarm limit from 10 to 3 in Sidebar.logic.ts to lower concurrent detail subscriptions and memory pressure.
  • Collapses redundant context-window.updated activities in threadReducer: when a valid (finite, non-negative usedTokens) update is appended, earlier valid updates for the same turn are dropped; malformed updates are preserved and do not displace valid history.
  • Behavioral Change: the desktop app will now silently reload up to 3 times on renderer failure before requiring a manual restart.
Macroscope summarized 2d46b95.
    1. Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: c18c5428-d699-4d03-8622-f13e197f3f7c

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. Approvability

      Verdict: Needs human review

      This PR introduces new crash recovery behavior (auto-reload on renderer OOM) and changes how thread activity data is deduplicated to prevent memory growth. While well-bounded and tested, these runtime behavior changes to failure handling and state management warrant human review.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).

Sign in to join this conversation.