jackwener/OpenCLI · error · ArgumentError
${result?.error || 'Could not select Codex conversation'}${d
Error message
${result?.error || 'Could not select Codex conversation'}${detail} What it means
When the in-page conversation-selection routine fails, `openCodexConversation` builds a message from the routine's `error` (defaulting to 'Could not select Codex conversation') plus a detail suffix listing available conversations/projects, and maps it to the appropriate error type. This branch throws an `ArgumentError` when the error starts with 'Multiple conversations matched', meaning the selection was ambiguous.
Source
Thrown at clis/codex/sidebar.js:331
preferNativeClick: typeof page.nativeClick === 'function',
};
let result = await page.evaluate(`(${selectCodexConversationInDocument.toString()})(${JSON.stringify(target)})`);
if (result?.expanded) {
if (typeof page.nativeClick === 'function' && Number.isFinite(result.x) && Number.isFinite(result.y)) {
await page.nativeClick(result.x, result.y);
}
await page.wait(0.75);
result = await page.evaluate(`(${selectCodexConversationInDocument.toString()})(${JSON.stringify(target)})`);
}
if (!result?.ok || !result?.selected) {
const detail = result?.conversations
? ` Available: ${result.conversations.map(item => `${item.index}. ${item.title}`).join('; ')}`
: result?.projects
? ` Available projects: ${result.projects.join(', ')}`
: '';
const message = `${result?.error || 'Could not select Codex conversation'}${detail}`;
if (result?.error?.startsWith('Invalid conversation index:')) {
throw new ArgumentError(message);
}
if (result?.error?.startsWith('Multiple conversations matched')) {
throw new ArgumentError(message, 'Pass --project or --thread-id to disambiguate the target conversation.');
}
if (result?.error?.startsWith('Project not found:')
|| result?.error?.startsWith('Conversation not found:')
|| result?.error?.startsWith('Thread not found:')
|| result?.error?.startsWith('No visible conversations under project:')) {
throw new EmptyResultError('codex conversation', message);
}
throw new CommandExecutionError(message, 'Open the Codex sidebar and verify project/conversation rows are visible.');
}
if (typeof page.nativeClick === 'function' && Number.isFinite(result.x) && Number.isFinite(result.y)) {
await page.nativeClick(result.x, result.y);
}
await page.wait(1);
return result;
}View on GitHub (pinned to 49907e53dc)
Solutions
- Pass `--project <name>` to scope the selection to one project.
- Pass `--thread-id <id>` to target the exact conversation unambiguously.
- Use a more specific conversation title/index that matches exactly one conversation.
- Rename duplicate conversations in Codex to make titles unique.
Example fix
// before
await openCodexConversation(page, { title: 'New chat' });
// after
await openCodexConversation(page, { title: 'New chat', project: 'API Client' }); Defensive patterns
Strategy: try-catch
Validate before calling
// Disambiguate before calling: check how many conversations match the title
const matches = conversations.filter((c) => c.title === title);
if (matches.length > 1) {
// require project or thread-id up front
if (!project && !threadId) throw new Error(`'${title}' matches ${matches.length} conversations; pass --project or --thread-id`);
} Type guard
const isAmbiguousSelection = (e) => String(e?.message || e).includes('Multiple conversations matched'); Try / catch
try {
await openCodexConversation(page, { title });
} catch (e) {
if (isAmbiguousSelection(e)) {
await openCodexConversation(page, { title, threadId: resolveThreadId(title) });
} else throw e;
} Prevention
- Always pass --project or --thread-id when titles may be duplicated.
- Prefer thread-id for unambiguous targeting.
- Use the 'Available:' list in the error to disambiguate.
- Keep conversation titles unique in Codex.
When it happens
Trigger: Selecting a conversation by title/index matched more than one conversation (duplicate titles across projects or within the sidebar), and the caller supplied neither `--project` nor `--thread-id` to disambiguate.
Common situations: Two Codex projects contain identically named conversations; a generic title like 'New chat' exists multiple times; a partial title match hits several rows.
Related errors
- No Codex conversations were visible. Open the Codex sidebar
- Model name "${rawName}" is ambiguous.
- Picker option "${rawLabel}" is ambiguous.
- ${label} must be a positive integer
- ${label} cannot be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/2941fa5bd4eaf100.
Report an issue: GitHub.