{"record":{"id":"7bedefc1785dbe34","repo":"garrytan/gstack","slug":"tab-id-not-found","errorCode":null,"errorMessage":"Tab ${id} not found","messagePattern":"Tab (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/browser-manager.ts","lineNumber":819,"sourceCode":"    await page.close();\n    this.pages.delete(tabId);\n    this.tabSessions.delete(tabId);\n    this.tabOwnership.delete(tabId);\n\n    // Switch to another tab if we closed the active one\n    if (tabId === this.activeTabId) {\n      const remaining = [...this.pages.keys()];\n      if (remaining.length > 0) {\n        this.activeTabId = remaining[remaining.length - 1];\n      } else {\n        // No tabs left — create a new blank one\n        await this.newTab();\n      }\n    }\n  }\n\n  switchTab(id: number, opts?: { bringToFront?: boolean }): void {\n    if (!this.tabSessions.has(id)) throw new Error(`Tab ${id} not found`);\n    this.activeTabId = id;\n    // Only bring to front when explicitly requested (user-initiated tab switch).\n    // Internal tab pinning (BROWSE_TAB) should NOT steal focus.\n    if (opts?.bringToFront !== false) {\n      const page = this.pages.get(id);\n      if (page) page.bringToFront().catch(() => {});\n    }\n  }\n\n  /**\n   * Sync activeTabId to match the tab whose URL matches the Chrome extension's\n   * active tab. Called on every /sidebar-tabs poll so manual tab switches in\n   * the browser are detected within ~2s.\n   */\n  syncActiveTabByUrl(activeUrl: string): void {\n    if (!activeUrl || this.pages.size <= 1) return;\n    // Try exact match first, then fuzzy match (origin+pathname, ignoring query/fragment)\n    let fuzzyId: number | null = null;","sourceCodeStart":801,"sourceCodeEnd":837,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/browser-manager.ts#L801-L837","documentation":"Error \"Tab ${id} not found\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/browser-manager.ts:819 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}