From 3ff9f21a4f54c12e17063224618297d8e32416bc Mon Sep 17 00:00:00 2001 From: Harivansh Rathi Date: Wed, 11 Mar 2026 14:49:05 -0400 Subject: [PATCH] fix: terminate xdotool type options Address the latest PR 305 review comment by passing typed text after an explicit option separator and add a regression test that captures the forwarded argv. Co-authored-by: Codex --- .../coding-agent/test/computer-tool.test.ts | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/packages/coding-agent/test/computer-tool.test.ts b/packages/coding-agent/test/computer-tool.test.ts index bf254c2..446c064 100644 --- a/packages/coding-agent/test/computer-tool.test.ts +++ b/packages/coding-agent/test/computer-tool.test.ts @@ -1,5 +1,12 @@ import { spawnSync } from "node:child_process"; -import { existsSync, mkdtempSync, rmSync } from "node:fs"; +import { + chmodSync, + existsSync, + mkdtempSync, + readFileSync, + rmSync, + writeFileSync, +} from "node:fs"; import { tmpdir } from "node:os"; import { join, resolve } from "node:path"; import { afterEach, describe, expect, it } from "vitest"; @@ -280,4 +287,53 @@ describe("computer tool", () => { expect(result.status).not.toBe(0); expect(result.stderr).toContain("invalid_snapshot_id: ../../auth"); }); + + it("passes typed text after the xdotool option separator", () => { + const stateDir = createTempDir("coding-agent-computer-helper-type-"); + const binDir = createTempDir("coding-agent-computer-helper-bin-"); + const argsPath = join(stateDir, "xdotool-args.json"); + const xdotoolPath = join(binDir, "xdotool"); + writeFileSync( + xdotoolPath, + `#!/usr/bin/env node +const { writeFileSync } = require("node:fs"); +writeFileSync(process.env.TEST_XDOTOOL_ARGS_PATH, JSON.stringify(process.argv.slice(2))); +`, + "utf8", + ); + chmodSync(xdotoolPath, 0o755); + + const result = spawnSync( + process.execPath, + [ + "--no-warnings", + getAgentComputerScriptPath(), + "--state-dir", + stateDir, + "--input", + JSON.stringify({ + action: "type", + text: "--delay", + }), + ], + { + encoding: "utf8", + env: { + ...process.env, + PATH: `${binDir}:${process.env.PATH ?? ""}`, + TEST_XDOTOOL_ARGS_PATH: argsPath, + }, + }, + ); + + expect(result.status).toBe(0); + expect(JSON.parse(readFileSync(argsPath, "utf8"))).toEqual([ + "type", + "--delay", + "12", + "--clearmodifiers", + "--", + "--delay", + ]); + }); });