mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-24 17:31:14 +00:00
* 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.
34 lines
1.0 KiB
TypeScript
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();
|
|
});
|
|
});
|