Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(shared-computers): no own-window proof for a send that repeats a line still waiting in the queue
AdityaUmale1259ca1e14b5
diff --git a/server/routes/bot-messages.test.ts b/server/routes/bot-messages.test.tsindex 361ca0b5c1..b36ed5c494 100644--- a/server/routes/bot-messages.test.ts+++ b/server/routes/bot-messages.test.ts@@ -783,6 +783,23 @@ describe("POST /api/bots/:id/messages from the desktop app's own window", () =>expect(ownWindowLine(threadId, line)).toBe(false);});+ it("notes no proof for a send that only repeats a press still waiting in the queue", async () => {+ const { store, bot, threadId, state, post, show } = await fixture();+ state.busy = true;+ const widgetId = show("routineForm");+ const pressed = await post({ threadId, sendId: SEND, widgetAction: { messageId: widgetId, ref: "confirm", values: { days: "mon,tue,wed,thu,fri,sat,sun", report: "discord:releases" } } });+ expect(pressed.status, JSON.stringify(pressed.body)).toBe(202);+ const waiting = queuedSteeredMessage(bot.id, threadId, SEND)!;+ expect(waiting, "the press waits in the queue").toBeTruthy();+ const repeat = await post({ threadId, sendId: SEND, text: waiting.text, replyToId: widgetId });+ expect(repeat.status, JSON.stringify(repeat.body)).toBe(202);+ expect(repeat.body.queueId).toBe(waiting.id);+ drainSteeredMessages(store, () => {});+ const line = store.messagesFor(threadId).find((message) => message.sendId === SEND);+ expect(line?.text, "the press became the thread's line").toBe(waiting.text);+ expect(ownWindowLine(threadId, line)).toBe(false);+ });+it("does not note a bare loopback send on a headless server, where it may be a bot's shell", async () => {const { threadId, post } = await fixture({}, false);const plain = await post({ threadId, sendId: SEND, text: words });diff --git a/server/routes/bot-messages.ts b/server/routes/bot-messages.tsindex a58d1560c4..a52db414c4 100644--- a/server/routes/bot-messages.ts+++ b/server/routes/bot-messages.ts@@ -345,9 +345,9 @@ export function createBotMessageRoutes(deps: BotMessageRouteDeps): RouteHandlerif (personPresent && sendId && !guarded && !press && !appSent) noteTypedSend(threadId, sendId, text);const notedSession = auth.kind === "session" && sendId ? noteSendingSession(threadId, sendId, auth.session.id) : false;// The desktop app's own window: in the desktop app a loopback change needs its private capability.- // Only a new line the send itself adds: a repeat or a collision must not lend the proof to a line already there.+ // Only a new line the send itself adds: a repeat or a collision must not lend the proof to a line already there or waiting.const ownWindowSend = DESKTOP_MANAGED && auth.kind === "loopback" && !auth.companionDevice && sendId && !guarded && !press && !appSent- && !store.messagesFor(threadId).some((line) => line.sendId === sendId);+ && !store.messagesFor(threadId).some((line) => line.sendId === sendId) && !queuedSteeredMessage(bot.id, threadId, sendId);if (pressKey) pressesInFlight.set(pressKey, sendId);try {const receipt = await acceptDirectSend({