Files
openclaw/src/node-host/invoke-payload.test.ts
Peter Steinberger 89f53f1c38 fix(terminal): keystrokes typed while a terminal opens are lost; node PTY relay lifecycle races (#107214)
* fix(terminal): harden node PTY relay and terminal session lifecycle

Pin node relay invokes to the authorized node connection (ROUTE_CHANGED
guard), stop node-side input writes to settled/dead PTYs, finalize
sessions on resize failure like write failure, keep surrogate pairs
intact across scrollback and relay prelude truncation, bound the relay
pre-registration output buffer, and buffer Control UI keystrokes typed
while terminal.open/attach is in flight so slow node-relay opens no
longer drop input. Correct the terminal.data seq doc to its real
contract and pin seq monotonicity, seq-gap bounds, input coercion, and
runner event routing with new tests.

* refactor(terminal): extract startup input buffer and fix CI findings

Move Control UI startup input buffering into terminal-startup-input.ts
(LOC budget), drop a stale session-manager comment, remove a map
spread, and fix test typings for event frames and typed mock access.
2026-07-14 01:22:22 -07:00

34 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { coerceNodeInvokeInputPayload } from "./invoke-payload.js";
describe("coerceNodeInvokeInputPayload", () => {
it("accepts a bounded well-formed input payload", () => {
expect(
coerceNodeInvokeInputPayload({
id: "invoke-1",
nodeId: "node-1",
seq: 0,
payloadJSON: JSON.stringify({ kind: "data", data: "keys" }),
}),
).toEqual({
invokeId: "invoke-1",
nodeId: "node-1",
seq: 0,
payloadJSON: JSON.stringify({ kind: "data", data: "keys" }),
});
});
it.each([
[
"oversized payloadJSON",
{ id: "i", nodeId: "n", seq: 0, payloadJSON: "x".repeat(16 * 1024 + 1) },
],
["negative seq", { id: "i", nodeId: "n", seq: -1, payloadJSON: "{}" }],
["fractional seq", { id: "i", nodeId: "n", seq: 0.5, payloadJSON: "{}" }],
["array frame", []],
["string frame", "input"],
])("rejects %s", (_name, payload) => {
expect(coerceNodeInvokeInputPayload(payload)).toBeNull();
});
});