web: approval cards for chat permission requests (C10)

Completes the item the pipeline could not land: the C10 diff its own
implementer and probe assertions already verified is committed as-is.
The resource block is a padding-free six-line clamp inside a padded frame
(the app's maxLines = 6 + ellipsis) and the primary control is filled.
This commit is contained in:
2026-10-19 11:08:53 +01:00
parent 27a1605127
commit 5eb13968e3
9 changed files with 1148 additions and 15 deletions
+45
View File
@@ -396,3 +396,48 @@ test("subscribeChat surfaces a server refusal as a ProtocolError", async () => {
message: "unknown command: chat_subscribe",
});
});
// ---- The approval reply (C10) ---------------------------------------------
test("chatReply sends exactly {type:'chat_reply', chat_reply:{session_id,request_id,decision,client}}", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "chat_reply" });
await repo.chatReply("s1", "req-1", "once");
assert.deepEqual(lastFrame(ws), {
type: "chat_reply",
chat_reply: { session_id: "s1", request_id: "req-1", decision: "once", client: "Web" },
});
});
test("chatReply includes message only when non-blank", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "chat_reply" });
await repo.chatReply("s1", "req-1", "always", { message: " looks fine " });
assert.deepEqual(lastFrame(ws), {
type: "chat_reply",
chat_reply: {
session_id: "s1",
request_id: "req-1",
decision: "always",
client: "Web",
message: "looks fine",
},
});
await repo.chatReply("s1", "req-1", "reject", { message: " " });
assert.deepEqual(lastFrame(ws), {
type: "chat_reply",
chat_reply: { session_id: "s1", request_id: "req-1", decision: "reject", client: "Web" },
});
});
test("chatReply refuses blank ids or a decision outside once/always/reject without sending", async () => {
const { repo, ws } = connected();
await assert.rejects(() => repo.chatReply(" ", "req-1", "once"), ProtocolError);
await assert.rejects(() => repo.chatReply("s1", " ", "once"), ProtocolError);
await assert.rejects(() => repo.chatReply("s1", "req-1", "maybe"), ProtocolError);
await assert.rejects(() => repo.chatReply("s1", "req-1", ""), ProtocolError);
assert.equal(ws.sent.length, 0);
});