Repository navigation
Do not resolve home-relative chat links against the project root - #1796
SawyerHood merged 1 commit into
Conversation
resolveRelativeLocalFileHref treated every non-absolute href as workspace-relative, so `~/.config/example.md` became `<root>/~/.config/example.md` and opened a broken workspace file tab. Add a home-relative guard (`~`, `~/…`, `~user/…`) next to the absolute path check. Names that merely start with `~` stay relative. Fixes #1182 Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain English summary: This change stops BB from treating home paths such as ~/.config/file as files inside the current project. Ordinary filenames such as ~notes.md still work as project files.
I found no defect caused by this pull request.
- Security: The new check runs after one URI decode and before path joining. Existing path normalization still blocks ordinary traversal attempts.
- Code quality: The focused cases cover bare, encoded, suffixed, and named-user home paths. They also protect valid tilde-prefixed project names.
- Architecture: The codebase has no matching home-path helper that should replace this local check. Other tilde checks expand different configuration or host paths.
- Performance: The new pattern adds one linear scan per relative link. It adds no I/O or state work.
I found one older, non-blocking issue. The Markdown flow can decode some values twice through its parse-resolve-parse sequence. A separate change should define one decode step and add combined-flow tests for %257E and double-encoded dot segments.
Validation passed across 44 focused tests, git diff --check, and all current GitHub checks. The worktree stayed clean.
I started the isolated development app, and it returned HTTP 200. Dev-browser read the page title, but the page body stayed empty and timed out. I could not complete the live click test, and I stopped the isolated instance.
This is a comment-only review. I did not approve or request changes.
What was wrong
When an assistant message contains a shell-style home path such as
~/.config/example.md(inline code that ends in.md, or an explicit[text](~/…)link), the app renders it as a local-file link.resolveRelativeLocalFileHrefinapps/app/src/components/ui/markdown-local-file-link.tsrejects absolute paths, fragments, queries, and URI schemes, and then treats every other href as workspace-relative. The path became<workspace>/~/.config/example.md, which passed the containment checks. A click opened a workspace file tab that saidFailed to load file, andOpen in editorfailed withOpen target path does not exist: <workspace>/~/.config/example.md.What changed
apps/app/src/components/ui/markdown-local-file-link.ts: addisHomeRelativePathwith the pattern/^~(?:[^/]*\/|$)/uand include it in the early-return guard ofresolveRelativeLocalFileHref, next to thestartsWith("/")check. The check runs on the decoded href, so%7E/…is covered. It matches~,~/…, and~user/…. Names that only start with~(~notes.md,~$report.docx,docs/~draft.md) stay relative files.apps/app/src/components/ui/markdown-local-file-link.test.ts: add 6 home-relative cases that must resolve tonulland 4 positive cases that must still resolve as relative files.The fix follows the report's proposal with no deviation. Home-directory expansion (option 2 in the report) needs a host payload field and a protocol version bump. That is a separate change.
How I verified
pnpm exec vitest run src/components/ui/markdown-local-file-link.test.tson the base commit with only the test change: 6 failed / 15 passed. With the fix: 21 passed.pnpm exec turbo run typecheck --filter=@bb/app: clean.pnpm exec turbo run test --filter=@bb/app: 360 files, 2852 tests passed.Fixes #1182
Report: https://get-bb.github.io/reports/issues/1182.html