{"record":{"id":"ebf5761de25b1403","repo":"jackwener/OpenCLI","slug":"no-chats-visible-in-sidebar-are-you-logged-in","errorCode":null,"errorMessage":"No chats visible in sidebar. Are you logged in?","messagePattern":"No chats visible in sidebar\\. Are you logged in\\?","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"error","filePath":"clis/kimi/chat.js","lineNumber":141,"sourceCode":"        const items = await page.evaluate(`(() => {\n      ${IS_VISIBLE_JS}\n      const anchors = Array.from(document.querySelectorAll('a[href*=\"/chat/\"]')).filter(isVisible);\n      const seen = new Set();\n      const out = [];\n      for (const a of anchors) {\n        const href = a.getAttribute('href') || '';\n        const m = href.match(/\\\\/chat\\\\/([0-9a-f-]{8,})/i);\n        if (!m) continue;\n        const id = m[1].toLowerCase();\n        if (id === 'history' || seen.has(id)) continue;\n        seen.add(id);\n        const title = (a.innerText || a.textContent || '').trim().replace(/\\\\s+/g, ' ').slice(0, 200);\n        out.push({ id, title: title || '(untitled)' });\n      }\n      return out;\n    })()`);\n        if (!items.length) {\n            throw new EmptyResultError('kimi history', 'No chats visible in sidebar. Are you logged in?');\n        }\n        const limit = Number.isInteger(kwargs?.limit) && kwargs.limit > 0 ? kwargs.limit : 30;\n        return items.slice(0, limit).map((r, i) => ({ Index: i + 1, Title: r.title, ChatId: r.id }));\n    },\n});\n\n// -------- detail --------\ncli({\n    site: 'kimi',\n    name: 'detail',\n    access: 'read',\n    description: 'Open a Kimi chat by ID and return its visible messages.',\n    domain: KIMI_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    args: [","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/kimi/chat.js#L123-L159","documentation":"The kimi history command scrapes sidebar chat links via page.evaluate and throws EmptyResultError when the scrape returns zero items. The library treats 'no chats in sidebar' as a distinct condition from a scrape failure — most often meaning the session is not logged in, or the sidebar has not rendered yet.","triggerScenarios":"`kimi history` runs while logged out (sidebar renders login prompt), the sidebar is collapsed/empty in the DOM, or the evaluate ran before React rendered the chat list.","commonSituations":"Expired session showing a logged-out homepage; fresh account with no conversations; slow load — evaluate fires before the sidebar hydrates; Kimi UI change moved chat links out of the `a[href*=\"/chat/\"]` selector.","solutions":["Log in to Kimi (or re-login) and confirm chats are visible in the sidebar, then retry","Add a wait/retry: re-run history after a few seconds so the sidebar finishes rendering","Open a chat once so the sidebar history populates for new accounts","If logged in and chats exist, check whether Kimi changed sidebar markup and update the selector"],"exampleFix":"// before\nconst items = await page.evaluate(scrapeSidebar);\nif (!items.length) throw new EmptyResultError('kimi history', '...');\n// after\nlet items = await page.evaluate(scrapeSidebar);\nfor (let i = 0; i < 3 && !items.length; i++) {\n  await page.wait(2);\n  items = await page.evaluate(scrapeSidebar);\n}\nif (!items.length) throw new EmptyResultError('kimi history', 'No chats visible in sidebar. Are you logged in?');","handlingStrategy":"fallback","validationCode":"const cookie = (await page.getCookies({ url: 'https://www.kimi.com' })).some(c => c.name === 'access_token');\nif (!cookie) throw new Error('Not logged in — history will be empty; run login first');","typeGuard":"function isSidebarEmptyResult(items) {\n  return !Array.isArray(items) || items.length === 0;\n}","tryCatchPattern":"try {\n  const history = await kimiHistory({ limit: 30 });\n} catch (e) {\n  if (e instanceof EmptyResultError || /No chats visible/.test(e.message)) {\n    await sleep(3000);            // let sidebar render\n    await page.reload();          // or navigate to kimi.com home\n    return kimiHistory({ limit: 30 });\n  }\n  throw e;\n}","preventionTips":["Confirm login before listing history","Allow the sidebar a few seconds to render before scraping","For new accounts, create one chat so the sidebar is populated","Keep the selector `a[href*=\"/chat/\"]` in sync with Kimi UI changes"],"tags":["kimi","empty-result","scraping","auth"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}