mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-09-24 15:49:09 +00:00
1a8f5be432
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.
24 lines
1.1 KiB
TypeScript
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['"]/);
|
|
});
|