Skip to content

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

Closed
BoYanZh wants to merge 1 commit into
anomalyco:devfrom
BoYanZh:v2-picker-start
Closed

BoYanZh wants to merge 1 commit into
anomalyco:devfrom
BoYanZh:v2-picker-start

Conversation

@BoYanZh

@BoYanZh BoYanZh commented Oct 11, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #54663 (split out from #54626).

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. Previously, directory suggestions and Tab-completed paths could end with a mixed separator such as C:\repo\apex/, and input comparison stripped only /.

Add pickerDisplaySeparator, withPickerSeparator, and stripPickerTrailingSeparator in domain.ts; use them for completion, suggestion suffixes, and input comparison in dialog.tsx. POSIX behavior and the public API are unchanged.

Commit 802415e already removes the ineffective resolvePickerStart reorder and its four tests. The picker start order matches base 707de58. This PR does not claim to change the server-reported starting directory.

How did you verify your code works?

Rechecked on Windows at 802415e98198fbe67ebed61bcbab864a02238df8 with Bun 1.3.14:

  • From packages/app: bun test ./src/workspaces/selection — 52 pass, 0 fail, 107 expect() calls, 2 files. The previous count of 56 included the four removed tests.
  • oxlint on the three changed files: 0 errors, 8 warnings in existing code outside the changed hunks.
  • Prettier check on the three changed files: passes.
  • git diff --check against base 707de58: passes.
  • bun typecheck from packages/app: fails with TS1128 at src/custom-elements.d.ts(1,1) and (1,2). That file is unchanged by this PR. No full type-check success is claimed.
  • GitHub Actions check, test, and nix-eval for this head report action_required; CI is not confirmed passing.

Windows reproduction and recorded before/after

The existing Windows verification record compared pristine 707de58 with this branch, using the local dev app and a backend started with serve from a nested directory. The exact historical arguments and working directory were not recorded.

Recorded steps: open Add project, type C:\...\opencode-pristine\pack, inspect suggestions, and press Tab.

Observation Before (707de58) After (this branch)
Directory suggestion C:\...\opencode-pristine\packages/ C:\...\opencode-pristine\packages\
Tab-completed input C:\...\packages/ C:\...\packages\

These are previously recorded observations, not a new browser run. They establish separator behavior only, not a change in the initial directory.

The repository documents separate local development processes:

  • Backend from repository root: bun dev serve --port 4096
  • App from packages/app: bun dev -- --port 4444
  • Open http://localhost:4444, targeting the backend at http://localhost:4096.

This is documented setup guidance, not a claim that these exact arguments were used in the earlier nested-directory verification.

Screenshots / recordings

before-54630 after-54630

Checklist

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

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

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

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

Copy link
Copy Markdown
Contributor

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

@opencode-agent opencode-agent 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.

Read through, plus the selection domain tests (55 pass) and the packages/app type check (passes). I couldn't check the Windows-only display here.

The separator part fixes a real bug. displayPickerPath already shows Windows drive paths with \, but the base still added / to directory suggestions and accepted completions, and only stripped trailing /. So C:\repo\apex/ showed up, and a typed C:\repo\ wasn't seen as the current folder. The new helpers fix both, and POSIX paths behave as before.

The start-directory reorder doesn't change behaviour, so on its own it doesn't fix #54626 (see the inline comment). The web client always sets sync.data.path.home to an empty string (loadPathQuery in runtime/server/global-sync/bootstrap.ts), so home never won in the old order either. sync.data.path.directory and the fallback both come from GET /api/location. In my reading, when the picker opens at home it's because the server it talks to reports home as its location. The background service used by opencode and opencode pair does that. Could you say on #54626 how you started the server, and attach before/after screenshots of the picker on Windows?

Public API: unchanged.

Related: #43173, #49947

props.location?.directory ||
sync.data.path.directory ||
fallbackPath.latest?.directory,
const start = createMemo(() =>

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 reorder doesn't seem to change which directory the picker opens at. sync.data.path.home is always "" on the web side (loadPathQuery sets home: ""), so it never won before either. location()?.directory (props.location, or api.location.get()) and sync.data.path.directory both come from the same /api/location response. The old and new orders end up at the same value. If the picker opened at home for you, the server probably reported home as its location (e.g. the background service). That would need a fix elsewhere, not in this memo. Unless you have a case where the result differs, I'd drop resolvePickerStart and keep this PR to the separator fix.

expect(nextSuggestionIndex(0, 1, 0)).toBe(-1)
})

test("prefers the server directory over home for the picker start", () => {

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.

These four resolvePickerStart tests only check the order of an a || b || c chain, and home is never set at runtime. If the reorder is dropped (see the comment on dialog.tsx), they can go too. The test.each separator cases are enough.

@BoYanZh

BoYanZh commented Oct 12, 2026

Copy link
Copy Markdown
Author

Windows in-browser verification (dev app + \serve\ backend from a nested dir, pristine \707de58\ vs this branch). Same steps both times: Add project picker, type \C:\...\opencode-pristine\pack, read the suggestion list:

  • Before: suggestion text is \C:\...\opencode-pristine\packages/\ (backslash path, forward-slash suffix); Tab-completed input is \C:\...\packages/.
  • After: suggestion text is \C:\...\opencode-pristine\packages\; completed input ends with \\.

Server started with \serve\ from the nested directory; screenshots available on request (no image upload via CLI, can drag-drop them here if needed).

@BoYanZh BoYanZh changed the title fix(app): anchor directory picker at server directory with native separators fix(app): use native separators in directory picker Oct 15, 2026
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@BoYanZh

BoYanZh commented Oct 15, 2026

Copy link
Copy Markdown
Author

Screenshot attached.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

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