Files
Netcatty/application/state/useManualTerminalChromeSurfaceInjection.ts
T
bincxz 71687491f0 Fix terminal theme mode switching and speed up workspace tab changes.
Keep connection dialog and chrome surfaces in sync when toggling follow-app vs manual themes, and isolate side-panel live state per tab so switching workspace tabs no longer re-renders every mounted panel.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 03:28:50 +08:00

29 lines
936 B
TypeScript

import { useLayoutEffect, useRef } from 'react';
import type { TerminalTheme } from '../../domain/models';
import { applyTopTabsChromeThemeVars } from '../app/topTabsChromeTheme';
import {
clearTerminalLayerChromeSurfaceVars,
injectTerminalLayerChromeSurfaceVars,
} from '../../infrastructure/theme/terminalAppearanceVars';
/** Manual mode: side panel + host tree follow the focused session theme, not the global default. */
export function useManualTerminalChromeSurfaceInjection(
theme: TerminalTheme,
enabled: boolean,
): void {
const prevEnabledRef = useRef(enabled);
useLayoutEffect(() => {
const wasEnabled = prevEnabledRef.current;
prevEnabledRef.current = enabled;
if (enabled) {
injectTerminalLayerChromeSurfaceVars(theme);
applyTopTabsChromeThemeVars(theme);
return;
}
if (wasEnabled) {
clearTerminalLayerChromeSurfaceVars();
}
}, [enabled, theme.id, theme]);
}