web: create a chat through the directory picker (C2)

This commit is contained in:
2026-10-19 14:25:42 +01:00
parent 2fe63012f9
commit a7872c3f31
9 changed files with 841 additions and 36 deletions
+35
View File
@@ -345,6 +345,41 @@ test("chatInterrupt sends the session as chat_query (not a chat_interrupt body)"
assert.deepEqual(lastFrame(ws), { type: "chat_interrupt", chat_query: { session_id: "s1" } });
});
test("chatDirectories sends exactly {type:'chat_directories'} and returns the list", async () => {
const { repo, ws } = connected();
const directories = ["/home/operator", "/repo/one", "/repo/two"];
ws.reply = (frame) => ({ id: frame.id, type: "chat_directories", chat_directories: directories });
assert.deepEqual(await repo.chatDirectories(), directories);
assert.deepEqual(lastFrame(ws), { type: "chat_directories" });
});
test("chatDirectories returns [] when the reply carries no directories", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "chat_directories" });
assert.deepEqual(await repo.chatDirectories(), []);
});
test("chatDirectories surfaces a server refusal as a ProtocolError", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "error", error: "unknown command: chat_directories" });
await assert.rejects(() => repo.chatDirectories(), {
name: "ProtocolError",
message: "unknown command: chat_directories",
});
});
test("chatCreate sends home as ~ and carries the exact title/directory/operation_id body", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "chat_create", chat_session: { id: "ses_new" } });
await repo.chatCreate("New chat", "~", "op-4");
assert.deepEqual(lastFrame(ws), {
type: "chat_create",
chat_create: { title: "New chat", directory: "~", operation_id: "op-4" },
});
});
test("chatCreate sends title/directory/operation_id and returns chat_session", async () => {
const { repo, ws } = connected();
const created = { id: "ses_new", title: "New chat" };