jackwener/OpenCLI · error · CommandExecutionError

${result?.reason || 'Failed to click delete menu item.'}${de

Error message

${result?.reason || 'Failed to click delete menu item.'}${detail}

What it means

The grok delete command's menu-click step failed: clickConversationMenuItem could not find or click the per-conversation menu item matching ['删除','delete'] in the sidebar. The library throws CommandExecutionError with the helper's reason plus optional detail, and appends the SESSION_HINT pointing at login/auth/session problems in the existing grok.com browser session.

Source

Thrown at clis/grok/delete.js:44

        { name: 'id', positional: true, type: 'string', required: true, help: 'Conversation UUID or grok.com/c/<uuid> URL' },
        { name: 'yes', type: 'boolean', default: false, help: 'Actually delete (default is a dry-run preview)' },
    ],
    columns: ['status', 'id'],
    func: async (page, kwargs) => {
        const id = parseGrokSessionId(kwargs.id);
        const yes = normalizeBooleanFlag(kwargs.yes);

        await ensureOnGrok(page);
        if (!(await isLoggedIn(page))) throw authRequired();

        if (!yes) {
            return [{ status: 'dry-run (pass --yes to actually delete)', id }];
        }

        const result = await clickConversationMenuItem(page, id, ['删除', 'delete']);
        if (!result || !result.ok) {
            const detail = result?.detail ? ` ${result.detail}` : '';
            throw new CommandExecutionError(`${result?.reason || 'Failed to click delete menu item.'}${detail}`, SESSION_HINT);
        }
        if (!(await waitForConversationToDisappear(page, id))) {
            throw new CommandExecutionError(
                'Delete menu item was clicked, but the conversation is still visible in the sidebar.',
                SESSION_HINT,
            );
        }
        return [{ status: 'deleted', id }];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the conversation ID exists in `grok list` and is not already deleted
  2. Re-login (grok login) to refresh the session, then retry with --yes
  3. Ensure the page is fully loaded before delete; retry after a fresh page.goto to grok.com
  4. If Grok's UI changed, update the menu-item matchers in clis/grok/utils.js (clickConversationMenuItem) to the new labels

Example fix

// before
const result = await clickConversationMenuItem(page, id, ['删除', 'delete']);
// after
await ensureOnGrok(page);
await page.wait(2); // let the sidebar finish rendering
const result = await clickConversationMenuItem(page, id, ['删除', 'delete', 'Delete', '删除对话']);
Defensive patterns

Strategy: validation

Validate before calling

// validate the target exists before deleting
const conversations = await grokList();
if (!conversations.some(c => c.id === targetId)) {
  throw new Error(`Conversation ${targetId} not found — nothing to delete.`);
}
if (!process.argv.includes('--yes')) {
  console.log('Dry-run: pass --yes to actually delete.');
  process.exit(0);
}

Type guard

function isClickResultOk(r) {
  return !!r && typeof r === 'object' && r.ok === true;
}

Try / catch

try {
  await grokDelete(id, { yes: true });
} catch (e) {
  if (String(e.message).includes('Failed to click delete menu item')) {
    // session/UI issue: re-login, reload sidebar, retry once
    await grokLogin();
    await grokDelete(id, { yes: true });
  } else throw e;
}

Prevention

When it happens

Trigger: clickConversationMenuItem(page, id, ['删除','delete']) returns falsy or {ok:false} — the conversation row, its '...' menu, or the delete item was not found/clickable for the given conversation UUID (delete.js:41-45).

Common situations: Conversation ID does not exist or was already deleted; grok.com UI changed (menu labels/locales no longer match '删除'/'delete'); page not fully loaded before clicking; session expired so the sidebar renders logged-out state; bot-protection overlay intercepting the click.

Related errors


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