MCPcopy
hub / github.com/binaricat/Netcatty / LogViewComponent

Function LogViewComponent

components/LogView.tsx:24–328  ·  view source on GitHub ↗
({
    log,
    defaultTerminalTheme,
    defaultFontSize,
    isVisible,
    onClose,
    onUpdateLog,
})

Source from the content-addressed store, hash-verified

22}
23
24const LogViewComponent: React.FC<LogViewProps> = ({
25 log,
26 defaultTerminalTheme,
27 defaultFontSize,
28 isVisible,
29 onClose,
30 onUpdateLog,
31}) => {
32 const { t, resolvedLocale } = useI18n();
33 const containerRef = useRef<HTMLDivElement>(null);
34 const termRef = useRef<XTerm | null>(null);
35 const fitAddonRef = useRef<FitAddon | null>(null);
36 const [isReady, setIsReady] = useState(false);
37 const [themeModalOpen, setThemeModalOpen] = useState(false);
38 const [isExporting, setIsExporting] = useState(false);
39 const [previewTheme, setPreviewTheme] = useState<TerminalTheme | null>(null);
40
41 // Subscribe to custom theme changes so editing triggers re-render
42 const customThemes = useCustomThemes();
43 const explicitThemeId = useMemo(() => {
44 if (!log.themeId) return undefined;
45 const exists = TERMINAL_THEMES.some((theme) => theme.id === log.themeId)
46 || customThemes.some((theme) => theme.id === log.themeId);
47 return exists ? log.themeId : undefined;
48 }, [customThemes, log.themeId]);
49
50 useEffect(() => {
51 if (log.themeId && !explicitThemeId) {
52 onUpdateLog(log.id, { themeId: undefined });
53 }
54 }, [explicitThemeId, log.id, log.themeId, onUpdateLog]);
55
56 // Use log's saved theme/fontSize or fall back to defaults
57 const currentTheme = useMemo(() => {
58 if (previewTheme) {
59 return previewTheme;
60 }
61 if (explicitThemeId) {
62 return TERMINAL_THEMES.find(t => t.id === explicitThemeId)
63 || customThemes.find(t => t.id === explicitThemeId)
64 || defaultTerminalTheme;
65 }
66 return defaultTerminalTheme;
67 }, [customThemes, defaultTerminalTheme, explicitThemeId, previewTheme]);
68
69 const currentFontSize = log.fontSize ?? defaultFontSize;
70
71 // Format date for display
72 const formattedDate = useMemo(() => {
73 const date = new Date(log.startTime);
74 return date.toLocaleString(resolvedLocale || undefined, {
75 year: "numeric",
76 month: "short",
77 day: "numeric",
78 hour: "2-digit",
79 minute: "2-digit",
80 });
81 }, [log.startTime, resolvedLocale]);

Callers

nothing calls this directly

Calls 8

useI18nFunction · 0.90
useCustomThemesFunction · 0.90
cnFunction · 0.90
exportSessionLogMethod · 0.80
tFunction · 0.70
getMethod · 0.45
writeMethod · 0.45
disposeMethod · 0.45

Tested by

no test coverage detected