Hmbown/CodeWhale · error
Windows get_app_state does not support window_id
Error message
Windows get_app_state does not support window_id
What it means
On Windows, get_app_state inspects one application's UIA tree but cannot address a specific window by id; it throws unsupportedSelector when window_id is present. The backend supports selecting the app only by exact window title via app_ref.name.
Solutions
- Remove window_id and pass app_ref: { name: <exact window title> } instead.
- Get the exact title from list_windows or list_apps.title first.
- If the app has multiple windows, note that the backend matches by title filter only; disambiguate by title text.
- On macOS, window_id remains supported — gate the call on process.platform or backend name.
Example fix
// before
await computerUse({ action: "get_app_state", app_ref: { name: "Notepad" }, window_id: 42 });
// after
await computerUse({ action: "get_app_state", app_ref: { name: "Notepad" } }); Defensive patterns
Strategy: validation
Validate before calling
if (args.window_id != null) throw new Error("win32 get_app_state: drop window_id, use app_ref.name"); Type guard
const winSafeAppStateArgs = (a) => a != null && a.window_id === undefined && typeof a.app_ref?.name === "string" && a.app_ref.name.trim().length > 0;
Try / catch
try { await getAppState(args) } catch (e) { if (String(e.message).includes("does not support window_id")) { delete args.window_id; await getAppState(args); } else throw e; } Prevention
- Never persist window ids across platforms; resolve titles instead
- Look up the exact window title with list_windows/list_apps before get_app_state
- Gate selector usage on the active backend
When it happens
Trigger: Calling get_app_state with window_id set (e.g. an id previously returned by list_windows on another platform).
Common situations: Cross-platform scripts carrying macOS window ids into the Windows backend; agents caching window ids across calls; treating list_windows output ids as stable handles on Windows.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Windows get_app_state supports only app_ref
- Windows list_windows does not support app_ref or window_id…
- Windows screenshot does not support app_ref or window_id…
- application window not found in UIA tree — pass…
- set_value failed
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/0861437851d2f3fb.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/plugins/computer-use/src/backends/win32.mjs:358
let argumentsScript = "";
if (urlArg != null) {
if (typeof urlArg !== "string" || !URL.canParse(urlArg) || /[\0\r\n]/.test(urlArg)) throw new ExecError("open_application url must be an absolute URL");
// Start-Process joins ArgumentList into a Windows command line. Quote
// one argument there, and transport that string as data into PowerShell.
const quoted = '"' + urlArg.replace(/(\\*)"/g, '$1$1\\"').replace(/(\\+)$/g, '$1$1') + '"';
const encoded = Buffer.from(quoted, "utf16le").toString("base64");
argumentsScript = `$launchArg = [Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('${encoded}')); `;
}
// activate defaults to background on every platform: a minimized
// launch leaves the user's foreground window alone. Windows input is
// still shared-surface — this only controls the launch, not input.
const windowStyle = activate === true ? "" : " -WindowStyle Minimized";
const r = await psOk(`${argumentsScript}Start-Process -FilePath "${target}"${windowStyle}${urlArg != null ? " -ArgumentList $launchArg" : ""}; Write-Output '{"launched": true}'`, { timeoutMs: 20_000 });
if (r.code !== 0) throw new ExecError(`Start-Process failed: ${r.stderr.trim().slice(0, 200)}`, r);
return { launched: true, name: target, url: urlArg ?? null, activate: activate === true };
},
get_app_state: async (args = {}) => {
if (Object.hasOwn(args, "window_id")) throw unsupportedSelector("Windows get_app_state does not support window_id");
const { app_ref, detail } = args;
if (Object.hasOwn(args, "app_ref") && (!app_ref || typeof app_ref !== "object" || Array.isArray(app_ref)
|| Object.keys(app_ref).length !== 1 || !Object.hasOwn(app_ref, "name") || typeof app_ref.name !== "string" || !app_ref.name.trim())) {
throw unsupportedSelector("Windows get_app_state supports only app_ref: { name: exact window title }; PID, bundle_id and other references are unsupported");
}
const filter = Buffer.from(app_ref?.name ?? "", "utf16le").toString("base64");
const maxEls = detail === "full" ? 800 : 400;
const j = await psJson(`${UIA_PRELUDE}
$max = ${maxEls};
$filter = [Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('${filter}'));
$root = [System.Windows.Automation.AutomationElement]::RootElement;
$els = New-Object System.Collections.ArrayList;
$found = $false; $truncated = $false; $appName = $null;
$targets = @($root.FindAll([System.Windows.Automation.TreeScope]::Children, [System.Windows.Automation.Condition]::TrueCondition));
if ($filter) {
$targets = @($targets | Where-Object { [string]::Equals($_.Current.Name, $filter, [StringComparison]::OrdinalIgnoreCase) });
if ($targets.Count -gt 1) { throw 'More than one application window has this exact name' }
}View on GitHub (pinned to 73e0f67d83)