/* eslint-disable @typescript-eslint/no-explicit-any */ import React, { memo } from 'react'; import { terminalLayerWorkspaceCtxEqual } from './terminalLayerViewMemo'; type WorkspaceContext = Record; function TerminalLayerWorkspaceSectionInner({ ctx }: { ctx: WorkspaceContext }) { const { workspaceInnerRef, workspaceOverlayRef, draggingSessionId, isFocusMode, dropHint, setDropHint, computeSplitHint, handleWorkspaceDrop, TerminalPanesHost, sessions, sessionHostsMap, sessionChainHostsMap, sessionSudoAutofillPasswordsMap, resolvedSessionHostIds, workspaceById, workspaceRectsById, isTerminalLayerVisible, workspaceFocusHandlersRef, workspaceBroadcastHandlersRef, splitHorizontalHandlersRef, splitVerticalHandlersRef, resolveSessionAppearance, hostMap, keys, identities, snippets, knownHosts, terminalFontFamilyId, fontSize, terminalTheme, followAppTerminalTheme, accentMode, customAccent, terminalSettings, hotkeyScheme, disableTerminalFontZoom, restoreTerminalCwd, keyBindings, resizing, isComposeBarOpen, sessionLogConfig, sshDebugLogsEnabled, onHotkeyAction, handleTerminalFontSizeChange, handleOpenSftp, handleTerminalCwdChange, handleTerminalTitleChange, handleTerminalBell, handleTerminalOutput, handleTerminalContextReaderChange, handleOpenScripts, handleOpenHistory, handleOpenSystem, handleOpenTheme, handleCloseSession, handleStatusChange, handleSessionExit, handleTerminalDataCapture, handleOsDetected, handleUpdateHost, handleAddKnownHost, handleCommandExecuted, handleCommandSubmitted, onSetWorkspaceFocusedSession, onSplitSession, isBroadcastEnabled, handleBroadcastInput, handleBroadcastInterruptPriorityChange, handleToggleWorkspaceComposeBar, handleSnippetExecutorChange, handleProgrammaticCommandLogRewriteChange, handleAddSelectionToAI, activeResizers, activeWorkspace, composeBarThemeColors, findSplitNode, focusedSessionId, handleComposeSend, handleSnippetFromPanel, refocusTerminalSession, setIsComposeBarOpen, setResizing, TerminalComposeBar, Array, cn, onStartSessionRename, onRemoveSessionFromWorkspace, onReorderTabs, onStartSessionDrag, onEndSessionDrag, } = ctx; return (
{draggingSessionId && !isFocusMode && (
{ if (isFocusMode) return; if (!e.dataTransfer.types.includes('session-id')) return; e.preventDefault(); e.stopPropagation(); const hint = computeSplitHint(e); setDropHint(hint); }} onDragLeave={(e) => { if (!e.dataTransfer.types.includes('session-id')) return; setDropHint(null); }} onDrop={(e) => { e.preventDefault(); e.stopPropagation(); handleWorkspaceDrop(e); }} > {dropHint && (
)}
)} {!isFocusMode && activeResizers.map((handle: any) => { const isVertical = handle.direction === 'vertical'; const left = isVertical ? handle.rect.x - 3 : handle.rect.x; const top = isVertical ? handle.rect.y : handle.rect.y - 3; const width = isVertical ? handle.rect.w + 6 : handle.rect.w; const height = isVertical ? handle.rect.h : handle.rect.h + 6; return (
{ e.preventDefault(); e.stopPropagation(); const ws = activeWorkspace; if (!ws) return; const split = findSplitNode(ws.root, handle.splitId); const childCount = split && split.type === 'split' ? split.children.length : 0; const sizes = split && split.type === 'split' && split.sizes && split.sizes.length === childCount ? split.sizes : Array(childCount).fill(1); setResizing({ workspaceId: ws.id, splitId: handle.splitId, index: handle.index, direction: handle.direction, startSizes: sizes.length ? sizes : [1, 1], startArea: handle.splitArea, startClient: { x: e.clientX, y: e.clientY }, }); }} >
); })}
{activeWorkspace && isComposeBarOpen && ( void handleSnippetFromPanel(snippet)} snippets={snippets} onClose={() => { setIsComposeBarOpen(false); refocusTerminalSession(focusedSessionId); }} isBroadcastEnabled={isBroadcastEnabled?.(activeWorkspace.id)} themeColors={composeBarThemeColors} /> )}
); } export const TerminalLayerWorkspaceSection = memo( TerminalLayerWorkspaceSectionInner, (prev, next) => terminalLayerWorkspaceCtxEqual(prev.ctx, next.ctx), ); TerminalLayerWorkspaceSection.displayName = 'TerminalLayerWorkspaceSection';