Skip to content

fix(file-explorer): find the Windows parent folder instead of / - #27995

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
crew/bug-resolve/fix-27791
Nov 2, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
crew/bug-resolve/fix-27791

Conversation

@CrysisDeu

Copy link
Copy Markdown
Contributor

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 / to C:\ 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

  • Breadcrumb navigation for Windows roots (parentChain, crumbLabel). Their own comment in utils.ts marks that as a separate change, and they are unchanged here.
  • Any backend change. The backend's refusal of C:\ is correct.

What changed (motivation → approach → change)

  • Symptom: the three controls above re-root a Windows tab at /.
  • Root cause: dirname in website/src/apps/file-explorer/utils.ts split on / only. The backend prints host-separator paths (str(p) in file_explorer/server.py), so C:\work\repo has no /, lastIndexOf('/') is -1, and dirname returned /. The same folder already had a separator-aware parentDir in deepLink.ts, whose comment named this gap.
  • Change: dirname now delegates Windows-shaped paths (drive-rooted or backslash UNC, the existing backslashIsSeparator test from utils/pathBasename.ts) to parentDir, so there is one separator-aware cut. At a drive root (C:\) or a UNC share root (\\host\share) there is no parent, so dirname returns the path itself and changeRoot'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.tsx path-bar open, "Go to parent folder", "Reveal parent") without touching them. The deepLink.ts comment that called dirname POSIX-only is updated.
  • Alternatives considered: calling parentDir unconditionally would treat \ as a separator in POSIX names (/tmp/we\ird → /tmp/we), which pathBasename.ts forbids. Switching only the three call sites to parentDir would leave the trap in dirname for the next caller.

Intended? / Repro

Intended? No. website/src/apps/file-explorer/deepLink.ts:50-54 on main describes utils.dirname as POSIX-only and explains that Windows gateways print backslash paths, which is why parentDir exists. #17512 converted basename in the same file and its author left dirname out 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 real utils.ts from main with esbuild and called dirname:

main dirname("C:\\Users\\u\\repo") -> "/"
main dirname("C:\\Users\\u\\repo\\src\\a.ts") -> "/"
main dirname("C:\\") -> "/"
main dirname("\\\\host\\share\\dir") -> "/"
main dirname("/home/u/repo") -> "/home/u"
main dirname("/tmp/we\\ird") -> "/tmp"

The same script on this branch:

fix dirname("C:\\Users\\u\\repo") -> "C:\\Users\\u"
fix dirname("C:\\Users\\u\\repo\\src\\a.ts") -> "C:\\Users\\u\\repo\\src"
fix dirname("C:\\") -> "C:\\"
fix dirname("\\\\host\\share\\dir") -> "\\\\host\\share"
fix dirname("\\\\host\\share") -> "\\\\host\\share"
fix dirname("/home/u/repo") -> "/home/u"
fix dirname("/file.txt") -> "/"
fix dirname("/tmp/we\\ird") -> "/tmp"

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 dirname returns for Windows-shaped paths; no path, key, function or record is hidden, removed or renamed.

Tests

  • website/src/test/fileExplorer.test.tsx: dirname returns the Windows parent for drive-rooted paths (with \, trailing \, and C:/ spellings), returns C:\ 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 to C:\Users\me\src, never /; "Go to parent folder" on an unavailable C:\Users\me\gone re-roots to C:\Users\me; opening C:\Users\me\notes.txt through the path bar with root C:\Users\me keeps the root (no extra tree fetch) and opens the file.
  • Existing POSIX dirname, parentChain and 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 typecheck clean, eslint clean on the four changed files, npm run jscpd found 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 dirname returns 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

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
@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners November 2, 2026 09:14
@CrysisDeu
CrysisDeu requested a review from buluoray November 2, 2026 09:14
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 528e755fd25384b20c87d9b81474316efbc3b216 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 528e755fd25384b20c87d9b81474316efbc3b216 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The fix is in the one shared helper, and paths that are not Windows-shaped keep the old /-only result.

Notes

  • "Manual verification: N/A" does not trigger the platform BLOCK. The new branch depends on the shape of the path string, not on the host OS, and the CI frontend tests run it with Windows-shaped inputs.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 528e755fd25384b20c87d9b81474316efbc3b216 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

The fix works at the cause, inside dirname. One loose end: the UNC share-root rule lives only in dirname, so the other callers of parentDir still climb past the share root.

Notes

  • Item 4 — symptom-level: UNC_SHARE_ROOT_RE (utils.ts:19) keeps \\host\share from climbing, but only inside dirname. parentDir still returns \\host for \\host\share. I grepped parentDir( outside tests and found 3 other callers that skip this guard: deepLink.ts:83 (revealChain), FileExplorerPage.tsx:360 and FilePathMenu.tsx:348. Subtraction: delete UNC_SHARE_ROOT_RE from utils.ts and let parentDir return null at a share root, so all four callers share one rule and dirname's ?? p handles the rest.

What this change ships

Inventory (5 items) — 4 justified

Intent: on a Windows gateway, a Files user moving to a parent folder ends up in the real parent folder, not in / (which the backend refuses). FIX.

  1. "Go to parent folder" on the unavailable-folder panel now opens the Windows parent, not / — justified
  2. The tree's "Reveal parent" now opens the Windows parent, not / — justified
  3. Opening a file by typing its Windows path keeps the current root instead of re-rooting at / — justified
  4. At a drive root or UNC share root, going to the parent does nothing — symptom-level; the UNC guard lives only in dirname, not in parentDir
  5. The deepLink.ts comment no longer calls dirname POSIX-only — justified

[FIRST-PRINCIPLES-REVIEWED] 528e755

Description read

[DESCRIPTION-READ] 6a381a5df59fafc6a251f5e7bf8875df1578b2c9368513ddae43767e3f2a5cd4

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 528e755fd25384b20c87d9b81474316efbc3b216 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 528e755

Verdict parsed from the review's SHA-scoped output markers for commit 528e755fd25384b20c87d9b81474316efbc3b216.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 528e755fd25384b20c87d9b81474316efbc3b216 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 528e755fd25384b20c87d9b81474316efbc3b216 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 528e755

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 528e755fd25384b20c87d9b81474316efbc3b216 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 2, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 2, 2026 11:10

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 /.

@KiroCrewCaptain
KiroCrewCaptain merged commit c156fd7 into main Nov 2, 2026
95 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the crew/bug-resolve/fix-27791 branch November 2, 2026 11:20
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File Explorer: Go to parent folder, Reveal parent and open-by-path re-root to / on a Windows gateway, because utils.dirname splits on / only

2 participants