fix: Windows session path, shell env, error message, and autocomplete#31946
fix: Windows session path, shell env, error message, and autocomplete#31946Nigmat-future wants to merge 2 commits into
Conversation
Normalize session directory matching across slash styles, hide desktop subprocess consoles on Windows, inject shell env via process.env with bash-safe prefix stripping, surface NamedError detail in Error.message, and fix TUI @file autocomplete on Windows paths. Fixes anomalyco#31629, anomalyco#31597, anomalyco#31904, anomalyco#31414, anomalyco#23144
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search results, the current PR #31946 is a comprehensive fix that addresses multiple related Windows compatibility issues. While I found several older PRs that addressed similar path separator normalization issues in sessions (PRs #28040, #28027, #28306, #28251, #30367), these appear to be historical attempts at the same problems that this PR is now fixing more comprehensively. The current PR is a consolidated fix for multiple separate issues (#31629, #31597, #31904, #31414, #23144), and the search results do not reveal any currently open duplicate PRs that would conflict with or duplicate the work in PR #31946. No duplicate PRs found |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
I did a local integration experiment to see whether this PR and my narrower desktop change in #31933 could coexist. I pushed the result here in case any of it is useful to you: https://github.com/hereswilson/opencode/tree/combine-windows-fixes The integration was possible with conflicts only in the overlapping desktop helper files, and the focused desktop tests passed. No pressure to take any of it, but the app path cache and stale resolver tests may be useful if you want to fold in my narrower Windows selected app path hardening. |
|
Thanks for trying the integration with #31933 — really helpful to know the overlap is mostly in the desktop helper files and that the focused desktop tests still pass on your combined branch. This PR is intentionally broader (session path matching, shell env, NamedError, TUI autocomplete, plus the basic \windowsHide\ wiring in desktop/ipc), so I did not fold in the selected-app path cache / stale resolver hardening from #31933 to avoid duplicating or competing with your narrower fix. If maintainers prefer one desktop path, I'm happy to align with whichever approach you think is cleaner — your \combine-windows-fixes\ branch is a good reference for resolving the helper-file conflicts. Appreciate you sharing it. |
Issue for this PR
Fixes #31629, #31597, #31904, #31414, #23144
Type of change
What does this PR do?
On Windows, several small issues compounded into broken UX:
Desktop subprocess flash (Windows: subprocess spawn (git, codegraph, etc.) flashes console window #31629) —
execFile/spawnin the desktop main process did not setwindowsHide, so helper processes briefly opened console windows. Added shared helpers inpackages/desktop/src/main/child-process.tsand wired them throughipc.tsandapps.ts.Session list mismatch (Windows: Sessions not showing in opencode desktop UI due to inconsistent path separator (/ vs \) #31597) — session directories were stored/compared with mixed
/and\, so listing sessions for the current workspace could return empty after a restart. Normalized directories to forward slashes on write and compare withREPLACE(\, /)on read so existing DB rows still match.Git Bash env injection ([Bug] Windows Git Bash: bash命令注入使用PowerShell $env:语法导致大量报错 #31904) — non-interactive env vars were sometimes prefixed with PowerShell
$env:VAR=...syntax even when the active shell was bash. Env is now applied throughprocess.envat spawn time, and any leftover PowerShell-style prefix is stripped for non-pwsh shells.NamedError message (NamedError hides data.message: Error.message is set to the tag name #31414) —
NamedErrorpassed the error tag tosuper()instead ofdata.message, so users sawProviderAuthError: ProviderAuthError. NowError.messagecarries the human-readable detail.@file autocomplete (@file autocomplete fails completely on Windows due to path separator mismatch #23144) — TUI path trimming only handled trailing
/, not\, so Windows directory completion could fail. Updated the regex to strip both.How did you verify your code works?
Ran targeted tests locally on Windows:
packages/core:bun test test/util-error.test.ts test/session-directory.test.ts— 6 passpackages/opencode:bun test test/shell/env.test.ts test/util/error.test.ts test/server/global-session-list.test.ts test/server/session-list.test.ts— 22 passpackages/desktop:bun test src/main/child-process.test.ts— 2 passScreenshots / recordings
Not a UI change — no screenshot.
Checklist