Gateway: multi-select answers and a summary endpoint for the complication
This commit is contained in:
1 parent
69858d4719
commit
830bf4f139
5 files changed
+98
-7
No files matched your search
@@ -1,7 +1,8 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
|
||||
import type { BoundedThread, ThreadShell } from "../src/t3/types.ts";
|
||||
import { summarize, trimText } from "../src/views.ts";
|
||||
import type { T3Host } from "../src/t3/host.ts";
|
||||
import { buildSummary, summarize, trimText } from "../src/views.ts";
|
||||
|
||||
const thread = (overrides: Partial<ThreadShell> = {}): ThreadShell => ({
|
||||
id: "thread-1",
|
||||
@@ -98,7 +99,33 @@ describe("summarize", () => {
|
||||
thread({ pendingRuntimeRequest: { id: "q1", kind: "user_input", createdAt: "2026-11-01T09:00:00.000Z" } }),
|
||||
);
|
||||
expect(summary.request?.questions).toEqual([
|
||||
{ id: "db", header: "Database", question: "Which database?", options: [{ label: "SQLite", value: "SQLite" }], allowCustomAnswer: false },
|
||||
{ id: "db", header: "Database", question: "Which database?", options: [{ label: "SQLite", value: "SQLite" }], allowCustomAnswer: false, multiSelect: false },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildSummary", () => {
|
||||
const at = (minute: number) => `2026-11-01T09:${String(minute).padStart(2, "0")}:00.000Z`;
|
||||
const host = (label: string, status: string, threads: ThreadShell[]) =>
|
||||
({ id: label, label, status, threads: new Map(threads.map((t) => [t.id, t])) }) as unknown as T3Host;
|
||||
|
||||
it("counts waiting and working threads and names the one waiting longest", () => {
|
||||
const summary = buildSummary([
|
||||
host("Mac mini", "online", [
|
||||
thread({ id: "a", title: "Newer ask", pendingRuntimeRequest: { id: "r1", kind: "command", createdAt: at(30) } }),
|
||||
thread({ id: "b", status: "running" }),
|
||||
thread({ id: "c", status: "completed" }),
|
||||
thread({ id: "d", status: "running", lineage: { relationshipToParent: "subagent" } }),
|
||||
]),
|
||||
host("LittleMan", "offline", [
|
||||
thread({ id: "e", title: "Older ask", pendingRuntimeRequest: { id: "q1", kind: "user_input", createdAt: at(5) } }),
|
||||
]),
|
||||
]);
|
||||
expect(summary).toEqual({
|
||||
needsYou: 2,
|
||||
working: 1,
|
||||
next: { hostId: "LittleMan", threadId: "e", title: "Older ask", hostLabel: "LittleMan" },
|
||||
hostsOffline: 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user