{"record":{"id":"833896f16b9f6512","repo":"garrytan/gstack","slug":"usage-browse-tab-id","errorCode":null,"errorMessage":"Usage: browse tab <id>","messagePattern":"Usage: browse tab <id>","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/meta-commands.ts","lineNumber":276,"sourceCode":"  shutdown: () => Promise<void> | void,\n  tokenInfo?: TokenInfo | null,\n  opts?: MetaCommandOpts,\n): Promise<string> {\n  // Per-tab operations use the active session; global operations use bm directly\n  const session = bm.getActiveSession();\n\n  switch (command) {\n    // ─── Tabs ──────────────────────────────────────────\n    case 'tabs': {\n      const tabs = await bm.getTabListWithTitles();\n      return tabs.map(t =>\n        `${t.active ? '→ ' : '  '}[${t.id}] ${t.title || '(untitled)'} — ${t.url}`\n      ).join('\\n');\n    }\n\n    case 'tab': {\n      const id = parseInt(args[0], 10);\n      if (isNaN(id)) throw new Error('Usage: browse tab <id>');\n      bm.switchTab(id);\n      return `Switched to tab ${id}`;\n    }\n\n    case 'newtab': {\n      // --json returns structured output (machine-parseable). Other flag-like\n      // tokens are treated as the url. make-pdf always passes --json.\n      let url: string | undefined;\n      let jsonMode = false;\n      for (const a of args) {\n        if (a === '--json') { jsonMode = true; }\n        else if (!url) { url = a; }\n      }\n      const id = await bm.newTab(url);\n      if (jsonMode) {\n        return JSON.stringify({ tabId: id, url: url ?? null });\n      }\n      return `Opened tab ${id}${url ? ` → ${url}` : ''}`;","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/meta-commands.ts#L258-L294","documentation":"Thrown by the 'tab' meta-command when parseInt(args[0], 10) returns NaN — the argument is missing, empty, or non-numeric. The command requires a valid integer tab ID to switch to.","triggerScenarios":"Calling 'browse tab' with zero arguments, or with a non-numeric argument like 'browse tab abc' or 'browse tab active'.","commonSituations":"User forgets the tab ID, passes a tab title or URL instead of the numeric ID, or a script passes an undefined/null value that serializes to a non-numeric string.","solutions":["Run 'browse tabs' first to see the list of open tabs with their numeric IDs","Pass the integer ID shown in the tab list, e.g., 'browse tab 2'","If scripting, ensure the tab ID variable is a number before formatting the command"],"exampleFix":"# before\n$B tab abc\n\n# after\n$B tabs   # see: [0] ..., [1] ..., [2] ...\n$B tab 2","handlingStrategy":"validation","validationCode":"const id = parseInt(args[0], 10);\nif (isNaN(id)) {\n  throw new Error('Tab ID must be a number. Run \"browse tabs\" to list IDs.');\n}","typeGuard":"function isValidTabId(arg: string | undefined): arg is string {\n  return arg !== undefined && /^\\d+$/.test(arg);\n}","tryCatchPattern":null,"preventionTips":["Always run 'browse tabs' first to get valid numeric IDs","Pass integer IDs only — titles and URLs are not accepted"],"tags":["browse","cli","tabs"],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}