{"record":{"id":"44628bbe50c690c3","repo":"jackwener/OpenCLI","slug":"composer-type-failed","errorCode":null,"errorMessage":"composer type failed","messagePattern":"composer type failed","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/kimi/chat.js","lineNumber":275,"sourceCode":"\nasync function sendKimiMessage(page, text) {\n    const prompt = String(text || '').trim();\n    if (!prompt) throw new ArgumentError('text', 'is required');\n    await ensureOnKimi(page);\n    const beforeUsers = await page.evaluate(`(() => {\n      return Array.from(document.querySelectorAll('.chat-content-list .chat-content-item, .message-list > *, .segment'))\n        .filter((row) => /user|sent-by-user|me-/i.test(String(row.className || ''))).length;\n    })()`);\n    const typeRes = await page.evaluate(`(() => {\n      ${IS_VISIBLE_JS}\n      const editor = document.querySelector('[contenteditable=\"true\"][role=\"textbox\"]');\n      if (!editor || !isVisible(editor)) return { ok: false, reason: 'Kimi composer not visible.' };\n      editor.focus();\n      document.execCommand('selectAll', false);\n      document.execCommand('insertText', false, ${JSON.stringify(prompt)});\n      return { ok: true };\n    })()`);\n    if (!typeRes?.ok) throw new CommandExecutionError(typeRes?.reason || 'composer type failed', '');\n    await page.wait(0.3);\n    const sendRes = await page.evaluate(clickBySvgNameScript('Send'));\n    if (!sendRes?.ok) throw new CommandExecutionError(sendRes?.reason || 'Send button click failed', '');\n\n    const deadline = Date.now() + 3000;\n    while (Date.now() < deadline) {\n        const verified = await page.evaluate(`(() => {\n      const normalize = (value) => String(value || '').replace(/\\\\u00a0/g, ' ').replace(/\\\\s+/g, ' ').trim();\n      const prompt = normalize(${JSON.stringify(prompt)});\n      const before = Number(${JSON.stringify(beforeUsers)}) || 0;\n      const rows = Array.from(document.querySelectorAll('.chat-content-list .chat-content-item, .message-list > *, .segment'))\n        .filter((row) => /user|sent-by-user|me-/i.test(String(row.className || '')));\n      return rows.slice(before).some((row) => normalize(row.innerText || row.textContent).includes(prompt));\n    })()`);\n        if (verified) return { prompt };\n        await page.wait(0.2);\n    }\n    throw new CommandExecutionError(","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/kimi/chat.js#L257-L293","documentation":"Thrown when the in-page script that types into the Kimi composer reports failure. The script locates the contenteditable editor, checks visibility, focuses it, and uses document.execCommand('insertText'); if the editor is not found/visible, `typeRes.ok` is false and the reason (or this fallback text) is wrapped in CommandExecutionError.","triggerScenarios":"Composer not visible when send is called — wrong page (no Kimi chat UI), composer still loading, composer disabled (`aria-disabled=true`), or a Kimi DOM change that hides/moves the editor.","commonSituations":"Automation landing on a login or redirect page instead of the chat UI; Kimi updating its composer markup; clicking send before hydration; account issue showing a disabled input.","solutions":["Call ensureOnKimi / navigate to an actual Kimi chat page before sending.","Wait a moment for the page to finish loading, then retry the send.","Check the page manually — log in / resolve any interstitial (CAPTCHA, terms, quota).","Inspect typeRes.reason in a debug run to see whether the editor selector needs updating."],"exampleFix":"// before\nawait cli('kimi', 'send', { text: 'hi' }); // page may still be loading\n// after\nawait page.wait(2);\nawait cli('kimi', 'send', { text: 'hi' });","handlingStrategy":"retry","validationCode":"// confirm we're on a chat page before sending\nconst onChat = await page.evaluate(() => !!document.querySelector('.chat-content-list, .message-list, .segment'));\nif (!onChat) { await ensureOnKimi(page); await page.wait(2); }","typeGuard":"function composerReady(res) { return res && res.ok === true; }","tryCatchPattern":"try {\n  await cli('kimi', 'send', { text });\n} catch (e) {\n  if (/composer type failed|not visible/i.test(e.message)) {\n    await page.wait(3);\n    await cli('kimi', 'send', { text });\n  } else throw e;\n}","preventionTips":["Navigate to a real chat page before sending.","Allow settle time after page load.","Resolve login/CAPTCHA/quota interstitials before automation.","Log the in-page reason to detect selector drift early."],"tags":["dom-scraping","command-execution","kimi"],"backgroundTag":"composer-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}