Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Chat UI: make routine run headers scannable boundaries
jonathanwxh-cell66ab76ebbdab
diff --git a/src/components/ChatView.automation.test.ts b/src/components/ChatView.automation.test.tsindex 4a28b3a1be..3ea77ff975 100644--- a/src/components/ChatView.automation.test.ts+++ b/src/components/ChatView.automation.test.ts@@ -127,6 +127,23 @@ describe("an automation's line in the chat", () => {expect(caption("m2")).toBeNull();});+ it("gives the routine header a scannable pill-and-divider boundary above the reply without tucking into the message before it", async () => {+ await draw(transcript([{ id: "r1", parentId: "m2", role: "bot", kind: "text", text: "# Morning Summary\n\nAll systems normal.", at: at(3), automation: line("run-1") }]));+ const label = caption("run-1")!;+ expect(label.className).toContain("mt-2");+ expect(label.className).not.toContain("text-[11px]");+ expect(label.querySelector("[data-automation-rule]")?.getAttribute("aria-hidden")).toBe("true");+ const badge = label.querySelector<HTMLElement>("[data-automation-badge]")!;+ expect(badge.className).toContain("ui-chip");+ expect(badge.className).toContain("bg-panel");+ expect(badge.textContent).toContain("Inbox brief");+ expect(badge.querySelector<HTMLElement>('[title="Inbox brief"]')?.textContent).toBe("Inbox brief");+ const open = badge.querySelector<HTMLButtonElement>("button")!;+ expect(open.className).toContain("motion-reduce:transition-none");+ expect(open.className).toContain("focus-visible:outline-focus");+ expect(document.querySelector('[data-mid="r1"]')?.hasAttribute("data-tuck")).toBe(false);+ });+it("says when the run needs the person or could not finish, and offers no run it cannot open", async () => {await draw(transcript([{ id: "r1", parentId: "m2", role: "bot", kind: "text", text: "Should I send it?", at: at(3), automation: line("run-1", { needsYou: true }) },diff --git a/src/components/RoutineRunCard.tsx b/src/components/RoutineRunCard.tsxindex 5948ef104f..ddf35ede6c 100644--- a/src/components/RoutineRunCard.tsx+++ b/src/components/RoutineRunCard.tsx@@ -149,22 +149,26 @@ export function AutomationCaption({ message, line, botId }: { message: Message;const asking = line.needsYou === true && (message.card ? liveCardKind(message.card) !== null : line.copyOf !== undefined ||!state.bots.find((bot) => bot.id === botId)?.messages.some((later) => later.role === "user" && later.at > message.at));const tone = line.partial ? "text-warning" : line.failed ? "text-danger" : asking ? "text-warning" : "text-accent";+ const chipBorder = line.partial || asking ? "border-warning/35" : line.failed ? "border-danger/35" : "border-hairline/60";return (- <div data-automation-caption={line.runId} className="-mb-2 flex min-w-0 items-center gap-1.5 pl-0.5 text-[11px] text-ink-tertiary">- <Zap aria-hidden="true" size={12} className={cn("shrink-0", tone)} />- <span className="truncate font-medium text-ink-secondary">{line.name}</span>- <time className="shrink-0" dateTime={new Date(line.scheduledFor).toISOString()}>· {formatTime(line.scheduledFor)}</time>- {(line.failed || asking) && <span className={cn("shrink-0", tone)}>· {t(line.partial ? "chat.automation.partial" : line.failed ? "chat.automation.failed" : "chat.automation.needsYou")}</span>}- {canOpen && (- <button- type="button"- onClick={() => openThread(dispatch, { botId, threadId: line.executionThreadId }, state, showThreads)}- aria-label={t("chat.automation.openRunFor", { name: line.name })}- className="shrink-0 rounded px-1 hover:bg-inset hover:text-ink focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent"- >- {t("chat.automation.openRun")}- </button>- )}+ <div data-automation-caption={line.runId} className="mt-2 -mb-1 flex w-full min-w-0 items-center gap-2 text-[12px] leading-4 text-ink-secondary">+ <span data-automation-badge className={cn("ui-chip gap-1.5 border bg-panel px-2.5 text-ink-secondary", chipBorder)}>+ <Zap aria-hidden="true" size={12} className={cn("shrink-0", tone)} />+ <span dir="auto" title={line.name} className="truncate font-medium text-ink">{line.name}</span>+ <time className="shrink-0 text-ink-secondary" dateTime={new Date(line.scheduledFor).toISOString()}>· {formatTime(line.scheduledFor)}</time>+ {(line.failed || asking) && <span className={cn("shrink-0", tone)}>· {t(line.partial ? "chat.automation.partial" : line.failed ? "chat.automation.failed" : "chat.automation.needsYou")}</span>}+ {canOpen && (+ <button+ type="button"+ onClick={() => openThread(dispatch, { botId, threadId: line.executionThreadId }, state, showThreads)}+ aria-label={t("chat.automation.openRunFor", { name: line.name })}+ className="ms-0.5 shrink-0 cursor-pointer rounded px-1 font-medium text-ink-secondary transition-colors motion-reduce:transition-none hover:bg-raised-hover hover:text-ink focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus"+ >+ {t("chat.automation.openRun")}+ </button>+ )}+ </span>+ <span aria-hidden="true" data-automation-rule className="h-px min-w-4 flex-1 bg-hairline/60" /></div>);}diff --git a/src/components/chat-bubble.test.ts b/src/components/chat-bubble.test.tsindex 68924ecd91..f9c48b52d1 100644--- a/src/components/chat-bubble.test.ts+++ b/src/components/chat-bubble.test.ts@@ -1,5 +1,26 @@import { describe, expect, it } from "vitest";-import { BOT_BUBBLE_FINISH, joinedCorners, plainBotBubble, SIMPLE_BOT_BUBBLE, SIMPLE_STACKED, SIMPLE_USER_BUBBLE } from "./chat-bubble";+import type { TranscriptItem } from "@/lib/activity-runs";+import type { Message } from "@/state/store";+import { BOT_BUBBLE_FINISH, joinedCorners, plainBotBubble, SIMPLE_BOT_BUBBLE, SIMPLE_STACKED, SIMPLE_USER_BUBBLE, simpleRowLayout } from "./chat-bubble";++describe("simple row layout around routine messages", () => {+ it("never tucks an automation row under the bot message or card above it and keeps bubble joins broken", () => {+ const base = new Date(2026, 9, 21, 9, 0).getTime();+ const automation = { routineId: "inbox", runId: "run-1", name: "Inbox brief", trigger: "schedule" as const, executionThreadId: "run-thread", scheduledFor: base };+ const botReply: Message = { id: "b1", parentId: null, role: "bot", kind: "text", text: "Previous reply.", at: base + 1_000 };+ const botCard: Message = { id: "c1", parentId: "b1", role: "bot", kind: "options", at: base + 2_000, card: { title: "Question", subtitle: "Pick one", options: ["A"], requestId: "q1", requestType: "question", answered: "A" } };+ const routineAfterReply: Message = { id: "a1", parentId: "b1", role: "bot", kind: "text", text: "Routine reply.", at: base + 3_000, automation };+ const routineAfterCard: Message = { id: "a2", parentId: "c1", role: "bot", kind: "text", text: "Routine after card.", at: base + 4_000, automation };+ const items = (rows: Message[]): TranscriptItem[] => rows.map((message) => ({ kind: "message", id: message.id, message }));++ const afterReply = simpleRowLayout(items([botReply, routineAfterReply]), { botId: "pepper", showToolCalls: false, unreadIds: null });+ expect(afterReply.tucks).toEqual([false, false]);+ expect(afterReply.joins).toEqual([{ above: false, below: false }, { above: false, below: false }]);++ const afterCard = simpleRowLayout(items([botReply, botCard, routineAfterCard]), { botId: "pepper", showToolCalls: false, unreadIds: null });+ expect(afterCard.tucks).toEqual([false, true, false]);+ });+});describe("a run of one sender's bubbles", () => {it("gives each bubble in the run a 6px tail at its bottom corner on its own side, and keeps the top corners round", () => {diff --git a/src/components/chat-bubble.ts b/src/components/chat-bubble.tsindex 9e176222b8..651482e144 100644--- a/src/components/chat-bubble.ts+++ b/src/components/chat-bubble.ts@@ -101,13 +101,13 @@ export function bubbleJoins(slots: readonly TranscriptSlot[]): BubbleJoin[] {}/** Simple mode: a card sits 12px under its own bot's bubble, and a bubble 12px under its card, instead of the 16px- * between senders. Two bubbles join instead, and a stamp between rows keeps the full gap. */+ * between senders. Two bubbles join instead, and a stamp or boundary caption between rows keeps the full gap. */export function cardTucks(slots: readonly TranscriptSlot[]): boolean[] {const tucks = slots.map(() => false);let previous: TranscriptSlot | null = null;slots.forEach((slot, index) => {if (slot.hidden) return;- tucks[index] = Boolean(previous && slot.sender && slot.sender === previous.sender && !slot.stamped && !previous.breakAfter && !(slot.group && previous.group));+ tucks[index] = Boolean(previous && slot.sender && slot.sender === previous.sender && !slot.stamped && !slot.breakBefore && !previous.breakAfter && !(slot.group && previous.group));previous = slot;});return tucks;