From 58fe405801169a011ec9b8d39c2a4605c0958d86 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Mon, 17 Aug 2026 14:50:01 +0200 Subject: [PATCH] fix(app): keep pull requests in the explorer pane Pull request auto-placement was using the current location of Changes as a proxy for pane ownership. Keep the registered explorer pane authoritative so moving Changes cannot redirect automatically discovered pull requests. --- .../app/src/stores/workspace-layout-store.test.ts | 4 ++-- packages/app/src/stores/workspace-layout-store.ts | 11 ++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/app/src/stores/workspace-layout-store.test.ts b/packages/app/src/stores/workspace-layout-store.test.ts index f0d2968b0..d9c917765 100644 --- a/packages/app/src/stores/workspace-layout-store.test.ts +++ b/packages/app/src/stores/workspace-layout-store.test.ts @@ -423,7 +423,7 @@ describe("workspace-layout-store actions", () => { expect(findPaneContainingTab(layout.root, "pull_request")?.id).toBe(explorerPaneId); }); - it("places an auto-added pull request in the pane containing Changes", () => { + it("keeps an auto-added pull request in the explorer pane when Changes is elsewhere", () => { const workspaceKey = createWorkspaceKey(); const store = workspaceLayoutStore.getState(); store.openTabFocused(workspaceKey, { kind: "working_diff" }); @@ -439,7 +439,7 @@ describe("workspace-layout-store actions", () => { const layout = workspaceLayoutStore.getState().layoutByWorkspace[workspaceKey]; expect(findPaneContainingTab(layout.root, "working_diff")?.id).toBe("main"); - expect(findPaneContainingTab(layout.root, "pull_request")?.id).toBe("main"); + expect(findPaneContainingTab(layout.root, "pull_request")?.id).toBe(explorerPaneId); }); it("opens assistant files in an ensured explorer pane and reveals it on the next open", () => { diff --git a/packages/app/src/stores/workspace-layout-store.ts b/packages/app/src/stores/workspace-layout-store.ts index eb82465af..fdadc5ac1 100644 --- a/packages/app/src/stores/workspace-layout-store.ts +++ b/packages/app/src/stores/workspace-layout-store.ts @@ -521,17 +521,10 @@ export function createWorkspaceLayoutStore( } const layout = getWorkspaceLayout(state.layoutByWorkspace, normalizedWorkspaceKey); - const workingDiffTab = collectAllTabs(layout.root).find( - (tab) => tab.target.kind === "working_diff", - ); - const workingDiffPane = workingDiffTab - ? findPaneContainingTab(layout.root, workingDiffTab.tabId) - : null; const explorerPaneId = state.explorerPaneIdByWorkspace[normalizedWorkspaceKey] ?? null; const explorerPane = findPaneById(layout.root, explorerPaneId); - const placementPane = workingDiffPane ?? explorerPane; - const placementLayout = placementPane - ? (focusPaneInLayout({ layout, paneId: placementPane.id }) ?? layout) + const placementLayout = explorerPane + ? (focusPaneInLayout({ layout, paneId: explorerPane.id }) ?? layout) : layout; const result = openTabInLayoutFocused({ layout: placementLayout,