Skip to content

Chat links starting with ~/ resolve against the project root #1182

Closed

Description

@arunsathiya

Summary

A chat message that contains a path like ~/.config/example.md renders as a clickable link. The click opens a file tab in the secondary panel. From that tab, Open in editor fails, because the path bb resolved is <project root>/~/.config/example.md.

Steps to reproduce

  1. Open a thread whose environment has a workspace, for example /Users/me/bb.
  2. Post a message that contains ~/.config/example.md.
  3. Click the link. A file tab opens.
  4. Click Open in editor.

Expected: the link resolves to the home directory, or bb leaves it as plain text.

Actual: bb joins the literal ~ segment to the workspace root. The editor reports that it cannot open /Users/me/bb/~/.config/example.md.

Cause

resolveRelativeLocalFileHref in apps/app/src/components/ui/markdown-local-file-link.ts treats every non-absolute href as workspace-relative. It rejects absolute paths, fragments, queries, and URI schemes, but it does not handle a leading ~/.

The join at line 320 produces the literal path above. That path passes isAbsoluteFilePathWithinRoot, so resolveThreadLocalFileLink classifies the link as a workspace file and opens a workspace tab.

No code expands ~ in this path. Tilde expansion exists in apps/cli, apps/desktop/src/main.ts, apps/host-daemon, and packages/config, but not in the renderer link code. The renderer has no home directory value at all.

Possible fixes

  1. Reject a leading ~/ in resolveRelativeLocalFileHref. The link stays plain text. Small and safe.
  2. Expand ~/ to the host home path. This needs the home path in the renderer, and it routes the result as a host file link. Larger, and it needs a host-daemon field.

I plan to send a pull request for option 1, unless you prefer option 2.

Activity

  1. added theissue type on Aug 8, 2026
  2. ymichael commented on Aug 10, 2026

    @ymichael
    Collaborator

    @arunsathiya option 1 sounds good - feel free to open a PR for it!

  3. SawyerHood commented on Aug 13, 2026

    @SawyerHood
    Collaborator

    Apologies for the overlap, @arunsathiya — an overnight issue sweep opened #1504 for this without checking that you were already assigned. I have closed it. This is yours.

    One note from that work, in case it saves you time: rejecting a decoded leading ~/ in resolveRelativeLocalFileHref also needs to reject the percent-encoded forms, otherwise %7E/ still reaches the join.

    AGENT GENERATED: by Claude Opus 5

  4. added
    ui
    on Aug 18, 2026
  5. SawyerHood commented on Aug 18, 2026

    @SawyerHood
    Collaborator

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1182.html

    • Verdict: REPRODUCED · root-cause confidence: high
    • Root cause (short): resolveRelativeLocalFileHref (apps/app/src/components/ui/markdown-local-file-link.ts L294-L323) rejects absolute/fragment/query/scheme hrefs but has no case for shell home paths, so ~/x is string-joined onto the workspace root, yielding <root>/~/x, which passes every containment check and opens as a workspace file tab whose Open-in-editor fails with path_not_found.
    • Proposed fix: Add isHomeRelativePath(path) with the corrected regex /^(?:/|[^/]*/|$)/ — i.e. /^(?:[^/]*/|$)/u — and include it in the early-return guard of resolveRelativeLocalFileHref next to the startsWith("/") check, on the decoded href (so %7E/ is covered). Matches bare ~, ~/…, ~user/…; keeps ~notes.md, ~$report.docx, docs/~draft.md as relative files (now guarded by four positive test cases). Verified at 16ceb3a: repro test 7 fail/4 pass on base, 11/11 with fix; 37 pass together with markdown-local-file-link.test.ts and markdown-preview.test.tsx; turbo typecheck @bb/app clean; dif…
    • Caveats: Revision: the original regex /^[^/]*(?:/|$)/ was equivalent to /^/ and the report's claim that it kept ~notes.md linkified was false; corrected regex, diff, test file (11 cases), vitest output, and report text were regenerated and a Verification section added. Live-app screenshots were not re-taken because both regexes behave identically for every ~/… case exercised in the browser (unit tes…

    The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at 16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Opus 5

  6. added
    confirmed-repro
    on Aug 18, 2026
  7. added a commit that references this issue on Aug 18, 2026
    88564b6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

confirmed-reproui

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions