Skip to content

Commit 71f044f

Browse files
baxenclaude
andcommitted
fix(agents2): delete each working reaction on its own
The relay rejects a deletion with more than one target, so the single deletion naming both reactions was refused and they were never removed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Bradley Axen <[email protected]>
1 parent 5f792c2 commit 71f044f

2 files changed

Lines changed: 24 additions & 13 deletions

File tree

‎src/features/agents2/service.test.ts‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,20 +460,23 @@ it("reacts 👀 and 💬 to a mention until the work its run handed off settles"
460460
expect(await published(native, 5)).toEqual([]);
461461
finish();
462462
await vi.waitFor(async () =>
463-
expect(await published(native, 5)).toHaveLength(1),
463+
expect(await published(native, 5)).toHaveLength(2),
464+
);
465+
// The relay takes one target per deletion.
466+
expect((await published(native, 5)).map(({ tags }) => tags)).toEqual(
467+
reactions.map(({ id }) => [
468+
["h", channel],
469+
["e", id],
470+
["k", "7"],
471+
]),
464472
);
465-
expect((await published(native, 5))[0]?.tags).toEqual([
466-
["h", channel],
467-
...reactions.map(({ id }) => ["e", id]),
468-
["k", "7"],
469-
]);
470473
// Only mentions are reacted to, and a failed run takes its reactions back.
471474
run.mockRejectedValueOnce(new Error("boom"));
472475
emit({ events: [event("m2", { tags: mention.tags })], channelId: channel });
473476
emit({ events: [event("w", { content: "deploy" })], channelId: channel });
474477
await vi.waitFor(() => expect(run).toHaveBeenCalledTimes(3));
475478
await vi.waitFor(async () =>
476-
expect(await published(native, 5)).toHaveLength(2),
479+
expect(await published(native, 5)).toHaveLength(4),
477480
);
478481
expect(await published(native, 7)).toHaveLength(4);
479482
});

‎src/features/agents2/working-reactions.ts‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,20 @@ export function reactWhileWorking(
3737
);
3838
if (ids.length < results.length)
3939
console.warn("Agent working reactions were not all published");
40-
if (!ids.length) return;
41-
return publish({
42-
kind: 5,
43-
content: "",
44-
tags: [["h", channelId], ...ids.map((id) => ["e", id]), ["k", "7"]],
45-
});
40+
// The relay takes one target per deletion.
41+
return Promise.all(
42+
ids.map((id) =>
43+
publish({
44+
kind: 5,
45+
content: "",
46+
tags: [
47+
["h", channelId],
48+
["e", id],
49+
["k", "7"],
50+
],
51+
}),
52+
),
53+
);
4654
})
4755
.catch((error) =>
4856
console.warn("Agent working reactions were not removed", error),

0 commit comments

Comments
 (0)