Skip to content

fix: Windows session path, shell env, error message, and autocomplete#31946

Open
Nigmat-future wants to merge 2 commits into
anomalyco:devfrom
Nigmat-future:fix/windows-and-error-issues-bundle
Open

fix: Windows session path, shell env, error message, and autocomplete#31946
Nigmat-future wants to merge 2 commits into
anomalyco:devfrom
Nigmat-future:fix/windows-and-error-issues-bundle

Conversation

@Nigmat-future

@Nigmat-future Nigmat-future commented Jun 11, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #31629, #31597, #31904, #31414, #23144

Type of change

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

What does this PR do?

On Windows, several small issues compounded into broken UX:

  1. Desktop subprocess flash (Windows: subprocess spawn (git, codegraph, etc.) flashes console window #31629)execFile/spawn in the desktop main process did not set windowsHide, so helper processes briefly opened console windows. Added shared helpers in packages/desktop/src/main/child-process.ts and wired them through ipc.ts and apps.ts.

  2. 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 with REPLACE(\, /) on read so existing DB rows still match.

  3. 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 through process.env at spawn time, and any leftover PowerShell-style prefix is stripped for non-pwsh shells.

  4. NamedError message (NamedError hides data.message: Error.message is set to the tag name #31414)NamedError passed the error tag to super() instead of data.message, so users saw ProviderAuthError: ProviderAuthError. Now Error.message carries the human-readable detail.

  5. @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 pass
  • packages/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 pass
  • packages/desktop: bun test src/main/child-process.test.ts — 2 pass

Screenshots / recordings

Not a UI change — no screenshot.

Checklist

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

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
@github-actions github-actions Bot added needs:title needs:compliance This means the issue will auto-close after 2 hours. labels Jun 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hey! Your PR title Fix Windows shell, session path, error, and autocomplete issues doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

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

@Nigmat-future Nigmat-future changed the title Fix Windows shell, session path, error, and autocomplete issues fix: Windows session path, shell env, error message, and autocomplete Jun 11, 2026
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jun 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@hereswilson

Copy link
Copy Markdown

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.

@Nigmat-future

Copy link
Copy Markdown
Author

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.

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.

Windows: subprocess spawn (git, codegraph, etc.) flashes console window

2 participants