Skip to content

Frontend perf + correctness: capture plan in tasks/#645

Merged
ajslater merged 1 commit intov1.11-performancefrom
frontend-perf-plan
Apr 30, 2026
Merged

Frontend perf + correctness: capture plan in tasks/#645
ajslater merged 1 commit intov1.11-performancefrom
frontend-perf-plan

Conversation

@ajslater
Copy link
Copy Markdown
Owner

Summary

Plan-only PR covering the codex frontend (~12k LOC components + ~3.5k LOC stores/api/plugins, 170 .js/.vue files). Mirrors the importer-perf / janitor-perf plan-capture pattern (#621, #625, #627, #635).

Investigation methodology

Surface too big for a single sweep. Fanned the investigation across four parallel sub-agents — browser, reader, API+socket, admin+metadata — plus build-config review by hand. ~64 raw findings synthesized, deduplicated, and grouped into four tiers and five sub-plans.

Headline findings (correctness)

Two confirmed silent-failure bugs on the read path:

components/reader/pager/page/page.vue:104

mounted() {
  setTimeout(function () {           // non-arrow: `this` is the timer
    if (!this.loaded) this.loading = true;
  }, PROGRESS_DELAY_MS);
}

The load-progress spinner literally never shows. Has been broken since the file was written.

stores/reader.js:486

if (!arcs.length) {
  // No arcs is a 500 from the mtime api
  arcs.push({ r: "0" });             // wrong shape; sibling code uses { group, pks }
}

The fallback the comment says was added to avoid a 500 itself returns a 500.

Plus 11 more bugs of varying severity: rapid-click races on loadBrowserPage / loadBooks, iOS PWA blob URL leak, unbounded search history growth, double-rendering of filter list items, etc.

Plan structure

Sub-plan Items Focus Approx LOC
01 correctness-bugs 13 bugs Race conditions, leaks, broken-since-conception ~150
02 request-dedup 11 items AbortController, pending-promise dedup, WS exp backoff, CSRF cache ~200
03 hot-path-renders 19 items Per-render alloc, deep watchers, layout thrash, theme lookups ~230
04 reader-scroll-perf 7 items Prefetch window, scroll throttle, bookmark debounce ~150
05 bundle-and-startup 2 items Vendor chunk split, parallel cold-boot fetches ~50

Suggested ship order: 01 → 02 → 03 → 04 → 05. Correctness first, then network dedup, then per-render optimizations, then reader-specific, then build/startup.

Test plan

  • Review 00-meta.md for surface-map accuracy and finding triage
  • Confirm the sub-plan groupings make sense
  • Flag any items that should be promoted/demoted between tiers
  • Approve as planning artifact (no code changes)

🤖 Generated with Claude Code

Survey + plan covering ~12k LOC of components and ~3.5k LOC of
stores/api/plugins. The investigation itself fanned across four
parallel sub-agents (browser, reader, API+socket, admin+metadata)
plus build-config review; ~64 raw findings synthesized into four
tiers and five sub-plans.

Tier 1: 13 correctness bugs — race conditions, leaks, broken-
since-conception features. Examples: page.vue's load-progress
spinner uses setTimeout(function() ...) so this is wrong and the
spinner never actually appears; reader.js's no-arcs mtime
fallback uses { r: "0" } when adjacent code uses { group, pks }
so the fallback is a 500; loadBrowserPage and loadBooks have no
AbortController so rapid clicks race. Ships first.

Tier 2: 19 hot-path render allocations. Per-render array
spreads, deep watchers, structuredClone-of-frozen-sentinels,
metadata layout thrash, theme lookups per chip. Each item small;
aggregate dominates render frames on large libraries.

Tier 3: 11 network/dedup. AbortController plumbing, pending-
promise dedup, exponential backoff on WS reconnect, CSRF token
cache, admin static-table caching.

Tier 4: 7 reader-specific. Bound the prefetch window (currently
all pages prefetched on a 1000-page omnibus), throttle the
vertical-scroll handler, debounce bookmark API calls, tighten
the eager window in horizontal mode, replace fixed-timeout
programmatic-scroll guard with onscrollend.

Sub-plans:
- 01 correctness-bugs: ship first; ~150 LOC across 13 files
- 02 request-dedup: AbortController + dedup helpers; ~200 LOC
- 03 hot-path-renders: split into two PRs (browser + metadata)
- 04 reader-scroll-perf: prefetch window + scroll throttle
- 05 bundle-and-startup: vendor chunk split + parallel cold-boot

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@ajslater ajslater merged commit def4da5 into v1.11-performance Apr 30, 2026
1 check failed
@ajslater ajslater deleted the frontend-perf-plan branch May 2, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant