You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(shared): distinguish POSIX file links with backslashes in their parent folders - #47675
buildFileLinkParentSuffixByPath, pathParentSegments, and fileLinkLabel in packages/shared/src/fileLinks.ts unconditionally replace \ with /. On POSIX, backslashes are valid directory and filename characters (which fileBasename in packages/shared/src/path.ts already preserves), so two distinct POSIX paths with the same basename—such as /repo/D:\notes/report.md and /repo/D:/notes/report.md (or /repo/a\b/report.md and /repo/a/b/report.md)—collapse to the same key and receive no parent-folder suffix. Both file chips render identically as report.md in chat markdown (ChatMarkdown.tsx) and lose their disambiguated parent label in thread find text (threadFindText.ts), while a POSIX basename containing \ (build\log.txt) falsely collides with log.txt.
Change
Extract and export isPosixAbsolutePath in packages/shared/src/path.ts using fileBasename's existing predicate (path.startsWith("/") && !isNetworkPath(path) && !SLASH_PREFIXED_WINDOWS_DRIVE_PATTERN.test(path)) and call it from fileBasename.
Add fileLinkPathKey in packages/shared/src/fileLinks.ts so POSIX absolute paths keep literal backslashes in buildFileLinkParentSuffixByPath, pathParentSegments, and fileLinkLabel, while Windows drive paths, slash-prefixed Windows drive paths (/C:/...), UNC/network paths, and relative paths continue normalizing \ to /.
Add focused regression tests in packages/shared/src/fileLinks.test.ts covering POSIX backslash parent folders, POSIX basenames with literal backslashes, and Windows/UNC normalization.
Scope
Small, focused fix for an obvious bug in shared path/file-link disambiguation (no issue needed). Re-lands AppsAtMe's #47190, which was auto-closed by the 3-open-PR cap shortly after opening; credited with Co-authored-by: AppsAtMe <[email protected]>.
Verification
Focused unit tests (red -> green):vp test run packages/shared/src/fileLinks.test.ts
On base a19b9187b3: 3 failed / 48 passed (buildFileLinkParentSuffixByPath(['/repo/D:\notes/report.md', '/repo/D:/notes/report.md']) returned []; buildFileLinkParentSuffixByPath(['/repo/a/build\log.txt', '/repo/b/log.txt']) returned bogus suffixes for "log.txt"; fileLinkLabel returned "report.md" instead of "report.md · repo/D:\notes").
On head 762c249487: 51/51 passed (packages/shared/src/path.test.ts 72/72 and packages/shared/src/threadFindText.test.ts 25/25 also passed).
Changed checks:vp run check:changed upstream/main passed (format, lint, knip, typecheck across 37 packages, and 3 affected test files / 125 tests).
Surfaces:apps/web (ChatMarkdown.tsx) and packages/shared/src/threadFindText.ts both use buildFileLinkParentSuffixByPath and fileLinkLabel; Electron desktop wraps apps/web; apps/mobile calls fileLinkLabel(target, new Map()) without parent disambiguation (fileBasename already preserves POSIX backslashes).
Not checked: Electron desktop shell, Linux Chromium (verified in macOS Chromium), and live Windows runtime (Windows drive, /C:/..., and UNC paths verified via unit tests).
Scenario: POSIX file links with backslashes in their parent folders stay distinct
Proven: the scenario fails on base a19b9187b3 and passes on head 762c249487.
Base a19b9187b3
Head 762c249487
Result
❌ failed ASSERTION_FAILED: expect.toHaveText failed locator: getByRole("link", name: /^report.md/).nth(0) expected: text "report.md · demo/a\b" observed: text "report.md" (match count 1)
✅ passed
posix backslash file link labels
Scenario source (uncommitted, run with vp run scenarios:prove … --base upstream/main)
import{expect}from"e2e";import{test,WEB}from"./t3.ts";test("POSIX file links with backslashes in their parent folders stay distinct",WEB,async({ t3, app, screen })=>{constproject=awaitt3.project("demo",{"a\\b/report.md": "# Backslash folder report\n","a/b/report.md": "# Nested folder report\n",});constthread=awaitt3.thread({
project,title: "Compare reports",messages: ["Compare [report.md](./a%5Cb/report.md) and [report.md](./a/b/report.md).",],});awaitt3.open(thread);awaitscreen.getByRole("button",/^AgentCompare/).tap();constlinks=screen.getByRole("link",/^report\.md/);awaitlinks.nth(0).waitFor();awaitlinks.nth(1).waitFor();awaitapp.screenshot("posix-backslash-file-link-labels");awaitexpect(links.nth(0)).toHaveText("report.md · demo/a\\b");awaitexpect(links.nth(1)).toHaveText("report.md · a/b");},);
…arent folders
buildFileLinkParentSuffixByPath, pathParentSegments, and fileLinkLabel unconditionally replaced backslashes with forward slashes, collapsing distinct POSIX paths such as /repo/D:\notes/report.md and /repo/D:/notes/report.md so neither received a parent-folder suffix. Share fileBasename's POSIX absolute path check as isPosixAbsolutePath and skip backslash normalization for POSIX absolute paths while keeping Windows and UNC normalization unchanged.
Co-authored-by: AppsAtMe <[email protected]>
Macroscope's review found this PR approvable — Preserves literal backslashes in POSIX parent-folder names so file links receive distinct labels. The impact is limited to displayed labels and searchable text; navigation targets remain unchanged.
You can add or adjust custom eligibility rules. Learn more.
Reviewing files that changed from the base of the PR and between 762c249 and 24baa24.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The change adds POSIX absolute path classification and uses consistent path keys to build and look up file-link parent suffixes. Tests cover equivalent Windows path spellings, POSIX paths with literal backslashes, and paths on separate drives.
Changes: File-link suffix handling
Layer / File(s)
Summary
Path classification and key handling packages/shared/src/path.ts, packages/shared/src/fileLinks.ts
isPosixAbsolutePath identifies POSIX absolute paths. File-link path keys preserve these paths and normalize backslashes for other paths.
Suffix generation and display packages/shared/src/fileLinks.ts, packages/shared/src/fileLinks.test.ts
Suffix grouping and label lookup use the same path-key conversion. Tests cover equivalent Windows spellings and distinguishing suffixes for POSIX paths with literal backslashes and Windows paths on separate drives.
File links to POSIX paths containing literal backslashes now get distinct parent suffixes, and Windows path handling is unchanged. The change is small and well covered by tests, and no merge-blocking risk is evident.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the primary change: POSIX file links with backslashes in parent folders are now distinguished. It follows the conventional commit form and matches the objectives, which describe preser…
Description check
The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section explains the collision of distinct POSIX paths and gives reproduction examples. The …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the primary change: POSIX file links with backslashes in parent folders are now distinguished. It follows the conventional commit form and matches the objectives, which describe preserving literal backslashes in POSIX absolute paths for file-link disambiguation.
Full details: Description check
Explanation
The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section explains the collision of distinct POSIX paths and gives reproduction examples. The Change section lists the helper and key-function changes and the new tests. Scope explains why no issue is needed for this small bug fix. Verification gives focused test results, changed-check results, surfaces, and items not checked, with before/after evidence for the UI scenario. The template's agent-attribution line is present as the model name 'Gemini 4 Neon via T3 Code'. The description does not link an issue, but it explains why none is needed, as the template allows.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Reviewing files that changed from the base of the PR and between ab091df and 762c249.
Files selected for processing: 3
packages/shared/src/fileLinks.test.ts
packages/shared/src/fileLinks.ts
packages/shared/src/path.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Environment: Linux web client, Chromium, 1280×800, light theme; fresh isolated server state on each commit, Replay (dev).
On each commit, seed a fresh demo git project containing a literal a\b/report.md and a/b/report.md. Create a Replay (dev) thread with Compare [report.md](./a%5Cb/report.md) and [report.md](./a/b/report.md)., open the thread, expand the user message, and capture the rendered file links.
Scenario: POSIX file links preserve literal backslashes in distinguishing parents
The secondary build\log.txt basename false-collision case and Windows/UNC normalization were not exercised in this UI scenario; it proves the primary POSIX parent-folder reproduction.
Mobile and desktop shell were not exercised; this proof covers the web rendering path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:S10-29 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
buildFileLinkParentSuffixByPath,pathParentSegments, andfileLinkLabelinpackages/shared/src/fileLinks.tsunconditionally replace\with/. On POSIX, backslashes are valid directory and filename characters (whichfileBasenameinpackages/shared/src/path.tsalready preserves), so two distinct POSIX paths with the same basename—such as/repo/D:\notes/report.mdand/repo/D:/notes/report.md(or/repo/a\b/report.mdand/repo/a/b/report.md)—collapse to the same key and receive no parent-folder suffix. Both file chips render identically asreport.mdin chat markdown (ChatMarkdown.tsx) and lose their disambiguated parent label in thread find text (threadFindText.ts), while a POSIX basename containing\(build\log.txt) falsely collides withlog.txt.Change
isPosixAbsolutePathinpackages/shared/src/path.tsusingfileBasename's existing predicate (path.startsWith("/") && !isNetworkPath(path) && !SLASH_PREFIXED_WINDOWS_DRIVE_PATTERN.test(path)) and call it fromfileBasename.fileLinkPathKeyinpackages/shared/src/fileLinks.tsso POSIX absolute paths keep literal backslashes inbuildFileLinkParentSuffixByPath,pathParentSegments, andfileLinkLabel, while Windows drive paths, slash-prefixed Windows drive paths (/C:/...), UNC/network paths, and relative paths continue normalizing\to/.packages/shared/src/fileLinks.test.tscovering POSIX backslash parent folders, POSIX basenames with literal backslashes, and Windows/UNC normalization.Scope
Small, focused fix for an obvious bug in shared path/file-link disambiguation (no issue needed). Re-lands AppsAtMe's #47190, which was auto-closed by the 3-open-PR cap shortly after opening; credited with
Co-authored-by: AppsAtMe <[email protected]>.Verification
vp test run packages/shared/src/fileLinks.test.tsa19b9187b3: 3 failed / 48 passed (buildFileLinkParentSuffixByPath(['/repo/D:\notes/report.md', '/repo/D:/notes/report.md'])returned[];buildFileLinkParentSuffixByPath(['/repo/a/build\log.txt', '/repo/b/log.txt'])returned bogus suffixes for"log.txt";fileLinkLabelreturned"report.md"instead of"report.md · repo/D:\notes").762c249487: 51/51 passed (packages/shared/src/path.test.ts72/72 andpackages/shared/src/threadFindText.test.ts25/25 also passed).vp run check:changed upstream/mainpassed (format,lint,knip,typecheckacross 37 packages, and 3 affected test files / 125 tests).apps/web(ChatMarkdown.tsx) andpackages/shared/src/threadFindText.tsboth usebuildFileLinkParentSuffixByPathandfileLinkLabel; Electron desktop wrapsapps/web;apps/mobilecallsfileLinkLabel(target, new Map())without parent disambiguation (fileBasenamealready preserves POSIX backslashes)./C:/..., and UNC paths verified via unit tests).Scenario: POSIX file links with backslashes in their parent folders stay distinct
Proven: the scenario fails on base
a19b9187b3and passes on head762c249487.a19b9187b3762c249487ASSERTION_FAILED: expect.toHaveText failed
locator: getByRole("link", name: /^report.md/).nth(0)
expected: text "report.md · demo/a\b"
observed: text "report.md" (match count 1)
Scenario source (uncommitted, run with
vp run scenarios:prove … --base upstream/main)Gemini 4 Neon via T3 Code