{"record":{"id":"7889dded3688e23a","repo":"Hmbown/CodeWhale","slug":"unsupported-uia-action","errorCode":null,"errorMessage":"unsupported UIA action","messagePattern":"unsupported UIA action","errorType":"exception","errorClass":"ExecError","httpStatus":null,"severity":"error","filePath":"crates/tui/plugins/computer-use/src/backends/win32.mjs","lineNumber":552,"sourceCode":"    },\n    set_value: async ({ target, value }) => {\n      const resolve = elementScript(target);\n      const b64 = Buffer.from(String(value ?? \"\"), \"utf16le\").toString(\"base64\");\n      const j = await psJson(`${resolve}\n$val = [Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('${b64}'));\n$vp = $cur.GetCurrentPattern([System.Windows.Automation.ValuePattern]::Pattern);\nif ($vp.Current.IsReadOnly) { throw 'element_read_only' }\n$vp.SetValue($val);\n@{ ok = $true; verified = ($vp.Current.Value -ceq $val) } | ConvertTo-Json -Compress;`, { timeoutMs: 45_000 });\n      if (!j.ok) throw new ExecError(\"set_value failed\");\n      return { action_sent: true, strategy: \"a11y\", verified: j.verified === true };\n    },\n    select_text: async () => { throw new ExecError(\"select_text is not implemented on the win32 backend yet — fail-closed\"); },\n    perform_action: async ({ target, action = \"Invoke\" }) => {\n      const resolve = elementScript(target);\n      const actions = { invoke: [\"Invoke\", \"Invoke\"], click: [\"Invoke\", \"Invoke\"], toggle: [\"Toggle\", \"Toggle\"], expand: [\"ExpandCollapse\", \"Expand\"], expandcollapse: [\"ExpandCollapse\", \"Expand\"], collapse: [\"ExpandCollapse\", \"Collapse\"], select: [\"SelectionItem\", \"Select\"], selectionitem: [\"SelectionItem\", \"Select\"] };\n      const chosen = actions[String(action).toLowerCase()];\n      if (!chosen) throw new ExecError(\"unsupported UIA action\");\n      await psOk(`${resolve}\n$pattern = $cur.GetCurrentPattern([System.Windows.Automation.${chosen[0]}Pattern]::Pattern);\n$pattern.${chosen[1]}();`, { timeoutMs: 45_000 });\n      return { action_sent: true, strategy: \"a11y\", action };\n    },\n    read_clipboard: async () => {\n      const j = await psJson(`$t = Get-Clipboard -Raw -ErrorAction SilentlyContinue;\n@{ text = [string]$t } | ConvertTo-Json -Compress;`, { timeoutMs: 10_000 });\n      return { text: j.text ?? \"\", encoding: \"utf8\" };\n    },\n    write_clipboard: async ({ text }) => {\n      const b64 = Buffer.from(String(text ?? \"\"), \"utf16le\").toString(\"base64\");\n      await psOk(`Set-Clipboard -Value ([System.Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('${b64}')));\nWrite-Output '{\"ok\": true}';`, { timeoutMs: 10_000 });\n      return { written: String(text ?? \"\").length };\n    },\n    cursor_position: async () => {\n      const j = await psJson(`${USER32_PRELUDE}","sourceCodeStart":534,"sourceCodeEnd":570,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/plugins/computer-use/src/backends/win32.mjs#L534-L570","documentation":"perform_action on the win32 backend maps a whitelisted action name (invoke, click, toggle, expand, collapse, select, and case variants) onto UI Automation patterns. Any other string — or a misspelling — fails this lookup and throws. It is an input validation error on the action parameter.","triggerScenarios":"Calling perform_action with action set to anything outside the mapping, e.g. 'check', 'focus', 'ExpandCollapse', 'scroll', or a typo like 'invke'; also when action is a non-string that String()ifies to an unmapped value.","commonSituations":"Scripts written against another backend's richer action vocabulary (e.g. check/uncheck or focus actions) being reused on win32; case/spacing mistakes; passing the UIA pattern name instead of the logical action name.","solutions":["Use one of the supported action names: invoke, click, toggle, expand, expandcollapse, collapse, select (case-insensitive).","Map your action before calling: e.g. 'check' → 'toggle', 'focus' → 'invoke' where semantically valid.","Validate action strings against the supported list before dispatching to avoid wasted 45s PowerShell calls."],"exampleFix":"// before\nawait backend.perform_action({ target, action: 'check' }); // throws\n// after\nconst supported = ['invoke','click','toggle','expand','expandcollapse','collapse','select'];\nconst act = supported.includes(String(action).toLowerCase()) ? action : 'toggle';\nawait backend.perform_action({ target, action: act });","handlingStrategy":"validation","validationCode":"const SUPPORTED_UIA_ACTIONS = ['invoke','click','toggle','expand','expandcollapse','collapse','select'];\nfunction assertUiaAction(action) {\n  if (!SUPPORTED_UIA_ACTIONS.includes(String(action).toLowerCase()))\n    throw new Error(`unsupported UIA action: ${action}`);\n}","typeGuard":"const isSupportedAction = (a) => ['invoke','click','toggle','expand','expandcollapse','collapse','select']\n  .includes(String(a).toLowerCase());","tryCatchPattern":"try {\n  await backend.perform_action({ target, action });\n} catch (e) {\n  if (e.message === 'unsupported UIA action') throw new Error(`action ${action} not supported on win32; use invoke/toggle/expand/collapse/select`);\n  throw e;\n}","preventionTips":["Normalize and whitelist action names before dispatching to perform_action.","Map cross-backend action vocabularies (check→toggle, focus→invoke) explicitly.","Never pass raw UIA pattern names as the action string.","Unit-test the action-name mapping used by your agent scripts."],"tags":["windows","uia","validation","invalid-argument"],"backgroundTag":"invalid-enum-value","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T16:17:23.217Z"}