Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
test(chat): cover delivered-copy source matching
meutex3b2235d49574
diff --git a/server/bot-attachment.test.ts b/server/bot-attachment.test.tsindex 06423b4b6b..b18b2a6208 100644--- a/server/bot-attachment.test.ts+++ b/server/bot-attachment.test.ts@@ -326,4 +326,38 @@ describe("deliveredCopy", () => {expect(deliveredCopy([ask, first, second, twice], twice, "sideboard.png")).toBeNull();expect(deliveredCopy([ask, first, twice], { ...twice, parentId: "first" }, "sideboard.png")).toEqual(photo);});++ it("finds a renamed delivery by its source path", () => {+ const attached = bot("attached", "ask", { attachments: [renamed] });+ const reply = bot("reply", "attached", { text: "[README](D:/AI/openmausbot-skills/README.md)" });+ expect(deliveredCopy([ask, attached, reply], reply, "README.md", "D:\\AI\\openmausbot-skills\\README.md")).toEqual(renamed);+ });++ it("finds the same source spelled as a file:// URL or with an encoded space", () => {+ const spaced = { ...renamed, source: "D:\\AI\\openmausbot-skills\\my file.pdf", name: "团队技能包.pdf" };+ const attached = bot("attached", "ask", { attachments: [spaced] });+ const reply = bot("reply", "attached", { text: "[pdf](file:///D:/AI/openmausbot-skills/my%20file.pdf)" });+ expect(deliveredCopy([ask, attached, reply], reply, "my file.pdf", "file:///D:/AI/openmausbot-skills/my%20file.pdf")).toEqual(spaced);+ });++ it("still finds a delivery by display name when the record has no source", () => {+ const attached = bot("attached", "ask", { attachments: [photo] });+ const reply = bot("reply", "attached", { text: "" });+ expect(deliveredCopy([ask, attached, reply], reply, "sideboard.png", "/tmp/sideboard.png")).toEqual(photo);+ });++ it("refuses when two deliveries share the clicked source", () => {+ const by = (botId: string) => ({ from: { botId, name: botId, color: "blue" } }) as Partial<Message>;+ const first = bot("first", "ask", { ...by("me"), attachments: [renamed] });+ const second = bot("second", "first", { ...by("me"), attachments: [{ ...renamed, path: "/store/copy-2.md" }] });+ const reply = bot("reply", "second", by("me"));+ expect(deliveredCopy([ask, first, second, reply], reply, "README.md", "D:\\AI\\openmausbot-skills\\README.md")).toBeNull();+ });++ it("ignores a different bot's delivery even when its source matches", () => {+ const by = (botId: string) => ({ from: { botId, name: botId, color: "blue" } }) as Partial<Message>;+ const peer = bot("peer", "ask", { ...by("other"), attachments: [renamed] });+ const reply = bot("reply", "peer", by("me"));+ expect(deliveredCopy([ask, peer, reply], reply, "README.md", "D:\\AI\\openmausbot-skills\\README.md")).toBeNull();+ });});