{"record":{"id":"becabfb8592da876","repo":"jackwener/OpenCLI","slug":"sign-in-to-grok-com-in-your-browser-then-retry","errorCode":null,"errorMessage":"Sign in to grok.com in your browser, then retry.","messagePattern":"Sign in to grok\\.com in your browser, then retry\\.","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/grok/history.js","lineNumber":36,"sourceCode":"    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    args: [\n        { name: 'limit', type: 'int', default: 20, help: 'Max conversations to show (default 20, max 100)' },\n    ],\n    columns: ['Index', 'Title', 'Url'],\n    func: async (page, kwargs) => {\n        const limit = Number(kwargs.limit ?? 20);\n        if (!Number.isInteger(limit) || limit <= 0) {\n            throw new ArgumentError('limit', 'must be a positive integer');\n        }\n        if (limit > 100) {\n            throw new ArgumentError('limit', 'must be <= 100');\n        }\n        await ensureOnGrok(page);\n        await page.wait(2);\n        if (!(await isLoggedIn(page))) {\n            throw authRequired();\n        }\n        const sessions = await getHistoryFromSidebar(page, limit);\n        if (!sessions.length) {\n            throw new EmptyResultError('grok history', 'No Grok conversations found in the sidebar for the signed-in account.');\n        }\n        return sessions.slice(0, limit).map((s, i) => ({\n            Index: i + 1,\n            Title: s.title || '(untitled)',\n            Url: `https://grok.com/c/${s.id}`,\n        }));\n    },\n});\n","sourceCodeStart":18,"sourceCodeEnd":49,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/grok/history.js#L18-L49","documentation":"The grok history command drives a real browser page, ensures it is on grok.com, then checks isLoggedIn before scraping the sidebar. If the page has no signed-in Grok session, it throws an AuthRequiredError (via authRequired(), clis/grok/utils.js:17) whose message tells the user to sign in to grok.com in the browser and retry. History data is only available to authenticated accounts.","triggerScenarios":"Running the grok history command against a profile where the user is logged out of grok.com (isLoggedIn returns false), or whose session cookie expired; also triggered when automation lands on a logged-out page state after ensureOnGrok.","commonSituations":"Fresh browser profile with no grok.com login; cookies cleared by privacy settings or cleanup extensions; expired session after weeks of inactivity; running the CLI with a different profile than the one where you signed in.","solutions":["Open grok.com in the same browser profile the CLI drives and sign in, then rerun the command.","Verify you are pointing the CLI at the profile that holds the logged-in session (not a fresh automation profile).","Check that cookie-clearing settings/extensions are not wiping grok.com sessions between runs.","If already signed in, reload grok.com and retry — a stale page state can fail the isLoggedIn probe."],"exampleFix":"// before: opencli grok history on a logged-out profile -> AuthRequiredError\n// after: open grok.com in the automation profile, complete sign-in, then rerun: opencli grok history","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const sessions = await grokHistory(limit);\n} catch (e) {\n  if (/Sign in to grok\\.com/i.test(e.message) || e.name === 'AuthRequiredError') {\n    // prompt: open grok.com in the driven profile, sign in, then retry\n    return;\n  }\n  throw e;\n}","preventionTips":["Sign in to grok.com in the same profile the CLI automates before running history commands.","Avoid cookie-clearing extensions/settings on automation profiles.","Re-login when grok.com sessions expire (periodic manual check)."],"tags":["authentication","grok","browser-automation"],"backgroundTag":"auth-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}