different-ai/openwork · error
Tab order contains an unknown tab.
Error message
Tab order contains an unknown tab.
What it means
reorderBrowserTabs checks every proposed id against the current open-tab set and throws if any id is not currently open. The order array was the right length with unique entries but referenced a tab that no longer (or never did) exist.
Source
Thrown at apps/desktop/electron/browser-panel.mjs:689
for (const tab of tabsToClose) {
try { tab.view.webContents.close(); } catch { /* already destroyed */ }
}
sendToRenderer("openwork:browser:panel-closed");
sendBrowserState();
return closedTabIds;
}
function reorderBrowserTabs(tabIds) {
const nextOrder = Array.isArray(tabIds) ? tabIds.map(String) : [];
if (nextOrder.length !== browserTabOrder.length) {
throw new Error("Tab order must include every open tab.");
}
if (new Set(nextOrder).size !== nextOrder.length) {
throw new Error("Tab order must not contain duplicate tabs.");
}
const current = new Set(browserTabOrder);
if (nextOrder.some((tabId) => !current.has(tabId))) {
throw new Error("Tab order contains an unknown tab.");
}
browserTabOrder = nextOrder;
sendBrowserState();
return listBrowserTabs();
}
function sendBrowserState() {
sendToRenderer("openwork:browser:state", browserStatePayload());
}
/**
* Attach the browser view to the main window.
* @param {object} bounds — { x, y, width, height }
* @param {object} [opts]
* @param {boolean} [opts.preloadDefault=false] - load default URL if the view has no URL
* @param {boolean} [opts.ensureTab=false] - create a blank tab if needed
*/
function attachBrowserView(bounds, { preloadDefault = false, ensureTab = false } = {}) {View on GitHub (pinned to 2b7df46e8a)
Solutions
- Re-fetch listBrowserTabs() and rebuild the order from live ids
- Intersect the proposed order with currently open tabs, appending any missing open tabs
- Handle tab-close events to purge stale ids from client state before reordering
Example fix
// before reorderBrowserTabs(cachedOrder); // after const open = new Set(listBrowserTabs().map(t => t.tabId)); reorderBrowserTabs([...cachedOrder.filter(id => open.has(id)), ...[...open].filter(id => !cachedOrder.includes(id))]);
Defensive patterns
Strategy: validation
Validate before calling
function orderUsesOpenTabs(ids) {
const open = new Set(listBrowserTabs().map(t => String(t.tabId)));
return ids.map(String).every(id => open.has(id));
}
if (!orderUsesOpenTabs(order)) order = order.filter(id => orderUsesOpenTabs([id])); Type guard
function areKnownTabIds(ids, open) {
const known = new Set(open.map(t => String(t.tabId)));
return ids.map(String).every(id => known.has(id));
} Try / catch
try {
reorderBrowserTabs(order);
} catch (e) {
if (e.message === 'Tab order contains an unknown tab.') {
const open = listBrowserTabs().map(t => t.tabId);
reorderBrowserTabs(order.filter(id => open.includes(id)).concat(open.filter(id => !order.includes(id))));
} else throw e;
} Prevention
- Purge closed tab ids from client state on close events
- Snapshot tab ids immediately before reordering to narrow race windows
- Never hardcode tab ids in scripts; always read current state
- Handle async tab closes with a reconcile-then-retry pattern
When it happens
Trigger: Reordering with an id from a tab closed between snapshot and call; fabricated/corrupt ids; ids carried over from a previous panel session.
Common situations: Race where a tab closes while the user reorders; stale client state after a crash-restore; automation scripts hardcoding tab ids.
Related errors
- Unknown browser tab: ${tabId}
- Tab order must include every open tab.
- Tab order must not contain duplicate tabs.
- Agent context diagnostics timeout must be between 1 ms and 3
- Invalid cloud provider sync response.
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/204e89f495bf0868.
Report an issue: GitHub.