fix(server): stop large thread history from exhausting memory - #4948
fix(server): stop large thread history from exhausting memory#4948t3dotgg wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
ApprovabilityVerdict: Needs human review This PR introduces a significant runtime behavior change that limits thread activity history to 500 items to prevent memory exhaustion. Users with large threads will see truncated history with an indicator. The change also removes sidebar thread prewarming and adds complex pinned-activity logic to preserve actionable items. Human review recommended due to the user-visible impact. You can customize Macroscope's approvability policy. Learn more. |
c8e508e to
122963a
Compare
122963a to
450b199
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 450b199. Configure here.
450b199 to
1c3bf90
Compare
|
This is slop |

Large retained threads can exhaust the server heap when their activity history is hydrated, when the compatibility snapshot endpoint reads every thread body, or when a stale client cursor replays the global event log without a bound.
This keeps initial thread detail to the newest 500 work activities while preserving unresolved approval and user-input requests. It switches project resolution to the lightweight command read model, caps reconnect replay at 1,000 events with a projected snapshot fallback, and stops prewarming hidden sidebar thread details. Web and mobile show a small notice when older work activity is omitted. Messages and checkpoints remain complete.
This intentionally defers older-activity pagination. Based on the server work and investigation in #3510 by @olafura.
Fixes #2761. Addresses #996.
Verification:
Built by gpt-5.6-sol in the Codex harness through T3 Code.
Note
High Risk
Changes core projection hydration, snapshot HTTP behavior, and thread WebSocket catch-up—areas that affect memory, reconnect correctness, and whether actionable approvals/user-inputs appear outside the activity window.
Overview
This PR caps memory and reconnect cost for threads with very large activity histories.
Server read model:
getThreadDetailByIdnow returns only the latest 500 work activities (plus pinned unresolved approval/user-input rows outside that window) and sets optionalhasMoreActivitieswhen older items exist. Messages and checkpoints stay fully loaded.Compatibility snapshot: The orchestration
/snapshotHTTP endpoint and project CLI offline path now usegetCommandReadModel()instead of hydrating every thread body.WebSocket reconnect:
subscribeThreadbounds event replay to the projection head (max 1,000 events); stale cursors get a fresh thread detail snapshot instead of unboundedreadEventsreplay.Clients: Web and mobile show “Earlier work activity not shown” when bounded; the web sidebar stops prewarming hidden thread-detail subscriptions. Contracts add optional
hasMoreActivitieson thread payloads.Reviewed by Cursor Bugbot for commit 1c3bf90. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Limit thread history to 500 activities to prevent memory exhaustion on large threads
ProjectionSnapshotQuery.tsnow window activity to the 500 most recent items, with ahasMoreActivitiesflag set when older items exist.ws.tsnow bound catch-up replay to the captured projection head; stale cursors trigger a full snapshot replacement instead of unbounded replay.hasMoreActivitiesis true.hasMoreActivitiesand will continue to see full history; the field is optional in the contract for compatibility.Macroscope summarized 1c3bf90.