mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +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>
41 lines
855 B
TypeScript
41 lines
855 B
TypeScript
import { useSyncExternalStore } from 'react';
|
|
|
|
type Listener = () => void;
|
|
|
|
let suppressDepth = 0;
|
|
const listeners = new Set<Listener>();
|
|
|
|
function emit() {
|
|
listeners.forEach((listener) => listener());
|
|
}
|
|
|
|
export const terminalLayoutSuppressStore = {
|
|
getActive: () => suppressDepth > 0,
|
|
|
|
subscribe: (listener: Listener) => {
|
|
listeners.add(listener);
|
|
return () => listeners.delete(listener);
|
|
},
|
|
|
|
begin: () => {
|
|
suppressDepth += 1;
|
|
emit();
|
|
},
|
|
|
|
end: () => {
|
|
const wasActive = suppressDepth > 0;
|
|
suppressDepth = Math.max(0, suppressDepth - 1);
|
|
if (wasActive) {
|
|
emit();
|
|
}
|
|
},
|
|
};
|
|
|
|
export function useTerminalLayoutSuppressActive(): boolean {
|
|
return useSyncExternalStore(
|
|
terminalLayoutSuppressStore.subscribe,
|
|
terminalLayoutSuppressStore.getActive,
|
|
terminalLayoutSuppressStore.getActive,
|
|
);
|
|
}
|