test(app): account for terminal write completion before barriers

This commit is contained in:
Mohamed Boudra
2026-09-10 11:21:43 +02:00
parent 459e60f9cb
commit f5c90b2758
@@ -302,9 +302,10 @@ describe("terminal-emulator-runtime", () => {
{ kittyKeyboardFlags: 7, win32InputMode: false, bracketedPaste: false },
]);
// The plain write carries no onCommitted, so it registers no callback; writeCallbacks[0]
// is the barrier gate sentinel.
writeCallbacks[0]?.();
// Commit the plain write, then the sentinel that gates the snapshot.
writeCallbacks[0]();
expect(inputModeChanges).toHaveLength(1);
writeCallbacks[1]();
expect(inputModeChanges).toEqual([
{ kittyKeyboardFlags: 7, win32InputMode: false, bracketedPaste: false },
@@ -413,14 +414,15 @@ describe("terminal-emulator-runtime", () => {
runtime.write({ data: terminalOutput("output") });
runtime.restoreOutput({ data: terminalOutput("snapshot") });
// The plain write carries no onCommitted so it registers no callback; writeCallbacks[0]
// is the sentinel gate. suppressInput only flips once the gate resolves the barrier.
// The plain write commits first. Only the following sentinel opens the barrier.
expect(readSuppressInput()).toBe(false);
writeCallbacks[0]?.();
writeCallbacks[0]();
expect(readSuppressInput()).toBe(false);
writeCallbacks[1]();
expect(readSuppressInput()).toBe(true);
// writeCallbacks[1] is the barrier's own snapshot write; committing it restores input.
writeCallbacks[1]?.();
// Committing the barrier's snapshot write restores input.
writeCallbacks[2]();
expect(readSuppressInput()).toBe(false);
});