Skip to content

Commit 1fe3148

Browse files
Keep chat and right-panel controls on one row
- tighten the chat header layout for compact widths - move right-panel maximize control into the titlebar strip - update responsive panel tab spacing and alignment
1 parent 75812ac commit 1fe3148

5 files changed

Lines changed: 127 additions & 77 deletions

File tree

‎apps/web/src/components/ChatView.browser.tsx‎

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,6 +2110,48 @@ describe("ChatView timeline estimator parity (full app)", () => {
21102110
}
21112111
});
21122112

2113+
it("keeps the compact chat header on one row", async () => {
2114+
const mounted = await mountChatView({
2115+
viewport: COMPACT_FOOTER_VIEWPORT,
2116+
snapshot: createSnapshotForTargetUser({
2117+
targetMessageId: "msg-user-compact-header" as MessageId,
2118+
targetText: "keep the compact header aligned",
2119+
}),
2120+
});
2121+
2122+
try {
2123+
const chatHeader = await waitForElement(
2124+
() => document.querySelector<HTMLElement>("[data-chat-header]"),
2125+
"Unable to find chat header.",
2126+
);
2127+
const threadTitle = await waitForElement(
2128+
() => chatHeader.querySelector<HTMLElement>("h2"),
2129+
"Unable to find thread title.",
2130+
);
2131+
const headerActions = await waitForElement(
2132+
() => document.querySelector<HTMLElement>("[data-chat-header-actions]"),
2133+
"Unable to find chat header actions.",
2134+
);
2135+
2136+
const headerRect = chatHeader.getBoundingClientRect();
2137+
const titleRect = threadTitle.getBoundingClientRect();
2138+
const actionsRect = headerActions.getBoundingClientRect();
2139+
const headerCenter = headerRect.top + headerRect.height / 2;
2140+
2141+
expect(headerRect.height).toBe(52);
2142+
expect(titleRect.top).toBeGreaterThanOrEqual(headerRect.top);
2143+
expect(titleRect.bottom).toBeLessThanOrEqual(headerRect.bottom);
2144+
expect(actionsRect.top).toBeGreaterThanOrEqual(headerRect.top);
2145+
expect(actionsRect.bottom).toBeLessThanOrEqual(headerRect.bottom);
2146+
expect(Math.abs(titleRect.top + titleRect.height / 2 - headerCenter)).toBeLessThanOrEqual(1);
2147+
expect(Math.abs(actionsRect.top + actionsRect.height / 2 - headerCenter)).toBeLessThanOrEqual(
2148+
1,
2149+
);
2150+
} finally {
2151+
await mounted.cleanup();
2152+
}
2153+
});
2154+
21132155
it("keeps panel toggles fixed and can maximize the right panel", async () => {
21142156
const mounted = await mountChatView({
21152157
viewport: WIDE_FOOTER_VIEWPORT,
@@ -2353,12 +2395,34 @@ describe("ChatView timeline estimator parity (full app)", () => {
23532395
() => sheet.querySelector<HTMLElement>("[data-panel-layout-controls]"),
23542396
"Unable to find shared controls in the responsive right-panel sheet.",
23552397
);
2356-
2398+
const tabbar = await waitForElement(
2399+
() => sheet.querySelector<HTMLElement>("[data-right-panel-tabbar]"),
2400+
"Unable to find responsive right-panel tabbar.",
2401+
);
2402+
const controlButtons = Array.from(controls.querySelectorAll<HTMLButtonElement>("button"));
2403+
const tabbarRect = tabbar.getBoundingClientRect();
2404+
const controlsRect = controls.getBoundingClientRect();
2405+
2406+
expect(controlButtons.map((button) => button.getAttribute("aria-label"))).toEqual([
2407+
"Toggle terminal drawer",
2408+
"Toggle right panel",
2409+
]);
2410+
expect(tabbarRect.height).toBe(52);
2411+
expect(controlsRect.height).toBe(52);
2412+
expect(controlsRect.top).toBe(tabbarRect.top);
2413+
expect(window.innerWidth - controlsRect.right).toBe(12);
2414+
for (const button of controlButtons) {
2415+
const rect = button.getBoundingClientRect();
2416+
const buttonCenter = rect.top + rect.height / 2;
2417+
const tabbarCenter = tabbarRect.top + tabbarRect.height / 2;
2418+
expect(rect.width).toBe(32);
2419+
expect(rect.height).toBe(32);
2420+
expect(Math.abs(buttonCenter - tabbarCenter)).toBeLessThanOrEqual(1);
2421+
}
23572422
expect(
2358-
Array.from(controls.querySelectorAll<HTMLButtonElement>("button")).map((button) =>
2359-
button.getAttribute("aria-label"),
2360-
),
2361-
).toEqual(["Toggle terminal drawer", "Toggle right panel"]);
2423+
controlButtons[1]!.getBoundingClientRect().left -
2424+
controlButtons[0]!.getBoundingClientRect().right,
2425+
).toBe(4);
23622426
expect(sheet.querySelector('button[aria-label="Maximize panel"]')).toBeNull();
23632427
expect(sheet.querySelector('button[aria-label="Close tasks sidebar"]')).toBeNull();
23642428

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ import { ExpandedImageDialog } from "./chat/ExpandedImageDialog";
169169
import { PullRequestThreadDialog } from "./PullRequestThreadDialog";
170170
import { MessagesTimeline } from "./chat/MessagesTimeline";
171171
import { ChatHeader } from "./chat/ChatHeader";
172-
import { PanelLayoutControls } from "./chat/PanelLayoutControls";
172+
import { PanelLayoutControls, RightPanelMaximizeControl } from "./chat/PanelLayoutControls";
173173
import { type ExpandedImagePreview } from "./chat/ExpandedImagePreview";
174174
import { NoActiveThreadState } from "./NoActiveThreadState";
175175
import { resolveEffectiveEnvMode, resolveEnvironmentOptionLabel } from "./BranchToolbar.logic";
@@ -1331,9 +1331,8 @@ function ChatViewContent(props: ChatViewProps) {
13311331
const planSidebarOpen = activeRightPanelKind === "plan";
13321332
const previewPanelOpen = activeRightPanelKind === "preview" && isPreviewSupportedInRuntime();
13331333
const rightPanelOpen = rightPanelState.isOpen;
1334-
const canMaximizeRightPanel = rightPanelOpen && !shouldUsePlanSidebarSheet;
13351334
const rightPanelMaximized =
1336-
canMaximizeRightPanel && maximizedRightPanelThreadKey === routeThreadKey;
1335+
rightPanelOpen && !shouldUsePlanSidebarSheet && maximizedRightPanelThreadKey === routeThreadKey;
13371336
const inlineRightPanelOwnsTitleBar = rightPanelOpen && !shouldUsePlanSidebarSheet;
13381337

13391338
useEffect(() => {
@@ -3114,7 +3113,7 @@ function ChatViewContent(props: ChatViewProps) {
31143113
useRightPanelStore.getState().toggleVisibility(activeThreadRef);
31153114
}, [activeThreadRef, closePlanSidebar, closePreviewPanel, planSidebarOpen, rightPanelOpen]);
31163115
const toggleRightPanelMaximized = () => {
3117-
if (!canMaximizeRightPanel) return;
3116+
if (!rightPanelOpen || shouldUsePlanSidebarSheet) return;
31183117
setMaximizedRightPanelThreadKey((threadKey) =>
31193118
threadKey === routeThreadKey ? null : routeThreadKey,
31203119
);
@@ -4589,36 +4588,28 @@ function ChatViewContent(props: ChatViewProps) {
45894588
return <NoActiveThreadState />;
45904589
}
45914590

4592-
const panelLayoutControls = (
4591+
const panelToggleControls = (
45934592
<PanelLayoutControls
45944593
terminalAvailable={Boolean(activeProject)}
45954594
terminalOpen={Boolean(terminalUiState.terminalOpen)}
45964595
terminalShortcutLabel={terminalToggleShortcutLabel}
45974596
rightPanelAvailable={Boolean(activeProject)}
45984597
rightPanelOpen={rightPanelOpen}
45994598
rightPanelShortcutLabel={rightPanelToggleShortcutLabel}
4600-
rightPanelMaximized={rightPanelMaximized}
4601-
canMaximizeRightPanel={canMaximizeRightPanel}
46024599
onToggleTerminal={toggleTerminalVisibility}
46034600
onToggleRightPanel={toggleRightPanel}
4604-
onToggleRightPanelMaximized={toggleRightPanelMaximized}
46054601
/>
46064602
);
4607-
const sheetPanelLayoutControls = (
4608-
<PanelLayoutControls
4609-
placement="panel-header"
4610-
terminalAvailable={Boolean(activeProject)}
4611-
terminalOpen={Boolean(terminalUiState.terminalOpen)}
4612-
terminalShortcutLabel={terminalToggleShortcutLabel}
4613-
rightPanelAvailable={Boolean(activeProject)}
4614-
rightPanelOpen={rightPanelOpen}
4615-
rightPanelShortcutLabel={rightPanelToggleShortcutLabel}
4616-
rightPanelMaximized={rightPanelMaximized}
4617-
canMaximizeRightPanel={canMaximizeRightPanel}
4618-
onToggleTerminal={toggleTerminalVisibility}
4619-
onToggleRightPanel={toggleRightPanel}
4620-
onToggleRightPanelMaximized={toggleRightPanelMaximized}
4621-
/>
4603+
const panelLayoutControls = (
4604+
<div className="workspace-titlebar-controls z-50 gap-1 [-webkit-app-region:no-drag]">
4605+
{rightPanelOpen && !shouldUsePlanSidebarSheet ? (
4606+
<RightPanelMaximizeControl
4607+
maximized={rightPanelMaximized}
4608+
onToggle={toggleRightPanelMaximized}
4609+
/>
4610+
) : null}
4611+
{panelToggleControls}
4612+
</div>
46224613
);
46234614
const rightPanelContent = activeThreadRef ? (
46244615
activeRightPanelSurface?.kind === "preview" ? (
@@ -4689,7 +4680,7 @@ function ChatViewContent(props: ChatViewProps) {
46894680
{isElectron && activeThreadRef ? (
46904681
<PreviewAutomationOwner threadRef={activeThreadRef} visible={previewPanelOpen} />
46914682
) : null}
4692-
{rightPanelOpen ? panelLayoutControls : null}
4683+
{rightPanelOpen && !shouldUsePlanSidebarSheet ? panelLayoutControls : null}
46934684
<div
46944685
className={cn(
46954686
"flex min-h-0 min-w-0 flex-col overflow-hidden",
@@ -4962,7 +4953,7 @@ function ChatViewContent(props: ChatViewProps) {
49624953
<RightPanelSheet open onClose={planSidebarOpen ? closePlanSidebar : closePreviewPanel}>
49634954
<RightPanelTabs
49644955
mode="sheet"
4965-
headerControls={sheetPanelLayoutControls}
4956+
layoutControls={panelToggleControls}
49664957
surfaces={rightPanelState.surfaces}
49674958
activeSurfaceId={activeRightPanelSurface?.id ?? null}
49684959
pendingSurfaceIds={pendingFileSurfaceIds}

‎apps/web/src/components/RightPanelTabs.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { PierreEntryIcon } from "./chat/PierreEntryIcon";
1818
interface RightPanelTabsProps {
1919
mode: PreviewPanelMode;
2020
maximized?: boolean;
21-
headerControls?: ReactNode;
21+
layoutControls?: ReactNode;
2222
surfaces: readonly RightPanelSurface[];
2323
activeSurfaceId: string | null;
2424
pendingSurfaceIds: ReadonlySet<string>;
@@ -270,8 +270,8 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
270270
>
271271
<div
272272
className={cn(
273-
"gap-1 px-2",
274-
props.mode === "inline" ? "workspace-topbar pr-28" : "flex h-10 shrink-0 items-center",
273+
"workspace-topbar gap-1 pl-2",
274+
props.mode === "inline" ? "pr-28" : "pr-3",
275275
ownsDesktopTitleBar && "wco:pr-[calc(var(--workspace-native-controls-inset)+6rem)]",
276276
)}
277277
data-right-panel-tabbar
@@ -384,7 +384,7 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
384384
) : null}
385385
</div>
386386
</ScrollArea>
387-
{props.headerControls}
387+
{props.layoutControls}
388388
</div>
389389
<div className="flex min-h-0 flex-1 flex-col">
390390
{props.activeSurfaceId === null ? (

‎apps/web/src/components/chat/ChatHeader.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ export const ChatHeader = memo(function ChatHeader({
7272
primaryEnvironmentId,
7373
});
7474
return (
75-
<div className="@container/header-actions flex min-w-0 flex-1 flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
76-
<div className="flex min-w-0 flex-wrap items-center gap-2 overflow-hidden sm:flex-1 sm:flex-nowrap sm:gap-3">
75+
<div className="@container/header-actions flex min-w-0 flex-1 items-center gap-2 sm:gap-3">
76+
<div className="flex min-w-0 flex-1 items-center gap-2 overflow-hidden sm:gap-3">
7777
<SidebarTrigger className="size-7 shrink-0 md:hidden" />
7878
<Tooltip>
7979
<TooltipTrigger
8080
render={
8181
<h2
8282
aria-label={activeThreadTitle}
83-
className="min-w-0 flex-1 basis-40 truncate text-sm font-medium text-foreground"
83+
className="min-w-0 flex-1 truncate text-sm font-medium text-foreground"
8484
>
8585
{activeThreadTitle}
8686
</h2>
@@ -92,7 +92,7 @@ export const ChatHeader = memo(function ChatHeader({
9292
<div
9393
data-chat-header-actions
9494
className={cn(
95-
"flex min-w-0 flex-wrap items-center justify-start gap-2 sm:shrink-0 sm:justify-end @3xl/header-actions:gap-3",
95+
"flex shrink-0 items-center justify-end gap-2 @3xl/header-actions:gap-3",
9696
rightPanelOpen ? "pr-0" : "pr-16",
9797
)}
9898
>

‎apps/web/src/components/chat/PanelLayoutControls.tsx‎

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,35 @@
11
import { Maximize2Icon, Minimize2Icon, PanelBottomIcon, PanelRightIcon } from "lucide-react";
22
import { memo } from "react";
33

4-
import { cn } from "~/lib/utils";
5-
64
import { Toggle } from "../ui/toggle";
75
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
86

97
interface PanelLayoutControlsProps {
10-
placement?: "titlebar" | "panel-header";
118
terminalAvailable: boolean;
129
terminalOpen: boolean;
1310
terminalShortcutLabel: string | null;
1411
rightPanelAvailable: boolean;
1512
rightPanelOpen: boolean;
1613
rightPanelShortcutLabel: string | null;
17-
rightPanelMaximized: boolean;
18-
canMaximizeRightPanel: boolean;
1914
onToggleTerminal: () => void;
2015
onToggleRightPanel: () => void;
21-
onToggleRightPanelMaximized: () => void;
2216
}
2317

2418
export const PanelLayoutControls = memo(function PanelLayoutControls({
25-
placement = "titlebar",
2619
terminalAvailable,
2720
terminalOpen,
2821
terminalShortcutLabel,
2922
rightPanelAvailable,
3023
rightPanelOpen,
3124
rightPanelShortcutLabel,
32-
rightPanelMaximized,
33-
canMaximizeRightPanel,
3425
onToggleTerminal,
3526
onToggleRightPanel,
36-
onToggleRightPanelMaximized,
3727
}: PanelLayoutControlsProps) {
3828
return (
3929
<div
40-
className={cn(
41-
"z-50 flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]",
42-
placement === "titlebar" ? "workspace-titlebar-controls" : "h-full",
43-
)}
30+
className="flex h-full shrink-0 items-center gap-1 [-webkit-app-region:no-drag]"
4431
data-panel-layout-controls
4532
>
46-
{rightPanelOpen && canMaximizeRightPanel ? (
47-
<Tooltip>
48-
<TooltipTrigger
49-
render={
50-
<Toggle
51-
className="shrink-0 [-webkit-app-region:no-drag]"
52-
pressed={rightPanelMaximized}
53-
onPressedChange={onToggleRightPanelMaximized}
54-
aria-label={rightPanelMaximized ? "Restore panel size" : "Maximize panel"}
55-
variant="ghost"
56-
size="sm"
57-
>
58-
{rightPanelMaximized ? (
59-
<Minimize2Icon className="size-3.5" />
60-
) : (
61-
<Maximize2Icon className="size-3.5" />
62-
)}
63-
</Toggle>
64-
}
65-
/>
66-
<TooltipPopup side="bottom">
67-
{rightPanelMaximized ? "Restore panel size" : "Maximize panel"}
68-
</TooltipPopup>
69-
</Tooltip>
70-
) : null}
7133
<Tooltip>
7234
<TooltipTrigger
7335
render={
@@ -115,3 +77,36 @@ export const PanelLayoutControls = memo(function PanelLayoutControls({
11577
</div>
11678
);
11779
});
80+
81+
export const RightPanelMaximizeControl = memo(function RightPanelMaximizeControl({
82+
maximized,
83+
onToggle,
84+
}: {
85+
maximized: boolean;
86+
onToggle: () => void;
87+
}) {
88+
const label = maximized ? "Restore panel size" : "Maximize panel";
89+
return (
90+
<Tooltip>
91+
<TooltipTrigger
92+
render={
93+
<Toggle
94+
className="shrink-0 [-webkit-app-region:no-drag]"
95+
pressed={maximized}
96+
onPressedChange={onToggle}
97+
aria-label={label}
98+
variant="ghost"
99+
size="sm"
100+
>
101+
{maximized ? (
102+
<Minimize2Icon className="size-3.5" />
103+
) : (
104+
<Maximize2Icon className="size-3.5" />
105+
)}
106+
</Toggle>
107+
}
108+
/>
109+
<TooltipPopup side="bottom">{label}</TooltipPopup>
110+
</Tooltip>
111+
);
112+
});

0 commit comments

Comments
 (0)