mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-21 23:50:45 +00:00
* perf(terminal): smooth layout drags and faster tab switching Defer xterm refit during split, sidebar, and host-tree drags while keeping pane containers in sync with live layout measurements. Refactor TerminalLayer into focused sections with TabBridge/memo optimizations and add the terminal host tree sidebar. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(terminal): keep side panels alive and guard session attach races Prevent terminal boot unmount from leaking backend sessions, keep SFTP/scripts/theme/AI state when switching side tabs, and defer heavy SFTP UI mount so first entry stays responsive. Co-authored-by: Cursor <cursoragent@cursor.com> * perf(terminal): reduce tab switch jank --------- Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { useSyncExternalStore } from 'react';
|
|
|
|
/**
|
|
* Tiny external store for "immersive mode active" (whether the active terminal
|
|
* tab's theme is driving the app chrome). Kept out of the App component's render
|
|
* so that toggling immersive — and tab switches in general — do not force a
|
|
* full App re-render. The owner (AppActiveTabChrome) calls setImmersiveActive;
|
|
* AppView/TopTabs read it via useImmersiveActive without re-rendering App.
|
|
*/
|
|
type Listener = () => void;
|
|
|
|
let immersiveActive = false;
|
|
const listeners = new Set<Listener>();
|
|
|
|
export function setImmersiveActive(active: boolean): void {
|
|
if (immersiveActive === active) return;
|
|
immersiveActive = active;
|
|
listeners.forEach((listener) => listener());
|
|
}
|
|
|
|
function subscribe(listener: Listener): () => void {
|
|
listeners.add(listener);
|
|
return () => listeners.delete(listener);
|
|
}
|
|
|
|
function getSnapshot(): boolean {
|
|
return immersiveActive;
|
|
}
|
|
|
|
export function useImmersiveActive(): boolean {
|
|
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
}
|