t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: SSH-style `host:path` references in chat never become file chips

Open alvarohulse opened this issue 2 months ago • 1 comments

Before submitting

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

Area

apps/web

Steps to reproduce

  1. In any thread, have the agent (or yourself) write an SSH-style host:path reference in inline code, e.g. `devbox:~/notes/handoff.md` or `devbox:/home/me/notes/handoff.md`.
  2. In the same message, include a plain path such as `~/notes/handoff.md` for comparison.

Expected behavior

Either the host:path reference renders as a file chip (ideally resolved against the matching SSH environment when the host matches one), or this is documented as intentionally out of scope.

This may well be intended behavior; filing so maintainers can decide. The reverse direction already exists: #11229 makes "Copy full path" on a remote file chip produce host:path, so a chip copied from one thread and pasted into another currently doesn't round-trip back into a chip.

Actual behavior

The host:path reference stays as plain inline code. The bare ~/… path in the same message becomes a chip.

Cause (from reading main): parseMarkdownFileLink in packages/client-runtime/src/markdownLinks.ts rejects anything matching EXTERNAL_SCHEME_PATTERN (/^([A-Za-z][A-Za-z0-9+.-]*):(.*)$/). A hostname like devbox or devbox-doggo is a valid URL scheme under that pattern, so devbox:~/… is treated as an external URL (like mailto:) and dropped before any path checks run.

Image

Impact

Minor bug or occasional failure

Version or commit

main @ c57a04b722

Environment

Linux server (remote environment), web/desktop client; agent output from Claude Code. Applies to any provider since detection is client-side.

Workaround

Write the path without the host prefix (~/… or an absolute path); it then resolves against the thread's environment.

Related: #11229 (copies host:path), #8251 (chips for files outside the project root fail to open).

🤖 Generated with Claude Code

alvarohulse avatar Oct 01 '26 05:10 alvarohulse

[!NOTE] Grok responding on behalf of Julius.

Triage

Thanks for digging into the parser. I confirmed this on main (c57a04b722), and your diagnosis is right. I'm treating it as an enhancement rather than a broken file chip, and it isn't a duplicate of #8251 (open issue) or #11229 (open PR).

parseMarkdownFileLink in packages/client-runtime/src/markdownLinks.ts returns null when hasExternalScheme matches. That check uses EXTERNAL_SCHEME_PATTERN (/^([A-Za-z][A-Za-z0-9+.-]*):(.*)$/), and it only lets a value through when the part after the colon is a line or column suffix (Dockerfile:8, script.ts:10) or the prefix is a Windows drive. devbox, devbox-doggo, and build-server.local all fit the scheme grammar, and ~/notes/handoff.md isn't a line number, so devbox:~/notes/handoff.md and devbox:/home/me/notes/handoff.md get dropped before looksLikeFilePath ever runs. A plain ~/notes/handoff.md has no scheme, so it still becomes a chip. Web inline code (resolveInlineCodeFileLinkMeta), mobile inline code (resolveMarkdownInlineCodePresentation), and explicit markdown links all go through this same parser.

That filter is also what keeps mailto:, javascript:, and https:// from turning into file chips (javascript:alert(1) has its own test). file: URLs are parsed earlier on purpose, so they aren't affected.

On the round-trip point: host:path isn't a supported file reference on main today. "Copy full path" copies targetPath with no host (handleCopy(targetPath, "Full path") in apps/web/src/components/ChatMarkdown.tsx). #11229 would start copying host:path for remote chips (for example build-server.local:/tmp/...), but it's still open, so nothing on main breaks the round trip yet. If it merges, a pasted copy in inline code would hit this same rejection until host:path is a real reference.

Simply stripping the host and chipping the rest would open the wrong file. resolveMarkdownFileLinkTarget only joins onto the current thread's cwd, so devbox:~/notes/handoff.md would open ~/notes/handoff.md on whatever machine that thread is using. A useful chip has to match the host to an SSH alias or advertised hostname, expand ~ on that machine, and open the file there. Real URI schemes, unknown hosts, and user@host:path should stay plain text. (user@host:path slips past the scheme check today but then fails the path-shape checks.) Web and mobile would both need this, since they share the parser.

For now, the workaround in your report is the supported form: write the path without the host prefix.

juliusmarminge avatar Oct 01 '26 06:10 juliusmarminge