[BUG] Desktop app: clickable file links intermittently fail after EnterWorktree mid-session — UI resolves links against the original project root, not the live worktree cwd (file-link variant of #45202)

Status Open
Reported on v2.1.205
Maintainer reply None cached
Activity 1 comment · opened Jul 18, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

In the Claude Code desktop app, EnterWorktree mid-session correctly moves the agent's tool cwd into the worktree (.claude/worktrees/<name>), and the env header reports the session's primary working directory as the worktree. But the desktop app UI resolves clickable markdown file links against the original project root (the main checkout the app launched with), not the live session cwd.

This manifests intermittently: when the agent emits a path relative to the project root (including the .claude/worktrees/<name>/ prefix) the link opens; when it emits a path relative to the worktree cwd (e.g. .review/report.md) — a legitimate reading, since the env reports cwd as the worktree — the UI can't resolve it. Using "Copy relative path" on a working vs broken link confirms one includes .claude/worktrees/<name>/ and the other doesn't.

Same root cause as #45202 (VS Code button, closed as stale): the UI base directory doesn't follow a mid-session worktree switch.

What Should Happen?

After a mid-session worktree switch, the UI should resolve file paths/links against the session's live cwd (the worktree) — matching what EnterWorktree advertises ("switches the session's working directory"). Then worktree-relative links open correctly and the base is consistent for both the UI and the agent.

Error Messages/Logs

Couldn't read this file. It may have been deleted or moved, or it lives outside the working directory.

Steps to Reproduce

  1. Open the desktop app on a git repo (main checkout = project root).
  2. Agent runs EnterWorktree → creates/enters .claude/worktrees/<name>; session cwd switches in (env header confirms).
  3. Agent writes a file in the worktree and emits a markdown link relative to its cwd (e.g. .review/report.md).
  4. Click it → "Couldn't read this file … outside the working directory." (File exists at .claude/worktrees/<name>/.review/report.md relative to the project root.)
  5. Intermittency check: when the agent instead emits .claude/worktrees/<name>/.review/report.md (project-root-relative), the same file opens fine.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.205 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

Related: #45202 — "Desktop app: VS Code button opens original directory after creating worktree mid-session." Same root cause (UI base directory doesn't follow a mid-session worktree switch), different surface (VS Code button, Linux). That issue was auto-closed as stale by a bot (not fixed, not a deliberate decline).

Platform detail: Windows 11, build 10.0.26200, Claude Code desktop app.

<img width="685" height="978" alt="Image" src="https://github.com/user-attachments/assets/db543634-c1fb-4e86-a77c-59fa9faf311a" />

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗