feat: unified attachment pipeline with clipboard image and file picker
Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
1 parent
d63af25fc1
commit
761a80004a
7 files changed
+597
-57
No files matched your search
@@ -191,3 +191,24 @@ test("restart turns a countdown into held", () => {
|
||||
const s = reduce(mk(it("c", "countdown", { left: 2 })), { type: "restart", agent: "a" });
|
||||
assert.deepEqual(states(s), ["held"]);
|
||||
});
|
||||
|
||||
test("restore_draft turns an unfinished attachment into an error", () => {
|
||||
const att = (id, state) => ({ id, name: id, path: "p", bytes: 1, kind: "file", state });
|
||||
const draft = { text: "t", caret: 1, attachments: [att("a", "adding"), att("b", "ready")], identity: { created_ms: 5, app: null }, savedAt: 1 };
|
||||
const s = reduce(createState(), { type: "restore_draft", agent: "t2", draft, identity: { created_ms: 5, app: null } });
|
||||
assert.equal(s.attachments.t2[0].state, "error");
|
||||
assert.ok(s.attachments.t2[0].error.length > 0);
|
||||
assert.equal(s.attachments.t2[1].state, "ready");
|
||||
});
|
||||
|
||||
test("attachment states: adding -> ready with the remote path, or error; retry goes back to adding", () => {
|
||||
let s = reduce(createState(), { type: "attach", agent: "a", file: { id: "1", name: "f", path: "p", bytes: 1, state: "adding" } });
|
||||
assert.equal(s.attachments.a[0].state, "adding");
|
||||
s = reduce(s, { type: "attachment_update", agent: "a", id: "1", patch: { state: "ready", remotePath: "/r/f" } });
|
||||
assert.deepEqual([s.attachments.a[0].state, s.attachments.a[0].remotePath], ["ready", "/r/f"]);
|
||||
s = reduce(s, { type: "attachment_update", agent: "a", id: "1", patch: { state: "error", error: "x" } });
|
||||
assert.equal(s.attachments.a[0].error, "x");
|
||||
s = reduce(s, { type: "attachment_update", agent: "a", id: "1", patch: { state: "adding" } });
|
||||
assert.equal(s.attachments.a[0].error, undefined);
|
||||
assert.equal(reduce(s, { type: "attachment_update", agent: "a", id: "zz", patch: { state: "ready" } }), s);
|
||||
});
|
||||
Reference in new issue
Block a user