Review fixes: name a slow shell, stop orphaned dashboards, bound quit stops, serialize pty tests

AI Assisted
This commit is contained in:
Seth committed 2026-12-05 14:37:34 -08:00
1 parent 0bd721fc27
commit f640f890f4
10 files changed
+412 -75

No files matched your search

+39
View File
@@ -1754,3 +1754,42 @@ test("every skill but the dashboard picks its interface through the interface co
assert.doesNotMatch(text, /ask \*\*web console\*\*/, `${f} no longer asks up front`);
}
});
// A page that goes away without its `/bye` (the app crashed or was force quit)
// still shortens the server's deadline, once no page is left: the closed stream
// alone counts as a closed tab. Driven through the router with a stand-in
// request, since the deadline it moves is two minutes long.
test("the last event stream closing counts as a closed tab, even with no /bye", async () => {
const { EventEmitter } = await import("node:events");
const { handle } = await import("../src/web-console/routes.mjs");
const clients = new Set();
let closedTabs = 0;
const ctx = {
port: () => 4321,
token: "",
touch() {},
clients,
browsers: 0,
readState: () => null,
haveKey: () => "",
stateFrame: (s) => s,
// As server.mjs's closedTab(): it acts only once no page is left.
closedTab: () => {
if (clients.size === 0) closedTabs++;
},
};
const page = () => {
const req = Object.assign(new EventEmitter(), { method: "GET", url: "/events", headers: { host: "127.0.0.1:4321" } });
const res = { writeHead() {}, flushHeaders() {}, setTimeout() {}, write() {} };
handle(req, res, ctx);
return req;
};
const first = page();
const second = page();
assert.equal(ctx.browsers, 2);
first.emit("close");
assert.equal(closedTabs, 0, "another page is still there");
second.emit("close");
assert.equal(ctx.browsers, 0);
assert.equal(closedTabs, 1, "the last page gone: the deadline moves as for a /bye");
});