{"record":{"id":"2941fa5bd4eaf100","repo":"jackwener/OpenCLI","slug":"result-error-could-not-select-codex-convers","errorCode":null,"errorMessage":"${result?.error || 'Could not select Codex conversation'}${detail}","messagePattern":"\\$\\{result\\?\\.error \\|\\| 'Could not select Codex conversation'\\}\\$\\{detail\\}","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/codex/sidebar.js","lineNumber":331,"sourceCode":"        preferNativeClick: typeof page.nativeClick === 'function',\n    };\n    let result = await page.evaluate(`(${selectCodexConversationInDocument.toString()})(${JSON.stringify(target)})`);\n    if (result?.expanded) {\n        if (typeof page.nativeClick === 'function' && Number.isFinite(result.x) && Number.isFinite(result.y)) {\n            await page.nativeClick(result.x, result.y);\n        }\n        await page.wait(0.75);\n        result = await page.evaluate(`(${selectCodexConversationInDocument.toString()})(${JSON.stringify(target)})`);\n    }\n    if (!result?.ok || !result?.selected) {\n        const detail = result?.conversations\n            ? ` Available: ${result.conversations.map(item => `${item.index}. ${item.title}`).join('; ')}`\n            : result?.projects\n                ? ` Available projects: ${result.projects.join(', ')}`\n                : '';\n        const message = `${result?.error || 'Could not select Codex conversation'}${detail}`;\n        if (result?.error?.startsWith('Invalid conversation index:')) {\n            throw new ArgumentError(message);\n        }\n        if (result?.error?.startsWith('Multiple conversations matched')) {\n            throw new ArgumentError(message, 'Pass --project or --thread-id to disambiguate the target conversation.');\n        }\n        if (result?.error?.startsWith('Project not found:')\n            || result?.error?.startsWith('Conversation not found:')\n            || result?.error?.startsWith('Thread not found:')\n            || result?.error?.startsWith('No visible conversations under project:')) {\n            throw new EmptyResultError('codex conversation', message);\n        }\n        throw new CommandExecutionError(message, 'Open the Codex sidebar and verify project/conversation rows are visible.');\n    }\n    if (typeof page.nativeClick === 'function' && Number.isFinite(result.x) && Number.isFinite(result.y)) {\n        await page.nativeClick(result.x, result.y);\n    }\n    await page.wait(1);\n    return result;\n}","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/codex/sidebar.js#L313-L349","documentation":"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.","triggerScenarios":"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.","commonSituations":"Two Codex projects contain identically named conversations; a generic title like 'New chat' exists multiple times; a partial title match hits several rows.","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."],"exampleFix":"// before\nawait openCodexConversation(page, { title: 'New chat' });\n// after\nawait openCodexConversation(page, { title: 'New chat', project: 'API Client' });","handlingStrategy":"try-catch","validationCode":"// Disambiguate before calling: check how many conversations match the title\nconst matches = conversations.filter((c) => c.title === title);\nif (matches.length > 1) {\n  // require project or thread-id up front\n  if (!project && !threadId) throw new Error(`'${title}' matches ${matches.length} conversations; pass --project or --thread-id`);\n}","typeGuard":"const isAmbiguousSelection = (e) => String(e?.message || e).includes('Multiple conversations matched');","tryCatchPattern":"try {\n  await openCodexConversation(page, { title });\n} catch (e) {\n  if (isAmbiguousSelection(e)) {\n    await openCodexConversation(page, { title, threadId: resolveThreadId(title) });\n  } else throw e;\n}","preventionTips":["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."],"tags":["codex","sidebar","ambiguity","argument"],"backgroundTag":"ambiguous-selection","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}