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): note the own-window proof only for a new line the desktop send accepted
AdityaUmaleb737198ee6c4
diff --git a/server/routes/bot-messages.test.ts b/server/routes/bot-messages.test.tsindex 025fc7d832..361ca0b5c1 100644--- a/server/routes/bot-messages.test.ts+++ b/server/routes/bot-messages.test.ts@@ -769,6 +769,20 @@ describe("POST /api/bots/:id/messages from the desktop app's own window", () =>expect(ownWindowLine(threadId, relayed.body.message)).toBe(false);});+ it("notes no proof for a send that only repeats or collides with a press already in the thread", async () => {+ const { threadId, post, show } = await fixture();+ 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 line = pressed.body.message;+ expect((await post({ threadId, sendId: SEND, text: line.text })).status).toBe(409);+ expect(ownWindowLine(threadId, line)).toBe(false);+ const repeat = await post({ threadId, sendId: SEND, text: line.text, replyToId: widgetId });+ expect(repeat.status, JSON.stringify(repeat.body)).toBe(202);+ expect(repeat.body.message.id).toBe(line.id);+ 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 3527c412e0..a58d1560c4 100644--- a/server/routes/bot-messages.ts+++ b/server/routes/bot-messages.ts@@ -345,7 +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.- if (DESKTOP_MANAGED && auth.kind === "loopback" && !auth.companionDevice && sendId && !guarded && !press && !appSent) noteOwnWindowSend(threadId, sendId, text);+ // Only a new line the send itself adds: a repeat or a collision must not lend the proof to a line already there.+ const ownWindowSend = DESKTOP_MANAGED && auth.kind === "loopback" && !auth.companionDevice && sendId && !guarded && !press && !appSent+ && !store.messagesFor(threadId).some((line) => line.sendId === sendId);if (pressKey) pressesInFlight.set(pressKey, sendId);try {const receipt = await acceptDirectSend({@@ -353,6 +355,7 @@ export function createBotMessageRoutes(deps: BotMessageRouteDeps): RouteHandlerpersonPresent, admin: owners.admin(auth), ...(followUp ? { followUp } : {}),...(mentions?.length && !press && !appSent ? { mentions } : {}),}, guardedStart);+ if (ownWindowSend) noteOwnWindowSend(threadId, sendId, text);press?.settle("queueId" in receipt ? receipt.queueId : undefined);appContext?.deliver();if (relayed && target && onBehalfOf) relayedReaction(threadId, target.id, onBehalfOf, relayed);