Repository navigation
fix(file-explorer): find the Windows parent folder instead of / - #27995
Conversation
utils.dirname split on '/' only, so on a Windows gateway every backslash path came back as '/', and Go to parent folder, Reveal parent and open-by-path re-rooted the tab at a root the backend refuses. A Windows-shaped path (drive-rooted or backslash UNC) now takes parentDir's separator-aware cut and stops at the drive or share root; POSIX paths keep the '/'-only rule. Fixes #27791
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The diff changes only which folder the path helper returns. It adds or changes no control, string or markup, so nothing renders differently and no screenshot is needed. [UX-REVIEWED] 528e755 Description read[DESCRIPTION-READ] 20cee1eba90765c061dedb0b95032c36931504b063b5164de1c18cf072892f20 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The fix is in the one shared helper, and paths that are not Windows-shaped keep the old Notes
[DESIGN-REVIEWED] 528e755 Description read[DESCRIPTION-READ] 565b509ed3bda9750196c51011cb1ab91f0f2be06eea76985d94bdb462e0aca3 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix works at the cause, inside Notes
What this change shipsInventory (5 items) — 4 justifiedIntent: on a Windows gateway, a Files user moving to a parent folder ends up in the real parent folder, not in
[FIRST-PRINCIPLES-REVIEWED] 528e755 Description read[DESCRIPTION-READ] 6a381a5df59fafc6a251f5e7bf8875df1578b2c9368513ddae43767e3f2a5cd4 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (4 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: file explorer dirname uses the Windows-aware parent for drive and UNC paths instead of returning /.
Problem / Motivation
Goal: On a Windows gateway, "Go to parent folder", the tree's "Reveal parent" and opening a file by path land on the real parent folder instead of
/.On a Windows gateway the Files app computes every parent folder as
/. The backend resolves/toC:\and refuses it (path not allowed: C:\), so the folder tab lands on a root it cannot list. Three controls hit this: "Go to parent folder" on the folder-unavailable panel, the tree context menu's "Reveal parent", and opening a file by typing its path in the path bar (the tab re-roots at/before the file opens).Why it matters
Every Windows desktop user of the Files app is hit. Each of these actions leaves the tab on a root the backend refuses. The panel's only in-tab recovery control is the same broken button, and "Reveal parent" also closes the tab's open files. The only workaround is typing the parent path by hand or opening a new folder tab.
Not a goal
parentChain,crumbLabel). Their own comment inutils.tsmarks that as a separate change, and they are unchanged here.C:\is correct.What changed (motivation → approach → change)
/.dirnameinwebsite/src/apps/file-explorer/utils.tssplit on/only. The backend prints host-separator paths (str(p)infile_explorer/server.py), soC:\work\repohas no/,lastIndexOf('/')is-1, anddirnamereturned/. The same folder already had a separator-awareparentDirindeepLink.ts, whose comment named this gap.dirnamenow delegates Windows-shaped paths (drive-rooted or backslash UNC, the existingbackslashIsSeparatortest fromutils/pathBasename.ts) toparentDir, so there is one separator-aware cut. At a drive root (C:\) or a UNC share root (\\host\share) there is no parent, sodirnamereturns the path itself andchangeRoot's same-path guard makes the click a no-op. POSIX paths keep the old/-only body, so their results are byte-identical, including names that contain\(/tmp/we\ird→/tmp). This fixes all three call sites (FileExplorerPage.tsxpath-bar open, "Go to parent folder", "Reveal parent") without touching them. ThedeepLink.tscomment that calleddirnamePOSIX-only is updated.parentDirunconditionally would treat\as a separator in POSIX names (/tmp/we\ird→/tmp/we), whichpathBasename.tsforbids. Switching only the three call sites toparentDirwould leave the trap indirnamefor the next caller.Intended? / Repro
Intended? No.
website/src/apps/file-explorer/deepLink.ts:50-54on main describesutils.dirnameas POSIX-only and explains that Windows gateways print backslash paths, which is whyparentDirexists. #17512 convertedbasenamein the same file and its author leftdirnameout of scope explicitly ("navigation, not a name-display site"). No RFC or doc asks for/as the parent of a Windows path, and/is refused by the backend's_safe_path.Repro (main @
cb13209a9e, no test suite run): a standalone script bundled the realutils.tsfrom main with esbuild and calleddirname:The same script on this branch:
The user-visible trigger is from the issue: on a Windows gateway, right-click a nested tree entry and choose "Reveal parent"; the tab re-roots at
/and shows "This folder is unavailable."Backwards compatibility
Compatible: POSIX paths go through the unchanged
/-only body, so every result on Linux and macOS gateways is byte-identical; only drive-rooted and backslash-UNC paths change, from/to their real parent (or the root itself).Removes nothing: the change only alters which parent
dirnamereturns for Windows-shaped paths; no path, key, function or record is hidden, removed or renamed.Tests
website/src/test/fileExplorer.test.tsx:dirnamereturns the Windows parent for drive-rooted paths (with\, trailing\, andC:/spellings), returnsC:\itself at a drive root, returns the UNC parent and stops at the share root, and keeps a backslash inside a POSIX name as part of the name.website/src/test/FileExplorerPageCoverage.test.tsx(new describe for a Windows gateway): "Reveal parent" re-roots toC:\Users\me\src, never/; "Go to parent folder" on an unavailableC:\Users\me\gonere-roots toC:\Users\me; openingC:\Users\me\notes.txtthrough the path bar with rootC:\Users\mekeeps the root (no extra tree fetch) and opens the file.dirname,parentChainand page tests are unchanged.Proof: not provable -- frontend test (prove.py runs Python only)
Not run locally (host rule: CI is the only test runner). Local static gates:
npm run typecheckclean,eslintclean on the four changed files,npm run jscpdfound 0 clones.Manual verification
N/A for a Windows click-through: no Windows gateway is available here. The pure-function repro above was run against main and this branch, and the three call sites are covered by the page tests listed under Tests.
Screenshots / video
Why no screenshot: no component, markup, style or string changes; the diff only changes which folder path
dirnamereturns for Windows-shaped paths, so nothing renders differently on the Linux capture harness, and the Windows navigation result is asserted by the page tests above.Related Issues
Fixes #27791
Sibling sweep
Swept: git grep -nE "dirname(|lastIndexOf('/')" -- website/src/apps/file-explorer/
Sibling: website/src/apps/file-explorer/FileExplorerPage.tsx:322 -- changed here -- path-bar open calls dirname, fixed by the helper change
Sibling: website/src/apps/file-explorer/FileExplorerPage.tsx:576 -- changed here -- Go to parent folder calls dirname, fixed by the helper change
Sibling: website/src/apps/file-explorer/FileExplorerPage.tsx:600 -- changed here -- Reveal parent calls dirname, fixed by the helper change
Sibling: website/src/apps/file-explorer/utils.ts -- not affected -- parentChain and crumbLabel are breadcrumb code that the file's own comment defers to a separate change
Sibling: website/src/components/FilePathMenu.tsx:348 -- not affected -- already uses the separator-aware parentDir
Pattern harvest
Rule candidate: review-prompt
Pattern: a frontend path helper that splits on '/' only, applied to a gateway path the backend prints with the host separator
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.