Skip to content

Commit 447d71d

Browse files
koushikxdclaude
andauthored
fix(web): chat stays centered while the thread details card fits beside it (#25838)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 95ca05d commit 447d71d

2 files changed

Lines changed: 8 additions & 21 deletions

File tree

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,16 @@ describe("chat canvas layout", () => {
102102
});
103103
expect(result.frame).toEqual({ x: 1260, y: 351, width: 240, height: 365 });
104104
expect(result.overlapsDetailsCard).toBe(false);
105-
expect(result.chat).toEqual({ left: 330, width: 736, insetStart: 0, insetEnd: 188 });
105+
expect(result.chat).toEqual({ left: 424, width: 736, insetStart: 0, insetEnd: 0 });
106106
});
107-
it("centers the chat beside a details card it would crowd", () => {
107+
it("moves the chat left only as far as a details card it would crowd requires", () => {
108108
const { chat } = resolveChatCanvasLayout({
109109
container: { width: 1344, height: 988 },
110110
maxChatWidth: 736,
111111
detailsCard: { left: 1052, right: 1332, bottom: 339 },
112112
preview: null,
113113
});
114-
// Equal space on both sides of the chat.
115-
expect(chat).toMatchObject({ left: (1052 - 736) / 2, width: 736 });
114+
expect(chat).toMatchObject({ left: 1052 - 32 - 736, width: 736 });
116115
});
117116
it("keeps the chat canvas-centered when it clears the details card", () => {
118117
const result = resolveChatCanvasLayout({
@@ -255,7 +254,7 @@ describe("chat canvas layout", () => {
255254
const compact = layout(460);
256255
expect(compact.frame!.x + compact.frame!.width).toBe(1572);
257256
expect(compact.frame!.width).toBe(460);
258-
expect(compact.chat.left).toBe(330);
257+
expect(compact.chat.left).toBe(364);
259258
expect(compact.overlapsDetailsCard).toBe(true);
260259
expect(density(compact)).toBe("compact");
261260
expectClear(compact);
@@ -295,6 +294,9 @@ describe("workspace card beside chat", () => {
295294
detailsCard: { left: width - 292, right: width - 12, bottom: 400 },
296295
preview: player,
297296
});
297+
it("keeps chat centered while the card fits beside it", () => {
298+
expect(withCard(1500).chat).toEqual({ left: 382, width: 736, insetStart: 0, insetEnd: 0 });
299+
});
298300
it("narrows chat only after it reaches the left padding", () => {
299301
expect(withCard(1108).chat).toMatchObject({ left: 48, width: 736 });
300302
expect(withCard(1028).chat).toEqual({ left: 48, width: 656, insetStart: 0, insetEnd: 276 });

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,7 @@ export function resolveChatCanvasLayout({
4646
: container.width - padding;
4747
const normalWidth = Math.max(0, Math.min(centeredWidth, laneRight - padding));
4848
const canvasCenterLeft = (container.width - normalWidth) / 2;
49-
// Beside a card it would crowd, the chat centers between the card and the canvas edge. The shift
50-
// eases to zero as clearance grows, so very wide windows keep the chat still and a resize
51-
// never jumps it.
52-
const besideShift = detailsCard
53-
? Math.min(
54-
(container.width - detailsCard.left) / 2,
55-
Math.max(
56-
0,
57-
(container.width - detailsCard.left) / 2 - (laneRight - canvasCenterLeft - normalWidth),
58-
),
59-
)
60-
: 0;
61-
const normalLeft = Math.max(
62-
padding,
63-
Math.min(canvasCenterLeft - besideShift, laneRight - normalWidth),
64-
);
49+
const normalLeft = Math.max(padding, Math.min(canvasCenterLeft, laneRight - normalWidth));
6550
let chat = {
6651
left: normalLeft,
6752
width: normalWidth,

0 commit comments

Comments
 (0)