fix(server): thread lists keep syncing past 32,766 threads #25691
main fromrefs/pull/25691/head·opened View on GitHubProblem#
Servers with more than 32,766 matching threads exceed SQLite’s parameter limit when loading thread lists. Sidebar updates stop across web, desktop, and mobile even though agents keep running.
Fixes #25621.
Change#
Pass thread and run ID lists as one JSON parameter using json_each, instead of binding a separate parameter for every ID. This avoids SQLite’s parameter limit without changing thread-list filtering.
Scope and approval#
This addresses only the query-limit failure reported in #25621, with a focused regression test. No client behavior changes or unrelated performance work are included.
Verification#
- Added a regression test with 32,768 threads. It failed before the fix with
too many SQL variablesand passes afterward. - All 47 tests in
ProjectionStore.test.tspass. Format, lint, and server typecheck pass. - Manually tested an isolated dev server seeded with 34,948 threads, mostly idle subagents. Opened the app in two browser tabs and confirmed thread creation and renaming synced without refreshing. Reloading also loaded the sidebar successfully.
- Screen recording attached.
- Full
check:changedwas interrupted by an out-of-memory kill. Verification was run separately afterward; knip, GraphQL generation, and depende
https://github.com/user-attachments/assets/b27ef2de-41b4-40b1-a293-0ee402577594
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Approved at
bd33236Macroscope's review found this PR approvable — This focused server bug fix replaces per-ID SQLite bindings with one JSON parameter for existing shell snapshot filters, preventing thread-list synchronization from failing above SQLite’s parameter limit. It includes a regression test covering 32,768 threads and does not alter product defaults or static-analysis settings.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: 78e93fd
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
58d8576f-d0d2-4ff1-aa61-9abb9da30784
Commits-
Reviewing files that changed from the base of the PR and between 78e93fd9d15ccecb2009804ee308fce2bd7b21dc and bd33236a644d662f1e95aa2c2e6cd9fadcf3b841.
Files selected for processing: 2-
apps/server/src/orchestration-v2/ProjectionStore.test.tsapps/server/src/orchestration-v2/ProjectionStore.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
Walkthrough
-
ProjectionStore now uses a single JSON parameter with
json_eachfor shell snapshot ID-list filters. A regression test verifies that an active project shell snapshot returns 32,768 threads.Changes: Shell snapshot ID filtering
Priority:Layer / File(s) Summary JSON-backed filters and regression coverage
apps/server/src/orchestration-v2/ProjectionStore.ts,apps/server/src/orchestration-v2/ProjectionStore.test.tsAdded inJsonListand replaced per-IDsql.infilters for shell threads, runs, item counts, provider threads, pending turn items, and active-run work. Added a regression test that checks a snapshot containing 32,768 threads. NormalEstimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related PRs
- pingdotgg/t3code#24723: Adds the
threadIdsshell filter; this PR changes how that filter binds large ID lists.
Suggested reviewers:
juliusmarminge,t3dotgg,yash-singh1 - pingdotgg/t3code#24723: Adds the
Merge Risk:
Minimal · up tobd332-
The JSON-backed filtering change preserves existing behavior while avoiding SQLite’s bound-parameter limit; no actionable merge risk remains.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the main change: thread lists in the server keep syncing past 32,766 threads. The changeset replaces per-ID SQL bound parameters with a single JSON parameter expanded through json_each… Linked Issues check Issue #25621requires that shell snapshot loading succeed when a server has more than 32,766 matching threads. The failure comes fromthread_id IN ${sql.in(...)}bindings in the shell snapshot queri…Out of Scope Changes check The PR changes two files. apps/server/src/orchestration-v2/ProjectionStore.tsswaps the ID-list bindings in the shell snapshot queries for theinJsonListhelper. Each swapped query is part of the …Description check The description includes all required sections. It clearly explains the SQLite parameter-limit problem, the JSON and json_each change, the focused scope, regression testing, manual verification, and t… Full details: Title check
-
Explanation
The title names the main change: thread lists in the server keep syncing past 32,766 threads. The changeset replaces per-ID SQL bound parameters with a single JSON parameter expanded through json_each, which addresses the SQLite parameter limit that causes this failure. The title is in conventional commit format and is specific enough for a reviewer scanning history.
Full details: Linked Issues check
-
Explanation
Issue
#25621requires that shell snapshot loading succeed when a server has more than 32,766 matching threads. The failure comes fromthread_id IN ${sql.in(...)}bindings in the shell snapshot queries ofProjectionStore.ts. The diff replaces these bindings withinJsonList(...), which sends the ID list as one JSON parameter read throughjson_each. The diff covers each query the issue names: shell thread selection (threadIds),selectShellRunRows,selectShellRunItemCounts, the total item count query,selectShellProviderThreadRows,selectShellPendingTurnItemRows(both the thread filter and theactiveRunIdsfilter). The issue listsjson_each(?)as an acceptable fix. Because the helper is applied in the shared store layer, the server-internal callers named in the issue (getShellSnapshot()with no location filter) also get the fix. The regression testreads a shell snapshot with more threads than SQLite allows bound parametersseeds 32,768 threads and asserts that an active project snapshot returns all of them. The PR author reports that this test failed before the change withtoo many SQL variables. Filtering semantics are preserved:IN (SELECT value FROM json_each(...))returns the same matches asIN (?, ...), and an empty list matches no rows in both forms. Limits of this review:encodeIdListis used in the new helper but is not part of this diff. It is treated as an existing helper in the same file. The author reports that the server typecheck passes. Client-side sync and desktop/mobile behavior are downstream effects and were not verified in code. The PR states these are unchanged.
Full details: Out of Scope Changes check
-
Explanation
The PR changes two files.
apps/server/src/orchestration-v2/ProjectionStore.tsswaps the ID-list bindings in the shell snapshot queries for theinJsonListhelper. Each swapped query is part of the failing shell snapshot path named in#25621.apps/server/src/orchestration-v2/ProjectionStore.test.tsadds one regression test for the same failure. Neither file has changes unrelated to the query-limit fix. No client, contract, or unrelated performance change appears in the reviewed diff. The PR description matches this scope.
Full details: Description check
-
Explanation
The description includes all required sections. It clearly explains the SQLite parameter-limit problem, the JSON and json_each change, the focused scope, regression testing, manual verification, and the incomplete check:changed run. The Scope and approval section identifies issue
#25621and explains why the change is focused.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
Note
🤖 Claude Opus 5.5 responding on behalf of Theo
Closing: this is covered by #25696, which landed. Reopen if a needed part is still missing.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes