Skip to content

perf(web): share document parser bundles and skip covered snapshot reads - #920

Merged
tt-a1i merged 1 commit into
mainfrom
codex/engineering-audit
Nov 13, 2026
Merged

tt-a1i merged 1 commit into
mainfrom
codex/engineering-audit

Conversation

@tt-a1i

@tt-a1i tt-a1i commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Problem

Web file attachment staging and Office preview ship separate worker bundles containing the same ExcelJS and Mammoth code. The Web store also queues a second snapshot read when events arrive during an outstanding read, even if the accepted response already contains those events.

Value

Against main ffc9c624, the packaged Web assets shrink from 13,058,005 to 11,749,696 bytes (140 to 137 files). Local npm pack --ignore-scripts produces a 4.87 MB tarball, down from 5.25 MB. In the overlapping-read regression the client makes one follow-up request after initialization instead of two. These measurements cover distribution size and a specific event ordering. End-user startup time was not measured.

Approach

  • Use one Vite worker entry for extraction and preview. Each operation still creates and terminates its own Worker. Classify files on the main thread without importing the parser module. Keep the PDF rendering and extraction APIs in their respective execution contexts.
  • Coalesce event requests by their largest sequence. The host captures the snapshot cursor before reading the projection. Only a snapshot accepted into the store can satisfy a queued event. Uncovered events, heartbeats and reconnects still reconcile with the host.
  • Move prompt image admission and retry signatures into a focused host module alongside ordinary prompt file handling. Document how to regenerate tracked assets after a source conflict.

Validation

  • Frozen dependencies, Bun 1.3.14, Node 22.23.3 on macOS arm64. The integrated audit candidate passed bun run check and bun run test (2,476 Node passes, 8 skips, 1,652 UI passes). That run also contained the independent local test-runner changes.
  • All 232 Web store tests passed. The covered-cursor regression detects the extra request on the original store. Separate cases cover newer events, a superseded response and forced heartbeat reconciliation.
  • All 23 focused document staging/parser/worker tests passed. Three existing host HTTP tests covered image limits, signatures and retry replay.
  • 14 Chrome end-to-end tests passed using the production bundle. These exercised PDF and Office extraction and preview, upload failure/retry, session changes, and streamed history at desktop and phone widths.

Impact

A smaller Git/npm distribution and fewer redundant reads under overlap. Prompt data formats, request authority, model-facing tools, and persisted data retain their contracts. The rebuild is included for source installations. The patch is reversible with a normal revert.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Nov 13, 2026
@tt-a1i
tt-a1i marked this pull request as ready for review November 13, 2026 16:32
@tt-a1i
tt-a1i merged commit ef38865 into main Nov 13, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant