/** * PaneContent - Renders tab content for a single pane. * Uses CSS display-toggle to keep all tabs mounted (preserving state). */ import { lazy, Suspense, useEffect, useState } from 'react'; import { useAppTranslation } from '@features/localization/renderer'; import { TabUIProvider } from '@renderer/contexts/TabUIContext'; import { DashboardView } from '../dashboard/DashboardView'; import type { Pane } from '@renderer/types/panes'; import type { Tab } from '@renderer/types/tabs'; const ExtensionStoreView = lazy(() => import('../extensions/ExtensionStoreView').then((module) => ({ default: module.ExtensionStoreView, })) ); const NotificationsView = lazy(() => import('../notifications/NotificationsView').then((module) => ({ default: module.NotificationsView, })) ); const SessionReportTab = lazy(() => import('../report/SessionReportTab').then((module) => ({ default: module.SessionReportTab, })) ); const SchedulesView = lazy(() => import('../schedules/SchedulesView').then((module) => ({ default: module.SchedulesView, })) ); const SettingsView = lazy(() => import('../settings/SettingsView').then((module) => ({ default: module.SettingsView, })) ); const TeamDetailView = lazy(() => import('../team/TeamDetailView').then((module) => ({ default: module.TeamDetailView, })) ); const TeamListView = lazy(() => import('../team/TeamListView').then((module) => ({ default: module.TeamListView, })) ); const SessionTabContent = lazy(() => import('./SessionTabContent').then((module) => ({ default: module.SessionTabContent, })) ); const TeamGraphTab = lazy(() => import('@features/agent-graph/renderer').then((module) => ({ default: module.TeamGraphTab, })) ); interface PaneContentProps { pane: Pane; isPaneFocused: boolean; } interface PaneTabSlotProps { tab: Tab; isActive: boolean; isPaneFocused: boolean; } const PaneLazyFallback = (): React.JSX.Element => { const { t } = useAppTranslation('common'); return (
); }; const PaneTabSlot = ({ tab, isActive, isPaneFocused }: PaneTabSlotProps): React.JSX.Element => { const [hasActivated, setHasActivated] = useState(isActive); const shouldRenderContent = hasActivated && (tab.type !== 'teams' || isActive); useEffect(() => { if (isActive) { setHasActivated(true); } }, [isActive]); return (
{shouldRenderContent && ( }> {tab.type === 'dashboard' && } {tab.type === 'notifications' && } {tab.type === 'settings' && } {tab.type === 'teams' && } {tab.type === 'team' && ( )} {tab.type === 'session' && ( )} {tab.type === 'report' && } {tab.type === 'extensions' && ( )} {tab.type === 'schedules' && } {tab.type === 'graph' && ( )} )}
); }; export const PaneContent = ({ pane, isPaneFocused }: PaneContentProps): React.JSX.Element => { const activeTabId = pane.activeTabId; // Show default dashboard if no tabs are open in this pane const showDefaultDashboard = !activeTabId && pane.tabs.length === 0; return (
{showDefaultDashboard && (
)} {pane.tabs.map((tab) => { const isActive = tab.id === activeTabId; return ( ); })}
); };