fix(projects): treat symlinked directories as directories in Add Project browsers
Summary
Fixes #8983.
In the Add Project / Add Remote Project folder browsers, a symbolic link pointing to a directory was listed as a file — no folder icon, not navigable — so any project living behind a symlinked path could not be reached or selected.
Two classification sites had the same bug:
browseServerDir(src/main/runtime/orca-runtime.ts) usedDirent.isDirectory(), which does not follow symlinks. Symlink entries are now classified by their target type viastat, mirroring the existing (and test-locked) behavior of the relayfs.readDirhandler insrc/relay/fs-handler.ts.ssh:browseDirPOSIX branch (src/main/ipc/ssh-browse.ts) derived the directory marker fromls -p, which does not dereference links. The listing now appends the/marker via[ -d ](which follows symlinks) in a plain POSIXshloop. Thelsoutput is captured into a variable first so a failingls(e.g. permission denied) still propagates through the&&chain as a non-zero exit code instead of being masked by the while-loop pipeline — preserving the existing error semantics.
Deliberately unchanged: the local file-explorer fs:readDir and runtime file listing intentionally treat symlinks as file-like to avoid macOS TCC prompts (documented and test-locked); the Windows remote fallback already classifies symlinked directories correctly via PSIsContainer.
Screenshots
Remote filesystem browser (Add Remote Project) on a real Linux SSH host, running this branch. linked-dir is a symlink to real-dir; it now renders as a navigable directory, sorts with directories, and can be descended into and selected as a project (breadcrumb reached /tmp/orca-symlink-verify/linked-dir):
Before this change the same entry rendered with a file icon and could not be entered.
Testing
- [x]
pnpm lint - [x]
pnpm typecheck - [x]
pnpm test - [x]
pnpm build - [x] Added or updated high-quality tests that would catch regressions, or explained why tests were not needed
New regression tests (both watched failing before the fix):
orca-runtime.test.ts:browseServerDirover a real temp directory containing a symlinked directory, a symlinked file, and a broken symlink — asserts symlink-to-dir classifies as a directory, symlink-to-file and broken links stay file-like, and sort order holds. Usesjunctionon Windows, matching the existing relay symlink test.ssh-browse.test.ts: locks the new POSIX listing command and asserts symlinked-directory entries parse as directories; existing command-string assertions updated via a shared helper.
Manual verification: drove the built dev app end-to-end against a real Linux SSH host — browsed into the symlinked directory and confirmed it is selectable as a project. The new shell snippet was additionally exercised directly in sh against fixtures with spaces in names, an empty directory, a broken symlink, and a permission-denied directory (still exits non-zero).
AI Review Report
Review by Claude (Fable 5), which also authored the change. Checks performed:
- Cross-platform (macOS/Linux/Windows): the
browseServerDirchange is purenode:fsand platform-neutral; Node reports Windows junctions as symlinks, and the new test usesjunctionon win32. The SSH change touches only the POSIX branch; the Windows PowerShell fallback (PSIsContainer, already symlink-correct) is untouched. No shortcuts, labels, or path-separator handling involved. - SSH/remote/local: the remote listing keeps a single exec round-trip (no per-entry SSH calls) and preserves exit-code error semantics for permission-denied/unreadable directories (verified in a real shell). Verified live over SSH against a Linux host. The relay/daemon
fs.readDirpath already handled symlinks and is unchanged. - Shell portability: the new snippet uses only POSIX
shconstructs (command ls -1A,[ -d ],printf,while IFS= read -r) — no bashisms, nofind -maxdepth, nopipefail— so dash/busybox login shells are fine. Filenames with spaces are preserved; filenames containing newlines remain a pre-existing limitation of the line-based protocol, unchanged by this PR. - Performance: extra
statcalls are issued only for symlink entries and run concurrently; non-symlink entries take the previous fast path. Remote listing adds one subshell and a builtin test per entry inside the existing single exec. - Behavioral risk: broken symlinks classify as files (matching relay behavior); the browse target itself was already
stat-validated, so selecting a symlinked folder keeps working as before.
Security Audit
- The remote command keeps the existing
shellEscapefor the only user-controlled input (the directory path); the added shell text is a static string with no interpolation, and"$f"values come fromlsoutput inside the already-escaped target directory — no new injection surface. - No new IPC endpoints, no auth/secrets/dependency changes. Local symlink following is confined to classifying entries of a directory the user explicitly browsed; the relay ACL model is untouched (the raw-exec browse path exists precisely because browsing happens before workspace roots are registered, unchanged).
Notes
- POSIX remote hosts get the fix via the new listing command; Windows remote hosts were already correct.
- The local file explorer's intentional "symlinks are file-like" TCC-avoidance behavior is out of scope and unchanged.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 2026b9af-7123-44f2-996b-ac1ed31c6878
📥 Commits
Reviewing files that changed from the base of the PR and between 58a5c33a9e09624584c25f11834d17fabae1348d and 81d99a39384d4f36c24b727e256fd2a0fbf5c046.
📒 Files selected for processing (4)
src/main/ipc/ssh-browse.test.tssrc/main/ipc/ssh-browse.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/main/runtime/orca-runtime.ts
- src/main/runtime/orca-runtime.test.ts
- src/main/ipc/ssh-browse.ts
- src/main/ipc/ssh-browse.test.ts
📝 Walkthrough
Walkthrough
Remote POSIX browsing now captures ls output and appends directory markers using per-entry directory checks, including symlinked directories, while preserving command failure status. Tests centralize expected command construction and cover symlinked directory listings. Local server browsing now resolves symlink targets asynchronously to set isDirectory, retains isSymlink, and tests real, symlinked, and broken entries.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly matches the main change: fixing symlinked directories in Add Project browsers. |
| Description check | ✅ Passed | The description matches the required template and includes summary, screenshots, testing, review, security, and notes. |
| Linked Issues check | ✅ Passed | The changes satisfy #8983 by classifying symlinked directories correctly in both browse paths and preserving Windows and local file-explorer behavior. |
| Out of Scope Changes check | ✅ Passed | The PR stays focused on symlink browsing fixes and regression tests, with no clear unrelated code changes. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
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 @coderabbitai help to get the list of available commands.
Follow-up #8998 (stacked on this) adds a visual symlink indicator in the same browsers, so a linked directory is distinguishable from a real one — the natural next step now that they behave identically. It also extends ssh:browseDir to carry symlink state.
Taking a look!
Thank you @choihjin. Your approach (follow symlinks with stat on the server listing, and [ -d ] instead of ls -p on the SSH listing) is carried forward in #29658, ported onto the modules this code has since moved to, with you credited as co-author. Closing this one in favour of that PR.