{"record":{"id":"f8d117d07cc0ba46","repo":"jackwener/OpenCLI","slug":"chatgpt-history","errorCode":null,"errorMessage":"chatgpt history","messagePattern":"chatgpt history","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"error","filePath":"clis/chatgpt/history.js","lineNumber":35,"sourceCode":"    strategy: Strategy.COOKIE,\n    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    args: [\n        { name: 'limit', type: 'int', default: 20, help: 'Max conversations to show' },\n    ],\n    columns: ['Index', 'Id', 'Title', 'Url'],\n    func: async (page, kwargs) => {\n        const limit = requirePositiveInt(\n            Number(kwargs.limit ?? 20),\n            'chatgpt history --limit',\n            'Example: opencli chatgpt history --limit 20',\n        );\n        await ensureOnChatGPT(page);\n        await ensureChatGPTLogin(page, 'ChatGPT history requires a logged-in ChatGPT session.');\n        const conversations = await getConversationList(page);\n        if (!conversations.length) {\n            throw new EmptyResultError('chatgpt history', 'No ChatGPT conversation links were visible in the sidebar.');\n        }\n        return conversations.slice(0, limit);\n    },\n});\n","sourceCodeStart":17,"sourceCodeEnd":40,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatgpt/history.js#L17-L40","documentation":"The `chatgpt history` command throws EmptyResultError('chatgpt history') when getConversationList returns zero conversation links from the sidebar. It signals that no sidebar conversation links were visible, so there is nothing to slice by --limit.","triggerScenarios":"`opencli chatgpt history` after ensureOnChatGPT + ensureChatGPTLogin pass, but the sidebar contains no conversation anchor elements — new account with no history, sidebar collapsed, DOM changes, or the page not fully loaded when extraction ran.","commonSituations":"Brand-new ChatGPT account with zero conversations; sidebar hidden/collapsed by ChatGPT UI or a small viewport; account switched so the persistent session cookie belongs to an empty account; ChatGPT redesign changing sidebar selectors.","solutions":["Open chatgpt.com in a browser and confirm the sidebar lists conversations; disable the sidebar collapse state if hidden.","Retry after the page fully loads (transient extraction race).","Verify the correct logged-in account (the cookie session may point to an empty account).","If the sidebar renders conversations but extraction is empty, the selectors likely changed — update the library."],"exampleFix":"// before\nopencli chatgpt history --limit 20\n// after\n# confirm conversations exist in the browser, ensure window is wide enough to show the sidebar, then\nopencli chatgpt history --limit 20","handlingStrategy":"retry","validationCode":"// Ensure the session account actually has history before listing\nconst accountPage = await open('https://chatgpt.com');\n// or simply guard the result:\nconst conversations = await run('chatgpt history', '--limit', '20').catch(() => []);\nif (!conversations.length) console.warn('Sidebar empty: new account or hidden sidebar');","typeGuard":"function hasSidebarHistory(conversations) {\n  return Array.isArray(conversations) && conversations.length > 0;\n}","tryCatchPattern":"try {\n  const conversations = await run('chatgpt history', '--limit', '20');\n} catch (err) {\n  if (String(err.message).includes('chatgpt history')) {\n    // empty account, collapsed sidebar, or selector drift — inspect manually\n    return [];\n  }\n  throw err;\n}","preventionTips":["Confirm the logged-in account has conversations before calling history","Maximize the viewport so the sidebar is expanded, not collapsed","Refresh auth if the session is stale (ensureChatGPTLogin gates this but accounts can differ)","After a ChatGPT redesign, expect selector drift and update the library"],"tags":["chatgpt","empty-result","sidebar"],"backgroundTag":"empty-result-no-data","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}