@devries-cameron20 / t3code Mirror · read-only / commits / 71c2410a67
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 14:45 UTC

fix(web): thread details slides in on close (#28929)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Claudesaul committed Nov 14, 2026 at 07:04 UTC 71c2410a672d8417e299886794913414b1a85587
1 file changed +28 -2
apps/web/src/components/chat/PanelLayoutControls.tsx
+28 -2
@@ -5,7 +5,7 @@ import {
5 Maximize2Icon,
6 Minimize2Icon,
7 } from "lucide-react";
8 -import { memo, type ReactNode } from "react";
8 +import { memo, type ReactNode, useLayoutEffect, useRef } from "react";
9
10 import { cn } from "~/lib/utils";
11
@@ -15,6 +15,9 @@ import { useMobileSidebarSheetMounted } from "../ui/sidebar";
15 import { Toggle } from "../ui/toggle";
16 import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
17
18 +/** Matches the right inset of `ThreadPanelHeaderControl`. */
19 +const THREAD_PANEL_HEADER_INSET_PX = 12;
20 +
21 export interface PanelLayoutControlsProps {
22 showThreadPanelControl?: boolean;
23 showTerminalControl?: boolean;
@@ -68,7 +71,7 @@ export const PanelLayoutControls = memo(function PanelLayoutControls({
71 );
72 const threadPanelControl = (
73 <Tooltip>
71 - <TooltipTrigger render={<span className="flex shrink-0" />}>
74 + <TooltipTrigger render={<span className="flex shrink-0" data-thread-panel-toggle />}>
75 {threadPanelPresentation === "popover" ? (
76 <PopoverTrigger handle={threadPanelPopoverHandle} render={threadPanelToggle} />
77 ) : (
@@ -195,9 +198,32 @@ export function WorkspaceTitlebarControls(props: {
198 readonly onToggleMaximized: () => void;
199 readonly children: ReactNode;
200 }) {
201 + const { rightPanelOpen, maximized } = props;
202 + const controlsRef = useRef<HTMLDivElement | null>(null);
203 + const previous = useRef({ rightPanelOpen, maximized });
204 + // 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.
205 + useLayoutEffect(() => {
206 + const { rightPanelOpen: wasOpen, maximized: wasMaximized } = previous.current;
207 + previous.current = { rightPanelOpen, maximized };
208 + if (!wasOpen || rightPanelOpen || wasMaximized) return;
209 + const toggle = controlsRef.current?.querySelector("[data-thread-panel-toggle]");
210 + const panel = toggle?.ownerDocument.querySelector("[data-preview-panel-mode='inline']");
211 + const timing = panel?.getAnimations()[0]?.effect?.getTiming();
212 + if (!toggle || !panel || !timing) return;
213 + // The header's toggle was just removed, so slide this one in from where it sat.
214 + const headerRight = panel.getBoundingClientRect().left - THREAD_PANEL_HEADER_INSET_PX;
215 + const offset = headerRight - toggle.getBoundingClientRect().right;
216 + const animation = toggle.animate(
217 + [{ transform: `translateX(${offset}px)` }, { transform: "none" }],
218 + { ...timing, easing: getComputedStyle(panel).transitionTimingFunction },
219 + );
220 + return () => animation.cancel();
221 + }, [rightPanelOpen, maximized]);
222 +
223 const mobileSidebarSheetMounted = useMobileSidebarSheetMounted();
224 return (
225 <div
226 + ref={controlsRef}
227 className={cn(
228 "pointer-events-none fixed top-[var(--workspace-controls-top)] right-[var(--workspace-controls-right)] z-50 mr-px flex h-[var(--workspace-topbar-height)] items-center gap-1 [-webkit-app-region:no-drag]",
229 mobileSidebarSheetMounted && "hidden",