Repository navigation
fix(web): repo-root-relative file chips open in subfolder projects #14506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,3 +52,20 @@ export function pickWorkspaceBasenameMatch( | |
| ); | ||
| return foldedMatches.length === 1 ? (foldedMatches[0]?.path ?? null) : null; | ||
| } | ||
|
|
||
| /** | ||
| * Agents echo git paths relative to the repository root, so in a project that | ||
| * is a subfolder of its repository `physics/notes/a.md` repeats the project's | ||
| * own folder. Returns the path with that repeated prefix removed, if any. | ||
| */ | ||
| export function stripRepeatedWorkspacePrefix(relativePath: string, cwd: string): string | null { | ||
| const pathSegments = relativePath.split(/[\\/]+/); | ||
| const cwdSegments = cwd.split(/[\\/]+/).filter(Boolean); | ||
| 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("/"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 High A Windows path such as 🤖 Copy this AI Prompt to have your agent fix this: |
||
| } | ||
| } | ||
| return null; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High
components/ChatMarkdown.tsx:2567On case-insensitive Windows workspaces,
stripRepeatedWorkspacePrefixfails to match a repo-relative path such asphysics\notes\outline.mdagainstC:\school\Physics, so the lookup is skipped and the panel opens the duplicatedPhysics\physics\notes\outline.mdpath. 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: