#5625 · Local path links bypass preview routing
Trusted base: 01affc197dc621cddc7343e09b1c5c10a5b9efcb, fetched from get-bb/bb origin/main.
PARTIALLY REPRODUCED · Root-cause confidence: high
1. TL;DR
The real Markdown renderer leaves bare absolute paths with extensionless basenames as ordinary browser links rather than local preview links. A DOM click on an extensionless path never invokes the local-file callback, while an explicit file URL for the identical path does. The parser requires a dotted basename for bare trusted-host absolute paths and rejects trailing directory separators in all modes. There is also no directory outcome in the thread link resolver: an accepted explicit directory-shaped URL is dispatched to the file-preview route. These findings repeat in two clean trusted source checkouts; the final macOS Electron/system-browser navigation and not-found page are not reproduced here.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| Extensionless absolute links miss local-file handling. | Verified | Rendered href stays bare; regression click records zero local open requests in both checkouts. |
| Dotted absolute paths and explicit file URLs route locally. | Verified for tested controls | The dotted-path observation and explicit extensionless file-URL click resolve to open-host-path. |
| Directory-shaped bare paths, with or without a slash, miss local handling. | Verified syntactically | Both rendered hrefs stay raw. No filesystem stat is performed by these functions. |
| Explicit file URL with a trailing slash becomes plain text. | Verified | No anchor is rendered for that fixture. |
| Explicit file URL without a trailing slash sends a directory to a file preview. | Routing verified | The directory-shaped fixture resolves to open-host-path; a real directory preview error was not exercised. |
| Home-relative links remain ordinary relative hrefs. | Verified | The renderer preserves the literal home-relative href. |
| Clicking opens the system browser and the app's not-found screen on macOS. | Unverified live | Desktop source supports the mechanism, but this Linux DOM harness does not run Electron, Finder, or a real browser navigation. |
| Every path suffix, encoding, workspace/storage variant, and provider behaves as described. | Not exhaustively tested | Only the fixtures and controls listed below were executed; 88 relevant existing tests pass. |
3. Environment
- Linux x86_64, kernel 4.19.0-gvisor; Node v22.19.0; pnpm 9.15.0; Vitest 4.1.1 with jsdom.
- Two new detached checkouts at the identical full base SHA. The starting working checkout was not used to run target code.
- No provider, desktop runtime, running BB instance, network ports, or runtime data directory was needed. No production data was read.
- Frozen install succeeds in both checkouts. The first checkout's full Turbo build succeeds: 66/66 tasks.
4. Minimal reproduction
- Clone the trusted target and check out the recorded commit:
git clone https://github.com/get-bb/bb.git source-a cd source-a git checkout --detach 01affc197dc621cddc7343e09b1c5c10a5b9efcb pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build
- Save the complete test below as
apps/app/src/components/ui/issue-5625-repro.test.tsx. The fixture paths are synthetic; the routing code does not read the filesystem. - Run the renderer-boundary regression:
pnpm exec turbo run test --filter=@bb/app -- src/components/ui/issue-5625-repro.test.tsx --silent=false
- Expected: the explicit-file-URL control and bare-path subject dispatch the same host file preview request. Actual: the control succeeds, but the subject leaves the request list empty.
FAIL opens an extensionless absolute file through the same host preview route as explicit file URLs
AssertionError: expected [] to deeply equal [ { kind: 'open-host-path', …(1) } ]
Expected: [{ kind: "open-host-path", request: { lineRange: null, path: "/tmp/local-route-proof/Buildfile" } }]
Received: []
Test Files 1 failed (1)
Tests 1 failed | 1 passed (2)
exit status 1
The assertion and test-count lines above are excerpts from both actual runs; the Expected/Received lines summarize the full assertion diff. This is an intentional regression failure, not a build or test-harness failure.
Observed renderer output
| Fixture | Direct parser accepted | Rendered href | Thread resolution |
|---|---|---|---|
| dotted | true | file:///tmp/local-route-proof/manual.md | open-host-path |
| extensionless | false | /tmp/local-route-proof/Buildfile | none |
| directory | false | /tmp/local-route-proof/assets | none |
| directory-slash | false | /tmp/local-route-proof/assets/ | none |
| explicit-file | true | file:///tmp/local-route-proof/Buildfile | open-host-path |
| explicit-directory | true | file:///tmp/local-route-proof/assets | open-host-path |
| explicit-directory-slash | false | (plain text) | none |
| home-relative | false | ~/local-route-proof.md | none |
“Directory” is a synthetic pathname category here, not a stat result. The resolver cannot distinguish a directory from a file. The table is identical in both runs.
Complete reproduction test
// @vitest-environment jsdom
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, beforeAll, expect, it } from "vitest";
import { LazyMarkdownHtml } from "./lazy-markdown-html";
import { MarkdownPreview } from "./markdown-preview";
import { buildMarkdownMessageLinkRouting } from "./markdown-message-link-routing";
import { parseLocalFileHref } from "./markdown-local-file-link";
import { resolveThreadLocalFileLink } from "@/lib/thread-local-file-links";
beforeAll(() => LazyMarkdownHtml.preload());
afterEach(cleanup);
const fixtures = [
{ label: "dotted", href: "/tmp/local-route-proof/manual.md" },
{ label: "extensionless", href: "/tmp/local-route-proof/Buildfile" },
{ label: "directory", href: "/tmp/local-route-proof/assets" },
{ label: "directory-slash", href: "/tmp/local-route-proof/assets/" },
{ label: "explicit-file", href: "file:///tmp/local-route-proof/Buildfile" },
{ label: "explicit-directory", href: "file:///tmp/local-route-proof/assets" },
{
label: "explicit-directory-slash",
href: "file:///tmp/local-route-proof/assets/",
},
{ label: "home-relative", href: "~/local-route-proof.md" },
];
it("records actual rendered hrefs and path resolutions", () => {
const linkRouting = buildMarkdownMessageLinkRouting({
onOpenLocalFileLink: () => true,
workspaceRootPath: "/workspace",
});
render(
<MarkdownPreview
content={fixtures
.map(({ label, href }) => `[${label}](${href})`)
.join("\n\n")}
linkRouting={linkRouting}
/>,
);
const observations = fixtures.map(({ label, href }) => {
const parsed = parseLocalFileHref({
absoluteLinks: { kind: "trusted-host" },
href,
});
const renderedHref =
screen.queryByRole("link", { name: label })?.getAttribute("href") ?? null;
const resolution =
parsed === null
? null
: resolveThreadLocalFileLink({
fileOpenTargetIds: [],
hostFileLinksAvailable: true,
link: parsed,
threadStorageRootPath: "/thread-storage",
workspaceRootPath: "/workspace",
}).kind;
return { label, parsed: parsed !== null, renderedHref, resolution };
});
console.log(JSON.stringify(observations, null, 2));
expect(observations.find(({ label }) => label === "dotted")?.resolution).toBe(
"open-host-path",
);
expect(
observations.find(({ label }) => label === "extensionless")?.renderedHref,
).toBe("/tmp/local-route-proof/Buildfile");
expect(
observations.find(({ label }) => label === "directory-slash")?.parsed,
).toBe(false);
expect(
observations.find(({ label }) => label === "explicit-directory")
?.resolution,
).toBe("open-host-path");
});
it("opens an extensionless absolute file through the same host preview route as explicit file URLs", () => {
const resolutions: ReturnType<typeof resolveThreadLocalFileLink>[] = [];
const linkRouting = buildMarkdownMessageLinkRouting({
onOpenLocalFileLink: (link) => {
resolutions.push(
resolveThreadLocalFileLink({
fileOpenTargetIds: [],
hostFileLinksAvailable: true,
link,
threadStorageRootPath: "/thread-storage",
workspaceRootPath: "/workspace",
}),
);
return true;
},
workspaceRootPath: "/workspace",
});
render(
<MarkdownPreview
content="[control](file:///tmp/local-route-proof/Buildfile)\n\n[subject](/tmp/local-route-proof/Buildfile)"
linkRouting={linkRouting}
/>,
);
const expectedResolution = {
kind: "open-host-path",
request: { lineRange: null, path: "/tmp/local-route-proof/Buildfile" },
};
expect(fireEvent.click(screen.getByRole("link", { name: "control" }))).toBe(
false,
);
expect(resolutions).toEqual([expectedResolution]);
resolutions.length = 0;
fireEvent.click(screen.getByRole("link", { name: "subject" }));
expect(resolutions).toEqual([expectedResolution]);
});
The complete test is embedded here so the public report is self-contained. Raw logs and local test files remain outside the public reports repository, per its publication policy. No screenshot is supplied: the reproduced evidence is DOM routing and callback dispatch, not a claimed desktop visual reproduction.
5. Root cause
Message routing enables trusted-host absolute local links.
That policy selects requireLikelyFileBasename for non-URL absolute hrefs in parseLocalFileHref.
}
const parts = parseAbsoluteLocalFileHref(
urlParts?.path ?? href,
absoluteLinks.kind === "trusted-host" && !isUrl,
);
const link =
parts === null
The filename heuristic and trailing-separator validation reject extensionless basenames and slash-terminated paths:
function hasLikelyFileBasename(path: string): boolean {
const segments = isWindowsDriveLocalFilePath(path)
? path.split(/[\\/]/u)
: path.split("/");
const basename = segments[segments.length - 1] ?? "";
return basename.startsWith(".") || basename.includes(".");
}
function isValidAbsoluteLocalFilePath({
path,
requireLikelyFileBasename,
}: LocalFilePathValidationArgs): boolean {
return (
isAbsoluteLocalFilePathStart(path) &&
path !== "/" &&
!path.endsWith("/") &&
!(isWindowsDriveLocalFilePath(path) && path.endsWith("\\")) &&
!path.includes("\n") &&
!path.includes("\r") &&
!path.includes("?") &&
!path.includes("#") &&
!hasControlCharacter(path) &&
(!requireLikelyFileBasename || hasLikelyFileBasename(path))
);
When classification fails, the URL transform falls back to defaultUrlTransform; the rendered DOM confirms that bare paths survive unchanged, whereas the rejected file URL becomes plain text.
MarkdownAnchor only consumes recognized local links prevents the default navigation only when an applicable callback handles the link. Otherwise the raw anchor has target="_blank".
Home-relative paths are excluded from relative resolution, with no replacement home expansion in this path.
A second defect prevents a parser-only directory fix: the resolution union has no directory result, and the resolver routes accepted paths only to file-oriented destinations. The main thread handler opens workspace, storage, or host file previews consumes these outcomes. Accepting more strings would not implement directory opening.
For the desktop symptom, the ordinary browser preference handler only accepts HTTP(S) strings, while the Electron new-window handler forwards resolvable external URLs. This supports, but does not replace, a live desktop verification of the final navigation.
6. Proposed fix and simple-fix gate
Separate local-path recognition from file-versus-directory resolution. Preserve existing app-route handling, contained-root restrictions, and unsupported URL-host rejection. Use trusted host metadata when a path's type is ambiguous; route a directory through the existing appropriate folder/storage browsing action rather than a file reader. Define how unresolved and home-relative paths should behave before enabling a broader set of local targets. Add renderer click and directory-resolution regressions, plus desktop end-to-end verification.
No automatic fix PR: a complete fix needs a directory-aware routing contract and a policy decision about ambiguous absolute paths; the current contract is file-only. A one-line relaxation would leave directories broken and change an explicitly tested classification policy. This fails the “no product or architecture decision” simple-fix condition. No production patch, branch, or fix push was made.
Issue timeline metadata and an open-PR search for the trusted numeric issue found no linked open PR at investigation time. No external fork or issue-supplied code was fetched or executed.
7. Verification
The same agent repeated the reproduction, not an independent verifier. A second clean worktree was created at 01affc197dc621cddc7343e09b1c5c10a5b9efcb before introducing the first checkout's reproduction file. Its tracked production tree stayed unchanged. Its frozen install used its own dependency links. Only the self-authored test was copied in.
git worktree add --detach ../source-b 01affc197dc621cddc7343e09b1c5c10a5b9efcb cd ../source-b pnpm install --frozen-lockfile --prefer-offline # Save the complete test above at the same repository-relative path. pnpm exec turbo run test --force --filter=@bb/app -- src/components/ui/issue-5625-repro.test.tsx --silent=false First run: 1 passed, 1 failed; subject requests []; exit 1 Second run: 1 passed, 1 failed; subject requests []; exit 1 Observed href/resolution tables: identical
No servers were launched, so there are no shared ports or data directories to reset between runs. Code permalinks and excerpts were checked against the full recorded SHA. A subsequent fetch found no newer change to the three routing implementation files.
A first draft of the observation harness queried visible text directly; the local-file icon splits text nodes. That query was corrected to use the accessible link role before recording these final results. This corrected a test query, not a production defect.
8. Related issues
Repository search found #4466 about missing routing on plugin-hosted chat surfaces and #1634 about a Finder action. Neither replaces this renderer-classification regression, where routing is supplied. These issues were not investigated further.
9. Appendix
Existing tests
pnpm exec turbo run test --filter=@bb/app -- src/components/ui/markdown-local-file-link.test.ts src/components/ui/markdown-preview.test.tsx src/lib/thread-local-file-links.test.ts markdown-local-file-link.test.ts 29 passed markdown-preview.test.tsx 49 passed thread-local-file-links.test.ts 10 passed Test Files 3 passed (3) Tests 88 passed (88) exit status 0
The existing Markdown test suite emits jsdom's “Not implemented: navigation to another Document” diagnostic but passes. The baseline classifier test explicitly rejects an extensionless trusted-host absolute path; this demonstrates why flipping the heuristic alone is a policy change rather than a complete directory fix.
Recorded command families
Read-only GitHub issue/comments, type/field/label definitions, similar issue metadata, open PR metadata, repository visibility, and Pages configuration; trusted repository clone/fetch/worktree creation; frozen dependency installs; Turbo full build and the test commands above; source and history inspection; reproduction file formatting; and git diff --check. Both target checkouts contain only the self-authored reproduction file as an untracked change.
Trust and scope
Issue content was treated as untrusted claims. Its suggested commands, patches, links, and fork code were not followed or executed. The report tests were designed from the trusted main-branch renderer and existing contracts. No user account, credential, private runtime data, external issue-supplied URL, or real host filesystem fixture was needed.
Limitations: no live macOS/Electron click, system-browser not-found screenshot, Finder open target, real directory preview failure, or provider turn. The conservative verdict is PARTIALLY REPRODUCED despite high confidence in the verified routing root cause.
AGENT GENERATED