mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
36e5779d94
* 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>
31 lines
969 B
TypeScript
31 lines
969 B
TypeScript
import { useEffect, useRef } from "react";
|
|
import { netcattyBridge } from "../../../infrastructure/services/netcattyBridge";
|
|
import type { FileWatchErrorEvent, FileWatchSyncedEvent, SftpStateOptions } from "./types";
|
|
|
|
export const useSftpFileWatch = (options?: SftpStateOptions) => {
|
|
const optionsRef = useRef(options);
|
|
optionsRef.current = options;
|
|
|
|
useEffect(() => {
|
|
const bridge = netcattyBridge.get();
|
|
if (!bridge?.onFileWatchSynced || !bridge?.onFileWatchError) return;
|
|
|
|
const unsubscribeSynced = bridge.onFileWatchSynced((payload: FileWatchSyncedEvent) => {
|
|
optionsRef.current?.onFileWatchSynced?.(payload);
|
|
});
|
|
|
|
const unsubscribeError = bridge.onFileWatchError((payload: FileWatchErrorEvent) => {
|
|
optionsRef.current?.onFileWatchError?.(payload);
|
|
});
|
|
|
|
return () => {
|
|
try {
|
|
unsubscribeSynced?.();
|
|
unsubscribeError?.();
|
|
} catch {
|
|
// ignore cleanup errors
|
|
}
|
|
};
|
|
}, []);
|
|
};
|