chat: deliver attachments and cancel runs immediately
Carry browser files as base64 prompt attachments, write them to private temporary files and pass file:// references to OpenCode, and map the user turn's top-level files back into history. Replay a running step on subscribe, forward only a caller-supplied msg_ id, and persist cancel on the run and live step before interrupting the runner.
This commit is contained in:
@@ -367,6 +367,17 @@ test("chatPrompt includes files when present and reads chat_queued", async () =>
|
||||
assert.equal(queued, true);
|
||||
});
|
||||
|
||||
test("chatPrompt sends browser attachment bytes with their name and mime", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "chat_prompt" });
|
||||
await repo.chatPrompt("s1", "see attached", [], "op-3", [
|
||||
{ name: "note.txt", mime: "text/plain", data: "aGVsbG8=" },
|
||||
]);
|
||||
assert.deepEqual(lastFrame(ws).chat_prompt.attachments, [
|
||||
{ name: "note.txt", mime: "text/plain", data: "aGVsbG8=" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("chatPrompt refuses a blank session or blank text without sending", async () => {
|
||||
const { repo, ws } = connected();
|
||||
await assert.rejects(() => repo.chatPrompt(" ", "hi", [], "op"), ProtocolError);
|
||||
|
||||
Reference in New Issue
Block a user