File preview links break when session runs inside a worktree

Resolved 💬 2 comments Opened May 5, 2026 by smara-codes Closed May 5, 2026

Summary

When Claude Code starts a session in a worktree (e.g. .claude/worktrees/<name>), markdown file links in responses resolve relative to the worktree root — not the main repo. If Claude writes files to the main repo using absolute paths (which it does by default), clicking those links in the preview panel fails with:

"The file could not be read. It may have been deleted or moved."

The files exist and are accessible via the file tree, but one-click preview from a response link does not work.

Steps to Reproduce

  1. Claude Code starts a session inside a worktree (e.g. auto-created by a previous session)
  2. Claude writes files to the main repo using absolute paths
  3. Claude includes a relative markdown link to that file in its response
  4. User clicks the link in the preview panel → fails

Expected Behavior

File links in Claude responses should resolve correctly regardless of whether the session is running in a worktree — or the preview panel should detect that the file is outside the worktree and offer to open it from its absolute path.

Workarounds

  • Navigate to the file manually via the file tree
  • Run the session from the main repo instead of a worktree
  • Remove stale worktrees so the session returns to the main repo root

Context

This is particularly disruptive for knowledge-management or document-heavy workflows where Claude frequently links to files it has written or updated. The user has no obvious signal that the session is running in a worktree, making the broken links confusing.

View original on GitHub ↗

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