Skip to content

fix(app): use native separators in directory picker - #63980

Open
BoYanZh wants to merge 3 commits into
anomalyco:devfrom
BoYanZh:v2-picker-start
Open

BoYanZh wants to merge 3 commits into
anomalyco:devfrom
BoYanZh:v2-picker-start

Conversation

@BoYanZh

@BoYanZh BoYanZh commented Nov 14, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #54663 (split out from #54626).

Supersedes #54630, which was closed by automated cleanup and can no longer be reopened after the rebase (GitHub rejects reopen on force-pushed branches).

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Fix the separators added by the Windows web directory picker.

  1. Directory suggestion rows ended with a mixed separator such as C:\repo\apex/. Add pickerDisplaySeparator in domain.ts (reused by displayInputDirectory) and use it for the suggestion suffix in dialog.tsx.
  2. Tab completion still built the completed path with a hardcoded /, so C:\Users\b\pack + Tab produced C:\Users\b\packages/, and the input-vs-root comparison in canSearchPickerInput stripped only /, so a typed C:\Users\b\packages\ did not count as the open root and kept searching. Tab now completes through the same withPickerSeparator helper that clicking a folder uses, and the comparison uses the canonical trimmed path, so either separator matches.

Regression coverage: a Windows-suggestion parity test in domain.test.ts, a Tab-completion test in combobox-machine.test.ts, and the existing "input equal to the open root has nothing to suggest" case extended with a trailing-backslash Windows input. Both new tests fail before the fix and pass after it.

Rebased onto current dev (46744b6). POSIX behavior and public API unchanged.

How did you verify your code works?

  • bun test ./src/workspaces/selection/domain.test.ts: 47 pass, 0 fail.
  • bun test ./src/workspaces/selection/combobox-machine.test.ts: 21 pass, 0 fail.
  • bun test --conditions=solid --isolate --preload ../ui/test/solid-jsx.ts --preload ./happydom.ts ./src/workspaces/selection: 87 pass, 0 fail.
  • The two new assertions fail on the pre-fix code (Tab produced ...packages/; the trailing-backslash input started a search instead of opening empty), so they protect this contract.
  • bunx prettier --check on the three changed files: passes.
  • bunx oxlint src/workspaces/selection/: 0 warnings, 0 errors.
  • git diff --check: passes.
  • bun run typecheck:tsc (tsc -b) from packages/app: 0 errors.

Screenshots / recordings

No visual change on POSIX. On Windows, suggestion rows and Tab-completed inputs now both end with \.

TODO: Windows before/after capture of the picker (Tab completing C:\Users\b\pack to C:\Users\b\packages\). Not captured in this revision: the app dev server needs a running backend on port 4096, which is currently held by an existing process that must not be restarted, so the capture is left for a follow-up rather than disturbing a live server.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #54626

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Nov 14, 2026

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This fixes the directory suggestion rows, but not Tab completion. #54663 and the description both cover Tab-completed paths and the trailing-separator comparison, and both are still wrong.

I ran the PR's transitionPickerCombobox with Windows paths (home and root C:/Users/b). Typing C:\Users\b\pack and pressing Tab on the C:/Users/b/packages suggestion still sets the input to C:\Users\b\packages/. Clicking the same suggestion gives C:\Users\b\packages\. The cause is in packages/app/src/workspaces/selection/combobox-machine.ts:

  • Line 191 (Tab): value.endsWith("/") ? value : value + "/" still hardcodes /. It could use pickerDisplaySeparator(value), or simply displayInputDirectory.
  • Line 155: the input-vs-root comparison still strips only trailing /, so C:\Users\b\ doesn't match the root C:\Users\b.

Could you fix both there and add a small Tab test with a Windows path to combobox-machine.test.ts? Before/after screenshots of the picker on Windows would also help, since I couldn't run the web UI on Windows.

The domain and combobox tests pass (67 pass) and tsc -b passes in packages/app.

The public API is unchanged. pickerDisplaySeparator is a new internal export of the app package.

Related: #54626

return displayed.endsWith(separator) ? displayed : displayed + separator
}

export function pickerDisplaySeparator(displayed: string) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The Tab path doesn't use this helper yet. combobox-machine.ts:191 still appends a hardcoded /, so Tab on a Windows directory suggestion still produces C:\Users\b\packages/; I checked by running transitionPickerCombobox. combobox-machine.ts:155 still strips only trailing /. Using this helper (or displayInputDirectory) in both places would cover the rest of #54663.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Nov 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My earlier point is fixed: Tab completion now uses withPickerSeparator, and the root comparison uses trimPickerPath. I re-ran my Windows-path script against transitionPickerCombobox: Tab on C:\Users\b\pack now gives C:\Users\b\packages\, the same as clicking the suggestion. The domain and combobox tests pass (68 pass) and tsc -b passes in packages/app.

The public API is unchanged. withPickerSeparator and trimPickerPath are new internal exports of the app package.

No further concerns. The Windows before/after screenshots you mentioned would still help, since I couldn't run the picker on Windows.

Tab and the typed-input/root comparison hardcoded "/", so a Windows path
completed to C:\Users\b\packages/ and an input equal to the open root kept
searching. Complete with the separator the displayed path already uses and
compare paths in the canonical trimmed form.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tab completion and the root comparison are still fixed after the rebase. On the new base, Tab on C:\Users\b\pack gives C:\Users\b\packages/; with this PR it gives C:\Users\b\packages\. The selection tests pass (88 pass).

The rebase onto the redesigned picker (#64241) caused two problems:

  • tsc -b in packages/app now fails. The windows test context is missing the new required committed field (see inline).
  • The suggestion-row change in dialog.tsx is no longer needed and now changes POSIX output (see inline).

The public API is unchanged.

  • packages/app/src/workspaces/selection/combobox-machine.test.ts:24: Since the rebase, PickerComboboxContext requires committed, so tsc -b fails here with TS2741. Adding committed: "" (as the POSIX context above does) fixes it.
  • packages/app/src/workspaces/selection/dialog.tsx:714: After the redesign (#64241), suggestion rows show only the folder name (with a folder icon and the parent path), with no trailing /, so there is no mixed separator left to fix here. This now adds a separator after every folder name, and on Linux and macOS rows newly read packages/. I'd drop this hunk, the pickerDisplaySeparator import and its test in domain.test.ts. The Tab and comparison fixes in combobox-machine.ts cover #54663.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Both points from my last review are fixed. The windows test context now sets committed, so tsc -b in packages/app passes again. The dialog.tsx suggestion-row change is gone, so rows look the same as on dev on every platform.

I re-ran my Windows-path check against transitionPickerCombobox: Tab on C:\Users\b\pack gives C:\Users\b\packages\, the same as clicking the suggestion. The selection tests pass (85 pass).

The public API is unchanged.

The description still mentions the suggestion-row change in dialog.tsx, which is no longer part of the PR.

@BoYanZh

BoYanZh commented Nov 19, 2026

Copy link
Copy Markdown
Author

Note on visuals after the redesign fix: suggestion rows are intentionally unchanged now (redesign #64241 already shows name + icon + parent path, no trailing slash), so there is no before/after for rows on POSIX. Tab behavior is covered by tests: typing C:\Users\b\pack + Tab on C:/Users/b/packages now completes to backslash, same as clicking. Historical Windows captures from #54630 for reference: before after

This branch has not been deployed

No deployments
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.

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

1 participant