Skip to content

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

fix(devs): a department named devs is tagged, not the bug report (#4091)

Aditya Umalec79d293cbd3a
diff --git a/server/host/devs-reports.test.ts b/server/host/devs-reports.test.ts
index 70761e3a77..376515205a 100644
--- a/server/host/devs-reports.test.ts
+++ b/server/host/devs-reports.test.ts
@@ -18,7 +18,7 @@ afterEach(() => { for (const dir of dirs.splice(0)) rmSync(dir, { recursive: tru
const SCOUT = { id: "scout", name: "Scout", threadId: "scout-main", modelSelection: { instanceId: "claude", model: "claude-opus-5-5" }, composio: true };
const ROVER = { id: "rover", name: "Rover", threadId: "rover-main", modelSelection: { instanceId: "codex", model: "gpt-5.5", effort: "high" } };
-function fixture(options: { dataDir?: string; outcomes?: SendOutcome[]; sessions?: PublicSession[]; ownerKey?: string | null; team?: boolean;
+function fixture(options: { dataDir?: string; sections?: string[]; outcomes?: SendOutcome[]; sessions?: PublicSession[]; ownerKey?: string | null; team?: boolean;
profileEmail?: string; automated?: boolean; lineLanguage?: DevsReportsDeps["lineLanguage"]; appVersion?: string; clock?: number;
/** The conversations, kept across a restart (another fixture on the same data). */
threads?: Map<string, Message[]>;
@@ -34,6 +34,7 @@ function fixture(options: { dataDir?: string; outcomes?: SendOutcome[]; sessions
const groups = [{ id: "launch", name: "Launch", threadId: "room", memberIds: ["scout", "rover"] }];
const store = {
bots,
+ sections: options.sections ?? [],
bot: (id: string) => bots.find((bot) => bot.id === id) ?? null,
botByThread: (threadId: string) => bots.find((bot) => bot.threadId === threadId) ?? null,
groupByThread: (threadId: string) => groups.find((group) => group.threadId === threadId),
@@ -199,6 +200,17 @@ describe("a message that tags @devs", () => {
expect(fx.sent).toHaveLength(1);
fx.stop();
});
+ it("is never a message that tags a department named devs", async () => {
+ const fx = fixture({ sections: ["Devs"] });
+ fx.person("scout-main", "I added Rover to the @devs department, notify Scout");
+ fx.busy.add("scout-main");
+ expect(fx.reports.note("scout-main", true)).toBe("");
+ fx.advance(NO_ANSWER_MS);
+ await fx.settle();
+ expect(fx.sent).toEqual([]);
+ expect((await fx.call("scout", "scout-main", { went_wrong: "x" })).status).toBe(409);
+ fx.stop();
+ });
});
describe("what the person is told, in their language", () => {
diff --git a/server/host/devs-reports.ts b/server/host/devs-reports.ts
index d1eacbdd0e..d7f9d99f62 100644
--- a/server/host/devs-reports.ts
+++ b/server/host/devs-reports.ts
@@ -86,7 +86,7 @@ type Author = { bot: BotRecord; summary: BotSummary } | { why: string };
export interface DevsReportsDeps {
dataDir: string;
- store: Pick<Store, "bots" | "bot" | "botByThread" | "groupByThread" | "projectBotForTask" | "activePath" | "appendMessage" | "patchMessage" | "onChange">;
+ store: Pick<Store, "bots" | "sections" | "bot" | "botByThread" | "groupByThread" | "projectBotForTask" | "activePath" | "appendMessage" | "patchMessage" | "onChange">;
installId: string;
appVersion: string;
/** Where this server runs, as the team reads it: desktop app, My Cloud, Team Cloud… */
@@ -221,7 +221,8 @@ export function createDevsReports(deps: DevsReportsDeps) {
try { store.appendMessage(threadId, { role: "bot", kind: "activity", tool: { name: `notice: ${said.line}`, ok: said.ok } }); }
catch { /* the conversation is gone; the report still went */ }
};
- const botNames = () => store.bots.map((bot) => bot.name);
+ // A bot or a department named devs is tagged instead.
+ const namesBeforeDevs = () => [...store.bots.map((bot) => bot.name), ...store.sections];
const secrets = () => environmentSecrets();
const languageFor = (person: string | undefined) => (deps.lineLanguage ? deps.lineLanguage(person) : deps.language());
@@ -449,12 +450,14 @@ export function createDevsReports(deps: DevsReportsDeps) {
function personWrote(threadId: string, line: Message): void {
if (seen.has(line.id) || !line.text || now() - line.at > FRESH_MS) return;
if (!line.sendId && deps.automated(threadId)) return;
- if (!tagsDevs(line.text, botNames())) return;
+ if (!tagsDevs(line.text)) return;
+ const names = namesBeforeDevs();
+ if (!tagsDevs(line.text, names)) return;
seen.add(line.id);
if (seen.size > 1_000) seen.delete(seen.values().next().value!);
if (waiting.length >= MAX_WAITING) return notice(threadId, { ok: false, line: fullLine(languageFor(line.sender?.id)), marker: "" });
const redact = (text: string) => clip(redactReportText(text, secrets()), 3_000);
- waiting.push({ messageId: line.id, threadId, at: line.at, text: redact(line.text), words: redact(withoutDevsTags(line.text, botNames())),
+ waiting.push({ messageId: line.id, threadId, at: line.at, text: redact(line.text), words: redact(withoutDevsTags(line.text, names)),
...(line.sender ? { sender: { name: line.sender.name, ...(line.sender.id ? { id: line.sender.id } : {}) } } : {}) });
save();
timer?.poke();
diff --git a/shared/devs-mention.ts b/shared/devs-mention.ts
index 6b1a2c778f..b7eb6396d7 100644
--- a/shared/devs-mention.ts
+++ b/shared/devs-mention.ts
@@ -8,8 +8,8 @@ export const DEVS_TAG = "devs";
const startsWithName = (rest: string, name: string) =>
rest.slice(0, name.length).toLowerCase() === name.toLowerCase() && !isMentionNameContinuation(rest.slice(name.length));
-/** The tag's length when `rest` (the text after an at-sign) starts with it. A bot named devs, or with a longer name
- * that starts with it, is tagged instead. */
+/** The tag's length when `rest` (the text after an at-sign) starts with it. A bot or department named devs, or with a
+ * longer name that starts with it, is tagged instead. */
export function devsTagAt(rest: string, botNames: readonly string[] = []): number | undefined {
if (!startsWithName(rest, DEVS_TAG)) return undefined;
const bot = botNames.some((name) => name.trim().length >= DEVS_TAG.length && startsWithName(rest, name));