Pending approvals in the composer's place
This commit is contained in:
1 parent
49b04f9012
commit
3a7c183e1c
5 files changed
+107
-34
No files matched your search
@@ -164,6 +164,19 @@ describe("a finished turn", () => {
|
||||
});
|
||||
|
||||
describe("approvals", () => {
|
||||
test("the request shows in the composer's place, with its buttons, and not in the timeline", async () => {
|
||||
const app = await open({ session: fakeSession({ projection: withApproval() }) });
|
||||
const frame = app.frame();
|
||||
expect(frame).toContain("Command approval");
|
||||
expect(frame).toContain("Deletes dist/ and rebuilds it.");
|
||||
// Only the composer block names the command; its timeline row is hidden.
|
||||
expect(frame.split("rm -rf dist && bun run build")).toHaveLength(2);
|
||||
expect(frame).not.toContain("Press i to type");
|
||||
const approve = app.find("Approve");
|
||||
await app.click(approve.x, approve.y);
|
||||
expect(app.calls("respond").map((call) => call.args[2])).toEqual(["accept"]);
|
||||
});
|
||||
|
||||
test("y, Y and n answer the request", async () => {
|
||||
const app = await open({ session: fakeSession({ projection: withApproval() }) });
|
||||
expect(app.hints()).toStartWith("y approve · Y always · n decline · j/k threads");
|
||||
|
||||
@@ -9,11 +9,34 @@ const after = (seconds: number) => DateTime.makeUnsafe(DateTime.toEpochMillis(at
|
||||
|
||||
/** The thread with a command waiting for approval. */
|
||||
export function withApproval(supportsFeedback = false): OrchestrationV2ThreadProjection {
|
||||
const item = {
|
||||
id: "item-approval",
|
||||
threadId: v2Projection.thread.id,
|
||||
runId: null,
|
||||
nodeId: null,
|
||||
providerThreadId: null,
|
||||
providerTurnId: null,
|
||||
nativeItemRef: null,
|
||||
parentItemId: null,
|
||||
ordinal: 0,
|
||||
status: "waiting",
|
||||
title: null,
|
||||
startedAt: at,
|
||||
completedAt: null,
|
||||
updatedAt: at,
|
||||
type: "approval_request",
|
||||
requestId: "approval-1",
|
||||
requestKind: "command",
|
||||
prompt: "rm -rf dist && bun run build",
|
||||
reason: "Deletes dist/ and rebuilds it.",
|
||||
};
|
||||
return {
|
||||
...v2Projection,
|
||||
runtimeRequests: [
|
||||
{ id: "approval-1", nodeId: "node-1", providerTurnId: null, nativeRequestRef: null, kind: "command", status: "pending", responseCapability: { type: "live", providerSessionId: "session-1", ...(supportsFeedback ? { supportsFeedback } : {}) }, createdAt: at, resolvedAt: null },
|
||||
],
|
||||
turnItems: [item],
|
||||
visibleTurnItems: [{ position: 0, visibility: "local", sourceThreadId: v2Projection.thread.id, sourceItemId: item.id, item }],
|
||||
} as unknown as OrchestrationV2ThreadProjection;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user