Repository navigation
Description
Summary
In an assistant message, a Markdown link to an absolute path opens a local preview only when the last path segment contains a dot. So [notes](/tmp/bb-link-repro/notes.md) and file:///tmp/bb-link-repro/notes.md open correctly. But links to folders, such as /tmp/bb-link-repro/folder or /tmp/bb-link-repro/folder/, and links to files with no extension, such as /tmp/bb-link-repro/Makefile, are not treated as local paths. They stay as raw same-origin hrefs, so a click sends bb's own server URL (http://<bb-origin>/tmp/bb-link-repro/folder) to the system browser, and the app shows its not-found page there. I expected a file link to open in the host-file preview and a folder link to open in something useful, such as the file manager open target or the thread-storage browser.
Versions and environment
- bb 0.46.0 desktop app. The code path below is the same on
mainat 05771e3. - macOS 26.6, Apple Silicon
- Claude Code 2.1.301 provider
- Thread with a ready project-checkout environment on the local machine
Steps to reproduce
-
In a terminal:
mkdir -p /tmp/bb-link-repro/folder && echo hi > /tmp/bb-link-repro/notes.md && echo all: > /tmp/bb-link-repro/Makefile -
Start a thread in any project and send this prompt:
Reply with exactly these lines and nothing else: - [file](/tmp/bb-link-repro/notes.md) - [file url](file:///tmp/bb-link-repro/notes.md) - [folder](/tmp/bb-link-repro/folder) - [folder slash](/tmp/bb-link-repro/folder/) - [folder url slash](file:///tmp/bb-link-repro/folder/) - [makefile](/tmp/bb-link-repro/Makefile) - [home](~/bb-link-repro-notes.md) -
Click each link.
The smallest form is any message link to an absolute path whose last segment has no ..
Does not reproduce: absolute paths whose last segment has a dot, with or without :12, :12:4 or #L3-L5. file:///… and file://localhost/… URLs, percent-encoded spaces, workspace-relative paths, and files in thread storage also route correctly.
Expected vs actual
Expected:
notes.mdandMakefileopen in a preview tab.- The folder links open in the file manager or the default folder open target. A folder in thread storage opens in the thread-storage browser.
~/…links resolve to the home directory, or render as plain text.
Actual: I ran the upstream classifier against each href, using parseLocalFileHref, resolveRelativeLocalFileHref and resolveThreadLocalFileLink from 05771e3 under plain Node with stubs for imports. The workspace root was /tmp/bb-link-repro/ws and the thread-storage root was /Users/<user>/.bb/thread-storage/<thread>.
| href | Parsed as local file? | Rendered href |
Result |
|---|---|---|---|
/tmp/bb-link-repro/notes.md |
yes | file:///tmp/bb-link-repro/notes.md |
open-host-path |
/tmp/bb-link-repro/notes.md:12 |
yes, line 12 | file:///…/notes.md#L12 |
open-host-path |
file:///tmp/bb-link-repro/notes.md |
yes | same | open-host-path |
file://localhost/tmp/bb-link-repro/notes.md |
yes | file:///… |
open-host-path |
/tmp/bb%20link%20repro/my%20notes.md |
yes, decoded | file:///tmp/bb%20link… |
open-host-path |
/Users/<user>/.bb/thread-storage/<thread>/report.md |
yes | file:///… |
open-thread-storage-path |
/tmp/bb-link-repro/folder |
no | /tmp/bb-link-repro/folder |
same-origin href |
/tmp/bb-link-repro/folder/ |
no | /tmp/bb-link-repro/folder/ |
same-origin href |
/tmp/bb-link-repro/ws/src (folder in workspace) |
no | raw | same-origin href |
/Users/<user>/.bb/thread-storage/<thread>/subdir |
no | raw | same-origin href |
/tmp/bb-link-repro/Makefile |
no | raw | same-origin href |
~/bb-link-repro-notes.md |
no | ~/bb-link-repro-notes.md |
relative href against the current page |
file:///tmp/bb-link-repro/folder |
yes, as a file | file:///tmp/bb-link-repro/folder |
open-host-path on a directory |
file:///tmp/bb-link-repro/folder/ |
no | "" |
rendered as plain text, not a link |
file://otherhost/tmp/… |
no | "" |
rendered as plain text |
I did not reproduce the click results below in the live app. I worked them out from the code:
- Same-origin href: the anchor has
target="_blank". The messageonOpenLinkhandler accepts onlyhttp(s)URLs, so it returnsfalsefor a bare path and the browser default runs. Electron's window-open handler resolves the href against the app origin. It denies the new window and openshttp://<bb-origin>/tmp/bb-link-repro/folderin the system browser. The server's catch-all returnsindex.htmlfor that path, so the browser shows the app's not-found route, not an HTTP 404. file:///…/folderwithout a trailing slash: this opens a host-file preview tab for a directory. That tab is a file reader, so I expect it to show an error.
Evidence (code at 05771e3)
- Message links use
trusted-hostabsolute routing: markdown-message-link-routing.ts#L48-L51 - For
trusted-hosthrefs that are not URLs,parseLocalFileHrefsetsrequireLikelyFileBasename: markdown-local-file-link.ts#L406-L424 - That flag rejects any basename without a
., so folders andMakefileare rejected. A trailing/is rejected in every mode: markdown-local-file-link.ts#L226-L261 file:URLs skip the basename check, sofile:///…/folderis accepted as a file: markdown-local-file-link.ts#L373-L404~/is excluded from relative resolution (from Chat links starting with ~/ resolve against the project root #1182), and nothing else handles it: markdown-local-file-link.ts#L291-L313- When the href does not parse, the URL transform falls back to react-markdown's
defaultUrlTransform. That keeps bare paths and blanks non-http schemes such asfile:with a host or a trailing slash: markdown-preview.tsx#L514-L549 MarkdownAnchorthen renders the raw href withtarget="_blank"and passes the click toonOpenLink: markdown-preview.tsx#L637-L712onOpenLinkhandles onlyhttp(s)URLs: in-app-browser-link-preference.ts#L27-L39- The desktop window-open handler sends the resolved
http://<origin>/…URL to the system browser: desktop-window-factory.ts#L283-L288. The server returnsindex.htmlfor unknown paths: server.ts#L359-L388 resolveThreadLocalFileLinkhas no directory outcome. Every parsed absolute path ends as a workspace, thread-storage or host file preview: thread-local-file-links.ts#L133-L216
Suggested fix
- Accept trailing-slash paths as directory links.
- Add a directory resolution to
resolveThreadLocalFileLink: thread-storage folders open in the thread-storage browser, and other folders go to the default folder open target, such as Finder. Show a toast when no target is available. - Relax the dot-basename check for paths under common host roots (
/Users,/home,/tmp, and similar), soMakefileandLICENSEalso link.
My fork, benwaffle/bb, carries a patch that does this, in the commit "Open file-change titles outside the Changes panel as local files". I can open a PR with that part if it helps. With that patch, a folder link without a trailing slash under a host root still resolves as a file, except in thread storage, where it is checked against the storage file list. A full fix probably needs a stat on the host to tell files and folders apart.
What I ruled out
- The report I started from said that every absolute-path or
file://link 404s. That is not the case: paths with a dotted basename andfile:///URLs route to local previews (see the table above). - Not Chat links starting with ~/ resolve against the project root #1182. That fix makes
~/links stop resolving against the project root, but they still render as broken relative hrefs. - Not Relative markdown links in plugin-embedded ThreadChat open as broken URLs against the app origin #4438 or ThreadChat drops local-file link routing on full-page plugin routes: inline-code file mentions, @thread mentions, and workspace-relative images render dead #4466. Those cover plugin-embedded
ThreadChatsurfaces that receive no local-file routing. This bug is in the main thread view, where routing is present but the classifier rejects the href. - Related but different: Add a Finder action beside local file links #1634 (Finder action beside file links), Markdown file preview fails for symlinks targeting folders outside the project root #3400 (symlinked folders in the Markdown file preview), Canonicalize attached and referenced file preview and download behavior #2697 (closed, file preview canonicalization).
- Not specific to the provider. Classification happens in the app renderer on the message text.
AGENT GENERATED
Activity
bb-slop-cop commentedon Oct 16, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotui. Filled missing values; replaced none.partial-repro.01affc197dc62; the explicit file-URL control works. All 88 relevant existing tests pass. The final macOS/Electron browser navigation remains unverified.Resolve and open Markdown links in one place (#6756)