* 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>
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { useSyncExternalStore } from 'react';
|
|
|
|
export type HostTreeInlineGroupEdit = {
|
|
groupPath: string;
|
|
initialName: string;
|
|
isNew: boolean;
|
|
shouldScrollIntoView?: boolean;
|
|
};
|
|
|
|
type Listener = () => void;
|
|
|
|
class HostTreeInlineGroupEditStore {
|
|
private edit: HostTreeInlineGroupEdit | null = null;
|
|
private listeners = new Set<Listener>();
|
|
|
|
getEdit = () => this.edit;
|
|
|
|
startEdit = (edit: HostTreeInlineGroupEdit) => {
|
|
this.edit = {
|
|
...edit,
|
|
shouldScrollIntoView: edit.isNew ? true : edit.shouldScrollIntoView,
|
|
};
|
|
this.listeners.forEach((listener) => listener());
|
|
};
|
|
|
|
markScrollHandled = () => {
|
|
if (!this.edit?.shouldScrollIntoView) return;
|
|
this.edit = { ...this.edit, shouldScrollIntoView: false };
|
|
this.listeners.forEach((listener) => listener());
|
|
};
|
|
|
|
clear = () => {
|
|
if (!this.edit) return;
|
|
this.edit = null;
|
|
this.listeners.forEach((listener) => listener());
|
|
};
|
|
|
|
subscribe = (listener: Listener) => {
|
|
this.listeners.add(listener);
|
|
return () => this.listeners.delete(listener);
|
|
};
|
|
}
|
|
|
|
export const hostTreeInlineGroupEditStore = new HostTreeInlineGroupEditStore();
|
|
|
|
export const useHostTreeInlineGroupEdit = () => {
|
|
return useSyncExternalStore(
|
|
hostTreeInlineGroupEditStore.subscribe,
|
|
hostTreeInlineGroupEditStore.getEdit,
|
|
hostTreeInlineGroupEditStore.getEdit,
|
|
);
|
|
};
|