This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools.workspace-manager: fix first tab restore being blank

Create window with first tab URL directly instead of creating
a blank window and trying to clean up the new tab afterwards.

+19 -28
+19 -28
tools/workspace-manager/firefox-extension/background.js
··· 231 231 232 232 // ── Tab restoring (from workspace file) ───────────────────── 233 233 234 - async function restoreTabsInWindow(tabDataList, windowId) { 235 - let activeTabId = null; 236 - for (const tab of tabDataList) { 237 - const created = await browser.tabs.create({ 238 - windowId, 239 - url: tab.url, 240 - pinned: tab.pinned, 241 - active: tab.active, 242 - }); 243 - if (tab.active) activeTabId = created.id; 244 - } 245 - 246 - // Remove initial blank tab 247 - const allTabs = await browser.tabs.query({ windowId }); 248 - for (const t of allTabs) { 249 - if ( 250 - (t.url === "about:blank" || t.url === "about:newtab") && 251 - t.id !== activeTabId && 252 - allTabs.length > 1 253 - ) { 254 - await browser.tabs.remove(t.id); 255 - break; 256 - } 257 - } 258 - } 259 - 260 234 async function restoreWorkspace(workspace) { 261 235 if (restoringWorkspaces.has(workspace)) return; 262 236 restoringWorkspaces.add(workspace); ··· 266 240 const tabs = resp.tabs || []; 267 241 if (tabs.length === 0) return; 268 242 269 - const newWindow = await browser.windows.create({}); 270 - await restoreTabsInWindow(tabs, newWindow.id); 243 + // Create window with the first tab to avoid a blank "new tab" 244 + const first = tabs[0]; 245 + const newWindow = await browser.windows.create({ url: first.url }); 246 + const windowId = newWindow.id; 247 + 248 + // Pin the first tab if needed 249 + if (first.pinned && newWindow.tabs && newWindow.tabs[0]) { 250 + await browser.tabs.update(newWindow.tabs[0].id, { pinned: true }); 251 + } 252 + 253 + // Create remaining tabs 254 + for (let i = 1; i < tabs.length; i++) { 255 + await browser.tabs.create({ 256 + windowId, 257 + url: tabs[i].url, 258 + pinned: tabs[i].pinned, 259 + active: tabs[i].active, 260 + }); 261 + } 271 262 } catch (e) { 272 263 console.error(`Failed to restore workspace ${workspace}:`, e); 273 264 } finally {