Skip to content

fix(wiki-v2#409,#407,#384): self-hosted fonts, no-store documents, lazy code grammars, request-error UX - #68

Merged
PMQ9 merged 4 commits into
wiki-v2from
fix/409-407-384-client-render-path
Nov 5, 2026
Merged

PMQ9 merged 4 commits into
wiki-v2from
fix/409-407-384-client-render-path

Conversation

@PMQ9

@PMQ9 PMQ9 commented Nov 5, 2026

Copy link
Copy Markdown

TL;DR

This is the fork half of the cccvu/wiki-v2 change for issues 409, 407 and 384:

  • fonts are self-hosted;
  • every HTML document is no-store;
  • highlight.js grammars load lazily, then the code blocks are re-highlighted;
  • request errors say what actually happened (rate limit, offline, HTTP status).

The super PR carries the console half, UPSTREAM_MODIFICATIONS.md (docmost#183–docmost#189 plus the updated entries), the ADR 0020 amendment and the e2e changes. Review the pair together in the super PR.

What changed

  • fix(#409,#407,#384) d4b91c4:
    • coloring table cells and formatting text docmost/docmost#409 fonts: @fontsource-variable/inter and @fontsource/roboto (5.3.0, exact pins) are imported once from features/brand/fonts.ts. The Google Fonts links are removed from index.html, theme.ts now leads with "Inter Variable", and assetsInlineLimit never inlines woff/woff2.

    • coloring table cells and formatting text docmost/docmost#409 documents: in authz/http-headers/client-static.ts, every .html document gets DOCUMENT_CACHE_CONTROL (no-cache, no-store, must-revalidate). A spec pins it to the literal in the upstream * fallback; static.module.ts itself is unchanged.

    • fix: improve sidebar page tree syncing docmost/docmost#407: features/editor-ux/code-highlight/ adds:

      • an empty lowlight, plus a memoized lazy import("./grammars");
      • CodeHighlightLoader, a meta-only LOWLIGHT_REFRESH_META refresh;
      • useCodeLanguages().

      vite.config.ts adds the grammars to mustStayLazy and ratchets the budget to 745,000.

    • How to publish as a public webpage? docmost/docmost#384: features/request-errors/ adds requestErrorMessage, createAppQueryClient() (one retry, only for a 429 with Retry-After ≤ 10 s, plus a single deduped toast) and RequestErrorText. It also fixes the api-client.ts 404 TypeError.

    • smoke.sh §5 asserts the document policy.

  • chore(#409) cdcf81b: the lockfile, written with the pinned pnpm 10.4.0 and containing only the two fontsource entries.
  • fix(#407) 9c57629:
    • prefetchCodeGrammarsWhenIdle() is called from main.tsx.
    • useEditorEditable makes the code-block picker and the mermaid source follow setEditable. That was a pre-existing upstream bug; useEditorState can't see setEditable, and a test pins that.
  • docs(#407) d3613e8: wording for when the prefetch fires.

Upstream-owned files touched:

  • new seams: apps/client/package.json, lowlight-plugin.ts, custom-code-block/index.ts, code-block-view.tsx, recent-changes.tsx, favorites-pages.tsx, created-by-me.tsx (super §183–189)
  • amended seams: §7 api-client.ts, §11 vite.config.ts, §12 theme.ts, §13 index.html, §59 extensions.ts, §120 main.tsx, §132 favorites-page.tsx, §149 pnpm-lock.yaml, §162 api-client.test.ts
  • scripts/check-upstream-boundary.sh passes.

How this was tested

  • Tests (Node 22):
    • Client Vitest: 466/466.
    • Server Jest authz/http-headers: 38/38.
    • tsc passes for the client and the build plugin.
    • The strict bundle build passes.
    • 43 mutants across the new tests all went red.
  • Bundle:
    • Initial JS: 721,339 → 681,550 B br.
    • Eager vendor-hljs: 48,473 → 7,760 B br.
    • The 41,233 B br grammar chunk is never in the initial set.
  • Browser (Chromium 153 and Chrome 157, isolated stack, production bundle):
    • No requests to Google; woff2 is immutable and same-origin.
    • Every document is no-store.
    • Signed-in pages are never restored from bfcache. After logout, in the same tab or another one, Back shows no signed-in content.
    • Code shows unhighlighted for 0 ms, cold and warm (205 ms before the prefetch).
    • The picker enables on Read→Edit.
    • 429, 500 and offline each show the right text; there is one toast, and the retry waits at least the Retry-After.

Full evidence is in the super PR.

🤖 Generated with Claude Code

PMQ9 and others added 4 commits November 4, 2026 23:58
… documents, lazy code grammars, request-error UX

- docmost#409: Inter (variable) + Roboto 500 are self-hosted via fontsource and served from hashed /assets
  (immutable, same-origin, font-display swap) instead of a render-blocking fonts.googleapis.com
  stylesheet; woff/woff2 are never inlined. Every HTML document (/, /index.html, the * fallback, a stale
  asset URL) now sends the fallback's `no-cache, no-store, must-revalidate`: no-store is the only
  cross-browser control that keeps an authenticated page out of bfcache after logout.
- docmost#407: lowlight starts empty; highlight.js grammars load in one lazy chunk when an editor mounts and a
  meta-only transaction re-decorates code blocks (LowlightPlugin honours LOWLIGHT_REFRESH_META). The
  language picker reads a store so it fills in once grammars arrive. Initial JS 721,339 -> 681,334 B br;
  budget ratcheted to 745,000.
- docmost#384: queries get a status-aware error text (rate limit / offline / HTTP status), one deduped
  rate-limit toast, and one retry only for a short (<=10 s) Retry-After. The api-client 404 branch no
  longer throws a TypeError on a 404 without a string message.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- lowlight.ts: prefetchCodeGrammarsWhenIdle() schedules the lazy grammar
  load once via requestIdleCallback (3 s timeout), else a 300 ms timer,
  and swallows a failure (the load logs and un-memoizes it; the editor
  mount retries). main.tsx (seam docmost#120) calls it after the render call, so
  a cold page with code starts the fetch after first paint instead of at
  editor mount (~205 ms of plain code on Fast-4G before).
- code-block-view.tsx (seam docmost#186): pre-existing upstream bug. The language
  picker's disabled and the mermaid source's hidden read editor.isEditable
  at render time, and a ReactNodeView does not re-render on setEditable(),
  so after Read -> Edit the picker stayed disabled until the block changed.
  New fork-owned useEditorEditable() subscribes to the 'update' event that
  setEditable emits; @tiptap/react's useEditorState listens to
  'transaction' only and misses it (pinned in the test).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, not strictly after first paint

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@PMQ9
PMQ9 merged commit 2258c5e into wiki-v2 Nov 5, 2026
@PMQ9
PMQ9 deleted the fix/409-407-384-client-render-path branch November 5, 2026 15: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