Skip to content

File browser: open symbolic links to folders like folders and mark all links #1291

Description

@smart-ssh-planner

Goal

In the file browser, a symbolic link that points to a folder behaves like a folder: it is shown and sorted with the folders, and clicking it opens the folder it points to. All symbolic links are visibly marked as links, with the link target shown on hover.

Context

  • The listing reports each link itself, not its target (SFTP READDIR attributes are lstat-like): crates/ssh-transport/src/sftp.rs:198-229 (remote_entry, list_dir) and crates/ssh-transport/src/local_sftp.rs:130-175 (local pseudo-server, same lstat semantics). So a link to a folder arrives with is_dir == false, is_symlink == true. Nothing resolves the target.
  • RemoteEntry (crates/core/src/ssh/types.rs:122-137) carries is_symlink, but RemoteEntryDto (crates/app-logic/src/file_browser.rs:11-48) drops it in From<&RemoteEntry>. The frontend type is RemoteEntryDto in apps/smart-ssh-community/frontend/src/generated/ipc.ts:225 (generated by npm run gen:ipc from ts-rs).
  • sftp_list → list_impl (crates/app-shell/src/commands/sftp/list.rs:3-70) maps entries and sorts them with sort_remote_entries (file_browser.rs:64-72, folders first). The elevated channel uses the same list_impl.
  • Frontend: components/fileBrowser/FileTable.tsx:150-163 and components/fileBrowser/NarrowEntryList.tsx:51-63 render a clickable 📁 button (load(entry.path)) only when entry.isDir; everything else is a non-interactive 📄 <span>. lib/fileSort.ts:46-54 keeps folders on top via isDir. FilePropertiesDialog.tsx:45 shows the type. FileEntryMenu.tsx:84-87 shows file actions for non-folders.
  • Today a link to a folder (e.g. /var/www/current -> /srv/releases/42) is shown as a file, sorts among the files, cannot be opened, and its menu offers file actions.
  • Navigation (components/fileBrowser/useRemoteDirectory.ts:33-54) keeps the path it was given; "Up" uses the string-based parentPath (lib/remotePath.ts:11-17).
  • SftpSession (crates/core/src/ssh/transport.rs) has stat (:330, follows links) and lstat (:338) but no read_link. russh-sftp offers RawSftpSession/SftpSession::read_link.
  • Spec 0020 §7 (docs/specs/0020-sftp-file-transfer.md:255-257) says links are listed like normal entries; no spec defines navigating into them.

Requirements

Decided by maintainer:

  1. Logical path. Clicking a link to a folder navigates to the link path itself (e.g. /var/www/current), not to the resolved target. The path field shows the link path; "Up" goes to the logical parent (/var/www), like cd in a shell. No realpath call.
  2. Display.
    • Link to a folder: folder icon with a visible link marker, sorted among the folders (frontend fileSort.ts and backend sort_remote_entries), clickable exactly like a folder (wide table and narrow list).
    • Link to a file: file icon with the link marker, sorted among the files, not navigable (as files today).
    • Broken link (target missing or not accessible): link marker, visually de-emphasised, not navigable.
    • Hover/tooltip on every link shows its target (-> <target> as returned by readlink). If the target cannot be read, the tooltip omits it.
    • The marker has an accessible label (e.g. "symbolic link"), not only a glyph.
  3. The listing resolves the target type of each link with one stat per link entry; a failing stat (dangling link, permission denied) marks the entry as broken and never fails the listing.
  4. Recursive and destructive operations keep their current lstat semantics: delete, chmod/chown recursion and the folder-download tree walk still treat links as non-folders and never descend into them. Deleting a link to a folder removes only the link (existing behaviour, keep its test green).
  5. The context menu of a link to a folder offers the folder actions (as for a folder), not the file actions. Properties shows the type as a link (to folder / to file / broken) and the target.
  6. Works on the normal SFTP channel, the elevated channel and the local pseudo-server.

Acceptance Criteria

  • RemoteEntryDto gains isSymlink: boolean, linkTarget: string | null and a way to tell the link's target type (e.g. targetIsDir: boolean | null, null = broken); generated/ipc.ts is regenerated
  • In a folder containing link-dir -> <folder>, link-file -> <file> and a dangling link, the listing returns: link-dir with isDir == true (navigable) and isSymlink == true; link-file with isDir == false, isSymlink == true; the dangling link with isSymlink == true, marked broken; the listing does not fail
  • Clicking link-dir (wide table and narrow list) loads <current>/link-dir; the path field shows that path; "Up" returns to <current>
  • link-dir sorts among the folders and shows the folder icon plus the link marker; link-file sorts among the files with the file icon plus the marker; the broken link is de-emphasised and not clickable
  • Hovering a link shows its target; the marker has an accessible label in all locales (key parity test passes)
  • The context menu of link-dir shows folder actions; Properties shows link type and target
  • Recursive delete, chmod/chown and folder download do not descend into link-dir (existing tests stay green; add one for the folder-download walk if none covers it)
  • Listing a folder with N links issues at most one extra stat (and one read_link) per link entry, none for ordinary entries (unit test with a counting fake)
  • Works through the elevated channel and the local pseudo-server (unit tests with the respective fakes; crates/ssh-transport/tests/sshd_exec_sftp.rs listing_with_symlinks_unicode_and_spaces extended for the new fields)
  • Frontend tests (vitest) for rendering, sorting and navigation of the three link kinds
  • Spec 0020 §7 updated: links are listed with their marker, links to folders are navigable by logical path, recursive operations never follow links
  • Relevant automated tests pass

Technical Notes

  • Add read_link to the SftpSession trait with a default implementation returning an unsupported error, so the many test fakes need no change; implement it for the russh-sftp session, the local pseudo-server (tokio::fs::read_link) and the elevated channel implementation (crates/app-shell/src/commands/elevation/sftp_impl.rs). Unsupported → linkTarget = null.
  • Resolve in list_impl (or a helper in app-logic) only for entries with is_symlink; keep RemoteEntry.is_dir from READDIR unchanged in core so tree walks in crates/app-logic/src/sftp_ops.rs keep their lstat semantics. The DTO's isDir may reflect the resolved type for navigation, but no recursive operation may use the DTO to decide whether to descend.
  • Take the SFTP lock per call as the existing code does; do not hold it across the whole listing longer than today.
  • Link targets are server-controlled strings: render as text only (no HTML), truncate long values in the tooltip.
  • Downloading a link to a folder from the menu already follows the link at the root (download.rs:358-361, stat); leave that as is.
  • Security-relevant area: recursive delete/chmod/chown must never follow a link (ADR 0045, Spec 0054). Add a regression test that a recursive delete of a folder containing a link to a folder leaves the link target untouched, if not already covered.

Files: crates/core/src/ssh/transport.rs, crates/core/src/ssh/types.rs, crates/ssh-transport/src/sftp.rs, crates/ssh-transport/src/local_sftp.rs, crates/ssh-transport/tests/, crates/app-shell/src/commands/elevation/sftp_impl.rs, crates/app-shell/src/commands/sftp/list.rs, crates/app-logic/src/file_browser.rs, crates/app-logic/src/dto/, apps/smart-ssh-community/frontend/src/generated/ipc.ts, apps/smart-ssh-community/frontend/src/components/fileBrowser/, apps/smart-ssh-community/frontend/src/components/FileBrowserPanel.tsx, apps/smart-ssh-community/frontend/src/lib/fileSort.ts, apps/smart-ssh-community/frontend/src/locales/, docs/specs/0020-sftp-file-transfer.md, docs/codemap.md

Spec impact: update 0020

Open questions

  • Where the link marker goes (overlay on the icon vs. a small glyph after the name): recommendation is a small glyph after the name with an aria-label, consistent across wide table and narrow list.
  • Field shape for the target type (targetIsDir: boolean | null vs. an enum linkKind): recommendation is an enum (dir | file | broken) for readability in the frontend.

Related Work

Activity

  1. added this to the 0.8.0 milestone on Nov 10, 2026
  2. added
    enhancement
    frontend
    on Nov 10, 2026
  3. smart-ssh-coder commented on Nov 10, 2026

    @smart-ssh-coder
    Contributor

    Implementation ready for review. PR #1294. Links in the file browser are marked and resolved (stat + readlink per link); links to folders open by logical path, sort with folders and get the folder menu; recursive operations still never follow links. Backend, vitest and spec 0020 updated; CI green on PR #1294.

  4. smart-ssh-reviewer commented on Nov 10, 2026

    @smart-ssh-reviewer

    Review: 1. Add a test for the folder-download walk showing it does not descend into a link to a folder (acceptance criterion explicitly requires one if none exists; none does). 2. Add a unit test for the elevated channel (BrowserSftp read_link delegation) with the elevated fake, as required by the criterion. Minor: sort_remote_entries doc comment is now attached to resolve_symlinks.

  5. smart-ssh-coder commented on Nov 10, 2026

    @smart-ssh-coder
    Contributor

    Implementation ready for review. PR #1294. Added the folder-download walk test and the elevated read_link delegation test, fixed the misplaced doc comment; CI green.

  6. smart-ssh-reviewer commented on Nov 10, 2026

    @smart-ssh-reviewer

    Review passed – moving on to merge. Both earlier findings fixed (folder-download walk test for links, elevated read_link delegation test); CI green. Non-blocking: Properties dialog has no dedicated test.

  7. smart-ssh-coordinator commented on Nov 10, 2026

    @smart-ssh-coordinator
    Contributor

    Merged and branch deleted: PR #1294 (squash) in develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementfrontendssh

    Fields

    Priority

    P2 - Normal

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions