observePullRequest used to reveal and focus the explorer pane, and the persisted focus leak then made ambient tab opens (sidebar agent clicks, reconcile auto-open) insert agent tabs into the explorer pane while the main pane sat empty. PR detection now only background-adds the PR tab to the explorer pane, with no reveal and no focus change, so a tab the user already opened elsewhere stays where it is. Placement policy is centralized in workspace-layout-actions.ts (resolvePlacementPane / insertNewTabIntoPane): explicit paneId wins, and ambient entity opens (agent, provider_subagent, terminal, draft, browser) reroute from the explorer pane to the primary pane. explorerPaneId is a required input so callers cannot silently fail open. Pane-rail + affordances thread explicit paneId instead of focus-then-open.
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { WorkspaceLayout } from "@/stores/workspace-layout-store";
|
|
import { createDefaultLayout } from "@/stores/workspace-layout-store";
|
|
import { openTabInLayoutFocused } from "@/stores/workspace-layout-actions";
|
|
import { resolveBrowserNewTabRequest, type BrowserNewTabRequest } from ".";
|
|
|
|
function createLayoutWithBrowser(browserId: string): WorkspaceLayout {
|
|
return openTabInLayoutFocused({
|
|
layout: createDefaultLayout(),
|
|
target: { kind: "browser", browserId },
|
|
now: 1,
|
|
explorerPaneId: null,
|
|
}).layout;
|
|
}
|
|
|
|
describe("browser new-tab requests", () => {
|
|
it("accepts desktop requests from browser tabs in the current workspace", () => {
|
|
const request = resolveBrowserNewTabRequest({
|
|
payload: {
|
|
sourceBrowserId: "browser-1",
|
|
url: "https://example.com/target",
|
|
},
|
|
workspaceLayout: createLayoutWithBrowser("browser-1"),
|
|
});
|
|
|
|
expect(request).toEqual<BrowserNewTabRequest>({
|
|
sourceBrowserId: "browser-1",
|
|
url: "https://example.com/target",
|
|
});
|
|
});
|
|
|
|
it("ignores desktop requests from another workspace", () => {
|
|
const request = resolveBrowserNewTabRequest({
|
|
payload: {
|
|
sourceBrowserId: "browser-from-other-workspace",
|
|
url: "https://example.com/target",
|
|
},
|
|
workspaceLayout: createLayoutWithBrowser("browser-1"),
|
|
});
|
|
|
|
expect(request).toBeNull();
|
|
});
|
|
|
|
it("rejects unsupported desktop request URLs", () => {
|
|
const request = resolveBrowserNewTabRequest({
|
|
payload: {
|
|
sourceBrowserId: "browser-1",
|
|
url: "file:///etc/passwd",
|
|
},
|
|
workspaceLayout: createLayoutWithBrowser("browser-1"),
|
|
});
|
|
|
|
expect(request).toBeNull();
|
|
});
|
|
});
|