Skip to content

fix(web): repo-root-relative file chips open in subfolder projects - #14506

Closed
Gigioxx wants to merge 1 commit into
pingdotgg:mainfrom
Gigioxx:fix/repo-relative-file-chips
Closed

Gigioxx wants to merge 1 commit into
pingdotgg:mainfrom
Gigioxx:fix/repo-relative-file-chips

Conversation

@Gigioxx

@Gigioxx Gigioxx commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Note

🤖 Claude Opus 5.5 on behalf of Guille

Fixes #14492.

When a project is a subfolder of its git repo (repo at ~/school, project at ~/school/physics), agents often print paths the way git does, relative to the repo root: physics/notes/outline.md. The chip joins that onto the project root, so clicking it opens physics/physics/notes/outline.md and the files panel fails with Failed to read workspace file 'physics/notes/outline.md'.

Clicking a slashed chip now checks whether its leading segments repeat the project folder's own trailing segments (physics/… inside …/physics). If so, it asks the workspace index, the same lookup bare filenames already use, and opens the stripped path (notes/outline.md) only when that file exists and the literal path does not. A real physics/physics/... folder still opens as written.

This does not use repositoryIdentity.rootPath, which is missing for repos without a remote. It also covers "Reveal in file manager", which shares the lookup. The chip label, tooltip, and copy actions still show the joined path; mobile is unchanged since its chips have no workspace lookup yet.

Verification

  • Reproduced in a dev server with a remote-less repo at /tmp/school and the project at /tmp/school/physics: on main the chip opened physics > physics > notes > outline.md with the read error. With this change it opens physics > notes > outline.md and shows the file.
  • With a real physics/physics/notes/outline.md present, the chip still opens that nested file.
  • vp test run apps/web/src/workspaceBasenameLookup.test.ts (12 passed)
  • vp lint, vp fmt --check on the changed files, web tsc --noEmit

Made with Claude Opus 5.5 in Claude Code (T3 Code).

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Oct 1, 2026
for (let count = Math.min(cwdSegments.length, pathSegments.length - 1); count > 0; count--) {
const prefix = cwdSegments.slice(-count);
if (prefix.every((segment, index) => segment === pathSegments[index])) {
return pathSegments.slice(count).join("/");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High src/workspaceBasenameLookup.ts:67

A Windows path such as physics\notes\a.md is not matched against the workspace index's physics/notes/a.md, so paths.has(workspaceRelativePath) incorrectly reports the literal file as absent and may open notes/a.md instead. The slash normalization here only affects the stripped return value; normalize workspaceRelativePath before the lookup or use the normalized value consistently.

🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/workspaceBasenameLookup.ts around line 67:

A Windows path such as `physics\notes\a.md` is not matched against the workspace index's `physics/notes/a.md`, so `paths.has(workspaceRelativePath)` incorrectly reports the literal file as absent and may open `notes/a.md` instead. The slash normalization here only affects the stripped return value; normalize `workspaceRelativePath` before the lookup or use the normalized value consistently.

const isBasename = needsWorkspaceBasenameLookup(workspaceRelativePath);
const strippedPath = isBasename
? null
: stripRepeatedWorkspacePrefix(workspaceRelativePath, cwd);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High components/ChatMarkdown.tsx:2567

On case-insensitive Windows workspaces, stripRepeatedWorkspacePrefix fails to match a repo-relative path such as physics\notes\outline.md against C:\school\Physics, so the lookup is skipped and the panel opens the duplicated Physics\physics\notes\outline.md path. Make the prefix comparison case-insensitive for Windows paths so normal casing variations are stripped.

🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/ChatMarkdown.tsx around line 2567:

On case-insensitive Windows workspaces, `stripRepeatedWorkspacePrefix` fails to match a repo-relative path such as `physics\notes\outline.md` against `C:\school\Physics`, so the lookup is skipped and the panel opens the duplicated `Physics\physics\notes\outline.md` path. Make the prefix comparison case-insensitive for Windows paths so normal casing variations are stripped.

Copy link
Copy Markdown
Member

Note

This comment is posted by Julius' dot

Closing for missing UI verification. The reproduction notes and 12 focused tests help, but this changes file-chip click and reveal behavior without before/after screenshots or an interaction recording.

Please attach those captures showing the repeated-prefix path opening the intended file and a real nested folder still taking precedence, then request reconsideration.

@macroscopeapp

macroscopeapp Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Would Approve

Macroscope's review found this PR approvable — This is a small, self-contained web bug fix that adds a bounded workspace-index lookup for duplicated repo-relative file paths while preserving existing fallback behavior. Separate high-severity findings identify Windows path-handling risks that must be resolved by the correctness review process.

Not approved because:

  • 2 blocking correctness issues found at or above your repo's Minimum Blocking Severity

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

@Gigioxx

Gigioxx commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

[claude-opus-5-5] Responding on behalf of Guille

Replaced by #14510, which adds before/after screenshots and the nested-folder case. It also fixes the two Windows findings from Macroscope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Repo-root-relative file paths in agent output break when the project is a subfolder of the git repo

2 participants