{"record":{"id":"d38027260f0ee06b","repo":"jackwener/OpenCLI","slug":"browser-session-required-for-twitter-hide-reply","errorCode":null,"errorMessage":"Browser session required for twitter hide-reply","messagePattern":"Browser session required for twitter hide-reply","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/twitter/hide-reply.js","lineNumber":19,"sourceCode":"import { CommandExecutionError } from '@jackwener/opencli/errors';\nimport { cli, Strategy } from '@jackwener/opencli/registry';\nimport { parseTweetUrl, buildTwitterArticleScopeSource } from './shared.js';\n\ncli({\n    site: 'twitter',\n    name: 'hide-reply',\n    access: 'write',\n    description: 'Hide a reply on your tweet (useful for hiding bot/spam replies)',\n    domain: 'x.com',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [\n        { name: 'url', type: 'string', required: true, positional: true, help: 'The URL of the reply tweet to hide' },\n    ],\n    columns: ['status', 'message'],\n    func: async (page, kwargs) => {\n        if (!page)\n            throw new CommandExecutionError('Browser session required for twitter hide-reply');\n        const target = parseTweetUrl(kwargs.url);\n        await page.goto(target.url);\n        await page.wait({ selector: '[data-testid=\"primaryColumn\"]' });\n        const runHideAttempt = (allowParentDiscovery) => page.evaluate(`(async () => {\n        try {\n            ${buildTwitterArticleScopeSource(target.id)}\n            const visible = (el) => !!el && (el.offsetParent !== null || el.getClientRects().length > 0);\n            const moreLabels = new Set(['More', '更多']);\n            const findParentConversationUrl = (targetArticle) => {\n                const primary = document.querySelector('[data-testid=\"primaryColumn\"]') || document;\n                const articles = Array.from(primary.querySelectorAll('article'));\n                const targetIndex = articles.indexOf(targetArticle);\n                if (targetIndex <= 0) return null;\n                for (let index = targetIndex - 1; index >= 0; index -= 1) {\n                    const links = Array.from(articles[index].querySelectorAll('a[href*=\"/status/\"]'))\n                        .filter((link) => link.querySelector('time'));\n                    for (const link of links) {\n                        const statusId = __twGetStatusIdFromHref(link.href);","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/hide-reply.js#L1-L37","documentation":"CommandExecutionError thrown by `twitter hide-reply` when it is invoked without a live browser page. Hiding a reply requires driving a real logged-in x.com session (page.evaluate on the tweet page); a null page means the command was run in a headless/API context with no browser session established.","triggerScenarios":"Calling the hide-reply command with no browser session: page is null at func entry, e.g. running outside the browser-backed mode or after the session failed to launch/closed.","commonSituations":"Running the command without starting the browser-backed CLI mode; the browser session crashed or was closed before the command; scripting the CLI programmatically without establishing a session first.","solutions":["Start a browser session (e.g. `opencli open` or the session bootstrap your workflow uses) before running twitter hide-reply","Re-run the command; if the session crashed, restart the CLI","Ensure you are logged into x.com in that session, since hiding replies requires authenticated actions"],"exampleFix":"// before: no session\n$ opencli twitter hide-reply https://x.com/user/status/123\nError: Browser session required for twitter hide-reply\n// after: open a session first\n$ opencli open https://x.com   # establishes the browser session\n$ opencli twitter hide-reply https://x.com/user/status/123","handlingStrategy":"validation","validationCode":"// Ensure a browser session exists before invoking hide-reply\nconst { execSync } = require('child_process');\ntry {\n  execSync('opencli session status', { stdio: 'pipe' });\n} catch {\n  execSync('opencli open https://x.com'); // establish session\n}","typeGuard":"function hasBrowserSession(ctx) {\n  return !!ctx && !!ctx.page && typeof ctx.page.evaluate === 'function';\n}","tryCatchPattern":"try {\n  await cli.hideReply(url);\n} catch (err) {\n  if (/Browser session required/.test(err.message)) {\n    await openSession('https://x.com');\n    return cli.hideReply(url);\n  }\n  throw err;\n}","preventionTips":["Always establish the browser session before running session-bound commands (hide-reply, following, etc.)","Check session health in wrapper scripts and bootstrap it on demand","Log into x.com in the session — hiding replies requires authentication","Restart the CLI if a previous command left the browser session closed"],"tags":["browser-session","twitter","precondition"],"backgroundTag":"missing-browser-session","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}