The best way to control Claude Code, Codex and more from any computer or phone
fix(web): thread details card no longer jumps mid panel animation (#22614)
Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Andrei committed
Nov 15, 2026 at 06:30 UTC
d080e4eb587898c5057d03b3c7148d113ddeccc3
5 files changed
+101
-5
apps/web/src/components/chat/ChatCanvas.tsx
+69
-2
@@ -7,6 +7,41 @@ import { selectThreadPanelOpen, useRightPanelStore } from "../../rightPanelStore
7
import { observeResize } from "../../lib/observeResize";
8
import type { ScopedThreadRef } from "@t3tools/contracts";
9
10
+function panelWidthTransitions(element: HTMLElement) {
11
+ const panels = element
12
+ .closest("[data-panel-animations]")
13
+ ?.querySelectorAll('[data-slot="sidebar-gap"], [data-preview-panel-mode="inline"]');
14
+ return Array.from(panels ?? []).flatMap((panel) =>
15
+ panel
16
+ .getAnimations()
17
+ .filter(
18
+ (animation): animation is CSSTransition =>
19
+ animation instanceof CSSTransition &&
20
+ animation.transitionProperty === "width" &&
21
+ animation.playState === "running",
22
+ ),
23
+ );
24
+}
25
+
26
+// Sample only the layout panels; seeking unrelated transitions can change their lifecycle.
27
+function measureTransitionWidths(element: HTMLElement, transitions: CSSTransition[]) {
28
+ if (transitions.length === 0) return null;
29
+ const times = transitions.map((animation) => animation.currentTime);
30
+ // Opposite panel transitions can reach their widest points at different times.
31
+ for (const animation of transitions) {
32
+ const end = Number(animation.effect?.getComputedTiming().endTime ?? 0);
33
+ animation.currentTime = 0;
34
+ const startWidth = element.clientWidth;
35
+ animation.currentTime = end;
36
+ if (startWidth < element.clientWidth) animation.currentTime = 0;
37
+ }
38
+ const narrowestWidth = element.clientWidth;
39
+ transitions.forEach((animation, index) => {
40
+ animation.currentTime = times[index] ?? null;
41
+ });
42
+ return { transitions, narrowestWidth };
43
+}
44
+
45
export function ChatCanvas({
46
store,
47
threadRef,
@@ -36,7 +71,34 @@ export function ChatCanvas({
71
if (!element || !probe) return;
72
const findBar =
73
detailsCardTopInset > 0 ? element.querySelector<HTMLElement>("[data-thread-find-bar]") : null;
74
+ let disposed = false;
75
+ // Seeking forces layout, so it runs once when a transition starts, not every frame.
76
+ let transitionWidths: ReturnType<typeof measureTransitionWidths> = null;
77
const measure = () => {
78
+ const width = element.clientWidth;
79
+ const transitions = panelWidthTransitions(element);
80
+ if (
81
+ transitions.length !== (transitionWidths?.transitions.length ?? 0) ||
82
+ transitions.some((animation, index) => animation !== transitionWidths?.transitions[index])
83
+ ) {
84
+ const settling = measureTransitionWidths(element, transitions);
85
+ if (settling && transitionWidths) {
86
+ settling.narrowestWidth = Math.min(
87
+ settling.narrowestWidth,
88
+ transitionWidths.narrowestWidth,
89
+ );
90
+ }
91
+ transitionWidths = settling;
92
+ // The last resize can arrive while the transitions still count as running.
93
+ if (settling) {
94
+ void Promise.allSettled(settling.transitions.map((animation) => animation.finished)).then(
95
+ () => {
96
+ if (disposed || transitionWidths !== settling) return;
97
+ measure();
98
+ },
99
+ );
100
+ }
101
+ }
102
const canvasBounds = element.getBoundingClientRect();
103
const findBarBounds = findBar?.getBoundingClientRect();
104
const styles = getComputedStyle(probe);
@@ -49,7 +111,8 @@ export function ChatCanvas({
111
bottom: findBarBounds ? findBarBounds.bottom - canvasBounds.top : 0,
112
}
113
: null,
52
- width: element.clientWidth,
114
+ width,
115
+ narrowestWidth: transitionWidths?.narrowestWidth ?? width,
116
height: element.clientHeight,
117
padding: Number.parseFloat(styles.paddingLeft),
118
maxChatWidth: Number.parseFloat(styles.width),
@@ -65,7 +128,11 @@ export function ChatCanvas({
128
if (findBar) observed.push(findBar);
129
if (composerOverlayElement) observed.push(composerOverlayElement);
130
if (timelineElement) observed.push(timelineElement);
68
- return observeResize(observed, measure);
131
+ const stopObserving = observeResize(observed, measure);
132
+ return () => {
133
+ disposed = true;
134
+ stopObserving();
135
+ };
136
}, [store, composerOverlayElement, timelineElement, detailsCardTopInset]);
137
const detailsCardInlineOpen = useRightPanelStore((state) =>
138
threadRef === null
apps/web/src/components/chat/canvasStore.test.ts
+6
-2
@@ -31,9 +31,9 @@ const preview: ChatCanvasPreview = {
31
32
describe("chat canvas model", () => {
33
it("shows the details card inline only where the canvas fits it beside the chat", () => {
34
- const resolve = (width: number) =>
34
+ const resolve = (width: number, narrowestWidth = width) =>
35
resolveChatCanvasModel({
36
- measurements: measurements(width),
36
+ measurements: { ...measurements(width), narrowestWidth },
37
detailsCardMeasurement: null,
38
threadRef,
39
preview: null,
@@ -41,6 +41,7 @@ describe("chat canvas model", () => {
41
}).detailsCardMode;
42
expect(resolve(1400)).toBe("inline");
43
expect(resolve(900)).toBe("popover");
44
+ expect(resolve(1400, 900)).toBe("popover");
45
});
46
47
it("moves the card into a popover when a preview below it leaves too little height", () => {
@@ -79,5 +80,8 @@ describe("chat canvas model", () => {
80
store.getState().measureDetailsCard({ threadRef, width: 280, fullContentHeight: 300 });
81
expect(measured.measurements).toBe(before.measurements);
82
expect(store.getState()).toBe(measured);
83
+ store.getState().setMeasurements({ ...measurements(1400), narrowestWidth: 900 });
84
+ expect(store.getState().measurements.narrowestWidth).toBe(900);
85
+ expect(store.getState()).not.toBe(measured);
86
});
87
});
apps/web/src/components/chat/canvasStore.ts
+4
@@ -13,6 +13,7 @@ interface CanvasEdges {
13
14
export interface ChatCanvasMeasurements {
15
readonly width: number;
16
+ readonly narrowestWidth?: number;
17
readonly height: number;
18
readonly padding: number;
19
readonly maxChatWidth: number;
@@ -47,6 +48,7 @@ const sameEdges = (a: CanvasEdges | null, b: CanvasEdges | null) =>
48
49
const sameMeasurements = (a: ChatCanvasMeasurements, b: ChatCanvasMeasurements) =>
50
a.width === b.width &&
51
+ a.narrowestWidth === b.narrowestWidth &&
52
a.height === b.height &&
53
a.padding === b.padding &&
54
a.maxChatWidth === b.maxChatWidth &&
@@ -101,6 +103,7 @@ export function resolveChatCanvasModel({
103
// preview overlap has pushed the card itself into popover mode.
104
const preferredDetailsCard = resolveThreadDetailsCardLayout({
105
container,
106
+ narrowestWidth: measurements.narrowestWidth ?? measurements.width,
107
lane,
108
frame: null,
109
topInset: detailsCardTopInset,
@@ -139,6 +142,7 @@ export function resolveChatCanvasModel({
142
});
143
const detailsCardPlacement = resolveThreadDetailsCardLayout({
144
container,
145
+ narrowestWidth: measurements.narrowestWidth ?? measurements.width,
146
lane,
147
frame: layout.frame,
148
overlapsDetailsCard: layout.overlapsDetailsCard,
apps/web/src/components/chat/chatCanvasLayout.test.ts
+14
@@ -357,4 +357,18 @@ describe("workspace card beside chat", () => {
357
expect(card.x - chat.left - chat.width).toBeGreaterThanOrEqual(32);
358
}
359
});
360
+ it("stays out of a panel animation that ends or starts too narrow for it", () => {
361
+ const place = (width: number, narrowestWidth: number) =>
362
+ resolveThreadDetailsCardLayout({
363
+ container: { width, height: 900 },
364
+ narrowestWidth,
365
+ lane: { padding: 48, minChatWidth: 640 },
366
+ frame: null,
367
+ });
368
+ expect(place(1344, 1344)).toMatchObject({ x: 1052 });
369
+ expect(place(1344, 804)).toBeNull();
370
+ expect(place(1344, 1124)).toMatchObject({ x: 1052 });
371
+ // A window resize mid-animation leaves the sampled ends wider than the canvas.
372
+ expect(place(900, 1344)).toBeNull();
373
+ });
374
});
apps/web/src/components/chat/threadDetailsCardLayout.ts
+8
-1
@@ -16,12 +16,15 @@ export function resolveThreadDetailsCardDensity(
16
17
export function resolveThreadDetailsCardLayout({
18
container,
19
+ narrowestWidth = container.width,
20
lane,
21
frame,
22
overlapsDetailsCard = false,
23
topInset = 0,
24
}: {
25
container: { width: number; height: number };
26
+ // While a panel animates the container, the card fits only if it fits at both ends.
27
+ narrowestWidth?: number;
28
lane: { padding: number; minChatWidth: number };
29
frame: PreviewMiniPlayerFrame | null;
30
overlapsDetailsCard?: boolean;
@@ -30,7 +33,11 @@ export function resolveThreadDetailsCardLayout({
33
const gap = THREAD_DETAILS_CARD_GAP;
34
const width = THREAD_DETAILS_CARD_WIDTH;
35
const x = container.width - width - gap;
33
- if (x - DETAILS_CARD_CLEARANCE - lane.padding < lane.minChatWidth) return null;
36
+ // The transition ends are sampled once, so a resize mid-animation can leave them
37
+ // wider than the container is now.
38
+ const fitWidth = Math.min(narrowestWidth, container.width);
39
+ if (fitWidth - width - gap - DETAILS_CARD_CLEARANCE - lane.padding < lane.minChatWidth)
40
+ return null;
41
const y = gap + topInset;
42
const height =
43
overlapsDetailsCard && frame && frame.x + frame.width > x - gap && frame.x < x + width + gap