t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: Clicking repo-relative file links in a linked PR description from a 'No project' thread tries to open them inside the scratch folder

Open Dodhon opened this issue 1 week ago • 0 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. Have a registered project for a GitHub repo (e.g. repo-a at <root>/dev/repo-a) and a broader project whose tree also contains another copy/worktree/symlink of a matching path (e.g. a Home project containing both dev/repo-a/rules/foo.md and .t3/worktrees/repo-a/.../rules/foo.md or .codex/memory/rules/foo.md).
  2. In a No project scratch thread (so the thread's cwd is <t3>/scratch/<thread-dir>), link and open a PR for repo-a in the right-hand PR panel.
  3. Click an auto-linkified repo-relative file path inside the PR description (for example inline code `rules/foo.md`).

Expected behavior

Clicking a repo-relative file reference inside a PR's description resolves against the PR's repository (either opening the file from the registered project matching the PR's owner/name, or opening the file in the PR's Code/Files tab) instead of trying to open a nonexistent file inside the thread's scratch folder.

Actual behavior

T3 Code opens a new file tab with breadcrumb No project > rules > foo.md and displays:

The file could not be accessed or read.
It may be missing or inaccessible.

Attempted path
<t3>\scratch\<thread-dir>\rules\foo.md

Workspace folder: <t3>\scratch\<thread-dir>. Check the link's path or locate the file in Files.

Root cause & decision context for maintainers

Traced in apps/web + packages/client-runtime (local checkout at 2f265f0024):

  1. apps/web/src/components/pullRequest/PullRequestMarkdown.tsx:126-135: PullRequestBodySegmentView already has context.repository (owner/name) and forwards it to <ChatMarkdown> for media (sourceControlMediaRepository={repository}), but passes the thread's cwd (<t3>/scratch/<thread-dir>) for file links—even when the PR belongs to a different repository.
  2. apps/web/src/components/ChatMarkdown.tsx:861-883 + packages/client-runtime/src/workspaceBasenameLookup.ts:125 (pickProjectLinkMatch): Because <scratch-cwd>/rules/foo.md does not exist, findWorkspaceFileMatch searches all otherRoots equally without using repository. When more than one path across otherRoots ends with /rules/foo.md (for example a Home project that also covers worktrees or symlinked copies alongside the repo project), matches.size > 1, so pickProjectLinkMatch returns null.
  3. apps/web/src/components/ChatMarkdown.tsx:919: openAt(match ?? panelPath) then falls back to panelPath (rules/foo.md), which FilePreviewPanel attempts to read relative to the scratch cwd.

Design question to decide before any PR: When a PR rendered inside a different workspace / No project thread contains a repo-relative file citation:

  • Option A: Resolve the PR's cwd (or prioritize lookup in findWorkspaceFileMatch) to the registered project whose repositoryIdentity matches context.repository on the same environment.
  • Option B: Open matching paths in the PR's own Files/Code view (or source-control blob URL) when the file isn't in the active thread's workspace, rather than opening a broken file preview tab against a scratch folder.
  • Option C (complement): In pickProjectLinkMatch, prefer exact root-relative matches (entry.path === target) over deeper suffix matches (.../worktrees/.../target) when a nested parent project (like Home) overlaps a child project.

Impact

Minor bug or occasional failure

Version or commit

T3 Code (Nightly) 0.1.12-nightly.20261122.5098 (traced against 2f265f0024)

Environment

Windows 11, T3 Code Desktop Nightly 0.1.12-nightly.20261122.5098, Antigravity (gemini-4-neon)

Workaround

Open the PR's Files Changed tab (or view the file on GitHub) instead of clicking repo-relative paths inside the PR description from a No project scratch thread.

Dodhon avatar Nov 22 '26 21:11 Dodhon