import type { ReactNode } from 'react' import { useTabStore } from '../../stores/tabStore' import { EmptySession } from '../../pages/EmptySession' import { ActiveSession } from '../../pages/ActiveSession' import { ScheduledTasks } from '../../pages/ScheduledTasks' import { Settings } from '../../pages/Settings' import { TerminalSettings } from '../../pages/TerminalSettings' export function ContentRouter() { const activeTabId = useTabStore((s) => s.activeTabId) const tabs = useTabStore((s) => s.tabs) const activeTabType = tabs.find((t) => t.sessionId === activeTabId)?.type const terminalTabs = tabs.filter((tab) => tab.type === 'terminal') let page: ReactNode = null if (!activeTabId || !activeTabType) { page = } else if (activeTabType === 'settings') { page = } else if (activeTabType === 'scheduled') { page = } else if (activeTabType !== 'terminal') { page = } return (
{page && (
{page}
)} {terminalTabs.map((tab) => { const active = tab.sessionId === activeTabId const visible = activeTabType === 'terminal' && active return (
useTabStore.getState().openTerminalTab(tab.terminalCwd)} />
) })}
) }