{"record":{"id":"078107904c48abd0","repo":"Hmbown/CodeWhale","slug":"clipboard-write-is-not-exposed-by-hdc-on-current-harmonyos","errorCode":null,"errorMessage":"clipboard write is not exposed by hdc on current HarmonyOS builds","messagePattern":"clipboard write is not exposed by hdc on current HarmonyOS builds","errorType":"exception","errorClass":"ExecError","httpStatus":null,"severity":"error","filePath":"crates/tui/plugins/computer-use/src/backends/harmonyos.mjs","lineNumber":270,"sourceCode":"      if (String(text).toLowerCase() !== \"click\") throw new ExecError('hold_key on harmony supports only hold_key({\"text\":\"click\"}) = longClick');\n      const d = Math.max(1, Math.min(5, Number(duration) || 1));\n      return uiInput([\"longClick\", \"300\", \"300\"]);\n    },\n    set_value: async ({ target, value }) => {\n      const b = await centerOf(target);\n      await uiInput([\"click\", String(b.cx), String(b.cy)]);\n      await new Promise((r) => setTimeout(r, 300));\n      await uiInput([\"inputText\", String(b.cx), String(b.cy), escDeviceText(String(value))]);\n      return { action_sent: true, strategy: \"uitest-element\" };\n    },\n    select_text: async () => { throw new ExecError(\"select_text is not exposed by uitest dumpLayout/uiInput on the harmony backend\"); },\n    perform_action: async ({ target, action }) => {\n      const b = await centerOf(target);\n      if (action === \"longClick\") return uiInput([\"longClick\", String(b.cx), String(b.cy)]);\n      return uiInput([\"click\", String(b.cx), String(b.cy)]);\n    },\n    read_clipboard: async () => { throw new ExecError(\"clipboard read is not exposed by hdc on current HarmonyOS builds\"); },\n    write_clipboard: async () => { throw new ExecError(\"clipboard write is not exposed by hdc on current HarmonyOS builds\"); },\n    cursor_position: async () => { throw new ExecError(\"cursor position does not exist on touch devices\"); },\n    recordingStart: async ({ intervalMs = 400 } = {}) => {\n      if (recording) throw new ExecError(`recording ${recording.id} already running`);\n      if (!(await have(\"ffmpeg\"))) throw new ExecError(\"ffmpeg is required on the host to mux harmony snapshot-series recordings\");\n      const id = crypto.randomBytes(4).toString(\"hex\");\n      const dir = fs.mkdtempSync(path.join(os.tmpdir(), `cu-rec-${id}-`));\n      const startedAt = new Date().toISOString();\n      const rec = recording = { id, dir, startedAt, intervalMs, seq: 0, controller: new AbortController() };\n      const tick = () => {\n        if (rec.stopped || rec.pending) return rec.pending;\n        rec.pending = (async () => {\n          const opts = { timeoutMs: 15_000, signal: rec.controller.signal };\n          const remote = `${DEVICE_TMP}-rec-${id}-${String(rec.seq).padStart(5, \"0\")}.jpeg`;\n          try {\n            await deviceOut([\"snapshot_display\", \"-f\", remote], opts);\n            await exec.pullFile(remote, path.join(dir, `f${String(rec.seq).padStart(5, \"0\")}.jpeg`), opts);\n            rec.seq++;\n          } finally { await shell([\"rm\", \"-f\", remote], opts).catch(() => {}); }","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/plugins/computer-use/src/backends/harmonyos.mjs#L252-L288","documentation":"Writing the device clipboard is not possible through hdc's uitest interface on current HarmonyOS builds, symmetric with read_clipboard. The backend throws this ExecError unconditionally instead of attempting a non-existent command.","triggerScenarios":"Calling write_clipboard(\"text\") on the harmonyos backend, typically to stage data before a paste action in the app under test.","commonSituations":"Setup steps that seed the clipboard for paste-into-field tests; scripts ported from Android backends where clipboard write exists; cross-platform automation frameworks sharing one clipboard-based helper.","solutions":["Deliver text directly into the field with set_value or the text/input action instead of paste","If paste flow must be tested, type the clipboard content into another field of the app and use the app's own copy UI","Gate clipboard-write steps by backend and skip them on harmonyos"],"exampleFix":"// before\nawait backend.write_clipboard(\"hello\");\nawait backend.key({ text: \"enter\" }); // paste flow\n// after\nawait backend.set_value({ target: \"#field\", value: \"hello\" });","handlingStrategy":"fallback","validationCode":"if (backend.name === \"harmonyos\") {\n  // clipboard write unsupported: use set_value / inputText instead\n}","typeGuard":null,"tryCatchPattern":"try {\n  await backend.write_clipboard(text);\n} catch (e) {\n  if (String(e.message).includes(\"clipboard write is not exposed by hdc\")) await backend.set_value({ target, value: text });\n  else throw e;\n}","preventionTips":["Seed field content with set_value instead of clipboard+paste","Skip clipboard-setup steps on harmonyos in shared test suites","Check hdc/uitest release notes before re-enabling clipboard actions"],"tags":["harmonyos","clipboard","platform-limitation"],"backgroundTag":"unsupported-platform","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"}