jackwener/OpenCLI · error · CommandExecutionError

Instagram reel editor did not appear

Error message

Instagram reel editor did not appear

What it means

waitForReelStage polls buildInspectReelStageJs() twice per second for maxWaitSeconds until the detected stage equals `expected`. If the inspector reports state 'failed', it throws CommandExecutionError('Instagram reel editor did not appear') carrying Instagram's dialog detail. This means the reel flow explicitly broke before reaching the requested editor stage.

Source

Thrown at clis/instagram/reel.js:278

        return { state: 'composer', detail: text };
      }
      if (/edit|cover photo|trim|video has no audio/.test(lower) && hasVisibleButton(['next'])) {
        return { state: 'edit', detail: text };
      }
      if (/crop|select crop|open media gallery/.test(lower) && hasVisibleButton(['next'])) {
        return { state: 'crop', detail: text };
      }
      return { state: 'pending', detail: text };
    })()
  `;
}
async function waitForReelStage(page, expected, maxWaitSeconds = 20) {
    for (let attempt = 0; attempt < maxWaitSeconds * 2; attempt += 1) {
        const result = await page.evaluate(buildInspectReelStageJs());
        if (result?.state === expected)
            return;
        if (result?.state === 'failed') {
            throw new CommandExecutionError('Instagram reel editor did not appear', result.detail ? `Instagram reel flow failed: ${result.detail}` : 'Instagram reel flow failed before the next editor stage');
        }
        if (attempt < maxWaitSeconds * 2 - 1)
            await page.wait({ time: 0.5 });
    }
    throw new CommandExecutionError(`Instagram reel ${expected} editor did not appear`);
}
async function focusCaptionEditor(page) {
    const result = await page.evaluate(`
    (() => {
      const isVisible = (el) => {
        if (!(el instanceof HTMLElement)) return false;
        const style = window.getComputedStyle(el);
        const rect = el.getBoundingClientRect();
        return style.display !== 'none'
          && style.visibility !== 'hidden'
          && rect.width > 0
          && rect.height > 0;
      };

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the detail message: it contains Instagram's failure dialog text.
  2. Check the account for action blocks/rate limits and slow down posting frequency.
  3. Re-authenticate the browser session (cookies/login) if the flow died on a login wall.
  4. Verify the video still meets reel specs and retry with a compliant file.
  5. Update buildInspectReelStageJs detection if Instagram's failure UI changed and is being misclassified.

Example fix

// before
await waitForReelStage(page, 'caption'); // fails: session expired mid-flow
// after
await ensureLoggedIn(page); // refresh session before starting the reel flow
await waitForReelStage(page, 'caption');
Defensive patterns

Strategy: try-catch

Validate before calling

// Confirm session health before starting the reel flow
const session = await page.evaluate(() => ({
  loggedIn: !!document.querySelector('svg[aria-label="Home"], nav a[href="/"]'),
  dialogText: document.querySelector('[role="dialog"]')?.innerText || ''
}));
if (!session.loggedIn || session.dialogText) throw new Error('Resolve session/dialog before reel flow');

Type guard

function isReelStageResult(r) {
  return !!r && typeof r === 'object' && typeof r.state === 'string' &&
    (r.detail === undefined || typeof r.detail === 'string');
}

Try / catch

try {
  await waitForReelStage(page, expected);
} catch (err) {
  if (String(err.message).includes('editor did not appear')) {
    console.error('Reel flow failed:', err.secondary || err.message);
    // address rate limit / session / media issue, then retry once
  } else throw err;
}

Prevention

When it happens

Trigger: During polling, page.evaluate(buildInspectReelStageJs()) returns {state:'failed'} — Instagram rendered a failure dialog before the expected editor stage appeared.

Common situations: Instagram rejects the previous step (e.g. share/publish fails due to rate limiting or media rules); session becomes invalid mid-flow; the video was removed or flagged; an unexpected popup derails the flow and the inspector classifies it as failed.

Related errors


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