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 @@ -53,7 +53,7 @@ export function useGitStatusMap(
if (!status) return emptyResult();

// Union of all changes — later writes win so uncommitted state
// overrides committed state. Same pattern as the Changes panel's "all" filter.
// overrides committed state. Same pattern as the Changes tab's "all" filter.
const fileStatusByPath = new Map<string, FileStatus>();
for (const file of status.againstBase) {
fileStatusByPath.set(normalizePath(file.path), file.status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,9 +900,11 @@ export function PullRequestCodeTab({
)}
<div className="flex min-h-0 flex-1 flex-col">
<DiffViewToolbar
fileCount={files.length}
isTreeCollapsed={isTreeCollapsed}
onToggleTree={() => setManualTreeCollapsed(!isTreeCollapsed)}
tree={{
fileCount: files.length,
isCollapsed: isTreeCollapsed,
onToggle: () => setManualTreeCollapsed(!isTreeCollapsed),
}}
areAllFilesCollapsed={areAllFilesCollapsed}
onToggleCollapseAll={() =>
setAllFilesCollapsed(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useLingui } from "@lingui/react/macro";
import { cn } from "@superset/ui/utils";
import { GitCompareArrows } from "lucide-react";
import { memo, useMemo } from "react";
import { useWorkspaceGitStatus } from "../../providers/WorkspaceGitStatusProvider";
Expand All @@ -9,16 +10,20 @@ import { usePRFlowState } from "./hooks/usePRFlowState";

interface ChangesControlProps {
workspaceId: string;
onOpenChanges: () => void;
/** Whether the active tab shows a Changes pane — the face's toggle state. */
isChangesOpen: boolean;
/** Close the visible Changes pane, or open/focus one when none shows. */
onToggleChanges: () => void;
}

/**
* Top-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 (opens the Changes pane) 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 face is the PR badge alone,
* with "Open changes" moving into its menu.
* 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
* face is the PR badge alone. Either face toggles the Changes pane: it
* closes the one in view and opens or focuses one otherwise, reading as
* pressed while one shows.
*
* Segments hide on their own: stats while status is unknown, the tree is
* clean, or a PR owns the face; the right side while the flow state is
Expand All @@ -28,7 +33,8 @@ interface ChangesControlProps {
*/
export const ChangesControl = memo(function ChangesControl({
workspaceId,
onOpenChanges,
isChangesOpen,
onToggleChanges,
}: ChangesControlProps) {
const { t } = useLingui();
const status = useWorkspaceGitStatus();
Expand All @@ -38,10 +44,15 @@ export const ChangesControl = memo(function ChangesControl({
[status.data],
);

const label = t({
id: "workspace.changesPill.openChanges",
message: "Open changes",
});
const label = isChangesOpen
? t({
id: "workspace.changesPill.closeChanges",
message: "Close changes",
})
: t({
id: "workspace.changesPill.openChanges",
message: "Open changes",
});

const hasPr =
flowState.kind === "pr-exists" ||
Expand All @@ -55,10 +66,14 @@ export const ChangesControl = memo(function ChangesControl({
{visibleStats && (
<button
type="button"
onClick={onOpenChanges}
onClick={onToggleChanges}
aria-label={label}
aria-pressed={isChangesOpen}
title={label}
className="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"
className={cn(
"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",
)}
>
<GitCompareArrows className="size-3.5" />
<span className="tabular-nums text-emerald-600 [.dark_&]:text-[#34d399]">
Expand All @@ -81,7 +96,9 @@ export const ChangesControl = memo(function ChangesControl({
state={flowState}
workspaceId={workspaceId}
onRefresh={onRetry}
onOpenChanges={onOpenChanges}
isChangesOpen={isChangesOpen}
toggleLabel={label}
onToggleChanges={onToggleChanges}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,23 @@ interface PRStatusGroupProps {
state: PRFlowState;
workspaceId: string;
onRefresh?: () => void;
/** Whether a Changes pane is in view — the face reads as pressed. */
isChangesOpen?: boolean;
/** Accessible name for the face's toggle ("Open changes" / "Close changes"). */
toggleLabel?: string;
/**
* Opens the Changes pane — the badge's main click, since it replaced the
* diff-stat pill as the control's face once a PR exists.
* Toggles the Changes pane — the badge's main click, since it replaced
* the diff-stat pill as the control's face once a PR exists.
*/
onOpenChanges?: () => void;
onToggleChanges?: () => void;
}

/**
* Top-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 in-app PR view, and a GitHub link.
* Clicking the badge opens the Changes pane; the in-app PR view lives in the
* menu (hidden for session workspaces — null projectId — since the PR route
* Clicking the badge toggles the Changes pane; the in-app PR view lives in
* the menu (hidden for session workspaces — null projectId — since the PR route
* is project-scoped). Hovering surfaces a rich detail popover (title,
* branch, CI summary, last activity).
*
Expand All @@ -59,7 +63,9 @@ export function PRStatusGroup({
state,
workspaceId,
onRefresh,
onOpenChanges,
isChangesOpen = false,
toggleLabel,
onToggleChanges,
}: PRStatusGroupProps) {
const { t } = useLingui();
const navigate = useNavigate();
Expand Down Expand Up @@ -199,7 +205,14 @@ export function PRStatusGroup({
const badgeContent = (
<>
<PRIcon state={linkState} className="size-4" />
<span className="font-mono text-xs text-muted-foreground">
{/* The number brightens while pressed — the state tint alone moves
the fill too little to read as a toggle. */}
<span
className={cn(
"font-mono text-xs",
isChangesOpen ? "text-foreground" : "text-muted-foreground",
)}
>
#{pr.number}
</span>
{showIndicators && <PRStatusIndicators checks={checks} />}
Expand All @@ -208,6 +221,7 @@ export function PRStatusGroup({
const badgeClass = cn(
"flex h-full items-center gap-1 px-1.5 outline-none transition-colors",
tint.hover,
isChangesOpen && tint.pressed,
);

return (
Expand All @@ -219,14 +233,20 @@ export function PRStatusGroup({
>
<HoverCard openDelay={150} closeDelay={120}>
<HoverCardTrigger asChild>
{/* The face opens the Changes pane — the badge replaced the
{/* The face toggles the Changes pane — the badge replaced the
diff-stat pill, so its click keeps that pill's job; the PR
view is one menu entry (or the hover card) away. */}
{onOpenChanges != null ? (
{onToggleChanges != null ? (
<button
type="button"
className={badgeClass}
onClick={onOpenChanges}
aria-pressed={isChangesOpen}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Comment thread
AviPeltz marked this conversation as resolved.
Resolved
// The visible text is only the PR number; name the action
// and keep the number so the badge is still identifiable.
aria-label={
toggleLabel ? `${toggleLabel}, #${pr.number}` : undefined
}
onClick={onToggleChanges}
>
{badgeContent}
</button>
Expand Down Expand Up @@ -381,37 +401,44 @@ export function PRStatusGroup({
function stateTintClasses(state: PRState): {
container: string;
hover: string;
/** Face fill while the Changes pane it toggles is in view. */
pressed: string;
divider: string;
} {
switch (state) {
case "open":
return {
container: "bg-emerald-500/10",
hover: "hover:bg-emerald-500/15 focus-visible:bg-emerald-500/15",
pressed: "bg-emerald-500/20",
divider: "bg-emerald-500/30",
};
case "merged":
return {
container: "bg-violet-500/10",
hover: "hover:bg-violet-500/15 focus-visible:bg-violet-500/15",
pressed: "bg-violet-500/20",
divider: "bg-violet-500/30",
};
case "closed":
return {
container: "bg-rose-500/10",
hover: "hover:bg-rose-500/15 focus-visible:bg-rose-500/15",
pressed: "bg-rose-500/20",
divider: "bg-rose-500/30",
};
case "draft":
return {
container: "bg-muted/40",
hover: "hover:bg-muted/60 focus-visible:bg-muted/60",
pressed: "bg-muted/70",
divider: "bg-border",
};
case "queued":
return {
container: "bg-amber-500/10",
hover: "hover:bg-amber-500/15 focus-visible:bg-amber-500/15",
pressed: "bg-amber-500/20",
divider: "bg-amber-500/30",
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function ShipControl({
// against) — measuring against the repo default gets stacked branches
// exactly backwards. Same 10s cadence as the PR/sync queries so
// committing (here or in a terminal) enables it promptly; both queries
// dedupe with ChangesPanel's identical ones.
// dedupe with the sidebar Changes tab's identical ones.
const baseBranchQuery = workspaceTrpc.git.getBaseBranch.useQuery(
{ workspaceId },
{ enabled: canCreatePr, staleTime: Number.POSITIVE_INFINITY },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ import {
type WorkspaceSidebarTab,
} from "renderer/routes/_authenticated/providers/CollectionsProvider/dashboardSidebarLocal/schema";
import { useSettings } from "renderer/stores/settings";
import { useRowlessSidebarTabStore } from "../../state/rowlessSidebarTabStore";
import type { CommentPaneData, DiffFocusSide } from "../../types";
import {
DEFAULT_WORKSPACE_SIDEBAR_TAB,
setWorkspaceSidebarTab,
} from "../../utils/setWorkspaceSidebarTab";
import { FilesTab } from "./components/FilesTab";
import { PRActionHeader } from "./components/PRActionHeader";
import { SidebarHeader } from "./components/SidebarHeader";
import { type SelectedDiffTarget, useChangesTab } from "./hooks/useChangesTab";
import { useReviewTab } from "./hooks/useReviewTab";
import type { SidebarTabDefinition } from "./types";

// Gates the "Create PR" button only — the chat-driven create flow doesn't
// exist in v2 yet. The PR status group (link + merge dropdown for an open PR)
// always renders so users can see PR state and merge once a PR exists.

const LABELLED_TAB_WIDTH = 88;
const LABEL_HYSTERESIS = 20;

Expand All @@ -49,6 +51,8 @@ interface WorkspaceSidebarProps {
onOpenComment?: (comment: CommentPaneData) => void;
onSearch?: () => void;
selectedFilePath?: string;
/** The diff pane's current file, highlighted in the Changes tab. */
selectedDiffTarget?: SelectedDiffTarget;
pendingReveal?: PendingReveal | null;
workspaceId: string;
}
Expand All @@ -59,6 +63,7 @@ export function WorkspaceSidebar({
onOpenComment,
onSearch,
selectedFilePath,
selectedDiffTarget,
pendingReveal,
workspaceId,
}: WorkspaceSidebarProps) {
Expand All @@ -72,22 +77,46 @@ export function WorkspaceSidebar({
.where(({ localState }) => eq(localState.workspaceId, workspaceId)),
[collections, workspaceId],
);
// Workspaces without a local row (auto-included local mains) keep their
// tab in the session-only fallback that setWorkspaceSidebarTab writes.
const rowlessTab = useRowlessSidebarTabStore((s) => s.tabs[workspaceId]);
const clearRowlessTab = useRowlessSidebarTabStore((s) => s.clearTab);
// The live query can lag a render when the workspace switches; a row that
// still belongs to the previous workspace must not speak for this one.
const row = localState?.workspaceId === workspaceId ? localState : undefined;
const activeTab: SidebarTabId =
localState && isSidebarTabId(localState.sidebarState.activeTab)
? localState.sidebarState.activeTab
: "files";
row && isSidebarTabId(row.sidebarState.activeTab)
? row.sidebarState.activeTab
: (rowlessTab ?? DEFAULT_WORKSPACE_SIDEBAR_TAB);

// A row created while a rowless choice is pending (pinning a local main)
// starts on the default tab: carry the choice into the row once, then
// drop the session entry so it can't resurface if the row goes away.
const hasRow = row != null;
useEffect(() => {
if (!hasRow || rowlessTab === undefined) return;
setWorkspaceSidebarTab(collections, workspaceId, rowlessTab);
clearRowlessTab(workspaceId);
}, [hasRow, rowlessTab, collections, workspaceId, clearRowlessTab]);

function setActiveTab(tab: string) {
if (!isSidebarTabId(tab)) return;
if (!collections.v2WorkspaceLocalState.get(workspaceId)) return;
collections.v2WorkspaceLocalState.update(workspaceId, (draft) => {
draft.sidebarState.activeTab = tab;
});
setWorkspaceSidebarTab(collections, workspaceId, tab);
}

const containerRef = useRef<HTMLDivElement>(null);
const [compact, setCompact] = useState(false);

const changesTab = useChangesTab({
workspaceId,
selectedDiffTarget,
onSelectFile: onSelectDiffFile
? (path, openInNewTab, changeKey) =>
onSelectDiffFile(path, openInNewTab, undefined, undefined, changeKey)
: undefined,
onOpenFile: onSelectFile,
});

// PR review comments are always relative to the base branch, so they map
// onto the "against-base" source group — matching the same query (and
// changeKey format) the Changes pane uses for that group lets us disambiguate
Expand Down Expand Up @@ -143,7 +172,7 @@ export function WorkspaceSidebar({
),
};

const tabs: SidebarTabDefinition[] = [filesTab, reviewTab];
const tabs: SidebarTabDefinition[] = [filesTab, changesTab, reviewTab];
const activeTabDef = tabs.find((t) => t.id === activeTab) ?? tabs[0];

const tabCount = tabs.length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export function SidebarHeader({
compact,
inverted: true,
}),
"relative min-w-0 flex-1 justify-center",
// Size by content: equal thirds truncate "Changes 99+" to
// "Ch…" at the default width while "Files" sits on slack.
"relative min-w-0 flex-auto justify-center",
// The resizable panel already draws the sidebar's left edge.
index === 0 && "border-l-transparent",
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ export function BaseBranchSelector({
return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
{/* Same chip as the commit-filter trigger beside it, so "vs" sits
between two equal paddings instead of hugging the branch. */}
<button
type="button"
className="inline-flex min-w-0 items-center gap-0.5 font-medium text-foreground hover:underline"
className="flex min-w-0 items-center gap-1 rounded px-1.5 py-0.5 font-medium text-foreground text-xs hover:bg-accent"
>
<span className="min-w-0 truncate" title={currentValue}>
{currentValue}
</span>
<ChevronDown className="size-3 shrink-0" />
<ChevronDown className="size-3 shrink-0 text-muted-foreground" />
</button>
</PopoverTrigger>
<PopoverContent
Expand Down
Loading
Loading