Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface ChangesControlProps {
}

/**
* Sidebar-strip Changes control: one bordered button with a single face covering
* Tab-bar Changes control: one bordered button with a single face covering
* the branch's whole lifecycle. Before a PR exists the face is the diff
* stats with the ship actions (commit → push → create PR) in the chevron —
* or the ship action itself once the tree is clean; once a PR exists the
Expand Down Expand Up @@ -64,7 +64,7 @@ export const ChangesControl = memo(function ChangesControl({
!hasPr && stats != null && stats.fileCount > 0 ? stats : null;

return (
<div className="flex h-6 items-stretch divide-x divide-border/60 overflow-hidden rounded-md border border-border/60 bg-muted/30 empty:hidden">
<div className="flex h-7 items-stretch divide-x divide-border/60 overflow-hidden rounded-md border border-border/60 bg-muted/30 empty:hidden">
{visibleStats && (
<button
type="button"
Expand All @@ -73,11 +73,11 @@ export const ChangesControl = memo(function ChangesControl({
aria-pressed={isChangesOpen}
title={label}
className={cn(
"flex min-w-0 items-center gap-1 overflow-hidden px-2 text-xs text-muted-foreground outline-none transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:bg-accent/60 focus-visible:text-foreground",
"flex items-center gap-1 px-2 text-xs text-muted-foreground outline-none transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:bg-accent/60 focus-visible:text-foreground",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Unbounded Changes control width

On a narrow workspace window, large addition and deletion totals can make this button wider than the space available. The tab bar's trailing controls do not shrink, so the wider Changes control leaves less room for pane tabs and can push other controls beyond the bar. Please keep the stats face bounded in its new location.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/ChangesControl/ChangesControl.tsx
Line: 76

Comment:
**Unbounded Changes control width**

On a narrow workspace window, large addition and deletion totals can make this button wider than the space available. The tab bar's trailing controls do not shrink, so the wider Changes control leaves less room for pane tabs and can push other controls beyond the bar. Please keep the stats face bounded in its new location.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Bound the stats face again by restoring min-w-0 overflow-hidden so large totals cannot expand this trailing control and crowd the pane tabs.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/ChangesControl/ChangesControl.tsx, line 76:

<comment>Bound the stats face again by restoring `min-w-0 overflow-hidden` so large totals cannot expand this trailing control and crowd the pane tabs.</comment>

<file context>
@@ -73,11 +73,11 @@ export const ChangesControl = memo(function ChangesControl({
 					title={label}
 					className={cn(
-						"flex min-w-0 items-center gap-1 overflow-hidden px-2 text-xs text-muted-foreground outline-none transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:bg-accent/60 focus-visible:text-foreground",
+						"flex items-center gap-1 px-2 text-xs text-muted-foreground outline-none transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:bg-accent/60 focus-visible:text-foreground",
 						isChangesOpen && "bg-accent/60 text-foreground",
 					)}
</file context>
Suggested change
"flex items-center gap-1 px-2 text-xs text-muted-foreground outline-none transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:bg-accent/60 focus-visible:text-foreground",
"flex min-w-0 items-center gap-1 overflow-hidden px-2 text-xs text-muted-foreground outline-none transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:bg-accent/60 focus-visible:text-foreground",

isChangesOpen && "bg-accent/60 text-foreground",
)}
>
<GitCompareArrows className="size-3.5 shrink-0" />
<GitCompareArrows className="size-3.5" />
{visibleStats.additions > 0 && (
<span className="tabular-nums text-emerald-600 [.dark_&]:text-[#34d399]">
+{visibleStats.additions}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ interface PRStatusGroupProps {
}

/**
* Sidebar-strip PR badge — status icon + number + compact CI/review indicators,
* Tab-bar PR badge — status icon + number + compact CI/review indicators,
* with a dropdown for merge actions (open, non-draft PRs), marking a draft
* ready for review, the PR summary pane, and a GitHub link.
* Clicking the badge toggles the Changes pane; the PR pane lives in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface ShipControlProps {
}

/**
* The no-PR half of the sidebar-strip Changes control: walks the branch to a pull
* The no-PR half of the tab-bar Changes control: walks the branch to a pull
* request. Full mode shows one progressive face — Commit (message popover)
* while the tree is dirty, then Create PR (title/description popover; pushes
* first when the branch is unpublished or ahead), then Push. Compact mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ interface WorkspaceSidebarProps {
selectedDiffTarget?: SelectedDiffTarget;
pendingReveal?: PendingReveal | null;
workspaceId: string;
/** Changes/PR control and open-in button, rendered by the page. */
shipControls: ReactNode;
/** Run button rendered by the page, hosted in the sidebar's top strip. */
runButton: ReactNode;
/** Rendered by the page, which owns the pane store agents launch into. */
Expand All @@ -74,7 +72,6 @@ export function WorkspaceSidebar({
selectedDiffTarget,
pendingReveal,
workspaceId,
shipControls,
runButton,
pagesMenu,
}: WorkspaceSidebarProps) {
Expand Down Expand Up @@ -179,11 +176,7 @@ export function WorkspaceSidebar({
ref={containerRef}
className="isolate flex h-full w-full min-h-0 flex-col overflow-hidden bg-background"
>
<PRActionHeader
shipControls={shipControls}
runButton={runButton}
pagesMenu={pagesMenu}
/>
<PRActionHeader runButton={runButton} pagesMenu={pagesMenu} />
<SidebarHeader
tabs={tabs}
activeTab={activeTabDef?.id ?? activeTab}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,15 @@ import type { ReactNode } from "react";
import { WindowControlsInset } from "renderer/routes/_authenticated/_dashboard/components/WindowControlsInset";

interface PRActionHeaderProps {
shipControls: ReactNode;
/** Rendered by the page, which owns the run hooks and pane store. */
runButton: ReactNode;
pagesMenu: ReactNode;
}

export function PRActionHeader({
shipControls,
runButton,
pagesMenu,
}: PRActionHeaderProps) {
export function PRActionHeader({ runButton, pagesMenu }: PRActionHeaderProps) {
return (
<div className="@container/strip flex h-12 shrink-0 items-center bg-muted/45 px-2 dark:bg-muted/35">
<div className="@container drag flex h-full min-w-0 flex-1 items-center overflow-hidden pr-1">
<div className="no-drag flex h-6 min-w-0 flex-wrap items-center gap-x-1 overflow-hidden">
{shipControls}
</div>
</div>
<div className="@container/strip flex h-12 shrink-0 items-center gap-2 bg-muted/45 px-2 dark:bg-muted/35">
<div className="drag h-full min-w-0 flex-1" />
<div className="flex items-center gap-2">
{pagesMenu}
{runButton}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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") => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,20 +386,6 @@ function V2WorkspaceContent() {
/>
);

const shipControls = (
<>
{isLayoutReady && (
<ChangesControl
workspaceId={workspaceId}
isChangesOpen={isChangesPaneOpen}
onToggleChanges={toggleChangesPane}
onOpenPullRequest={openPullRequestPane}
/>
)}
<V2WorkspaceOpenInButton workspaceId={workspaceId} />
</>
);

return (
<FileDocumentStoreProvider store={store}>
<WorkspaceGitStatusProvider workspaceId={workspaceId}>
Expand Down Expand Up @@ -454,6 +440,19 @@ function V2WorkspaceContent() {
store={store}
/>
)}
{isLayoutReady && (
<ChangesControl
workspaceId={workspaceId}
isChangesOpen={isChangesPaneOpen}
onToggleChanges={toggleChangesPane}
onOpenPullRequest={openPullRequestPane}
/>
)}
{/* 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. */}
<V2WorkspaceOpenInButton workspaceId={workspaceId} />
<RightSidebarToggle />
{!isMac && !sidebarOpen && <WindowControlsInset />}
</div>
Expand Down Expand Up @@ -488,7 +487,6 @@ function V2WorkspaceContent() {
>
<WorkspaceSidebar
workspaceId={workspaceId}
shipControls={shipControls}
runButton={workspaceRunButton}
pagesMenu={pagesMenu}
onSelectFile={openFilePaneFromTreeClick}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export {
DEFAULT_WORKSPACE_SIDEBAR_TAB,
getWorkspaceSidebarTab,
setWorkspaceSidebarTab,
} from "./setWorkspaceSidebarTab";
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { beforeEach, describe, expect, it } from "bun:test";
import { useRowlessSidebarTabStore } from "../../state/rowlessSidebarTabStore";
import { setWorkspaceSidebarTab } from "./setWorkspaceSidebarTab";
import {
getWorkspaceSidebarTab,
setWorkspaceSidebarTab,
} from "./setWorkspaceSidebarTab";

type Collections = Parameters<typeof setWorkspaceSidebarTab>[0];

Expand Down Expand Up @@ -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");
});
Comment on lines +51 to +60

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Sidebar interaction remains untested

This test covers reading the active tab, but not the new behavior that closes the Changes pane and conditionally closes the sidebar. Please test that closing Changes also closes a sidebar still on Changes, while a sidebar switched to Files or Review stays open. Otherwise, a regression in that interaction could pass the tests.

Knowledge Base Used: Restore per-mount v2 pane store synchronization

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/utils/setWorkspaceSidebarTab/setWorkspaceSidebarTab.test.ts
Line: 51-60

Comment:
**Sidebar interaction remains untested**

This test covers reading the active tab, but not the new behavior that closes the Changes pane and conditionally closes the sidebar. Please test that closing Changes also closes a sidebar still on Changes, while a sidebar switched to Files or Review stays open. Otherwise, a regression in that interaction could pass the tests.

**Knowledge Base Used:** [Restore per-mount v2 pane store synchronization](https://app.greptile.com/personal-org-6810/-/custom-context/knowledge-base/superset-sh/superset/-/reverts/revert_4017-20260503-pane-store-registry-regressions-06bbdb2.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.


it("keeps rowless choices per workspace", () => {
const collections = stubCollections({});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ type Collections = ReturnType<typeof useCollections>;
/** 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.<name>.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);
});
});
Loading