'use client'; import { memo, useState } from 'react'; import type { IDockviewPanelProps } from 'dockview-react'; import { PanelRoot, PanelBody } from './panel-primitives'; import { PassthroughTerminal } from './passthrough-terminal'; import { ShellTerminal } from './shell-terminal'; import { useAppStore } from '@/components/state-provider'; export const TerminalPanel = memo(function TerminalPanel( props: IDockviewPanelProps<{ terminalId: string; type?: 'shell' | 'dev-server'; processId?: string }> ) { const terminalId = props.params.terminalId; const type = props.params.type ?? 'shell'; const processId = props.params.processId; // Capture the session ID at creation time — terminal stays connected // to its original session even when the user switches tasks const activeSessionId = useAppStore((state) => state.tasks.activeSessionId); const [sessionId] = useState(() => activeSessionId); const devOutput = useAppStore((state) => processId ? state.processes.outputsByProcessId[processId] ?? '' : '' ); const devProcess = useAppStore((state) => processId ? state.processes.processesById[processId] : undefined ); const isStopping = devProcess?.status === 'stopping'; if (type === 'dev-server' && processId) { return ( ); } return ( ); });