Skip to content

[fix]: add Windows support fixes and cross-platform CI for browse - #3408

Merged
seanmcguire12 merged 14 commits into
mainfrom
add-win32-env-ci
Nov 10, 2026
Merged

seanmcguire12 merged 14 commits into
mainfrom
add-win32-env-ci

Conversation

@seanmcguire12

@seanmcguire12 seanmcguire12 commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

why

  • browse’s core commmands already worked on Windows, but CI lacked coverage
  • running the contract suite exposed failures launching package-manager commands and cleaning up timed-out child processes

what changed

  • handle Windows command shims and terminate child process trees on timeout

@changeset-bot

changeset-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e1b14c3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
browse Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 15 files

Architecture diagram
sequenceDiagram
    participant GH as GitHub Actions
    participant WF as Workflow (ci/baseline)
    participant NPM as pnpm/turbo
    participant CLI as Browse CLI
    participant DAEMON as Browse Daemon
    participant CHROME as Headless Chrome
    participant FS as Filesystem
    participant VITEST as Vitest Runner

    Note over GH,WF: CI dispatch (Linux + NEW Windows baseline)

    GH->>WF: Trigger workflow (PR paths / dispatch)
    WF->>WF: Checkout & setup-node-pnpm

    WF->>NPM: turbo build --filter=browse
    NPM-->>WF: Build artifacts

    alt Linux smoke job (ci.yml)
        WF->>NPM: pnpm --filter browse test:smoke
        NPM->>VITEST: Run vitest.smoke.config.ts
        VITEST->>CLI: Spawn CLI process (runCli)
    else Windows baseline (browse-windows-baseline.yml)
        WF->>NPM: pnpm --filter browse test:cli
        NPM->>VITEST: Run CLI contract tests
        VITEST->>CLI: Spawn CLI with Node-based stubs
    end

    rect rgb(240, 248, 255)
        Note over CLI,CHROME: Smoke Test Flow (NEW)
        VITEST->>FS: Create temp dir + fixture server
        VITEST->>CLI: browse open <url> --local --headless
        CLI->>DAEMON: Start daemon (managed-local mode)
        DAEMON->>CHROME: Launch headless Chrome
        CHROME-->>DAEMON: Page loaded (title/URL)
        DAEMON-->>CLI: OpenResult JSON
        CLI-->>VITEST: stdout JSON

        VITEST->>CLI: browse snapshot
        CLI->>DAEMON: Get accessibility tree
        DAEMON-->>CLI: Snapshot refs
        CLI-->>VITEST: Tree JSON

        VITEST->>CLI: browse fill #name "Browse user"
        CLI->>DAEMON: Fill input
        DAEMON->>CHROME: Set value
        DAEMON-->>CLI: filled: true

        VITEST->>CLI: browse click @ref (snapshot ref)
        CLI->>DAEMON: Click element
        DAEMON->>CHROME: Dispatch click
        CHROME-->>DAEMON: DOM updated
        DAEMON-->>CLI: clicked: true

        VITEST->>CLI: browse get text #result
        CLI->>DAEMON: Query DOM
        DAEMON-->>CLI: "Hello, Browse user"

        VITEST->>CLI: browse stop
        CLI->>DAEMON: Stop daemon + browser
        alt Restart same session
            VITEST->>CLI: browse open (same session id)
            CLI->>DAEMON: New daemon PIDs
            DAEMON->>CHROME: Relaunch
            VITEST->>CLI: browse get value #name -> empty
        end
    end

    rect rgb(255, 248, 240)
        Note over VITEST,FS: Test Fixture Portability (NEW writeNodeExecutable)
        VITEST->>FS: Write .cjs + launcher (.cmd on win32 / shell on POSIX)
        VITEST->>CLI: Spawn CLI with PATH=stubDir
        CLI->>FS: External command (npx/npm/pnpm stub)
        FS-->>CLI: Command output/exit code
        alt Windows npm pack test
            VITEST->>NPM: cmd.exe /c npm pack --dry-run
            NPM-->>VITEST: Pack manifest JSON
        end
    end

    WF->>WF: Summarize outcomes + upload artifacts
    WF-->>GH: Job summary (new step output)
Loading

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@socket-security

socket-security Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​types/​cross-spawn@​6.0.61001007780100

View full report

@seanmcguire12 seanmcguire12 changed the title ignore [fix]: add Windows support fixes and cross-platform CI for browse Nov 6, 2026

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 26 files

Architecture diagram
sequenceDiagram
    participant CI as CI Workflow
    participant Setup as setup-chrome-verified Action
    participant Chrome as Chrome Browser
    participant CLI as Browse CLI
    participant PM as Package Manager (npm/pnpm/npx)
    participant Child as Child Process Tree
    participant Test as Contract/Smoke Tests

    Note over CI,Chrome: Cross-Platform CI Pipeline (NEW: Windows coverage for browse)

    CI->>CI: Filter paths for browse changes
    CI->>CI: Matrix: Ubuntu Linux / Windows 2025
    CI->>Setup: Setup Chrome verified action
    Setup->>Setup: Install Chrome (Linux only - install-deps)
    Setup->>Chrome: Verify headless launch via Node execFileSync
    Chrome-->>Setup: Chrome path exported
    Setup-->>CI: CHROME_PATH env

    CI->>CLI: Build browse package
    CI->>CLI: Run test:cli (contract suite)
    CI->>CLI: Run test:smoke (real Chrome browser)
    CI->>CLI: Run test:smoke:package (installed package)

    Note over CLI,PM: Service Command Launching (CHANGED: cross-spawn for Windows shims)

    CLI->>PM: Spawn command (npm/pnpm/npx/git)
    PM-->>CLI: Output/exit code

    alt Windows platform (.cmd/.bat shims)
        PM->>Child: Launch via cmd.exe shim
        Note over PM,Child: cross-spawn handles path quoting and non-PATH executables
    else POSIX platform
        PM->>Child: Direct exec
    end

    Note over CLI,Child: Process Termination (NEW: terminateChild helper)

    CLI->>CLI: Detect timeout or shutdown signal
    CLI->>Child: terminateChild(SIGTERM/SIGKILL)

    alt Windows platform
        Child->>Child: taskkill /PID <pid> /T /F
        Note over CLI,Child: Kills entire process tree (shims + Node children)
    else POSIX platform
        CLI->>Child: child.kill(signal)
    end

    Child-->>CLI: Exit event / killed

    Note over CLI,Test: Installed Package Smoke Test (NEW: run-cli with executable)

    Test->>Test: Create temp dir, pack tarball, npm install standalone
    Test->>CLI: Invoke installed browse executable (cross-spawn)
    CLI->>CLI: Spawn daemon process (detached, windowsHide)
    CLI->>Chrome: Launch/connect browser
    Chrome-->>CLI: Browser session established
    Test->>CLI: Run CLI commands (status, open, fill, click, get, snapshot, stop)
    CLI-->>Test: JSON output validated
    Test->>Test: Verify daemon shutdown and session cleanup
    CLI->>Child: Stop/terminate daemon process tree

    Note over CLI,Test: Contract Tests (CHANGED: platform-neutral fixtures)

    Test->>Test: Write executable stub via writeNodeExecutable
    Test->>CLI: Run CLI with restricted PATH (prependPath)
    CLI->>PM: Spawn stub (npx/pnpm/npm)
    PM-->>CLI: Capture output/logs
    Test-->>CLI: Assert behavior

    Note over CLI,Child: Error Path: Timeout (NEW: process tree cleanup)

    CLI->>Child: timeoutMs exceeded
    CLI->>Child: terminateChild(child, "SIGTERM")
    alt SIGTERM does not kill
        CLI->>Child: terminateChild(child, "SIGKILL") after 5s delay
        Note over CLI,Child: Also kills grandchildren launched via shims
    end
    Child-->>CLI: Exit, telemetry records timeout reason
Loading

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/cli/tests/helpers/run-cli.ts Resolved
Comment thread packages/cli/tests/helpers/run-cli.ts Resolved

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 3 files (changes from recent commits).

Confidence score: 4/5

  • In .github/workflows/ci.yml, one failed browse-build matrix leg can skip all contract and smoke jobs, even for platforms with a valid artifact. Keep the dependency platform-local or let consumers run for successful platforms.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name=".github/workflows/ci.yml">

<violation number="1" location=".github/workflows/ci.yml:367">
P2: A failure in either `browse-build` matrix leg skips every contract and smoke job, including jobs whose matching OS artifact is available. Keep the dependency platform-local or allow successful-platform consumers to run despite the other build leg failing, so one OS failure does not hide independent test results.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread .github/workflows/ci.yml
name: Browse contracts (${{ matrix.platform }})
runs-on: ${{ matrix.os }}
timeout-minutes: 20
needs: [determine-changes, browse-build]

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.

P2: A failure in either browse-build matrix leg skips every contract and smoke job, including jobs whose matching OS artifact is available. Keep the dependency platform-local or allow successful-platform consumers to run despite the other build leg failing, so one OS failure does not hide independent test results.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/workflows/ci.yml, line 367:

<comment>A failure in either `browse-build` matrix leg skips every contract and smoke job, including jobs whose matching OS artifact is available. Keep the dependency platform-local or allow successful-platform consumers to run despite the other build leg failing, so one OS failure does not hide independent test results.</comment>

<file context>
@@ -323,16 +323,78 @@ jobs:
+    name: Browse contracts (${{ matrix.platform }})
+    runs-on: ${{ matrix.os }}
+    timeout-minutes: 20
+    needs: [determine-changes, browse-build]
+    if: needs.determine-changes.outputs.browse == 'true'
+    strategy:
</file context>

@seanmcguire12
seanmcguire12 added this pull request to stack #3411 November 6, 2026 21:38
@seanmcguire12
seanmcguire12 merged commit 6a56cbb into main Nov 10, 2026
129 checks passed
@seanmcguire12
seanmcguire12 deleted the add-win32-env-ci branch November 10, 2026 23:20
shrey150 pushed a commit that referenced this pull request Nov 13, 2026
Release Browse independently of the Stagehand SDKs. Merging this PR
publishes the CLI from the merged commit.

## 0.11.4

### Patch Changes

- [#3426](#3426)
[`f93e6d1`](f93e6d1)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Report an
error when an active browser session disconnects during command startup
instead of automatically starting a replacement.

- [#3379](#3379)
[`73fdba0`](73fdba0)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - remove
unused deepmerge dependency

- [#3330](#3330)
[`dc8eb40`](dc8eb40)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - bump zod to
4.6.6

- [#3289](#3289)
[`aa67fee`](aa67fee)
Thanks [@shrey150](https://github.com/shrey150)! - Add `--stagehand`
flag to `browse cloud extensions upload`.

- [#3439](#3439)
[`2fe947c`](2fe947c)
Thanks [@github-actions](https://github.com/apps/github-actions)! - Make
`browse doctor` fail and show the cause when the session's last browser
start failed

- [#3400](#3400)
[`ce298c6`](ce298c6)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Add token
validation to internal local Functions runtime requests

- [#3408](#3408)
[`6a56cbb`](6a56cbb)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Fix Windows
package-manager command launching for Functions and templates, and
terminate child processes when skill installation times out.

- [#3391](#3391)
[`3fbda6b`](3fbda6b)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Validate
daemon directory locations before connecting to a session.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants