Repository navigation
perf(client): unarchiving or deleting an archived thread reads the archive once - #40535
juliusmarminge wants to merge 2 commits into
Conversation
…chive once The archive's own action refreshed the list twice (the action hook and the panel), and the shell's removal for the same action triggered a third read on delete. Drop the panel's (and mobile's) duplicate refresh, and skip the shell-removal refresh when the loaded or in-flight archive already covers it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
… archive and delete The shell's thread.removed push can land before the command's reply, so the archive refresh trigger started one read and the action's explicit refresh restarted it with a second. Archive and delete always reach an open archive as a shell removal, so drop their explicit refresh on web and mobile; only unarchive, which is no removal, refreshes explicitly. This replaces the snapshotSequence check on the trigger. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Unarchiving or deleting a thread from Settings → Archived downloaded the whole archived list two (unarchive) or three (delete) times per click, about 100 KB each with ~50 archived threads. Now each action reads the list once.
ArchivedThreadsPanelno longer refreshes the archive itself;useThreadActionsalready does after a successful unarchive or delete. The unusedrefreshis gone from the webuseArchivedThreadSnapshots.archivedShellSnapshotrefresh trigger inclient-runtimenow skips a shell removal that the loaded or in-flight archive read already covers (bysnapshotSequence). Removals from other clients still refresh the list.useThreadActionExecutor's own.Fixes #40497
Reproduction on main
Windows Server 2025 (4 vCPU, 16 GB) from the shared pool, origin/main fcf5097. vp i, vp build in apps/web, then with T3CODE_DEV_SEED=0:
node src/bin.ts serve --base-dir C:/p/home --port 4800 --host 127.0.0.1with the Replay (dev) provider from the report's settings.json;project addon a small git repo with a remote; seeded 76 threads withthread start --provider devReplay --model command-outputin 4 parallel loops; archived 59 of them through the sidebar context menu (Playwright). Then the reporter's settings.cjs driver (headless Chromium on /settings/archived, recording WebSocket requests), with a freshpairtoken minted per run. Unarchive, 7 runs (59->52 archived): orchestration.getArchivedShellSnapshot sent 2 times per click on every run, both in the same ms (~40-65 ms after the thread.unarchive dispatch), each answered with ~111 KB (49152+49152+13011 bytes at 58 archived, ~1.9 KB/thread). Row gone: 440, 297, 280, 267, 258, 390, 276 ms, median 280 ms (258-440). Delete with Confirm, 7 runs (52->45 archived): 3 snapshots per delete on every run, two in the same ms ~65-80 ms after thread.delete and a third 30-130 ms later (e.g. +301 dispatch, +376, +376, +443). Row gone: 490, 418, 795, 414, 409, 674, 407 ms, median 418 ms (407-795). Server span timings were not captured.Evidence
Being captured: before and after in the real app. This section is filled in before the pull request can merge.
Tests
vp test run src/state/runtime.test.ts(packages/client-runtime, previous round): 46 passed, including the extended archive refresh test, which fails without the trigger changevp run check:changed(previous round): lint, knip, typecheck, tests and react compiler passed aftervp fmtvp test run src/reactCompilerCoverage.test.ts(apps/mobile): 1162 passed; the archive hook and route screen compile with no bailoutuseArchivedThreadSnapshots.tsandArchivedThreadsRouteScreen.tsxwith Metro's babel preset:refreshis memoized onenvironmentIds, and theuseFocusEffectcallback onrefreshNot in this change
environmentIdsgets a new identity whenever any saved connection record changes, which re-runs the Archived screen's focus refresh once; no archive action triggers this, and it predates this change.Who did the work
Run by the t3code factory in T3 Code.