Repository navigation
Add SMB network location support (browse, mount, authenticate) - #31
Conversation
…n bar navigate_input previously only recognized the literal "trash:///" as a URI and treated everything else as a native path, so typing any other scheme (smb://, sftp://, network:///) was rejected as "not an absolute path" before it ever reached the file source. This generalizes URI detection to any well-formed scheme, and additionally normalizes Windows-style UNC/SMB shorthand (\\host\share, smb:\\host\share) into a proper smb:// URI, matching how users are used to typing network paths.
Typing or opening an smb:// (or other GVfs) location that isn't mounted yet used to surface a raw "location is not mounted" error with no way to proceed. LocationValidationError::NotMounted now carries the location so the UI can respond to it specifically: both the location-bar entry and column drill-down trigger gio::File::mount_enclosing_volume via a GTK MountOperation (which handles any credential prompt natively) and retry the original navigation on success. Also accept a bare "//host/share" network shorthand alongside the existing "\\host\share" UNC form, without touching ordinary single-slash absolute paths.
GVfs reports an unmounted browsable child (an smb:// host's individual shares, a "Connect to Server" bookmark, ...) as FileType::Mountable rather than Directory, and querying that location's own info succeeds with that type instead of raising NOT_MOUNTED. Two things followed from that: - Entries of that type were previously classified as EntryKind::Other, so activating one asked the desktop to open it in a new application instead of descending into it - which, since Strata is the default file manager, spawned a second Strata window per click. - Mounting such a location needs gio::File::mount_mountable, not mount_enclosing_volume (which is for a file that merely sits on an unmounted volume). LocationValidationError gains a distinct Mountable(Location) case so the UI can pick the right GIO call.
lgse#20 explicitly scopes remote locations to proper URIs (smb://, sftp://, ftp://, dav://, ...) and calls out \\host\share and user@host:path as unsupported shorthand needing a clear message rather than silent reinterpretation. Drop the smb:// rewriting we added earlier and report LocationValidationError::UnsupportedShorthand for those forms instead, while leaving well-formed URIs untouched.
…ckends Address three gaps identified against lgse#20's acceptance criteria before proposing this as SMB support: - Cancelling the GTK credential prompt (or a backend that already reported the failure itself) now returns quietly to the prior state instead of surfacing an alarming "Unable to connect" message. - A URI typed with an embedded password (smb://user:pass@host/share) is rejected outright with a safe explanation; a bare username (smb://user@host/share) is still accepted and prompts normally. - A missing GVfs backend (NOT_SUPPORTED) now names the scheme and, for SMB, the gvfs-smb package to install, instead of a raw GIO error. Also stopped logging the full URI (host/share/path) for remote locations, logging only the scheme. Manually verified all three against a live credential prompt.
Points at network:/// so the existing GIO-generic FileSource pipeline (already used for Trash and mounted volumes) browses locally discovered network hosts, mirroring Windows Explorer's Network folder. Discovery itself is handled entirely by gvfsd-network; this only wires up the sidebar entry and a bundled Lucide "network" icon.
A mounted GVfs backend (SMB, ...) can still return a `.path()` via its FUSE mirror even though the file isn't native, so the existing `.path().map(Location::local).unwrap_or_else(uri)` pattern picked the opaque `/run/user/$UID/gvfs/...` mirror over the clean URI everywhere a Location was derived from a gio::File: the DEVICES sidebar list, volume rows, click-to-navigate, and every child entry produced while enumerating a remote directory. Gate on `gio::File::is_native()` instead, in a single shared `location_for_file` helper (now `pub(crate)` from adapters) reused by the sidebar code that previously duplicated the same broken pattern. Closes lgse#5 and the matching lgse#20 acceptance criterion ("no /run/user/$UID/gvfs/... path exposed"). Manually verified: browsing Network -> a real SMB share -> a subfolder no longer fails with "That location does not exist".
update_basename_validation runs on every text change, including the programmatic clears that happen when a New Folder/File prompt opens, cancels, or succeeds after creating. Since validate_basename treats an empty name as invalid, any of those routine clears could leave the field styled red before the user typed anything wrong (or anything at all) — found while creating a folder on a mounted SMB share, but the bug is unrelated to location and reproduces for local folders too. Treat an empty field as the normal, unstyled starting state instead: submission is still blocked (the function still returns false), only the alarming red border for a field nobody has touched yet is gone.
Every directory batch delivered to a column that already has a selection re-fires SelectionSetChanged, and both that handler and FocusChanged unconditionally called column.list.grab_focus(). Slow network directories stream many batches over several seconds, so opening New Folder/File or a rename and starting to type would get its keyboard focus ripped back to the file list mid-batch, making the field look unresponsive (a blinking cursor stays visible for a moment due to redraw lag, but keystrokes go to the list's own type-ahead search instead). Local directories return everything in one fast batch, so the race window never showed up there. Skip the scroll-to-focus and grab_focus calls while a rename or new entry prompt is active for the view.
FileSource::watch only supports native paths, so a remote directory has no live monitor and its column never learns about a newly created item on its own. The operation itself succeeds (confirmed against a real SMB share, and visible in Nautilus), but the new folder stayed invisible in Strata until navigating away and back. operation_callback now takes the operation's parent/destination location and, when it lacks a native path, explicitly refreshes every open column at that location after a Created or Pasted event. Local directories already have a working watcher, so they're left alone to avoid a redundant reload.
Fallout from rebasing onto v0.4.0, which merged lgse#4 and renamed the shared new-folder state to the generalized new-entry state used by both New Folder and New File: - The focus-steal fix now checks active_new_entry instead of the since-renamed active_new_folder. - create_file() gets the same explicit refresh-after-create treatment as create_directory() for locations with no live monitor. - update_basename_validation's empty-field logic is now a separate pure basename_field_error() helper, so it can be unit tested without a real GTK widget. The previous version called gtk::init() directly, which works locally but fails on GitHub's headless CI runners (confirmed failing on PR lgse#30 for the same reason).
Moving an item to Trash on a backend without trash support (most remote filesystems, including SMB) fails with NOT_SUPPORTED, which previously surfaced as a raw GIO error. Detect that specific case and suggest permanent deletion instead. Per lgse#20's own guidance, pre-emptively hiding the Trash option based on a capability query is a bigger, separate piece of work (its own delivery slice); this only improves what happens when the attempt is already made.
|
Here's a short recording of the end-to-end flow: typing an smb:// URI, browsing the discovered shares, and the native credential prompt mounting successfully. screenrecording-2026-08-30_22-54-37.mp4 |
|
Dude that's really cool. I think the 2 main things I want to address:
I can take it from here tho. Solid @mrocha-montes thank you for the foundational work! |
|
@spuder, I don't think that's a big ask. I can create a follow up ticket for it right now as this PR is already getting large! |
|
Addressed the follow-up review findings in
Also expanded coverage for unsupported schemes, async mount rejection events, remote URI parents/breadcrumbs, and remote rename refreshes. The network auto-discovery requirement and acceptance criterion were also added to #20, linked back to the request in this PR. |
Without a limit, a mount that keeps failing before the credential prompt is ever answered (observed live against a real SMB share, where the operation resolved in well under 250ms with no button click or reply) retried forever, tearing down and rebuilding the authentication dialog on every failure and making it impossible to type into. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FM7CdkaaMoyPTGxaSFaF2M
|
Found a real bug testing this live against an SMB server on my LAN (192.168.1.220): opening a share that rejects the connection ( Root cause, confirmed with timing logs: the mount operation resolves (with an error) well under 250ms after Pushed (Was just curious to peek at how the review was going and couldn't resist poking at it. Back to my actual day job now for real this time!) |
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FM7CdkaaMoyPTGxaSFaF2M
|
Followed up in The retry exists so that, after the user submits incorrect credentials and the GIO mount operation completes, Strata can start a fresh backend mount operation and let the backend request corrected credentials using its real Strata now records whether Connect was clicked for each mount operation and retries only when:
If the backend fails before the user replies, Strata now reports the failure instead of tearing down and recreating the prompt. @mrocha-montes, could you please retest this against the SMB server that reproduced the sub-250ms failure? In particular, please confirm that the prompt no longer flickers/reopens when the backend fails before any click, and that submitting genuinely incorrect credentials still opens a fresh retry prompt. |
|
The local SMB fixture reproduced the remaining UX problem: the backend can return Fixed in
There is no timer-driven or failure-driven retry loop now; every subsequent mount attempt requires a user click. @mrocha-montes, could you retest both the original early-completion server and an incorrect-then-correct credential attempt with this revision? |
|
Confirmed locally against a loopback Samba fixture that reproduces the fast The final fix is in
This keeps credential correction possible without any automatic retry loop. I verified both the early-failure prompt and a successful login locally; @mrocha-montes, a retest against the original SMB server would still be appreciated to confirm its backend behaves the same way. |
|
Retested against the same SMB server (192.168.1.220) that reproduced the original sub-250ms failure. Both scenarios confirmed working as expected:
Nice fix, thanks for tracking it down. |
|
I have a small changeset to add pin support to smb network filesystem at https://github.com/SjB/strata/tree/smb-pin-support mostly generated by Luna. |
|
@SjB let's raise a separate PR for it so I fully understand the context of your changes |
* Accept typed URI locations and Windows-style SMB paths in the location bar navigate_input previously only recognized the literal "trash:///" as a URI and treated everything else as a native path, so typing any other scheme (smb://, sftp://, network:///) was rejected as "not an absolute path" before it ever reached the file source. This generalizes URI detection to any well-formed scheme, and additionally normalizes Windows-style UNC/SMB shorthand (\\host\share, smb:\\host\share) into a proper smb:// URI, matching how users are used to typing network paths. * Auto-mount unmounted network locations before failing navigation Typing or opening an smb:// (or other GVfs) location that isn't mounted yet used to surface a raw "location is not mounted" error with no way to proceed. LocationValidationError::NotMounted now carries the location so the UI can respond to it specifically: both the location-bar entry and column drill-down trigger gio::File::mount_enclosing_volume via a GTK MountOperation (which handles any credential prompt natively) and retry the original navigation on success. Also accept a bare "//host/share" network shorthand alongside the existing "\\host\share" UNC form, without touching ordinary single-slash absolute paths. * Recognize GVfs Mountable entries and mount them with the right GIO call GVfs reports an unmounted browsable child (an smb:// host's individual shares, a "Connect to Server" bookmark, ...) as FileType::Mountable rather than Directory, and querying that location's own info succeeds with that type instead of raising NOT_MOUNTED. Two things followed from that: - Entries of that type were previously classified as EntryKind::Other, so activating one asked the desktop to open it in a new application instead of descending into it - which, since Strata is the default file manager, spawned a second Strata window per click. - Mounting such a location needs gio::File::mount_mountable, not mount_enclosing_volume (which is for a file that merely sits on an unmounted volume). LocationValidationError gains a distinct Mountable(Location) case so the UI can pick the right GIO call. * Reject UNC and SCP shorthand instead of guessing an smb:// URI lgse#20 explicitly scopes remote locations to proper URIs (smb://, sftp://, ftp://, dav://, ...) and calls out \\host\share and user@host:path as unsupported shorthand needing a clear message rather than silent reinterpretation. Drop the smb:// rewriting we added earlier and report LocationValidationError::UnsupportedShorthand for those forms instead, while leaving well-formed URIs untouched. * Close lgse#20 gaps: cancel handling, embedded credentials, missing backends Address three gaps identified against lgse#20's acceptance criteria before proposing this as SMB support: - Cancelling the GTK credential prompt (or a backend that already reported the failure itself) now returns quietly to the prior state instead of surfacing an alarming "Unable to connect" message. - A URI typed with an embedded password (smb://user:pass@host/share) is rejected outright with a safe explanation; a bare username (smb://user@host/share) is still accepted and prompts normally. - A missing GVfs backend (NOT_SUPPORTED) now names the scheme and, for SMB, the gvfs-smb package to install, instead of a raw GIO error. Also stopped logging the full URI (host/share/path) for remote locations, logging only the scheme. Manually verified all three against a live credential prompt. * Add a Network sidebar entry backed by GVfs network discovery Points at network:/// so the existing GIO-generic FileSource pipeline (already used for Trash and mounted volumes) browses locally discovered network hosts, mirroring Windows Explorer's Network folder. Discovery itself is handled entirely by gvfsd-network; this only wires up the sidebar entry and a bundled Lucide "network" icon. * Keep GVfs mounts URI-native instead of leaking their FUSE path A mounted GVfs backend (SMB, ...) can still return a `.path()` via its FUSE mirror even though the file isn't native, so the existing `.path().map(Location::local).unwrap_or_else(uri)` pattern picked the opaque `/run/user/$UID/gvfs/...` mirror over the clean URI everywhere a Location was derived from a gio::File: the DEVICES sidebar list, volume rows, click-to-navigate, and every child entry produced while enumerating a remote directory. Gate on `gio::File::is_native()` instead, in a single shared `location_for_file` helper (now `pub(crate)` from adapters) reused by the sidebar code that previously duplicated the same broken pattern. Closes lgse#5 and the matching lgse#20 acceptance criterion ("no /run/user/$UID/gvfs/... path exposed"). Manually verified: browsing Network -> a real SMB share -> a subfolder no longer fails with "That location does not exist". * Don't flag an empty name field as an error update_basename_validation runs on every text change, including the programmatic clears that happen when a New Folder/File prompt opens, cancels, or succeeds after creating. Since validate_basename treats an empty name as invalid, any of those routine clears could leave the field styled red before the user typed anything wrong (or anything at all) — found while creating a folder on a mounted SMB share, but the bug is unrelated to location and reproduces for local folders too. Treat an empty field as the normal, unstyled starting state instead: submission is still blocked (the function still returns false), only the alarming red border for a field nobody has touched yet is gone. * Don't let background selection refreshes steal focus from an inline edit Every directory batch delivered to a column that already has a selection re-fires SelectionSetChanged, and both that handler and FocusChanged unconditionally called column.list.grab_focus(). Slow network directories stream many batches over several seconds, so opening New Folder/File or a rename and starting to type would get its keyboard focus ripped back to the file list mid-batch, making the field look unresponsive (a blinking cursor stays visible for a moment due to redraw lag, but keystrokes go to the list's own type-ahead search instead). Local directories return everything in one fast batch, so the race window never showed up there. Skip the scroll-to-focus and grab_focus calls while a rename or new entry prompt is active for the view. * Refresh the open column after creating on a location with no monitor FileSource::watch only supports native paths, so a remote directory has no live monitor and its column never learns about a newly created item on its own. The operation itself succeeds (confirmed against a real SMB share, and visible in Nautilus), but the new folder stayed invisible in Strata until navigating away and back. operation_callback now takes the operation's parent/destination location and, when it lacks a native path, explicitly refreshes every open column at that location after a Created or Pasted event. Local directories already have a working watcher, so they're left alone to avoid a redundant reload. * Adapt to v0.4.0's generalized New File/Folder prompt Fallout from rebasing onto v0.4.0, which merged lgse#4 and renamed the shared new-folder state to the generalized new-entry state used by both New Folder and New File: - The focus-steal fix now checks active_new_entry instead of the since-renamed active_new_folder. - create_file() gets the same explicit refresh-after-create treatment as create_directory() for locations with no live monitor. - update_basename_validation's empty-field logic is now a separate pure basename_field_error() helper, so it can be unit tested without a real GTK widget. The previous version called gtk::init() directly, which works locally but fails on GitHub's headless CI runners (confirmed failing on PR lgse#30 for the same reason). * Explain when a location doesn't support Trash Moving an item to Trash on a backend without trash support (most remote filesystems, including SMB) fails with NOT_SUPPORTED, which previously surfaced as a raw GIO error. Detect that specific case and suggest permanent deletion instead. Per lgse#20's own guidance, pre-emptively hiding the Trash option based on a capability query is a bigger, separate piece of work (its own delivery slice); this only improves what happens when the attempt is already made. * feat(smb): refine authentication and mount controls * fix(smb): harden remote navigation and refresh * fix(smb): cap automatic mount retries after authentication failure Without a limit, a mount that keeps failing before the credential prompt is ever answered (observed live against a real SMB share, where the operation resolved in well under 250ms with no button click or reply) retried forever, tearing down and rebuilding the authentication dialog on every failure and making it impossible to type into. * Fix formatting (cargo fmt) in the previous commit * fix(smb): retry only rejected credential submissions * fix(smb): prompt after early authentication failure --------- Co-authored-by: Marcelo Rocha <[email protected]> Co-authored-by: Pierre Berube <[email protected]>




Summary
Ctrl+Laccepts any well-formedscheme://URI, not justtrash:///, sosmb://,sftp://,ftp://,dav://, etc. all reach GIO instead of being rejected as "not an absolute path."GtkMountOperationfor credentials. Correctly dispatches tomount_enclosing_volumevsmount_mountabledepending on the GVfs entry type (they are not interchangeable).\\host\share) and SCP-style (user@host:path) shorthand rejected with a clear message instead of being misread as a local path, per this issue's own product decisions.gvfs-smb) instead of a raw GIO error.Closes #5: GVfs mounts now stay URI-native everywhere a
Locationis derived from agio::File(sidebar, volumes, click-to-navigate, and every child entry produced while enumerating a remote directory), instead of leaking the opaque/run/user/$UID/gvfs/...FUSE path.Two more bugs found and fixed while testing against a real SMB share:
Also improved: Trash on a backend that doesn't support it (SMB has none) now explains that and suggests permanent delete, instead of surfacing a raw GIO error.
Not included
Left for later slices per this issue's own scope: SFTP/FTP/WebDAV-specific testing (the code is protocol-agnostic through GIO, but only verified against SMB), saved Connections UI/persistence, a Disconnect action, and capability-gated hiding of unsupported operations like Trash.
Testing
161 automated tests (
./scripts/check.shclean), plus manual end-to-end testing against a real SMB share on my LAN. Recording attached in a follow-up comment.One more thing: I'll be away from this for a bit starting tomorrow, work week kicking off. No rush reviewing, take your time. Good luck with everything!