/* eslint-disable react-refresh/only-export-components */ /* eslint-disable react-hooks/exhaustive-deps */ import { toast } from "sonner"; import { useTranslation } from "react-i18next"; import { Separator } from "@/components/separator"; import { Button } from "@/components/button"; import { Sheet, SheetContent } from "@/components/sheet"; import { ChevronLeft, ChevronRight, Maximize2, Minimize2, PanelRight, RotateCcw, SquareArrowOutUpRight, } from "lucide-react"; import { useState, useRef, useCallback, useEffect, useLayoutEffect, createRef, lazy, Suspense, } from "react"; import { createPortal } from "react-dom"; import { useIsMobile } from "@/hooks/use-mobile"; import { useAiAvailability } from "@/hooks/use-ai-availability"; import { MobileBottomBar } from "@/shell/MobileBottomBar"; import { AppRail, type RailView } from "@/sidebar/AppRail"; import { railItemLabel, PROMOTABLE_IDS, RIGHT_DOCKABLE_IDS, } from "@/sidebar/rail-items"; import { MultiPanelHint } from "@/sidebar/MultiPanelHint"; import { OnboardingDialog } from "@/onboarding/OnboardingDialog"; import { UI_ONBOARDING_VERSION } from "@/types/ui-preferences"; import { useUiPreferencesContext } from "@/contexts/UiPreferencesContext"; import { defaultSizes, SplitView, type RowColSizes } from "@/shell/SplitView"; import { renderTabContent } from "@/shell/tabUtils"; import { TabBar } from "@/shell/TabBar"; import { dispatchCtrlW, isShiftKey } from "@/lib/app-keyboard-shortcuts"; import { parseCustomKeybindings } from "@/api/open-tabs-api"; import { findMatchingKeybinding } from "@/lib/keybinding-match"; import type { CustomKeybinding, KeybindingActionType, } from "@/types/keybindings"; // Shell surfaces that are not needed for first paint. const CommandPalette = lazy(() => import("@/shell/CommandPalette").then((m) => ({ default: m.CommandPalette, })), ); const HostsPanel = lazy(() => import("@/sidebar/HostsPanel").then((m) => ({ default: m.HostsPanel })), ); const QuickConnectPanel = lazy(() => import("@/sidebar/QuickConnectPanel").then((m) => ({ default: m.QuickConnectPanel, })), ); const SerialPanel = lazy(() => import("@/sidebar/SerialPanel").then((m) => ({ default: m.SerialPanel })), ); const SplitScreenPanel = lazy(() => import("@/sidebar/SplitScreenPanel").then((m) => ({ default: m.SplitScreenPanel, })), ); const AlertManager = lazy(() => import("@/dashboard/panels/alerts/AlertManager").then((m) => ({ default: m.AlertManager, })), ); // Secondary rail panels — load on first open, not with the shell critical path. const SshToolsPanel = lazy(() => import("@/sidebar/SshToolsPanel").then((m) => ({ default: m.SshToolsPanel })), ); const CollabPanel = lazy(() => import("@/sidebar/CollabPanel").then((m) => ({ default: m.CollabPanel })), ); const SnippetsPanel = lazy(() => import("@/sidebar/SnippetsPanel").then((m) => ({ default: m.SnippetsPanel })), ); const MacrosPanel = lazy(() => import("@/sidebar/MacrosPanel").then((m) => ({ default: m.MacrosPanel })), ); const FleetsPanel = lazy(() => import("@/sidebar/FleetsPanel").then((m) => ({ default: m.FleetsPanel })), ); const WorkspacesPanel = lazy(() => import("@/sidebar/WorkspacesPanel").then((m) => ({ default: m.WorkspacesPanel, })), ); const AutomationsPanel = lazy(() => import("@/sidebar/AutomationsPanel").then((m) => ({ default: m.AutomationsPanel, })), ); const AiPanel = lazy(() => import("@/features/ai/AiPanel").then((m) => ({ default: m.AiPanel, })), ); const HistoryPanel = lazy(() => import("@/sidebar/HistoryPanel").then((m) => ({ default: m.HistoryPanel })), ); const SessionLogsPanel = lazy(() => import("@/sidebar/SessionLogsPanel").then((m) => ({ default: m.SessionLogsPanel, })), ); const UserProfilePanel = lazy(() => import("@/sidebar/UserProfilePanel").then((m) => ({ default: m.UserProfilePanel, })), ); const AdminSettingsPanel = lazy(() => import("@/sidebar/AdminSettingsPanel").then((m) => ({ default: m.AdminSettingsPanel, })), ); const AlertsPanel = lazy(() => import("@/sidebar/AlertsPanel").then((m) => ({ default: m.AlertsPanel })), ); const CredentialsPanel = lazy(() => import("@/sidebar/CredentialsPanel").then((m) => ({ default: m.CredentialsPanel, })), ); const PortForwardingPanel = lazy(() => import("@/sidebar/PortForwardingPanel").then((m) => ({ default: m.PortForwardingPanel, })), ); const TermixIdPanel = lazy(() => import("@/sidebar/TermixIdPanel").then((m) => ({ default: m.TermixIdPanel })), ); const ConnectionsPanel = lazy(() => import("@/sidebar/ConnectionsPanel").then((m) => ({ default: m.ConnectionsPanel, })), ); function SidebarPanelFallback() { return (