Skip to content

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

Closed
juliusmarminge wants to merge 5 commits into
mainfrom
fix/issue-25823
Closed

juliusmarminge wants to merge 5 commits into
mainfrom
fix/issue-25823

Conversation

@juliusmarminge

Copy link
Copy Markdown
Member

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 #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 threads main 96fc7b9 this branch 6fd4cfc
    5 changed threads per frame 83 ms, 5 list rebuilds 3.8 ms, 1 list rebuild
    1 changed thread per frame 41.6 ms —
    2,900 frames × 5 changed — 11.6 s total (3.7 s with the list unmounted)
    quiet list not mounted 1.3 ms 1.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

juliusmarminge and others added 3 commits October 27, 2026 08:24
… quiet list per changed thread

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…date

The quiet thread shell list read one quiet atom per thread, and each of those
read the whole thread index. Every shell frame re-ran all of them and rebuilt
the list once per changed thread, which froze the renderer for about a minute
when a thread opened with ~13k threads.

The list now builds from each enabled environment's threads and pending
subagent requests, the same way the other shell lists do. It holds shells
through streaming ticks itself, keyed by thread and pruned on every rebuild.

Fixes #25823

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Oct 27, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Oct 27, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Track performance audit fixes #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 name Status Explanation
Title check Passed The title clearly and concisely describes the main fix: preventing freezes when opening threads in repositories with thousands of threads.
Description check Passed The 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 check Passed 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 sub…
Out of Scope Changes check Passed 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 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 da9db8b and 3a4a1c8.

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.

@t3dotgg t3dotgg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

GigaZoro pushed a commit to GigaZoro/CodeShip that referenced this pull request Oct 30, 2026
…s of threads (upstream pingdotgg#25853)

Cherry-picked from pingdotgg#25853

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@juliusmarminge juliusmarminge added bugfix Fix PR opened by an issue lead; enters the PR loop pr:gate-failed A land gate failed labels Oct 30, 2026
@reed-yang

Copy link
Copy Markdown

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 rows Official 0.1.5 factory Backported factory List deliveries before → after
4,000 / all 3,489 ms (one update) 10.9–11.2 ms (three updates) 4,000 → 1
26,138 / all Not run 34.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.

Copy link
Copy Markdown
Member Author

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

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

It stays open for a person to finish or close.

@macroscopeapp
macroscopeapp Bot dismissed their stale review November 11, 2026 08:04

Dismissing prior approval to re-evaluate 3a4a1c8

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Nov 11, 2026
@juliusmarminge

Copy link
Copy Markdown
Member Author

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.

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

Labels

bugfix Fix PR opened by an issue lead; enters the PR loop pr:gate-failed A land gate failed size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

3 participants