diff --git a/application/app/topTabsChromeTheme.ts b/application/app/topTabsChromeTheme.ts index 2e3dd3a00..33b10ffbd 100644 --- a/application/app/topTabsChromeTheme.ts +++ b/application/app/topTabsChromeTheme.ts @@ -113,8 +113,3 @@ export function applyTopTabsChromeThemeVars(theme: TerminalTheme): void { setStylePropertyIfChanged(tabsRoot, '--top-tabs-accent', 'hsl(var(--accent))'); topTabsChromeThemeVarsApplied = true; } - -export function hasActiveChromeThemeDataset(): boolean { - if (typeof document === 'undefined') return false; - return Boolean(document.documentElement.dataset.activeChromeTheme); -} diff --git a/application/state/activeTabStore.ts b/application/state/activeTabStore.ts index 3c6d5e330..eb5b3c5fa 100644 --- a/application/state/activeTabStore.ts +++ b/application/state/activeTabStore.ts @@ -67,11 +67,6 @@ export const useActiveTabId = () => { ); }; -// Hook to get setter - never causes re-render -export const useSetActiveTabId = () => { - return activeTabStore.setActiveTabId; -}; - // Check if a specific tab is active - only re-renders when this specific tab's active state changes export const useIsTabActive = (tabId: string) => { const getSnapshot = useCallback(() => activeTabStore.getActiveTabId() === tabId, [tabId]); diff --git a/application/state/customThemeStore.ts b/application/state/customThemeStore.ts index fdc79473d..d140b4d49 100644 --- a/application/state/customThemeStore.ts +++ b/application/state/customThemeStore.ts @@ -142,14 +142,6 @@ export const customThemeStore = new CustomThemeStore(); // ============== Hooks ============== -/** Get all themes (built-in + custom) */ -export const useAllThemes = (): TerminalTheme[] => { - return useSyncExternalStore( - customThemeStore.subscribe, - customThemeStore.getAllThemes - ); -}; - /** Get custom themes only */ export const useCustomThemes = (): TerminalTheme[] => { return useSyncExternalStore( @@ -158,12 +150,6 @@ export const useCustomThemes = (): TerminalTheme[] => { ); }; -/** Get theme by ID (built-in or custom) with fallback */ -export const useThemeById = (id: string): TerminalTheme => { - const allThemes = useAllThemes(); - return allThemes.find(t => t.id === id) || TERMINAL_THEMES[0]; -}; - /** Theme mutation actions */ export const useCustomThemeActions = () => { const addTheme = useCallback((theme: TerminalTheme) => { diff --git a/application/state/fontStore.ts b/application/state/fontStore.ts index d2fc301f3..99b780105 100644 --- a/application/state/fontStore.ts +++ b/application/state/fontStore.ts @@ -134,24 +134,6 @@ export const useAvailableFonts = (): TerminalFont[] => { ); }; -/** - * Get font loading state - */ -export const useFontsLoading = (): boolean => { - return useSyncExternalStore( - fontStore.subscribe, - fontStore.getIsLoading - ); -}; - -/** - * Get font by ID with fallback - useful for components that need a specific font - */ -export const useFontById = (fontId: string): TerminalFont => { - const fonts = useAvailableFonts(); - return fonts.find(f => f.id === fontId) || fonts[0] || TERMINAL_FONTS[0]; -}; - /** * Initialize fonts eagerly (call at app startup) */ diff --git a/application/state/settingsTerminalTheme.test.ts b/application/state/settingsTerminalTheme.test.ts deleted file mode 100644 index 5c66d5032..000000000 --- a/application/state/settingsTerminalTheme.test.ts +++ /dev/null @@ -1,63 +0,0 @@ -import test from "node:test"; -import assert from "node:assert/strict"; - -import { resolveCurrentTerminalTheme } from "./settingsTerminalTheme"; - -const commonArgs = { - terminalThemeId: "netcatty-dark", - customThemes: [], - resolvedTheme: "dark" as const, - lightUiThemeId: "snow", - darkUiThemeId: "github", - accentMode: "theme" as const, - customAccent: "", -}; - -test("follow-app terminal theme uses pending pick before resolvedTheme catches up", () => { - const theme = resolveCurrentTerminalTheme({ - ...commonArgs, - followAppTerminalTheme: true, - pendingFollowAppTerminalThemeId: "system-flexoki-light", - resolvedTheme: "dark", - lightUiThemeId: "flexoki", - darkUiThemeId: "github", - terminalThemeDarkId: "dracula", - terminalThemeLightId: "solarized-light", - }); - - assert.equal(theme.id, "system-flexoki-light"); -}); - -test("follow-app terminal theme ignores manual per-mode terminal picks", () => { - const theme = resolveCurrentTerminalTheme({ - ...commonArgs, - followAppTerminalTheme: true, - terminalThemeDarkId: "dracula", - terminalThemeLightId: "solarized-light", - }); - - assert.equal(theme.id, "system-github-dark"); -}); - -test("manual terminal theme uses the active per-mode pick", () => { - const theme = resolveCurrentTerminalTheme({ - ...commonArgs, - followAppTerminalTheme: false, - terminalThemeDarkId: "dracula", - terminalThemeLightId: "solarized-light", - }); - - assert.equal(theme.id, "dracula"); -}); - -test("manual terminal theme preserves the saved global theme until a per-mode pick exists", () => { - const theme = resolveCurrentTerminalTheme({ - ...commonArgs, - terminalThemeId: "dracula", - followAppTerminalTheme: false, - terminalThemeDarkId: "auto", - terminalThemeLightId: "auto", - }); - - assert.equal(theme.id, "dracula"); -}); diff --git a/application/state/settingsTerminalTheme.ts b/application/state/settingsTerminalTheme.ts deleted file mode 100644 index cb0beb992..000000000 --- a/application/state/settingsTerminalTheme.ts +++ /dev/null @@ -1,63 +0,0 @@ -import type { TerminalTheme } from '../../domain/models'; -import { TERMINAL_THEMES, getBuiltinTerminalThemeById } from '../../infrastructure/config/terminalThemes'; -import { - applyCustomAccentToTerminalTheme, - resolveFollowAppTerminalThemeId, - resolveManualTerminalThemeId, -} from '../../domain/terminalAppearance'; - -interface ResolveCurrentTerminalThemeParams { - terminalThemeId: string; - terminalThemeDarkId: string; - terminalThemeLightId: string; - customThemes: TerminalTheme[]; - followAppTerminalTheme: boolean; - pendingFollowAppTerminalThemeId?: string | null; - resolvedTheme: 'light' | 'dark'; - lightUiThemeId: string; - darkUiThemeId: string; - accentMode: 'theme' | 'custom'; - customAccent: string; -} - -export function resolveCurrentTerminalTheme({ - terminalThemeId, - terminalThemeDarkId, - terminalThemeLightId, - customThemes, - followAppTerminalTheme, - pendingFollowAppTerminalThemeId = null, - resolvedTheme, - lightUiThemeId, - darkUiThemeId, - accentMode, - customAccent, -}: ResolveCurrentTerminalThemeParams): TerminalTheme { - if (followAppTerminalTheme) { - const followedId = resolveFollowAppTerminalThemeId(pendingFollowAppTerminalThemeId, { - resolvedTheme, - lightUiThemeId, - darkUiThemeId, - fallbackThemeId: terminalThemeId, - }); - const followed = getBuiltinTerminalThemeById(followedId) - || customThemes.find(t => t.id === followedId); - if (followed) { - return applyCustomAccentToTerminalTheme(followed, accentMode, customAccent); - } - } - const manualThemeId = resolveManualTerminalThemeId({ - resolvedTheme, - terminalThemeDarkId, - terminalThemeLightId, - lightUiThemeId, - darkUiThemeId, - fallbackThemeId: terminalThemeId, - }); - const baseTheme = getBuiltinTerminalThemeById(manualThemeId) - || customThemes.find(t => t.id === manualThemeId) - || getBuiltinTerminalThemeById(terminalThemeId) - || customThemes.find(t => t.id === terminalThemeId) - || TERMINAL_THEMES[0]; - return applyCustomAccentToTerminalTheme(baseTheme, accentMode, customAccent); -} diff --git a/application/state/uiFontStore.ts b/application/state/uiFontStore.ts index dc21fec3b..21cb31497 100644 --- a/application/state/uiFontStore.ts +++ b/application/state/uiFontStore.ts @@ -162,16 +162,6 @@ export const useAvailableUIFonts = (): UIFont[] => { ); }; -/** - * Get UI font loading state - */ -export const useUIFontsLoading = (): boolean => { - return useSyncExternalStore( - uiFontStore.subscribe, - uiFontStore.getIsLoading - ); -}; - /** * Get UI font loaded state */ @@ -182,14 +172,6 @@ export const useUIFontsLoaded = (): boolean => { ); }; -/** - * Get UI font by ID with fallback - */ -export const useUIFontById = (fontId: string): UIFont => { - const fonts = useAvailableUIFonts(); - return fonts.find(f => f.id === fontId) || fonts[0] || UI_FONTS[0]; -}; - /** * Check if a font ID is valid */ diff --git a/application/state/useThemeRuntime.ts b/application/state/useThemeRuntime.ts index 324f493cd..521e462ee 100644 --- a/application/state/useThemeRuntime.ts +++ b/application/state/useThemeRuntime.ts @@ -1,6 +1,6 @@ import { useCallback, useLayoutEffect, useMemo, useState } from 'react'; -import type { Host, TerminalTheme } from '../../domain/models'; +import type { TerminalTheme } from '../../domain/models'; import { idleThemeUserIntent, pickingThemeUserIntent, @@ -113,7 +113,3 @@ export function useTerminalAppearanceInjection( injectTerminalAppearanceVars(appearance.theme, { includeChromeSurfaces }); }, [appearance.theme.id, appearance.theme, includeChromeSurfaces]); } - -export function buildHostScope(host: Host | null, isEphemeral: boolean): TerminalAppearanceHostScope { - return { host, isEphemeral }; -} diff --git a/components/AIChatSidePanelHelpers.ts b/components/AIChatSidePanelHelpers.ts index d56caedd5..c35567c48 100644 --- a/components/AIChatSidePanelHelpers.ts +++ b/components/AIChatSidePanelHelpers.ts @@ -108,22 +108,6 @@ export function modelPresetsContainId(presets: AgentModelPreset[], modelId: stri return presets.some((preset) => modelPresetMatchesId(preset, modelId)); } -export function isCopilotAgentConfig(agent?: ExternalAgentConfig): boolean { - if (!agent) return false; - const tokens = [ - agent.id, - agent.name, - agent.icon, - agent.command, - getExternalAgentSdkBackend(agent), - ] - .filter((value): value is string => typeof value === 'string' && value.length > 0) - // Split on both separators so Windows command paths (e.g. "...\\copilot.exe") - // reduce to their basename rather than staying as the full path. - .map((value) => value.split(/[\\/]/).pop()?.toLowerCase() ?? value.toLowerCase()); - return tokens.some((token) => token.includes('copilot')); -} - export function shouldLoadSdkRuntimeModels(agent?: ExternalAgentConfig): boolean { const sdkBackend = getExternalAgentSdkBackend(agent); return sdkBackend === 'claude' diff --git a/components/hostIconRenderer.tsx b/components/hostIconRenderer.tsx index eaa051ec5..484334669 100644 --- a/components/hostIconRenderer.tsx +++ b/components/hostIconRenderer.tsx @@ -46,29 +46,6 @@ const HOST_ICON_COMPONENTS = { "server-cog": ServerCog, } as const satisfies Record>; -export const HOST_ICON_LABEL_KEYS: Record = { - server: "hostDetails.icon.option.server", - terminal: "hostDetails.icon.option.terminal", - database: "hostDetails.icon.option.database", - cloud: "hostDetails.icon.option.cloud", - router: "hostDetails.icon.option.router", - shield: "hostDetails.icon.option.shield", - code: "hostDetails.icon.option.code", - box: "hostDetails.icon.option.box", - globe: "hostDetails.icon.option.globe", - cpu: "hostDetails.icon.option.cpu", - "hard-drive": "hostDetails.icon.option.hard-drive", - network: "hostDetails.icon.option.network", - wifi: "hostDetails.icon.option.wifi", - lock: "hostDetails.icon.option.lock", - key: "hostDetails.icon.option.key", - monitor: "hostDetails.icon.option.monitor", - container: "hostDetails.icon.option.container", - activity: "hostDetails.icon.option.activity", - zap: "hostDetails.icon.option.zap", - "server-cog": "hostDetails.icon.option.server-cog", -}; - export const renderHostIconGlyph = (iconId: HostIconId, className?: string): React.ReactNode => { const Icon = HOST_ICON_COMPONENTS[iconId] || Server; return ; diff --git a/components/notes/MarkdownPreview.tsx b/components/notes/MarkdownPreview.tsx deleted file mode 100644 index a001cc767..000000000 --- a/components/notes/MarkdownPreview.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from "react"; -import { LazyMessageResponse } from "../ai-elements/LazyMessageResponse"; - -export function MarkdownPreview({ - content, - emptyText, -}: { - content: string; - emptyText: string; -}) { - const trimmed = content.trim(); - if (!trimmed) { - return ( -
- {emptyText} -
- ); - } - - return ( - - {trimmed} - - ); -} diff --git a/components/terminal/composeBarHelpers.ts b/components/terminal/composeBarHelpers.ts index 1ddada6e0..fac986ff3 100644 --- a/components/terminal/composeBarHelpers.ts +++ b/components/terminal/composeBarHelpers.ts @@ -1,6 +1,5 @@ import type { Snippet } from '../../types'; -export const COMPOSE_BAR_DEFAULT_HEIGHT = 120; export const COMPOSE_BAR_MIN_HEIGHT = 72; export const COMPOSE_BAR_MAX_HEIGHT = 360; diff --git a/components/terminal/terminalHelpers.ts b/components/terminal/terminalHelpers.ts index 2ce28d536..52d451687 100644 --- a/components/terminal/terminalHelpers.ts +++ b/components/terminal/terminalHelpers.ts @@ -2,7 +2,7 @@ import type { DragEvent, PointerEvent } from "react"; import { Terminal as XTerm } from "@xterm/xterm"; import type { TerminalContextReader } from "../../domain/terminalContextRead"; -import { getSessionConnectionLabel, resolveSessionTabTitle } from "../../domain/sessionTabTitle"; +import { resolveSessionTabTitle } from "../../domain/sessionTabTitle"; import { logger } from "../../lib/logger"; import { getPathForFile, type DropEntry } from "../../lib/sftpFileUtils"; import { normalizeLineEndings } from "../../lib/utils"; @@ -28,14 +28,6 @@ export interface TerminalBroadcastInputOptions { lineDelayMs?: number; } -/** - * Get the static connection label for a terminal session. - * Uses customName if set, otherwise falls back to hostLabel. - */ -export function getSessionDisplayName(session: TerminalSession): string { - return getSessionConnectionLabel(session); -} - export { resolveSessionTabTitle }; /** diff --git a/components/terminalLayer/TerminalLayerSupport.tsx b/components/terminalLayer/TerminalLayerSupport.tsx index 41883e665..fc5b72e92 100644 --- a/components/terminalLayer/TerminalLayerSupport.tsx +++ b/components/terminalLayer/TerminalLayerSupport.tsx @@ -14,7 +14,7 @@ import { STORAGE_KEY_AI_SHOW_TERMINAL_SELECTION_ACTION } from '../../infrastruct import { cn } from '../../lib/utils'; import { LazyLoadBoundary } from '../ui/lazy-load-boundary'; import type { DropEntry } from '../../lib/sftpFileUtils'; -import type { GroupConfig, Host, Identity, KnownHost, ProxyProfile, SSHKey, Snippet, TerminalSession, TerminalTheme, VaultNote, Workspace } from '../../types'; +import type { GroupConfig, Host, Identity, KnownHost, ProxyProfile, SSHKey, Snippet, TerminalSession, VaultNote, Workspace } from '../../types'; import type { ExecutorContext } from '../../infrastructure/ai/cattyAgent/executor'; import Terminal from '../Terminal'; import { removePaneVisible, setPaneVisible } from '../terminal/paneVisibilityStore'; @@ -141,12 +141,6 @@ export const clearTerminalPreviewVars = (sessionId: string | null) => { pane.style.removeProperty('--terminal-preview-toolbar-btn-active'); }; -export const clearTerminalPreviewVarsForSessions = (sessionIds: Iterable) => { - for (const sessionId of sessionIds) { - clearTerminalPreviewVars(sessionId); - } -}; - export const setStylePropertyIfChanged = (element: HTMLElement, property: string, value: string) => { if (element.style.getPropertyValue(property) === value) return; element.style.setProperty(property, value); @@ -175,29 +169,6 @@ const getHostTreePreviewRoots = (): HTMLElement[] => { )); }; -export const applyHostTreePreviewThemeVars = (theme: TerminalTheme) => { - const roots = getHostTreePreviewRoots(); - if (roots.length === 0) return; - const bg = theme.colors.background; - const fg = theme.colors.foreground; - const values = { - '--terminal-host-tree-bg': bg, - '--terminal-host-tree-fg': fg, - '--terminal-host-tree-muted': `color-mix(in srgb, ${fg} 55%, ${bg} 45%)`, - '--terminal-host-tree-separator': `color-mix(in srgb, ${fg} 10%, ${bg} 90%)`, - '--terminal-host-tree-hover-bg': `color-mix(in srgb, ${fg} 8%, transparent)`, - '--terminal-host-tree-active-bg': `color-mix(in srgb, ${fg} 14%, transparent)`, - '--terminal-host-tree-drop-bg': `color-mix(in srgb, ${fg} 20%, transparent)`, - '--terminal-host-tree-folder-fg': `color-mix(in srgb, ${fg} 75%, ${bg} 25%)`, - } satisfies Record<(typeof HOST_TREE_PREVIEW_PROPERTIES)[number], string>; - - for (const root of roots) { - for (const property of HOST_TREE_PREVIEW_PROPERTIES) { - setStylePropertyIfChanged(root, property, values[property]); - } - } -}; - export const clearHostTreePreviewVars = () => { const roots = getHostTreePreviewRoots(); for (const root of roots) { diff --git a/components/terminalLayer/terminalLayerStableSnapshot.ts b/components/terminalLayer/terminalLayerStableSnapshot.ts deleted file mode 100644 index bbed8c72e..000000000 --- a/components/terminalLayer/terminalLayerStableSnapshot.ts +++ /dev/null @@ -1,188 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import type React from 'react'; - -import type { DropEntry } from '../../lib/sftpFileUtils'; -import type { ProgrammaticCommandLogRewrite } from '../terminal/programmaticCommandLog'; -import type { - GroupConfig, - Host, - Identity, - KnownHost, - ProxyProfile, - SSHKey, - Snippet, - TerminalSession, - TerminalTheme, - VaultNote, - Workspace, -} from '../../types'; -import type { - PendingSftpUpload, - PendingTerminalSelectionForAI, - SidePanelTab, - SnippetExecutor, - TerminalLayerProps, -} from './TerminalLayerSupport'; - -export type TerminalLayerStableSnapshot = { - props: TerminalLayerProps; - t: (key: string) => string; - terminalBackend: ReturnType; - terminalRendererCwdBySessionRef: React.MutableRefObject>; - hosts: Host[]; - customGroups: string[]; - sessions: TerminalSession[]; - workspaces: Workspace[]; - draggingSessionId: string | null; - hostMap: Map; - hostMapRef: React.MutableRefObject>; - effectiveHosts: Host[]; - sessionHostsMap: Map; - sessionHostsMapRef: React.MutableRefObject>; - resolvedSessionHostIds: Set; - sessionChainHostsMap: Map; - sessionSudoAutofillPasswordsMap: Map; - workspaceById: Map; - snippetExecutorsRef: React.MutableRefObject>; - programmaticCommandLogRewriteHandlersRef: React.MutableRefObject void>>; - activeTabIdRef: React.MutableRefObject; - activeWorkspaceRef: React.MutableRefObject; - activeSessionRef: React.MutableRefObject; - focusedSessionIdRef: React.MutableRefObject; - sessionsRef: React.MutableRefObject; - workspacesRef: React.MutableRefObject; - hostsRef: React.MutableRefObject; - portForwardingRules: import('../../domain/models').PortForwardingRule[]; - portForwardingRulesRef: React.MutableRefObject; - onSetWorkspaceFocusedSessionRef: React.MutableRefObject; - sidePanelOpenTabs: Map; - setSidePanelOpenTabs: React.Dispatch>>; - sidePanelOpenTabsRef: React.MutableRefObject>; - sidePanelWidth: number; - setSidePanelWidth: (value: number) => void; - sidePanelPosition: 'left' | 'right'; - setSidePanelPosition: (value: 'left' | 'right') => void; - sftpHostForTab: Map; - setSftpHostForTab: React.Dispatch>>; - sftpHostForTabRef: React.MutableRefObject>; - sftpInitialLocationForTab: Map; - setSftpInitialLocationForTab: React.Dispatch>>; - sftpPendingUploadsForTab: Map; - setSftpPendingUploadsForTab: React.Dispatch>>; - pendingTerminalSelectionForAI: PendingTerminalSelectionForAI | null; - setPendingTerminalSelectionForAI: React.Dispatch>; - lastSidePanelTabRef: React.MutableRefObject>; - notesMountedTabIds: string[]; - setNotesMountedTabIds: React.Dispatch>; - notesOpenNoteByTab: Map; - setNotesOpenNoteByTab: React.Dispatch>>; - isComposeBarOpen: boolean; - setIsComposeBarOpen: React.Dispatch>; - splitHorizontalHandlersRef: React.MutableRefObject void>>; - splitVerticalHandlersRef: React.MutableRefObject void>>; - onSplitSessionRef: React.MutableRefObject; - workspaceFocusHandlersRef: React.MutableRefObject void>>; - workspaceBroadcastHandlersRef: React.MutableRefObject void>>; - onToggleWorkspaceViewModeRef: React.MutableRefObject; - onToggleBroadcastRef: React.MutableRefObject; - validAIScopeTargetIds: Set; - validSessionActivityIds: Set; - activityTrackedSessions: TerminalSession[]; - handleCloseSession: (sessionId: string) => void; - handleStatusChange: (sessionId: string, status: TerminalSession['status']) => void; - handleSessionExit: (sessionId: string, evt: any) => void; - handleOsDetected: (hostId: string, distro: string) => void; - handleUpdateHost: (host: Host) => void; - handleAddKnownHost: (knownHost: KnownHost) => void; - handleCommandExecuted: (command: string, hostId: string, hostLabel: string, sessionId: string) => void; - handleTerminalDataCapture: (sessionId: string, data: string) => void; - handleBroadcastInput: (data: string, sourceSessionId: string) => void; - handleBroadcastInterruptPriorityChange: (sessionId: string, prioritize: (() => void) | null) => void; - handleSnippetExecutorChange: (sessionId: string, executor: SnippetExecutor | null) => void; - handleProgrammaticCommandLogRewriteChange: ( - sessionId: string, - queueRewrite: ((rewrite: ProgrammaticCommandLogRewrite) => void) | null, - ) => void; - handleTerminalFontSizeChange: (sessionId: string, nextFontSize: number) => void; - handleOpenSftp: (host: Host, initialPath?: string, pendingUploadEntries?: DropEntry[], sourceSessionId?: string) => void; - handlePendingUploadHandled: (tabId: string, requestId: string) => void; - handleSftpInitialLocationApplied: (tabId: string, location: { hostId: string; path: string }) => void; - handleSftpCurrentPathChange: (memoryKey: string, location: { hostId: string; path: string }) => void; - handleSidePanelResizeStart: (e: React.MouseEvent) => void; - handleToggleWorkspaceComposeBar: () => void; - handleSwitchSidePanelTab: (tab: SidePanelTab) => void; - handleToggleSftpFromBar: () => void; - handleOpenScripts: () => void; - handleOpenHistory: () => void; - handleHistoryPaste: (command: string) => void; - handleHistoryRun: (command: string) => void; - handleToggleScriptsSidePanel: () => void; - handleToggleSidePanel: () => void; - handleOpenTheme: () => void; - handleOpenAI: () => void; - handleOpenSystem: () => void; - handleOpenNotes: () => void; - handleBackFromNotes: () => void; - handleOpenHostFromNotes: (host: Host, source?: { noteId?: string }) => void; - handleAddSelectionToAI: (sourceSessionId: string, selection: string) => void; - handlePendingTerminalSelectionConsumed: (requestId: string) => void; - handleToggleAiFromTopBar: () => void; - resolveSftpHostForTab: (tabId: string) => Host | null; - handleCloseSidePanel: () => void; - getTerminalCwd: () => Promise; - refocusTerminalSession: (sessionId?: string | null) => void; - refocusActiveTerminalSession: () => void; - onSessionData: ReturnType['onSessionData']; - toggleScriptsSidePanelRef?: React.MutableRefObject<(() => void) | null>; - toggleSidePanelRef?: React.MutableRefObject<(() => void) | null>; - accentMode: 'theme' | 'custom'; - customAccent: string; - followAppTerminalTheme: boolean; - terminalTheme: TerminalTheme; - terminalFontFamilyId: string; - fontSize: number; - terminalSettings: TerminalLayerProps['terminalSettings']; - editorWordWrap: boolean; - setEditorWordWrap: (value: boolean) => void; - keys: SSHKey[]; - identities: Identity[]; - snippets: Snippet[]; - snippetPackages: string[]; - notes: VaultNote[]; - noteGroups: string[]; - knownHosts: KnownHost[]; - hotkeyScheme: TerminalLayerProps['hotkeyScheme']; - disableTerminalFontZoom: TerminalLayerProps['disableTerminalFontZoom']; - restoreTerminalCwd: TerminalLayerProps['restoreTerminalCwd']; - keyBindings: TerminalLayerProps['keyBindings']; - onHotkeyAction: TerminalLayerProps['onHotkeyAction']; - onConnectToHost: TerminalLayerProps['onConnectToHost']; - onCreateLocalTerminal: TerminalLayerProps['onCreateLocalTerminal']; - onReorderWorkspaceSessions: TerminalLayerProps['onReorderWorkspaceSessions']; - onReorderTabs: TerminalLayerProps['onReorderTabs']; - onCopySession: TerminalLayerProps['onCopySession']; - onCopySessionToNewWindow: TerminalLayerProps['onCopySessionToNewWindow']; - onUpdateSessionRestoreCwd: TerminalLayerProps['onUpdateSessionRestoreCwd']; - onUpdateSessionDynamicTitle: TerminalLayerProps['onUpdateSessionDynamicTitle']; - onUpdateSessionCodingCliProvider: TerminalLayerProps['onUpdateSessionCodingCliProvider']; - onRequestAddToWorkspace: TerminalLayerProps['onRequestAddToWorkspace']; - onSetWorkspaceFocusedSession: TerminalLayerProps['onSetWorkspaceFocusedSession']; - onToggleWorkspaceViewMode: TerminalLayerProps['onToggleWorkspaceViewMode']; - onSplitSession: TerminalLayerProps['onSplitSession']; - isBroadcastEnabled: TerminalLayerProps['isBroadcastEnabled']; - updateHosts: TerminalLayerProps['updateHosts']; - updateSnippets: TerminalLayerProps['updateSnippets']; - updateSnippetPackages: TerminalLayerProps['updateSnippetPackages']; - updateNotes: TerminalLayerProps['updateNotes']; - updateNoteGroups: TerminalLayerProps['updateNoteGroups']; - sftpDefaultViewMode: TerminalLayerProps['sftpDefaultViewMode']; - sftpDoubleClickBehavior: TerminalLayerProps['sftpDoubleClickBehavior']; - sftpAutoSync: TerminalLayerProps['sftpAutoSync']; - sftpShowHiddenFiles: TerminalLayerProps['sftpShowHiddenFiles']; - sftpUseCompressedUpload: TerminalLayerProps['sftpUseCompressedUpload']; - sessionLogConfig: { enabled: true; directory: string; format: string; timestampsEnabled?: boolean } | undefined; - sshDebugLogsEnabled: boolean; - groupConfigs: GroupConfig[]; - proxyProfiles: ProxyProfile[]; - shellHistory: import('../../types').ShellHistoryEntry[]; -}; diff --git a/components/terminalLayer/terminalThemeSelection.test.ts b/components/terminalLayer/terminalThemeSelection.test.ts deleted file mode 100644 index e76c81b06..000000000 --- a/components/terminalLayer/terminalThemeSelection.test.ts +++ /dev/null @@ -1,56 +0,0 @@ -import assert from "node:assert/strict"; -import test from "node:test"; - -import { emptyTerminalThemePreview } from "./terminalThemePreview"; -import { - resolveActiveThemePreviewId, - resolveThemeListSelectionId, -} from "./terminalThemeSelection"; - -const preview = { - targetSessionId: "session-a", - targetHostId: "host-1", - globalPreview: false, - themeId: "dracula", -}; - -test("active preview id follows host scope when focus moves within the same host", () => { - assert.equal( - resolveActiveThemePreviewId(preview, "session-b", "host-1"), - "dracula", - ); - assert.equal( - resolveActiveThemePreviewId(preview, "session-b", "host-2"), - null, - ); -}); - -test("follow-app list selection prefers pending pick over resolved terminal theme", () => { - assert.equal( - resolveThemeListSelectionId({ - followAppTerminalTheme: true, - followAppPendingThemeId: "system-flexoki-light", - terminalThemeId: "system-github-dark", - themePreview: emptyTerminalThemePreview(), - previewTargetSessionId: "session-a", - previewTargetHostId: "host-1", - focusedThemeId: "system-github-dark", - }), - "system-flexoki-light", - ); -}); - -test("manual list selection prefers in-scope preview over focused theme", () => { - assert.equal( - resolveThemeListSelectionId({ - followAppTerminalTheme: false, - followAppPendingThemeId: null, - terminalThemeId: "netcatty-dark", - themePreview: preview, - previewTargetSessionId: "session-b", - previewTargetHostId: "host-1", - focusedThemeId: "solarized-light", - }), - "dracula", - ); -}); diff --git a/components/terminalLayer/terminalThemeSelection.ts b/components/terminalLayer/terminalThemeSelection.ts deleted file mode 100644 index a892b555c..000000000 --- a/components/terminalLayer/terminalThemeSelection.ts +++ /dev/null @@ -1,40 +0,0 @@ -import type { TerminalThemePreviewState } from './terminalThemePreview'; - -/** Which preview theme id applies to the current focus scope (list highlight in manual mode). */ -export function resolveActiveThemePreviewId( - themePreview: TerminalThemePreviewState, - previewTargetSessionId: string | null, - previewTargetHostId: string | null, -): string | null { - if (!themePreview.themeId) return null; - if (themePreview.globalPreview) return themePreview.themeId; - if (themePreview.targetSessionId === previewTargetSessionId) return themePreview.themeId; - if ( - themePreview.targetHostId - && previewTargetHostId - && themePreview.targetHostId === previewTargetHostId - ) { - return themePreview.themeId; - } - return null; -} - -/** Single source of truth for the theme list checkmark / footer label. */ -export function resolveThemeListSelectionId(options: { - followAppTerminalTheme: boolean; - followAppPendingThemeId: string | null | undefined; - terminalThemeId: string; - themePreview: TerminalThemePreviewState; - previewTargetSessionId: string | null; - previewTargetHostId: string | null; - focusedThemeId: string; -}): string { - if (options.followAppTerminalTheme) { - return options.followAppPendingThemeId ?? options.terminalThemeId; - } - return resolveActiveThemePreviewId( - options.themePreview, - options.previewTargetSessionId, - options.previewTargetHostId, - ) ?? options.focusedThemeId; -} diff --git a/domain/agentIcon.ts b/domain/agentIcon.ts index 9c1b618ba..4d6386d2f 100644 --- a/domain/agentIcon.ts +++ b/domain/agentIcon.ts @@ -136,8 +136,6 @@ export type AgentIconSource = { type?: 'builtin' | 'external'; }; -const GENERIC_AGENT_ICON_KEYS = new Set(['terminal', 'plus', 'catty']); - export function normalizeAgentToken(value?: string): string { return (value ?? '').toLowerCase().replace(/[^a-z0-9]+/g, ''); } @@ -211,10 +209,6 @@ export function resolveAgentIconKey(source: AgentIconSource | 'add-more'): Agent return 'terminal'; } -export function isRecognizedAgentIconKey(key: AgentIconKey): boolean { - return !GENERIC_AGENT_ICON_KEYS.has(key); -} - export function getAgentIconVisual(key: AgentIconKey): AgentIconVisual { return AGENT_ICON_VISUALS[key]; } diff --git a/domain/codingCliProviderMatch.ts b/domain/codingCliProviderMatch.ts index f7652634d..cd02ebf21 100644 --- a/domain/codingCliProviderMatch.ts +++ b/domain/codingCliProviderMatch.ts @@ -1,4 +1,4 @@ -import { CODING_CLI_PROVIDERS, getCodingCliProvider, type CodingCliProvider, type CodingCliProviderId } from './codingCliProviders'; +import { CODING_CLI_PROVIDERS, getCodingCliProvider, type CodingCliProvider } from './codingCliProviders'; import { inferCodingCliProviderFromTitleSignals, titleIncludesPhrase, @@ -127,10 +127,3 @@ export function resolveSessionCodingCliProvider( return undefined; } - -export function resolveSessionCodingCliProviderId( - source: SessionCodingCliSource, - host?: Pick, -): CodingCliProviderId | undefined { - return resolveSessionCodingCliProvider(source, host)?.id; -} diff --git a/domain/hostConnectScripts.test.ts b/domain/hostConnectScripts.test.ts index 61f371b33..d33e959a6 100644 --- a/domain/hostConnectScripts.test.ts +++ b/domain/hostConnectScripts.test.ts @@ -6,7 +6,6 @@ import { getGlobalConnectScripts, getHostConnectScriptIds, migrateHostConnectScriptIds, - moveHostConnectScript, reorderHostConnectScript, removeHostConnectScript, resolveConnectScriptsForHost, @@ -55,7 +54,7 @@ test('resolveConnectScriptsForHost runs globals before host queue and dedupes', assert.deepEqual(resolved.map((item) => item.id), ['global', 'both', 'host-only']); }); -test('append and move update host connectScriptIds order', () => { +test('append updates host connectScriptIds order', () => { const snippets = [ script({ id: 'a', targets: ['host-a'] }), script({ id: 'b', targets: ['host-a'] }), @@ -63,8 +62,6 @@ test('append and move update host connectScriptIds order', () => { let next = appendHostConnectScript(host, 'a', snippets); next = appendHostConnectScript(next, 'b', snippets); assert.deepEqual(getHostConnectScriptIds(next, snippets), ['a', 'b']); - next = moveHostConnectScript(next, 'b', 'up', snippets); - assert.deepEqual(getHostConnectScriptIds(next, snippets), ['b', 'a']); }); test('syncHostsForSnippetTargetChange appends and removes queue entries', () => { diff --git a/domain/hostConnectScripts.ts b/domain/hostConnectScripts.ts index 765b06b92..e86bcc2d3 100644 --- a/domain/hostConnectScripts.ts +++ b/domain/hostConnectScripts.ts @@ -134,21 +134,6 @@ export function removeHostConnectScript(host: Host, scriptId: string, snippets: return { ...host, connectScriptIds: next }; } -export function moveHostConnectScript( - host: Host, - scriptId: string, - direction: 'up' | 'down', - snippets: Snippet[], -): Host { - const current = [...getHostConnectScriptIds(host, snippets)]; - const index = current.indexOf(scriptId); - if (index === -1) return host; - const targetIndex = direction === 'up' ? index - 1 : index + 1; - if (targetIndex < 0 || targetIndex >= current.length) return host; - [current[index], current[targetIndex]] = [current[targetIndex], current[index]]; - return { ...host, connectScriptIds: current }; -} - export function reorderHostConnectScript( host: Host, draggedScriptId: string, @@ -208,11 +193,3 @@ export function syncHostsForSnippetTargetChange( return updated; }); } - -export function connectScriptsForHostFromSnippets( - hostId: string, - snippets: Snippet[], -): Snippet[] { - const host = { id: hostId } as Host; - return resolveConnectScriptsForHost(host, snippets); -} diff --git a/domain/snippetTargets.ts b/domain/snippetTargets.ts index c9f6fdccc..1341748f7 100644 --- a/domain/snippetTargets.ts +++ b/domain/snippetTargets.ts @@ -52,14 +52,6 @@ export function getScriptsLinkedToHost(snippets: Snippet[], hostId: string): Sni ); } -export function getLoginScriptForHost(snippets: Snippet[], hostId: string): Snippet | undefined { - return snippets.find( - (snippet) => isScriptSnippet(snippet) - && snippet.trigger === 'onConnect' - && snippetAppliesToHost(snippet, hostId), - ); -} - export function linkHostToScript(snippet: Snippet, hostId: string): Snippet { const targets = snippet.targets ?? []; if (targets.includes(hostId)) { @@ -79,37 +71,8 @@ export function unlinkHostFromScript(snippet: Snippet, hostId: string): Snippet return { ...snippet, targets: nextTargets.length > 0 ? nextTargets : undefined }; } -export function linkHostToScripts(snippets: Snippet[], hostId: string, scriptId: string): Snippet[] { - return snippets.map((snippet) => ( - snippet.id === scriptId ? linkHostToScript(snippet, hostId) : snippet - )); -} - export function unlinkHostFromScripts(snippets: Snippet[], hostId: string, scriptId: string): Snippet[] { return snippets.map((snippet) => ( snippet.id === scriptId ? unlinkHostFromScript(snippet, hostId) : snippet )); } - -/** @deprecated Prefer host.connectScriptIds queue via HostDetails automation panel. */ -export function setLoginScriptForHost( - snippets: Snippet[], - hostId: string, - scriptId?: string, -): Snippet[] { - const cleared = snippets.map((snippet) => { - if (!isScriptSnippet(snippet) || snippet.trigger !== 'onConnect') return snippet; - if (!snippet.targets?.includes(hostId)) return snippet; - return unlinkHostFromScript(snippet, hostId); - }); - - if (!scriptId) return cleared; - - return cleared.map((snippet) => { - if (!isScriptSnippet(snippet) || snippet.id !== scriptId) return snippet; - return { - ...linkHostToScript(snippet, hostId), - trigger: 'onConnect' as const, - }; - }); -} diff --git a/electron-builder.config.cjs b/electron-builder.config.cjs index 6e885aad2..34cdae344 100644 --- a/electron-builder.config.cjs +++ b/electron-builder.config.cjs @@ -52,7 +52,6 @@ module.exports = { 'infrastructure/config/terminalFlowConstants.json', 'lib/**/*.cjs', 'lib/**/*.json', - '!electron/.dev-config.json', 'skills/**/*', '!public/**/*', '!**/*.map', diff --git a/electron/.dev-config.json b/electron/.dev-config.json deleted file mode 100644 index ea2923fa6..000000000 --- a/electron/.dev-config.json +++ /dev/null @@ -1 +0,0 @@ -{"VITE_DEV_SERVER_URL":"http://localhost:5173"} \ No newline at end of file diff --git a/electron/scripts/scriptStepCounter.cjs b/electron/scripts/scriptStepCounter.cjs deleted file mode 100644 index 13fb348de..000000000 --- a/electron/scripts/scriptStepCounter.cjs +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; - -const STEP_MATCHERS = [ - { regex: /await\s+nct\.screen\.waitForPrompt\s*\(/g, label: "waitForPrompt" }, - { regex: /await\s+nct\.screen\.waitForAny\s*\(/g, label: "waitForAny" }, - { regex: /await\s+nct\.screen\.waitForText\s*\(/g, label: "waitForText" }, - { regex: /await\s+nct\.screen\.waitForRegex\s*\(/g, label: "waitForRegex" }, - { regex: /await\s+nct\.screen\.waitFor\s*\(/g, label: "waitFor" }, - { regex: /await\s+nct\.screen\.sendLine\s*\(/g, label: "sendLine" }, - { regex: /await\s+nct\.screen\.send\s*\(/g, label: "send" }, - { regex: /await\s+nct\.screen\.clear\s*\(/g, label: "clear" }, - { regex: /await\s+nct\.session\.sleep\s*\(/g, label: "sleep" }, - { regex: /await\s+nct\.sleep\s*\(/g, label: "sleep" }, - { regex: /await\s+nct\.session\.disconnect\s*\(/g, label: "disconnect" }, - { regex: /await\s+nct\.session\.startLog\s*\(/g, label: "startLog" }, - { regex: /nct\.log\s*\(/g, label: "log" }, -]; - -function countScriptSteps(source) { - const text = String(source || ""); - let total = 0; - for (const matcher of STEP_MATCHERS) { - const matches = text.match(matcher.regex); - if (matches) total += matches.length; - } - return Math.max(total, 1); -} - -module.exports = { - STEP_MATCHERS, - countScriptSteps, -}; diff --git a/electron/scripts/scriptStepCounter.test.cjs b/electron/scripts/scriptStepCounter.test.cjs deleted file mode 100644 index 6e46e99e6..000000000 --- a/electron/scripts/scriptStepCounter.test.cjs +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -const test = require("node:test"); -const assert = require("node:assert/strict"); -const { countScriptSteps } = require("./scriptStepCounter.cjs"); - -test("countScriptSteps counts common nct calls", () => { - const source = ` -await nct.screen.waitFor('$ ', 5000); -await nct.screen.waitForText('ready', 5000); -await nct.screen.waitForRegex('READY.*', 5000); -await nct.screen.sendLine('ls'); -nct.log('done'); -`; - assert.equal(countScriptSteps(source), 5); -}); diff --git a/infrastructure/ai/sdk/tools.test.ts b/infrastructure/ai/sdk/tools.test.ts deleted file mode 100644 index 74317754b..000000000 --- a/infrastructure/ai/sdk/tools.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import test from "node:test"; -import assert from "node:assert/strict"; - -import { fitTerminalExecuteResultForModel } from "./tools.ts"; - -test("fitTerminalExecuteResultForModel keeps command output compact for model replay", () => { - const result = fitTerminalExecuteResultForModel({ - stdout: "A".repeat(200_000), - stderr: "B".repeat(50_000), - exitCode: 0, - }); - - assert.ok(result.stdout.length < 25_000); - assert.ok(result.stderr.length < 12_000); - assert.match(result.stdout, /output truncated for request size/); - assert.equal(result.exitCode, 0); -}); diff --git a/infrastructure/ai/sdk/tools.ts b/infrastructure/ai/sdk/tools.ts deleted file mode 100644 index 7e1172a2a..000000000 --- a/infrastructure/ai/sdk/tools.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { createCattyToolsFromCatalog, fitTerminalExecuteResultForModel } from '../harness'; - -export { fitTerminalExecuteResultForModel }; - -/** @deprecated Use createCattyToolsFromCatalog from harness directly. */ -export const createCattyTools = createCattyToolsFromCatalog; diff --git a/lib/regexSafety.ts b/lib/regexSafety.ts index 9284ee575..83929a184 100644 --- a/lib/regexSafety.ts +++ b/lib/regexSafety.ts @@ -6,16 +6,10 @@ */ export type RegexSafetyReason = "nested_quantifier"; -export type RegexValidationIssue = "syntax_invalid" | "safety_rejected"; - export type RegexSafetyCheckResult = | { safe: true } | { safe: false; reason: RegexSafetyReason }; -export type RegexValidationResult = - | { valid: true } - | { valid: false; issue: RegexValidationIssue; reason?: RegexSafetyReason; errorMessage?: string }; - export function checkRegexSafetyPattern(pattern: string): RegexSafetyCheckResult { const nestedUnboundedQuantifier = /\((?:\?:)?[^)]*(?:\+|\*|\{\d+,\}|\{,\d+\})[^)]*\)(?:\+|\*|\{\d+,\}|\{,\d+\})/; if (nestedUnboundedQuantifier.test(pattern)) { @@ -23,31 +17,3 @@ export function checkRegexSafetyPattern(pattern: string): RegexSafetyCheckResult } return { safe: true }; } - -export function validateUserRegexPattern(pattern: string, flags = "gi"): RegexValidationResult { - try { - // Syntax validation only. - new RegExp(pattern, flags); - } catch (err) { - return { - valid: false, - issue: "syntax_invalid", - errorMessage: err instanceof Error ? err.message : String(err), - }; - } - - const safety = checkRegexSafetyPattern(pattern); - if (safety.safe === false) { - return { - valid: false, - issue: "safety_rejected", - reason: safety.reason, - }; - } - - return { valid: true }; -} - -export function isSafeRegexPattern(pattern: string): boolean { - return checkRegexSafetyPattern(pattern).safe; -} diff --git a/lib/searchMatcher.ts b/lib/searchMatcher.ts index 4ca3b0072..8405c4d00 100644 --- a/lib/searchMatcher.ts +++ b/lib/searchMatcher.ts @@ -348,10 +348,3 @@ export function getHostSearchMatch( const networkResult = evaluateHostFieldGroup(querySegments, networkSources); return selectBetterHostMatch(humanResult, networkResult); } - -export function getHostSearchReason(match: HostSearchMatchResult): string { - if (!match.matched || match.details.length === 0) return ""; - const uniqueFields = Array.from(new Set(match.details.map((detail) => detail.field))); - const phaseLabel = match.phase === "strict" ? "strict" : "loose"; - return `${phaseLabel}:${uniqueFields.join("/")}`; -} diff --git a/lib/sftpFileUtils.ts b/lib/sftpFileUtils.ts index 17412c065..a43b716d9 100644 --- a/lib/sftpFileUtils.ts +++ b/lib/sftpFileUtils.ts @@ -5,57 +5,6 @@ import { netcattyBridge } from "../infrastructure/services/netcattyBridge"; -// Common text file extensions -const TEXT_EXTENSIONS = new Set([ - // Code/Scripts - 'js', 'jsx', 'ts', 'tsx', 'mjs', 'cjs', 'vue', 'svelte', - 'py', 'pyw', 'pyi', - 'sh', 'bash', 'zsh', 'fish', 'bat', 'cmd', 'ps1', 'psm1', - 'c', 'cpp', 'h', 'hpp', 'cc', 'cxx', 'hh', 'hxx', - 'java', 'scala', 'kt', 'kts', 'groovy', 'gradle', - 'go', 'rs', 'rb', 'php', 'pl', 'pm', 'lua', 'r', 'R', - 'swift', 'dart', 'cs', 'fs', 'vb', - 'ex', 'exs', 'erl', 'hrl', 'clj', 'cljs', 'cljc', - 'hs', 'lhs', 'elm', 'ml', 'mli', 'nim', - // Web - 'html', 'htm', 'xhtml', 'css', 'scss', 'sass', 'less', 'styl', - // Config/Data - 'json', 'json5', 'jsonc', 'xml', 'xsl', 'xslt', 'xsd', - 'yml', 'yaml', 'toml', 'ini', 'conf', 'cfg', 'config', 'properties', - 'env', 'gitignore', 'gitattributes', 'editorconfig', 'eslintrc', 'prettierrc', - 'sql', 'graphql', 'gql', - // Text/Docs - 'md', 'markdown', 'mdx', 'txt', 'text', 'log', 'rst', 'adoc', 'asciidoc', - 'tex', 'latex', 'bib', - // Data formats - 'csv', 'tsv', 'psv', - // System - 'rc', 'bashrc', 'zshrc', 'profile', 'vimrc', 'tmux', 'nanorc', - 'dockerfile', 'containerfile', 'makefile', 'cmake', 'mak', - // Version control & Git - 'gitconfig', 'gitmodules', 'gitkeep', - // Other common text formats - 'diff', 'patch', 'htaccess', 'lock', 'sum', - // Service/System files - 'service', 'socket', 'timer', 'mount', 'automount', 'target', - // Shell history and data - 'history', 'zsh_history', 'bash_history', -]); - -// Additional filenames (no extension) that are always text -const TEXT_FILENAMES = new Set([ - 'readme', 'license', 'licence', 'changelog', 'authors', 'contributors', - 'copying', 'install', 'news', 'todo', 'history', 'makefile', 'dockerfile', - 'gemfile', 'rakefile', 'brewfile', 'procfile', 'vagrantfile', - 'cmakelists.txt', 'cmakelists', -]); - -// Common image file extensions -const IMAGE_EXTENSIONS = new Set([ - 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg', - 'ico', 'tiff', 'tif', 'heic', 'heif', 'avif', 'jfif', -]); - // Known binary file extensions - files that should never be opened as text const BINARY_EXTENSIONS = new Set([ // Images @@ -83,24 +32,6 @@ const BINARY_EXTENSIONS = new Set([ 'swf', 'fla', 'blend', 'unity3d', 'unitypackage', ]); -// MIME types for images (for creating blob URLs) -const IMAGE_MIME_TYPES: Record = { - jpg: 'image/jpeg', - jpeg: 'image/jpeg', - jfif: 'image/jpeg', - png: 'image/png', - gif: 'image/gif', - bmp: 'image/bmp', - webp: 'image/webp', - svg: 'image/svg+xml', - ico: 'image/x-icon', - tiff: 'image/tiff', - tif: 'image/tiff', - heic: 'image/heic', - heif: 'image/heif', - avif: 'image/avif', -}; - // Language IDs for syntax highlighting const EXTENSION_TO_LANGUAGE: Record = { js: 'javascript', @@ -194,108 +125,6 @@ export function hasFileExtension(fileName: string): boolean { return fileName.lastIndexOf('.') > 0; } -/** - * Check if a file is a text file based on its extension and name - */ -export function isTextFile(fileName: string): boolean { - const ext = getFileExtension(fileName); - - // Check known text extensions - if (TEXT_EXTENSIONS.has(ext)) { - return true; - } - - // Check common filenames that are text but have no extension - const baseName = fileName.toLowerCase().split('/').pop() || ''; - const nameWithoutExt = baseName.replace(/\.[^.]+$/, ''); - - // Check exact filename matches - if (TEXT_FILENAMES.has(baseName) || TEXT_FILENAMES.has(nameWithoutExt)) { - return true; - } - - // Check dot-files that are typically text config files - if (baseName.startsWith('.')) { - const dotConfigPatterns = [ - /^\.(git|npm|yarn|docker|eslint|prettier|babel|env)/, - /^\.(nvmrc|ruby-version|python-version|node-version)$/, - /rc$/, // Files ending with 'rc' like .bashrc, .vimrc - ]; - if (dotConfigPatterns.some(pattern => pattern.test(baseName))) { - return true; - } - } - - return false; -} - -/** - * Check if binary data appears to be text by analyzing byte patterns - * This provides a more accurate detection than extension-only checking - * - * @param data - First chunk of file data (ArrayBuffer or Uint8Array) - * @param maxBytes - Maximum bytes to check (default 512) - * @returns true if data appears to be text - */ -export function isTextData(data: ArrayBuffer | Uint8Array, maxBytes: number = 512): boolean { - const bytes = data instanceof ArrayBuffer ? new Uint8Array(data) : data; - const checkLength = Math.min(bytes.length, maxBytes); - - if (checkLength === 0) return true; // Empty file is considered text - - let controlChars = 0; - let nullBytes = 0; - let highBytes = 0; - let totalBytes = 0; - - for (let i = 0; i < checkLength; i++) { - const byte = bytes[i]; - totalBytes++; - - // Null bytes are strong indicators of binary files - if (byte === 0) { - nullBytes++; - if (nullBytes > 0) return false; // Even one null byte suggests binary - } - - // Control characters (except common ones like \t, \n, \r) - if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) { - controlChars++; - } - - // High-bit characters (non-ASCII) - some are OK for UTF-8 - if (byte > 127) { - highBytes++; - } - } - - // If more than 30% are control chars or more than 95% are high-bit chars, likely binary - const controlRatio = controlChars / totalBytes; - const highRatio = highBytes / totalBytes; - - if (controlRatio > 0.3) return false; - if (highRatio > 0.95) return false; - - return true; -} - -/** - * Enhanced text file detection combining extension and content analysis - * Use this when you have access to file data for better accuracy - */ -export function isTextFileEnhanced(fileName: string, data?: ArrayBuffer | Uint8Array): boolean { - // First check by extension - const extCheck = isTextFile(fileName); - - // If we have data, verify it's actually text - if (data && data.byteLength > 0) { - return extCheck && isTextData(data); - } - - // Fall back to extension-only check - return extCheck; -} - /** * Check if a file is definitely a binary file based on its extension. * Used to exclude files from "Edit" option in context menu. @@ -305,37 +134,6 @@ export function isKnownBinaryFile(fileName: string): boolean { return BINARY_EXTENSIONS.has(ext); } -/** - * Check if a file could potentially be opened as text. - * This is more permissive than isTextFile - it returns true for any file - * that is not a known binary file. Used for showing "Edit" in context menu. - * Actual text detection should be done by reading file content. - */ -export function couldBeTextFile(fileName: string): boolean { - // If it's a known binary file, definitely not text - if (isKnownBinaryFile(fileName)) { - return false; - } - // Otherwise, it could be text - we'll verify when actually opening - return true; -} - -/** - * Check if a file is an image file based on its extension - */ -export function isImageFile(fileName: string): boolean { - const ext = getFileExtension(fileName); - return IMAGE_EXTENSIONS.has(ext); -} - -/** - * Get MIME type for an image file - */ -export function getImageMimeType(fileName: string): string { - const ext = getFileExtension(fileName); - return IMAGE_MIME_TYPES[ext] || 'application/octet-stream'; -} - /** * Get language ID for syntax highlighting */ diff --git a/lib/useRenderTracker.ts b/lib/useRenderTracker.ts index 0a704ac9b..cf177dafa 100644 --- a/lib/useRenderTracker.ts +++ b/lib/useRenderTracker.ts @@ -78,18 +78,3 @@ function summarizeValue(value: unknown): string { } return String(value); } - -/** - * 简单的渲染计数器,只记录渲染次数不做详细分析 - */ -export function useRenderCount(componentName: string): number { - const renderCountRef = useRef(0); - renderCountRef.current += 1; - - // 只在调试模式下打印 - if (DEBUG_RENDER_TRACKING) { - logger.info(`[Render] ${componentName} - 第${renderCountRef.current}次渲染`); - } - - return renderCountRef.current; -} diff --git a/public/ai/agents/sparkles.svg b/public/ai/agents/sparkles.svg deleted file mode 100644 index dbdbc1ecf..000000000 --- a/public/ai/agents/sparkles.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/public/dmg-background.jpg b/public/dmg-background.jpg deleted file mode 100644 index 4876a338e..000000000 Binary files a/public/dmg-background.jpg and /dev/null differ diff --git a/public/dmg-fix-icon.png b/public/dmg-fix-icon.png deleted file mode 100644 index fbf2462e2..000000000 Binary files a/public/dmg-fix-icon.png and /dev/null differ diff --git a/public/icon-win.svg b/public/icon-win.svg deleted file mode 100644 index dfc92a790..000000000 --- a/public/icon-win.svg +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/public/icons/variants/original.png b/public/icons/variants/original.png deleted file mode 100644 index f0620503d..000000000 Binary files a/public/icons/variants/original.png and /dev/null differ diff --git a/screenshots/ai-feature.png b/screenshots/ai-feature.png deleted file mode 100644 index 2e06d52dd..000000000 Binary files a/screenshots/ai-feature.png and /dev/null differ diff --git a/screenshots/gifs/ai-feature-muti-hosts.mp4 b/screenshots/gifs/ai-feature-muti-hosts.mp4 deleted file mode 100644 index cdae540b9..000000000 Binary files a/screenshots/gifs/ai-feature-muti-hosts.mp4 and /dev/null differ diff --git a/screenshots/gifs/ai-feature.mp4 b/screenshots/gifs/ai-feature.mp4 deleted file mode 100644 index f11f7ce69..000000000 Binary files a/screenshots/gifs/ai-feature.mp4 and /dev/null differ diff --git a/screenshots/gifs/custom-highlight.mp4 b/screenshots/gifs/custom-highlight.mp4 deleted file mode 100644 index aafad22bc..000000000 Binary files a/screenshots/gifs/custom-highlight.mp4 and /dev/null differ diff --git a/screenshots/gifs/custom-themes.mp4 b/screenshots/gifs/custom-themes.mp4 deleted file mode 100644 index a986f9683..000000000 Binary files a/screenshots/gifs/custom-themes.mp4 and /dev/null differ diff --git a/screenshots/gifs/drag-file-upload.mp4 b/screenshots/gifs/drag-file-upload.mp4 deleted file mode 100644 index e4a4dfc61..000000000 Binary files a/screenshots/gifs/drag-file-upload.mp4 and /dev/null differ diff --git a/screenshots/gifs/dual-terminal--split-manage.mp4 b/screenshots/gifs/dual-terminal--split-manage.mp4 deleted file mode 100644 index 40209b928..000000000 Binary files a/screenshots/gifs/dual-terminal--split-manage.mp4 and /dev/null differ diff --git a/screenshots/gifs/gird-list-tre-views.mp4 b/screenshots/gifs/gird-list-tre-views.mp4 deleted file mode 100644 index 5e09fcfad..000000000 Binary files a/screenshots/gifs/gird-list-tre-views.mp4 and /dev/null differ diff --git a/screenshots/gifs/main-window-light.png b/screenshots/gifs/main-window-light.png deleted file mode 100644 index 13432e1eb..000000000 Binary files a/screenshots/gifs/main-window-light.png and /dev/null differ diff --git a/screenshots/gifs/sftpview-with-drag-and-built-in-editor.mp4 b/screenshots/gifs/sftpview-with-drag-and-built-in-editor.mp4 deleted file mode 100644 index 100ee5f46..000000000 Binary files a/screenshots/gifs/sftpview-with-drag-and-built-in-editor.mp4 and /dev/null differ diff --git a/screenshots/main-window-dark.png b/screenshots/main-window-dark.png deleted file mode 100644 index 4020e48bb..000000000 Binary files a/screenshots/main-window-dark.png and /dev/null differ diff --git a/screenshots/main-window-light.png b/screenshots/main-window-light.png deleted file mode 100644 index 13432e1eb..000000000 Binary files a/screenshots/main-window-light.png and /dev/null differ diff --git a/screenshots/split-window.png b/screenshots/split-window.png deleted file mode 100644 index da460b670..000000000 Binary files a/screenshots/split-window.png and /dev/null differ diff --git a/screenshots/treeview-dark.png b/screenshots/treeview-dark.png deleted file mode 100644 index 8e26c485e..000000000 Binary files a/screenshots/treeview-dark.png and /dev/null differ diff --git a/screenshots/treeview-light.png b/screenshots/treeview-light.png deleted file mode 100644 index 962371417..000000000 Binary files a/screenshots/treeview-light.png and /dev/null differ diff --git a/screenshots/vault_grid_view.png b/screenshots/vault_grid_view.png deleted file mode 100644 index 0e9cbba75..000000000 Binary files a/screenshots/vault_grid_view.png and /dev/null differ diff --git a/screenshots/vault_list_view.png b/screenshots/vault_list_view.png deleted file mode 100644 index 8b4397d8b..000000000 Binary files a/screenshots/vault_list_view.png and /dev/null differ