{"record":{"id":"db10fb9b86fe8df8","repo":"jackwener/OpenCLI","slug":"failed-to-send-qianwen-image-prompt","errorCode":null,"errorMessage":"Failed to send Qianwen image prompt","messagePattern":"Failed to send Qianwen image prompt","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/qwen/image.js","lineNumber":136,"sourceCode":"        const skipDownload = normalizeBooleanFlag(kwargs.sd, false);\n        const timeout = Number(kwargs.timeout ?? 180);\n        if (!Number.isInteger(timeout) || timeout <= 0) {\n            throw new ArgumentError('timeout must be a positive integer');\n        }\n\n        await ensureOnQianwen(page);\n        await dismissLoginModal(page);\n        if (startFresh) {\n            await startNewChat(page);\n            await dismissLoginModal(page);\n        }\n        await setFeatureToggle(page, 'image', true);\n        await page.wait(0.5);\n\n        const send = await sendMessage(page, prompt);\n        if (!send?.ok) {\n            if (await hasLoginGate(page)) throw authRequired();\n            throw new CommandExecutionError(send?.reason || 'Failed to send Qianwen image prompt');\n        }\n\n        // Grab the newest assistant bubble id after send by polling briefly\n        let targetId = '';\n        for (let i = 0; i < 5; i += 1) {\n            await page.wait(1);\n            const bubbles = await getMessageBubbles(page);\n            const lastAnswer = [...bubbles].reverse().find((b) => b.role === 'Assistant');\n            if (lastAnswer) { targetId = lastAnswer.id; break; }\n        }\n\n        const waitResult = await waitForImageUrls(page, targetId, timeout);\n        const link = await page.evaluate('window.location.href').catch(() => 'https://www.qianwen.com/');\n        if (waitResult.status === 'auth_required') throw authRequired();\n        if (waitResult.status === 'timeout') {\n            throw new TimeoutError('qianwen image', timeout, 'No generated images observed before timeout.');\n        }\n","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qwen/image.js#L118-L154","documentation":"After toggling image mode, clis/qwen/image.js calls sendMessage(page, prompt); if the result lacks ok:true it throws CommandExecutionError with the sender's reason, or the generic 'Failed to send Qianwen image prompt' when no reason is given. A login gate on the page is checked first and surfaced as an auth error instead. This indicates the prompt never reached the chat.","triggerScenarios":"sendMessage fails to locate the input box or submit button, the page DOM changed, the session was logged out mid-flow (and hasLoginGate misses it), or the composer is disabled while a previous request is still generating.","commonSituations":"Qianwen frontend update renaming composer selectors; expired cookies so the send button no-ops; sending a new image prompt while the previous generation is still running; network hiccup during page load.","solutions":["Re-run after confirming you are logged in to qianwen.com in the automation browser (check for the login modal/gate)","Start a fresh chat (the command's new flag defaults true) so the composer is idle and enabled","Retry once after a short wait — transient DOM/network flakiness is common","If it persists, inspect the page: the send-button/input selectors in sendMessage likely need updating after a site update"],"exampleFix":"// before\nclis qwen image --prompt 'sunset'   # fails mid-session with stale composer\n// after\nclis qwen image --prompt 'sunset' --new true   # force fresh chat before sending","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await runQianwenImage(prompt);\n} catch (e) {\n  if (/Failed to send Qianwen image prompt/.test(e.message)) {\n    await ensureLoggedIn(page);            // re-check login state\n    await sleep(2000);                     // brief backoff for transient DOM flake\n    await runQianwenImage(prompt);         // single retry, fresh chat\n  } else throw e;\n}","preventionTips":["Confirm the automation browser has an active qianwen.com session before running","Always start from a fresh chat so the composer is idle and enabled","Avoid sending while a previous generation is still in progress","Update selectors in sendMessage promptly after Qianwen UI changes"],"tags":["browser-automation","dom","send-failure"],"backgroundTag":"message-send-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}