Skip to content

Computer use for the Pi coding agent — Windows apps, browsers and desktops through native UI trees, screenshots and real input.

test: the live slider check goes through computer_type replace; the live engine helper keeps semantic actions off foreground delivery (LPT-934)

alexshpunt-clanker[bot]010e30a70b84
diff --git a/test/live/quick-fixes.live.ts b/test/live/quick-fixes.live.ts
index 889372f..bf023ad 100644
--- a/test/live/quick-fixes.live.ts
+++ b/test/live/quick-fixes.live.ts
@@ -1,4 +1,6 @@
import { afterAll, expect, test } from "vitest";
+import { requireComputerAddress } from "../../src/computer-resources.ts";
+import { pressPlan, typePlan } from "../../src/computer-tools.ts";
import { addresses, connectLive, text } from "./remote.ts";
const live = await connectLive();
@@ -21,19 +23,17 @@ test("a display overview takes a per-Read size", async () => {
expect(small.details.agent_image).toMatchObject({ output: { width: 320 } });
});
-test("set_value on a delivery-preference address reaches the slider", async () => {
+test("computer_type replace with foreground reaches the slider through accessibility", async () => {
const opened = await live.insert(live.machine, { action: "open", app: "Paint" });
const window = `computer:window/${opened.details.window_ref}`;
try {
const view = await live.read(window, ["ui"]);
const size = view.details.ui!.elements.find(element => element.role === "Slider" && element.name === "Size")!;
- const done = await live.insert(`computer:observation/${view.details.observation_id}?hint=${encodeURIComponent(size.hint)}&delivery=foreground`,
- { action: "set_value", text: "20" });
+ const done = await live.resources.input(requireComputerAddress(window), live.cwd, typePlan({ window, target: size.hint, text: "20", replace: true, foreground: true }));
// Paint's Size slider is read-only through UIA, so the driver itself answers; the adapter no longer refuses first.
expect(text(done)).not.toMatch(/accessibility only/);
expect(done.details.state).toMatchObject({ route: "accessibility", native_message: "semantic_element_read_only" });
} finally {
- const view = await live.read(window, ["ui"]);
- await live.insert(`computer:observation/${view.details.observation_id}`, { action: "hotkey", keys: ["alt", "f4"], delivery_mode: "foreground" });
+ await live.resources.input(requireComputerAddress(window), live.cwd, pressPlan({ window, key: "alt+F4", foreground: true }));
}
});
diff --git a/test/live/remote.ts b/test/live/remote.ts
index beabd96..9371d7f 100644
--- a/test/live/remote.ts
+++ b/test/live/remote.ts
@@ -1,3 +1,4 @@
+import { isSemanticAction } from "../../src/semantic-actions.ts";
import { computerSource, displaySource } from "../../src/computer-address.ts";
import type { ComputerAddress } from "../../src/computer-address.ts";
import { ComputerResources, requireComputerAddress } from "../../src/computer-resources.ts";
@@ -33,7 +34,7 @@ export async function connectLive(cwd = process.cwd()) {
const runner = name === "local" ? localRunner(config.interop) : sshRunner((await machineConfig(cwd, name)).ssh);
/**
* One engine command, as the computer_* tools send it: `?hint=` and `?delivery=` on an observation become its ref and
- * delivery_mode, close goes to Delete and kill to Delete with ?force=true, as the tools do.
+ * delivery_mode (semantic actions never take one), close goes to Delete and kill to Delete with ?force=true, as the tools do.
*/
const engine = (path: string, command: Record<string, unknown>, signal?: AbortSignal) => {
const [base, query] = path.split("?");
@@ -41,7 +42,7 @@ export async function connectLive(cwd = process.cwd()) {
if (command.action === "kill") return resources.delete(`${base}?force=true`, cwd, signal);
const options = new URLSearchParams(query ?? "");
const address = { ...at(base), ...(options.get("hint") ? { hint: options.get("hint")! } : {}) } as ComputerAddress;
- const delivery = options.get("delivery");
+ const delivery = isSemanticAction(String(command.action)) ? null : options.get("delivery");
return resources.perform(address, cwd, JSON.stringify(delivery ? { ...command, delivery_mode: delivery } : command), signal);
};
return {