fix(file-explorer): open symlink files when stat fails - #11670
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughFile explorer handlers now receive an external-path authorization callback. Local symlink activation authorizes the target before stat resolution. Remote-owned symlinks skip local authorization. Authorization and stat failures open the target as a preview file. Tests cover these cases and update handler setup dependencies. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryWhen
Confidence Score: 5/5Safe to merge — the fix is a one-line change in a single branch of the symlink-activation flow, the rest of the logic is untouched, and the new test directly covers the corrected path. The change is minimal and well-scoped: only the catch block inside the isSymlink branch is modified. The symlink-to-directory path (stat succeeds with isDirectory: true) is unchanged. The fallthrough to the shared openFile call already existed and is exercised by other tests. The new test provides direct regression coverage of the failure case, and the implementation matches what the test asserts. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/src/components/right-sidebar/useFileExplorerHandlers.ts | Removes the early-return toast error on statPath failure for symlinks; instead defaults targetIsDirectory to false and falls through to open the node as a file. The rest of the symlink/directory/file logic is untouched. |
| src/renderer/src/components/right-sidebar/useFileExplorerHandlers.test.ts | Adds a regression test covering the stat-failure path: verifies that openFile is called with the correct params when statPath rejects, mirroring the existing non-directory symlink test. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[activateFileExplorerNode] --> B{activeWorktreeId?}
B -->|null| Z[return]
B -->|set| C[setSelectedPath]
C --> D{node.isDirectory?}
D -->|yes| E{canToggleDirectories?}
E -->|no| Z
E -->|yes| F[toggleDir]
D -->|no| G{node.isSymlink?}
G -->|no| M[requireMatchingRoute]
G -->|yes| H[statPath node.path]
H -->|success| I{isDirectory?}
H -->|error - BEFORE: toast + return / AFTER: targetIsDirectory = false| I
I -->|true| J[loadDir with force+failOnError]
J -->|loaded| K[markPathAsDirectory + toggleDir]
J -->|failed| L[toast.error Cannot open symlink target]
I -->|false| M
M -->|route found| N[openFile as edit preview]
M -->|route error| O[toast.error owner unresolved]
Reviews (1): Last reviewed commit: "fix(file-explorer): open symlink files w..." | Re-trigger Greptile
Following a symlink out of the workspace was denied by the main-process path allow-list, so both the stat and the file read failed. Activating the row is explicit intent, so authorize the target the way terminal links and Quick Open already do.
|
Thanks for chasing this down — the diagnosis is right. I've pushed a follow-up commit to your branch (heads up so it isn't a surprise). Testing it in the app turned up a second half to the bug. The reason What the follow-up adds:
Worth knowing: #11681 and #4556 are also open against #11654 and take a different route — relaxing the allow-list itself rather than granting per activation. A maintainer will decide which approach lands. Checked on macOS against a symlink to a file outside the repo, a symlink to a directory outside the repo, a symlink inside the repo, and a broken symlink (that one now shows a plain "file not found" in the tab). |
Summary
Fixes #11654.
Tests