Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: A relative Markdown link to a folder with a trailing slash, like `[patches/](patches/)`, renders as a plain link and does nothing on click #15237

ClosedVantrongs(GitHub profile, opens in a new tab) opened this issue 2 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. In a thread whose workspace has a folder patches, have the agent reply with [patches/](patches/) and [./patches/](./patches/).
  2. Click each link.

Expected behavior

Both open the folder, as folder links have since #10909.

Actual behavior

[./patches/](./patches/) is a folder chip and opens. [patches/](patches/) renders as an ordinary blue link, and clicking it does nothing, with no error or toast.

looksLikeFilePath rejects it: RELATIVE_FILE_PATH_PATTERN needs a segment after the last /, and RELATIVE_FILE_NAME_PATTERN needs an extension. The same folder passes as ./patches/, as an absolute path with a trailing slash, or as docs/My Folder without one (the test "resolves relative spaced folders"), although explicit Markdown links are meant to need less path evidence than inline code (markdown-links.ts).

The rejected link stays an <a target="_blank"> with the relative href. The click handler leaves non-web hrefs to the browser, which resolves it against the t3code: origin, and the desktop's setWindowOpenHandler denies anything that isn't http(s) without feedback. So any relative link that isn't recognized as a file is a silent dead click.

A possible fix is to accept a trailing slash on a relative link path, and to show an error instead of a dead click for a link that is neither a file nor a web URL.

Impact

Minor bug or occasional failure

Version or commit

0.0.46-nightly.20261003.2623 (fed41fa)

Environment

Desktop app on Linux (NixOS, Wayland, niri); Claude Code 2.1.288

Logs or stack traces

No response

Screenshots, recordings, or supporting files

No response

Workaround

No response

  1. Vantrongs(GitHub profile, opens in a new tab) added labelsneeds-triage

  2. Note

    Grok responding on behalf of Julius.

    Triage

    Thanks @Vantrongs for the clear repro and for tracing it all the way down to looksLikeFilePath.

    Confirmed. It's still the behavior on main (ce90eec), which is newer than nightly fed41fa.

    parseMarkdownFileLink accepts ./patches/ because of the ./ prefix, and it accepts /tmp/favicons/ because /tmp/ is a filesystem root. patches/ falls through to RELATIVE_FILE_PATH_PATTERN in packages/client-runtime/src/markdownLinks.ts, which needs a non-empty segment after the last slash, so the link isn't treated as a file. The same happens to any relative folder written with a trailing slash and no ./, ../, or ~/ prefix, including docs/My Folder/ and apps/web/src/. docs/My Folder without the slash still matches, which is why that test passes. A bare name with no slash, like readme, is rejected on purpose.

    Once the link isn't a file, MarkdownAnchor leaves it as a plain <a target="_blank">. The click handler only catches same-page fragments, web media, change requests, and http(s) URLs, so a relative href falls through. On desktop, setWindowOpenHandler silently denies anything parseSafeExternalUrl doesn't accept, which is why nothing happens. In a regular browser, the same link opens a new tab against the app's own origin. Mobile uses the same classifier, so patches/ isn't a file chip there either.

    Likely fix area

    • looksLikeFilePath could treat an explicit relative link that ends in / as a folder. fileBasename already labels that form as a folder, and recognized folder chips already open the file tree (#10909), so recognition looks like the only missing step. Inline code could keep the stricter check in inlineCodeFilePathCandidate, so `patches/` stays plain code. The shared tests in packages/client-runtime/src/markdownLinks.test.ts would cover both clients.
    • Showing an error for any link that's neither a file nor a web URL is a separate change. mailto: and other non-http links take the same silent path on desktop, so that may be worth tracking on its own.

    A maintainer will decide on the fix direction.

    Related, but not the same: merged #10909 and #5460, and open PRs #8254 and #14510, all deal with chips that are already recognized or with labeling a trailing separator.

  3. juliusmarminge removed labelsneeds-triage

  4. juliusmarminge added labelsvia-triage

  5. I'd like to take this one.

    Proposed scope, following the triage note: recognition only. RELATIVE_FILE_PATH_PATTERN in packages/client-runtime/src/markdownLinks.ts requires a non-empty segment after the last /, so I'd make that final segment optional. Explicit relative links like patches/, apps/web/src/ and docs/My Folder/ then parse as folders and reuse the existing folder-chip behaviour from #10909.

    What stays the same:

    • Inline code: `patches/` remains plain code, since inlineCodeFilePathCandidate still rejects it.
    • Routes and bare names: /chat/settings and readme are still not treated as files.

    I'd add cases to the shared table in markdownLinks.test.ts and to the trailing-separator tests in apps/web/src/markdown-links.test.ts, and attach before/after screenshots.

    Not included: the error for links that are neither a file nor a web URL. That looks like a separate change, as noted above.

    Is this direction OK? If so I'll open a PR.

Sign in to join this conversation.