{"record":{"id":"af4a1b0fcb0053b6","repo":"Hmbown/CodeWhale","slug":"select-text-is-not-implemented-on-the-win32-backend-yet-fail","errorCode":null,"errorMessage":"select_text is not implemented on the win32 backend yet — fail-closed","messagePattern":"select_text is not implemented on the win32 backend yet — fail-closed","errorType":"exception","errorClass":"ExecError","httpStatus":null,"severity":"warning","filePath":"crates/tui/plugins/computer-use/src/backends/win32.mjs","lineNumber":547,"sourceCode":"Start-Sleep -Milliseconds ${Math.round(d * 1000)};\n${[...keys].reverse().map((code) => event(code, 2)).join(\"\\n\")}\nWrite-Output '{\"ok\": true}';`, { timeoutMs: Math.max(10_000, d * 1000 + 8000) });\n        return { action_sent: true, key, heldSec: d };\n      });\n    },\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}')));","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/plugins/computer-use/src/backends/win32.mjs#L529-L565","documentation":"The win32 backend has not implemented select_text; the method deliberately throws this fail-closed ExecError so callers never silently get a no-op. It is a capability gap of the backend, not a runtime fault — the request was valid but the feature does not exist on this platform yet.","triggerScenarios":"Any call to backend.select_text({...}) on the win32 backend, regardless of arguments. Always and immediately thrown.","commonSituations":"Agents attempting text selection workflows (select then copy) on Windows after they worked on a backend that supports it; generic tool scripts dispatching actions across backends without checking per-backend capability.","solutions":["Use an alternative on win32: shift+arrow keyboard sequences or double-click to select a word, then perform_action/copy.","Gate the caller on backend capability — skip select_text when running on the win32 backend.","Implement the method in win32.mjs using UIA TextPattern if your project needs it, replacing the fail-closed stub."],"exampleFix":"// before\nawait backend.select_text({ target, start, end });\n// after\nif (typeof backend.select_text === 'function' && !backend.selectTextNotImplemented) {\n  await backend.select_text({ target, start, end });\n} else {\n  await backend.key({ keys: ['shift', 'end'] }); // keyboard-based selection\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"const supportsSelectText = (backend) =>\n  backend && backend.backendId !== 'win32' && typeof backend.select_text === 'function';","tryCatchPattern":"if (supportsSelectText(backend)) {\n  await backend.select_text({ target, start, end });\n} else {\n  await backend.key({ keys: ['shift', 'end'] }); // keyboard selection\n}","preventionTips":["Maintain a per-backend capability map and gate feature calls on it.","Treat fail-closed stubs as API contract: never call select_text on win32.","Use keyboard-selection primitives for text selection on Windows.","Track the backend implementation status before porting cross-platform scripts."],"tags":["windows","not-implemented","accessibility","fail-closed"],"backgroundTag":"method-not-implemented","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"}