Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): thread lists keep syncing past 32,766 threads #25691

ClosedBilalIrfanContact(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/25691/headopened View on GitHub

Problem

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 variables and passes afterward.
  • All 47 tests in ProjectionStore.test.ts pass. 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:changed was 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

    2. Approvability

      Verdict: Approved at bd33236

      Macroscope'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).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review.

      Recent review info
      Run configuration
      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.ts
      • apps/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_each for shell snapshot ID-list filters. A regression test verifies that an active project shell snapshot returns 32,768 threads.

      Changes: Shell snapshot ID filtering

      Layer / File(s)Summary
      JSON-backed filters and regression coverage
      apps/server/src/orchestration-v2/ProjectionStore.ts, apps/server/src/orchestration-v2/ProjectionStore.test.ts
      Added inJsonList and replaced per-ID sql.in filters 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.
      Priority: Normal

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Possibly related PRs

      • pingdotgg/t3code#24723: Adds the threadIds shell filter; this PR changes how that filter binds large ID lists.

      Suggested reviewers: juliusmarminge, t3dotgg, yash-singh1

      Merge Risk: Minimal · up to bd332

      The JSON-backed filtering change preserves existing behavior while avoiding SQLite’s bound-parameter limit; no actionable merge risk remains.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe 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 checkPassedIssue #25621 requires that shell snapshot loading succeed when a server has more than 32,766 matching threads. The failure comes from thread_id IN ${sql.in(...)} bindings in the shell snapshot queri…
      Out of Scope Changes checkPassedThe PR changes two files. apps/server/src/orchestration-v2/ProjectionStore.ts swaps the ID-list bindings in the shell snapshot queries for the inJsonList helper. Each swapped query is part of the …
      Description checkPassedThe 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 #25621 requires that shell snapshot loading succeed when a server has more than 32,766 matching threads. The failure comes from thread_id IN ${sql.in(...)} bindings in the shell snapshot queries of ProjectionStore.ts. The diff replaces these bindings with inJsonList(...), which sends the ID list as one JSON parameter read through json_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 the activeRunIds filter). The issue lists json_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 test reads a shell snapshot with more threads than SQLite allows bound parameters seeds 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 with too many SQL variables. Filtering semantics are preserved: IN (SELECT value FROM json_each(...)) returns the same matches as IN (?, ...), and an empty list matches no rows in both forms. Limits of this review: encodeIdList is 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.ts swaps the ID-list bindings in the shell snapshot queries for the inJsonList helper. Each swapped query is part of the failing shell snapshot path named in #25621. apps/server/src/orchestration-v2/ProjectionStore.test.ts adds 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 #25621 and 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
      Comment `@coderabbitai help` to get the list of available commands.
    4. 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.

Sign in to join this conversation.