perf(shell): cold connects skip idle subagent threads, a third of the thread list #24648
main fromrefs/pull/24648/head·merged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubEvery client downloads the whole active thread list on cold connect. On real data that was 2.94 MB of JSON (212 KB gzip) for 1,294 threads, and 360 of those rows were subagent child threads: a third of the bytes, for rows that never show in the sidebar.
Servers now advertise shellThreadFamilies. Clients that see it ask the shell snapshot to leave out idle subagent children. A child stays while it has a live or queued run, a pending request, background work, or a subagent child of its own. When a thread is open, the client reads that thread's subagent tree once with a new getThreadFamily read and merges those rows behind the shell rows. The Lineage panel, subagent rows, the open child's toolbar and diff, and the sidebar highlight work as before. Live deltas are unchanged, so a child that wakes up comes back by itself. Nothing is migrated.
Being missing from the shell no longer means "deleted":
- The mobile outbox waits for the family read before it drops a queued message.
- Related-thread links navigate instead of showing a "no longer available" toast.
- The delete prompt asks the server (
getWorktreeThreadIds) before it offers to remove a worktree.
| Real data, branch server code | Before | After |
|---|---|---|
| Shell JSON | 2,943,983 B | 1,969,561 B (-33.1%) |
| Shell gzip | 211,900 B | 156,547 B (-26.1%) |
| Rows | 1,294 | 936 |
| Family read per open tree | none | p50 6.7 KB, p90 32 KB, max 283 KB |
Compatibility: old clients do not opt in and get the same shell. New clients on old servers see no flag and keep today's behavior. All new contract fields are optional.
After (cropped): the Lineage panel lists six idle children that the shell no longer sends, and a cold-opened idle child keeps its breadcrumb and panels.

Proof:
vp run check:changedpasses with 441 tests. New tests cover the omission rule, family and worktree reads on the SQL and memory stores, the shell generation, family retry, and the outbox rule.- Sizes were measured with this branch's server code on a read-only copy of real data.
- A dev server seeded from real data serves 279 shell rows by default and 216 with the opt-in. The web client caches 216.
- Headless web check: the omitted children open from Lineage, and a cold-opened idle child works.
- Not run on a mobile device: the local emulator fails to boot.
Not fixed here: message.dispatch to a deleted thread is accepted. This bug existed before this change.
Created with Claude Opus 5.5 in Claude Code. A three-model council reviewed the design and the implementation.
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅ Codex Live turn messages 2 2 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB −7 B (−0.1%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB −7 B (−0.6%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅ Claude Live turn messages 2 2 0 (0.0%) 8 ✅ Baseline:
6548c00· PR result:3b8d374· Source CI: successScenario 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.
No actionable comments were generated in the recent review.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: t3/explore-shell-subagents
- File: .coderabbit.config.ts
- Commit: 3b8d374
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
c73e243b-372a-4cae-ab61-91d3cdef5af1
Commits-
Reviewing files that changed from the base of the PR and between 6548c006d429e7242ebc10c34946420418a276ec and 3b8d37487bd977dda1e3dba08bfe477703918eeb.
Files selected for processing: 35-
apps/mobile/src/features/threads/ThreadRouteScreen.tsxapps/mobile/src/state/shell.tsapps/mobile/src/state/thread-outbox-model.tsapps/mobile/src/state/thread-outbox.test.tsapps/mobile/src/state/threads.tsapps/mobile/src/state/use-composer-drafts.test.tsapps/mobile/src/state/use-thread-outbox-drain.tsapps/server/src/auth/RpcAuthorization.tsapps/server/src/observability/RpcInstrumentation.tsapps/server/src/orchestration-v2/ProjectionStore.test.tsapps/server/src/orchestration-v2/ProjectionStore.tsapps/server/src/orchestration-v2/ShellStream.test.tsapps/server/src/orchestration-v2/ShellStream.tsapps/server/src/orchestration-v2/ThreadManagementService.tsapps/server/src/orchestration-v2/http.tsapps/server/src/ws.test.tsapps/server/src/ws.tsapps/web/src/components/ChatView.tsxapps/web/src/components/chat/useThreadLifecycle.tsxapps/web/src/composerDraftStore.test.tsapps/web/src/hooks/useThreadActions.tsapps/web/src/state/shell.test.tsapps/web/src/state/threads.tsdocs/internals/connection-runtime.mdpackages/client-runtime/src/state/orchestration.tspackages/client-runtime/src/state/shell-sync.test.tspackages/client-runtime/src/state/shell.tspackages/client-runtime/src/state/shellSnapshotHttp.tspackages/client-runtime/src/state/threadFamilies.test.tspackages/client-runtime/src/state/threadFamilies.tspackages/client-runtime/src/state/threads.tspackages/contracts/src/environmentHttp.tspackages/contracts/src/orchestrationV2.tspackages/contracts/src/rpc.tspackages/contracts/src/server.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
-
Walkthrough
-
The change adds optional idle-subagent filtering to shell snapshots and subscriptions, plus RPCs for retrieving thread-family rows and worktree thread IDs. Clients track shell generations and removals, merge mounted family reads, and use these results when displaying threads, draining queued messages, and checking worktree cleanup.
Changes: Thread Family Shell Synchronization
Priority:Layer / File(s) Summary Shell filtering and query contracts
packages/contracts/src/environmentHttp.ts,packages/contracts/src/orchestrationV2.ts,packages/contracts/src/rpc.ts,packages/contracts/src/server.tsContracts add the omitIdleSubagentsquery and subscription options, thread-family and worktree-thread-ID RPC schemas, and theshellThreadFamiliescapability.Server filtering and query handlers
apps/server/src/orchestration-v2/ProjectionStore.ts,apps/server/src/orchestration-v2/ThreadManagementService.ts,apps/server/src/orchestration-v2/ShellStream.ts,apps/server/src/orchestration-v2/http.ts,apps/server/src/ws.ts,apps/server/src/auth/RpcAuthorization.ts,apps/server/src/observability/RpcInstrumentation.ts,apps/server/src/orchestration-v2/*test.ts,apps/server/src/ws.test.tsShell reads can filter by family or worktree path. HTTP snapshots and WebSocket subscriptions can omit idle subagents. The new RPC handlers return family rows with a snapshot sequence or worktree thread IDs. Client shell state and family merging
packages/client-runtime/src/state/shell.ts,packages/client-runtime/src/state/shellSnapshotHttp.ts,packages/client-runtime/src/state/threadFamilies.ts,packages/client-runtime/src/state/orchestration.ts,packages/client-runtime/src/state/threads.ts,packages/client-runtime/src/state/*test.ts,apps/mobile/src/state/shell.ts,apps/mobile/src/state/use-composer-drafts.test.ts,apps/web/src/state/shell.test.ts,apps/web/src/composerDraftStore.test.ts,docs/internals/connection-runtime.mdClient shell state tracks snapshot generations and removals. Family reads are mounted and merged with shell rows, subject to removal sequences. Shell synchronization requests idle-subagent omission when the server advertises support. Thread views, queued messages, and worktree cleanup
apps/mobile/src/features/threads/ThreadRouteScreen.tsx,apps/mobile/src/state/threads.ts,apps/mobile/src/state/thread-outbox-model.ts,apps/mobile/src/state/thread-outbox.test.ts,apps/mobile/src/state/use-thread-outbox-drain.ts,apps/web/src/components/ChatView.tsx,apps/web/src/components/chat/useThreadLifecycle.tsx,apps/web/src/state/threads.ts,apps/web/src/hooks/useThreadActions.tsThread views mount family reads. Queued messages wait for unsettled family reads before treating a missing thread as removed. Worktree cleanup checks server-reported thread IDs when family support is enabled. NormalEstimated code review effort: 4 (Complex) | ~45 minutes
Change: Feature
Sequence Diagram(s)#
sequenceDiagram participant ThreadView participant ClientRuntime participant WsServer participant ProjectionStore ThreadView->>ClientRuntime: mount thread family ClientRuntime->>WsServer: getThreadFamily(threadId) WsServer->>ProjectionStore: read family shell rows and snapshot sequence ProjectionStore-->>WsServer: family rows and sequence WsServer-->>ClientRuntime: family rows and sequence ClientRuntime-->>ThreadView: merged shell snapshotSuggested labels:
size:XXL,📱 Native Change,macroscope-reviewSuggested reviewers:
juliusmarminge,maria-rcks
Merge Risk:
Minimal · up to3b8d3-
No identified issue remains that should block merging after normal checks.
Pre-merge checks:
3 · 1-
Failed checks: 1 inconclusiveCheck name Status Explanation Resolution Description check The description covers the template sections. Problem: it explains that every cold connect downloads the full active thread list, including 360 idle subagent rows, with measured sizes. Change: it expl… Add a link to the triaged issue or maintainer discussion that approved this direction and scope, including the approval comment, or explain why this change qualifies as an exemption under the Scope and approval rules. The rest of the descri… Passed checks: 3 passed-
Check name Status Explanation Title check The title "perf(shell): cold connects skip idle subagent threads, a third of the thread list" matches the main change. The changeset adds the optional shellThreadFamilies capability, so shell snapshot… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Title check
-
Explanation
The title "perf(shell): cold connects skip idle subagent threads, a third of the thread list" matches the main change. The changeset adds the optional shellThreadFamilies capability, so shell snapshots omit idle subagent child threads, and clients load a thread's family on demand. The title follows conventional commit form and names the primary change and its effect. It is 81 characters, which is slightly long, but it is specific and clear.
-
Full details: Description check
-
Explanation
The description covers the template sections. Problem: it explains that every cold connect downloads the full active thread list, including 360 idle subagent rows, with measured sizes. Change: it explains the shellThreadFamilies capability, the getThreadFamily read, and the mobile outbox, related-thread, and worktree-deletion adjustments. Verification: it lists check:changed with 441 tests, measured sizes, a dev-server check, a headless web check, and a note that mobile was not run. Scope and approval: the template asks for a linked triaged issue or maintainer approval, and the description has no such link or approval reference. It does say that the change is a performance fix with compatibility behavior, but it gives no issue link or approval. The description also includes a note on an unfixed bug and an agent attribution line. Those lines are acceptable.
Resolution
Add a link to the triaged issue or maintainer discussion that approved this direction and scope, including the approval comment, or explain why this change qualifies as an exemption under the Scope and approval rules. The rest of the description is complete.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Approvability#
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — This PR introduces a new thread-family RPC/state-management path and changes default shell synchronization, outbox, lifecycle, and worktree-cleanup behavior across server, web, and mobile code. Its cross-layer runtime impact and auth-surface change require human review.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).