{"record":{"id":"60e990d8d1d02ed5","repo":"jackwener/OpenCLI","slug":"this-browser-session-does-not-support-creating-tab","errorCode":null,"errorMessage":"This browser session does not support creating tabs","messagePattern":"This browser session does not support creating tabs","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli.ts","lineNumber":1200,"sourceCode":"    }));\n\n  const browserTab = browser\n    .command('tab')\n    .description('Tab management — list, create, and close tabs in the browser session');\n\n  browserTab.command('list')\n    .description('List tabs in the browser session with target IDs')\n    .action(browserAction(async (page) => {\n      const tabs = await page.tabs();\n      console.log(JSON.stringify(tabs, null, 2));\n    }));\n\n  browserTab.command('new')\n    .argument('[url]', 'Optional URL to open in the new tab')\n    .description('Create a new tab and print its target ID')\n    .action(browserAction(async (page, url?: string) => {\n      if (!page.newTab) {\n        throw new Error('This browser session does not support creating tabs');\n      }\n      const createdPage = await page.newTab(url);\n      console.log(JSON.stringify({\n        page: createdPage,\n        url: url ?? null,\n      }, null, 2));\n    }));\n\n  addBrowserTabOption(browserTab.command('select')\n    .argument('[targetId]', 'Target tab/page identity returned by \"browser open\", \"browser tab new\", or \"browser tab list\"')\n    .description('Select a tab by target ID and make it the default browser tab'))\n    .action(browserAction(async (page, targetId?: string, opts?: { tab?: string } | Command) => {\n      const resolvedTarget = resolveBrowserTabTarget(targetId, opts);\n      if (!resolvedTarget) {\n        throw new Error('Target tab required. Pass it as an argument or --tab <targetId>.');\n      }\n      await page.selectTab(resolvedTarget);\n      saveBrowserTargetState(resolvedTarget, getPageScope(page));","sourceCodeStart":1182,"sourceCodeEnd":1218,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/src/cli.ts#L1182-L1218","documentation":"The `browser tab new` subcommand requires the page to support creating tabs via an optional page.newTab capability. Some session kinds (e.g. connected/attached contexts) do not implement it, so the CLI throws rather than failing mid-operation. It is a capability guard, not a user-argument error.","triggerScenarios":"Running `opencli browser <session> tab new [url]` against a session whose page lacks a newTab implementation (page.newTab is undefined).","commonSituations":"Sessions attached to an externally managed browser that disallows tab creation; restricted/remote debugging contexts; older browser adapters without the capability.","solutions":["Use a session type that supports tab creation (launch/own the browser via the library)","Check whether the underlying browser context allows opening new pages (popup blocking, CDP permissions)","Update the browser adapter/driver to a version implementing newTab","Work around by opening a new page in the browser manually and selecting it via `browser tab select <targetId>`"],"exampleFix":"// before\nopencli browser attached-session tab new https://example.com  // throws\n// after\nopencli browser launched-session tab new https://example.com","handlingStrategy":"try-catch","validationCode":"if (typeof (page as { newTab?: unknown }).newTab !== 'function') {\n  throw new Error('This session does not support tab creation; use a launched browser session.');\n}","typeGuard":"function supportsNewTab(page: IPage): page is IPage & { newTab: (url?: string) => Promise<IPage> } {\n  return typeof (page as { newTab?: unknown }).newTab === 'function';\n}","tryCatchPattern":"try {\n  await run(['opencli', 'browser', session, 'tab', 'new', url]);\n} catch (e) {\n  if (String((e as Error).message).includes('does not support creating tabs')) {\n    console.error(`Session '${session}' cannot create tabs. Launch a session owned by the CLI instead.`);\n    return;\n  }\n  throw e;\n}","preventionTips":["Check session/adapter capabilities before scripting tab operations against it","Prefer launched (CLI-owned) browser sessions when tab management is needed","Keep browser adapters updated so optional capabilities are implemented","Document which session kinds support newTab in team tooling"],"tags":["browser","capability","unsupported-operation"],"backgroundTag":"unsupported-capability","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}