Skip to content

Adding a workspace: offer a Browse… button that opens the OS folder dialog (local browser only) #540

Closed

Description

@0721-art

What I see

Adding a workspace on Windows (选择目录 / Select directory → 本机), the dialog starts at the drive list — C:, D:, E: — with a path box and a 前往 button. Without a breadcrumb, quick locations (home, Desktop, Downloads, recent projects) or type-ahead, reaching a project under C:\Users\me\Documents\… means either typing the absolute path or clicking down one level at a time.

Every native folder dialog on the same machine already does this better, because it is the UI people use all day: breadcrumbs, Up, quick-access sidebar, search, recent folders, and keyboard navigation.

This is a UX suggestion, not a bug: the picker works, it is just slower to find a folder in than the OS dialog.

Proposal: a Browse… button that opens the OS folder dialog

  • In components/DirectoryPicker.tsx, next to the path input: a button that asks the server to open the operating system's folder chooser, then fills the path with the result.
  • Only offered when the page is served to the machine the server runs on — isLoopbackHost (lib/hosts/host-login.ts) already answers that, and remote/mobile browsers never see the button (a dialog would otherwise open on a desktop nobody is looking at).
  • Degrades silently: no desktop session, unknown platform, user cancels, or the dialog times out → the button does nothing and the existing in-page browsing stays exactly as it is.

Sketch

GET  /api/cwd/picker          → { supported: boolean, reason?: "remote" | "headless" | "unsupported-platform" }
POST /api/cwd/pick  { initialPath?, hostId? }
                              → { path }            chosen
                              → { cancelled: true } cancelled
                              → 501 picker_unsupported
  • Loopback check + local host only (hostId absent or local); anything else answers 501.
  • The chooser runs in a child process, never in the server process: powershell -STA + System.Windows.Forms.FolderBrowserDialog on Windows, osascript -e 'choose folder' on macOS, zenity --file-selection --directory (or the XDG portal) on Linux. A timeout keeps a stuck dialog from holding the request open.
  • The returned path goes through the existing /api/cwd/validate before it is accepted, so a directory that is not a valid workspace is rejected the same way a typed path is.
  • New strings go into all four locales (directoryPicker.* keys already exist as flat keys, e.g. directoryPicker.go).

Why not only improve the in-page browser

Both are useful and not exclusive: breadcrumbs / start-at-home / recent projects make the web picker better for everyone, including remote hosts. But they cannot give the quick-access sidebar, the OS search or the muscle memory of the native dialog, and that is the part that makes "find my project folder" fast.

Willing to send a PR

I can implement this behind the capability check above, with tests for the parts that are testable without a desktop:

  • isLoopbackHost gate and the hostId rejection (route-level, fake req),
  • argument building and output parsing per platform (lib/... pure helpers),
  • the cancel/timeout mapping,
  • the component test that the button is absent when supported is false.

The dialog itself cannot be exercised in CI (no interactive desktop); the PR would say so and describe the manual check on Windows/macOS.

If you would rather not carry three platform implementations, a Windows-only button behind supported would already cover the platform this report comes from.

Activity

  1. kahme247 commented on Nov 23, 2026

    @kahme247
    Collaborator

    Verified fixed on current main (head c93b5b13) by merged PR #544 (merge commit 19330325).

    Evidence on main:

    • components/DirectoryPicker.tsx:337-348 renders a Browse button (directoryPicker.browse) next to the path input, shown only when nativePickerAvailable is true.
    • Availability is gated to this machine: GET /api/cwd/picker returns pickerAvailable(context.localPeer) (app/api/cwd/picker/route.ts), and the component only checks it for the local host.
    • POST /api/cwd/pick (app/api/cwd/pick/route.ts) opens the OS dialog and returns { path } / { cancelled: true }, refusing non-local hosts with 501 picker_unavailable.
    • lib/cwd-picker.ts runs the chooser in a child process per platform — PowerShell FolderBrowserDialog on Windows, osascript choose folder on macOS, zenity --file-selection --directory on Linux — with a 5-minute timeout, and the picked path goes through the existing /api/cwd/validate flow.

    Closing as implemented by #544.

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