Files
Netcatty/application/state/vaultHostTreeActionsStore.ts
T
陈大猫andCursor 36e5779d94 perf(terminal): reduce terminal tab-switch and layout jank (#1321)
* 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>
2026-06-09 03:35:03 +08:00

47 lines
1.4 KiB
TypeScript

import { useSyncExternalStore } from 'react';
import type { Host } from '../../types';
export interface VaultHostTreeActions {
onDeleteHost: (host: Host) => void;
onCopyCredentials: (host: Host) => void;
onNewGroup: (parentPath?: string) => void;
onRenameGroup: (groupPath: string) => void;
onDeleteGroup: (groupPath: string) => void;
commitInlineGroupRename: (name: string) => void;
cancelInlineGroupEdit: () => void;
moveHostToGroup: (hostId: string, groupPath: string | null) => void;
moveGroup: (sourcePath: string, targetParent: string | null) => void;
managedGroupPaths?: Set<string>;
onUnmanageGroup?: (groupPath: string) => void;
}
type Listener = () => void;
class VaultHostTreeActionsStore {
private actions: VaultHostTreeActions | null = null;
private listeners = new Set<Listener>();
getActions = () => this.actions;
setActions = (actions: VaultHostTreeActions | null) => {
this.actions = actions;
this.listeners.forEach((listener) => listener());
};
subscribe = (listener: Listener) => {
this.listeners.add(listener);
return () => this.listeners.delete(listener);
};
}
export const vaultHostTreeActionsStore = new VaultHostTreeActionsStore();
export const useVaultHostTreeActions = () => {
return useSyncExternalStore(
vaultHostTreeActionsStore.subscribe,
vaultHostTreeActionsStore.getActions,
vaultHostTreeActionsStore.getActions,
);
};