{"record":{"id":"3910f1ef4567b28d","repo":"jackwener/OpenCLI","slug":"chatgpt-composer-is-not-available-on-the-current-p","errorCode":null,"errorMessage":"ChatGPT composer is not available on the current page.","messagePattern":"ChatGPT composer is not available on the current page\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/chatgpt/utils.js","lineNumber":373,"sourceCode":"            hasComposer,\n            isLoggedIn: hasComposer || !!userMenu || !hasLoginGate,\n            hasLoginGate,\n        };\n    })()`)), 'chatgpt page state');\n}\n\nexport async function ensureChatGPTLogin(page, message = 'ChatGPT requires a logged-in browser session.') {\n    const state = await getPageState(page);\n    if (!state.isLoggedIn || state.hasLoginGate) {\n        throw new AuthRequiredError(CHATGPT_DOMAIN, message);\n    }\n    return state;\n}\n\nexport async function ensureChatGPTComposer(page, message = 'ChatGPT composer is not available on the current page.') {\n    const state = await ensureChatGPTLogin(page, message);\n    if (!state.hasComposer) {\n        throw new CommandExecutionError(message);\n    }\n    return state;\n}\n\nfunction requireKnownChatGPTModel(model) {\n    const key = String(model ?? '').trim().toLowerCase();\n    const targetKey = CHATGPT_MODEL_ALIASES[key] || key;\n    const option = CHATGPT_MODEL_TARGETS[targetKey];\n    if (!option) {\n        throw new ArgumentError(\n            `Unknown ChatGPT model \"${model}\"`,\n            `Choose one of: ${CHATGPT_MODEL_CHOICES.join(', ')}`,\n        );\n    }\n    return { key: targetKey, alias: key !== targetKey ? key : null, ...option };\n}\n\nfunction requireKnownChatGPTTool(tool) {","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatgpt/utils.js#L355-L391","documentation":"ensureChatGPTLogin confirmed the user is on ChatGPT but no composer input element was found on the page, so the library throws CommandExecutionError with this message. The composer (the contenteditable prompt textbox) is required for ask/new/send commands; without it the CLI cannot type the prompt. The library treats this as an automation precondition failure, not a code bug.","triggerScenarios":"Calling askCommand, newCommand, or sendCommand (or selectChatGPTModel/selectChatGPTTool, which call ensureChatGPTComposer with a custom message) when the rendered ChatGPT page has no element matching COMPOSER_SELECTORS — e.g. a mid-flow captcha, a UI variant without the prompt-textarea, a paywall/upgrade interstitial, or the page failing to finish loading before the composer check.","commonSituations":"ChatGPT rolls out a DOM change that renames the composer testid/aria-label; headless browser stuck on a Cloudflare/captcha screen; logged in but landing on a page that redirects away from the composer; slow network so the SPA hasn't rendered the composer when checked; user logged into a workspace showing an admin/SSO interstitial.","solutions":["Run the command again after waiting — transient slow renders often produce this.","Open https://chatgpt.com in the same browser profile and confirm the composer is actually visible while logged in.","Dismiss any captcha/Cloudflare challenge or upgrade/paywall dialog blocking the composer.","Check for a ChatGPT UI update or library update; update the opencli package so COMPOSER_SELECTORS match the current DOM.","Set OPENCLI_CHATGPT_MODEL_DEBUG=1 to see which automation step is failing and inspect the page state."],"exampleFix":"// before\nawait askCommand({ prompt: 'hi' }); // throws if composer missing\n// after\ntry {\n  await askCommand({ prompt: 'hi' });\n} catch (err) {\n  if (err.message.includes('composer is not available')) {\n    await page.goto('https://chatgpt.com');\n    await page.wait(2);\n    return askCommand({ prompt: 'hi' });\n  }\n  throw err;\n}","handlingStrategy":"try-catch","validationCode":"const state = await chatgpt.getLoginState(page);\nif (!state.loggedIn || !state.hasComposer) {\n  await page.goto('https://chatgpt.com');\n  await page.wait(2);\n}","typeGuard":"function hasComposer(state) {\n  return typeof state === 'object' && state !== null && state.hasComposer === true;\n}","tryCatchPattern":"try {\n  await askCommand({ prompt });\n} catch (err) {\n  if (err instanceof CommandExecutionError && /composer is not available/.test(err.message)) {\n    await page.goto('https://chatgpt.com');\n    await page.wait(2);\n    return askCommand({ prompt }); // one retry\n  }\n  throw err;\n}","preventionTips":["Reuse a logged-in browser profile with the composer visible before automating.","Add a short settle wait after navigation so the SPA renders the composer.","Pin/track library updates for ChatGPT DOM selector changes.","Handle captcha/Cloudflare screens out-of-band before running commands."],"tags":["browser-automation","chatgpt","dom-selector","ui-change"],"backgroundTag":"dom-element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}