{"record":{"id":"1c03864c94f2fb2d","repo":"jackwener/OpenCLI","slug":"sign-in-to-grok-com-in-your-browser-then-retry-1c0386","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/pin.js","lineNumber":34,"sourceCode":"\nfunction defineToggle(name, accessLabels) {\n    cli({\n        site: 'grok',\n        name,\n        access: 'write',\n        description: `${name === 'pin' ? 'Pin' : 'Unpin'} a Grok conversation by ID`,\n        domain: GROK_DOMAIN,\n        strategy: Strategy.COOKIE,\n        browser: true,\n        siteSession: 'persistent',\n        args: [\n            { name: 'id', positional: true, type: 'string', required: true, help: 'Conversation UUID or grok.com/c/<uuid> URL' },\n        ],\n        columns: ['status', 'id'],\n        func: async (page, kwargs) => {\n            const id = parseGrokSessionId(kwargs.id);\n            await ensureOnGrok(page);\n            if (!(await isLoggedIn(page))) throw authRequired();\n\n            const expectedState = name === 'pin' ? 'pinned' : 'unpinned';\n            const before = await readConversationMenuLabels(page, id);\n            if (!before.ok) {\n                const detail = before.detail ? ` ${before.detail}` : '';\n                throw new CommandExecutionError(`${before.reason || `Failed to inspect ${name} state.`}${detail}`, SESSION_HINT);\n            }\n            if (getPinStateFromMenuLabels(before.labels) === expectedState) {\n                return [{ status: `already-${expectedState}`, id }];\n            }\n\n            const result = await clickConversationMenuItem(page, id, accessLabels);\n            if (!result || !result.ok) {\n                const detail = result?.detail ? ` ${result.detail}` : '';\n                throw new CommandExecutionError(`${result?.reason || `Failed to ${name} conversation.`}${detail}`, SESSION_HINT);\n            }\n            const verified = await waitForConversationPinState(page, id, expectedState);\n            if (!verified.ok) {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/grok/pin.js#L16-L52","documentation":"The grok pin/unpin commands (defineToggle) open the conversation's context menu, first verifying the user is logged in (throwing AuthRequiredError via authRequired() when not) and then reading the menu labels via readConversationMenuLabels to determine the current pinned state. When the menu cannot be read (before.ok false), it throws a CommandExecutionError carrying the inspection reason, any detail, and a session hint. Login failure is the most common cause of this path.","triggerScenarios":"Running grok pin <id> or grok unpin <id> when isLoggedIn(page) is false, or when readConversationMenuLabels cannot open/read the conversation's three-dot menu (conversation not found in sidebar, sidebar not loaded, DOM changed, menu closed prematurely).","commonSituations":"Signed-out or expired grok.com session in the driven profile; the target conversation id is not present in the current sidebar list (unpinned conversations may not be listed); Grok DOM updates breaking the menu label probe.","solutions":["Sign in to grok.com in the browser profile the CLI drives, then rerun the pin/unpin command.","Confirm the conversation id (UUID or grok.com/c/<uuid> URL) exists and appears in the sidebar.","Reload grok.com in the driven browser so the sidebar and menus render freshly, then retry.","If the menu probe still fails after sign-in and reload, the Grok UI likely changed — update the CLI/extension to a matching version."],"exampleFix":"// before: opencli grok pin <uuid> while signed out -> CommandExecutionError/AuthRequiredError\n// after: sign in to grok.com in the driven profile, reload, then rerun: opencli grok pin <uuid>","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await grokPin(id);\n} catch (e) {\n  if (/Sign in to grok\\.com/i.test(e.message) || e.name === 'AuthRequiredError') {\n    // sign in to grok.com in the driven profile, then retry\n  } else if (e.name === 'CommandExecutionError') {\n    // conversation may not be in the sidebar — verify id, reload page, retry\n  } else {\n    throw e;\n  }\n}","preventionTips":["Verify the conversation id exists in the sidebar before pin/unpin.","Ensure the driven profile has an active grok.com session.","Reload grok.com before batch pin/unpin operations so menus render fresh.","Keep CLI/extension versions current to track Grok UI changes."],"tags":["authentication","grok","ui-automation","menu"],"backgroundTag":"auth-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}