Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Status line: only a generated title names the work, it rotates, and Advanced stays as it was
milind-soni082b70bf3344
diff --git a/src/components/ChatView.live-status.test.ts b/src/components/ChatView.live-status.test.tsindex 887762b390..b5591da6d7 100644--- a/src/components/ChatView.live-status.test.ts+++ b/src/components/ChatView.live-status.test.ts@@ -123,6 +123,20 @@ describe("Simple mode's working line", () => {expect(statusLine()).toBe("Writing some code");});+ it("rotates the work with the usual words over a long turn, and comes back to it", () => {+ mode.advanced = false;+ engine({ type: "turn.started" });+ render(busyBot([ask]));+ expect(statusLine()).toBe("Working on Dashboard");+ const seen = new Set<string>();+ for (let i = 0; i < 12; i++) {+ act(() => void vi.advanceTimersByTime(6_500));+ seen.add(statusLine()!);+ }+ expect(seen).toContain("Working on Dashboard");+ expect([...seen].some((line) => ["Thinking it through", "Mulling it over", "Working on it", "Chipping away"].includes(line))).toBe(true);+ });+it("says Teammates working while the bot waits on its teammates", () => {mode.advanced = false;const waiting = busyBot([ask, intro], false);diff --git a/src/components/NowCard.tsx b/src/components/NowCard.tsxindex c16d47ee40..471f86eced 100644--- a/src/components/NowCard.tsx+++ b/src/components/NowCard.tsx@@ -51,7 +51,7 @@ export function useTurnNow(bot: Pick<Bot, "id" | "name" | "threadId" | "tasks">,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]);+ : taskSubject(title, messages.flatMap((message) => 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;diff --git a/src/components/SidebarWorkingStep.test.ts b/src/components/SidebarWorkingStep.test.tsindex 65d1f8618b..c9978e1387 100644--- a/src/components/SidebarWorkingStep.test.ts+++ b/src/components/SidebarWorkingStep.test.ts@@ -5,6 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import type { RuntimeEvent } from "../../shared/runtime-events";import type { Message } from "@/state/store";import { noteTurnEvent, resetTurnLive } from "@/state/turn-status";+import { setAdvancedMode } from "@/lib/interface-mode";import { SidebarWorkingStep, useHeldText } from "./SidebarWorkingStep";(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;@@ -43,6 +44,18 @@ describe("sidebar working line", () => {expect(phrase()).toBe("Writing it up");});+ it("keeps Advanced mode's words for a page as they were", () => {+ setAdvancedMode(true);+ try {+ const write: Message = { id: "w", at: 1, role: "bot", kind: "activity", tool: { name: "Write", step: { activity: "write", target: "lisbon.html" } } };+ act(() => root.render(createElement(SidebarWorkingStep, { bot, last: write })));+ expect(phrase()).toBe("Writing a file");+ } finally {+ setAdvancedMode(false);+ localStorage.clear();+ }+ });+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);diff --git a/src/components/SidebarWorkingStep.tsx b/src/components/SidebarWorkingStep.tsxindex e50e309711..45c436f550 100644--- a/src/components/SidebarWorkingStep.tsx+++ b/src/components/SidebarWorkingStep.tsx@@ -4,6 +4,7 @@ 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";+import { useAdvancedMode } from "@/lib/interface-mode";/** 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;@@ -35,8 +36,8 @@ export function SidebarWorkingStep({ bot, last }: { bot: Pick<Bot, "threadId" |const threadId = workingThreadId(bot);const live = useTurnLive(threadId);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);+ // Simple mode: a page or write-up says what it makes ("Putting the page together"), still without the file's name.+ const made = useAdvancedMode() ? null : 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 2e7fc6aaa5..7d3f16da16 100644--- a/src/lib/friendly-activity.test.ts+++ b/src/lib/friendly-activity.test.ts@@ -50,17 +50,29 @@ describe("Simple mode's working line", () => {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");+ // The bot's own notes, a project's files and plain text are not a write-up for the person.+ for (const file of ["MEMORY.md", "SOUL.md", "README.md", "notes.md", "todo.md", "2026-11-26.md", ".plan.md", "requirements.txt", "robots.txt", "notes.txt"]) {+ expect(friendlyNowPhrases({ activity: "write", file, itemId: "w" }).phrases, file).toEqual(["Writing some code"]);+ }+ for (const path of ["/work/.claude/plan.md", "/bots/kiwi/memory/trip.md", "/bots/kiwi/skills/trip/guide.md", "C:\\Users\\ana\\.claude\\plan.md", "d:\\bots\\kiwi\\memory\\trip.md"]) {+ expect(madeKey(null, running("Write", { input: JSON.stringify({ file_path: path, content: "# Notes" }), step: { activity: "write", target: path.split(/[\\/]/).pop()! } })), path).toBeNull();+ }+ expect(madeKey(null, running("Write", { input: JSON.stringify({ file_path: "C:\\Users\\ana\\Documents\\trip-plan.md" }), step: { activity: "write", target: "trip-plan.md" } }))).toBe("chat.friendly.writeup");+ expect(madeKey(null, running("Write", { input: JSON.stringify({ file_path: "/work/lisbon/trip-plan.md", content: "# Lisbon" }), step: { activity: "write", target: "trip-plan.md" } }))).toBe("chat.friendly.writeup");// 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"]);+ const work = "Working on Lisbon food trip";+ // The work leads, and the usual words still rotate after it so a long turn's line never sits still.+ expect(friendlyNowPhrases(null, undefined, subject)).toEqual({ phase: "friendly:task:Lisbon food trip",+ phrases: [work, "Thinking it through", "Mulling it over", "Working on it", "Chipping away"] });+ expect(friendlyNowPhrases({ activity: "thinking" }, undefined, subject).phrases[0]).toBe(work);+ expect(friendlyNowPhrases({ activity: "write", file: "build.py", itemId: "w" }, undefined, subject).phrases).toEqual([work, "Writing some code"]);+ expect(friendlyNowPhrases({ activity: "command", itemId: "x" }, undefined, subject).phrases).toEqual([work, "Running a few commands"]);+ expect(friendlyNowPhrases(null, running("Bash"), subject).phrases).toEqual([work, "Running a few commands"]);// 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”"]);@@ -82,6 +94,20 @@ describe("Simple mode's working line", () => {// Cut short, the stand-in ends in "…" even when the message it came from is not loaded.expect(taskSubject("Plan a 2-day food trip to Lisbon: where to eat, w…", [])).toBeUndefined();expect(taskSubject(" ", [])).toBeUndefined();+ expect(taskSubject("Conversation", [])).toBeUndefined();+ // Titles the app makes for hand-offs, rooms and routines: the hand-off's prefix is dropped, the rest is not the work.+ expect(taskSubject("@Pepper · Lisbon restaurant shortlist", [])).toBe("Lisbon restaurant shortlist");+ expect(taskSubject("@Pepper · work", [])).toBeUndefined();+ expect(taskSubject("From Pepper", [])).toBeUndefined();+ expect(taskSubject("Planning room · find a date", [])).toBeUndefined();+ expect(taskSubject("Weekly digest · Results", [])).toBeUndefined();+ // A brief cut at 60 characters, and a fork named from a bot's message.+ expect(taskSubject("Find three restaurants near Alfama open on Sunday nights and", [])).toBeUndefined();+ expect(taskSubject("# Day 1: Baixa and Alfama", [])).toBeUndefined();+ expect(taskSubject("Here's your two-day plan:", ["Here's your two-day plan:\n- Day 1"])).toBeUndefined();+ // A question reads as the work, without its question mark.+ expect(taskSubject("Best pastries in Lisbon?", [])).toBe("Best pastries in Lisbon");+ expect(taskSubject("What should I eat in Lisbon?", ["What should I eat in Lisbon?"])).toBeUndefined();expect(taskSubject(undefined, asked)).toBeUndefined();});});diff --git a/src/lib/friendly-activity.ts b/src/lib/friendly-activity.tsindex 773322fe71..147fa4e0c7 100644--- a/src/lib/friendly-activity.ts+++ b/src/lib/friendly-activity.ts@@ -37,31 +37,55 @@ 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"]];+/** Documents a person reads; a Markdown file only when it isn't the bot's own notes or a project's file (below). */+const DOCUMENT = /\.(?:docx?|odt|rtf|pdf)$/i;+const MARKDOWN = /\.(?:md|markdown)$/i;+/** Hidden, memory, notes and skills folders hold the bot's own files, never the person's write-up. */+const OWN_FOLDER = /(?:^|[\\/])(?:\.[^\\/]*|memory|memories|notes|skills|node_modules)[\\/]/i;+/** MEMORY.md, SOUL.md, README.md and the like, a dated journal, or a notes file: the bot's or a project's own. */+const OWN_MARKDOWN = /^(?:\.|[A-Z0-9_-]+\.|\d{4}-\d{2}-\d{2}|(?:notes?|memory|todo|scratch|changelog|readme)\.)/;-/** What the running write or edit is making, from the engine's report or the call still running in the chat. */+function madeOf(file: string, path: string | undefined): LocaleKey | null {+ if (/\.html?$/i.test(file)) return "chat.friendly.page";+ if (DOCUMENT.test(file)) return "chat.friendly.writeup";+ if (!MARKDOWN.test(file) || OWN_MARKDOWN.test(file) || (path && OWN_FOLDER.test(path))) return null;+ return "chat.friendly.writeup";+}++/** What the running write or edit is making for the person, from the engine's report or the call still running in the+ * chat: a page, a write-up, or (null) code, notes and anything else. */export function madeKey(status: LiveStatus | null, message?: Message): LocaleKey | null {- const step = message?.kind === "activity" && message.tool?.ok === undefined ? message.tool?.step : undefined;+ const tool = message?.kind === "activity" && message.tool?.ok === undefined ? message.tool : undefined;+ const step = tool?.step;// 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;+ if (!file) return null;+ // The call's input arrives as JSON text, its path near the start: read just that, never parse a whole file's content.+ const path = /"(?:file_path|path)"\s*:\s*"((?:[^"\\]|\\.){1,500})"/.exec(tool?.input?.slice(0, 2_000) ?? "")?.[1];+ return madeOf(file.replace(/…$/, ""), path);}/** 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"]);/** Titles the app gives a conversation itself (task-title.ts localizes the last two). */-const FACTORY_TITLES: ReadonlySet<string> = new Set(["New task", "New thread", SHARED_CHAT_TITLE]);+const FACTORY_TITLES: ReadonlySet<string> = new Set(["New task", "New thread", "Conversation", "work", SHARED_CHAT_TITLE]);+/** A generated title is 3 to 6 words; a longer one is a hand-off's brief or a message's opening cut short. */+const TITLE_MAX = 48;-/** The conversation's title as the name of the work, once it is more than a factory title 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; cut- * short, it ends in "…", which a generated title never does). */-export function taskSubject(title: string | undefined, userTexts: readonly string[]): string | undefined {- const name = title?.trim();- if (!name || FACTORY_TITLES.has(name) || name.endsWith("…")) return undefined;- return userTexts.some((text) => text.includes(name)) ? undefined : name;+/** The conversation's title as the name of the work, only when it is a title the engine generated. Anything else, or+ * anything unsure, is undefined and the line keeps today's words: a factory title; a hand-off thread's "@Bot · " prefix+ * is dropped first, and any other " · " title is the app's own (a room job, a routine's results); "From <bot>"; a title+ * starting with "#" or "@"; one longer than a generated title, or cut short with "…"; or the start of a line in one of+ * the conversation's messages (the stand-in title a thread or fork takes from a message until its generated one+ * arrives, pasted text included). A trailing ?, ! or . is left out, so a question reads as the work. */+export function taskSubject(title: string | undefined, texts: readonly string[]): string | undefined {+ const name = title?.trim().replace(/^@[^·]{1,80} · /, "").replace(/[?!.?!。]+$/u, "").trim();+ if (!name || FACTORY_TITLES.has(name) || name.length > TITLE_MAX || name.endsWith("…") || name.includes(" · ")) return undefined;+ if (/^(?:#|@|From\s)/.test(name)) return undefined;+ const raw = title!.trim().replace(/^@[^·]{1,80} · /, "");+ return texts.some((text) => text.split("\n").some((line) => line.trim().startsWith(raw) || line.trim().startsWith(name))) ? undefined : name;}/** Simple mode's one rotating line for what the bot is doing now: plain words in place of file names, sizes and@@ -77,7 +101,9 @@ export function friendlyNowPhrases(status: LiveStatus | null, message?: Message,if (service) return { phase: `friendly:service:${service}`, phrases: [t("chat.friendly.service", { service })] };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);+ // The work leads and the usual words still rotate after it, so a long turn's line never sits still.+ const task = (phase: string, keys: LocaleKey[]) => subject+ ? { phase: `friendly:task:${subject}`, phrases: [t("chat.friendly.task", { task: subject }), ...keys.map((key) => t(key))] } : 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 task("code", ["chat.friendly.code"]);diff --git a/src/locales/ja.json b/src/locales/ja.jsonindex c4e4cfbdf6..a207d38976 100644--- a/src/locales/ja.json+++ b/src/locales/ja.json@@ -2430,7 +2430,7 @@"chat.friendly.team": "チームと連絡中","chat.friendly.service": "{service} で作業中","chat.friendly.task": "「{task}」に取り組み中",- "chat.friendly.page": "ページを仕上げ中",+ "chat.friendly.page": "ページを作成中","chat.friendly.writeup": "文章にまとめ中","chat.activity.runCommand": "コマンドを実行中","chat.activity.readFile": "ファイルを読み中",diff --git a/src/locales/zh-tw.json b/src/locales/zh-tw.jsonindex ba89a79c1e..35936ec338 100644--- a/src/locales/zh-tw.json+++ b/src/locales/zh-tw.json@@ -2596,8 +2596,8 @@"chat.friendly.team": "正在和團隊確認","chat.friendly.service": "正在 {service} 中工作","chat.friendly.task": "正在處理「{task}」",- "chat.friendly.page": "正在整理頁面",- "chat.friendly.writeup": "正在寫成文字",+ "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 3aedc583ba..4ddb4b14e9 100644--- a/src/locales/zh.json+++ b/src/locales/zh.json@@ -2689,8 +2689,8 @@"chat.friendly.team": "正在和团队沟通","chat.friendly.service": "正在 {service} 中处理","chat.friendly.task": "正在处理「{task}」",- "chat.friendly.page": "正在整理页面",- "chat.friendly.writeup": "正在写成文字",+ "chat.friendly.page": "正在制作页面",+ "chat.friendly.writeup": "正在撰写","chat.activity.runCommand": "正在执行命令","chat.activity.readFile": "正在读取文件","chat.activity.writeFile": "正在写入文件",