← the Atlas

Markdown preview: repo-relative links open the target file

bug · seedling ·implemented ·

Plan — make a repo-relative Markdown link open the linked file in the Code tab (mirroring how relative images already resolve) instead of booting a bogus app SPA in a new browser tab.

Plan of record · branch md-preview-rellink · issue #1161 · shipped in #1190

What a user sees

In the Code tab’s rendered Markdown preview, a repo-relative link — say [the limitations doc](packages/solid-markdown/LIMITATIONS.md) — should open that file in the Code tab, the way it does on GitHub. Today it opens a new browser tab at the app origin (http://localhost:5173/packages/…/LIMITATIONS.md), which just boots a fresh kolu SPA at a route that means nothing. The linked file never opens.

Relative images already do the right thing — a README’s ![](docs/logo.png) renders the real image through the per-terminal file route. Relative links have no equivalent. This plan gives them one.

today — broken
[the limitations doc](packages/solid-markdown/LIMITATIONS.md)
  1. anchor stamped target=_blank rel=noopener
  2. browser resolves href against the app origin
  3. opens http://localhost:5173/packages/…/LIMITATIONS.md
✗ a fresh kolu SPA boots at a bogus route — the file never opens
this plan — fixed
[the limitations doc](packages/solid-markdown/LIMITATIONS.md)
  1. scheme-less anchor tagged, no target=_blank
  2. click intercepted → host callback onNavigateRelative
  3. resolved vs the doc's dir → openInCodeTab front door
✓ LIMITATIONS.md opens in the Code tab's browse view — the app origin is never navigated

The change reuses an existing seam rather than inventing one. Relative images are resolved by a host callback that the preview component already accepts; links get a parallel callback, and clicks route through the same front door every other “open this file in the Code tab” producer uses (terminal path:line links, the right-click Open path menu).

Three layers move, each a thin pass-through — the shape mirrors the image path exactly:

LayerToday (images)Added (links)
@kolu/solid-markdownaccepts resolveImageSrc; rewrites <img> srctags scheme-less anchors, intercepts their click, calls a new optional onNavigateRelative(path) host callback
@kolu/solid-fileview rendererthreads resolveImageSrcthreads the new link callback
right-panel/BrowseFileDispatcherresolves image src vs the doc’s dirresolves the href vs the doc’s dir, then calls openInCodeTab

Why route through the existing front door

openInCodeTab is the single producer-side entry point for “show this file in the Code tab.” Reusing it means relative links inherit, for free, the behaviour the team already debugged for terminal links:

The alternative — teaching the preview to navigate on its own — would duplicate that front-door logic and re-open bugs (#1161’s sibling: the production effect-ordering elision the front door was built to sidestep). Rejected.

Trade-offs & scope

Test gap to close

This is a bug fix, so the reproducing test comes first (red → green):