Skip to content

refactor(computer-use): injectable win32 runner for host-agnostic backend tests - #5912

Merged
Hmbown merged 1 commit into
Hmbown:mainfrom
EvanProgramming:refactor/win32-injectable-runner
Sep 6, 2026
Merged

refactor(computer-use): injectable win32 runner for host-agnostic backend tests#5912
Hmbown merged 1 commit into
Hmbown:mainfrom
EvanProgramming:refactor/win32-injectable-runner

Conversation

@EvanProgramming

Copy link
Copy Markdown
Contributor

Summary

Refactor-only follow-up, as invited on the closed #5910: the win32 input bug was already fixed and merged in #5903 — this PR does not re-touch that logic. It keeps main's merged behavior and adds the instance-local injectable runner seam that was called out as cleaner than the fake-powershell.exe-on-PATH fixture.

Why

crates/tui/plugins/computer-use/src/backends/win32.mjs defined its PowerShell runner helpers (ps/psOk/psJson) at module scope, so backend tests either needed a real powershell.exe or a PATH fixture. Moving them into create() lets a test pass create({ exec: { run } }) — the exact injection pattern the harmonyos backend already uses.

Changes

  • create(opts = {}): ps/psOk/psJson become instance-local and default to the production runner; opts.exec.run overrides it. No production behavior change when create() is called with no args.
  • New tests/win32.test.mjs exercising the win32 backend on any host (no Windows, no fake powershell):

Verification

node --test tests/win32.test.mjs → 4/4 pass; node --test tests/backends.test.mjs → 10/10 pass (no regression). All on macOS.

Refs #5903, #5910.

… exec })

Follow-up to the closed Hmbown#5910, per the maintainer's invitation after the
bug itself was fixed and merged in Hmbown#5903. This PR is refactor-only: it
keeps main's merged behavior and adds a cleaner test seam.

Previously the win32 backend's PowerShell runner (ps/psOk/psJson) lived at
module scope, so backend tests had to fake powershell.exe on PATH (or run
on Windows). Move the runner helpers into create() as instance-local
functions that default to the production runner but can be overridden with
create({ exec: { run } }) — the same injection pattern the harmonyos
backend already uses.

tests/win32.test.mjs now exercises the win32 backend on any host through
the injected runner: actions run without powershell, nonzero exits reject
(fail-truthful), and targeted mouse-down is verified to move + press with
the User32 type defined in-process. Verified on macOS with no Windows
involved: node --test tests/win32.test.mjs (4/4) and
tests/backends.test.mjs (10/10, no regression).

Refs Hmbown#5903, Hmbown#5910.

Signed-off-by: EvanProgramming <evangonggyf@gmail.com>
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Thanks @EvanProgramming for taking the time to contribute.

This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered.

Please read CONTRIBUTING.md for the expected contribution shape. A maintainer can grant recurring PR access by commenting /lgtm on a pull request.

@Hmbown Hmbown left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Verified locally on the PR head: the plugin suite passes (47/47 via npm test), the create({ exec }) seam matches the harmonyos backend's shape, and create() with no args is behavior-identical to main. The four new tests pin exactly the #5903 guarantees (in-process User32 prelude, nonzero exit rejects, targeted left_mouse_down moves and presses) without a Windows host. Merging once CI finishes.

@Hmbown
Hmbown merged commit 12cce92 into Hmbown:main Sep 6, 2026
25 checks passed
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