Repository navigation
Description
What happened
An agent switched the branch in a worktree that 636 threads share: one active coordinator and 635 archived subagent threads. The server then updated the branch of the archived threads one at a time, about 14 a minute (506 in the first 36 minutes). The web client had the thread details side panel open, which loads the archived thread list for its Lineage section. It requested orchestration.getArchivedShellSnapshot after every update and cancelled the request in flight each time. The server finished every cancelled request anyway, at 17 to 25 s each. The server averaged 2.4 cores in the hour that included the sync, against 0.9 cores over the 3.5 hours before.
Diagnosis
Three parts add up:
WorktreeBranchSync.reconcilereads worktree paths withincludeArchived: trueand dispatches onethread.metadata.updateper thread that shares the worktree, one after another. Archived threads get the new branch too, each in its own command.- The shell reports a change to an archived thread as a removal.
archivedShellSnapshotinpackages/client-runtime/src/state/orchestration.tsusesremovedAtas itsrefreshTrigger, so every update reloads the whole archived list and interrupts the request in flight. The list is loaded by Settings → Archived threads and byThreadRelationshipsPanel, the Lineage section of the thread details side panel, which can stay open all day. - Interrupting the RPC does not stop the server's read.
readShellSnapshot({ location: "archive" })reads every archived thread's shell row ([Bug]: Archived threads take 6 to 18 s to load: getArchivedShellSnapshot reads every archived thread, and one API client can hold all four readers #32805), so each reload costs the full read again. The reads queue on the database and keep it busy for the whole sync.
Together, one git checkout kept the server reading the archived list for as long as the sync ran.
Possible fixes, any one of which breaks the chain: skip archived threads in the branch sync, or update them in one command; reload the archived list at most once per interval while removals keep arriving, or apply them as deltas; let the server stop a snapshot read whose request was cancelled. For scale: on the same database, an archived list kept between requests that rereads only the threads with events since its last read answered in 40 ms instead of 25 s, with identical output.
Steps to reproduce
- Have a few thousand archived threads, a few hundred of which share one worktree (here: delegated subagent threads that ran in their coordinator's worktree and were archived).
- In the web app, open any thread with the thread details side panel showing its Lineage section.
- Run
git switch -c another-branchin the shared worktree. - Watch
orchestration.getArchivedShellSnapshotinserver.trace.ndjson: one request per updated archived thread, each interrupted by the next.
Version
Server 0.1.11-nightly.20261117.4838 (t3 serve as a systemd service) with local patches to some SQLite reads. One of them makes the archived list read faster; none touch the branch sync or the client. Web client 0.1.11-nightly.20261117.4838, unmodified.
Environment
Linux (Proxmox LXC, 16 CPUs, ZFS), Firefox web client on another machine against this server. statev2.sqlite 48 GB, about 8,000 archived threads.
Evidence
orchestration.getArchivedShellSnapshot client spans from the one web client, per 10 minutes (UTC), as requests/interrupted:
19:10 6/4 19:20 8/5 19:30 57/55 19:40 115/115 19:50 122/122 20:00 123/123
The branch switch was at 19:35. Branch-sync thread.metadata.update events on archived threads (one command each) per 10 minutes: 19:30 97, 19:40 139, 19:50 130, 20:00 100. Server statement log from 19:35 to 20:15: 451 archived shell reads, median 16.5 s, longest 22.1 s.
Related issues
#32805 (the archived list reads every archived thread). #31599 introduced threads following their worktree's branch.
Fix applied or workaround
No fix applied. Closing the thread details panel (and Settings → Archived threads) should stop the reloads until the sync ends; not tried here.
Filed by
Measured and written by Claude (Opus 5.5) in T3 Code; posted with the owner's approval.
Activity