Files
Netcatty/application/state/terminalCwdStore.test.ts
T
bincxz c239f30653 perf(terminal): cut TerminalLayer re-renders from history, cwd, and title churn
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.
2026-07-30 16:10:08 +08:00

29 lines
972 B
TypeScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { terminalCwdStore } from './terminalCwdStore.ts';
test('terminalCwdStore bumps version only when cwd changes', () => {
const versions: number[] = [];
const unsubscribe = terminalCwdStore.subscribe(() => {
versions.push(terminalCwdStore.getVersion());
});
const baseVersion = terminalCwdStore.getVersion();
assert.equal(terminalCwdStore.setCwd('s1', '/tmp'), true);
assert.equal(terminalCwdStore.getCwd('s1'), '/tmp');
assert.equal(terminalCwdStore.getVersion(), baseVersion + 1);
assert.equal(terminalCwdStore.setCwd('s1', '/tmp'), false);
assert.equal(terminalCwdStore.getVersion(), baseVersion + 1);
assert.equal(terminalCwdStore.setCwd('s1', '/var'), true);
assert.equal(terminalCwdStore.getCwd('s1'), '/var');
terminalCwdStore.prune(new Set());
assert.equal(terminalCwdStore.getCwd('s1'), null);
unsubscribe();
assert.ok(versions.length >= 2);
});