Repository navigation
Description
Summary
In the file preview of a Markdown file, clicking an in-page link such as [Scope](#block-1) does not scroll to the target. The web client opens a new browser tab with …/threads/<id>#block-1, so bb loads again from scratch and the user sees what looks like a page reload. Expected: the preview scrolls to the target and the user stays where they are.
Versions and environment
- bb 0.47.1 (
npm install [email protected], server on Debian 13 VPS, web client over SSH tunnel). Same code onmainat 3a2c49a. - Web client checked in Chromium (Playwright, headless). The desktop app was not checked.
- No agent involved.
Steps to reproduce
- Create
anchors.mdin a workspace:{ echo '# Anchor check'; echo; echo '[HTML anchor](#block-1) [Heading](#plain-heading) [Div](#div-anchor) [Other file](second.md#target)'; for i in $(seq 1 60); do echo; echo "Filler line $i"; done; echo; echo '<a id="block-1"></a>'; echo; echo '## Plain heading'; echo; echo '<div id="div-anchor">Div</div>'; } > anchors.md printf '# Second\n\nSECOND_FILE_TOP\n\n<a id="target"></a>\n\nTarget\n' > second.md - Open
anchors.mdin the thread file preview (workspace file, thread storage file and host file preview behave the same). - Click "HTML anchor", "Heading", "Div".
- Click "Other file".
Also tried: a Cyrillic heading and a Cyrillic <a id> (#%D0%B1… in href), and #user-content-block-1. Same result.
Expected vs actual
Link href / target Actual Target in DOM
#block-1 (<a id>) #block-1, _blank new tab …/threads/thr_…#block-1, no scroll no: empty <span> without id
#plain-heading #plain-heading, _blank new tab, no scroll <h2> without id
#div-anchor #div-anchor, _blank new tab, no scroll div#user-content-div-anchor
second.md#target file:///…/second.md second.md opens at the top, fragment dropped yes, no scroll
Original tab survives, history.length 2 -> 2, click event defaultPrevented: false.
Expected: #… links stay in the preview and scroll the preview container to the matching element. file.md#x opens the file at x.
Evidence
Cause, layer by layer (observed in DOM and click events, code at main 3a2c49a):
MarkdownAnchorsetstarget="_blank"on every link (L730). InhandleAnchorClicka#…href matches no branch:resolveUrlOpenTargetreturnsunhandledfor anything that is nothttp(s)://(L21-L33), sopreventDefaultis never called and the browser followstarget=_blank.rehype-sanitizewith the default schema prefixes raw HTML ids withuser-content-(div#user-content-div-anchor). The sanitizer keeps the anchor.<a id="block-1">has no href, soMarkdownAnchorreturns<span>{children}</span>and drops the id (L687).- Headings get no ids (no slug plugin), so GitHub-style heading links have no target.
- The document scrolls inside
[data-file-preview-scroll-container], not the window, so native fragment navigation would not move it even with a live target. - Local file routing builds
file:///…/second.mdwithout the fragment.
What you ruled out
- Not Markdown file preview: external links do nothing on click — MarkdownPreview gets no linkRouting.onOpenLink, so the target="_blank" default is swallowed #3395: that one is about external links in file preview doing nothing.
- Not Relative markdown links in plugin-embedded ThreadChat open as broken URLs against the app origin #4438: relative links in a plugin ThreadChat.
- Keep Markdown footnote links inside the preview #3586 fixed layer 1 for footnote links only and was closed unmerged as stale. No other open or closed issue or PR found for in-page fragment links (searched anchor, fragment, hash, heading anchor, slug, scrollIntoView, same-page).
- Still present on
mainat 3a2c49a:markdown-preview.tsxis unchanged since desktop-v0.47.1. - The document text is not the cause:
<a id>,<div id>, theuser-content-prefix and plain headings all fail the same way.
Suggested priority and effort
Medium: every in-page link in a Markdown file preview (tables of contents, footnote-style references) opens a second copy of bb. Workaround: browser find or the Raw tab. No data loss. Effort Low for layers 1, 3, 4. A fix for those follows in a PR. file.md#x (layer 6) is not covered there.
Checks
- I reproduced this on the latest release or on
main, or I say above that I could not. - I searched open and closed issues for the same problem.
- If an agent wrote this, the body ends with
> AGENT GENERATEDand links the thread or report. The investigation report lives in a private ops repo, the steps above are self-contained.
AGENT GENERATED
Activity
bb-slop-cop commentedon Oct 25, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotClassification: Bug · Priority: Medium · Effort: Medium · area:
ui.Reproduction and root-cause report: PARTIALLY REPRODUCED · root-cause confidence: high · reproduction label:
partial-repro.Four focused renderer regressions fail on trusted main in both clean checkouts: fragment clicks remain uncanceled with a new-tab target, HTML anchor IDs disappear, headings lack destination IDs, and relative file fragments are discarded. The application build and 117 existing tests pass. Chromium is unavailable, so actual new-tab behavior and preview scrolling remain unverified.
No PR: Complete cross-file navigation needs an extension to the public file-location contract, outside the simple-fix safety rules.
Support heading links only in Markdown file previews
Resolve and open Markdown links in one place (#6756)
lanjak commentedon Nov 17, 2026
Footnote references still do not scroll in Markdown file previews
#6756 fixed in-page
#fragmentlinks for headings and raw HTML ids. Footnote references are still broken: a click on[1]in a Markdown file preview does nothing. The back-reference link from the footnote works.Tested on:
mainat 1320c88e8a, Linux 7.3.4, Node 26.13.1. Tested with a component test that renders the realFilePreviewwithbuildMarkdownFileRoutingin jsdom and clicks both links. Not checked in a live browser.Steps
1reference.Observed
The footnote
<li>has noid, so the reference click (href#user-content-fn-1) finds no target. Only the back-reference scrolls.Cause
MarkdownListItemrenders<li>withclassNameandchildrenonly. It drops theidthat remark-gfm puts on each footnote item (markdown-preview.tsx#L1042-L1044). Keep Markdown footnote links inside the preview #3586 found the same gap and forwarded theid, but that PR was closed as stale.user-content-to footnote ids that remark-rehype already prefixed. The result isuser-content-user-content-fn-1.findMarkdownFragmentElementalso tries the id with one extrauser-content-prefix (markdown-link-target.ts#L135-L148). Thus the lookup still finds the target. The ids differ between the two paths, and any other consumer of the ids sees the double prefix.Fix options
idinMarkdownListItemLI#user-content-fn-1(plain) andLI#user-content-user-content-fn-1(HTML).remarkRehypeOptions={{ clobberPrefix: "" }}on the sanitized path only#fn-1, which the lookup resolves through its existing prefix fallback. Checked by a render of the HTML path:id="user-content-fn-1",href="#fn-1".clobberPrefix: ""in the sanitize schemaRecommendation: A now, because it fixes the visible defect with one line. B is optional cleanup if consistent ids matter. Do not use C.
This does not change timeline messages. Since #6756,
#fragmentlinks in messages render as plain text.Render streamed Markdown incrementally unless it has a parsed HTML no…