[FEATURE] Clickable file links: offer to open (or fetch from git) files outside the current session folder / on another branch — instead of a dead-end error

Resolved 💬 2 comments Opened Jun 16, 2026 by alanafachini Closed Jun 20, 2026

What I'm trying to do

Click a clickable file link that Claude Code renders in the chat / transcript, and open that file — even when the file is not currently in the active session's working tree (for example, it lives only on another git branch, in a different worktree, or just outside the session folder).

What happens today

Clicking such a link is a hard dead-end. The file pane shows only an error like:

The file cannot be read. It must have been deleted or moved, or is outside the session folder.

There is no recourse offered — no prompt, no explanation of why, no action to recover. The link looks clickable and inviting, but clicking it just fails.

Concrete reproduction

  1. On a feature branch, commit some files (e.g. docs/audit/coverage.md).
  2. Switch the session back to main (those files are not in the main working tree).
  3. Ask Claude something that makes it reference those files — it renders them as clickable markdown links (relative paths).
  4. Click the link → the error above. The file genuinely isn't in the current working tree (it exists on the other branch), so the lookup fails, and that's the whole story the user gets.

This also reproduces for files in a sibling worktree, files outside the session root, and plan files under ~/.claude/.

Why this matters for all users

  • Clickable file links are a core navigation affordance — users learn to trust and click them.
  • Multi-branch, git-worktree, and monorepo workflows are extremely common; in all of them it's routine to reference a file that isn't in the current working tree.
  • The current behavior is a dead-end with zero graceful recovery — not even the agent that authored the link can help the user open it.
  • A confusing error ("deleted or moved") is shown even when the file very much still exists, just on another branch / location.

Proposed behavior

When a clicked link resolves to a file that is outside the session folder or not in the current working tree, instead of a hard error:

  1. Ask the user whether they want to open it / pull it into the current session, OR
  2. Offer to read it from git (the branch or worktree where it exists) and display it read-only, OR
  3. At minimum, **explain why** with an actionable message — e.g. "This file exists on branch docs/..., which isn't checked out in this session. [Open anyway] [Show from branch]".

Any of these turns a dead-end into a recoverable, understandable interaction.

Related issues

These are existing reports of the same "outside the session folder" surface, but each treats a specific case as a bug; this request is for a general graceful-fallback / prompt rather than per-case fixes:

  • #65272 (multi-folder sessions)
  • #51331 (SSH sessions)
  • #56425 (worktree)
  • #54792 (paths with spaces/commas)
  • #50798 (~/.claude/plans/)
  • #58302 (FleetView chip session)

Environment

  • Claude Code — Desktop app
  • macOS

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗