Skip to content

fix(win32): Sidecar spawning a window#14197

Merged
Hona merged 2 commits intoanomalyco:devfrom
Hona:fix/desktop-window
Feb 18, 2026
Merged

fix(win32): Sidecar spawning a window#14197
Hona merged 2 commits intoanomalyco:devfrom
Hona:fix/desktop-window

Conversation

@Hona
Copy link
Member

@Hona Hona commented Feb 18, 2026

What does this PR do?

Fixes a Windows desktop regression where starting the local opencode-cli sidecar opens a visible console window.

Regression timeline (data-driven)

Root cause

When using process-wrap + JobObject on Windows, creation flags set directly on Command can be overwritten during wrapper pre_spawn handling, so CREATE_NO_WINDOW may be lost.

Fix approach

Apply Windows creation flags with process-wrap-aware ordering/handling so the spawned sidecar keeps CREATE_NO_WINDOW while preserving JobObject lifecycle behavior.

Verification

  • Traced commit history and diffs around packages/desktop/src-tauri/src/cli.rs.
  • Confirmed behavior against upstream source:
    • process-wrap/src/generic_wrap.rs
    • process-wrap/src/tokio/job_object.rs
    • process-wrap/src/tokio/creation_flags.rs
  • Local compile check passes for Windows target:
    • cargo check --target x86_64-pc-windows-msvc (from packages/desktop/src-tauri)

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@Hona Hona marked this pull request as ready for review February 18, 2026 22:04
@Hona Hona requested a review from adamdotdevin as a code owner February 18, 2026 22:04
Copilot AI review requested due to automatic review settings February 18, 2026 22:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a Windows regression introduced in v1.2.6 where the opencode-cli sidecar process spawns a visible console window. The root cause was that the process-wrap library's JobObject wrapper overwrites creation flags set directly on Command. The fix implements a custom CommandWrapper that applies CREATE_NO_WINDOW after JobObject runs its pre_spawn hook, ensuring the flag is preserved.

Changes:

  • Implements custom WinCreationFlags wrapper to set Windows process creation flags after JobObject processing
  • Adds Windows API dependency for CREATE_NO_WINDOW and CREATE_SUSPENDED constants
  • Removes direct creation_flags call that was being overwritten by JobObject

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/desktop/src-tauri/src/cli.rs Adds custom CommandWrapper implementation and integrates it into wrapper chain after JobObject
packages/desktop/src-tauri/Cargo.toml Adds windows crate dependency for Win32 API constants
packages/desktop/src-tauri/Cargo.lock Updates lock file to reflect new windows dependency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

#[cfg(windows)]
impl CommandWrapper for WinCreationFlags {
fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> std::io::Result<()> {
command.creation_flags((CREATE_NO_WINDOW | CREATE_SUSPENDED).0);
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

The CREATE_SUSPENDED flag causes the process to start in a suspended state and requires an explicit ResumeThread call to begin execution. There is no code in this file that resumes the process after spawning. This will cause the sidecar process to hang indefinitely in a suspended state, making it completely non-functional. Remove CREATE_SUSPENDED from the creation flags and keep only CREATE_NO_WINDOW.

Copilot uses AI. Check for mistakes.
@Hona Hona merged commit 7033b4d into anomalyco:dev Feb 18, 2026
14 checks passed
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.

2 participants