Skip to content

fix: accept a URI typed into the location bar from any location - #1984

Merged
jacobgkau merged 1 commit into
pop-os:masterfrom
chris-010:fix-uri-in-location-bar
Aug 18, 2026
Merged

jacobgkau merged 1 commit into
pop-os:masterfrom
chris-010:fix-uri-in-location-bar

Conversation

@chris-010

Copy link
Copy Markdown
Contributor

Typing smb://server/share into the location bar only works while the tab is already on a network location. From a normal folder the text is turned into a path and the navigation is dropped:

WARN tried to cd to Path("smb://chris@nas/") which is not a directory

The bar inherits its type from the tab (Message::EditLocationEnable), and the view only has the two branches next to the existing //TODO: allow editing other locations. EditLocationSubmit now decides by parsing the input instead. The reverse direction — a local path typed while standing in Networks — was broken the same way.

Known cosmetic side effect: while the share is not yet mounted the tab shows the raw URI as its name; the proper name appears once the mount completes.

Tested against a real SMB server on a build of 5bdfffa carrying only this patch, with an isolated XDG_CONFIG_HOME. Across the whole run: failed to connect 0, no path for item 0, failed to scan 0.

Eight steps, and two notes that may save a reviewer time
# step result
1 smb://user@server/ from a local folder share list appears
2 same address with a leading space same
3 /home/…/tmp from the network location navigates locally
4 foo:bar from a local folder no effect (unchanged behaviour)
5 sidebar → Networks unchanged
6 a directory whose name ends in a space opens, the space is preserved
7 smb://server/share, not mounted mounts and opens
8 foo:bar from a mounted share no effect
  • The reliable indicator for "this is a path" is that parsing fails, not that the host is missing — network:/// and file:///home both parse with has_host() == false. An earlier version keyed on the host and would have broken the Networks view.
  • An unmounted share cannot be resolved (Tab::resolve → mounter.dir_info), so navigating needs a fallback to the typed URI — and navigating is what triggers the mount, since Cmd::NetworkScan mounts the location it is asked to scan. The fallback is restricted to input recognised as a URI with a host; applying it to any network location let unparseable text through, and because with_uri keeps the previous display name and path, the window looked normal while the listing stayed empty.
  • I have disclosed use of any AI generated code in my commit messages.
  • I understand these changes in full and will be able to respond to review comments.
  • My change is accurately described in the commit message.
  • My contribution is tested and working as described.
  • I have read the Developer Certificate of Origin and certify my contribution under its conditions.

The location bar inherits its type from the tab's current location
(Message::EditLocationEnable), and the view has exactly two branches, next
to the existing "TODO: allow editing other locations": a Location::Network
is edited through with_uri, anything else through with_path. Typing
smb://server/share while standing in a local folder therefore produced
Path("smb://server/share"), which is not a directory, and the navigation
was dropped. The reverse direction was broken the same way: from the
Networks view a local path was passed to with_uri and became a bogus
network location.

EditLocationSubmit now decides by parsing the text instead of by the
location it came from:

  * parses as a URL with a scheme other than "file" and has a host
    -> Location::Network, using url::Url::as_str(), which also normalizes
       away surrounding whitespace.
  * fails to parse and the current location is a Network
    -> Location::Path, with the text untrimmed, because a directory name
       may legitimately end in a space.
  * anything else is left as it was, so network:/// and foo:bar keep
    behaving exactly as before.

The reliable indicator for "this is a path" is that parsing fails, not
that the host is missing: network:/// and file:///home both parse with
has_host() == false. Verified against url 2.5.8.

An unmounted share cannot be resolved, since Tab::resolve sends network
locations through mounter.dir_info, so resolve() returns None and the
navigation would be dropped again. Navigating there is what triggers the
mount, because Cmd::NetworkScan mounts the location it is asked to scan,
so the typed URI is used as a fallback. That fallback is restricted to
input recognised by the first rule above; applying it to any network
location would let unparseable text through, and because with_uri keeps
the display name and path of the previous location, the window would look
normal while the listing stayed empty.

Known cosmetic side effect: while the share is not mounted, resolve()
yields nothing and the tab shows the raw URI as its name. It is replaced
by the proper name as soon as the mount completes.

Drafted with AI assistance (Claude Code); the change was reviewed, built
and tested by me on real hardware as described.

Signed-off-by: chris-010 <10660568+chris-010@users.noreply.github.com>
@mmstick
mmstick requested review from a team August 17, 2026 16:46
@jacobktm jacobktm self-assigned this Aug 18, 2026

@jacobktm jacobktm left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This has passed regression testing. # Testing

This document provides a regression testing checklist for COSMIC Files. The checklist provides a starting point for Quality Assurance reviews.

Checklist

Basic navigation

  • Middle-click opens directory in a new tab (not focused).
  • Open two scrollable tabs. Scroll one tab, then switch to the other tab; it should not have scrolled.
  • Hover over the top item in the folder, then scroll down until it's out of view (while still hovered).
    On scrolling back up (with the mouse in a different position), the item should not have the hover highlight.
  • Right-click an item in the sidebar. No visual change should occur with the rest of the items.
  • Remove an item from the sidebar, then re-pin it.

File operations

  • Right-click -> Create a new folder, then enter it.
  • Right-click in the empty folder -> Create a new file.
  • Navigate to the parent folder, create another new file, then drag it into the created folder.
  • Files can be renamed.
  • Files can be opened with non-default apps & browsing store for new apps works.
  • Normal right-click shows Move to trash option.
  • Shift right-click, and right-click followed by Shift, both show Permanently delete option.

Advanced navigation & view settings

  • Image and video thumbnails generate & display in local folders.
  • Gallery preview shows with Spacebar.
  • Details pane shows with Ctrl+Spacebar.
  • Zoom in/out and reset to default zoom work.
  • Ctrl+1 and Ctrl+2 switch between list and icon view.
  • Ctrl+H shows/hides hidden files.
  • Directories can be sorted at top or inline.
  • Settings -> Theme works.
  • Settings -> Type to Search affects behavior as designed.
  • Single-click to open setting takes effect.
  • Sorting options work.
  • Cutting, copying, and pasting files works.
  • F5 reloads current directory.
  • Left sidebar can be collapsed and expanded.

External filesystems

  • Add a network drive (e.g. SFTP) and navigate into it.
  • Plug in a USB drive; able to mount, browse, and eject.

Integrations

  • Desktop icons display as expected
  • Drag-and-drop into Firefox works

Browsing to network shares from the location bar also works.

@jacobgkau
jacobgkau merged commit 3c9a78a into pop-os:master Aug 18, 2026
4 checks passed
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.

4 participants