Skip to content

Directory picker appends forward slash to Windows paths on complete/suggest #54663

In review

Description

@BoYanZh

Summary

On Windows, completed or suggested directory paths in the web directory picker use a forward slash as the trailing separator: C:\repo\apex/. Split out from #54626 (server start directory is correct there; this is display-only).

Version

v2.0.26 dev (707de58), web dev build + serve backend on Windows 10.

Steps

  1. serve from any directory, open the web UI, click Add project.
  2. Type a partial directory path, e.g. C:\Users\boyanzh\Desktop\Programs\repos\opencode-pristine\packages, press Tab.
  3. Observe the input box and the suggestion list.

Expected

C:\...\packages\ (native separator), suggestions like C:\...\ai\.

Actual

Input becomes C:\...\packages/; suggestions show C:\...\ai/, C:\...\app/, etc.

Root cause

packages/app/src/workspaces/selection/dialog.tsx: complete() appends a hardcoded "/", the suggestion rows render {suggestion.type === "directory" ? "/" : ""}, and the input comparison only strips trailing /. displayPickerPath itself already returns \ for drive paths — only the appended/stripped separators are wrong.

References

Activity

  1. opencode-agent commented on Oct 12, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report and the root-cause analysis. I could reproduce this on the latest dev (707de58), the same commit you built.

    I couldn't run the web UI on Windows here. Instead, the test below runs the real displayPickerPath on C:/... paths and adds the trailing separator the same way dialog.tsx does (that part is copied into the test):

    • Completing ...\opencode\packages gives C:\...\opencode\packages/ instead of ...\packages\.
    • The directory suggestion row for ai shows C:\...\packages\ai/ instead of ...\ai\.

    displayPickerPath already returns backslashes for drive paths. The / comes from the hardcoded separator in complete() and in the suggestion rows of packages/app/src/workspaces/selection/dialog.tsx, as you described. Your PR #54630 targets exactly this. #54626 is the related report about where the picker starts.

    Reproduction script (picker-separator.test.ts)
    // Reproduces #54663 against the real picker domain helpers, mirroring the exact
    // separator logic of packages/app/src/workspaces/selection/dialog.tsx.
    // Run from the repo root: bun test /workspace/repro/picker-separator.test.ts
    // (REPO env var can point at another checkout; default /workspace/repo)
    import { expect, test } from "bun:test"
    
    const repo = process.env.REPO ?? "/workspace/repo"
    const { displayPickerPath } = await import(`${repo}/packages/app/src/workspaces/selection/domain.ts`)
    
    const home = "C:/Users/boyanzh"
    const input = "C:\\Users\\boyanzh\\Desktop\\repos\\opencode\\packages"
    
    // dialog.tsx complete(): setInput(match.type === "directory" && !value.endsWith("/") ? value + "/" : value)
    function completed(absolute: string) {
      const value = displayPickerPath(absolute, input, home)
      return !value.endsWith("/") ? value + "/" : value
    }
    
    // dialog.tsx suggestion row: {displayPickerPath(...)}{suggestion.type === "directory" ? "/" : ""}
    function suggestionRow(absolute: string) {
      return displayPickerPath(absolute, input, home) + "/"
    }
    
    test("tab-completing a Windows directory uses a native trailing separator", () => {
      const result = completed("C:/Users/boyanzh/Desktop/repos/opencode/packages")
      console.log("completed input:", result)
      expect(result).toBe("C:\\Users\\boyanzh\\Desktop\\repos\\opencode\\packages\\")
    })
    
    test("Windows directory suggestion rows use a native trailing separator", () => {
      const row = suggestionRow("C:/Users/boyanzh/Desktop/repos/opencode/packages/ai")
      console.log("suggestion row:", row)
      expect(row).toBe("C:\\Users\\boyanzh\\Desktop\\repos\\opencode\\packages\\ai\\")
    })

    Run it: bun picker-separator.test.ts

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions