mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-09-24 15:49:09 +00:00
c239f30653
Decouple high-frequency UI state from TerminalLayer's memo boundary so npm run dev is less dominated by full-layer reconciliation. - Publish shell history through shellHistoryStore; History side panel subscribes directly instead of receiving shellHistory props. - Track terminal CWD in terminalCwdStore so OSC 7 updates do not setState TerminalLayerInner; TabBridge updates side-panel live snapshots only. - Move remote-history ownership into the History side-panel slot. - Treat sessions as equal for pane/layer memo when only dynamicTitle or codingCliProviderId changes (TopTabs still sees full session updates). - Stabilize AppView terminal handlers; thin AI vault catalog props when the AI panel is not visible; memo HostTreeView.
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import type { ShellHistoryEntry } from '../../domain/models';
|
|
|
|
type Listener = () => void;
|
|
|
|
/**
|
|
* External store for shell history so History side-panel / snippets consumers
|
|
* can subscribe without forcing TerminalLayer re-renders on every command.
|
|
*/
|
|
class ShellHistoryStore {
|
|
private snapshot: readonly ShellHistoryEntry[] = [];
|
|
private listeners = new Set<Listener>();
|
|
|
|
getSnapshot = (): readonly ShellHistoryEntry[] => this.snapshot;
|
|
|
|
subscribe = (listener: Listener): (() => void) => {
|
|
this.listeners.add(listener);
|
|
return () => {
|
|
this.listeners.delete(listener);
|
|
};
|
|
};
|
|
|
|
setSnapshot(next: readonly ShellHistoryEntry[]): void {
|
|
if (this.snapshot === next) return;
|
|
this.snapshot = next;
|
|
for (const listener of this.listeners) {
|
|
listener();
|
|
}
|
|
}
|
|
}
|
|
|
|
export const shellHistoryStore = new ShellHistoryStore();
|
|
|
|
export function publishShellHistorySnapshot(entries: readonly ShellHistoryEntry[]): void {
|
|
shellHistoryStore.setSnapshot(entries);
|
|
}
|
|
|
|
export function getShellHistorySnapshot(): readonly ShellHistoryEntry[] {
|
|
return shellHistoryStore.getSnapshot();
|
|
}
|
|
|
|
export function subscribeShellHistory(listener: Listener): () => void {
|
|
return shellHistoryStore.subscribe(listener);
|
|
}
|