Skip to content

Defer Markdown parsing and reduce shared workspace JavaScript - #4520

Merged
ymichael merged 1 commit into
mainfrom
bb/bundle-followup-investigation
Sep 29, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/bundle-followup-investigation

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

After #4512, the shared workspace route still imported thread-only screens, Markdown's HTML parser/sanitizer, and editor extensions that are always disabled. Plugin SDK registration also imported its embedded conversation renderer. TipTap's published blockquote bundle contained another copy of ProseMirror.

What changed

  • Compose the editor's enabled extensions directly, preserving rich-text gating and extension order. Patch blockquote's ESM/CJS bundles to use the existing @tiptap/pm/state TextSelection instead of bundled copies.
  • Download Markdown's HTML pipeline at workspace idle using ordinary cacheable fetches. Import it only when HTML-enabled Markdown contains <; coordinate fetch/import so first use does not download twice. Plain Markdown text remains visible while loading or failed; sanitization is unchanged.
  • Split ThreadDetailView and SDK ThreadChat. Thread URLs start the detail import alongside the workspace route; compose/plugin pages avoid it. SDK props are unchanged. Existing panel/model/palette preload policies and automatic import retries remain unchanged.
  • Guard the three boundaries, including the plugin runtime closure, and lower the workspace-route budgets by the measured savings. Document the download-only pattern.

Production JavaScript, decimal Brotli bytes; overlapping closures are deduplicated:

Payload Merged main This change
Boot 369,221 369,961
Additional workspace route 580,544 308,314
Initial workspace, including boot 949,765 678,275
Initial actual thread, including boot 949,765 916,608
Workspace plus normal background downloads, including idle HTML 1,209,250 1,085,959

These are app JavaScript closures, excluding plugin asset files, CSS, fonts and user data. Actual thread visits still need the thread code. A thread that immediately needs HTML totals 962,084 Brotli bytes, 12,319 more than the old combined route because splitting changes compression and chunk sharing; the largest benefit is on non-thread visits. Normal warmed execution excludes the 45,476 HTML Brotli bytes until needed.

LOC: runtime/build +243 net; tests +236; dependency metadata +48; docs +28. The separate 6,074-line vendor patch is mostly deletions of duplicated generated ProseMirror, not 6,074 lines of application code. No review stories, fixtures, preview providers, SDK or wire contracts were added.

How you verified

  • Turbo app build, typecheck and lint pass; frozen dependency install and bundle checker pass. 644 focused tests pass across targeted runs, 3 skipped.
  • New real cold-HTML test retains readable text while holding the actual implementation import and checks sanitization on release. It fails against the prior eager implementation. Existing HTML/media/directive tests keep their assertions, warming the implementation before testing rendered semantics.
  • New download-coordination tests catch duplicate first-use fetching; removing suppression fails the regression test. A real Vite build test checks emitted hashed prefetch URLs and static dependencies. Shared-chunk bundle measurement has a regression test.
  • Negative production build: eager imports of the three implementations fail their module guards; the HTML packages also fail their demand gates. Restored build passes.
  • Production Chromium: HTML/parser fetched as Fetch at idle with no V8 coverage before use; first HTML rendering executes both from disk cache with zero extra transfer bytes. Held/aborted requests preserve text and composer, show skeleton/red retry line, strip hostile handlers/scripts, and recover after reload. Cold first use now makes only the two script requests, without extra idle fetches. Desktop and phone screenshots are in the BB handoff.
  • Matched control: https://ymichael--6134.getbb.app/threads/thr_8bqg5t848s ; branch: https://ymichael--6135.getbb.app/threads/thr_8bqg5t848s . Both use the same isolated backend and read-only HTML response fixture. No user data was changed. Chromium only; no Safari or desktop-app claim.

AGENT GENERATED

@ymichael
ymichael merged commit f117245 into main Sep 29, 2026
20 checks passed
@ymichael
ymichael deleted the bb/bundle-followup-investigation branch September 29, 2026 23:07
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