{"record":{"id":"43d0d3ac7a17524d","repo":"Hmbown/CodeWhale","slug":"wtype-failed-r-stderr-slice-0-200","errorCode":null,"errorMessage":"wtype failed: ${r.stderr.slice(0, 200)}","messagePattern":"wtype failed: (.+?)","errorType":"exception","errorClass":"ExecError","httpStatus":null,"severity":"error","filePath":"crates/tui/plugins/computer-use/src/backends/linux.mjs","lineNumber":659,"sourceCode":"          if (chunk.codePointAt(0) > 127) {\n            const hex = chunk.codePointAt(0).toString(16).toUpperCase().padStart(4, \"0\");\n            const shift = chunk !== chunk.toLowerCase() ? \"shift+\" : \"\";\n            await xdotool([\"key\", `${shift}U${hex}`]);\n            // Each temp remap restores the keymap as soon as the event is\n            // queued; a lagging app can then read the press against the\n            // restored map and drop it. A short settle narrows that window.\n            // Under heavy host saturation XTEST drops remain possible — that\n            // residual is documented in the suite's known_limitations.\n            await new Promise((r) => setTimeout(r, 30));\n          } else {\n            await xdotool([\"type\", \"--delay\", \"12\", \"--\", chunk]);\n          }\n        }\n        return { action_sent: true, chars: text.length };\n      }\n      need(\"wtype\", \"typing on Wayland\");\n      const r = await run(\"wtype\", [\"--\", String(text)], { timeoutMs: 15_000 });\n      if (r.code !== 0) throw new ExecError(`wtype failed: ${r.stderr.slice(0, 200)}`, r);\n      return { action_sent: true, chars: text.length };\n    },\n    key: async ({ text, repeat = 1 }) => {\n      await probeSession();\n      const k = xdotoolKey(text);\n      const n = Math.max(1, Math.min(100, Number(repeat) || 1));\n      if (session === \"x11\") {\n        throwIfAborted();\n        heldKeys.add(k);\n        try {\n          await xdotool([\"key\", \"--repeat\", String(n), \"--delay\", \"60\", k]);\n          heldKeys.delete(k);\n        } finally { await releaseKey(k); }\n      } else await waylandKey(text, { repeat: n });\n      return { action_sent: true, key: k };\n    },\n    hold_key: async ({ text, duration }) => {\n      requireInputOwner();","sourceCodeStart":641,"sourceCodeEnd":677,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/plugins/computer-use/src/backends/linux.mjs#L641-L677","documentation":"On Wayland, typing is delegated to the wtype utility; this error is thrown when wtype exits non-zero and includes its first 200 bytes of stderr. It means wtype itself failed — not that the backend refused — usually due to missing input-method/virtual-keyboard protocol support or a bad character for the current keymap.","triggerScenarios":"wtype not granted the virtual-keyboard protocol (compositor rejects: sway needs no config but some compositors restrict it; hyprland fine, but sandboxed/flatpak contexts blocked); typing characters not representable in the active keymap/layout; wtype binary present but the session lacks zwp_virtual_keyboard_manager; running under a compositor without virtual keyboard support.","commonSituations":"Flatpak/sandboxed environments where Wayland protocol sockets are restricted; non-US keymaps choking on specific Unicode; headless Wayland (cage, gamescope) without keyboard protocol; wtype installed but ydotoold/uinput permissions missing — though wtype uses libxkbcommon + virtual keyboard directly.","solutions":["Read the stderr excerpt in the message for the exact wtype complaint.","Test manually: wtype -- 'hello' in a terminal on the same session to reproduce.","Ensure the compositor allows the virtual-keyboard protocol and the client can access the Wayland socket (WAYLAND_DISPLAY set, not sandboxed).","Switch keyboard layout or strip unsupported characters; alternatively run the app under XWayland and use the xdotool typing path."],"exampleFix":"// before\nawait backend.type({ text: 'naïve café' }); // fails under restricted keymap\n// after\nconst ascii = text.normalize('NFD').replace(/[^\\x20-\\x7E]/g, '');\nawait backend.type({ text: ascii }); // or fix wtype/Wayland env first","handlingStrategy":"try-catch","validationCode":"const chk = spawnSync('wtype', ['--', ''], { env: process.env });\nif (chk.error || chk.status !== 0) throw new Error('wtype unavailable or blocked: ' + chk.stderr);","typeGuard":null,"tryCatchPattern":"try {\n  await backend.type({ text });\n} catch (e) {\n  if (String(e.message).startsWith('wtype failed:')) {\n    // sanitize text or fall back to clipboard paste\n    await setClipboard(text);\n    await backend.key({ text: 'ctrl+v' });\n    return;\n  }\n  throw e;\n}","preventionTips":["Test wtype from a terminal in the same session before automating","Avoid characters unsupported by the active keymap, or normalize text first","Don't run automation inside sandboxes that block Wayland virtual-keyboard protocol"],"tags":["wayland","wtype","typing","linux","external-tool"],"backgroundTag":"command-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T21:17:16.096Z"}