Skip to content

perf(server,client-runtime,web,mobile): [NBR] cut full-projection prefetches, thread-find skills TX, and visit/activity churn - #48483

Open
t3dotgg wants to merge 1 commit into
nbr/config-optfrom
nbr/tx-cleanup
Open

t3dotgg wants to merge 1 commit into
nbr/config-optfrom
nbr/tx-cleanup

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Dec 3, 2026

Copy link
Copy Markdown
Member

Client-side mutations and background coordinators currently send unnecessary RX and TX traffic: composer sends and subagent/checkpoint actions fetch entire getThreadProjection snapshots when they only need a small slice, searchThread/searchThreadStream upload the full skills list on every keystroke, thread.visit fires every 10s during streaming turns, and backgroundActivityReporter sends redundant 45s keepalives across every open browser tab and unchanged environment.

Stacked on #48446 (nbr/config-opt). This change cuts redundant RX/TX wire traffic across server, client-runtime, Web/Desktop, and Mobile while keeping all wire changes opt-in and backwards-compatible:

  • Targeted getThreadProjection slices (orchestrationV2.ts, ws.ts, commands.ts, useComposerSend.ts, ChatView.tsx): add optional fields, subagentId, and omitCheckpointFiles to getThreadProjection (routing lightweight slices through getThreadRecords without materializing full bounded snapshots) and reuse the existing in-memory thread in useComposerSend.
  • Server-resolved thread search skills (ws.ts, server.ts, threadFind.ts, useThreadFind.ts): advertise threadFindServerSkills in ServerConfig and let the server resolve provider skills for searchThread/searchThreadStream when omitted by newer clients, eliminating per-keystroke skill TX while preserving explicit client overrides.
  • Throttle streaming thread.visit (threadVisits.ts): raise streaming heartbeat cadence from 10s to 60s while preserving immediate 0ms dispatch on thread open, unseen completion, and wake/focus, plus 10s failure retry.
  • Dedupe & slow down backgroundActivityReporter (apps/web/src/lib/backgroundActivityReporter.ts, apps/mobile/src/connection/background-activity.ts): raise foreground/background cadence to 75s/120s, skip unchanged environments within a 25s window, pause hidden tabs, re-report immediately on WebSocket reconnect via SupervisorConnectionState.generation, and dedupe visible tabs over BroadcastChannel with immediate release/scope-change takeover.

Verified with vp run check:changed (format, lint, knip, graphql, 39-package typecheck, 28 test files / 508 tests, React Compiler coverage).

Created with Gemini 4 Neon in Antigravity.

…fetches, thread-find skills TX, and visit/activity churn
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XL 500-999 changed lines (additions + deletions). labels Dec 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium

if (hasUnseenCompletion || wakeIsLatest || elapsed >= VISIT_DISPATCH_THROTTLE_MS) {

A failed non-open visit still waits up to 60 seconds to retry after reconnect, leaving the read watermark stale if the user leaves first. Once the 10-second retry cooldown expires, onShell reaches the ordinary dispatch check, which still requires elapsed >= VISIT_DISPATCH_THROTTLE_MS; let retryPending bypass that streaming throttle.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @packages/client-runtime/src/state/threadVisits.ts around line 284:

A failed non-open visit still waits up to 60 seconds to retry after reconnect, leaving the read watermark stale if the user leaves first. Once the 10-second retry cooldown expires, `onShell` reaches the ordinary dispatch check, which still requires `elapsed >= VISIT_DISPATCH_THROTTLE_MS`; let `retryPending` bypass that streaming throttle.

return;
}
if (
!payload.focused &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium lib/backgroundActivityReporter.ts:456

A visible tab can stop scope work from t=120s to t=149s: a peer report sent at t=0 still satisfies hasPeerCoverage at t=74s, so this tab skips its report until the next 75s tick, even if the peer's renewal fails. The server lease expires after 120s, so schedule a takeover before the peer lease expires or only skip when coverage lasts through the next tick.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/web/src/lib/backgroundActivityReporter.ts around line 456:

A visible tab can stop scope work from t=120s to t=149s: a peer report sent at t=0 still satisfies `hasPeerCoverage` at t=74s, so this tab skips its report until the next 75s tick, even if the peer's renewal fails. The server lease expires after 120s, so schedule a takeover before the peer lease expires or only skip when coverage lasts through the next tick.

@macroscopeapp

macroscopeapp Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — The PR reduces projection and search payloads while changing default activity-reporting, lease, and read-state update timing. Those default changes require human review of the freshness and background-work tradeoffs.

Needs human approval because:

  • 2 blocking correctness issues found at or above your repo's Minimum Blocking Severity

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire — 5.0 KiB — 6.8 KiB ✅
Codex Thread snapshot wire — 3.8 KiB — 4.9 KiB ✅
Codex Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Codex Live turn WebSocket decoded — 21.5 KiB — 24.4 KiB ✅
Codex Live turn messages — 1 — 8 ✅
Claude Total thread wire — 5.0 KiB — 6.8 KiB ✅
Claude Thread snapshot wire — 3.8 KiB — 4.9 KiB ✅
Claude Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Claude Live turn WebSocket decoded — 21.9 KiB — 24.4 KiB ✅
Claude Live turn messages — 1 — 8 ✅

Other scenarios

No main baseline exists yet for these 64 scenario measurements.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded — 10.5 KiB — 12.7 KiB ✅
Codex short turn resume WebSocket messages — 2 — 2 ✅
Codex long turn running, cold open HTTP decoded — 281.7 KiB — 302.7 KiB ✅
Codex long turn running, cold open rows — 75 — 75 ✅
Codex long turn running, history page HTTP decoded — 92.5 KiB — 107.4 KiB ✅
Codex long turn running, history page rows — 75 — 75 ✅
Codex long turn finished, cold open HTTP decoded — 381.5 KiB — 410.2 KiB ✅
Codex long turn finished, cold open rows — 151 — 151 ✅
Codex long turn finished, socket cold open WebSocket decoded — 381.6 KiB — 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages — 2 — 2 ✅
Codex long turn finished, socket cold open rows — 151 — 151 ✅
Codex long turn finished, work page HTTP decoded — 78.3 KiB — 200.2 KiB ✅
Codex long turn finished, work page rows — 75 — 150 ✅
Codex idle thread resume WebSocket decoded — 65 B — 200 B ✅
Codex idle thread resume WebSocket messages — 1 — 1 ✅
Codex fleet shell snapshot HTTP decoded — 42.4 KiB — 53.7 KiB ✅
Codex fleet shell snapshot rows — 27 — 27 ✅
Codex fleet shell subscribe WebSocket decoded — 65 B — 200 B ✅
Codex fleet shell subscribe WebSocket messages — 1 — 1 ✅
Codex fleet shell resume check HTTP decoded — 18 B — 100 B ✅
Codex fleet shell resume check rows — 0 — 0 ✅
Codex stale shell reload HTTP decoded — 42.4 KiB — 53.7 KiB ✅
Codex stale shell reload rows — 27 — 27 ✅
Codex stale shell resume WebSocket decoded — 140 B — 400 B ✅
Codex stale shell resume WebSocket messages — 2 — 2 ✅
Codex stale todo list cold open HTTP decoded — 72.4 KiB — 83.0 KiB ✅
Codex stale todo list cold open rows — 75 — 75 ✅
Codex stale todo list cold open nodes — 2 — 4 ✅
Codex stale todo list cold open subagents — 2 — 4 ✅
Codex stale todo list cold open plans — 1 — 2 ✅
Codex stale todo list cold open providerTurns — 1 — 2 ✅
Codex stale todo list cold open checkpoints — 1 — 2 ✅
Claude short turn resume WebSocket decoded — 10.6 KiB — 12.7 KiB ✅
Claude short turn resume WebSocket messages — 2 — 2 ✅
Claude long turn running, cold open HTTP decoded — 283.3 KiB — 302.7 KiB ✅
Claude long turn running, cold open rows — 75 — 75 ✅
Claude long turn running, history page HTTP decoded — 93.4 KiB — 107.4 KiB ✅
Claude long turn running, history page rows — 75 — 75 ✅
Claude long turn finished, cold open HTTP decoded — 384.2 KiB — 410.2 KiB ✅
Claude long turn finished, cold open rows — 151 — 151 ✅
Claude long turn finished, socket cold open WebSocket decoded — 384.3 KiB — 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages — 2 — 2 ✅
Claude long turn finished, socket cold open rows — 151 — 151 ✅
Claude long turn finished, work page HTTP decoded — 79.2 KiB — 200.2 KiB ✅
Claude long turn finished, work page rows — 75 — 150 ✅
Claude idle thread resume WebSocket decoded — 66 B — 200 B ✅
Claude idle thread resume WebSocket messages — 1 — 1 ✅
Claude fleet shell snapshot HTTP decoded — 43.0 KiB — 53.7 KiB ✅
Claude fleet shell snapshot rows — 27 — 27 ✅
Claude fleet shell subscribe WebSocket decoded — 66 B — 200 B ✅
Claude fleet shell subscribe WebSocket messages — 1 — 1 ✅
Claude fleet shell resume check HTTP decoded — 18 B — 100 B ✅
Claude fleet shell resume check rows — 0 — 0 ✅
Claude stale shell reload HTTP decoded — 43.0 KiB — 53.7 KiB ✅
Claude stale shell reload rows — 27 — 27 ✅
Claude stale shell resume WebSocket decoded — 140 B — 400 B ✅
Claude stale shell resume WebSocket messages — 2 — 2 ✅
Claude stale todo list cold open HTTP decoded — 73.4 KiB — 83.0 KiB ✅
Claude stale todo list cold open rows — 75 — 75 ✅
Claude stale todo list cold open nodes — 2 — 4 ✅
Claude stale todo list cold open subagents — 2 — 4 ✅
Claude stale todo list cold open plans — 1 — 2 ✅
Claude stale todo list cold open providerTurns — 1 — 2 ✅
Claude stale todo list cold open checkpoints — 1 — 2 ✅

Baseline: unavailable · PR result: ee988b0 · Source CI: success

Scenario and decoded snapshot size

10 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.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant