From bd04ab5b6428d6cd8785d5f593a8a0f0d0c214bc Mon Sep 17 00:00:00 2001 From: Claude Belizaire <139932571+Claudesaul@users.noreply.github.com> Date: Sun, 1 Nov 2026 17:07:20 -0500 Subject: [PATCH 1/2] fix(web): thread details toggle slides into place on close Closing the right panel swapped the header's toggle for the title bar's one, so it jumped across the window on the first frame. It now slides from where the header's toggle sat, on the panel's own curve and duration. --- apps/web/src/components/ChatView.tsx | 1 + .../components/chat/PanelLayoutControls.tsx | 32 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 6cd1c7775d96..89ecb917b557 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -3265,6 +3265,7 @@ export default function ChatView(props: ChatViewProps) { showMaximizeControl={!shouldUsePlanSidebarSheet} rightPanelOpen={rightPanelOpen} animationsActive={panelAnimationsActive} + animationDurationMs={panelAnimationDurationMs} maximized={rightPanelMaximized} onToggleMaximized={toggleRightPanelMaximizedStable} > diff --git a/apps/web/src/components/chat/PanelLayoutControls.tsx b/apps/web/src/components/chat/PanelLayoutControls.tsx index 56d93123d7d6..806dd603da6f 100644 --- a/apps/web/src/components/chat/PanelLayoutControls.tsx +++ b/apps/web/src/components/chat/PanelLayoutControls.tsx @@ -1,7 +1,7 @@ import { PanelBottomIcon, PanelRightIcon, SquareMenuIcon } from "lucide-react"; import { Maximize2, Minimize2 } from "lucide"; import { MorphIcon } from "~/components/MorphIcon"; -import { memo, type ReactNode } from "react"; +import { memo, type ReactNode, useLayoutEffect, useRef } from "react"; import { cn } from "~/lib/utils"; @@ -10,6 +10,9 @@ import { PopoverCreateHandle, PopoverTrigger } from "../ui/popover"; import { Toggle } from "../ui/toggle"; import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip"; +/** Matches the right inset of `ThreadPanelHeaderControl`. */ +const THREAD_PANEL_HEADER_INSET_PX = 12; + export interface PanelLayoutControlsProps { showThreadPanelControl?: boolean; showTerminalControl?: boolean; @@ -63,7 +66,7 @@ export const PanelLayoutControls = memo(function PanelLayoutControls({ ); const threadPanelControl = ( - }> + }> {threadPanelPresentation === "popover" ? ( ) : ( @@ -178,12 +181,37 @@ export function WorkspaceTitlebarControls(props: { readonly showMaximizeControl: boolean; readonly rightPanelOpen: boolean; readonly animationsActive: boolean; + readonly animationDurationMs: number; readonly maximized: boolean; readonly onToggleMaximized: () => void; readonly children: ReactNode; }) { + const { rightPanelOpen, animationsActive, animationDurationMs, maximized } = props; + const controlsRef = useRef(null); + const previous = useRef({ rightPanelOpen, maximized }); + // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- starts the toggle's slide before the commit that swapped it in paints; the animation is cancelled on change or unmount. + useLayoutEffect(() => { + const closed = previous.current.rightPanelOpen && !rightPanelOpen; + const wasMaximized = previous.current.maximized; + previous.current = { rightPanelOpen, maximized }; + if (!closed || wasMaximized || !animationsActive) return; + const controls = controlsRef.current; + const toggle = controls?.querySelector("[data-thread-panel-toggle]"); + const panel = controls?.ownerDocument.querySelector("[data-preview-panel-mode='inline']"); + if (!toggle || !panel) return; + // The header's toggle was just removed, so slide this one in from where it sat. + const toggleRect = toggle.getBoundingClientRect(); + const headerRight = panel.getBoundingClientRect().left - THREAD_PANEL_HEADER_INSET_PX; + const animation = toggle.animate( + [{ transform: `translateX(${headerRight - toggleRect.right}px)` }, { transform: "none" }], + { duration: animationDurationMs, easing: getComputedStyle(panel).transitionTimingFunction }, + ); + return () => animation.cancel(); + }, [rightPanelOpen, maximized, animationsActive, animationDurationMs]); + return (
From 12fc4ab7754b959ced14488b2400fc6ab303e5e8 Mon Sep 17 00:00:00 2001 From: Claude Belizaire <139932571+Claudesaul@users.noreply.github.com> Date: Sun, 1 Nov 2026 17:19:38 -0500 Subject: [PATCH 2/2] fix(web): take the toggle's slide timing from the panel's transition --- apps/web/src/components/ChatView.tsx | 1 - .../components/chat/PanelLayoutControls.tsx | 24 +++++++++---------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 89ecb917b557..6cd1c7775d96 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -3265,7 +3265,6 @@ export default function ChatView(props: ChatViewProps) { showMaximizeControl={!shouldUsePlanSidebarSheet} rightPanelOpen={rightPanelOpen} animationsActive={panelAnimationsActive} - animationDurationMs={panelAnimationDurationMs} maximized={rightPanelMaximized} onToggleMaximized={toggleRightPanelMaximizedStable} > diff --git a/apps/web/src/components/chat/PanelLayoutControls.tsx b/apps/web/src/components/chat/PanelLayoutControls.tsx index 806dd603da6f..e815f3036bdb 100644 --- a/apps/web/src/components/chat/PanelLayoutControls.tsx +++ b/apps/web/src/components/chat/PanelLayoutControls.tsx @@ -181,33 +181,31 @@ export function WorkspaceTitlebarControls(props: { readonly showMaximizeControl: boolean; readonly rightPanelOpen: boolean; readonly animationsActive: boolean; - readonly animationDurationMs: number; readonly maximized: boolean; readonly onToggleMaximized: () => void; readonly children: ReactNode; }) { - const { rightPanelOpen, animationsActive, animationDurationMs, maximized } = props; + const { rightPanelOpen, maximized } = props; const controlsRef = useRef(null); const previous = useRef({ rightPanelOpen, maximized }); // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- starts the toggle's slide before the commit that swapped it in paints; the animation is cancelled on change or unmount. useLayoutEffect(() => { - const closed = previous.current.rightPanelOpen && !rightPanelOpen; - const wasMaximized = previous.current.maximized; + const { rightPanelOpen: wasOpen, maximized: wasMaximized } = previous.current; previous.current = { rightPanelOpen, maximized }; - if (!closed || wasMaximized || !animationsActive) return; - const controls = controlsRef.current; - const toggle = controls?.querySelector("[data-thread-panel-toggle]"); - const panel = controls?.ownerDocument.querySelector("[data-preview-panel-mode='inline']"); - if (!toggle || !panel) return; + if (!wasOpen || rightPanelOpen || wasMaximized) return; + const toggle = controlsRef.current?.querySelector("[data-thread-panel-toggle]"); + const panel = toggle?.ownerDocument.querySelector("[data-preview-panel-mode='inline']"); + const timing = panel?.getAnimations()[0]?.effect?.getTiming(); + if (!toggle || !panel || !timing) return; // The header's toggle was just removed, so slide this one in from where it sat. - const toggleRect = toggle.getBoundingClientRect(); const headerRight = panel.getBoundingClientRect().left - THREAD_PANEL_HEADER_INSET_PX; + const offset = headerRight - toggle.getBoundingClientRect().right; const animation = toggle.animate( - [{ transform: `translateX(${headerRight - toggleRect.right}px)` }, { transform: "none" }], - { duration: animationDurationMs, easing: getComputedStyle(panel).transitionTimingFunction }, + [{ transform: `translateX(${offset}px)` }, { transform: "none" }], + { ...timing, easing: getComputedStyle(panel).transitionTimingFunction }, ); return () => animation.cancel(); - }, [rightPanelOpen, maximized, animationsActive, animationDurationMs]); + }, [rightPanelOpen, maximized]); return (