Repository navigation
perf(mobile): omit duplicated turn items from bounded thread snapshots - #15385
juliusmarminge wants to merge 2 commits into
Conversation
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
3295b30 to
918cf5f
Compare
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR changes the default bounded-snapshot transport across HTTP and WebSocket paths, adding a cross-package protocol marker and client restoration logic. Compatibility coverage is strong, but the production behavior and default wire format span several components and warrant human review. No code changes detected at You can add or adjust custom eligibility rules. Learn more. |
|
Warning Review limit reachedCodeRabbit couldn't verify your organization's usage billing state, so no usage-priced review was started. Retry after the billing service recovers. Next included review available in 18 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (15)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe change adds compact bounded snapshots that omit eligible local visible turn items and mark the omission. HTTP and WebSocket paths support opt-in negotiation. Client code restores omitted items before using the projection. ChangesCompact bounded snapshots
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant Client as fetchEnvironmentBoundedThreadSnapshot
participant Endpoint as threadBoundedSnapshot
participant Builder as boundedSnapshotResponseFields
participant Restorer as boundedSnapshotProjection
Client->>Endpoint: Request compactTurnItems=1
Endpoint->>Builder: Build compact bounded response
Builder-->>Endpoint: Projection and omission marker
Endpoint-->>Client: Bounded snapshot response
Client->>Restorer: Restore marked projection
Restorer-->>Client: Projection with local visible items
Merge Risk: ⚪ Minimal · up to The compact snapshot path is connected end to end, with no identified issue requiring a fix before merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problem, change, compatibility behavior, measurements, and verification. It does not include the required Scope and approval information, such as a triaged issue or maintainer approval, or an explanation of why the change qualifies for an exception. Full details: Docstring CoverageExplanation Docstring coverage is 47.06% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 14 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
96698d5 to
b46d7c5
Compare
Bounded thread snapshots sent every local visible row's item twice: once in visibleTurnItems and again in projection.turnItems. Clients can now opt in (compactTurnItems=1 over HTTP, acceptCompactTurnItems on the socket) to a snapshot marked turnItemsOmitLocalVisible that drops those leading entries. The client restores them with boundedSnapshotProjection right after decode, so reducers, caches and live events still see the full list. Older clients and servers keep the unchanged representation. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
b46d7c5 to
2d10c37
Compare
Stacked on #15248.
Problem
A bounded thread snapshot sends each local visible row's item twice: once in
visibleTurnItemsand again inprojection.turnItems. That duplication makes up roughly 30–45% of the raw JSON a phone downloads, parses, and decodes when it opens a thread.Fix
Clients can now opt in to a compact snapshot:
compactTurnItems=1onGET /api/orchestration/threads/:id/bounded, oracceptCompactTurnItemson the thread subscription. The server then drops the leadingturnItemsentries that repeat local visible rows and marks the snapshotturnItemsOmitLocalVisible. The client rebuilds them withboundedSnapshotProjectionright after decode, so reducers, the cache, and live events still see the full list.turnItemsare exactly the local visible rows' items (same object). Otherwise it sends the unchanged snapshot with no marker.Measurements
Synthetic fixtures seeded through the real
EventSinkinto a scratch DB, run against this branch on nucbox-1 (Node 24, x86_64), medians of 25 iterations. "Before" is the opted-out response, which is byte-identical to the base branch. "After" is the opted-in response. Node parse+decode isJSON.parseplus schema decode. Restore addsboundedSnapshotProjection. Every fixture round-trips to the identical projection after restore.Limits:
agent-turns, br output is 6% larger.Evidence (synthetic data only): script, results and log (tgz) · README with reproduction steps · results.json
Verification
Focused tests and typechecks passed for the touched packages: shared (6), client-runtime (49), contracts (34), server (44), projection (5). They cover the omit/restore round-trip, the identity guard, the HTTP and WS opt-in in both directions across versions, and client restore before reducers and the cache.
Implemented by Claude Opus 5.5 in Claude Code (T3 Code).
🤖 Generated with Claude Code
Native runtime follow-up
Alternating compact off/on in the iOS 27 simulator, using the matching native build and a Hermes debug bundle against the isolated nucbox fixture server over Tailscale. Three samples per mode per fixture, JS reload each time and synthetic-thread cache bypassed.
The endpoint is the populated React feed's layout-effect commit, not a confirmed displayed frame. Small sample sizes and overlapping results make these preliminary; they are not physical-device, release-build, 1.4 comparison, or battery measurements. Separate Hermes captures show substantial React opening work but only 17 ms sampled non-idle JS over 15 seconds on a settled thread with one connected environment.
Native measurements, diagnostic patch, automation, and method. Temporary instrumentation was removed after measurement.