diff --git a/components/Terminal.tsx b/components/Terminal.tsx index c5c8f56dc..c29b4513a 100644 --- a/components/Terminal.tsx +++ b/components/Terminal.tsx @@ -3,7 +3,7 @@ import { FitAddon } from "@xterm/addon-fit"; import { SerializeAddon } from "@xterm/addon-serialize"; import { SearchAddon } from "@xterm/addon-search"; import "@xterm/xterm/css/xterm.css"; -import { Cpu, Copy, HardDrive, Maximize2, MemoryStick, Radio, ArrowDownToLine, ArrowUpFromLine, Sparkles } from "lucide-react"; +import { Activity, Cpu, Copy, HardDrive, Maximize2, MemoryStick, Radio, ArrowDownToLine, ArrowUpFromLine, Sparkles } from "lucide-react"; import React, { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"; import { useI18n } from "../application/i18n/I18nProvider"; import { detectLocalOs } from "../lib/localShell"; @@ -135,6 +135,7 @@ const TerminalComponent: React.FC = ({ onOpenScripts, onOpenHistory, onOpenTheme, + onOpenSystem, isBroadcastEnabled, onToggleBroadcast, onToggleComposeBar, @@ -461,6 +462,12 @@ const TerminalComponent: React.FC = ({ const isSupportedOs = !isNetworkDevice && (host.os === 'linux' || host.os === 'macos' || detectedDeviceClass === 'linux-like'); + const isSystemSidebarEligible = + !!onOpenSystem && + isSupportedOs && + !isLocalConnection && + !isSerialConnection && + host.protocol !== 'telnet'; // Server-stats polling now lives inside (rendered by // TerminalView) so its ~5s refresh only re-renders that widget, not the whole // terminal. We just forward `isSupportedOs` via ctx. @@ -1137,7 +1144,7 @@ const TerminalComponent: React.FC = ({ useTerminalEffects({ CONNECTION_TIMEOUT, Error, XTERM_PERFORMANCE_CONFIG, applyUserCursorPreference, auth, autocompleteCloseRef, autocompleteInputRef, autocompleteKeyEventRef, captureTerminalLogData, clearTerminalCwd, commandBufferRef, connectionLogBufferRef, containerRef, createPromptLineBreakState, createReplaySafeTerminalLogSanitizer, createXTermRuntime, deferTerminalResizeRef, effectiveFontSize, effectiveFontWeight, effectiveTheme, error, executeSnippetCommand, fitAddonRef, fontFamilyId, fontSize, fontWeightFixupDoneRef, forceSyncRenderAfterResize, handleOsc52ReadRequest, handleTerminalDataCaptureOnce, hasConnectedRef, host, hotkeySchemeRef, identities, inWorkspace, isBootActiveRef, isBroadcastEnabledRef, isComposeBarOpen: effectiveComposeBarOpen, isFocusMode, isFocused, isLocalConnection, isNetworkDevice, isResizing: deferTerminalResize, isRestoringSelectionRef, isSearchOpen, isSerialConnection, isVisible, isVisibleRef, keyBindingsRef, keys, knownCwdRef, lastFittedSizeRef, lastToastedErrorRef, logger, mouseTrackingRef, onBroadcastInputRef, onCommandExecuted, onCommandSubmitted, onHotkeyActionRef, onSnippetShortkeyRef, onSnippetExecutorChange, onTerminalCwdChange, onTerminalFontSizeChange, paneLayoutKey, pendingAuthRef, pendingOutputScrollRef, prevIsResizingRef, promptLineBreakStateRef, resizeSession, resolveHostAuth, resolvedFontFamily, safeFit, searchAddonRef, serialConfig, serialLineBufferRef, serializeAddonRef, sessionId, sessionRef, sessionStarters, setError, setHasMouseTracking, setHasSelection, setIsCancelling, setIsDisconnectedDialogDismissed, setIsSearchOpen, setNeedsHostKeyVerification, setPendingHostKeyInfo, setPendingHostKeyRequestId, setProgressLogs, setProgressValue, setSelectionOverlayPosition, setShowLogs, setStatus, setTimeLeft, shouldEnableNativeUserInputAutoScroll, shouldProbeSessionCwd, snippetsRef, status, statusRef, sudoAutofillRef, t, teardown, termRef, terminalAltKeyOptions, terminalBackend, terminalContextActionsRef, terminalCwdTracker, terminalDataCapturedRef, terminalLogSanitizerRef, terminalSettings, terminalSettingsRef, toHostKeyInfo, toast, updateStatus, useEffect, useLayoutEffect, xtermRuntimeRef, zmodem, zmodemToastedRef }); - return ; + return ; }; const Terminal = memo(TerminalComponent, terminalPropsAreEqual); diff --git a/components/terminal/TerminalView.tsx b/components/terminal/TerminalView.tsx index a79e0e2ac..0b79a2670 100644 --- a/components/terminal/TerminalView.tsx +++ b/components/terminal/TerminalView.tsx @@ -30,7 +30,7 @@ function terminalViewCtxEqual( } function TerminalViewInner({ ctx }: { ctx: TerminalViewContext }) { - const { Button, Copy, Maximize2, Radio, Sparkles, TerminalAutocomplete, TerminalComposeBar, TerminalConnectionDialog, TerminalContextMenu, TerminalSearchBar, Tooltip, TooltipContent, TooltipTrigger, ZmodemOverwriteDialog, ZmodemProgressIndicator, auth, autocompleteAcceptTextRef, autocompleteCloseRef, autocompleteHostOs, autocompleteInputRef, autocompleteKeyEventRef, autocompleteRepositionRef, autocompleteSettings, chainProgress, cn, compactToolbar, containerRef, effectiveTheme, error, executeSnippet, executeSnippetCommand, handleAddSelectionToAI, handleCancelConnect, handleCloseDisconnectedSession, handleCloseSearch, handleDismissDisconnectedDialog, handleDragEnter, handleDragLeave, handleDragOver, handleDrop, handleFindNext, handleFindPrevious, handleHostKeyAddAndContinue, handleHostKeyClose, handleHostKeyContinue, handleOsc52ReadResponse, handleRetry, handleSearch, handleTopOverlayMouseDownCapture, hasMouseTracking, hasSelection, host, hotkeyScheme, inWorkspace, isBroadcastEnabled, isCancelling, isComposeBarOpen, isDraggingOver, isFocusMode, isLocalConnection, isSearchOpen, isSupportedOs, isVisible, keyBindings, keys, knownCwdRef, needsHostKeyVerification, onCloseSession, onExpandToFocus, onSplitHorizontal, onSplitVertical, onToggleBroadcast, osc52ReadPromptVisible, pendingHostKeyInfo, progressLogs, progressValue, renderControls, searchMatchCount, selectionOverlayPosition, sessionId, sessionRef, setIsComposeBarOpen, setShowLogs, shouldShowConnectionDialog, showLogs, snippets, status, statusDotTone, sudoHintRef, sudoHintText, t, termRef, terminalContextActions, terminalCwdTracker, terminalPreviewVars, terminalSettings, timeLeft, toast, zmodem } = ctx; + const { Activity, Button, Copy, Maximize2, Radio, Sparkles, TerminalAutocomplete, TerminalComposeBar, TerminalConnectionDialog, TerminalContextMenu, TerminalSearchBar, Tooltip, TooltipContent, TooltipTrigger, ZmodemOverwriteDialog, ZmodemProgressIndicator, auth, autocompleteAcceptTextRef, autocompleteCloseRef, autocompleteHostOs, autocompleteInputRef, autocompleteKeyEventRef, autocompleteRepositionRef, autocompleteSettings, chainProgress, cn, compactToolbar, containerRef, effectiveTheme, error, executeSnippet, executeSnippetCommand, handleAddSelectionToAI, handleCancelConnect, handleCloseDisconnectedSession, handleCloseSearch, handleDismissDisconnectedDialog, handleDragEnter, handleDragLeave, handleDragOver, handleDrop, handleFindNext, handleFindPrevious, handleHostKeyAddAndContinue, handleHostKeyClose, handleHostKeyContinue, handleOsc52ReadResponse, handleRetry, handleSearch, handleTopOverlayMouseDownCapture, hasMouseTracking, hasSelection, host, hotkeyScheme, inWorkspace, isBroadcastEnabled, isCancelling, isComposeBarOpen, isDraggingOver, isFocusMode, isLocalConnection, isSearchOpen, isSupportedOs, isSystemSidebarEligible, isVisible, keyBindings, keys, knownCwdRef, needsHostKeyVerification, onCloseSession, onExpandToFocus, onOpenSystem, onSplitHorizontal, onSplitVertical, onToggleBroadcast, osc52ReadPromptVisible, pendingHostKeyInfo, progressLogs, progressValue, renderControls, searchMatchCount, selectionOverlayPosition, sessionId, sessionRef, setIsComposeBarOpen, setShowLogs, shouldShowConnectionDialog, showLogs, snippets, status, statusDotTone, sudoHintRef, sudoHintText, t, termRef, terminalContextActions, terminalCwdTracker, terminalPreviewVars, terminalSettings, timeLeft, toast, zmodem } = ctx; return ( {t("terminal.statusbar.copyHostname.tooltip", { hostname: host.hostname })} )} + {isSystemSidebarEligible && ( + + + + + {t("terminal.layer.system")} + + )} {!compactToolbar && ( void; onOpenHistory?: () => void; onOpenTheme?: () => void; + onOpenSystem?: () => void; isBroadcastEnabled?: boolean; onToggleBroadcast?: () => void; onToggleComposeBar?: () => void; diff --git a/components/terminal/terminalMemo.ts b/components/terminal/terminalMemo.ts index a5bbb6bd1..6bf91b412 100644 --- a/components/terminal/terminalMemo.ts +++ b/components/terminal/terminalMemo.ts @@ -62,6 +62,7 @@ export const terminalPropsAreEqual = ( && prev.onOpenScripts === next.onOpenScripts && prev.onOpenHistory === next.onOpenHistory && prev.onOpenTheme === next.onOpenTheme + && prev.onOpenSystem === next.onOpenSystem && prev.onToggleBroadcast === next.onToggleBroadcast && prev.onToggleComposeBar === next.onToggleComposeBar && prev.onBroadcastInput === next.onBroadcastInput diff --git a/components/terminalLayer/TerminalLayerSupport.tsx b/components/terminalLayer/TerminalLayerSupport.tsx index f024cffb1..d7b20d27e 100644 --- a/components/terminalLayer/TerminalLayerSupport.tsx +++ b/components/terminalLayer/TerminalLayerSupport.tsx @@ -569,6 +569,7 @@ interface TerminalPaneProps { onOpenScripts: () => void; onOpenHistory?: () => void; onOpenTheme: () => void; + onOpenSystem?: () => void; onCloseSession: (sessionId: string) => void; onStatusChange: (sessionId: string, status: TerminalSession['status']) => void; onSessionExit: (sessionId: string, evt: TerminalSessionExitEvent) => void; @@ -658,6 +659,7 @@ const terminalPanePropsAreEqual = ( prev.onOpenScripts === next.onOpenScripts && prev.onOpenHistory === next.onOpenHistory && prev.onOpenTheme === next.onOpenTheme && + prev.onOpenSystem === next.onOpenSystem && prev.onCloseSession === next.onCloseSession && prev.onStatusChange === next.onStatusChange && prev.onSessionExit === next.onSessionExit && @@ -713,6 +715,7 @@ const TerminalPane: React.FC = memo(({ onOpenScripts, onOpenHistory, onOpenTheme, + onOpenSystem, onCloseSession, onStatusChange, onSessionExit, @@ -835,6 +838,12 @@ const TerminalPane: React.FC = memo(({ onSetWorkspaceFocusedSession?.(activeWorkspaceId, session.id); } }, [activeWorkspaceId, isFocusMode, onSetWorkspaceFocusedSession, session.id]); + const handleOpenSystemForPane = useCallback(() => { + if (activeWorkspaceId && !isFocusMode) { + onSetWorkspaceFocusedSession?.(activeWorkspaceId, session.id); + } + onOpenSystem?.(); + }, [activeWorkspaceId, isFocusMode, onOpenSystem, onSetWorkspaceFocusedSession, session.id]); const handleTerminalFontSizeChange = useCallback((nextFontSize: number) => { onTerminalFontSizeChange?.(session.id, nextFontSize); }, [onTerminalFontSizeChange, session.id]); @@ -888,6 +897,7 @@ const TerminalPane: React.FC = memo(({ onOpenScripts={onOpenScripts} onOpenHistory={onOpenHistory} onOpenTheme={onOpenTheme} + onOpenSystem={handleOpenSystemForPane} onCloseSession={onCloseSession} onStatusChange={onStatusChange} onSessionExit={onSessionExit} @@ -953,6 +963,7 @@ interface TerminalPanesHostProps { onOpenScripts: () => void; onOpenHistory?: () => void; onOpenTheme: () => void; + onOpenSystem?: () => void; onCloseSession: (sessionId: string) => void; onStatusChange: (sessionId: string, status: TerminalSession['status']) => void; onSessionExit: (sessionId: string, evt: TerminalSessionExitEvent) => void; @@ -1014,6 +1025,7 @@ const terminalPanesHostPropsAreEqual = ( if (prev.onOpenScripts !== next.onOpenScripts) return false; if (prev.onOpenHistory !== next.onOpenHistory) return false; if (prev.onOpenTheme !== next.onOpenTheme) return false; + if (prev.onOpenSystem !== next.onOpenSystem) return false; if (prev.onCloseSession !== next.onCloseSession) return false; if (prev.onStatusChange !== next.onStatusChange) return false; if (prev.onSessionExit !== next.onSessionExit) return false; diff --git a/components/terminalLayer/TerminalLayerWorkspaceSection.tsx b/components/terminalLayer/TerminalLayerWorkspaceSection.tsx index c29e0722b..e47a8aaa1 100644 --- a/components/terminalLayer/TerminalLayerWorkspaceSection.tsx +++ b/components/terminalLayer/TerminalLayerWorkspaceSection.tsx @@ -51,6 +51,7 @@ function TerminalLayerWorkspaceSectionInner({ ctx }: { ctx: WorkspaceContext }) handleTerminalCwdChange, handleOpenScripts, handleOpenHistory, + handleOpenSystem, handleOpenTheme, handleCloseSession, handleStatusChange, @@ -159,6 +160,7 @@ function TerminalLayerWorkspaceSectionInner({ ctx }: { ctx: WorkspaceContext }) onTerminalCwdChange={handleTerminalCwdChange} onOpenScripts={handleOpenScripts} onOpenHistory={handleOpenHistory} + onOpenSystem={handleOpenSystem} onOpenTheme={handleOpenTheme} onCloseSession={handleCloseSession} onStatusChange={handleStatusChange} diff --git a/components/terminalLayer/terminalLayerViewMemo.ts b/components/terminalLayer/terminalLayerViewMemo.ts index deba72b44..3d0520ccf 100644 --- a/components/terminalLayer/terminalLayerViewMemo.ts +++ b/components/terminalLayer/terminalLayerViewMemo.ts @@ -250,6 +250,7 @@ const WORKSPACE_CTX_KEYS = [ 'handleTerminalCwdChange', 'handleOpenScripts', 'handleOpenHistory', + 'handleOpenSystem', 'handleOpenTheme', 'handleCloseSession', 'handleStatusChange',