The setup terminal created its PTY at a fixed 24x80 while the browser measured its own box and threw the measurement away, so a full-screen CLI login drew into a corner of a much larger xterm. OpenRequest now carries a ConsoleSize with the target frame; the route reads cols/rows from the WebSocket URL, falling back to 24x80 when they are absent or out of range, and the daemon creates the PTY at that geometry. The component sends the size it measured before connecting. Live resize is the follow-on: it needs a control channel on the WebSocket, which today is a raw byte copy.
60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
bindingStatus,
|
|
setupTerminalURL,
|
|
EXPIRING_WINDOW_MS,
|
|
} from "../src/harness/harness.ts";
|
|
|
|
import type { HarnessBinding } from "../src/harness/harness.ts";
|
|
|
|
const now = Date.parse("2026-10-02T12:00:00Z");
|
|
|
|
function binding(overrides: Partial<HarnessBinding> = {}): HarnessBinding {
|
|
return { service: "github", captured: false, ...overrides };
|
|
}
|
|
|
|
test("credential status distinguishes uncaptured, ready, expiring and expired bindings", () => {
|
|
const cases: Array<[Partial<HarnessBinding>, string]> = [
|
|
[{}, "unconfigured"],
|
|
[{ captured: true, expires_at: "2026-10-02T13:00:00Z" }, "ready"],
|
|
[{ captured: true, expires_at: new Date(now + EXPIRING_WINDOW_MS - 1000).toISOString() }, "expiring"],
|
|
[{ captured: true, expires_at: "2026-10-02T11:00:00Z" }, "expired"],
|
|
[{ captured: true }, "ready"],
|
|
[{ captured: true, expires_at: "not-a-date" }, "ready"],
|
|
];
|
|
for (const [overrides, expected] of cases) {
|
|
assert.equal(bindingStatus(binding(overrides), now), expected, JSON.stringify(overrides));
|
|
}
|
|
});
|
|
|
|
test("setup terminals preserve secure transport, encode the profile and carry the size", () => {
|
|
const cases: Array<[string, Pick<Location, "protocol" | "host">, number, number, string]> = [
|
|
[
|
|
"claude-kit",
|
|
{ protocol: "http:", host: "127.0.0.1:8484" },
|
|
80,
|
|
24,
|
|
"ws://127.0.0.1:8484/api/harness/terminal?profile=claude-kit&cols=80&rows=24",
|
|
],
|
|
[
|
|
"claude kit",
|
|
{ protocol: "https:", host: "archie.example" },
|
|
80,
|
|
24,
|
|
"wss://archie.example/api/harness/terminal?profile=claude+kit&cols=80&rows=24",
|
|
],
|
|
[
|
|
"claude-kit",
|
|
{ protocol: "https:", host: "archie.example" },
|
|
120,
|
|
30,
|
|
"wss://archie.example/api/harness/terminal?profile=claude-kit&cols=120&rows=30",
|
|
],
|
|
];
|
|
for (const [profile, location, cols, rows, expected] of cases) {
|
|
assert.equal(setupTerminalURL(profile, location, cols, rows), expected, profile);
|
|
}
|
|
});
|