{"record":{"id":"e317a0b09937b8b1","repo":"jackwener/OpenCLI","slug":"claude-composer-is-not-available-on-the-current-pa","errorCode":null,"errorMessage":"Claude composer is not available on the current page.","messagePattern":"Claude composer is not available on the current page\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/claude/utils.js","lineNumber":64,"sourceCode":"            title: document.title,\n            hasComposer: !!composer,\n            isLoggedIn: !!userMenu,\n        };\n    })()`);\n}\n\nexport async function ensureClaudeLogin(page, message = 'Claude requires a logged-in browser session.') {\n    const state = await getPageState(page);\n    if (!state.isLoggedIn) {\n        throw new AuthRequiredError(CLAUDE_DOMAIN, message);\n    }\n    return state;\n}\n\nexport async function ensureClaudeComposer(page, message = 'Claude composer is not available on the current page.') {\n    const state = await ensureClaudeLogin(page, message);\n    if (!state.hasComposer) {\n        throw new CommandExecutionError(message);\n    }\n    return state;\n}\n\nexport function requireNonEmptyPrompt(prompt, commandName) {\n    const text = String(prompt ?? '').trim();\n    if (!text) {\n        throw new ArgumentError(\n            `${commandName} prompt cannot be empty`,\n            `Example: opencli ${commandName} \"hello\"`,\n        );\n    }\n    return text;\n}\n\nexport function requirePositiveInt(value, flagLabel, hint) {\n    if (!Number.isInteger(value) || value < 1) {\n        throw new ArgumentError(`${flagLabel} must be a positive integer`, hint);","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/claude/utils.js#L46-L82","documentation":"opencli's Claude commands drive the Claude web UI via a browser page. Before sending a prompt it verifies the user is logged in and that the message composer input exists on the page. If the composer element is not found (state.hasComposer is false), ensureClaudeComposer throws this CommandExecutionError because no command can proceed without it.","triggerScenarios":"Calling opencli claude ask/new/send when the loaded claude.ai page has no visible message composer: not logged in, a bot-check or interstitial page, session expired mid-flow, or the composer selector no longer matches after a Claude UI update.","commonSituations":"Expired browser session/cookies, running headless against a Cloudflare challenge, Claude product UI redesign changing DOM structure, landing on a page other than the chat surface.","solutions":["Run `opencli claude login` (or the auth flow) to establish a valid session, then retry","Open the page in a normal browser and confirm the composer is visible (complete any login/bot challenge)","Update opencli to the latest version so composer selectors match the current Claude UI","Retry later if Claude is showing an outage/interstitial page"],"exampleFix":"// before\nawait askCommand(page, { prompt: 'hi' }); // throws if session stale\n// after\nawait claudeLogin(page); // refresh session first\nawait askCommand(page, { prompt: 'hi' });","handlingStrategy":"try-catch","validationCode":"// before calling: check session state via the same helper\nconst state = await ensureClaudeLogin(page);\nif (!state.hasComposer) {\n  throw new Error('Composer unavailable; run `opencli claude login` first');\n}","typeGuard":"function hasComposerState(state) {\n  return typeof state === 'object' && state !== null && state.hasComposer === true;\n}","tryCatchPattern":"try {\n  await askCommand(page, { prompt });\n} catch (e) {\n  if (e instanceof CommandExecutionError && /composer is not available/.test(e.message)) {\n    await claudeLogin(page); // refresh session, then retry once\n    await askCommand(page, { prompt });\n  } else throw e;\n}","preventionTips":["Run the login flow before automation and keep the browser profile persistent","Check for bot-check/interstitial pages before invoking commands","Keep opencli updated when Claude ships UI changes","Add a pre-flight screenshot/DOM dump on failure for diagnosis"],"tags":["browser-automation","ui-selector","authentication"],"backgroundTag":"composer-element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}