Skip to content

perf(renderer): take the English catalog and the xterm WebGL addon off the boot graph - #18326

Merged
nwparker merged 5 commits into
mainfrom
perf/renderer-boot-graph
Sep 3, 2026
Merged

nwparker merged 5 commits into
mainfrom
perf/renderer-boot-graph

Conversation

@nwparker

@nwparker nwparker commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​376 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​365
Prod 22 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4509 $\color{#cf222e}{\Huge{\mathbf{−}}}$​170 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4339

ELI5

Every time Orca's window opens, the browser has to download and run a pile of
JavaScript before it can draw anything. Three big things were in that pile that
nobody needs at that moment: the full English dictionary (which the app never
actually reads) and the terminal's GPU renderer (only needed once a terminal
opens). They now load a moment after the window paints, still eagerly, so
nothing arrives later than it used to from your point of view — the startup
pile just got 779 KB (15.2%) smaller.

A third candidate, the emoji-name database, was tried and reverted: see
Negative user-facing trade-offs.

What was happening

out/renderer/index.html lists the entry chunk plus 331 <link rel="modulepreload"> chunks. Every one of them is fetched and evaluated
before first paint. Four payloads inside that graph were pure startup tax:

  • en.json (644 KB) was bundled as an eager i18next resource. But every
    renderer string goes through translate(key, fallback) — 12,868
    occurrences in non-test renderer source, zero single-argument
    translate(key) call sites
    , and the only .t( call sites are inside
    i18n.ts / main-i18n.ts / tests. For en, i18next resolves the same
    English text from that inline defaultValue, so most of the catalog was dead
    weight. src/main/i18n/main-i18n.ts already ships resources: { en: { translation: {} } } for exactly this reason.
  • @xterm/addon-webgl (243.6 KB) was a static import in
    pane-webgl-renderer.ts, but only ever constructed inside attachWebgl.
    Nine boot-path modules import that file for ENABLE_WEBGL_RENDERER /
    disposeWebgl / presentPaneViewport…, dragging the addon along.
  • right-sidebar-route.ts imported an 8-line string predicate
    (isPluginPanelTabKey) from plugin-manifest.ts, whose first line is
    import { z } from 'zod'.

What shipped

  • A generated runtime-required English catalog. en.json stays the
    translator source and the input to the four lazy target catalogs; the
    renderer now bundles src/renderer/src/i18n/en-runtime-required.json, which
    holds only the entries i18next cannot rebuild from a defaultValue.
    The prune rule is deliberately wider than "plural keys only", because a
    plural-only prune would have silently changed 60 strings:

    kept because entries
    CLDR plural suffix (_one/_other/…) — never derived from a default 38
    catalog value differs from a call site's inline default (translator edited it) 60
    no call site references it with a literal default (dynamic key, dynamic default, or unreferenced) 2,485
    total shipped 2,583 of 13,828

    Generated by config/scripts/generate-runtime-required-english-catalog.mjs
    (reusing the existing TypeScript-AST reference collector in
    verify-localization-catalog.mjs), checked by
    pnpm run verify:localization-runtime-catalog in pnpm lint and PR CI, and
    regenerated with pnpm run sync:localization-runtime-catalog.

    The gate checks a property, not byte equality: every runtime-required entry
    is shipped, and nothing shipped disagrees with en.json. An entry that stopped
    being required is dead weight, never a wrong string, so it is reported and
    tolerated — otherwise every unrelated PR that adds a translate() call would
    invalidate this file on every other open branch (CI builds the merge commit,
    which is exactly how the first push of this PR went red). Failures name the
    offending keys. The generator is order- and locale-independent (plain
    code-unit sort, set-based construction); a test pins that a reversed
    call-site walk produces byte-identical output.

  • primeTerminalWebglAddon() — a module-scoped handle fired by main.tsx
    right after the React root renders. attachWebgl stays synchronous and reads
    the resolved constructor. The load is still eager, just off the critical path.

  • plugin-tab-key.ts / plugin-id-format.ts — the pure string predicates
    moved out of the zod-importing modules and are re-exported from
    plugin-manifest.ts, so no importer changes.

Measurement

Real pnpm run build:electron-vite on this machine, before (origin/main,
946627f2ced) and after, measured from out/renderer/index.html's entry script
plus its modulepreload list. Both builds are on the same base.

before after
boot-graph chunks 332 336
boot-graph total (minified) 5108.9 KB 4330.2 KB
-778.7 KB / -15.2%

Per targeted chunk (minified KB):

chunk before after delta
i18n-*.js (644 KB of it was en.json) 689.2 154.7 -534.5
terminal-appearance-*.js (+ the two chunks it split into) 287.5 21.1 + 20.7 + 5.1 -240.6
useWorkspaceEmojiShortcodeInput-*.js (emojibase-data; deferral reverted) 171.9 171.9 0
plugin-manifest-*.js (+ the two chunks it split into) 124.9 5.4 + 89.1 + 30.3 ~0
store-*.js 1215.6 1210.6 -5.0
App-*.js 967.1 967.7 +0.6
client-*.js 174.3 174.3 0

The plugin/zod fix measured zero. Moving isPluginPanelTabKey off
plugin-manifest.ts did evict the manifest schema graph (that chunk went
124.9 → 5.4 KB), but zod itself stays on the boot path through six other
importers — shared/browser-client-page-renderer-protocol.ts,
shared/runtime-environments.ts, shared/closed-terminal-tab-tombstones.ts,
shared/codex-reset-credit-attempt-ledger.ts (via shared/constants.ts) and
store/slices/runtime-status.ts — so the 89.1 KB simply re-chunked. The change
is kept as the structural prerequisite for removing it, not as a win, and the
boot-graph guard does not ratchet zod, because there is nothing to ratchet
yet.

First paint: not measured. I could not get a repeatable first-paint number
on this machine, so I am not reporting one. The claim here is bytes fetched and
evaluated before first paint, which is measured directly from the build output.

Negative user-facing trade-offs

None found. Specifically:

  • No string changes. The prune rule keeps every entry whose absence could
    change a rendered string, including all 60 keys where the catalog has drifted
    from the inline default and all 2,485 keys with no statically-known default.
    runtime-required-catalog.test.ts re-renders every en.json entry
    through two live i18next instances (full catalog vs. pruned) and asserts
    identical output, plus every plural base key across counts 0/1/2/5/11/100.

  • Deferring @xterm/addon-webgl has one residual window, now bounded and
    self-correcting.
    attachWebgl is still synchronous, so a terminal opening
    after the load resolved attaches WebGL exactly as before, before its first
    paint. A terminal opening between the prime and its resolution is queued and
    attached the instant the module lands.

    A readiness review found two defects in the first version of that, both now
    fixed and both regression-tested (each verified to fail without its fix):

    • A failed load latched the DOM renderer for the whole session:
      .then(onOk, onError) settles fulfilled, so the memoized promise was cached
      with a null constructor, and even resetTerminalWebglSuggestion() — the
      documented GPU-setting recovery — could not clear it. The rejection path now
      clears the memo, latches queued panes so they retry at a recovery boundary
      rather than every frame, and caps attempts so a genuinely missing chunk is
      not re-fetched forever.
    • The queued-attach drain skipped the refit every other late-attach path
      performs. Because openTerminal's attachWebgl queued and returned, the
      initial fit measured DOM cell metrics and sized the PTY from them, and
      the addon then attached without re-measuring — a persistently narrow PTY and
      an unpainted right gutter, not a one-frame flicker. Both paths now share one
      attachWebglAndRefit pairing so they cannot diverge again.

    With those fixed the worst case is a queued pane rendering on xterm's DOM
    renderer for the frames between its openTerminal and the import landing,
    after which it attaches and re-fits. If the chunk cannot be loaded at all,
    panes stay on the DOM renderer — the same outcome this file already handles
    for a WebGL context failure — and recover at the next GPU-setting change.

  • Deferring emojibase-data (166.7 KB) was tried and reverted. It is the
    one sub-fix that could not meet the bar, so it is not in this PR. Until the
    dynamic import settled, getPrimedEmojiShortcodeEntries returned [], so
    exactShortcodeIndex built an empty map and
    replaceCompletedWorkspaceEmojiShortcode returned null
    (workspace-emoji-shortcodes.ts:21-32, :112-115) — a typed :wink: stayed
    literal and was persisted as the workspace display name. Before the
    change the shared catalog was statically imported, so the first call at any
    tick had full data; the window was new. "No human types that fast" is the
    wrong test for this app: Playwright/CDP in Orca's own e2e suite and agent
    automation through orca-cli both dispatch input in the same task as a
    field's mount effect, and the WorktreeMetaDialog test failure was exactly
    that, yielding 'Feature :wink:'. Nothing that resolves a shortcode can be
    async without the race, so the data stays statically imported and the ratchet
    records why. (The main process was never affected — it keeps its own
    synchronous import for worktree slugs.)

  • i18n.exists() / i18n.getResource('en', …) now return nothing for pruned
    keys.
    No product code calls either — the only callers were two tests, which
    now assert against en.json, the translator catalog that actually carries the
    contract. Rendered strings are unaffected, which is what the full-vs-pruned
    test proves.

Risk & verification

  • pnpm tc clean; pnpm run check:code-quality:changed clean; oxlint clean;
    max-lines / reliability-gates / runtime-electron ratchets clean.
  • verify:localization-catalog, verify:localization-runtime-catalog,
    verify:localization-extraction and verify:localization-coverage all pass.
  • 1,791 test files / 16,973 tests pass locally across every touched area
    (lib, i18n, components/{workspace-emoji,sidebar,new-workspace,settings},
    shared, config/scripts, the main-process worktree slug path). The
    whole-repo run is left to CI's 8 shards.
  • New boot-graph ratchet. config/scripts/renderer-boot-graph.mjs parses
    the built index.html modulepreload list and asserts neither en.json nor
    @xterm/addon-webgl appears in it. It runs
    unconditionally at the end of build:electron-vite (so CI cannot skip it),
    is also exposed as pnpm run verify:renderer-boot-graph, and is covered by
    renderer-boot-graph.test.mjs. Run against a real origin/main build it
    reports both:
    i18n/locales/en.json  -> i18n-BOJG51cl.js
    @xterm/addon-webgl    -> terminal-appearance-Cwb4eXi1.js
    
    The English probe is derived — the longest catalog value the prune drops —
    so it keeps working as copy changes.
  • Existing suites in the touched areas needed a primeTerminalWebglAddon() in
    beforeEach (4 files) — cold-module setup, since production primes once at
    boot. That is not the argument for the two new deferred-load tests: those
    drive the unprimed and failed-load paths deliberately, and each was checked to
    fail with its fix reverted.
  • The addon-load state machine now lives in terminal-webgl-addon-loader.ts and
    the viewport-present helpers in pane-viewport-present.ts, keeping
    pane-webgl-renderer.ts inside the 300-line budget without a suppression.
    Both are re-exported, so no importer changed.
  • SSH / folder-workspace / remote-wire: no execution-host, provider, or wire
    surface is touched. The main process is untouched apart from nothing — its
    emoji path still statically imports emojibase-data and stays synchronous.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 3d671786-7b4a-45b4-8f3c-3b6ab20f1242

📥 Commits

Reviewing files that changed from the base of the PR and between 4d754c5 and feacb13.

📒 Files selected for processing (4)
  • src/renderer/src/lib/pane-manager/pane-viewport-present.ts
  • src/renderer/src/lib/pane-manager/pane-webgl-renderer.test.ts
  • src/renderer/src/lib/pane-manager/pane-webgl-renderer.ts
  • src/renderer/src/lib/pane-manager/terminal-webgl-addon-loader.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The changes add generation and verification for a pruned English runtime localization catalog. Renderer boot-graph checks detect eagerly loaded WebGL and full-English payloads after successful builds. The WebGL addon now loads dynamically after renderer boot and supports queued pane attachment. Plugin ID and panel tab-key validation moves into shared modules. Tests, CI scripts, documentation, and package commands are updated accordingly.

Merge Risk: ⚪ Minimal · up to feacb

This change reduces renderer startup payloads while preserving terminal WebGL attachment, recovery, and fitting behavior. No concrete current-head merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.53% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 47 functions across 28 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description provides detailed explanations of the change, rationale, measurements, risks, and testing. However, it omits required template information, including a linked issue with Fixes #... a… Add a linked issue using Fixes #<issue-number>. Add the Visual Proof section with before-and-after evidence, or write exactly N/A and explain why there is no visual or interaction change. Complete the remaining required template section…
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the primary change: removing the English catalog and xterm WebGL addon from the renderer boot graph.
Full details: Description check

Explanation

The description provides detailed explanations of the change, rationale, measurements, risks, and testing. However, it omits required template information, including a linked issue with Fixes #... and a Visual Proof section or the required N/A statement with a reason. Several checklist and review sections are also absent.

Resolution

Add a linked issue using Fixes #&lt;issue-number&gt;. Add the Visual Proof section with before-and-after evidence, or write exactly N/A and explain why there is no visual or interaction change. Complete the remaining required template sections and checklists, or explicitly mark them not applicable.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

… data off the boot graph

The renderer's boot graph — the entry chunk plus its 331 modulepreload links,
all fetched and evaluated before first paint — carried three payloads nothing
needs at that moment.

`en.json` (644 KB) was an eager i18next resource, but every renderer string
goes through `translate(key, fallback)` and `en` resolves that inline default,
so most of the catalog was dead weight. The renderer now bundles a generated
`en-runtime-required.json` holding only the 2,583 of 13,828 entries a default
cannot reproduce: plural-suffixed keys, keys whose catalog value differs from a
call site's default, and keys no call site references with a literal default.
`en.json` stays the translator source and the input to the four lazy catalogs.

`@xterm/addon-webgl` (243.6 KB) and `emojibase-data` (170 KB) are now primed
right after the React root renders instead of statically imported. The load
stays eager and `attachWebgl` stays synchronous — it reads the resolved
constructor — so no terminal ever falls back to the DOM renderer for a frame.

`isPluginPanelTabKey`/`isQualifiedPluginKey` move to schema-free sibling
modules, re-exported from `plugin-manifest.ts`. This evicts the plugin manifest
schema graph from the boot chunk but measures ~0 KB, because six other shared
modules still put zod on the boot path.

Boot graph: 332 chunks / 5107.2 KB -> 336 chunks / 4161.5 KB (-945.7 KB, -18.5%).

A new ratchet parses the built index.html and fails if `en.json`,
`@xterm/addon-webgl` or `emojibase-data` is preloaded again; it runs at the end
of every `build:electron-vite`.
… data in tests

CI builds the merge of a PR with main, so a byte-for-byte comparison against a
committed generated file fails the moment any unrelated PR adds a translate()
call — which is what happened here. The check now asserts the property that
actually matters instead of byte equality: every runtime-required entry is
shipped, and nothing shipped disagrees with en.json. Entries that stopped being
required are dead weight, never a wrong string, so they are reported and
tolerated. Failures now name the offending keys rather than saying "stale".

The generator itself was already deterministic (plain code-unit sort, no
locale collation, order-independent set construction); a test now pins that a
reversed call-site walk produces byte-identical output.

Test fixes for the catalog prune and the deferred emoji load:
- browser-search / NativeChatSupportedAgents asserted key presence on the
  renderer's runtime resource. The durable contract is en.json — the renderer
  deliberately no longer bundles entries a call site default reproduces — so
  they assert against the translator catalog.
- Four emoji tests typed a shortcode in the same tick as mount, before the
  catalog the hook primes on mount resolves. Not reachable by a human; the
  tests now await the prime.
@nwparker
nwparker force-pushed the perf/renderer-boot-graph branch from 4978974 to f5387d2 Compare September 3, 2026 04:05

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — two robustness suggestions on the boot-graph ratchet inline.

Reviewed changes

This PR takes three payloads off the renderer boot graph and adds a ratchet to keep them off. The work is thorough and well-tested: a real en.json → pruned-catalog transform re-renders every English entry through live i18next instances, the WebGL addon is deferred through a queued-pane continuation, and the emoji data is deferred behind a type-only module boundary with a lazy self-prime.

  • Runtime-required English catalog — en.json is pruned to en-runtime-required.json (2,583 of 13,828 entries) by a new generator, checked by verify:localization-runtime-catalog in lint and PR CI, and wired into i18n.ts; the prune rule (plural suffixes, drifted values, dynamic keys/defaults all kept) is conservative and backed by a strong runtime equivalence test.
  • xterm WebGL addon deferral — pane-webgl-renderer.ts switches to a type-only import and a primeTerminalWebglAddon() handle; panes that open mid-load are queued and attached on resolution, with disposeWebgl cleaning the queue.
  • Emoji catalog deferral — emoji-shortcode-catalog-loader.ts lazy-imports the shared catalog behind a type-only boundary and self-primes; workspace-emoji-shortcodes.ts refuses to memoize an empty index.
  • zod off the boot path — pure string predicates move to plugin-id-format.ts / plugin-tab-key.ts, re-exported from plugin-manifest.ts so importers are unchanged.
  • Boot-graph ratchet — renderer-boot-graph.mjs parses the built index.html modulepreload graph and asserts none of the three payloads is present, run unconditionally at the end of build:electron-vite.

ℹ️ Nitpicks

  • The @xterm/addon-webgl and emojibase-data signatures are hardcoded string literals (WebGL2 not supported, zany_face), so a dependency bump that changes either string would silently stop the guard from detecting a regression. This is acknowledged in the code comment and low-priority, but worth a periodic manual re-check or deriving them the same way the English probe is derived.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

console.log(
`Renderer boot graph: ${chunks.length} chunks, ${(totalBytes / 1024).toFixed(1)} KB minified.`
)
if (violations.length === 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The gate fails open when readRendererBootGraph matches no chunks. verifyRendererBootGraph (and the build-time invocation in run-electron-vite-build.mjs) returns 0 whenever violations is empty — which is also the result when chunks is empty. If electron-vite/rolldown ever emits the src/href attributes before type/rel, or changes the <link rel="modulepreload"> shape, both regexes match nothing and the ratchet passes silently with 0 chunks. The only thing that catches an empty graph is the runIf(built) test's chunks.length > 10 assertion, which is not part of the build-time gate. Failing closed (e.g. throw when chunks.length === 0) would make the guard trustworthy against HTML format drift.

Technical details
# Boot-graph ratchet fails open on an empty parse

## Affected sites
- config/scripts/renderer-boot-graph.mjs:14 — script regex assumes `type="module"` precedes `src`
- config/scripts/renderer-boot-graph.mjs:17 — link regex assumes `rel="modulepreload"` precedes `href`
- config/scripts/renderer-boot-graph.mjs:106 — returns 0 on zero violations (incl. zero chunks)
- config/scripts/run-electron-vite-build.mjs:41 — build gate exits 0 on that same path

## Required outcome
- `verifyRendererBootGraph` returns non-zero when the boot graph parses to zero chunks, so the CI build step cannot pass vacuously.

## Suggested approach
- In `verifyRendererBootGraph`, after `readRendererBootGraph`, throw or `return 1` if `chunks.length === 0`.

for (const chunk of chunks) {
const code = fs.readFileSync(chunk.file, 'utf8')
for (const payload of payloads) {
if (code.includes(payload.signature)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The English probe compares the chunk text against the decoded value from prunedAwayEnglishSignature, but in the bundle the catalog value is stored JSON-escaped. The current longest pruned value is a CSS blob with no quotes/backslashes/newlines/non-ASCII, so code.includes(signature) matches today — but if copy changes ever make the longest pruned value contain a ", backslash, or newline, the decoded string will no longer appear verbatim in the chunk and the en.json probe will silently stop detecting. Probing the escaped form (e.g. JSON.stringify(signature).slice(1, -1)) or asserting the value has no escapable characters would close the gap.

Technical details
# English probe breaks if the pruned value needs JSON escaping

## Affected sites
- config/scripts/renderer-boot-graph.mjs:53 — `prunedAwayEnglishSignature` returns the decoded value
- config/scripts/renderer-boot-graph.mjs:91 — `code.includes(payload.signature)` matches raw, not escaped

## Required outcome
- The en.json probe continues to match (or fails loudly) when the longest pruned value contains characters that bundling escapes.

## Suggested approach
- Match `code.includes(JSON.stringify(signature).slice(1, -1))` against the chunk, or throw in `prunedAwayEnglishSignature` when the value contains escapable characters.

Deferring emojibase-data introduced a window that did not exist before: until
the dynamic import settled, getPrimedEmojiShortcodeEntries returned [], so
exactShortcodeIndex built an empty map and replaceCompletedWorkspaceEmojiShortcode
returned null — leaving a typed `:wink:` in the field literally, and persisting
it as the workspace display name.

Pre-change the shared catalog was statically imported, so the first call at any
tick returned full data. The window is reachable by anything that dispatches
input in the same task as the field's mount effect — Playwright/CDP in the e2e
suite and agent automation both do, and the WorktreeMetaDialog test failure was
exactly that, producing 'Feature :wink:' instead of 'Feature 😉'.

Nothing that resolves a shortcode can be async without that race, and a wrong
persisted name is not an acceptable trade for 166.7 KB, so the deferral is
reverted rather than papered over in the tests. The boot-graph ratchet drops
its emojibase-data probe and records why.

Boot graph: 5108.9 KB -> 4329.9 KB (-779.0 KB, -15.2%), down from -945.7 KB.
@nwparker nwparker changed the title perf(renderer): take the English catalog, xterm WebGL addon and emoji data off the boot graph perf(renderer): take the English catalog and the xterm WebGL addon off the boot graph Sep 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 39164063-74e8-4ae1-874c-03bf18b843f0

📥 Commits

Reviewing files that changed from the base of the PR and between 76836b3 and 4d754c5.

📒 Files selected for processing (31)
  • .gitattributes
  • .github/workflows/pr.yml
  • config/localization-audit.md
  • config/scripts/generate-runtime-required-english-catalog.mjs
  • config/scripts/generate-runtime-required-english-catalog.test.mjs
  • config/scripts/localization-package-contract.test.mjs
  • config/scripts/renderer-boot-graph.mjs
  • config/scripts/renderer-boot-graph.test.mjs
  • config/scripts/run-electron-vite-build.mjs
  • config/scripts/verify-localization-catalog.mjs
  • config/scripts/verify-renderer-boot-graph.mjs
  • package.json
  • src/main/runtime/decorative-title-fact-emission.test.ts
  • src/renderer/src/components/UpdateCard.tsx
  • src/renderer/src/components/settings/NativeChatSupportedAgents.test.tsx
  • src/renderer/src/components/settings/browser-search.test.ts
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/i18n/i18n.ts
  • src/renderer/src/i18n/runtime-required-catalog.test.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.test.ts
  • src/renderer/src/lib/pane-manager/pane-reveal-repaint.test.ts
  • src/renderer/src/lib/pane-manager/pane-webgl-context-recovery.test.ts
  • src/renderer/src/lib/pane-manager/pane-webgl-renderer.test.ts
  • src/renderer/src/lib/pane-manager/pane-webgl-renderer.ts
  • src/renderer/src/main.tsx
  • src/renderer/src/store/right-sidebar-route.ts
  • src/renderer/src/web/main.tsx
  • src/shared/plugins/plugin-id-format.ts
  • src/shared/plugins/plugin-manifest-fields.ts
  • src/shared/plugins/plugin-manifest.ts
  • src/shared/plugins/plugin-tab-key.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ The new commit is clean; the two minor suggestions from the prior review remain open and block an approval.

Reviewed changes (since prior pullfrog review at 4978974)

This commit makes three targeted fixes, all correct:

  • Merge-robust runtime-catalog gate — generate-runtime-required-english-catalog.mjs now checks a property (every required entry shipped, nothing shipped contradicts en.json) instead of byte equality. collectRuntimeRequiredCatalogProblems cleanly separates missing/contradicting (fail) from superfluous (tolerated, dead weight). The reasoning holds: a key only leaves the required set when every call site spells the identical string, so a superfluous entry's shipped value is always inert — it equals both en.json and every default. The new tests pin order-independence (toReversed walk is byte-identical, code-unit sort) and the three-way classification.
  • Emoji priming in unit tests — workspace-emoji-shortcodes.test.ts, SmartWorkspaceNameField.ime-enter.test.tsx, and WorktreeMetaDialog.test.tsx now await primeEmojiShortcodeCatalog() in beforeAll, matching the lazy-load boundary the PR introduced.
  • i18n assertions moved to the source catalog — NativeChatSupportedAgents.test.tsx and browser-search.test.ts assert against en.json rather than i18n.getResource('en', …)/i18n.exists, since the runtime English bundle is now pruned.

The regenerated en-runtime-required.json delta (+QuickLaunchButton.ec2adf093e) is consistent: that call site's fallback is a conditional expression, so it is a dynamic default and correctly required.

I confirmed the two remaining product call sites of the bundle APIs are unaffected: rich-markdown-code-block-languages.ts uses getResourceBundle only as a cache-invalidation sentinel (labels still resolve via translate(key, label)), and the hasResourceBundle hooks check bundle presence, not pruned keys.

The two open threads from the prior review (config/scripts/renderer-boot-graph.mjs — fail-open on an empty parse, and the JSON-escaping fragility of the derived English probe) are unaffected by this commit and remain worth addressing; neither is blocking, so I am leaving them as minor suggestions rather than repeating them here.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ The emoji revert is clean and well-reasoned — no issues in the delta.

Reviewed changes (since prior pullfrog review at f5387d)

  • Emoji deferral reverted — emoji-shortcode-catalog-loader.ts is deleted and workspace-emoji-shortcodes.ts returns to the static getStandardEmojiShortcodeEntries() import; exactShortcodeIndex is back to its ??= form. useWorkspaceEmojiShortcodeInput.ts, main.tsx, and the five touched test files drop their primeEmojiShortcodeCatalog() calls.
  • Boot-graph ratchet updated — the emojibase-data probe is removed from bootGraphForbiddenPayloads and the reason is recorded inline.

This is the correct call. The deferral introduced a real race: getPrimedEmojiShortcodeEntries returned [] until the dynamic import settled, so exactShortcodeIndex built an empty map and replaceCompletedWorkspaceEmojiShortcode returned null — a typed :wink: persisted literally as the workspace display name. As the commit message argues, anything that dispatches input in the same task as a field's mount effect (Playwright/CDP, orca-cli agent automation) hits the window, and no async shortcode resolver avoids it. The revert restores the prior synchronous guarantee; the 166.7 KB is a defensible trade for not persisting a wrong name. The reverted boot graph (-779 KB / -15.2%) is honestly remeasured.

The one residual artifact: src/main/runtime/decorative-title-fact-emission.test.ts and src/renderer/src/components/UpdateCard.tsx carry unrelated formatting-only changes (a call wrapped across lines, a boolean condition re-joined). They are inert, but they are scope drift from this PR and worth dropping so the revert stays purely about the emoji catalog.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…it on late attach

Two defects the deferral introduced, neither possible with a static import.

A failed load latched the DOM renderer for the whole session. `.then(onOk,
onError)` settles fulfilled, so the memoized promise was cached forever with a
null constructor: attachWebgl's re-prime got the cached promise back, and
resetTerminalWebglSuggestion — the documented "GPU setting changed, retry" path
— could not clear it either. The rejection path now clears the memo, latches the
queued panes the way a failed construction does so they retry at a recovery
boundary rather than every frame, and caps attempts so a genuinely missing chunk
is not re-fetched forever. The recovery boundary re-arms it.

The queued-attach drain skipped the refit. Every other late-attach path pairs
attach with a refit because the grid was measured under DOM cell metrics and
WebGL floors the device cell width. Post-deferral, openTerminal's attachWebgl
queued and returned, the initial fit rAF then measured DOM metrics and sized the
PTY from them, and the addon attached with no refit — a persistently narrow PTY
and an unpainted right gutter, not a one-frame flicker. Both paths now go
through one attachWebglAndRefit pairing so they cannot diverge again.

Regression tests cover both, and each was verified to fail without its fix.

The addon-load state machine moves to terminal-webgl-addon-loader.ts and the
viewport presentation helpers to pane-viewport-present.ts, keeping
pane-webgl-renderer.ts under the 300-line budget without a suppression.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ The deferred WebGL addon loader refactor is clean and well-tested — no new issues in the delta. The two open threads from the initial review (renderer-boot-graph.mjs fail-open parse and the English-probe JSON-escaping) are untouched by this commit and remain open, non-blocking.

Reviewed changes (since prior pullfrog review at 4d754c5)

  • WebGL addon load made recoverable — primeTerminalWebglAddon moved to terminal-webgl-addon-loader.ts; a failed import now clears the memoized promise and caps retries at 3, so the GPU-setting recovery boundary re-arms the load instead of caching a null constructor for the whole session.
  • Queued panes attach with a refit — the onLoaded continuation pairs attachWebgl with a next-frame safeFit through attachWebglAndRefit, fixing the narrow-PTY/right-gutter defect a bare attach left on panes that opened mid-load.
  • Viewport-present helpers extracted — presentPaneViewport* and its retry loop moved to pane-viewport-present.ts (pure move, re-exported so no importer changed).
  • Two regression tests — the unprimed late-attach refit and the failed-load retry, each verified to fail with its fix reverted.

ℹ️ Nitpicks

  • terminal-webgl-addon-loader.ts caps the load at 3 attempts so a genuinely missing chunk is not re-fetched forever, but no test asserts that a fourth primeTerminalWebglAddon() is a no-op after three failures — the cap is load-bearing and currently only documented, not pinned.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 968dbd9 into main Sep 3, 2026
28 checks passed
@nwparker
nwparker deleted the perf/renderer-boot-graph branch September 3, 2026 07:26
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…f the boot graph (stablyai#18326)

* perf(renderer): take the English catalog, xterm WebGL addon and emoji data off the boot graph

The renderer's boot graph — the entry chunk plus its 331 modulepreload links,
all fetched and evaluated before first paint — carried three payloads nothing
needs at that moment.

`en.json` (644 KB) was an eager i18next resource, but every renderer string
goes through `translate(key, fallback)` and `en` resolves that inline default,
so most of the catalog was dead weight. The renderer now bundles a generated
`en-runtime-required.json` holding only the 2,583 of 13,828 entries a default
cannot reproduce: plural-suffixed keys, keys whose catalog value differs from a
call site's default, and keys no call site references with a literal default.
`en.json` stays the translator source and the input to the four lazy catalogs.

`@xterm/addon-webgl` (243.6 KB) and `emojibase-data` (170 KB) are now primed
right after the React root renders instead of statically imported. The load
stays eager and `attachWebgl` stays synchronous — it reads the resolved
constructor — so no terminal ever falls back to the DOM renderer for a frame.

`isPluginPanelTabKey`/`isQualifiedPluginKey` move to schema-free sibling
modules, re-exported from `plugin-manifest.ts`. This evicts the plugin manifest
schema graph from the boot chunk but measures ~0 KB, because six other shared
modules still put zod on the boot path.

Boot graph: 332 chunks / 5107.2 KB -> 336 chunks / 4161.5 KB (-945.7 KB, -18.5%).

A new ratchet parses the built index.html and fails if `en.json`,
`@xterm/addon-webgl` or `emojibase-data` is preloaded again; it runs at the end
of every `build:electron-vite`.

* chore(i18n): pin the generated English subset to LF and mark it generated

* fix(i18n): make the runtime-catalog gate merge-robust and prime emoji data in tests

CI builds the merge of a PR with main, so a byte-for-byte comparison against a
committed generated file fails the moment any unrelated PR adds a translate()
call — which is what happened here. The check now asserts the property that
actually matters instead of byte equality: every runtime-required entry is
shipped, and nothing shipped disagrees with en.json. Entries that stopped being
required are dead weight, never a wrong string, so they are reported and
tolerated. Failures now name the offending keys rather than saying "stale".

The generator itself was already deterministic (plain code-unit sort, no
locale collation, order-independent set construction); a test now pins that a
reversed call-site walk produces byte-identical output.

Test fixes for the catalog prune and the deferred emoji load:
- browser-search / NativeChatSupportedAgents asserted key presence on the
  renderer's runtime resource. The durable contract is en.json — the renderer
  deliberately no longer bundles entries a call site default reproduces — so
  they assert against the translator catalog.
- Four emoji tests typed a shortcode in the same tick as mount, before the
  catalog the hook primes on mount resolves. Not reachable by a human; the
  tests now await the prime.

* revert(renderer): keep the emoji shortcode catalog statically imported

Deferring emojibase-data introduced a window that did not exist before: until
the dynamic import settled, getPrimedEmojiShortcodeEntries returned [], so
exactShortcodeIndex built an empty map and replaceCompletedWorkspaceEmojiShortcode
returned null — leaving a typed `:wink:` in the field literally, and persisting
it as the workspace display name.

Pre-change the shared catalog was statically imported, so the first call at any
tick returned full data. The window is reachable by anything that dispatches
input in the same task as the field's mount effect — Playwright/CDP in the e2e
suite and agent automation both do, and the WorktreeMetaDialog test failure was
exactly that, producing 'Feature :wink:' instead of 'Feature 😉'.

Nothing that resolves a shortcode can be async without that race, and a wrong
persisted name is not an acceptable trade for 166.7 KB, so the deferral is
reverted rather than papered over in the tests. The boot-graph ratchet drops
its emojibase-data probe and records why.

Boot graph: 5108.9 KB -> 4329.9 KB (-779.0 KB, -15.2%), down from -945.7 KB.

* fix(terminal): make the deferred WebGL addon load recoverable and refit on late attach

Two defects the deferral introduced, neither possible with a static import.

A failed load latched the DOM renderer for the whole session. `.then(onOk,
onError)` settles fulfilled, so the memoized promise was cached forever with a
null constructor: attachWebgl's re-prime got the cached promise back, and
resetTerminalWebglSuggestion — the documented "GPU setting changed, retry" path
— could not clear it either. The rejection path now clears the memo, latches the
queued panes the way a failed construction does so they retry at a recovery
boundary rather than every frame, and caps attempts so a genuinely missing chunk
is not re-fetched forever. The recovery boundary re-arms it.

The queued-attach drain skipped the refit. Every other late-attach path pairs
attach with a refit because the grid was measured under DOM cell metrics and
WebGL floors the device cell width. Post-deferral, openTerminal's attachWebgl
queued and returned, the initial fit rAF then measured DOM metrics and sized the
PTY from them, and the addon attached with no refit — a persistently narrow PTY
and an unpainted right gutter, not a one-frame flicker. Both paths now go
through one attachWebglAndRefit pairing so they cannot diverge again.

Regression tests cover both, and each was verified to fail without its fix.

The addon-load state machine moves to terminal-webgl-addon-loader.ts and the
viewport presentation helpers to pane-viewport-present.ts, keeping
pane-webgl-renderer.ts under the 300-line budget without a suppression.
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