Skip to content

perf(client): unarchiving or deleting an archived thread reads the archive once - #40535

Open
juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-40497
Open

juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-40497

Conversation

@juliusmarminge

Copy link
Copy Markdown
Member

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.

  • ArchivedThreadsPanel no longer refreshes the archive itself; useThreadActions already does after a successful unarchive or delete. The unused refresh is gone from the web useArchivedThreadSnapshots.
  • The archivedShellSnapshot refresh trigger in client-runtime now skips a shell removal that the loaded or in-flight archive read already covers (by snapshotSequence). Removals from other clients still refresh the list.
  • Mobile's archive screen dropped the same duplicate refresh on top of 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.1 with the Replay (dev) provider from the report's settings.json; project add on a small git repo with a remote; seeded 76 threads with thread start --provider devReplay --model command-output in 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 fresh pair token 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 change
  • vp run check:changed (previous round): lint, knip, typecheck, tests and react compiler passed after vp fmt
  • vp test run src/reactCompilerCoverage.test.ts (apps/mobile): 1162 passed; the archive hook and route screen compile with no bailout
  • Compiled useArchivedThreadSnapshots.ts and ArchivedThreadsRouteScreen.tsx with Metro's babel preset: refresh is memoized on environmentIds, and the useFocusEffect callback on refresh
  • Windows Server 2025 before/after measurement with a Playwright driver (previous round, 7 unarchives and 7 deletes per side): snapshots per action 2→1 (unarchive) and 3→1 (delete) on every run

Not in this change

  • The archived-list RPC still returns the full archived list on every refresh; removing just the changed row locally, or a paged/delta archive read, would cut the remaining request but is a larger design change.
  • Archiving a thread elsewhere (sidebar) still refreshes the archive atom explicitly and through the shell removal signal; the new trigger check skips the second read when the first is in flight, but I did not measure that path.
  • On mobile, environmentIds gets 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

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

…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]>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 21, 2026
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Web and mobile archived-thread actions no longer request explicit archived-snapshot refreshes. The snapshot hook no longer exposes a refresh callback. Tests now check the updated action behavior.

Changes: Archived snapshot action refreshes

Layer / File(s) Summary
Remove the settings refresh callback
apps/web/src/lib/archivedThreadsState.ts, apps/web/src/components/settings/ArchivedThreadsPanel.tsx
The snapshot hook no longer returns a refresh callback. The settings panel no longer refreshes snapshots after unarchive or delete actions.
Remove action-specific refresh requests
apps/web/src/hooks/useThreadActions.ts, apps/web/src/hooks/useThreadActions.permissions.test.ts, apps/mobile/src/features/home/useThreadListActions.ts, apps/mobile/src/features/home/useThreadListActions.test.ts, apps/mobile/src/features/archive/ArchivedThreadsRouteScreen.tsx
Web and mobile action handlers remove explicit snapshot refresh requests. The mobile hook no longer accepts a completion callback, and its callers and tests are updated.

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

Change: Refactor · Severity of issue fixed: Medium

Possibly related issues

Possibly related PRs

  • pingdotgg/t3code#40443: It removes explicit archived-thread refreshes in overlapping web and mobile action paths.

Suggested reviewers: saphid, macroscopeapp, maria-rcks

Merge Risk: Minimal · up to 3892a

Archived-thread unarchive and delete actions no longer issue duplicate archived-list refreshes on web or mobile, and removal events still refresh the open archive. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: unarchiving or deleting an archived thread now reads the archive once. It uses a conventional commit prefix (perf(client)) and states the user-visible effect. Scope ma…
Description check Passed The description follows the repository template closely. It has Problem, Change, Scope, Verification, and an agent attribution line. The Problem and Change sections state the bug (two or three full ar…
Linked Issues check Passed Linked issue #40497 requires one getArchivedShellSnapshot read per unarchive or delete, with the row removed, the unarchived thread back in the sidebar, and other clients' archive changes still shown.…
Out of Scope Changes check Passed The incremental changes remove duplicate archive refreshes on web and mobile. They match the duplicate-refresh scope of #40497 and the PR objectives:
- apps/web/src/hooks/useThreadActions.ts: removes …
Full details: Title check

Explanation

The title names the main change: unarchiving or deleting an archived thread now reads the archive once. It uses a conventional commit prefix (perf(client)) and states the user-visible effect. Scope matches the raw summary, which removes duplicate archive refreshes in web, mobile, and client-runtime.

Full details: Description check

Explanation

The description follows the repository template closely. It has Problem, Change, Scope, Verification, and an agent attribution line. The Problem and Change sections state the bug (two or three full archive reads per click) and the fix. Scope links issue #40497 as the bug report. Verification gives focused tests and a Windows before/after measurement with request counts and timings. The Evidence section says before/after captures are still pending, and the template asks for before/after screenshots or recordings for UI changes. That gap is the main remaining item, and it is a required item for this PR. The description also lists what is out of scope and who did the work, which goes beyond the template.

Full details: Linked Issues check

Explanation

Linked issue #40497 requires one getArchivedShellSnapshot read per unarchive or delete, with the row removed, the unarchived thread back in the sidebar, and other clients' archive changes still shown.

Code at head 3892a97:

  • Unarchive: apps/web/src/hooks/useThreadActions.ts keeps one explicit refreshArchivedThreadsForEnvironment call after a successful unarchive. ArchivedThreadsPanel no longer refreshes (previous round). This gives one read.
  • Delete: the explicit refresh was removed from the delete path. packages/client-runtime/src/state/orchestration.ts archivedShellSnapshot.refreshTrigger now reads the shell removedAt signal. The shell reports a delete as a removal, so the delete gives one read.
  • Other clients: the same removedAt trigger still refreshes the list on removals from other clients.

Discrepancies:

  • The PR description and the previous assessment describe a snapshotSequence check in orchestration.ts that skips covered removals. The head version of orchestration.ts has no such check. The trigger is unconditional. The incremental change summary does not list a runtime change that would move this logic.
  • The PR description says useThreadActions refreshes after delete. That is no longer true at head.
  • The Windows measurements in the PR description were taken in the previous round. They do not measure head 3892a97.

The code at head appears to satisfy the requirement. The stale description does not change the coding result.

Full details: Out of Scope Changes check

Explanation

The incremental changes remove duplicate archive refreshes on web and mobile. They match the duplicate-refresh scope of #40497 and the PR objectives:

  • apps/web/src/hooks/useThreadActions.ts: removes the explicit refresh on delete and on archive, and adds comments on the unarchive and archive paths.
  • apps/web/src/components/settings/ArchivedThreadsPanel.tsx and apps/web/src/lib/archivedThreadsState.ts: remove the unused refresh return value.
  • apps/mobile archive screen and useThreadListActions.ts: drop the duplicate refresh.
  • Test files: remove expectations for the removed refresh calls. These support the changed behavior.

No change adds paged, delta, or row-local archive reads. Those are assigned to other issues.

The PR description still describes the earlier mechanism. That is a documentation mismatch, not an unrelated code change.

Finishing Touches

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 bf557f2 and 3892a97.

Files selected for processing: 4

  • apps/mobile/src/features/home/useThreadListActions.test.ts
  • apps/mobile/src/features/home/useThreadListActions.ts
  • apps/web/src/hooks/useThreadActions.permissions.test.ts
  • apps/web/src/hooks/useThreadActions.ts
Files with no reviewable changes: 1

  • apps/web/src/hooks/useThreadActions.permissions.test.ts

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

… 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]>

This branch has not been deployed

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

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

1 participant