diff --git a/frontend/js/pane-manager.js b/frontend/js/pane-manager.js index 43cf14a..c255602 100644 --- a/frontend/js/pane-manager.js +++ b/frontend/js/pane-manager.js @@ -700,6 +700,30 @@ const PaneManager = { } this.activePaneId = 0; this._highlightActive(); + + // Migrate tabs from singleton TabManager to pane-0 PaneTabManager + // (the singleton managed all tabs in single-pane mode) + if (!savedPanes && window._singletonTabManager && window._singletonTabManager._tabs.length > 0) { + const stm = window._singletonTabManager; + const ptm = this.tabManagers[0]; + if (ptm && ptm._tabs.length === 0) { + console.log('[PaneManager] migrating', stm._tabs.length, 'tabs from singleton to pane-0'); + ptm._tabs = stm._tabs.map(t => ({ ...t })); + ptm._tabCache = { ...stm._tabCache }; + ptm._activeTabId = stm._activeTabId; + ptm._previewTabId = stm._previewTabId; + // Clear singleton — it now delegates to PaneManager + stm._tabs = []; + stm._tabCache = {}; + stm._activeTabId = null; + stm._previewTabId = null; + // Render the migrated tabs + setTimeout(() => { + ptm._renderTabs(); + if (ptm._activeTabId) ptm.activate(ptm._activeTabId); + }, 100); + } + } }, _createPane(idx, grid, reuseTabBar, reuseContent) { @@ -901,6 +925,20 @@ const PaneManager = { if (content) { content.id = 'content-area'; wrapper.appendChild(content); } const tl = wrapper.querySelector('.tab-list'); if (tl) tl.id = 'tab-list'; + + // Migrate tabs back to singleton TabManager + const ptm = this.tabManagers[0]; + if (ptm && window._singletonTabManager) { + const stm = window._singletonTabManager; + stm._tabs = ptm._tabs.map(t => ({ ...t })); + stm._tabCache = { ...ptm._tabCache }; + stm._activeTabId = ptm._activeTabId; + stm._previewTabId = ptm._previewTabId; + stm._tabBar = tabBar; + stm._tabList = tl; + stm._renderTabs(); + } + // Re-init pane-0 TabManager to point to restored DOM if (this.tabManagers[0]) { this.tabManagers[0]._tabBar = tabBar;