{"record":{"id":"7ca9646b4be7a50a","repo":"jackwener/OpenCLI","slug":"send-button-click-failed","errorCode":null,"errorMessage":"Send button click failed","messagePattern":"Send button click failed","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/kimi/chat.js","lineNumber":278,"sourceCode":"    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(\n        'Kimi message submission was not verified',\n        'The prompt was injected and Send was clicked, but no new user turn containing that prompt appeared.',\n    );","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/kimi/chat.js#L260-L296","documentation":"Thrown when clickBySvgNameScript('Send') fails to find/click Kimi's Send button. It can mean the button was not found in the DOM at all (message empty or still processing) or it was disabled — the actual reason comes from sendRes.reason, with this string as fallback. CommandExecutionError carries that detail.","triggerScenarios":"Send button not present or not clickable: text insertion failed silently, Kimi renders the send icon with a different SVG name, composer disabled, or button located outside the searched DOM subtree.","commonSituations":"Kimi UI update renaming the Send SVG icon; composer in a loading/disabled state right after typing; page not fully hydrated; automation on a non-chat page.","solutions":["Retry the send after a short wait (button may not have been rendered yet).","Verify the text was actually typed into the composer (a failed type leaves nothing to send).","Check the Kimi UI for SVG icon name changes and update clickBySvgNameScript usage ('Send').","Confirm the page is a loaded chat conversation, not a login/redirect page."],"exampleFix":"// before\nawait page.evaluate(clickBySvgNameScript('Send'));\n// after\nawait page.wait(0.5); // allow button to enable after typing\nconst res = await page.evaluate(clickBySvgNameScript('Send'));\nif (!res?.ok) await page.keyboard.press('Enter'); // fallback","handlingStrategy":"retry","validationCode":"const sendReady = await page.evaluate(() => {\n  const btn = document.querySelector('[aria-label*=\"Send\" i], svg[class*=\"send\" i]');\n  return !!btn;\n});\nif (!sendReady) await page.wait(1);","typeGuard":"function clickOk(res) { return !!res && res.ok === true; }","tryCatchPattern":"try {\n  await cli('kimi', 'send', { text });\n} catch (e) {\n  if (/Send button click failed/i.test(e.message)) {\n    await page.wait(1);\n    await cli('kimi', 'send', { text });\n  } else throw e;\n}","preventionTips":["Verify text landed in the composer before expecting Send to work.","Wait for the button to render/enable after typing.","Re-check the Send icon name after Kimi UI updates.","Prefer Enter-key submit as a fallback in your wrapper."],"tags":["dom-scraping","command-execution","kimi"],"backgroundTag":"button-click-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}