jackwener/OpenCLI · error · CommandExecutionError

Midjourney Creation Action unavailable: ${target?.reason ||

Error message

Midjourney Creation Action unavailable: ${target?.reason || text}

What it means

CommandExecutionError thrown when the in-page button lookup for a Creation Action fails: the labeled button occurrence was not found or is disabled. target?.reason explains which (e.g. 'button Create occurrence 2 not found', 'button Create is disabled'); falls back to the search text.

Source

Thrown at clis/midjourney/utils.js:1219

  const target = unwrapEvaluateResult(await page.evaluate((label, wantedIndex) => {
    const visible = (element) => {
      const rect = element.getBoundingClientRect();
      const style = getComputedStyle(element);
      return rect.width > 0 && rect.height > 0 && style.visibility !== 'hidden' && style.display !== 'none';
    };
    const close = [...document.querySelectorAll('button[title="Close"]')].filter(visible).at(-1);
    const scope = close?.parentElement?.parentElement;
    if (!scope) return { ok: false, reason: 'job detail scope not found' };
    const matches = [...scope.querySelectorAll('button')]
      .filter(visible)
      .filter((button) => String(button.textContent || '').replace(/\s+/g, ' ').trim() === label);
    const button = matches[wantedIndex];
    if (!button) return { ok: false, reason: `button ${label} occurrence ${wantedIndex} not found`, count: matches.length };
    if (button.disabled) return { ok: false, reason: `button ${label} is disabled`, count: matches.length };
    const rect = button.getBoundingClientRect();
    return { ok: true, x: rect.left + rect.width / 2, y: rect.top + rect.height / 2, count: matches.length };
  }, normalizeButtonText(text), occurrence));
  if (!target?.ok) throw new CommandExecutionError(`Midjourney Creation Action unavailable: ${target?.reason || text}`);
  if (typeof page.nativeClick !== 'function') throw new CommandExecutionError('Browser Bridge native click support is required for Creation Actions');
  await page.nativeClick(target.x, target.y);
  return target;
}

export async function clickVisibleControl(page, label) {
  const target = unwrapEvaluateResult(await page.evaluate((wanted) => {
    const visible = (element) => {
      const rect = element.getBoundingClientRect();
      return rect.width > 0 && rect.height > 0 && getComputedStyle(element).display !== 'none';
    };
    const button = [...document.querySelectorAll('button')].find((node) => visible(node) && (
      node.textContent?.trim().replace(/\s+/g, ' ') === wanted
      || node.title === wanted
      || node.getAttribute('aria-label') === wanted
    ));
    if (!button || button.disabled) return null;
    const rect = button.getBoundingClientRect();

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Reduce the occurrence index or verify how many matching buttons exist (target.count in reason).
  2. Wait for the current job to finish before clicking disabled action buttons.
  3. Verify button label text against the live UI and update the call.
  4. Reload the page and ensure the composer/creation view is open.

Example fix

// before
await clickCreationAction(page, 'Create', 2);
// after
const count = await countButtons(page, 'Create');
if (count > 1) await clickCreationAction(page, 'Create', 1);
Defensive patterns

Strategy: validation

Validate before calling

const count = await page.evaluate((label) =>
  [...document.querySelectorAll('button')].filter(b => b.textContent?.trim() === label).length, 'Create');
if (occurrence >= count) throw new Error(`Only ${count} matching buttons`);

Try / catch

try {
  await clickCreationAction(page, 'Create', idx);
} catch (err) {
  if (String(err.message).includes('unavailable')) {
    await page.wait(3); // job may still be running
    await clickCreationAction(page, 'Create', 0);
  } else throw err;
}

Prevention

When it happens

Trigger: clickCreationAction(page, label, occurrence) when fewer buttons match than the requested occurrence index, or the matched button has disabled=true.

Common situations: Requesting occurrence 2 of 'Create' when only one exists; job still running so the action button is disabled; Midjourney changed button labels; composer not open.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/2b58634227ee8662. Report an issue: GitHub.