Skip to content

fix(computer-win): screenshot --display no longer requires a pid#952

Merged
muqsitnawaz merged 2 commits into
mainfrom
fix-win-screenshot-display
Jul 13, 2026
Merged

fix(computer-win): screenshot --display no longer requires a pid#952
muqsitnawaz merged 2 commits into
mainfrom
fix-win-screenshot-display

Conversation

@muqsitnawaz

Copy link
Copy Markdown
Contributor

The bug (surfaced by #864's e2e suite)

The moment the Windows-host e2e suite ran in CI (wired up in #864), it caught a real bug:

FAIL src/lib/ssh-tunnel.e2e.test.ts > screenshot --host returns a non-empty PNG over the tunnel
Error: invalid_params: missing int param: pid

Screenshot.Capture (native/computer-win/Screenshot.cs) parsed pid with P.Int(@params, "pid") unconditionally, before dispatching on mode. But a full-display capture (display: true) needs no target app — it mirrors the macOS screenshot --display whole-screen path. So agents computer screenshot --display (no app) always failed on Windows.

The fix

pid is now optional:

  • display: true with a pid → capture the monitor that pid's window sits on (unchanged behavior).
  • display: true without a pid → capture the primary screen.
  • list and window-capture modes still require pid, enforced once the mode is known (missing int param: pid).

Verification (real, end-to-end)

Cross-built the win-x64 helper with the fix (scripts/build-win.sh, dotnet 10), and ran the full computer e2e suite against a live win-mini over the real ssh -L tunnel from zion:

AGENTS_TEST_WIN_HOST=win-mini node ./node_modules/vitest/vitest.mjs run src/lib/ssh-tunnel.e2e.test.ts
 Test Files  1 passed (1)
      Tests  4 passed (4)   ← was 3 passed / 1 failed

The screenshot --host test now returns a valid PNG (magic 89 50 4E 47, >1KB) over the tunnel.

Refs #864 (this is the first real bug the e2e suite caught; it takes the suite's CI run from 4/5 to 5/5 green).

The Windows helper's screenshot handler demanded an int `pid` param
unconditionally (Screenshot.cs), so a full-display capture — which needs
no target app, mirroring the macOS `screenshot --display` path — failed
with `invalid_params: missing int param: pid`. Surfaced by the Windows-host
e2e suite (#864) the moment it ran in CI: 'screenshot --host returns a
non-empty PNG over the tunnel'.

pid is now optional. With a pid, --display still captures the monitor that
pid's window sits on; without one it captures the primary screen. list and
window-capture modes still require pid (enforced once the mode is known).

Verified end-to-end against a live win-mini over the ssh -L tunnel: the full
ssh-tunnel.e2e.test.ts suite now passes 4/4 (was 3/4, this test failing).
@muqsitnawaz
muqsitnawaz force-pushed the fix-win-screenshot-display branch from c0449ae to 33a9136 Compare July 13, 2026 07:34
@muqsitnawaz
muqsitnawaz merged commit 1c87db5 into main Jul 13, 2026
11 checks passed
@muqsitnawaz
muqsitnawaz deleted the fix-win-screenshot-display branch July 13, 2026 07:37
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.

1 participant