jackwener/OpenCLI · error · CommandExecutionError
composer type failed
Error message
composer type failed
What it means
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.
Source
Thrown at clis/kimi/chat.js:275
async function sendKimiMessage(page, text) {
const prompt = String(text || '').trim();
if (!prompt) throw new ArgumentError('text', 'is required');
await ensureOnKimi(page);
const beforeUsers = await page.evaluate(`(() => {
return Array.from(document.querySelectorAll('.chat-content-list .chat-content-item, .message-list > *, .segment'))
.filter((row) => /user|sent-by-user|me-/i.test(String(row.className || ''))).length;
})()`);
const typeRes = await page.evaluate(`(() => {
${IS_VISIBLE_JS}
const editor = document.querySelector('[contenteditable="true"][role="textbox"]');
if (!editor || !isVisible(editor)) return { ok: false, reason: 'Kimi composer not visible.' };
editor.focus();
document.execCommand('selectAll', false);
document.execCommand('insertText', false, ${JSON.stringify(prompt)});
return { ok: true };
})()`);
if (!typeRes?.ok) throw new CommandExecutionError(typeRes?.reason || 'composer type failed', '');
await page.wait(0.3);
const sendRes = await page.evaluate(clickBySvgNameScript('Send'));
if (!sendRes?.ok) throw new CommandExecutionError(sendRes?.reason || 'Send button click failed', '');
const deadline = Date.now() + 3000;
while (Date.now() < deadline) {
const verified = await page.evaluate(`(() => {
const normalize = (value) => String(value || '').replace(/\\u00a0/g, ' ').replace(/\\s+/g, ' ').trim();
const prompt = normalize(${JSON.stringify(prompt)});
const before = Number(${JSON.stringify(beforeUsers)}) || 0;
const rows = Array.from(document.querySelectorAll('.chat-content-list .chat-content-item, .message-list > *, .segment'))
.filter((row) => /user|sent-by-user|me-/i.test(String(row.className || '')));
return rows.slice(before).some((row) => normalize(row.innerText || row.textContent).includes(prompt));
})()`);
if (verified) return { prompt };
await page.wait(0.2);
}
throw new CommandExecutionError(View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before
await cli('kimi', 'send', { text: 'hi' }); // page may still be loading
// after
await page.wait(2);
await cli('kimi', 'send', { text: 'hi' }); Defensive patterns
Strategy: retry
Validate before calling
// confirm we're on a chat page before sending
const onChat = await page.evaluate(() => !!document.querySelector('.chat-content-list, .message-list, .segment'));
if (!onChat) { await ensureOnKimi(page); await page.wait(2); } Type guard
function composerReady(res) { return res && res.ok === true; } Try / catch
try {
await cli('kimi', 'send', { text });
} catch (e) {
if (/composer type failed|not visible/i.test(e.message)) {
await page.wait(3);
await cli('kimi', 'send', { text });
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Send button click failed
- Copy button not visible
- Refresh button not visible
- No messages found in /chat/${id}.
- No chat turns found on current page.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/44628bbe50c690c3.
Report an issue: GitHub.