Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(desktop): open another browser tab from the work panel launcher
zszz3e66bb0c348bd
diff --git a/apps/desktop/src/components/workpanel/WorkPanel.tsx b/apps/desktop/src/components/workpanel/WorkPanel.tsxindex d23926970..e46eea4c1 100644--- a/apps/desktop/src/components/workpanel/WorkPanel.tsx+++ b/apps/desktop/src/components/workpanel/WorkPanel.tsx@@ -20,6 +20,7 @@ import {} from "../../lib/work-panel-tab-reorder";import {isKnownWorkPanelTab,+ launcherWorkPanelTab,parsePluginViewRef,pluginWorkPanelTab,subagentTabDisplayLabels,@@ -636,13 +637,14 @@ function LocalWorkPanel({const selectTool = useCallback((item: WorkPanelTool, sourceTabId?: string) => {+ const tab = launcherWorkPanelTab(tabs, item.tab);if (sourceTabId) {- replaceWorkPanelTab(sourceTabId, item.tab);+ replaceWorkPanelTab(sourceTabId, tab);return;}- const existing = tabs.find((tab) => tab.id === item.tab.id);+ const existing = tabs.find((candidate) => candidate.id === tab.id);if (existing) activateTab(existing.id);- else openWorkPanelTab(item.tab);+ else openWorkPanelTab(tab);},[activateTab, openWorkPanelTab, replaceWorkPanelTab, tabs],);diff --git a/apps/desktop/src/lib/work-panel-tabs.ts b/apps/desktop/src/lib/work-panel-tabs.tsindex 5a89f4d82..ee6fdac77 100644--- a/apps/desktop/src/lib/work-panel-tabs.ts+++ b/apps/desktop/src/lib/work-panel-tabs.ts@@ -151,6 +151,18 @@ export function browserPluginTab(location?: string): WorkPanelTab {return { ...base, id: `${base.id}:${Date.now().toString(36)}-${++newWorkPanelTabSequence}`, location: target, label: browserTabLabel(target) };}+/**+ * The tab a launcher pick opens. Tools reuse their open tab, except the+ * browser: each page lives in its own tab (#1086), so picking Browser while one+ * is open starts another blank page instead of focusing the existing one.+ */+export function launcherWorkPanelTab(tabs: WorkPanelTab[], tab: WorkPanelTab): WorkPanelTab {+ const browserResource = `${BROWSER_PLUGIN_TAB.pluginId}/${BROWSER_PLUGIN_TAB.viewId}`;+ if (tab.kind !== "plugin" || tab.resource !== browserResource) return tab;+ if (!tabs.some((item) => item.id === tab.id)) return tab;+ return { ...tab, id: `${tab.id}:${Date.now().toString(36)}-${++newWorkPanelTabSequence}` };+}+export function browserPluginTabForReveal(tabs: WorkPanelTab[],activeTabId: string | null,diff --git a/apps/desktop/test/work-panel-tabs.test.mjs b/apps/desktop/test/work-panel-tabs.test.mjsindex e5b05903a..ebdf49c38 100644--- a/apps/desktop/test/work-panel-tabs.test.mjs+++ b/apps/desktop/test/work-panel-tabs.test.mjs@@ -15,6 +15,7 @@ const {hasPluginView,isKnownWorkPanelTab,isToolWorkPanelTab,+ launcherWorkPanelTab,normalizeWorkPanelFilePath,newWorkPanelTab,openWorkPanelTabState,@@ -86,6 +87,33 @@ test("Browser reveal reuses the originating session's browser tab", () => {assert.equal(browserPluginTabForReveal([], null).id, browserPluginTab().id);});+test("picking Browser from the launcher again opens another browser tab (#2480)", () => {+ // The launcher picks a tool from a blank tab and replaces it.+ const pick = (state, tool) => {+ const blank = newWorkPanelTab();+ const opened = openWorkPanelTabState(state, blank);+ return replaceWorkPanelTabState(opened, blank.id, launcherWorkPanelTab(opened.tabs, tool));+ };+ const browserTool = pluginWorkPanelTab("pi.browser", "browser");+ const review = toolWorkPanelTab("review");++ let state = { tabs: [], activeTabId: null };+ state = pick(state, browserTool);+ state = pick(state, browserTool);+ const browsers = state.tabs.filter((tab) => tab.resource === "pi.browser/browser");+ assert.equal(browsers.length, 2, "a second browser tab sits beside the first");+ assert.equal(browsers[0].id, browserPluginTab().id, "the first keeps the default browser tab id");+ assert.notEqual(browsers[1].id, browsers[0].id);+ assert.equal(state.activeTabId, browsers[1].id, "the new browser tab is focused");+ assert.equal(state.tabs.some((tab) => tab.kind === "new"), false, "no blank launcher tab is left behind");++ // Other tools still focus their single open tab.+ state = pick(state, review);+ state = pick(state, review);+ assert.equal(state.tabs.filter((tab) => tab.id === review.id).length, 1);+ assert.equal(launcherWorkPanelTab(state.tabs, review), review);+});+test("file tabs normalize lexical paths and remain distinct by resource", () => {const first = fileWorkPanelTab("src\\App.tsx");const equivalent = fileWorkPanelTab("./src//components/../App.tsx");diff --git a/apps/desktop/test/work-panel.test.mjs b/apps/desktop/test/work-panel.test.mjsindex 6e62b4876..bda4ff33e 100644--- a/apps/desktop/test/work-panel.test.mjs+++ b/apps/desktop/test/work-panel.test.mjs@@ -288,11 +288,13 @@ test("work panel header exposes a scrollable tab strip and direct new-page actio// tab kind and no separate back control exists.assert.match(panelSource, /subagent: IconBot/);assert.doesNotMatch(panelSource, /work-panel-subagent-back|IconChevronLeft/);- // Reopening an already-open plugin view must reuse its tab so the browser- // keeps its location instead of being replaced by a blank singleton.+ // Reopening an already-open plugin view must not replace its tab with a+ // blank one: other views reuse it, and Browser opens another page beside it+ // (`launcherWorkPanelTab`, covered in work-panel-tabs.test.mjs).+ assert.match(panelSource, /const tab = launcherWorkPanelTab\(tabs, item\.tab\)/);assert.match(panelSource,- /const existing = tabs\.find\(\(tab\) => tab\.id === item\.tab\.id\)/,+ /const existing = tabs\.find\(\(candidate\) => candidate\.id === tab\.id\)/,);assert.match(panelSource, /if \(existing\) activateTab\(existing\.id\)/);assert.doesNotMatch(panelSource, /collapsePanel/);diff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.mdindex 0c8ba2310..6f4f5ce30 100644--- a/docs/spec/04-ux/09-interaction-patterns.md+++ b/docs/spec/04-ux/09-interaction-patterns.md@@ -561,9 +561,12 @@ may be retained while exactly one workspace supplies the visible shell context.body offers Browser or an in-scope plugin view.- An artifact trigger atomically creates or reuses its resource, activates it,and opens the panel. Background artifacts never open the visible panel.-- File resources use normalized paths as identity. Browser and plugin views- are singletons; repeated triggers preserve resource order and activate the- existing resource.+- File resources use normalized paths as identity. Plugin views are+ singletons; repeated triggers preserve resource order and activate the+ existing resource. Browser is the exception: each page has its own tab, so+ a clicked link opens another Browser tab and selecting Browser in the+ launcher while one is open adds a blank Browser tab instead of activating+ the existing page.- Once open, the panel header is a `tablist` that scrolls horizontally while atight `+` trigger stays fixed beside it. Each tab owns its active state andclose button; the active tab is scrolled into view. Clicking `+` creates a