+
{pagesMenu}
{runButton}
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspacePaneOpeners/useWorkspacePaneOpeners.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspacePaneOpeners/useWorkspacePaneOpeners.ts
index 0b8a3afa8e2..6ba8111dafa 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspacePaneOpeners/useWorkspacePaneOpeners.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/useWorkspacePaneOpeners/useWorkspacePaneOpeners.ts
@@ -23,7 +23,10 @@ import {
} from "../../utils/openChangesPaneInStore";
import { openPagePaneInStore } from "../../utils/openPagePaneInStore";
import { openPullRequestPaneInStore } from "../../utils/openPullRequestPaneInStore";
-import { setWorkspaceSidebarTab } from "../../utils/setWorkspaceSidebarTab";
+import {
+ getWorkspaceSidebarTab,
+ setWorkspaceSidebarTab,
+} from "../../utils/setWorkspaceSidebarTab";
import { useDefaultBrowserUrl } from "../useDefaultBrowserUrl";
import type { TerminalLauncher } from "../useV2TerminalLauncher";
@@ -221,10 +224,18 @@ export function useWorkspacePaneOpeners({
openChangesPaneInStore(store, useSettings.getState().changesOpenTarget);
}, [store, setRightSidebarOpen, collections, workspace.id]);
+ // Opening brings the sidebar along on Changes, so closing takes it back
+ // down — unless the sidebar has since moved to Files or Review, where
+ // it's serving something else and stays.
const toggleChangesPane = useCallback(() => {
- if (closeVisibleChangesPane(store)) return;
+ if (closeVisibleChangesPane(store)) {
+ if (getWorkspaceSidebarTab(collections, workspace.id) === "changes") {
+ setRightSidebarOpen(false);
+ }
+ return;
+ }
openChangesPane();
- }, [store, openChangesPane]);
+ }, [store, openChangesPane, collections, workspace.id, setRightSidebarOpen]);
const openPagePane = useCallback(
(page: PagePaneData, placement: "split" | "tab") => {
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/page.tsx b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/page.tsx
index bbe2c3b3355..2cb5312b304 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/page.tsx
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/page.tsx
@@ -386,20 +386,6 @@ function V2WorkspaceContent() {
/>
);
- const shipControls = (
- <>
- {isLayoutReady && (
-
- )}
-
- >
- );
-
return (
@@ -454,6 +440,19 @@ function V2WorkspaceContent() {
store={store}
/>
)}
+ {isLayoutReady && (
+
+ )}
+ {/* Open-in must not depend on the right sidebar being open,
+ so it lives here rather than in the sidebar's top strip
+ (#7167). Without an @container ancestor its branch label
+ stays hidden, which keeps it compact for the tab bar. */}
+
{!isMac && !sidebarOpen && }
@@ -488,7 +487,6 @@ function V2WorkspaceContent() {
>
[0];
@@ -45,6 +48,17 @@ describe("setWorkspaceSidebarTab", () => {
expect(useRowlessSidebarTabStore.getState().tabs["main-ws"]).toBe("files");
});
+ it("reads the row's tab, then the rowless fallback, then the default", () => {
+ const collections = stubCollections({
+ "ws-1": { sidebarState: { activeTab: "review" } },
+ });
+
+ expect(getWorkspaceSidebarTab(collections, "ws-1")).toBe("review");
+ expect(getWorkspaceSidebarTab(collections, "main-ws")).toBe("changes");
+ setWorkspaceSidebarTab(collections, "main-ws", "files");
+ expect(getWorkspaceSidebarTab(collections, "main-ws")).toBe("files");
+ });
+
it("keeps rowless choices per workspace", () => {
const collections = stubCollections({});
diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/setWorkspaceSidebarTab/setWorkspaceSidebarTab.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/setWorkspaceSidebarTab/setWorkspaceSidebarTab.ts
index 6c82497028f..9d0c88520db 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/setWorkspaceSidebarTab/setWorkspaceSidebarTab.ts
+++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/setWorkspaceSidebarTab/setWorkspaceSidebarTab.ts
@@ -7,6 +7,23 @@ type Collections = ReturnType;
/** The tab a workspace's sidebar shows before anything has been chosen. */
export const DEFAULT_WORKSPACE_SIDEBAR_TAB: WorkspaceSidebarTab = "changes";
+/**
+ * The tab a workspace's sidebar is on: its local-state row, else the
+ * session fallback a rowless workspace wrote, else the default. A plain
+ * read for event handlers — the sidebar itself subscribes to both sources.
+ */
+export function getWorkspaceSidebarTab(
+ collections: Collections,
+ workspaceId: string,
+): WorkspaceSidebarTab {
+ const row = collections.v2WorkspaceLocalState.get(workspaceId);
+ if (row) return row.sidebarState.activeTab;
+ return (
+ useRowlessSidebarTabStore.getState().tabs[workspaceId] ??
+ DEFAULT_WORKSPACE_SIDEBAR_TAB
+ );
+}
+
/**
* Switch a workspace's right-sidebar tab. The sidebar reads its active tab
* from per-workspace local state (not the global v2 preferences row), so
diff --git a/packages/host-service/test/integration/bug-hunt-3.integration.test.ts b/packages/host-service/test/integration/bug-hunt-3.integration.test.ts
index e1109997aff..b20dd5fc534 100644
--- a/packages/host-service/test/integration/bug-hunt-3.integration.test.ts
+++ b/packages/host-service/test/integration/bug-hunt-3.integration.test.ts
@@ -221,69 +221,3 @@ describe("bug-hunt-3: race + repeated config writes", () => {
expect(["main", "develop"]).toContain(result.baseBranch);
});
});
-
-describe("bug-hunt-3: more concurrency probes", () => {
- let host: TestHost;
- let repo: GitFixture;
- const projectId = randomUUID();
-
- beforeEach(async () => {
- repo = await createGitFixture();
- });
-
- afterEach(async () => {
- if (host) await host.dispose();
- repo.dispose();
- });
-
- test("BUG: parallel workspace.create calls for different branches can race on the same .git/config", async () => {
- host = await createTestHost({
- apiOverrides: {
- "host.ensure.mutate": () => ({ machineId: "m1" }),
- "v2Workspace.create.mutate": (input: unknown) => {
- const i = input as { branch: string; name: string };
- return {
- id: randomUUID(),
- projectId,
- branch: i.branch,
- name: i.name,
- };
- },
- },
- });
- host.db
- .insert(projects)
- .values({ id: projectId, repoPath: repo.repoPath })
- .run();
-
- // Two different branches in parallel — they both call
- // `git worktree add` and `git branch..base` writes inside the
- // procedure.
- const results = await Promise.allSettled([
- host.trpc.workspaces.create.mutate({
- projectId,
- name: "a",
- branch: "feature/a",
- }),
- host.trpc.workspaces.create.mutate({
- projectId,
- name: "b",
- branch: "feature/b",
- }),
- ]);
-
- // Document current behavior. If both succeed, great — we have no
- // bug. If one fails with a config-lock or worktree-lock error,
- // that's a real issue to file.
- const failures = results.filter((r) => r.status === "rejected");
- if (failures.length > 0) {
- console.warn(
- "[bug-hunt-3] parallel workspace.create failure(s):",
- failures.map((r) => (r.status === "rejected" ? String(r.reason) : "")),
- );
- }
- // We currently expect this to be tolerated. If it starts failing,
- // flip to a `test.todo` documenting the regression.
- expect(failures.length).toBe(0);
- });
-});