fix: always compare draft identity, gate auto-send until checked
Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
1 parent
e7deca480a
commit
57761326fd
7 files changed
+161
-34
No files matched your search
@@ -99,3 +99,43 @@ test("draft action keeps the caret", () => {
|
||||
const s = reduce(createState(), { type: "draft", agent: "a", text: "hi", caret: 1 });
|
||||
assert.equal(s.carets.a, 1);
|
||||
});
|
||||
|
||||
const q3 = () => ({ type: "restore", agent: "t2", items: [
|
||||
{ id: "1", text: "a", state: "queued", createdAt: 1 },
|
||||
{ id: "2", text: "b", state: "sending", createdAt: 2 },
|
||||
{ id: "3", text: "c", state: "uncertain", createdAt: 3 },
|
||||
] });
|
||||
|
||||
test("restore_draft keepCurrent: mismatch holds the queue, keeps what the user typed", () => {
|
||||
let s = reduce(createState(), q3());
|
||||
s = reduce(s, { type: "draft", agent: "t2", text: "nowy tekst", caret: 4 });
|
||||
s = reduce(s, { type: "restore_draft", agent: "t2", draft: dr(5), identity: { created_ms: 9, app: null }, keepCurrent: true });
|
||||
assert.equal(s.drafts.t2, "nowy tekst");
|
||||
assert.equal(s.carets.t2, 4);
|
||||
assert.deepEqual(s.queue.t2.map((i) => i.state), ["held", "held", "uncertain"]);
|
||||
assert.equal(s.notice.text, "Szkic z poprzedniej sesji agenta");
|
||||
});
|
||||
|
||||
test("restore_draft: unknown live identity holds the queue; notice only when saved identity was known", () => {
|
||||
let s = reduce(createState(), q3());
|
||||
const live = reduce(s, { type: "restore_draft", agent: "t2", draft: dr(5), identity: { created_ms: null, app: null } });
|
||||
assert.deepEqual(live.queue.t2.map((i) => i.state), ["held", "held", "uncertain"]);
|
||||
assert.equal(live.notice.text, "Szkic z poprzedniej sesji agenta");
|
||||
|
||||
const both = reduce(s, { type: "restore_draft", agent: "t2", draft: dr(null), identity: { created_ms: null, app: null } });
|
||||
assert.deepEqual(both.queue.t2.map((i) => i.state), ["held", "held", "uncertain"]);
|
||||
assert.equal(both.notice, null);
|
||||
assert.equal(both.drafts.t2, "szkic");
|
||||
});
|
||||
|
||||
test("restore_draft without a draft: unknown live identity still holds the queue", () => {
|
||||
const s = reduce(createState(), q3());
|
||||
const out = reduce(s, { type: "restore_draft", agent: "t2", draft: null, identity: { created_ms: null, app: null } });
|
||||
assert.deepEqual(out.queue.t2.map((i) => i.state), ["held", "held", "uncertain"]);
|
||||
assert.equal(out.notice, null);
|
||||
});
|
||||
|
||||
test("hold_queue holds queued and sending, keeps uncertain", () => {
|
||||
const s = reduce(reduce(createState(), q3()), { type: "hold_queue", agent: "t2" });
|
||||
assert.deepEqual(s.queue.t2.map((i) => i.state), ["held", "held", "uncertain"]);
|
||||
});
|
||||
Reference in new issue
Block a user