"use client"; import { IconLayoutSidebarRightCollapse, IconLayoutSidebarRightExpand } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip"; import { useTaskRightPanelsToggle } from "@/hooks/use-task-right-panels-toggle"; import { useEffect, useRef } from "react"; import { useTranslation } from "react-i18next"; type TaskRightPanelsToggleProps = { sessionId?: string | null; }; export function TaskRightPanelsToggle({ sessionId = null }: TaskRightPanelsToggleProps) { const { t } = useTranslation(); const { isSupported, isReady, isMaximized, isAvailable, rightPanelsVisible, toggleRightPanels } = useTaskRightPanelsToggle(sessionId); const buttonRef = useRef(null); const restoreFocusRef = useRef(false); const previousReadyRef = useRef(isReady); useEffect(() => { if (isReady && !previousReadyRef.current && restoreFocusRef.current) { buttonRef.current?.focus(); restoreFocusRef.current = false; } previousReadyRef.current = isReady; }, [isReady]); if (!isSupported) return null; let label: string; if (isMaximized) { label = t("task:rightPaneUnavailableWhileMaximized"); } else if (!isAvailable) { label = t("task:rightPaneUnavailable"); } else if (rightPanelsVisible) { label = t("task:hideRightPane"); } else { label = t("task:showRightPane"); } const canActivate = isReady && isAvailable; return ( {label} ); }