perf(server): trim stale context-window rows and drop dead replay RPC - #4791
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:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
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 2f6aad1. Configure here.
ApprovabilityVerdict: Approved Performance optimization that trims redundant context-window rows from snapshots (clients only read the latest value per turn) and removes unused replay RPC code. The new filtering logic is thoroughly tested to produce semantically equivalent results for clients, making this a safe optimization with dead code cleanup. You can customize Macroscope's approvability policy. Learn more. |
Thread detail snapshots shipped every context-window.updated activity a thread ever produced — often a third of all snapshot bytes — while both clients only read the latest one. Snapshots now retain just the newest row; live activity events are untouched so streaming updates still supersede it client-side. Also removes the orchestration.replayEvents websocket RPC: no client in any released version (checked back through v0.0.20) calls it, and it let one call serialize the entire event store. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A live thread.reverted makes the client drop activities from discarded turns. Keeping only the thread-wide latest row could leave the meter empty when that row belonged to a reverted turn; per-turn retention keeps a resolvable value on every surviving turn (97% of rows are still trimmed on real data). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
c1a8050 to
08b6d3a
Compare
The client's deriveLatestContextWindowSnapshot skips rows without a finite non-negative usedTokens during its backward walk. Retention now uses the same validity rule, so a malformed latest row passes through untouched instead of displacing the turn's last resolvable row. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
## What's Changed * Add OTA update checks to mobile settings by @juliusmarminge in pingdotgg/t3code#4686 * fix(mobile): threads load snapped to bottom on iOS by @t3dotgg in pingdotgg/t3code#4689 * feat: default sidebar v2 on for nightly and dev builds by @t3dotgg in pingdotgg/t3code#4491 * fix(web): 33 web UI fixes by @maxktz in pingdotgg/t3code#4700 * Make mobile Thread List v2 the default by @juliusmarminge in pingdotgg/t3code#4717 * Fix mobile showcase workflow without Clerk by @juliusmarminge in pingdotgg/t3code#4718 * Fix relay credential lookup for unlinked environments by @juliusmarminge in pingdotgg/t3code#4692 * Settle merged PR threads immediately by @t3dotgg in pingdotgg/t3code#4704 * feat(web): add maria's sidebar header artwork toggle by @maxktz in pingdotgg/t3code#4652 * feat(web): add appearance settings category by @maxktz in pingdotgg/t3code#4715 * fix(desktop): allow updater-controlled relaunch by @0x4bs3nt in pingdotgg/t3code#4721 * fix(web): prevent diff panel scroll jumping by @0x4bs3nt in pingdotgg/t3code#4724 * Link inline code file paths in chat markdown by @juliusmarminge in pingdotgg/t3code#4726 * Fix Android showcase capture and rebuild v2 queued rows by @juliusmarminge in pingdotgg/t3code#4730 * perf(server): negotiate permessage-deflate on the websocket by @t3dotgg in pingdotgg/t3code#4705 * docs: overhaul agent guidance by @t3dotgg in pingdotgg/t3code#4782 * Prevent sidebar row labels from truncating by @juliusmarminge in pingdotgg/t3code#4789 * perf(server): gzip large thread snapshots by @t3dotgg in pingdotgg/t3code#4788 * fix(web): stashed prompts now survive switching providers by @t3dotgg in pingdotgg/t3code#4787 * Fix Git ref refresh resource storms by @juliusmarminge in pingdotgg/t3code#4727 * perf(server): trim stale context-window rows and drop dead replay RPC by @t3dotgg in pingdotgg/t3code#4791 * fix(web): defer command palette filesystem navigation by @juliusmarminge in pingdotgg/t3code#2109 * fix(release): skip scripts during Vercel installs by @t3dotgg in pingdotgg/t3code#4796 * refactor(client): share filesystem browse navigation by @juliusmarminge in pingdotgg/t3code#4797 * fix(mobile): defer filesystem navigation by @juliusmarminge in pingdotgg/t3code#4799 * refactor(server): use native HTTP compression streams by @juliusmarminge in pingdotgg/t3code#4798 * Remove Connect waitlist and add GA announcement tooling by @juliusmarminge in pingdotgg/t3code#4691 **Full Changelog**: pingdotgg/t3code@v0.0.29...v0.0.30 ## What's Changed * Add OTA update checks to mobile settings by @juliusmarminge in pingdotgg/t3code#4686 * fix(mobile): threads load snapped to bottom on iOS by @t3dotgg in pingdotgg/t3code#4689 * feat: default sidebar v2 on for nightly and dev builds by @t3dotgg in pingdotgg/t3code#4491 * fix(web): 33 web UI fixes by @maxktz in pingdotgg/t3code#4700 * Make mobile Thread List v2 the default by @juliusmarminge in pingdotgg/t3code#4717 * Fix mobile showcase workflow without Clerk by @juliusmarminge in pingdotgg/t3code#4718 * Fix relay credential lookup for unlinked environments by @juliusmarminge in pingdotgg/t3code#4692 * Settle merged PR threads immediately by @t3dotgg in pingdotgg/t3code#4704 * feat(web): add maria's sidebar header artwork toggle by @maxktz in pingdotgg/t3code#4652 * feat(web): add appearance settings category by @maxktz in pingdotgg/t3code#4715 * fix(desktop): allow updater-controlled relaunch by @0x4bs3nt in pingdotgg/t3code#4721 * fix(web): prevent diff panel scroll jumping by @0x4bs3nt in pingdotgg/t3code#4724 * Link inline code file paths in chat markdown by @juliusmarminge in pingdotgg/t3code#4726 * Fix Android showcase capture and rebuild v2 queued rows by @juliusmarminge in pingdotgg/t3code#4730 * perf(server): negotiate permessage-deflate on the websocket by @t3dotgg in pingdotgg/t3code#4705 * docs: overhaul agent guidance by @t3dotgg in pingdotgg/t3code#4782 * Prevent sidebar row labels from truncating by @juliusmarminge in pingdotgg/t3code#4789 * perf(server): gzip large thread snapshots by @t3dotgg in pingdotgg/t3code#4788 * fix(web): stashed prompts now survive switching providers by @t3dotgg in pingdotgg/t3code#4787 * Fix Git ref refresh resource storms by @juliusmarminge in pingdotgg/t3code#4727 * perf(server): trim stale context-window rows and drop dead replay RPC by @t3dotgg in pingdotgg/t3code#4791 * fix(web): defer command palette filesystem navigation by @juliusmarminge in pingdotgg/t3code#2109 * fix(release): skip scripts during Vercel installs by @t3dotgg in pingdotgg/t3code#4796 * refactor(client): share filesystem browse navigation by @juliusmarminge in pingdotgg/t3code#4797 * fix(mobile): defer filesystem navigation by @juliusmarminge in pingdotgg/t3code#4799 * refactor(server): use native HTTP compression streams by @juliusmarminge in pingdotgg/t3code#4798 * Remove Connect waitlist and add GA announcement tooling by @juliusmarminge in pingdotgg/t3code#4691 **Full Changelog**: pingdotgg/t3code@v0.0.29...v0.0.30 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.30

Thread detail snapshots shipped every
context-window.updatedactivity a thread ever produced, while both web and mobile only read the latest row (web walks the array backwards inderiveLatestContextWindowSnapshot; mobile skips the kind entirely). On long threads that history was 24–37% of snapshot bytes.Snapshots now retain only the newest context-window row. Live
thread.activity-appendedevents are untouched, so streaming updates still flow and supersede the retained row client-side. Verified on cloned real data that the served row is byte-identical to the latest stored row and thatderiveLatestContextWindowSnapshotreturns the same result before and after.Measured on real thread snapshots (uncompressed HTTP bytes):
This also removes the
orchestration.replayEventswebsocket RPC. No client in any released version calls it (checked v0.0.20 through v0.0.29 plus current web/mobile/desktop/client-runtime), and it let a single call serialize the entire event store uncompressed. The project-event enrichment helpers inws.tsexisted only for that handler and go with it.Stacks cleanly with #4788 (HTTP gzip): these cut bytes at the source, gzip compresses what remains; on the largest thread the combined result is 6.85 MB → ~0.9 MB gzip.
Tests:
vp test apps/server/src/server.test.ts apps/server/test/ packages/contracts packages/client-runtime(801 passed)Built with Claude Fable 5 in Claude Code.
🤖 Generated with Claude Code
Note
Medium Risk
Snapshot shaping must stay equivalent to client meter logic; removing a public RPC is a breaking change for any external caller, though shipped clients reportedly never used it.
Overview
Thread detail snapshots now drop redundant
context-window.updatedactivities before payload projection, keeping only the latest resolvable row per turn (aligned with the web client’sderiveLatestContextWindowSnapshotrules). Livethread.activity-appendedevents are unchanged, so streaming updates still apply on the client.The
orchestration.replayEventsWebSocket RPC is removed from contracts and the server, along with project-event repository-identity enrichment that existed only for that handler. Related server tests are deleted or trimmed.Reviewed by Cursor Bugbot for commit 22bd560. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Trim stale context-window rows from thread snapshots and remove the
replayEventsRPCdropStaleContextWindowActivitiesinActivityPayloadProjection.tsto keep only the last validcontext-window.updatedactivity per turn in thread snapshots, preventing malformed rows from shadowing earlier valid ones.orchestration.replayEventsRPC from contracts, server routing, and auth scope — including all event-enrichment helpers that resolved repository identity.context-window.updatedrows; clients previously receiving multiple rows per turn will see only the latest resolvable one.Macroscope summarized 22bd560.