Repository navigation
Description
Problem
framePage prepares an HTML page for its sandboxed frame in three moves (ui-packages/web/src/features/reader/html-page.ts:35-68): the images it names are resolved from the library against the page's folder, web links get target="_blank", and #fragment links get a scroll handler. A link naming another file of the library — chapter-2.html, ./sub/report.pdf, ../index.html — matches none of the three: only /^https?:\/\//i and # are considered (lines 49-52), so the href is left as written.
In the frame it then kills the pane. The page runs from a blob URL in a sandbox without top navigation (ui-packages/web/src/features/reader/html-reader.tsx:25-31), so the click navigates the frame itself to blob:…/chapter-2.html, which cannot resolve: a blank pane until the tab is reopened — the dead pane #204 described for web links, back through the door #218 left shut.
A reader meets this with ordinary imports: a folder of saved pages — documentation, an offline copy of a site — where every page links its siblings. And the failure is lopsided inside one page: its <img src="images/fig.gif"> renders fine, because image references already resolve through the library (ui-packages/web/src/features/reader/markdown-image-resolver.ts:8-23), while its <a href="chapter-2.html"> blanks the pane. Notes open the files they link (ui-packages/web/src/features/reader/markdown-reader/file-link.tsx); an HTML page is the only place a library file link leads nowhere.
Proposal
- In
framePage, resolve each non-web, non-fragment href against the page's folder with the sameresolveFileReferencePaththe image resolver uses. - An href that names a library file opens that file in the reader, in a tab, as a note's file link does — the frame hands the target to the app, the shape the existing sandbox (scripts, popups) already allows.
- An href that resolves to nothing in the library does nothing, but must not navigate the frame — the pane never dies on a link again.
Goal
After this, a reader who imports a folder of linked pages moves between them by the pages' own links, each opening in a tab as a note's link does; and no link inside an HTML page can blank the pane it was clicked in.
Verification
grep -q "resolveFileReferencePath" ui-packages/web/src/features/reader/html-page.ts
pnpm --filter -reader/web test --silent -- src/features/reader/html-page.test.ts
pnpm checkRefs
- ui-packages/web/src/features/reader/html-page.ts:49-57 — the link filter that leaves library hrefs as written
- ui-packages/web/src/features/reader/html-reader.tsx:25-31 — the blob-sourced sandboxed frame a relative click navigates and dies in
- ui-packages/web/src/features/reader/markdown-image-resolver.ts:8-23 — the folder-relative resolution images already receive
- ui-packages/web/src/features/reader/markdown-reader/file-link.tsx — the in-app file-link interaction model to share
- Let a link in an HTML page open outside the reader — today a click navigates the sandbox away from the document, leaving a dead or hijacked pane until the tab is reopened #204 (closed by fix: links in a PDF or HTML page and files dropped outside Files no longer take the reader away #218) — the web-link half of this pane-killing problem; this issue is the library-link half the same fix left behind
Activity
bencode commentedon Oct 26, 2026
Independent review — posted by the scheduled issue-reviewer loop, independent of the authoring session. Audited against
main@e011712(2026-10-26, i.e. after #218).Evidence audit: all citations hold.
features/reader/html-page.ts:35–68—framePageconfirmed: images resolved through the library, web links filtered by/^https?:\/\//iand giventarget="_blank"(:49–57),#links given the scroll script; a library-relative href (chapter-2.html,./sub/report.pdf,../index.html) matches none of the three and is left as written.features/reader/html-reader.tsx:25–31— the frame is blob-sourced withsandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox"and no top navigation, so a relative click navigates the frame itself into an unresolvableblob:URL. The dead-pane mechanics are real.features/reader/markdown-image-resolver.ts+markdown-reader/file-link.tsx— the resolution (resolveFileReferencePath) and the in-app open interaction model both exist and are importable today.Sensor + Verification block repaired (logged here per policy): lint ✓ — but verify ✓ passed on unmodified main, i.e. a false pass: the block runs the existing
html-page.test.tsandpnpm check, both green with the deliverable absent (resolveFileReferencePathappears nowhere inhtml-page.ts). Since verify is the close gate, a future beat could have read this as implemented. Prepended the deliverable-shaped anchor:grep -q "resolveFileReferencePath" ui-packages/web/src/features/reader/html-page.tsRe-linted ✓; verify now ✗ on main for the right reason (fails fast).
Sharpening: the load-bearing invariant is "no link can blank the pane" — an href that resolves to nothing in the library must have its click swallowed inside the frame, not merely left unrewritten (a left-as-written href still navigates the blob frame and kills it). That swallow belongs in the injected in-frame script alongside the
#handler, and it is the casehtml-page.test.tsshould pin. Sibling forms (./,../, bare name) should flow through the oneresolveFileReferencePathcall; non-HTML targets (anotes.mdhref) should open through the same open-file path a note's link uses, not be special-cased.Verdict: valid — stays open.
bencode commentedon Oct 27, 2026
Closing. The page runs from a blob URL, and a relative href such as chapter-2.html cannot be resolved against one (new URL throws), so the browser does not navigate: the link does nothing rather than blanking the pane. Opening linked library files from a page would need a script in the frame and a message channel to the app, which a folder of interlinked saved pages, a rare import, does not justify.