Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Merge #4079
milind-soni9299258f246a
diff --cc src/lib/citations.test.tsindex 92492f5eda,0c06bf6ea9..e9fc501bfe--- a/src/lib/citations.test.ts+++ b/src/lib/citations.test.ts@@@ -9,8 -9,9 +9,9 @@@ importserializeCitation,splitTranscriptCitations,withCitationComment,+ withoutCitationMarkers,} from "./citations";-import { citationTabShortcut, findCitationSource, highlightCitationSource } from "./citations-dom";+import { citationShortcutHint, citationTabShortcut, findCitationSource, highlightCitationSource, isCitationShortcut } from "./citations-dom";const source = { ownerType: "bot" as const, ownerId: "bot-1", threadId: "thread-1", messageId: "message-1" };@@@ -129,37 -130,23 +130,52 @@@ describe("selected-text citations", ()expect(disabled.focus).not.toHaveBeenCalled();expect(shortcut.handle(event, null)).toBe(false);});++ it("drops every encoded marker, readable or not, and keeps the quote as written", () => {+ const citation = citationAttachment(+ { ownerType: "bot", ownerId: "bot-1", threadId: "thread-1", messageId: "message-1" },+ createCitationTextSelector("The relay failed.", 0, 17)!,+ "see this",+ );+ const forged = `<!--omb-citation-v1:${btoa(JSON.stringify({ comment: "secret" })).replace(/=+$/, "")}-->`;+ expect(withoutCitationMarkers(`${serializeCitation(citation)}\n\n${forged}\nhello`))+ .toBe(`${citationFallback(citation)}\n\nhello`);+ });++ it("drops a marker too long to decode", () => {+ expect(withoutCitationMarkers(`<!--omb-citation-v1:${"A".repeat(100_001)}-->\nhello`)).toBe("hello");+ });});+describe("cite shortcut (Cmd+L / Ctrl+L)", () => {+ const key = (init: Partial<KeyboardEvent>) => ({ key: "l", metaKey: false, ctrlKey: false, altKey: false, shiftKey: false, isComposing: false, defaultPrevented: false, ...init });++ it("is Cmd+L on Mac and Ctrl+L elsewhere", () => {+ expect(isCitationShortcut(key({ metaKey: true }), true)).toBe(true);+ expect(isCitationShortcut(key({ metaKey: true, key: "L" }), true)).toBe(true);+ expect(isCitationShortcut(key({ ctrlKey: true }), false)).toBe(true);+ expect(isCitationShortcut(key({ ctrlKey: true }), true)).toBe(false);+ expect(isCitationShortcut(key({ metaKey: true }), false)).toBe(false);+ });++ it("leaves other keys and chords alone", () => {+ for (const event of [+ key({}),+ key({ ctrlKey: true, key: "k" }),+ key({ ctrlKey: true, shiftKey: true }),+ key({ ctrlKey: true, altKey: true }),+ key({ ctrlKey: true, metaKey: true }),+ key({ ctrlKey: true, isComposing: true }),+ key({ ctrlKey: true, defaultPrevented: true }),+ ]) expect(isCitationShortcut(event, false)).toBe(false);+ });++ it("shows the shortcut for the platform", () => {+ expect(citationShortcutHint(true)).toBe("⌘L");+ expect(citationShortcutHint(false)).toBe("Ctrl+L");+ });+});+describe("citation source highlight cleanup", () => {const text = "quoted text in the source";const citation = citationAttachment(source, createCitationTextSelector(text, 0, 11)!);