Skip to content

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

Close the live locator form and word exists/absent checks plainly (LPT-911)

alexshpunt-clanker[bot]8bfc3eb31d71
diff --git a/src/provider.ts b/src/provider.ts
index 4dbdabb..dddb55d 100644
--- a/src/provider.ts
+++ b/src/provider.ts
@@ -69,7 +69,7 @@ export function presentComputerResult(result: ComputerResult, full = false): str
if (d.dom) lines.push(`Page: ${label(d.dom.title)} | ${label(d.dom.url)} | tab ${d.dom.active ?? "none"}`);
v.conditions.forEach((condition, i) => {
const spec = v.spec.conditions[i];
- const check = spec.is ? `is ${spec.is}` : spec.value !== undefined ? `value = ${JSON.stringify(spec.value)}` : spec.contains !== undefined ? `contains ${JSON.stringify(spec.contains)}`
+ const check = spec.is ? (spec.is === "exists" || spec.is === "absent" ? spec.is : `is ${spec.is}`) : spec.value !== undefined ? `value = ${JSON.stringify(spec.value)}` : spec.contains !== undefined ? `contains ${JSON.stringify(spec.contains)}`
: spec.count !== undefined ? `count = ${spec.count}` : spec.aria !== undefined ? "matches the aria snapshot"
: spec.title !== undefined ? `title = ${JSON.stringify(spec.title)}` : `url contains ${JSON.stringify(spec.url_contains)}`;
const target = spec.target === undefined ? "" : typeof spec.target === "string" ? spec.target + " " : JSON.stringify(spec.target) + " ";
diff --git a/test/live/locators.live.ts b/test/live/locators.live.ts
index f6d48f2..eea738f 100644
--- a/test/live/locators.live.ts
+++ b/test/live/locators.live.ts
@@ -5,9 +5,12 @@ import { presentComputerResult } from "../../src/provider.ts";
// LPT-911: native windows take Playwright locators. Every step is one call on the window address, without a prior Read.
const live = await connectLive();
const fixture = await serveFixture(live.runner);
-afterAll(async () => { await live.close(); fixture.close(); });
-
const title = `Locators ${Date.now()}`;
+// Closing the session leaves app windows open; end the form this check started, found by its unique title.
+afterAll(async () => {
+ await live.powershell(`Get-Process powershell | Where-Object { $_.MainWindowTitle -eq '${title}' } | Stop-Process -Force`).catch(() => "");
+ await live.close(); fixture.close();
+});
const form = `Add-Type -AssemblyName System.Windows.Forms
$f = New-Object Windows.Forms.Form; $f.Text = '${title}'; $f.Width = 520; $f.Height = 420
$b = New-Object Windows.Forms.Button; $b.Text = 'Count 0'; $b.Left = 10; $b.Top = 10; $b.Width = 120; $script:n = 0