jackwener/OpenCLI · error · EmptyResultError

No chats visible in sidebar. Are you logged in?

Error message

No chats visible in sidebar. Are you logged in?

What it means

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.

Source

Thrown at clis/kimi/chat.js:141

        const items = await page.evaluate(`(() => {
      ${IS_VISIBLE_JS}
      const anchors = Array.from(document.querySelectorAll('a[href*="/chat/"]')).filter(isVisible);
      const seen = new Set();
      const out = [];
      for (const a of anchors) {
        const href = a.getAttribute('href') || '';
        const m = href.match(/\\/chat\\/([0-9a-f-]{8,})/i);
        if (!m) continue;
        const id = m[1].toLowerCase();
        if (id === 'history' || seen.has(id)) continue;
        seen.add(id);
        const title = (a.innerText || a.textContent || '').trim().replace(/\\s+/g, ' ').slice(0, 200);
        out.push({ id, title: title || '(untitled)' });
      }
      return out;
    })()`);
        if (!items.length) {
            throw new EmptyResultError('kimi history', 'No chats visible in sidebar. Are you logged in?');
        }
        const limit = Number.isInteger(kwargs?.limit) && kwargs.limit > 0 ? kwargs.limit : 30;
        return items.slice(0, limit).map((r, i) => ({ Index: i + 1, Title: r.title, ChatId: r.id }));
    },
});

// -------- detail --------
cli({
    site: 'kimi',
    name: 'detail',
    access: 'read',
    description: 'Open a Kimi chat by ID and return its visible messages.',
    domain: KIMI_DOMAIN,
    strategy: Strategy.COOKIE,
    browser: true,
    siteSession: 'persistent',
    navigateBefore: false,
    args: [

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log in to Kimi (or re-login) and confirm chats are visible in the sidebar, then retry
  2. Add a wait/retry: re-run history after a few seconds so the sidebar finishes rendering
  3. Open a chat once so the sidebar history populates for new accounts
  4. If logged in and chats exist, check whether Kimi changed sidebar markup and update the selector

Example fix

// before
const items = await page.evaluate(scrapeSidebar);
if (!items.length) throw new EmptyResultError('kimi history', '...');
// after
let items = await page.evaluate(scrapeSidebar);
for (let i = 0; i < 3 && !items.length; i++) {
  await page.wait(2);
  items = await page.evaluate(scrapeSidebar);
}
if (!items.length) throw new EmptyResultError('kimi history', 'No chats visible in sidebar. Are you logged in?');
Defensive patterns

Strategy: fallback

Validate before calling

const cookie = (await page.getCookies({ url: 'https://www.kimi.com' })).some(c => c.name === 'access_token');
if (!cookie) throw new Error('Not logged in — history will be empty; run login first');

Type guard

function isSidebarEmptyResult(items) {
  return !Array.isArray(items) || items.length === 0;
}

Try / catch

try {
  const history = await kimiHistory({ limit: 30 });
} catch (e) {
  if (e instanceof EmptyResultError || /No chats visible/.test(e.message)) {
    await sleep(3000);            // let sidebar render
    await page.reload();          // or navigate to kimi.com home
    return kimiHistory({ limit: 30 });
  }
  throw e;
}

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/ebf5761de25b1403. Report an issue: GitHub.