{"record":{"id":"80c200db3746e408","repo":"Hmbown/CodeWhale","slug":"unsupported-selector","errorCode":"unsupported_selector","errorMessage":"Windows semantic actions do not support explicit application or window selectors","messagePattern":"Windows semantic actions do not support explicit application or window selectors","errorType":"error_code","errorClass":"ExecError","httpStatus":null,"severity":"error","filePath":"crates/tui/plugins/computer-use/src/backends/win32.mjs","lineNumber":104,"sourceCode":"// can never register the User32 type for later spawns. Each User32-backed\n// invocation therefore carries its own type definition via this prelude.\n// Compilation, conversion and native-call exceptions must stop before success.\nconst USER32_PRELUDE = `$ErrorActionPreference = 'Stop';\\nAdd-Type -TypeDefinition @'\\n${USER32}\\n'@ -ErrorAction Stop;`;\n\n/** Coordinate clicks on this backend are always raw pointer events; strategy=\"a11y\" must fail closed rather than silently degrade. */\nfunction assertEventStrategy(strategy) {\n  if (strategy != null && strategy !== \"auto\" && strategy !== \"event\") {\n    throw new ExecError(`strategy \"${strategy}\" is macOS-only; this backend dispatches coordinate clicks as raw pointer events — use an element target for a semantic action`);\n  }\n}\n\nfunction unsupportedSelector(message) {\n  return Object.assign(new ExecError(message), { code: \"unsupported_selector\" });\n}\n\nfunction assertUntargetedElement(target) {\n  if ([\"app_ref\", \"windowIndex\", \"window_id\"].some((key) => Object.hasOwn(target, key))) {\n    throw unsupportedSelector(\"Windows semantic actions do not support explicit application or window selectors\");\n  }\n}\n\nexport function create(opts = {}) {\n  // Allow tests (and other embedders) to inject a runner so no real\n  // powershell.exe is spawned. Production uses the imported runner.\n  const injectedRun = opts.exec && typeof opts.exec.run === \"function\" ? opts.exec.run : null;\n  const runner = injectedRun ?? run;\n\n  function requireInputOwner() {\n    if (opts.exec?.persistentInputOwner !== true) throw Object.assign(new ExecError(\n      \"This held-input gesture requires a connected Codewhale Computer Use desktop helper so a disconnected client cannot leave keys or buttons pressed. Start the helper and reconnect before retrying.\"\n    ), { code: \"input_owner_required\" });\n  }\n\n  async function ps(script, o = {}) {\n    throwIfAborted();\n    const encoded = Buffer.from(script, \"utf16le\").toString(\"base64\");","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/plugins/computer-use/src/backends/win32.mjs#L86-L122","documentation":"The Windows (win32) computer-use backend cannot route semantic actions to a specific application or window because it drives UI Automation through PowerShell with no window-targeting primitive. assertUntargetedElement rejects any target containing app_ref, windowIndex, or window_id with code 'unsupported_selector'. Actions therefore always apply to the currently focused element/desktop context.","triggerScenarios":"Invoking any Windows semantic action with a target object that has an app_ref, windowIndex, or window_id property, e.g. {kind:'click', window_id:123} or {kind:'type', app_ref:{name:'Notepad'}}.","commonSituations":"Sharing one tool-call payload across macOS/Linux/Windows backends where the platform-generic schema allows selectors; porting an automation script written against another OS backend; an agent emitting cross-platform selectors that only some backends support.","solutions":["Remove app_ref/windowIndex/window_id from the target and instead focus the window first (e.g. via a platform-appropriate activate/open step) before performing the action","Branch on platform and use a backend that supports selectors for targeted actions","Update the tool schema on Windows hosts so selector fields are not offered"],"exampleFix":"// before\nawait backend.action({ kind: 'click', window_id: 42 });\n// after\nawait backend.action({ kind: 'activate', name: 'Notepad' }); // focus first, no selector on the action\nawait backend.action({ kind: 'click' });","handlingStrategy":"validation","validationCode":"const UNSUPPORTED = ['app_ref', 'windowIndex', 'window_id'];\nif (UNSUPPORTED.some((k) => Object.hasOwn(target, k)))\n  throw new Error('strip selectors before Windows semantic actions');","typeGuard":"function isUntargeted(target) {\n  return !['app_ref', 'windowIndex', 'window_id'].some((k) => Object.hasOwn(target ?? {}, k));\n}","tryCatchPattern":"try {\n  await backend.action({ kind, ...target });\n} catch (e) {\n  if (e.code === 'unsupported_selector') {\n    await focusWindowFirst();\n    await backend.action({ kind });\n  } else throw e;\n}","preventionTips":["Strip selector fields from action targets on Windows hosts before dispatching","Focus/activate the desired window as a separate step, then send untargeted actions","Keep a per-platform capability map so selector fields are not emitted on win32"],"tags":["windows","win32","selectors","unsupported-platform"],"backgroundTag":"unsupported-operation","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}