You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
app: directory suggestions strip trailing spaces and can select a different folder #60294
The web directory picker strips trailing whitespace from an already resolved directory path when navigating through a search suggestion or a recent project. On Unix, foo and foo are distinct valid directory names. Selecting the latter via these paths can therefore navigate to the former, or fail if only foo exists. Tree selection itself preserves the space.
Reproduction
On dev commit 82666b6612cdb2ba13a7a26e150b21e897a80373, from packages/app, run the actual path functions used by the picker:
bun -e 'import {cleanPickerInput,pickerAbsoluteInput,pickerMode} from "./src/workspaces/selection/domain.ts"; const root="/tmp/example"; const target=root+"/foo "; console.log("tree selection", JSON.stringify(pickerMode("directory").selection(root,"foo /"))); console.log("suggestion navigation", JSON.stringify(pickerAbsoluteInput(cleanPickerInput(target),"/tmp",root)));'
Actual output:
tree selection "/tmp/example/foo "
suggestion navigation "/tmp/example/foo"
Expected: the resolved directory path retains its final space in both cases. chooseSuggestion passes suggestion.absolute to selectDirectory, which unconditionally applies cleanPickerInput (and .trim()) before navigation. Recent-project selection uses the same function. This reproduction exercises the actual path functions and the production call chain; it was not verified through a browser UI.
Both affected source files match the current upstream dev blobs. This is separate from the old #8937 report about a startup hang.
Thanks for the precise report. I reproduced this on the latest dev (d3ad3da).
With a directory named foo (trailing space, and no plain foo):
Tree selection resolves to /…/foo (correct).
The suggestion and recent-project path in selectDirectory/navigate runs the resolved absolute path through cleanPickerInput, whose .trim() turns it into /…/foo. That directory doesn't exist, or it can be a different folder.
The script below reproduces it against a real directory on disk. It calls the same picker functions; I didn't drive the browser UI.
Reproduction script (repro.ts)
// Run from packages/app of an OpenCode checkout: bun /workspace/repro/repro.ts// Shows that the directory picker's suggestion/recent-project path (selectDirectory/navigate// in src/workspaces/selection/dialog.tsx) trims a trailing space from an already-resolved// absolute path, while tree selection keeps it.import{mkdirSync,rmSync,existsSync}from"node:fs"import{resolve}from"node:path"constrepo=process.env.OC_DEV??"/workspace/repo"const{ cleanPickerInput, pickerAbsoluteInput, pickerMode }=awaitimport(resolve(repo,"packages/app/src/workspaces/selection/domain.ts"))constroot="/tmp/opencode/picker-example"rmSync(root,{recursive: true,force: true})mkdirSync(root+"/foo ",{recursive: true})// only "foo " (trailing space) existsconsttarget=root+"/foo "consttree=pickerMode("directory").selection(root,"foo /")// what selectDirectory(suggestion.absolute) / navigate(recentProject) compute:constsuggestion=pickerMode("directory").navigation(pickerAbsoluteInput(cleanPickerInput(target),"/tmp",root))console.log("target ",JSON.stringify(target),"exists:",existsSync(target))console.log("tree selection ",JSON.stringify(tree),"exists:",existsSync(tree))console.log("suggestion/recent ",JSON.stringify(suggestion),"exists:",existsSync(suggestion))if(suggestion!==target){console.log("BUG: suggestion navigation resolved to a different (here non-existent) directory")process.exit(1)}console.log("OK")
Activity
opencodejr commentedon Oct 29, 2026
Thanks for the precise report. I reproduced this on the latest
dev(d3ad3da).With a directory named
foo(trailing space, and no plainfoo):/…/foo(correct).selectDirectory/navigateruns the resolved absolute path throughcleanPickerInput, whose.trim()turns it into/…/foo. That directory doesn't exist, or it can be a different folder.The script below reproduces it against a real directory on disk. It calls the same picker functions; I didn't drive the browser UI.
Reproduction script (repro.ts)
Run it:
bun repro.ts