{"record":{"id":"c594762352a9f47d","repo":"jackwener/OpenCLI","slug":"opencli-failed-to-move-tab-back-moveerr","errorCode":null,"errorMessage":"[opencli] Failed to move tab back: ${moveErr}","messagePattern":"\\[opencli\\] Failed to move tab back: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"extension/src/background.ts","lineNumber":1511,"sourceCode":"          matchesSession ? 'bound_tab_not_debuggable' : 'bound_tab_mismatch',\n          matchesSession\n            ? `Bound tab for session \"${session.session}\" is not debuggable (${tab.url ?? 'unknown URL'}).`\n            : `Target tab is not the tab bound to session \"${session.session}\".`,\n          'Run \"opencli browser bind\" again on a debuggable http(s) tab.',\n        );\n      }\n      if (session && !matchesSession && session.preferredTabId === null && isDebuggableUrl(tab.url)) {\n        // Tab drifted to another window but content is still valid.\n        // Try to move it back instead of abandoning it.\n        console.warn(`[opencli] Tab ${tabId} drifted to window ${tab.windowId}, moving back to ${session.windowId}`);\n        try {\n          await chrome.tabs.move(tabId, { windowId: session.windowId, index: -1 });\n          const moved = await chrome.tabs.get(tabId);\n          if (moved.windowId === session.windowId && isDebuggableUrl(moved.url)) {\n            return { tabId, tab: moved };\n          }\n        } catch (moveErr) {\n          console.warn(`[opencli] Failed to move tab back: ${moveErr}`);\n        }\n      } else if (!isDebuggableUrl(tab.url)) {\n        console.warn(`[opencli] Tab ${tabId} URL is not debuggable (${tab.url}), re-resolving`);\n      }\n    } catch (err) {\n      if (err instanceof CommandFailure) throw err;\n      if (existingSession && !existingSession.owned) {\n        automationSessions.delete(leaseKey);\n        throw new CommandFailure(\n          'bound_tab_gone',\n          `Bound tab for session \"${existingSession.session}\" no longer exists.`,\n          'Run \"opencli browser bind\" again, then retry the command.',\n        );\n      }\n      console.warn(`[opencli] Tab ${tabId} no longer exists, re-resolving`);\n    }\n  }\n","sourceCodeStart":1493,"sourceCodeEnd":1529,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/extension/src/background.ts#L1493-L1529","documentation":"A console warning logged when the attempt to move a drifted tab back into the session's window (chrome.tabs.move) throws — the move failed, so the extension gives up on recovery for this attempt. The binding is not automatically abandoned here; the caller continues without a successfully relocated tab.","triggerScenarios":"chrome.tabs.move(tabId, {windowId: session.windowId}) rejects because the tab was closed mid-move, the target window no longer exists, or the extension lacks tab permissions at that moment.","commonSituations":"Race where the user closes the tab or window while the extension relocates it; incognito/window-type restrictions; window closed between resolution and move.","solutions":["Re-run 'opencli browser bind' on a fresh debuggable tab to establish a clean session","Ensure the session's target window still exists before running commands","Retry the command — the next resolution pass will re-resolve or recreate the tab","Check the extension has tabs permissions and access to the window type (normal vs incognito)"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"try { await chrome.windows.get(session.windowId); } catch { rebindSession(); }","typeGuard":null,"tryCatchPattern":"try { await chrome.tabs.move(tabId, { windowId, index: -1 }); } catch (moveErr) { await rebind(); }","preventionTips":["Confirm the session window exists before running commands","Avoid closing tabs/windows during automation","Re-run bind after any manual tab/window surgery"],"tags":["chrome-extension","tab-management","race-condition"],"backgroundTag":"tab-move-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}