Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Keep the viewer's own name whole before @all
bsisduck44dcad9edddc
diff --git a/src/lib/mentions.test.ts b/src/lib/mentions.test.tsindex ccbff0a7a1..71446171fe 100644--- a/src/lib/mentions.test.ts+++ b/src/lib/mentions.test.ts@@ -117,6 +117,11 @@ describe("a teammate's tag in display ranges", () => {expect(tags("@All Hands please")).toEqual([["@All Hands", true]]);expect(tags("@all please")).toEqual([["@all", false]]);});+ it("keeps the viewer's own longer name whole when it starts with @all", () => {+ const tags = (text: string) => mentionRanges(text, peers, true, { profileName: "All Hands" }).map(({ start, end, you }) => [text.slice(start, end), you ?? false]);+ expect(tags("@All Hands please")).toEqual([["@All Hands", true]]);+ expect(tags("@all please")).toEqual([["@all", false]]);+ });it("does not let a teammate's name take the viewer's own tag away", () => {expect(mentionRanges("@Sam", [{ name: "Sam", person: true }], false, { profileName: "Sam" })).toEqual([{ start: 0, end: 4, you: true }]);});diff --git a/src/lib/mentions.ts b/src/lib/mentions.tsindex 236f0ed729..39d6f1f9df 100644--- a/src/lib/mentions.ts+++ b/src/lib/mentions.ts@@ -69,7 +69,7 @@ export function mentionRanges(text: string, peers: readonly MentionPeer[], everyconst rest = text.slice(at + 1);const peer = candidates.find(({ name }) => rest.slice(0, name.length).toLowerCase() === name.toLowerCase()&& !isMentionNameContinuation(rest.slice(name.length)));- const all = everyone ? everyoneTagAt(rest, candidates.map(({ name }) => name)) : undefined;+ const all = everyone ? everyoneTagAt(rest, [...candidates.map(({ name }) => name), ...personNames]) : undefined;const you = all === undefined && personNames.length ? personTagAt(rest, personNames, botNames) : undefined;if (you !== undefined) {ranges.push({ start: at, end: at + you + 1, you: true });