Files
Netcatty/components/terminalLayer/TerminalLayerWorkspaceSection.liveStore.test.ts
T
bincxz 1a8f5be432 fix(app): prevent stale workspace chrome and restore patch corruption
Stop TerminalLayerWorkspaceSection from falling back to memoized ctx when
sidePanelLiveStore clears activeWorkspace (workspace → solo tab). Refuse
session-restore active-tab patches without a trusted in-memory full payload
so a connect+activate race cannot write stale disk sessions under a new
activeTabId; force full rebuild from live state instead.
2026-07-30 22:48:16 +08:00

24 lines
1.1 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
const source = readFileSync(
new URL("./TerminalLayerWorkspaceSection.tsx", import.meta.url),
"utf8",
);
test("workspace section uses live store only for activeWorkspace (no stale ctx fallback)", () => {
// After view memo omits activeWorkspace from equality, ctx can lag behind
// live when switching workspace → solo session (live clears to undefined).
// `live.x ?? ctx.x` would keep the old workspace for compose bar / resizers.
assert.match(source, /sidePanelLiveStore\.getSnapshot/);
assert.match(source, /const activeWorkspace = live\.activeWorkspace;/);
assert.match(source, /const focusedSessionId = live\.focusedSessionId;/);
assert.doesNotMatch(source, /live\.activeWorkspace\s*\?\?/);
assert.doesNotMatch(source, /live\.focusedSessionId\s*\?\?/);
assert.doesNotMatch(source, /ctx\.activeWorkspace/);
assert.doesNotMatch(source, /ctx\.focusedSessionId/);
// Focus mode must follow live workspace, not stale ctx.isFocusMode.
assert.match(source, /activeWorkspace\?\.viewMode === ['"]focus['"]/);
});