Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
71 lines
3.5 KiB
TypeScript
71 lines
3.5 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import test from "node:test";
|
|
|
|
const terminalSource = readFileSync(new URL("../Terminal.tsx", import.meta.url), "utf8");
|
|
const effectsSource = readFileSync(new URL("./useTerminalEffects.ts", import.meta.url), "utf8");
|
|
const runtimeSource = readFileSync(new URL("./runtime/createXTermRuntime.ts", import.meta.url), "utf8");
|
|
const layerSupportSource = readFileSync(new URL("../terminalLayer/TerminalLayerSupport.tsx", import.meta.url), "utf8");
|
|
const layerBridgeSource = readFileSync(new URL("../terminalLayer/TerminalLayerTabBridge.tsx", import.meta.url), "utf8");
|
|
const layerViewSource = readFileSync(new URL("../terminalLayer/TerminalLayerView.tsx", import.meta.url), "utf8");
|
|
|
|
test("local terminals stay out of hibernate and hidden-renderer paths", () => {
|
|
assert.match(
|
|
terminalSource,
|
|
/const effectiveTerminalProtocol = resolveEffectiveTerminalProtocol\(host\);[\s\S]*const hibernateEnabled =\s+resolveTerminalHibernateEnabledForProtocol\([\s\S]*effectiveTerminalProtocol/,
|
|
);
|
|
assert.match(
|
|
terminalSource,
|
|
/kittyKeyboardProtocolEnabledForSessionRef = useRef\([\s\S]*const kittyKeyboardProtocolEnabledForSession =[\s\S]*kittyKeyboardProtocolEnabledForSessionRef\.current/,
|
|
);
|
|
assert.match(terminalSource, /!kittyKeyboardProtocolEnabledForSession &&\s+!isBroadcastEnabled/);
|
|
assert.match(terminalSource, /hibernateEnabledRef\.current = hibernateEnabled/);
|
|
assert.match(terminalSource, /hibernateEnabled: hibernateEnabled/);
|
|
assert.match(
|
|
effectsSource,
|
|
/const effectiveTerminalProtocol = resolveEffectiveTerminalProtocol\(host\);[\s\S]*resolveTerminalHibernateEnabledForProtocol\([\s\S]*effectiveTerminalProtocol[\s\S]*&& !kittyKeyboardProtocolEnabledForSession/,
|
|
);
|
|
assert.match(layerSupportSource, /resolveTerminalHibernateEnabledForProtocol\(terminalSettings, host\.protocol\)/);
|
|
assert.match(layerBridgeSource, /const localWorkspaceIds = useMemo\(\(\) => new Set\(/);
|
|
assert.match(layerBridgeSource, /!hibernateHiddenTabs \|\| localWorkspaceIds\.has\(workspace\.id\)/);
|
|
assert.match(layerViewSource, /ctx\.hibernateHiddenTabs/);
|
|
});
|
|
|
|
test("reconnect clears keyboard pairing before resetting protocol state", () => {
|
|
assert.match(
|
|
terminalSource,
|
|
/startNewSession = \(\) => \{[\s\S]*resetKittyConnectionInputState\(\);[\s\S]*resetKittyKeyboardModeStateForSession/,
|
|
);
|
|
assert.match(
|
|
runtimeSource,
|
|
/clearKittyKeyboardBroadcastPairingState\([\s\S]*broadcastEncodedKeys,[\s\S]*broadcastLegacySuppressedKeys/,
|
|
);
|
|
assert.match(
|
|
runtimeSource,
|
|
/resetKittyConnectionInputState: clearKittyConnectionInputState/,
|
|
);
|
|
assert.match(
|
|
runtimeSource,
|
|
/kittyKeyboardLockState\.capsLock = event\.getModifierState\("CapsLock"\);[\s\S]*kittyKeyboardLockState\.numLock = event\.getModifierState\("NumLock"\);/,
|
|
);
|
|
assert.match(
|
|
runtimeSource,
|
|
/flushKittyKeyboardBroadcastReleases\([\s\S]*broadcastForwardedKeys,[\s\S]*broadcastKittyInput,[\s\S]*kittyKeyboardLockState/,
|
|
);
|
|
assert.doesNotMatch(
|
|
runtimeSource.match(/const clearKittyConnectionInputState = \(\) => \{[\s\S]*?\n {2}\};/)?.[0] ?? "",
|
|
/broadcastForwardedKeys\.clear\(\)/,
|
|
);
|
|
});
|
|
|
|
test("session cleanup flushes owed Kitty releases before dropping the backend id", () => {
|
|
assert.match(
|
|
terminalSource,
|
|
/const closingSessionId = sessionRef\.current;\s+xtermRuntimeRef\.current\?\.flushKittyKeyboardReleases\(\);\s+sessionRef\.current = null;/,
|
|
);
|
|
assert.match(
|
|
runtimeSource,
|
|
/flushKittyKeyboardReleases: clearKittyTransientInputState/,
|
|
);
|
|
});
|