jackwener/OpenCLI · error · CommandExecutionError

Instagram reel caption editor did not appear

Error message

Instagram reel caption editor did not appear

What it means

fillCaption runs an in-page probe (focusCaptionEditor) that looks for a visible [role="dialog"] containing a caption textarea or contenteditable Lexical editor ('Write a caption...'). If no such element is found, the library assumes the caption step of the reel-share dialog did not load and throws this CommandExecutionError instead of typing into a non-existent editor.

Source

Thrown at clis/instagram/reel.js:422

          if (currentText === target || pendingText === target) {
            return { ok: true };
          }
        }

        const value = (editor.textContent || '').replace(/\\u00a0/g, ' ').replace(/\\s+/g, ' ').trim();
        if (value === target) {
          return { ok: true };
        }
      }
      return { ok: false };
    })()
  `);
    return !!result?.ok;
}
async function fillCaption(page, content) {
    const focused = await focusCaptionEditor(page);
    if (!focused) {
        throw new CommandExecutionError('Instagram reel caption editor did not appear');
    }
    if (page.insertText) {
        try {
            await page.insertText(content);
            await page.wait({ time: 0.3 });
            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;
          };
          const dialogs = Array.from(document.querySelectorAll('[role="dialog"]')).filter((el) => isVisible(el));
          for (const dialog of dialogs) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run the share; transient dialog slowness is the most common cause, and the surrounding run flow may succeed on retry.
  2. Verify you are actually logged in and that no verification/challenge interstitial is being displayed instead of the share dialog.
  3. Slow down or step through the flow manually (headful mode, less aggressive waits) so the caption dialog has time to render before fillCaption runs.
  4. Update the library / check clis/instagram/reel.js selectors against the current Instagram DOM; if Instagram changed the editor markup the probe needs new selectors.

Example fix

// before
await uploadVideo(activePage, preparedUpload.uploadPath, selector);
await fillCaption(activePage, caption);
// after
await uploadVideo(activePage, preparedUpload.uploadPath, selector);
await waitForVideoPreview(activePage, 10);
await activePage.wait({ time: 1 }); // let the caption dialog finish rendering
await fillCaption(activePage, caption);
Defensive patterns

Strategy: retry

Validate before calling

// ensure a logged-in, reel-create-capable session before running
const sessionOk = await page.evaluate(() => !!document.querySelector('[role="dialog"]') || location.pathname.includes('/reels'));
if (!sessionOk) throw new Error('Not on reel-create flow; re-authenticate first');

Type guard

null

Try / catch

try {
  await client.shareReel({ videoPath, caption });
} catch (err) {
  if (String(err.message).includes('caption editor did not appear')) {
    await sleep(2000); // let the dialog finish rendering
    await client.shareReel({ videoPath, caption }); // retry once
  } else throw err;
}

Prevention

When it happens

Trigger: The in-page probe returns { ok: false }: no visible dialog, or the dialog has no textarea/contenteditable caption editor. Called from run() during the reel upload flow right after the video preview appears.

Common situations: Instagram shipped a DOM change (new aria-labels, no longer using [role=dialog] or contenteditable), a slower connection leaves the dialog still loading when the probe runs (no retry inside focusCaptionEditor), a login/2FA or 'Try again later' interstitial replaced the share dialog, or the flow is stuck on a previous dialog step.

Related errors


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