{"record":{"id":"4870fc419049461d","repo":"jackwener/OpenCLI","slug":"no-chat-turns-found-on-current-page","errorCode":null,"errorMessage":"No chat turns found on current page.","messagePattern":"No chat turns found on current page\\.","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"error","filePath":"clis/kimi/chat.js","lineNumber":207,"sourceCode":"    site: 'kimi',\n    name: 'read',\n    access: 'read',\n    description: 'Read messages in the current Kimi chat. Pass --conv <id> to navigate to a specific chat first.',\n    domain: KIMI_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    args: [\n        { name: 'conv', required: false, help: 'Chat id or URL (navigates there before reading)' },\n        { name: 'limit', type: 'int', required: false, default: 20 },\n    ],\n    columns: CHAT_COLUMNS,\n    func: async (page, kwargs) => {\n        await maybeNavigateConv(page, kwargs?.conv);\n        const turns = await readKimiTurns(page);\n        if (!turns.length) {\n            throw new EmptyResultError('kimi read', 'No chat turns found on current page.');\n        }\n        const limit = Number.isInteger(kwargs?.limit) && kwargs.limit > 0 ? kwargs.limit : 20;\n        return turns.slice(0, limit).map((t, i) => ({ Index: i + 1, Role: t.role, Text: (t.text || '').slice(0, 1200) }));\n    },\n});\n\n// Helper for read / detail: extract turns from the current chat content list.\n// Kimi renders messages in `.chat-content-list` as `.chat-content-item`\n// children — each gets a `chat-content-item-user` or `chat-content-item-assistant`\n// modifier class (also mirrored on the inner `.segment-user` / `.segment-assistant`).\nasync function readKimiTurns(page) {\n    return await page.evaluate(`(() => {\n    ${IS_VISIBLE_JS}\n    // Prefer .chat-content-list (the actual messages container); fall back\n    // to .message-list (older Kimi UI) and .chat-detail-content (parent).\n    const box = document.querySelector('.chat-content-list') || document.querySelector('.message-list') || document.querySelector('.chat-detail-content');\n    if (!box) return [];\n    // Find every chat-content-item or segment row.","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/kimi/chat.js#L189-L225","documentation":"Thrown by the kimi read command when `readKimiTurns(page)` finds no chat turns on the currently open page. Unlike detail, this reads whatever conversation is currently loaded (optionally navigating via kwargs.conv). EmptyResultError signals the page has no readable message DOM nodes.","triggerScenarios":"Running `kimi read` while the page shows a blank new-chat state, an unloaded/redirected conversation, or when kwargs.conv points to a nonexistent conversation.","commonSituations":"Calling read before sending any message in a fresh session; wrong conv id causing fallback to the new-chat screen; Kimi DOM changes breaking turn detection; slow page load racing the read.","solutions":["Send or receive at least one message in the conversation before running read.","Pass the correct `conv` id/URL explicitly so the command navigates to a real conversation.","Retry after a short wait to let the page finish rendering.","Check for Kimi UI updates that may invalidate readKimiTurns selectors."],"exampleFix":"// before\nconst turns = await cli('kimi', 'read');\n// after\nawait cli('kimi', 'send', { text: 'hi' });\nconst turns = await cli('kimi', 'read', { conv: 'https://kimi.moonshot.cn/chat/<id>' });","handlingStrategy":"retry","validationCode":"// ensure conversation has content before read\nconst convKnown = typeof kwargs.conv === 'string' && /chat\\//.test(kwargs.conv);\nif (!convKnown) await cli('kimi', 'send', { text: 'ping' });","typeGuard":"function hasTurns(t) { return Array.isArray(t) && t.length > 0; }","tryCatchPattern":"try {\n  return await cli('kimi', 'read', { conv });\n} catch (e) {\n  if (/No chat turns found/.test(e.message)) {\n    await page.wait(3);\n    return cli('kimi', 'read', { conv });\n  }\n  throw e;\n}","preventionTips":["Always pass an explicit, valid conv id/URL.","Wait for page load before reading.","Don't read a conversation before any message exists.","Watch for Kimi UI changes that invalidate turn selectors."],"tags":["empty-result","dom-scraping","kimi"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}