{"record":{"id":"131051fce1c03dc5","repo":"jackwener/OpenCLI","slug":"midjourney-imagine-composer-was-not-found","errorCode":null,"errorMessage":"Midjourney Imagine composer was not found.","messagePattern":"Midjourney Imagine composer was not found\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/generate.js","lineNumber":161,"sourceCode":"      image: byKind(imageRefs, 'url'),\n      style: [...byKind(styleRefs, 'url'), ...byKind(styleRefs, 'styleCode')],\n      omni: byKind(omniRefs, 'url'),\n    };\n    const effectivePrompt = buildEffectivePrompt(prompt, plan, kwargs, remoteReferences);\n    if (normalizeBoolean(kwargs['dry-run'])) {\n      return [resultBase(plan, { status: 'planned' })];\n    }\n\n    const commandStartedAt = Date.now();\n    await recordQuotaSnapshot(account, 'generate-before');\n    const recent = await fetchHistory(page, account.user_id, 30);\n    const baselineIds = new Set(recent.map((job) => String(job.id || '').toLowerCase()).filter(Boolean));\n    for (const id of await getVisibleJobIds(page).catch(() => [])) baselineIds.add(id);\n\n    try {\n      await page.wait({ selector: COMPOSER_SELECTOR, timeout: 12 });\n    } catch {\n      throw new CommandExecutionError(\n        'Midjourney Imagine composer was not found.',\n        `Open ${MIDJOURNEY_IMAGINE_URL} in Chrome and confirm the signed-in composer is visible.`,\n      );\n    }\n\n    const localImageRefs = byKind(imageRefs, 'local');\n    const localStyleRefs = byKind(styleRefs, 'local');\n    const localOmniRefs = byKind(omniRefs, 'local');\n    // The persistent web composer may contain references staged manually or\n    // left by an interrupted command. Clear it for every paid submission so\n    // an argument-free generation cannot inherit hidden browser state.\n    await clearImagePrompts(page);\n    if (localImageRefs.length || localStyleRefs.length || localOmniRefs.length) {\n      await uploadReferencesToSlot(page, localImageRefs, 'image');\n      await uploadReferencesToSlot(page, localStyleRefs, 'style');\n      await uploadReferencesToSlot(page, localOmniRefs, 'omni');\n    }\n    await closeImagePanel(page);","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/generate.js#L143-L179","documentation":"The generate command drives the Midjourney web UI and must find the prompt composer input (COMPOSER_SELECTOR) before submitting a job. page.wait({ selector, timeout: 12 }) polls for up to 12 seconds; when the composer never appears, a CommandExecutionError is thrown telling the user to open the Imagine page in a signed-in Chrome. This is a UI-automation precondition failure, not an API failure.","triggerScenarios":"COMPOSER_SELECTOR does not match any visible element within 12 seconds after navigating to MIDJOURNEY_IMAGINE_URL — e.g. the user is not signed in, a cookie/login wall or Cloudflare interstitial is shown, the browser session was never established, or Midjourney redesigned the composer markup so the selector no longer matches.","commonSituations":"Expired Midjourney session cookies; running headless/background without ever having logged in interactively; Midjourney UI update changing the composer DOM; slow page load or rate-limit/captcha page replacing the app; running the tool before the persistent browser session exists.","solutions":["Open https://www.midjourney.com/imagine in the managed Chrome window and sign in so the composer is visible","Re-run the command; transient slowness often resolves on retry","Refresh the browser session/cookies for www.midjourney.com (re-authenticate)","Update opencli — a Midjourney DOM change may require a patched COMPOSER_SELECTOR"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Preconditions to check before running generate:\n// 1. Session exists: navigate https://www.midjourney.com/imagine in the managed Chrome and confirm you are signed in (no login wall).\n// 2. Composer visible (mirrors the internal check):\nawait page.wait({ selector: COMPOSER_SELECTOR, timeout: 12 });","typeGuard":"function composerFound(err) {\n  return err instanceof Error && /composer was not found/.test(err.message);\n}","tryCatchPattern":"try {\n  await generate(prompt, opts);\n} catch (e) {\n  if (/composer was not found/.test(e.message)) {\n    await signInAndOpenImagine();  // re-establish session\n    await generate(prompt, opts);  // retry once\n  } else throw e;\n}","preventionTips":["Keep the persistent Chrome session signed in to midjourney.com; re-authenticate when cookies expire","Run `opencli midjourney status` once first as a cheap session health check","Avoid headless usage before completing an interactive login","Keep opencli updated so COMPOSER_SELECTOR tracks Midjourney DOM changes","Retry once on this error before escalating — page loads can be transiently slow"],"tags":["browser-automation","ui-selector","midjourney","session"],"backgroundTag":"selector-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}