{"record":{"id":"ff6e3defe71c51c1","repo":"jackwener/OpenCLI","slug":"browser-session-required-for-twitter-mute-word","errorCode":null,"errorMessage":"Browser session required for twitter mute-word","messagePattern":"Browser session required for twitter mute-word","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/twitter/mute-word.js","lineNumber":26,"sourceCode":"    }\n    return keyword;\n}\n\ncli({\n    site: 'twitter',\n    name: 'mute-word',\n    access: 'write',\n    description: 'Add a muted word or phrase on Twitter/X',\n    domain: 'x.com',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [\n        { name: 'keyword', type: 'string', positional: true, required: true, help: 'Word or phrase to mute' },\n    ],\n    columns: ['keyword', 'status', 'message'],\n    func: async (page, kwargs) => {\n        if (!page) {\n            throw new CommandExecutionError('Browser session required for twitter mute-word');\n        }\n        const keyword = parseKeyword(kwargs.keyword);\n\n        await page.goto('https://x.com/settings/add_muted_keyword');\n        await page.wait({ selector: '[data-testid=\"primaryColumn\"]' }).catch(() => {});\n\n        const result = await page.evaluate(`(async () => {\n            const keyword = ${JSON.stringify(keyword)};\n            let writeStarted = false;\n            const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));\n            const visible = (node) => {\n                if (!node) return false;\n                const style = window.getComputedStyle ? window.getComputedStyle(node) : null;\n                return !style || (style.visibility !== 'hidden' && style.display !== 'none');\n            };\n            const textOf = (node) => String(node?.innerText || node?.textContent || '').trim();\n            const lowerTextOf = (node) => textOf(node).toLowerCase();\n            const exactTextOf = (node) => lowerTextOf(node).replace(/\\\\s+/g, ' ');","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/mute-word.js#L8-L44","documentation":"CommandExecutionError thrown at the start of the mute-word command's func when the injected page object is falsy. This CLI is browser-based: it drives a Playwright-style page to navigate X.com's muted-keyword settings. Without an active browser session the automation cannot run, so it aborts immediately instead of failing later on page.goto.","triggerScenarios":"Invoking the twitter mute-word command outside a browser-session context (no `page` argument supplied by the opencli registry), e.g. running the CLI in a mode where browser automation was not launched or the session was closed before the command executed.","commonSituations":"Running the command via a non-browser strategy/registry configuration; browser launch failure upstream left page undefined; invoking the command programmatically without establishing the browser session the CLI expects.","solutions":["Run the command with browser automation enabled so the registry injects an active page (launch the CLI in its browser/session mode).","Ensure the browser session is started before invoking the command and not closed by an earlier step.","Check upstream browser-launch errors (missing Chromium, display issues in CI) that leave page undefined.","If embedding the CLI, pass a real page object rather than null/undefined."],"exampleFix":"// before\nawait cliRun('twitter mute-word \"spoiler\"'); // no browser session configured\n// after\nconst session = await opencli.browser.launch();\nawait cliRun('twitter mute-word \"spoiler\"', { browser: session });\nawait session.close();","handlingStrategy":"validation","validationCode":"if (!page) throw new Error('Browser session required: launch the opencli browser session before running twitter mute-word');","typeGuard":"function hasPage(p) {\n  return !!p && typeof p.goto === 'function' && typeof p.evaluate === 'function';\n}","tryCatchPattern":"try {\n  await run(['twitter', 'mute-word', kw]);\n} catch (err) {\n  if (err.message.includes('Browser session required')) {\n    const session = await opencli.browser.launch();\n    await run(['twitter', 'mute-word', kw], { browser: session });\n    await session.close();\n  } else throw err;\n}","preventionTips":["Always launch the browser session before any browser-based twitter command","Do not close/reuse a dead session across multiple CLI invocations","In CI, provision a display or headless browser before invoking browser commands"],"tags":["browser-automation","twitter","session-required","cli"],"backgroundTag":"browser-session-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}