Skip to content

Desktop: no way to open a local folder or reveal a file, because Tx::open_url refuses file: links #147

Done

Description

@godismyjudge95

What happens

Tx::open_url("file:///home/me/Pictures") returns OpenUrlError::UnsupportedScheme("file"). That is on purpose (open_url.rs#L3-L5, #L76-L90 at dev d03349e2), and keeping links to http, https and mailto is a good rule. But Rune has no other call for local paths, so every desktop app that has "Open folder" or "Show in folder" spawns platform commands itself.

Asks

Two desktop-only calls on Tx, separate from open_url, taking a &Path that must exist:

  1. open_path(path): open a file or folder in its default app.
    • macOS: NSWorkspace openURL: with a file URL.
    • Windows: ShellExecuteW with the path.
    • Linux: the OpenURI portal (OpenFile for a file, OpenDirectory for a folder) when present, else xdg-open.
  2. reveal_path(path): show the item selected in the file manager.
    • macOS: NSWorkspace activateFileViewerSelectingURLs:.
    • Windows: SHOpenFolderAndSelectItems.
    • Linux: org.freedesktop.FileManager1.ShowItems on the session bus, else open the parent folder.

Both should follow the open_url pattern: the check runs in the handler, the open runs after the frame, and headless runs keep the requests for tests (as Runtime::take_url_requests does).

Our workaround

We spawn open -R <file> on macOS, explorer /select,<file> on Windows and xdg-open <parent> on Linux for "Show in folder", and open, explorer or xdg-open for "Open folder". On Linux that cannot select the file, and inside a sandbox xdg-open may not be there.

Done when: Tx::open_path and Tx::reveal_path exist on macOS, Windows and Linux, reveal_path selects the file in Finder, Explorer and GNOME Files, a missing path returns an error in the handler, and headless runs record the requests.


Posted via Claude

Activity

  1. Stringsaeed commented on Nov 10, 2026

    @Stringsaeed

    Another case: a clipboard history that records copied files. It needs to open a file with its default app and reveal it in Finder (activateFileViewerSelectingURLs). Both go through NSWorkspace via objc2 today.

  2. Hona commented on Nov 24, 2026

    @Hona
    Member

    Implemented on dev in #1947 (e725e0665).

    What was added

    • Tx::open_path(path) (open a file or folder in its default app) and Tx::reveal_path(path) (select the item in Finder, Explorer, or the Linux file manager), keeping Tx::open_url restricted to http:, https:, and mailto: links.
    • OpenPathError, PathAction, PathRequest, and Runtime::take_path_requests() for headless runs and tests.
    • Open and Reveal buttons for dropped files in examples/drop-files (also viewable via --scene dropped).
    use std::path::Path;
    use rune::{el, Tx};
    
    let _ = el().on_press_tx(|_, tx: &mut Tx| {
        let _ = tx.reveal_path(Path::new("/path/to/export.csv"));
    });

    Difference from the proposal

    To keep filesystem I/O out of Rune's UI-thread frame loop, open_path and reveal_path validate syntax only in the handler (Empty, embedded NUL -> Invalid, web/mobile -> Unsupported) instead of calling stat synchronously, and run path resolution and OS launch off the UI thread after the frame. If you have a use case that requires synchronous existence checks or a different behaviour, please comment or reopen.

    Design & verification

    • Follows Electron (shell.openPath / shell.showItemInFolder), Apple NSWorkspace (with main-queue dispatch and NSURL::fileURLWithPath:isDirectory: after background resolution), Win32 ShellExecuteW / SHOpenFolderAndSelectItems, Freedesktop org.freedesktop.portal.OpenURI (OpenFile / OpenDirectory) + org.freedesktop.FileManager1.ShowItems (with xdg-open fallback), and Rune's Tx::open_url.
    • Verified: Windows unit/headless tests (open_path, open_url, window_requests, runtime::input, runtime::web, drop-files), macOS unit tests (open_path, open_url), Linux cargo check with default dbus and --no-default-features, and wasm32 WebGPU/WebGL checks.
    • Not verified live: real desktop launches in Finder, Explorer, GNOME Files/portal, or xdg-open, and interactive desktop windows.
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions