Skip to content

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

Keep who a busy-elsewhere teammate also waits for in this room

Bugfixer 2aeeeb63a7407
diff --git a/server/room-queue.test.ts b/server/room-queue.test.ts
index f7ad5ee2a3..0955729d9a 100644
--- a/server/room-queue.test.ts
+++ b/server/room-queue.test.ts
@@ -50,12 +50,18 @@ describe("room queue", () => {
describe("a member busy outside the room", () => {
it("tells the requester it is busy elsewhere and starts here when that finishes", () => {
- const [entry] = roomQueue([job("e1", "queued")], new Map([["room", "lead"]]));
+ const [entry] = roomQueue([job("e1", "queued")]);
expect(queuedJobDetail({ ...entry!, busyIn: { groupId: "room-1", threadId: "t1" } }, nameOf))
.toBe("queued 1 of 1 in this room: Editor 1 is busy in another room now, so it starts here when that finishes");
expect(queuedJobDetail({ ...entry!, busyIn: { threadId: "own" } }, nameOf))
.toBe("queued 1 of 1 in this room: Editor 1 is busy in another thread of its own now, so it starts here when that finishes");
});
+
+ it("still names who it waits for in this room when it is also busy elsewhere", () => {
+ const [entry] = roomQueue([job("e1", "queued")], new Map([["room", "scout"]]));
+ expect(queuedJobDetail({ ...entry!, busyIn: { groupId: "room-1", threadId: "t1" } }, nameOf))
+ .toBe("queued 1 of 1 in this room: Editor 1 is busy in another room now, so it starts here when that finishes and after Scout");
+ });
});
describe("room queue merging", () => {
diff --git a/server/room-queue.ts b/server/room-queue.ts
index 2ba0b667e8..3a75d45a60 100644
--- a/server/room-queue.ts
+++ b/server/room-queue.ts
@@ -41,7 +41,8 @@ export function roomQueue(items: readonly RoomLineItem[], speakers: ReadonlyMap<
export function queuedJobDetail(entry: RoomQueueEntry, nameOf: (botId: string) => string): string {
if (entry.busyIn) {
const where = entry.busyIn.groupId ? "another room" : "another thread of its own";
- return `queued ${entry.position} of ${entry.of} in this room: ${nameOf(entry.botId)} is busy in ${where} now, so it starts here when that finishes`;
+ const after = entry.waitingForBotId ? ` and after ${nameOf(entry.waitingForBotId)}` : "";
+ return `queued ${entry.position} of ${entry.of} in this room: ${nameOf(entry.botId)} is busy in ${where} now, so it starts here when that finishes${after}`;
}
const after = entry.waitingForBotId ? `, after ${nameOf(entry.waitingForBotId)}` : "";
return `queued ${entry.position} of ${entry.of} in this room: room jobs run one at a time, so it starts in turn${after}`;
diff --git a/src/lib/room-threads.test.ts b/src/lib/room-threads.test.ts
index 59bb2e3c91..dc80f4505b 100644
--- a/src/lib/room-threads.test.ts
+++ b/src/lib/room-threads.test.ts
@@ -74,7 +74,7 @@ describe("room queue labels", () => {
it("says where a waiting member is busy, by a name this viewer can see, and that it starts when that finishes", () => {
const placeOf = busyPlaceOf([{ id: "room-1", name: "Group 1" }], [{ id: "coder", tasks: [{ threadId: "own", title: "Fix login", createdAt: 1 }] }]);
- const inRoom = { botId: "coder", threadId: "open", state: "queued" as const, position: 1, of: 2, waitingForBotId: "scout", busyIn: { groupId: "room-1", threadId: "g1" } };
+ const inRoom = { botId: "coder", threadId: "open", state: "queued" as const, position: 1, of: 2, busyIn: { groupId: "room-1", threadId: "g1" } };
expect(roomQueueLabel(inRoom, () => "Scout", placeOf)).toBe("Busy in Group 1 · queued (1 of 2), starts when it finishes");
expect(roomQueueLabel({ ...inRoom, busyIn: { threadId: "own" } }, () => "Scout", placeOf)).toBe("Busy in Fix login · queued (1 of 2), starts when it finishes");
// A room or thread this viewer can't see is not named.
@@ -82,4 +82,13 @@ describe("room queue labels", () => {
.toBe("Busy in another conversation · queued (1 of 2), starts when it finishes");
expect(roomQueueLabel(inRoom, () => "Scout")).toBe("Busy in another conversation · queued (1 of 2), starts when it finishes");
});
+
+ it("keeps who a busy-elsewhere member also waits for in this room", () => {
+ const placeOf = busyPlaceOf([{ id: "room-1", name: "Group 1" }], []);
+ const entry = { botId: "coder", threadId: "open", state: "queued" as const, position: 2, of: 2, waitingForBotId: "scout", busyIn: { groupId: "room-1", threadId: "g1" } };
+ expect(roomQueueLabel(entry, () => "Scout", placeOf)).toBe("Busy in Group 1 · queued after Scout (2 of 2), starts when both finish");
+ expect(roomQueueLabel(entry, () => "Scout")).toBe("Busy in another conversation · queued after Scout (2 of 2), starts when both finish");
+ // A waited-for member this viewer can't name falls back to the plain busy line.
+ expect(roomQueueLabel(entry, () => undefined, placeOf)).toBe("Busy in Group 1 · queued (2 of 2), starts when it finishes");
+ });
});
diff --git a/src/lib/room-threads.ts b/src/lib/room-threads.ts
index 0a9af905c0..13d712be8e 100644
--- a/src/lib/room-threads.ts
+++ b/src/lib/room-threads.ts
@@ -52,13 +52,13 @@ export function busyPlaceOf(groups: Pick<Group, "id" | "name">[], bots: Pick<Bot
export function roomQueueLabel(entry: RoomQueueEntry, nameOf: (botId: string) => string | undefined,
placeOf?: (entry: RoomQueueEntry) => string | undefined): string {
+ const name = entry.waitingForBotId ? nameOf(entry.waitingForBotId) : undefined;
if (entry.busyIn) {
const place = placeOf?.(entry);
- return place
- ? t("room.queue.busyIn", { place, position: entry.position, of: entry.of })
- : t("room.queue.busyElsewhere", { position: entry.position, of: entry.of });
+ const slot = { position: entry.position, of: entry.of };
+ if (name) return place ? t("room.queue.busyInAfter", { place, name, ...slot }) : t("room.queue.busyElsewhereAfter", { name, ...slot });
+ return place ? t("room.queue.busyIn", { place, ...slot }) : t("room.queue.busyElsewhere", slot);
}
- const name = entry.waitingForBotId ? nameOf(entry.waitingForBotId) : undefined;
return name
? t("room.queue.waitingFor", { name, position: entry.position, of: entry.of })
: t("room.queue.waiting", { position: entry.position, of: entry.of });
diff --git a/src/locales/en.json b/src/locales/en.json
index ff698725a0..a176b4d746 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -5235,6 +5235,8 @@
"room.queue.waiting": "Queued ({position} of {of})",
"room.queue.busyIn": "Busy in {place} · queued ({position} of {of}), starts when it finishes",
"room.queue.busyElsewhere": "Busy in another conversation · queued ({position} of {of}), starts when it finishes",
+ "room.queue.busyInAfter": "Busy in {place} · queued after {name} ({position} of {of}), starts when both finish",
+ "room.queue.busyElsewhereAfter": "Busy in another conversation · queued after {name} ({position} of {of}), starts when both finish",
"room.queue.member": "{name}: {status}",
"room.responder.everyone": "Plain messages go to every group member; @mentions override this",
"room.responder.mentions": "Only explicitly @mentioned bots respond",