* Extract client SDK package * Polish SDK client identity defaults * Build client before dependent CI jobs * Restore daemon client server export * Extract protocol and client SDK packages * Fix provider override schema validation * Fix app test daemon client imports * Simplify workspace build targets * Fix CLI test server build bootstrap * Run SDK package tests in CI * Fix rebase package split drift * Restore lockfile registry metadata * Update SDK config test for prompt default * Move terminal stream router test to client package * Fix rebase drift for protocol imports * Fix SDK agent capability fixture * Restore legacy server client exports * Fix server export compatibility test * Advertise custom mode icon client capability * Remove server daemon-client exports * Format rebased mode control import * Fix rebase drift for protocol imports Files added by upstream PRs (#893, #1147, #1154) referenced the pre-split shared/ paths that this branch moves into @getpaseo/protocol. Redirect those imports to the protocol package so typecheck stays green after the rebase.
76 lines
2.4 KiB
TypeScript
76 lines
2.4 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
|
|
import {
|
|
TerminalStreamOpcode,
|
|
decodeTerminalStreamFrame,
|
|
} from "@getpaseo/protocol/binary-frames/index";
|
|
import type { TerminalCell, TerminalState } from "@getpaseo/protocol/messages";
|
|
import {
|
|
encodeTerminalRestoreFrame,
|
|
resolveRestoreAfterOutputOverflow,
|
|
resolveTerminalRestoreSnapshotOptions,
|
|
resolveTerminalSubscriptionSnapshotMode,
|
|
} from "./terminal-restore.js";
|
|
|
|
function terminalRow(text: string, cols = 80): TerminalCell[] {
|
|
return Array.from({ length: cols }, (_, index) => ({
|
|
char: text[index] ?? " ",
|
|
}));
|
|
}
|
|
|
|
function terminalState(text: string): TerminalState {
|
|
return {
|
|
rows: 1,
|
|
cols: 80,
|
|
grid: [terminalRow(text)],
|
|
scrollback: [],
|
|
cursor: { row: 0, col: text.length },
|
|
};
|
|
}
|
|
|
|
describe("terminal restore policy", () => {
|
|
test("uses ready snapshots only for restore-aware subscriptions", () => {
|
|
expect(resolveTerminalSubscriptionSnapshotMode(undefined)).toBe("state");
|
|
expect(resolveTerminalSubscriptionSnapshotMode({ mode: "live" })).toBe("ready");
|
|
});
|
|
|
|
test("resolves bounded restore snapshot options", () => {
|
|
expect(resolveTerminalRestoreSnapshotOptions({ mode: "live" })).toBeNull();
|
|
expect(resolveTerminalRestoreSnapshotOptions({ mode: "full-snapshot" })).toBeUndefined();
|
|
expect(resolveTerminalRestoreSnapshotOptions({ mode: "visible-snapshot" })).toEqual({
|
|
scrollbackLines: 200,
|
|
});
|
|
expect(
|
|
resolveTerminalRestoreSnapshotOptions({
|
|
mode: "visible-snapshot",
|
|
scrollbackLines: 999,
|
|
}),
|
|
).toEqual({ scrollbackLines: 500 });
|
|
});
|
|
|
|
test("promotes live restore to visible restore after output overflow", () => {
|
|
expect(resolveRestoreAfterOutputOverflow({ mode: "live" })).toEqual({
|
|
mode: "visible-snapshot",
|
|
});
|
|
expect(resolveRestoreAfterOutputOverflow({ mode: "full-snapshot" })).toEqual({
|
|
mode: "full-snapshot",
|
|
});
|
|
});
|
|
|
|
test("encodes restore snapshots as restore frames", () => {
|
|
const frame = decodeTerminalStreamFrame(
|
|
encodeTerminalRestoreFrame({
|
|
slot: 4,
|
|
snapshot: {
|
|
state: terminalState("restored"),
|
|
revision: 1,
|
|
},
|
|
}),
|
|
);
|
|
|
|
expect(frame?.opcode).toBe(TerminalStreamOpcode.Restore);
|
|
expect(frame?.slot).toBe(4);
|
|
expect(new TextDecoder().decode(frame?.payload ?? new Uint8Array())).toContain("restored");
|
|
});
|
|
});
|