Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(client-runtime): opening a thread no longer freezes with thousands of threads #25853

Closedjuliusmarmingewants to merge 5 commits intomain fromfix/issue-25823opened View on GitHub

juliusmarmingecommented

Problem

With ~13k threads, opening a large orchestration thread froze the desktop renderer for about a minute. environment-quiet-thread-shell-list read one per-thread quiet shell atom per thread. That kept every per-thread shell atom observed. Each shell frame from the server then re-ran all of them and rebuilt the whole list once per changed thread, part-way through propagation. Subscribers also received the half-applied lists in between. A driver over the real atoms with 13,037 threads and 5 changed threads per frame measured 83 ms and 5 list rebuilds per frame on main.

Change

quietThreadShellsAtom now builds directly from each enabled environment's thread array and pending subagent requests, the same way threadShellsAtom and navigationThreadShellsAtom already do. It applies the same streaming-tick hold per thread from list-local previous shells, which are rebuilt each pass so removed threads are dropped. The list no longer subscribes to per-thread atoms, so a shell frame rebuilds it once, with the final values. Order, membership (subagent and archived threads included) and reference stability when nothing changed are unchanged. Point reads through quietThreadShellAtom are untouched.

Scope and approval

Fixes pingdotgg/t3code#25823

Verification

  • vp test run packages/client-runtime/src/state/threadShell.test.ts: 10/10 pass. The new test "delivers one quiet shell list per snapshot update that changes several threads" fails on main because one update delivers three lists, two of them half-applied (a renamed, b, c, d, then a renamed, b renamed, c, d). It passes on this branch.

  • vp run check:changed: format, lint, knip, typecheck (7 packages) and tests pass.

  • Runtime transcript from a scratch driver over the real createEnvironmentThreadShellAtoms with synthetic threads. It mounts the quiet list as the sidebar does and times only registry.set per shell frame (Node 26, this VM):

    13,037 threadsmain 96fc7b9551this branch 6fd4cfcb9a
    5 changed threads per frame83 ms, 5 list rebuilds3.8 ms, 1 list rebuild
    1 changed thread per frame41.6 ms—
    2,900 frames × 5 changed—11.6 s total (3.7 s with the list unmounted)
    quiet list not mounted1.3 ms1.3 ms

    The list still walks every thread once per frame. That per-frame cost is now in line with the other shell lists, which already did the same.

  • Driver (scratch, not committed): issue-25823-quiet-list-driver.ts. Transcript: issue-25823-driver-transcript.txt

  • No visual change, so there are no captures. Not checked: the reporter's real 13k-thread desktop profile, and mobile (it shares this client-runtime code but reads only point atoms).

Claude Opus 5.5 (lead, red test, implementation, reviewer B) and GPT-6.1-Sol (reviewer A), in T3 Code via the Claude Code and Codex harnesses.

🤖 Generated with Claude Code

    1. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 3a4a1c8

      Macroscope's review found this PR approvable — The thread list now maintains its own cached shells rather than subscribing to each thread individually, reducing update fan-out for large histories. Existing filtering and streaming-update suppression remain intact, with effects confined to client presentation state.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      quietThreadShellsAtom now builds quiet-shell lists from enabled environments and thread snapshots. It skips hidden threads and caches shells by environment and thread ID, reusing shells for identical or streaming-only updates. A test checks subscription delivery after one snapshot update renames three threads.

      Changes: Quiet thread shell updates

      Layer / File(s)Summary
      List rebuilding and update validation
      packages/client-runtime/src/state/threadShell.ts, packages/client-runtime/src/state/threadShell.test.ts
      The atom builds the list from enabled environments and thread snapshots, skips hidden threads, and reuses cached shells for identical or streaming-only updates. The test checks that one snapshot update delivers the three renamed titles and the unchanged fourth title.

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

      Change: Bug fix · Severity of issue fixed: Medium

      Possibly related issues

      • pingdotgg/t3code#9661 — This PR removes per-thread quiet-shell subscriptions and changes how quiet-list updates are built, which addresses the listed performance behavior.

      Possibly related PRs

      Suggested reviewers: t3dotgg

      Merge Risk: Minimal · up to 3a4a1

      The change rebuilds the quiet thread list once per update instead of once per thread, which should remove the freeze when opening a thread among thousands. No merge-blocking risk was found.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title clearly and concisely describes the main fix: preventing freezes when opening threads in repositories with thousands of threads.
      Description checkPassedThe description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the issue, implementation, linked issue, test results, performance measurements, limit…
      Linked Issues checkPassedIssue [#25823] requires the quiet thread list to avoid repeated full-list rebuilds that freeze the renderer. The updated quietThreadShellsAtom reads enabled environment thread arrays and pending sub…
      Out of Scope Changes checkPassedThe changes are limited to the quiet shell list implementation and its focused regression test. The implementation directly addresses [#25823]. The test supports the required delivery behavior and hid…
      Full details: Description check

      Explanation

      The description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the issue, implementation, linked issue, test results, performance measurements, limitations, and agent usage.

      Full details: Linked Issues check

      Explanation

      Issue [#25823] requires the quiet thread list to avoid repeated full-list rebuilds that freeze the renderer. The updated quietThreadShellsAtom reads enabled environment thread arrays and pending subagent requests directly. It no longer reads one quiet-shell atom per thread. It preserves hidden-thread filtering, shell reuse, and list reference stability. The regression test verifies one delivery after several thread changes and verifies hidden-thread exclusion. The reported checks also pass.

      Full details: Out of Scope Changes check

      Explanation

      The changes are limited to the quiet shell list implementation and its focused regression test. The implementation directly addresses [#25823]. The test supports the required delivery behavior and hidden-thread behavior. No unrelated product behavior or unrelated files are included.

      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
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between da9db8b08b16130745600e1aa682bcdb24850884 and 3a4a1c81176603318f685dc3acdc485d5f3c46c3.

      Files selected for processing: 2

      • packages/client-runtime/src/state/threadShell.test.ts
      • packages/client-runtime/src/state/threadShell.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

    3. t3dotgg(GitHub profile, opens in a new tab) approved these changes

      Note

      🤖 GPT-6.1 Sol responding on behalf of Theo

      Approved at da9db8b08b16130745600e1aa682bcdb24850884.

      I applied the new regression test to current main bbd9593973. It failed because the list delivered partial updates. With the implementation applied, all 12 tests passed, and vp run check:changed passed, including typechecks for seven packages. The source and test paths are unchanged on main 8d94203c17.

      This removes per-thread atom fan-out. Cross-environment delegated approvals can still notify the task before its parent's request flag, as on main; this approval does not claim atomic delivery for those updates.

    4. juliusmarminge added labelsbugfix

    5. juliusmarminge added labelspr:gate-failed

    6. Additional validation on official macOS arm64 v0.1.5, following my v0.1.3 synthetic reproduction and live debugger confirmation.

      The freeze recurred after upgrading from locally patched 0.1.3 to unmodified 0.1.5. Both the shipped runtime-DV8b3pOc.js and current main at 9b1d351ba0 retain the per-thread quiet-atom loop. I backported this PR's logic at da9db8b08b16130745600e1aa682bcdb24850884 into a staged 0.1.5 app, retaining 0.1.5's existing streaming comparator and delegated-request inputs.

      Packaged-logic measurements

      The factory and relevant helpers were extracted from the shipped asset and run with the earlier synthetic harness and its existing source model/schema/reactivity dependencies (v0.1.3 checkout, Node 26.0.0, Effect 4.0.5). This checks the packaged algorithm; it is not a full v0.1.5 source-suite or browser benchmark. Timing covers one synchronous registry.set, excluding fixture construction and mounting.

      Synthetic threads / changed rowsOfficial 0.1.5 factoryBackported factoryList deliveries before → after
      4,000 / all3,489 ms (one update)10.9–11.2 ms (three updates)4,000 → 1
      26,138 / allNot run34.5–41.3 ms (three updates)— → 1

      Additional checks passed for unchanged list identity, streaming-only count changes retaining quiet shells, a single complete list after bulk title changes, thread removal, and environment disable/re-enable. As noted in the existing approval, this does not establish atomic delivery across cross-environment delegated-approval updates.

      Installed-app observation

      Verified that exactly one of 2,681 ASAR payload files changed, updated archive integrity metadata, and installed the locally signed copy with the original app preserved. The long conversation loaded, the desktop served the patched asset, and the existing remote server stayed running. Local record counts and settings hash were unchanged. Renderer CPU was 0.9% in an early idle observation and 8.0% around two minutes after launch; these are bounded observations, not a sustained frame-rate measurement. I did not capture a new live JS profile of the unmodified 0.1.5 recurrence.

      One practical cost of the local workaround: ad-hoc signing changes the designated requirement, so the macOS automatic updater rejects the next official build. The official update package itself passed signature/notarization checks. An official release containing this fix would avoid that manual-upgrade tradeoff.

      This supports the existing PR rather than a competing fix. Is there any remaining validation needed for merging it? I can check a proposed revision against this large-thread workload.

      Validation performed with Codex assistance; no private conversation data is included.

    7. The automated pipeline stopped on this pull request and will not merge it:

      someone else pushed to fix/issue-25823 (head is now da9db8b08b); the pipeline does not build on commits it did not review

      It stays open for a person to finish or close.

    8. tanstack-source added labelsbug

    9. Thanks for this. #35848 makes the same change and is the one being kept.

      #35848 carries this same fix and regression test forward with newer main incorporated. It explicitly supersedes this submission, so it is the version to continue reviewing.

      Your implementation and original commits are preserved there, including the streaming-update suppression and hidden-thread filtering.

      Closing as a duplicate.

    10. juliusmarminge closed this

Sign in to join this conversation.