Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Status line names the work: the conversation's title, and what a page or write-up makes
milind-soni1c97ed4f3e30
diff --git a/src/components/ChatView.live-status.test.ts b/src/components/ChatView.live-status.test.tsindex 2c56b9ef6f..887762b390 100644--- a/src/components/ChatView.live-status.test.ts+++ b/src/components/ChatView.live-status.test.ts@@ -94,7 +94,7 @@ describe("Simple mode's working line", () => {engine({ type: "turn.started" });render(busyBot([ask]));expect(mascot()).not.toBeNull();- expect(statusLine()).toBe("Thinking it through");+ expect(statusLine(), "the conversation's title names the work").toBe("Working on Dashboard");expect(mascot()!.innerHTML).toContain('width="28px"');const row = mascot()!.firstElementChild as HTMLElement;expect([...row.classList]).toEqual(expect.arrayContaining(["h-9", "ps-2", "gap-2"]));@@ -108,6 +108,18 @@ describe("Simple mode's working line", () => {// The reply that just arrived pops in first; the line comes back once it has.act(() => void vi.advanceTimersByTime(600));engine({ type: "turn.progress", activity: "write", itemId: "toolu_write", file: "index.html", bytes: 14 * 1024 + 300 } as Partial<RuntimeEvent>);+ expect(statusLine()).toBe("Putting the page together");+ engine({ type: "turn.progress", activity: "write", itemId: "toolu_script", file: "build.py", bytes: 300 } as Partial<RuntimeEvent>);+ expect(statusLine(), "code says the work, not the tool").toBe("Working on Dashboard");+ });++ it("keeps today's words while the title is still the opening of the ask", () => {+ mode.advanced = false;+ engine({ type: "turn.started" });+ const shown = busyBot([ask]);+ render({ ...shown, tasks: shown.tasks!.map((task) => ({ ...task, title: "Build me a sales dashboard" })) });+ expect(statusLine()).toBe("Thinking it through");+ engine({ type: "turn.progress", activity: "write", itemId: "toolu_script", file: "build.py", bytes: 300 } as Partial<RuntimeEvent>);expect(statusLine()).toBe("Writing some code");});diff --git a/src/components/NowCard.tsx b/src/components/NowCard.tsxindex ea65ee4d3c..c16d47ee40 100644--- a/src/components/NowCard.tsx+++ b/src/components/NowCard.tsx@@ -5,7 +5,7 @@ import { useStoreDispatch } from "@/state/store-select";import type { TurnLive } from "@/state/turn-status";import { cn } from "@/lib/cn";import { focusActivityRun } from "@/lib/activity-focus";-import { friendlyNowPhrases } from "@/lib/friendly-activity";+import { friendlyNowPhrases, taskSubject } from "@/lib/friendly-activity";import { t } from "@/lib/i18n";import { turnNowPhrases } from "@/lib/live-activity";import { nowSteps, type NowStep, type NowStepState } from "@/lib/now-steps";@@ -44,11 +44,15 @@ export function NowCard({ steps, tail, onOpenActivity }: { steps: readonly NowSt/** Everything the working line of a bot's chat shows: what is happening now, in each mode's words, how a long step is* doing, and the card it unfolds. */-export function useTurnNow(bot: Pick<Bot, "id" | "name" | "threadId">, messages: readonly Message[], lastMessage: Message | undefined, live: TurnLive, advanced: boolean) {+export function useTurnNow(bot: Pick<Bot, "id" | "name" | "threadId" | "tasks">, messages: readonly Message[], lastMessage: Message | undefined, live: TurnLive, advanced: boolean) {const dispatch = useStoreDispatch();const status = live.status;const exact = turnNowPhrases(status, lastMessage);- const shown = advanced ? exact : friendlyNowPhrases(status, lastMessage);+ const title = bot.tasks?.find((task) => task.threadId === bot.threadId)?.title;+ // Simple mode only, and once per title or loaded page of messages, never per frame.+ const subject = useMemo(() => advanced ? undefined+ : taskSubject(title, messages.flatMap((message) => message.role === "user" && message.text ? [message.text] : [])), [advanced, title, messages]);+ const shown = advanced ? exact : friendlyNowPhrases(status, lastMessage, subject);const steps = useMemo(() => nowSteps(messages, status), [messages, status]);const quiet = status && "quiet" in status ? status.quiet : undefined;const tail = status?.activity === "command" && "tail" in status ? status.tail : undefined;diff --git a/src/components/SidebarWorkingStep.test.ts b/src/components/SidebarWorkingStep.test.tsindex 6bccc4b53a..65d1f8618b 100644--- a/src/components/SidebarWorkingStep.test.ts+++ b/src/components/SidebarWorkingStep.test.ts@@ -29,6 +29,26 @@ describe("sidebar working line", () => {act(() => root.render(createElement(SidebarWorkingStep, { bot })));expect(phrase()).toBe("Running a command");});++ it("says what a page or write-up makes, still without its name", () => {+ const write = (target: string): Message => ({ id: "w", at: 1, role: "bot", kind: "activity", tool: { name: "Write", step: { activity: "write", target } } });+ act(() => root.render(createElement(SidebarWorkingStep, { bot, last: write("lisbon.html") })));+ expect(phrase()).toBe("Putting the page together");+ });++ it("reads the file's kind from the engine's live status too", () => {+ noteTurnEvent({ eventId: "e2", provider: "claudeAgent", threadId: "t-side", createdAt: "2026-11-07T00:00:00.000Z", turnId: "turn-2",+ type: "turn.progress", activity: "write", itemId: "w2", file: "lisbon-trip.md" } as RuntimeEvent);+ act(() => root.render(createElement(SidebarWorkingStep, { bot: { ...bot, threadId: "t-other" } })));+ expect(phrase()).toBe("Writing it up");+ });++ it("keeps the kind of step for code", () => {+ noteTurnEvent({ eventId: "e3", provider: "claudeAgent", threadId: "t-side", createdAt: "2026-11-07T00:00:00.000Z", turnId: "turn-3",+ type: "turn.progress", activity: "write", itemId: "w3", file: "build.py" } as RuntimeEvent);+ act(() => root.render(createElement(SidebarWorkingStep, { bot })));+ expect(phrase()).toBe("Writing a file");+ });});describe("useHeldText", () => {diff --git a/src/components/SidebarWorkingStep.tsx b/src/components/SidebarWorkingStep.tsxindex accd44495a..e50e309711 100644--- a/src/components/SidebarWorkingStep.tsx+++ b/src/components/SidebarWorkingStep.tsx@@ -3,6 +3,7 @@ import type { Bot, Message } from "@/state/store";import { useTurnLive } from "@/state/turn-status";import { t } from "@/lib/i18n";import { sidebarMessage, sidebarStatus, turnNowPhrases } from "@/lib/live-activity";+import { madeKey } from "@/lib/friendly-activity";/** How long a sidebar line holds one phrase before it may show the next, so a busy bot's row doesn't flicker. */export const SIDEBAR_PHRASE_HOLD_MS = 5000;@@ -33,7 +34,10 @@ export function workingThreadId(bot: Pick<Bot, "threadId" | "tasks">): string {export function SidebarWorkingStep({ bot, last }: { bot: Pick<Bot, "threadId" | "tasks">; last?: Message }) {const threadId = workingThreadId(bot);const live = useTurnLive(threadId);- const phrase = turnNowPhrases(sidebarStatus(live.status), threadId === bot.threadId ? sidebarMessage(last) : undefined)?.phrases[0];+ const message = threadId === bot.threadId ? last : undefined;+ // A page or write-up says what it makes ("Putting the page together"), still without the file's name.+ const made = madeKey(live.status, message);+ const phrase = made ? t(made) : turnNowPhrases(sidebarStatus(live.status), sidebarMessage(message))?.phrases[0];const shown = useHeldText(phrase ?? t("chat.activity.thinking"));return <span dir="auto" data-sidebar-working-phrase="" className="truncate">{shown}</span>;}diff --git a/src/lib/friendly-activity.test.ts b/src/lib/friendly-activity.test.tsindex e2f667402f..d34da604e8 100644--- a/src/lib/friendly-activity.test.ts+++ b/src/lib/friendly-activity.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";import type { Message } from "@/state/store";-import { friendlyNowPhrases, toolService } from "./friendly-activity";+import { friendlyNowPhrases, madeKey, taskSubject, toolService } from "./friendly-activity";const running = (name: string, extra: Partial<NonNullable<Message["tool"]>> = {}): Message =>({ id: "m", role: "bot", kind: "activity", at: 1, tool: { name, ...extra } });@@ -14,7 +14,7 @@ describe("Simple mode's working line", () => {it("names the kind of work in plain words, never a file name or size", () => {expect(friendlyNowPhrases({ activity: "reply" }).phrases).toEqual(["Typing…"]);expect(friendlyNowPhrases({ activity: "command", itemId: "x" }).phrases).toEqual(["Running a few commands"]);- expect(friendlyNowPhrases({ activity: "write", file: "index.html", bytes: 14_000, itemId: "w" }).phrases).toEqual(["Writing some code"]);+ expect(friendlyNowPhrases({ activity: "write", file: "scrape.py", bytes: 14_000, itemId: "w" }).phrases).toEqual(["Writing some code"]);expect(friendlyNowPhrases({ activity: "read", file: "notes.md", itemId: "r" }).phrases).toEqual(["Digging around"]);expect(friendlyNowPhrases({ activity: "web", itemId: "s" }).phrases).toEqual(["Digging around"]);expect(friendlyNowPhrases(null, running("Bash")).phrases).toEqual(["Running a few commands"]);@@ -30,7 +30,7 @@ describe("Simple mode's working line", () => {expect(friendlyNowPhrases({ activity: "command", itemId: "x", target: "scrape.py" }).phrases).toEqual(["Running scrape.py"]);expect(friendlyNowPhrases({ activity: "web", itemId: "s", target: "Acme construction leads" }).phrases).toEqual(["Searching the web for “Acme construction leads”"]);expect(friendlyNowPhrases(null, running("WebFetch", { step: { activity: "fetch", target: "linkedin.com" } })).phrases).toEqual(["Reading linkedin.com"]);- expect(friendlyNowPhrases(null, running("Write", { step: { activity: "write", target: "report.md" } })).phrases).toEqual(["Writing some code"]);+ expect(friendlyNowPhrases(null, running("Write", { step: { activity: "write", target: "report.md" } })).phrases).toEqual(["Writing it up"]);});it("says which outside service the bot is working in", () => {@@ -40,4 +40,44 @@ describe("Simple mode's working line", () => {expect(toolService("Bash")).toBeNull();expect(friendlyNowPhrases(null, running("mcp__notion__search")).phrases).toEqual(["Working in Notion"]);});++ it("says what a page or write-up makes, never the file's name", () => {+ expect(friendlyNowPhrases({ activity: "write", file: "lisbon.html", bytes: 14_000, itemId: "w" }).phrases).toEqual(["Putting the page together"]);+ expect(friendlyNowPhrases({ activity: "edit", target: "site/INDEX.HTM", itemId: "e" }).phrases).toEqual(["Putting the page together"]);+ expect(friendlyNowPhrases({ activity: "write", file: "lisbon-food-trip.md", itemId: "w" }).phrases).toEqual(["Writing it up"]);+ expect(friendlyNowPhrases(null, running("Write", { step: { activity: "write", target: "plan.docx" } })).phrases).toEqual(["Writing it up"]);+ expect(friendlyNowPhrases({ activity: "write", file: "build.py", itemId: "w" }).phrases).toEqual(["Writing some code"]);+ // The engine's report wins over a call still showing in the chat, as for the rest of the line.+ expect(friendlyNowPhrases({ activity: "thinking" }, running("Write", { step: { activity: "write", target: "page.html" } })).phrases[0]).toBe("Thinking it through");+ // A finished call says nothing about now.+ expect(madeKey(null, running("Write", { ok: true, step: { activity: "write", target: "page.html" } }))).toBeNull();+ });++ it("names the conversation's work in place of words that only name the tool", () => {+ const subject = "Lisbon food trip";+ expect(friendlyNowPhrases(null, undefined, subject)).toEqual({ phase: "friendly:task:Lisbon food trip", phrases: ["Working on Lisbon food trip"] });+ expect(friendlyNowPhrases({ activity: "thinking" }, undefined, subject).phrases).toEqual(["Working on Lisbon food trip"]);+ expect(friendlyNowPhrases({ activity: "write", file: "build.py", itemId: "w" }, undefined, subject).phrases).toEqual(["Working on Lisbon food trip"]);+ expect(friendlyNowPhrases({ activity: "command", itemId: "x" }, undefined, subject).phrases).toEqual(["Working on Lisbon food trip"]);+ expect(friendlyNowPhrases(null, running("Bash"), subject).phrases).toEqual(["Working on Lisbon food trip"]);+ // What says more than the tool stays: a page, a search, a reply, a service, the team.+ expect(friendlyNowPhrases({ activity: "write", file: "lisbon.html", itemId: "w" }, undefined, subject).phrases).toEqual(["Putting the page together"]);+ expect(friendlyNowPhrases({ activity: "web", itemId: "s", target: "pastelarias Belém" }, undefined, subject).phrases).toEqual(["Searching the web for “pastelarias Belém”"]);+ expect(friendlyNowPhrases({ activity: "read", file: "notes.md", itemId: "r" }, undefined, subject).phrases).toEqual(["Digging around"]);+ expect(friendlyNowPhrases({ activity: "reply" }, undefined, subject).phrases).toEqual(["Typing…"]);+ expect(friendlyNowPhrases(null, running("delegate_bot"), subject).phrases).toEqual(["Checking in with the team"]);+ expect(friendlyNowPhrases(null, running("mcp__notion__search"), subject).phrases).toEqual(["Working in Notion"]);+ });++ it("takes the conversation's title as its work only once it is more than a stand-in", () => {+ const asked = ["Plan a 2-day food trip to Lisbon: where to eat, what to order. Give me something I can keep and share."];+ expect(taskSubject("Lisbon two-day food trip", asked)).toBe("Lisbon two-day food trip");+ expect(taskSubject("Plan a 2-day food trip to Lisbon: where to eat, w…", asked)).toBeUndefined();+ expect(taskSubject("Plan a 2-day food trip to Lisbon", asked)).toBeUndefined();+ expect(taskSubject("Pasted notes for the trip", ['<pasted-text index="1">\nPasted notes for the trip\n</pasted-text>'])).toBeUndefined();+ expect(taskSubject("New task", [])).toBeUndefined();+ expect(taskSubject("New thread", [])).toBeUndefined();+ expect(taskSubject(" ", [])).toBeUndefined();+ expect(taskSubject(undefined, asked)).toBeUndefined();+ });});diff --git a/src/lib/friendly-activity.ts b/src/lib/friendly-activity.tsindex 52a79522fb..5b7da817bc 100644--- a/src/lib/friendly-activity.ts+++ b/src/lib/friendly-activity.ts@@ -36,19 +36,50 @@ function phrases(phase: string, keys: LocaleKey[]): LiveActivityPhrases {return { phase: `friendly:${phase}`, phrases: keys.map((key) => t(key)) };}+/** A written file's kind, as what it makes for the person: a page or a write-up; code and anything else are neither. */+const MADE: Array<[RegExp, LocaleKey]> = [[/\.html?$/i, "chat.friendly.page"], [/\.(?:md|markdown|txt|rtf|docx?|odt|pdf)$/i, "chat.friendly.writeup"]];++/** What the running write or edit is making, from the engine's report or the call still running in the chat. */+export function madeKey(status: LiveStatus | null, message?: Message): LocaleKey | null {+ const step = message?.kind === "activity" && message.tool?.ok === undefined ? message.tool?.step : undefined;+ // The engine's report wins over the chat's call, as it does for the rest of the line.+ const file = status ? (status.activity === "write" || status.activity === "edit" ? status.file ?? status.target : undefined)+ : step?.activity === "write" || step?.activity === "edit" ? step.target : undefined;+ return (file && MADE.find(([kind]) => kind.test(file))?.[1]) || null;+}++/** Words that name only the tool: the conversation's subject says more. */+const TOOL_TALK: ReadonlySet<LocaleKey> = new Set(["chat.friendly.code", "chat.friendly.commands"]);++const UNTITLED = new Set(["New task", "New thread"]);++/** The conversation's title as the name of the work, once it is more than a placeholder or the opening of one of the+ * person's own messages (the stand-in title a thread gets until its generated one arrives, pasted text included). */+export function taskSubject(title: string | undefined, userTexts: readonly string[]): string | undefined {+ const name = title?.trim();+ if (!name || UNTITLED.has(name)) return undefined;+ const opening = name.replace(/…$/, "");+ return userTexts.some((text) => text.includes(opening)) ? undefined : name;+}+/** Simple mode's one rotating line for what the bot is doing now: plain words in place of file names, sizes and* timers, chosen by the kind of step (a tool's spoken narration is read by its name, as every other step is); a- * command, search or page the server could name is said by name. */-export function friendlyNowPhrases(status: LiveStatus | null, message?: Message): LiveActivityPhrases {+ * command, search or page the server could name is said by name. A page or write-up says what it makes, and the+ * conversation's `subject`, when known, stands in for words that would only name the tool (thinking, code, commands). */+export function friendlyNowPhrases(status: LiveStatus | null, message?: Message, subject?: string): LiveActivityPhrases {const plain = message?.kind === "activity" && message.tool?.spoken ? { ...message, tool: { ...message.tool, spoken: undefined } } : message;const now = turnNowPhrases(status, plain);if (now?.phase.startsWith("step:") || now?.phase.startsWith("notice:")) return now;const tool = (status && "tool" in status ? status.tool : undefined) ?? (message?.kind === "activity" && message.tool?.ok === undefined ? message.tool?.name : undefined);const service = toolService(tool);if (service) return { phase: `friendly:service:${service}`, phrases: [t("chat.friendly.service", { service })] };- if (!now) return phrases("generic", GENERIC);+ const made = madeKey(status, message);+ if (made) return phrases(made, [made]);+ const task = (phase: string, keys: LocaleKey[]) => subject ? { phase: `friendly:task:${subject}`, phrases: [t("chat.friendly.task", { task: subject })] } : phrases(phase, keys);+ if (!now) return task("generic", GENERIC);if (now.phase.startsWith("live:read:")) return phrases("digging", ["chat.friendly.digging"]);- if (now.phase.startsWith("live:")) return phrases("code", ["chat.friendly.code"]);+ if (now.phase.startsWith("live:")) return task("code", ["chat.friendly.code"]);const match = BY_PHASE.find(([phases]) => phases.includes(now.phase));- return match ? phrases(match[1][0]!, match[1]) : phrases("generic", GENERIC);+ if (!match) return task("generic", GENERIC);+ return TOOL_TALK.has(match[1][0]!) ? task(match[1][0]!, match[1]) : phrases(match[1][0]!, match[1]);}diff --git a/src/locales/en.json b/src/locales/en.jsonindex 914f8d3ce2..756be10613 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -2963,6 +2963,9 @@"chat.friendly.clicking": "Clicking around","chat.friendly.team": "Checking in with the team","chat.friendly.service": "Working in {service}",+ "chat.friendly.task": "Working on {task}",+ "chat.friendly.page": "Putting the page together",+ "chat.friendly.writeup": "Writing it up","chat.activity.runCommand": "Running a command","chat.activity.readFile": "Reading a file","chat.activity.writeFile": "Writing a file",diff --git a/src/locales/it.json b/src/locales/it.jsonindex 8dfe385881..8cd455874b 100644--- a/src/locales/it.json+++ b/src/locales/it.json@@ -2953,6 +2953,9 @@"chat.friendly.clicking": "Naviga l'interfaccia","chat.friendly.team": "Si coordina con il team","chat.friendly.service": "Lavora su {service}",+ "chat.friendly.task": "Lavora a «{task}»",+ "chat.friendly.page": "Prepara la pagina",+ "chat.friendly.writeup": "Mette tutto per iscritto","chat.activity.runCommand": "Esegue un comando","chat.activity.readFile": "Legge un file","chat.activity.writeFile": "Scrive un file",diff --git a/src/locales/ja.json b/src/locales/ja.jsonindex d8cc4a87de..c4e4cfbdf6 100644--- a/src/locales/ja.json+++ b/src/locales/ja.json@@ -2429,6 +2429,9 @@"chat.friendly.clicking": "画面を操作中","chat.friendly.team": "チームと連絡中","chat.friendly.service": "{service} で作業中",+ "chat.friendly.task": "「{task}」に取り組み中",+ "chat.friendly.page": "ページを仕上げ中",+ "chat.friendly.writeup": "文章にまとめ中","chat.activity.runCommand": "コマンドを実行中","chat.activity.readFile": "ファイルを読み中","chat.activity.writeFile": "ファイルを書き込み中",diff --git a/src/locales/ko.json b/src/locales/ko.jsonindex 2fba1fcb40..c844e900b7 100644--- a/src/locales/ko.json+++ b/src/locales/ko.json@@ -2317,6 +2317,9 @@"chat.friendly.clicking": "이곳저곳 클릭하는 중","chat.friendly.team": "팀과 확인하는 중","chat.friendly.service": "{service}에서 작업 중",+ "chat.friendly.task": "“{task}” 작업 중",+ "chat.friendly.page": "페이지를 만드는 중",+ "chat.friendly.writeup": "글로 정리하는 중","chat.activity.runCommand": "명령 실행 중","chat.activity.readFile": "파일 읽는 중","chat.activity.writeFile": "파일 쓰는 중",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex 59fefc28b9..245ba91fa0 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -2758,6 +2758,9 @@"chat.friendly.clicking": "Clicando pela tela","chat.friendly.team": "Consultando a equipe","chat.friendly.service": "Trabalhando em {service}",+ "chat.friendly.task": "Trabalhando em “{task}”",+ "chat.friendly.page": "Montando a página",+ "chat.friendly.writeup": "Escrevendo o texto","chat.activity.runCommand": "Executando um comando","chat.activity.readFile": "Lendo um arquivo","chat.activity.writeFile": "Escrevendo um arquivo",diff --git a/src/locales/zh-tw.json b/src/locales/zh-tw.jsonindex 57ab2b79f2..ba89a79c1e 100644--- a/src/locales/zh-tw.json+++ b/src/locales/zh-tw.json@@ -2595,6 +2595,9 @@"chat.friendly.clicking": "正在點選操作","chat.friendly.team": "正在和團隊確認","chat.friendly.service": "正在 {service} 中工作",+ "chat.friendly.task": "正在處理「{task}」",+ "chat.friendly.page": "正在整理頁面",+ "chat.friendly.writeup": "正在寫成文字","chat.activity.runCommand": "正在執行指令","chat.activity.readFile": "正在讀取檔案","chat.activity.writeFile": "正在寫入檔案",diff --git a/src/locales/zh.json b/src/locales/zh.jsonindex 69beecbcd9..3aedc583ba 100644--- a/src/locales/zh.json+++ b/src/locales/zh.json@@ -2688,6 +2688,9 @@"chat.friendly.clicking": "正在到处点击","chat.friendly.team": "正在和团队沟通","chat.friendly.service": "正在 {service} 中处理",+ "chat.friendly.task": "正在处理「{task}」",+ "chat.friendly.page": "正在整理页面",+ "chat.friendly.writeup": "正在写成文字","chat.activity.runCommand": "正在执行命令","chat.activity.readFile": "正在读取文件","chat.activity.writeFile": "正在写入文件",