Skip to content

Commit 2dde1a9

Browse files
t3dotggclaude
andcommitted
fix(web): docked workspace card keeps space around chat
When the card docked, chat kept its full width and the margins shrank to 20px, so chat and card looked jammed together. Docked chat now keeps 96px on each side and gives up width first. Below a 640px chat, the card becomes the popover. A full-width chat keeps its normal padding. The card is also lighter: 280px wide, 32px rows, no section labels, and no "Project folder" hint. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 12bbc07 commit 2dde1a9

13 files changed

Lines changed: 97 additions & 55 deletions

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ export const BranchToolbarEnvModeSelector = memo(function BranchToolbarEnvModeSe
5959
}: BranchToolbarEnvModeSelectorProps) {
6060
const workspacePath = displayMode === "panel" ? (activeWorktreePath ?? workspaceRoot) : null;
6161
const workspaceDisplayName = resolveWorkspaceDisplayName(workspacePath);
62-
const workspaceKind = activeWorktreePath ? "Worktree" : "Project folder";
62+
// The panel names the workspace kind only when it is not the project folder.
63+
const workspaceKind = activeWorktreePath ? "Worktree" : null;
64+
const lockedWorkspaceKind = forceNewWorktree ? "Worktree" : workspaceKind;
65+
const selectWorkspaceKind =
66+
effectiveEnvMode === "worktree" && !activeWorktreePath ? "Create" : workspaceKind;
6367
const composerFloatingLayerProps = useComposerMenuProps();
6468
const showPreviousWorktree = Boolean(previousWorktreeLabel && onUsePreviousWorktree);
6569
const envModeItems = useMemo(
@@ -147,9 +151,9 @@ export const BranchToolbarEnvModeSelector = memo(function BranchToolbarEnvModeSe
147151
: (workspaceDisplayName ??
148152
resolveLockedWorkspaceLabel(activeWorktreePath, effectiveEnvMode))}
149153
</ComposerContextLabel>
150-
{displayMode === "panel" ? (
154+
{displayMode === "panel" && lockedWorkspaceKind ? (
151155
<span className="shrink-0 text-3xs font-normal text-muted-foreground/70">
152-
{forceNewWorktree ? "Worktree" : workspaceKind}
156+
{lockedWorkspaceKind}
153157
</span>
154158
) : null}
155159
</span>
@@ -210,9 +214,9 @@ export const BranchToolbarEnvModeSelector = memo(function BranchToolbarEnvModeSe
210214
<ComposerContextLabel displayMode={displayMode}>
211215
<SelectValue />
212216
</ComposerContextLabel>
213-
{displayMode === "panel" ? (
217+
{displayMode === "panel" && selectWorkspaceKind ? (
214218
<span className="shrink-0 text-3xs font-normal text-muted-foreground/70">
215-
{effectiveEnvMode === "worktree" && !activeWorktreePath ? "Create" : workspaceKind}
219+
{selectWorkspaceKind}
216220
</span>
217221
) : null}
218222
</TooltipTrigger>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,7 @@ export default function GitActionsControl({
18781878
// the output row expands below.
18791879
<GitActionElapsedTime
18801880
startedAtMs={gitActionProgress.startedAtMs}
1881-
className="flex h-9 shrink-0 items-center self-start pe-2.5 text-2xs font-normal tabular-nums text-muted-foreground"
1881+
className="flex h-8 shrink-0 items-center self-start pe-2.5 text-2xs font-normal tabular-nums text-muted-foreground"
18821882
/>
18831883
) : (
18841884
<>

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import {
88
type CSSProperties,
99
} from "react";
1010
import { ChatCanvasContext } from "./ChatCanvasContext";
11-
import { resolveChatCanvasLayout, type ChatCanvasPreview } from "./chatCanvasLayout";
11+
import {
12+
resolveChatCanvasLayout,
13+
resolveDockedChatMargin,
14+
type ChatCanvasPreview,
15+
} from "./chatCanvasLayout";
1216
import type { PreviewMiniPlayerObstacles } from "../preview/previewMiniPlayerLayout";
1317

1418
/**
@@ -99,7 +103,10 @@ export function ChatCanvas({
99103
const container = { width: measurements.width, height: measurements.height };
100104
return {
101105
container,
102-
lane: { padding: measurements.padding, minChatWidth: measurements.minChatWidth },
106+
lane: {
107+
margin: resolveDockedChatMargin(measurements),
108+
minChatWidth: measurements.minChatWidth,
109+
},
103110
layout: resolveChatCanvasLayout({ ...measurements, container, preview, detailsCard }),
104111
previewKey: preview?.key ?? null,
105112
reportPreview,

‎apps/web/src/components/chat/ChatCanvasContext.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { PreviewMiniPlayerObstacles } from "../preview/previewMiniPlayerLay
44

55
export const ChatCanvasContext = createContext<{
66
container: { width: number; height: number };
7-
lane: { padding: number; minChatWidth: number };
7+
lane: { margin: number; minChatWidth: number };
88
layout: ReturnType<typeof resolveChatCanvasLayout>;
99
previewKey: string | null;
1010
reportPreview: (preview: ChatCanvasPreview) => void;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function ThreadDetailsControl({
5656
className: cn(
5757
"relative inline-flex shrink-0 cursor-pointer items-center whitespace-nowrap border outline-none transition-[box-shadow,scale] [&:active:not([aria-haspopup])]:scale-[0.97] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 disabled:pointer-events-none disabled:opacity-64 aria-disabled:cursor-not-allowed aria-disabled:opacity-64 [&_svg]:shrink-0",
5858
parts[part],
59-
multiline && "h-auto min-h-9 py-0.75 disabled:opacity-100 sm:h-auto",
59+
multiline && "h-auto min-h-8 py-0.75 disabled:opacity-100 sm:h-auto",
6060
tone === "muted" && "text-muted-foreground/70 hover:text-foreground/80",
6161
tone === "destructive" &&
6262
"text-destructive hover:text-destructive data-pressed:text-destructive",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
126126
headingId="thread-details-workspace-heading"
127127
title="Workspace"
128128
separated={false}
129-
showHeading={density === "full"}
129+
showHeading={false}
130130
>
131131
{props.versionMismatch ? (
132132
<div className="mx-1 mb-2 flex gap-2 rounded-xl border border-warning/30 bg-warning/6 p-3">
@@ -198,7 +198,7 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
198198
<ThreadDetailsSection
199199
headingId="thread-details-version-control-heading"
200200
title="Version Control"
201-
showHeading={density === "full"}
201+
showHeading={false}
202202
separated={density === "full"}
203203
>
204204
<div className="flex flex-col">

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export function ThreadLineageRowList(props: {
9797
<button
9898
type="button"
9999
onClick={props.onShowMore}
100-
className={`flex h-9 w-full cursor-pointer items-center rounded-lg ${THREAD_DETAILS_PANEL_ROW_CONTENT_CLASS} text-sm font-medium text-muted-foreground/70 hover:bg-black/[0.055] hover:text-foreground/80 dark:hover:bg-white/[0.075]`}
100+
className={`flex h-8 w-full cursor-pointer items-center rounded-lg ${THREAD_DETAILS_PANEL_ROW_CONTENT_CLASS} text-sm font-medium text-muted-foreground/70 hover:bg-black/[0.055] hover:text-foreground/80 dark:hover:bg-white/[0.075]`}
101101
>
102102
<PlusIcon aria-hidden className="size-4 shrink-0" />
103103
Show {Math.min(props.hiddenCount, THREAD_LINEAGE_PAGE_COUNT)} more
@@ -394,7 +394,7 @@ export function ThreadRelationshipsPanel(props: {
394394
</>
395395
);
396396
return (
397-
<li key={threadId} className="group flex h-9 items-center rounded-lg">
397+
<li key={threadId} className="group flex h-8 items-center rounded-lg">
398398
{isMergeTarget ? (
399399
<div className={THREAD_DETAILS_PANEL_LINK_SPLIT_GROUP_CLASS}>
400400
<Tooltip>

‎apps/web/src/components/chat/chatCanvasLayout.test.ts‎

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ describe("chat canvas layout", () => {
214214
const density = (result: ReturnType<typeof layout>) => {
215215
const card = resolveThreadDetailsCardLayout({
216216
container,
217-
lane: { padding: 20, minChatWidth: 640 },
217+
lane: { margin: 96, minChatWidth: 640 },
218218
frame: result.frame,
219219
overlapsDetailsCard: result.overlapsDetailsCard,
220220
});
@@ -258,33 +258,41 @@ describe("chat canvas layout", () => {
258258
});
259259

260260
describe("workspace card docking", () => {
261-
const withCard = (width: number, player: ChatCanvasPreview | null = null) =>
261+
const withCard = (width: number, player: ChatCanvasPreview | null = null, maxChatWidth = 736) =>
262262
resolveChatCanvasLayout({
263263
container: { width, height: 900 },
264-
maxChatWidth: 736,
264+
maxChatWidth,
265265
composerHeight: 180,
266-
detailsCard: { left: width - 324, right: width - 12, bottom: 400 },
266+
detailsCard: { left: width - 292, right: width - 12, bottom: 400 },
267267
preview: player,
268268
});
269269
it("floats the card while the centered chat stays clear of it", () => {
270-
expect(withCard(1576).chat).toEqual({ left: 420, width: 736, insetStart: 0, insetEnd: 0 });
270+
expect(withCard(1512).chat).toEqual({ left: 388, width: 736, insetStart: 0, insetEnd: 0 });
271271
});
272272
it("docks the card and centers chat beside it once the margin is tight", () => {
273-
expect(withCard(1575).chat).toEqual({
274-
left: 251.5,
273+
expect(withCard(1511).chat).toEqual({
274+
left: 241.5,
275275
width: 736,
276-
insetStart: 0,
277-
insetEnd: 336,
276+
insetStart: 76,
277+
insetEnd: 368,
278278
});
279-
expect(withCard(1411).chat).toMatchObject({ left: 169.5, width: 736 });
279+
expect(withCard(1411).chat).toMatchObject({ left: 191.5, width: 736 });
280+
});
281+
it("narrows docked chat before giving up the space beside it", () => {
282+
expect(withCard(1147).chat).toEqual({ left: 96, width: 663, insetStart: 76, insetEnd: 368 });
283+
expect(withCard(1124).chat).toMatchObject({ left: 96, width: 640 });
280284
});
281-
it("shrinks docked chat down to its readable width", () => {
282-
expect(withCard(1100).chat).toEqual({ left: 20, width: 724, insetStart: 0, insetEnd: 336 });
283-
expect(withCard(1016).chat).toMatchObject({ left: 20, width: 640 });
285+
it("keeps a full-width chat at its normal padding beside the card", () => {
286+
expect(withCard(1147, null, 10_000).chat).toEqual({
287+
left: 20,
288+
width: 815,
289+
insetStart: 0,
290+
insetEnd: 292,
291+
});
284292
});
285293
it("keeps docked chat in place when a new preview opens below the card", () => {
286294
expect(withCard(1411, preview)).toEqual({
287-
chat: { left: 169.5, width: 736, insetStart: 0, insetEnd: 336 },
295+
chat: { left: 191.5, width: 736, insetStart: 76, insetEnd: 368 },
288296
frame: { x: 1079, y: 688, width: 320, height: 200 },
289297
overlapsChat: false,
290298
overlapsDetailsCard: false,

‎apps/web/src/components/chat/chatCanvasLayout.ts‎

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,28 @@ export interface ChatCanvasPreview {
1919
}
2020

2121
const GAP = 12;
22-
// The workspace card floats in the right margin only while the centered chat
23-
// stays this far from it. Closer than this, the card looks stuck to the chat.
24-
const DETAILS_CARD_FLOAT_CLEARANCE = 96;
22+
// Space between chat and the workspace card. The card floats in the right
23+
// margin while the centered chat clears it by this much. Closer than this, the
24+
// card docks and chat keeps this space on both sides.
25+
const DETAILS_CARD_CLEARANCE = 96;
26+
27+
/**
28+
* Space on each side of chat while the workspace card is docked. Chat gives up
29+
* width before this space. It never exceeds the centered margin, so a
30+
* full-width chat stays full width.
31+
*/
32+
export function resolveDockedChatMargin({
33+
width,
34+
padding,
35+
maxChatWidth,
36+
}: {
37+
width: number;
38+
padding: number;
39+
maxChatWidth: number;
40+
}) {
41+
const centeredWidth = Math.max(0, Math.min(maxChatWidth, width - padding * 2));
42+
return Math.min(DETAILS_CARD_CLEARANCE, (width - centeredWidth) / 2);
43+
}
2544

2645
/** Pure geometry shared by the conversation, composer, workspace card, and floating preview. */
2746
export function resolveChatCanvasLayout({
@@ -44,18 +63,21 @@ export function resolveChatCanvasLayout({
4463
const centeredWidth = Math.max(0, Math.min(maxChatWidth, container.width - padding * 2));
4564
// Without that clearance the card docks like a sidebar, and chat centers in
4665
// the space to its left.
47-
const laneRight =
48-
detailsCard &&
49-
(container.width + centeredWidth) / 2 + DETAILS_CARD_FLOAT_CLEARANCE > detailsCard.left
50-
? detailsCard.left - GAP
51-
: container.width;
52-
const normalWidth = Math.max(0, Math.min(maxChatWidth, laneRight - padding * 2));
66+
const docked =
67+
detailsCard !== null &&
68+
(container.width + centeredWidth) / 2 + DETAILS_CARD_CLEARANCE > detailsCard.left;
69+
const laneRight = docked ? detailsCard.left : container.width;
70+
const margin = docked
71+
? resolveDockedChatMargin({ width: container.width, padding, maxChatWidth })
72+
: padding;
73+
const normalWidth = Math.max(0, Math.min(maxChatWidth, laneRight - margin * 2));
5374
const normalLeft = (laneRight - normalWidth) / 2;
75+
// The lane CSS adds `padding` on each side, so the insets carry the rest.
5476
let chat = {
5577
left: normalLeft,
5678
width: normalWidth,
57-
insetStart: 0,
58-
insetEnd: container.width - laneRight,
79+
insetStart: margin - padding,
80+
insetEnd: container.width - laneRight + margin - padding,
5981
};
6082
let frame: PreviewMiniPlayerFrame | null = null;
6183
let overlapsChat = false;

‎apps/web/src/components/chat/threadDetailsCardLayout.test.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
resolveThreadDetailsCardLayout,
55
} from "./threadDetailsCardLayout";
66

7-
const lane = { padding: 20, minChatWidth: 640 };
7+
const lane = { margin: 96, minChatWidth: 640 };
88
const resolve = (width: number, height: number, previewY: number | null = null) =>
99
resolveThreadDetailsCardLayout({
1010
container: { width, height },
@@ -15,24 +15,24 @@ const resolve = (width: number, height: number, previewY: number | null = null)
1515
describe("workspace card", () => {
1616
it("pins to the top right at a fixed width", () => {
1717
expect(resolve(1600, 900)).toEqual({
18-
x: 1276,
18+
x: 1308,
1919
y: 12,
20-
width: 312,
20+
width: 280,
2121
height: 876,
2222
});
23-
expect(resolve(1344, 900)).toMatchObject({ x: 1020, width: 312 });
23+
expect(resolve(1344, 900)).toMatchObject({ x: 1052, width: 280 });
2424
});
25-
it("hides when a readable chat lane cannot fit beside it", () => {
26-
expect(resolve(1016, 900)).toMatchObject({ x: 692 });
27-
expect(resolve(1015, 900)).toBeNull();
25+
it("hides when a readable chat lane and its margins cannot fit beside it", () => {
26+
expect(resolve(1124, 900)).toMatchObject({ x: 832 });
27+
expect(resolve(1123, 900)).toBeNull();
2828
});
2929
it("keeps the card at the top right while the preview is freely dragged vertically", () => {
3030
for (const y of [12, 170, 250, 400, 648]) {
31-
expect(resolve(1600, 900, y)).toEqual({ x: 1276, y: 12, width: 312, height: 876 });
31+
expect(resolve(1600, 900, y)).toEqual({ x: 1308, y: 12, width: 280, height: 876 });
3232
}
3333
});
3434
it("keeps full height while a preview stays clear of the card", () => {
35-
expect(resolve(1344, 900, 600)).toMatchObject({ width: 312, height: 876 });
35+
expect(resolve(1344, 900, 600)).toMatchObject({ width: 280, height: 876 });
3636
expect(
3737
resolveThreadDetailsCardLayout({
3838
container: { width: 1600, height: 900 },
@@ -54,7 +54,7 @@ describe("card content fitting", () => {
5454
it("does not fold in response to a drag while the full card can be kept clear", () => {
5555
for (const y of [12, 170, 225, 240, 340, 380, 611]) {
5656
const placement = place(y)!;
57-
expect(placement).toMatchObject({ x: 1260, y: 12, height: 964 });
57+
expect(placement).toMatchObject({ x: 1292, y: 12, height: 964 });
5858
expect(resolveThreadDetailsCardDensity(placement.height, { full: 327, compact: 182 })).toBe(
5959
"full",
6060
);

0 commit comments

Comments
 (0)