Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(rooms): report a pick part the round never delivered

AdityaUmale9dcd6b9e4206
diff --git a/server/index.ts b/server/index.ts
index 310bf6c2d3..70827b9a0e 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -262,7 +262,7 @@ import {
drainChannelMessages,
restoreChannelMessages,
type ChannelQueueItem,
-} from "./channel-queue.ts"; import { copyRoomPick, pointedResponders, takeRoomPick, undeliveredPickBots, type RoomPick } from "./room-pointed.ts";
+} from "./channel-queue.ts"; import { copyRoomPick, pointedResponders, roomPickBots, takeRoomPick, undeliveredPickBots, type RoomPick } from "./room-pointed.ts";
import {
acceptedSendMatch,
sendFingerprint,
@@ -10838,7 +10838,7 @@ function startGroupTurn(
const addressed = stopWordPlacement(text) === "adjacent" ? undefined : message.id;
for (const held of responders.filter(isHeld)) noteHeldSkip(group.id, threadId, held, addressed);
responders = responders.filter((responder) => !isHeld(responder));
- } for (const id of undeliveredPickBots(options.pointed, responders)) store.appendMessage(threadId, { role: "bot", kind: "activity", tool: { name: serverLine(threadLanguage(threadId), "server.rooms.pickNotSent", { bot: store.bot(id)?.name ?? id }), ok: false } });
+ } const unsentPick = undeliveredPickBots(options.pointed, responders), notePickNotSent = (id: string) => store.appendMessage(threadId, { role: "bot", kind: "activity", tool: { name: serverLine(threadLanguage(threadId), "server.rooms.pickNotSent", { bot: store.bot(id)?.name ?? id }), ok: false } }); for (const id of unsentPick) notePickNotSent(id);
const explicitlyMentionedLead = roomResponders(text, routableMembers, { kind: "mentions" }, options.mentions)[0];
const goalCoordinator = channelMode === "goal"
? requestedGoalCoordinator ?? explicitlyMentionedLead ?? selectGroupGoalCoordinator(routableMembers, group.defaultResponder)
@@ -10978,7 +10978,7 @@ function startGroupTurn(
}
}
});
- const tracked = next.finally(() => finishGroupTurnOperation(groupId, operation));
+ const tracked = next.finally(() => { try { for (const id of roomPickBots(operation.pick)) if (!unsentPick.includes(id)) notePickNotSent(id); } finally { finishGroupTurnOperation(groupId, operation); } });
groupQueues.set(threadId, tracked.catch(() => {}));
return message;
}
diff --git a/server/room-pages-point.e2e.test.ts b/server/room-pages-point.e2e.test.ts
index 6ba35cf14e..80b9cbd8f9 100644
--- a/server/room-pages-point.e2e.test.ts
+++ b/server/room-pages-point.e2e.test.ts
@@ -97,4 +97,21 @@ it("sends a pick on a room page to the bot that made it, and to no other member"
await settled(helper.id);
await expect.poll(async () => (await transcript()).some((message) => message.kind === "activity" && String(message.tool?.name).includes("what you pointed at in its page wasn't sent")), { timeout: 30_000 }).toBe(true);
expect(evidence(designer.id).length).toBe(designerTurns + 1);
-}, 120_000);
+
+ // A line pointing at two bots' pages whose round stops during the first bot's turn reports the other bot's part.
+ expect((await api(`/api/groups/${group.id}/holds`, { botId: designer.id, held: false })).status).toBeLessThan(300);
+ writeFileSync(planPath, JSON.stringify({ [designer.id]: { steps: [], reply: "Done." }, [helper.id]: { steps: [{ tool: "show_html", arguments: { html: "<main><p>Notes</p></main>", title: "Notes" } }], reply: "Done." } }));
+ expect((await api(`/api/groups/${group.id}/messages`, { text: "@Helper make a notes page", mentions: [helper.id] })).status).toBe(202);
+ await expect.poll(async () => (await transcript()).find((message) => message.kind === "app" && message.from?.botId === helper.id)?.id, { timeout: 30_000 }).toBeTruthy();
+ await settled(helper.id);
+ const notes = (await transcript()).find((message) => message.kind === "app" && message.from?.botId === helper.id);
+ const designerReady = join(fixture.info.dataDir, "designer-ready");
+ writeFileSync(planPath, JSON.stringify({ [designer.id]: { steps: [], reply: "Done.", readyFile: designerReady, gateFile: join(fixture.info.dataDir, "designer-gate") }, [helper.id]: { steps: [], reply: "Done." } }));
+ const helperBefore = evidence(helper.id).length;
+ const both = await api(`/api/groups/${group.id}/messages`, { text: "Line these up", pointed: [pointed, { ...pointed, appId: notes.id, tag: "p", text: "Notes", selector: "main > p", html: "<p>Notes</p>" }] });
+ expect(both.status, JSON.stringify(both.body)).toBe(202);
+ await expect.poll(() => existsSync(designerReady), { timeout: 30_000 }).toBe(true);
+ expect((await api(`/api/groups/${group.id}/interrupt`, {})).status).toBeLessThan(300);
+ await expect.poll(async () => (await transcript()).some((message) => message.kind === "activity" && String(message.tool?.name).startsWith("Helper can't answer this line right now")), { timeout: 30_000 }).toBe(true);
+ expect(evidence(helper.id).length).toBe(helperBefore);
+}, 180_000);
diff --git a/server/room-pointed.ts b/server/room-pointed.ts
index fd54a91c0b..dbae7df513 100644
--- a/server/room-pointed.ts
+++ b/server/room-pointed.ts
@@ -33,7 +33,8 @@ export function roomPickBots(pick: RoomPick | undefined): string[] {
return pick ? Object.keys(pick.blocks) : [];
}
-/** Page bots of a pick that will not answer this line (held or gone since it was queued): their part reaches no one. */
+/** Page bots of a pick that will not answer this line (held or gone since it was queued): their part reaches no one.
+ * startGroupTurn also reports parts still in the run's pick when its round ends (a turn failed or the round stopped). */
export function undeliveredPickBots(pick: RoomPick | undefined, responders: ReadonlyArray<{ id: string }>): string[] {
return roomPickBots(pick).filter((id) => !responders.some((responder) => responder.id === id));
}