mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-23 16:42:19 +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>
31 lines
1002 B
TypeScript
31 lines
1002 B
TypeScript
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
|
export const TAB_ENTER_ANIMATION_MS = 220;
|
|
|
|
export function useTopTabLifecycleAnimations(orderedTabs: string[]) {
|
|
const prevTabIdsRef = useRef<Set<string>>(new Set());
|
|
const [enteringTabIds, setEnteringTabIds] = useState<ReadonlySet<string>>(() => new Set());
|
|
|
|
useEffect(() => {
|
|
const current = new Set(orderedTabs);
|
|
const prev = prevTabIdsRef.current;
|
|
const added = orderedTabs.filter((tabId) => !prev.has(tabId));
|
|
prevTabIdsRef.current = current;
|
|
|
|
if (added.length === 0) return;
|
|
|
|
setEnteringTabIds(new Set(added));
|
|
const timer = window.setTimeout(() => {
|
|
setEnteringTabIds(new Set());
|
|
}, TAB_ENTER_ANIMATION_MS);
|
|
return () => window.clearTimeout(timer);
|
|
}, [orderedTabs]);
|
|
|
|
const getTabAnimationClass = useCallback((tabId: string) => {
|
|
if (enteringTabIds.has(tabId)) return 'top-tab-enter';
|
|
return undefined;
|
|
}, [enteringTabIds]);
|
|
|
|
return { getTabAnimationClass };
|
|
};
|