Repository navigation
Description
Problem
The reading pane is the one large surface with no windowing. StandardMarkdownReader and the note reader hand the whole content string to react-markdown (ui-packages/web/src/components/markdown.tsx:8,115), which parses and mounts every block in a single synchronous render — no virtualization exists anywhere under features/reader/markdown-reader.
The ordinary route to a very large markdown string is a Word document: ui-packages/web/src/features/reader/docx-reader.tsx:87-89 converts the entire .docx to markdown and renders it through that reader. A ~1 MB .docx — far under every limit — expands to 1–3 MB of markdown; the 5 MB text cap (text-file-reader.tsx:50-53) checks only the stored blob's size, so it never applies to this path, and imports go up to 200 MB (core/files.ts:3).
Measured on this machine (react-markdown + remark-gfm, renderToStaticMarkup — parse and element creation only, before any DOM mount, layout, rehype-highlight or rehype-katex): 2,000 paragraphs = 215 ms; 8,000 paragraphs (1.34 MB) = 701 ms; 20,000 (3.37 MB) = 1,995 ms. In the browser the same document pays a multiple of that inside one React commit, during which the whole workspace is unresponsive, and it then keeps a DOM of hundreds of thousands of nodes for as long as it stays open.
Every other large surface got, or is getting, windowing: the sheet grid row-virtualizes (xlsx-reader/sheet-grid.tsx:1,77), the conversation transcript is #201, the Files panel is #166. PRODUCT.md wants reading to "feel immediate" and be "the largest and quietest part" of the workspace — but long documents are exactly the files ordinary readers bring (contracts, reports, ebooks), and the reading pane is the last unwindowed surface they open them in.
Proposal
- Render the markdown reading surface in a window: blocks outside the viewport parse lazily and unmount when far away, mirroring what the sheet grid already does for rows.
- Route the docx path through the same windowing (it already renders via the markdown reader), so a 200-page Word document opens in the same time budget as a one-page note.
- Preserve the features that interact with position: reading position (Remember where the reader stopped — reopen documents at their page or scroll position #40) restores by anchor or offset rather than absolute scroll height, and outline/link/citation jumps (Let a citation take the reader to its place — an answer's 'paper.pdf, page 12' opens the file at page 1 today, and no path reaches the page it named #192, Let a reader follow a PDF's own links — a 'see Figure 3', citation or table-of-contents click does nothing today #189) land through the window instead of mounting everything above the target.
- Keep note-graph features (Let readers follow the links in their own notes — [[wiki-links]] render as plain text while the assistant walks the graph #95) reading from the source text, as they do today, not from the mounted DOM.
Goal
After this, opening a 200-page Word document or a multi-megabyte note takes about as long as opening a one-page note, the tab stays responsive while it opens, and scrolling a long document does not slow as its length grows.
Verification
grep -rq "Virtualizer" ui-packages/web/src/features/reader/markdown-reader
pnpm --filter @gamma-reader/web exec vitest run --project unit --testNamePattern="window"
pnpm checkRefs
- ui-packages/web/src/components/markdown.tsx:8,115 — ReactMarkdown renders the entire string in one mount
- ui-packages/web/src/features/reader/docx-reader.tsx:87-89 — a Word document converts whole and renders through the markdown reader
- ui-packages/web/src/features/reader/text-file-reader.tsx:50-53 — the 5 MB cap checks the stored blob, not the converted content
- ui-packages/web/src/core/files.ts:3 — imports up to 200 MB
- ui-packages/web/src/features/reader/xlsx-reader/sheet-grid.tsx:1,77 — the row-virtualized grid this mirrors
- Measurement (node, renderToStaticMarkup, react-markdown + remark-gfm): 215 ms @ 2,000 paragraphs; 701 ms @ 8,000 (1.34 MB); 1,995 ms @ 20,000 (3.37 MB)
- Window the transcript the reader sees — an idle conversation re-reads its whole history and renders every message on each switch today, so the older a conversation gets, the slower it opens #201 — windowing the conversation transcript; this is the same treatment for the reading pane
- Keep the Files panel fluent at the 5000-file import cap — every row renders today, unwindowed #166 — windowing the Files panel; together the three surfaces complete
- Cap what open tabs hold in memory — every visited tab stays mounted today, and each open PDF keeps its loaded document until the tab closes #175 — the memory face of long-lived open tabs; a windowed document also bounds its DOM
- Remember where the reader stopped — reopen documents at their page or scroll position #40 — reading position, which windowing must restore by anchor
- Bound Lab cell output — one large print can freeze the reading tab #55 — family precedent: one big synchronous mount was bounded in Labs
- ui-packages/web/PRODUCT.md — "feel immediate"; "reading as the largest and quietest part"
Activity
bencode commentedon Oct 26, 2026
Independent review — posted by the scheduled issue-reviewer loop (a session separate from the one that files these issues), under the maintainer's standing instruction to evaluate, sharpen, or retire
source:scheduledproposals. Audited againstmain@70eb94e(PRs #231/#232/#234/#235 landed since last beat).Evidence audit: every citation confirmed; two drift notes.
markdown.tsx:8,115— whole-stringReactMarkdownmount, exact; zero virtualization underfeatures/reader/markdown-reader(only wiki-link's unrelated "virtual" resolution term).docx-reader.tsx:87-89, the 5 MB blob-only cap (text-file-reader.tsx:50-53checksdocument.size, never the converted content),core/files.ts:3(200 MB), PRODUCT.md:18/35 quotes — all exact. The measurement wasn't re-run, but the mechanism is confirmed from code and the numbers are internally consistent (linear, ~0.1 ms/paragraph before DOM/layout).:1,77— line 1 (useVirtualizerimport) exact; theuseVirtualizer({...})call moved to:92after PR fix: a selected cell shows its whole text above the grid #235 added the cell bar. Substance unchanged: the row-virtualized precedent this proposal mirrors is real.Sensor: lint ✓; verify ✗ — correctly reads "not implemented". The
Virtualizergrep is the load-bearing discriminator and is the right shape (mirroring the grid means the repo's own@tanstack/react-virtual). Note: the--testNamePattern="window"line already passes vacuously today (two unrelated threshold-"window" tests match) — harmless as a regression floor, but the new tests should be pinned by name, not relied on through that pattern.Verdict: valid, keep open. No duplicate among open or closed issues (#201 transcript, #166 Files panel, #175 memory — the three siblings are separately scoped; #55 was the Labs precedent). This completes the windowing family the queue has been building.
One sharpening suggestion: the Goal's "about as long as a one-page note" is the outcome to pin — an implementation that windows blocks but still parses the full string up front (remark runs before React) meets the Virtualizer grep while missing the Goal. Worth a test asserting parse work scales with the window, not the document (e.g. lazy remark per block, or a parse-time budget).
bencode commentedon Oct 30, 2026
Independent re-review — posted by the scheduled issue-reviewer loop, independent of the authoring session. Audited against
main@d05b6b6(2026-10-28), two days of commits after the last review (main@70eb94e).Evidence re-audit: all anchors hold in substance; drift only.
components/markdown.tsx:8exact; the whole-string<ReactMarkdown>mount now at :119-126 (cited :115, +4 lines).features/reader/markdown-reader/— 17 files, still zeroVirtualizer.docx-reader.tsx:87-89— still renders the entire converted string throughStandardMarkdownReader✓.text-file-reader.tsx:50-53— the 5 MB cap still checks onlydocument.size✓.core/files.ts:3— 200 MB import ceiling ✓.7f7ac7a+4f2d801moveduseVirtualizerinxlsx-reader/sheet-grid.tsxfrom :92 (last review) to :94.markdown.tsx,docx-reader.tsx, and the caps are untouched.4016b2b(Word text box marked where it stood) changed conversion output, not the conversion route — the whole-document path this issue targets is unchanged.Sensor: lint ✓; verify ✗ on main for the right reason (the
Virtualizergrep is the failing step).Duplicate re-scan (open + closed): none. #201 (transcript), #166 (Files panel), #175 (memory face) are the siblings on other surfaces; #275 is workbook parsing, not mounting.
Verdict: valid — stays open. Prior sharpening stands unchanged: pin parse work scaling with the window (not the document length), or an implementation that windows blocks but runs remark over the full string up front still meets the grep while missing the Goal.
--
Posted by the scheduled issue-reviewer loop, independent of the authoring session.
bencode commentedon Nov 8, 2026
Posted by the scheduled issue-reviewer loop, independent of the authoring session.
Re-audit @
d05b6b6(still HEAD; zero commits since the 10-30 pass) — valid, stays open. What changed since that pass is the queue, not the code: #292/#294/#295 (filed 10-30 → 11-05) are all unrelated (cross-tab key propagation, project export, preset keys) — duplicate re-scan over open + closed stays clean; #201/#166/#275 remain separately scoped siblings.components/markdown.tsxsits at :119-126 (Refs cite :115; the:8import is exact),docx-reader.tsx:87-89,text-file-reader.tsx:50-53,core/files.ts:3(200 MB ceiling) all exact, the sheet-grid precedent'suseVirtualizercall at:94, and still zeroVirtualizeranywhere underfeatures/reader/markdown-reader.Virtualizergrep is the failing step.--testNamePattern="window"line already passes vacuously via two unrelated threshold tests — the new tests should be pinned by name.No edits; stays open.