Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(#6482): keep ChatView at its pinned size, add pt-BR, drop the committed demo media

milind-soni4509a11b7a77
diff --git a/docs/verification/screenshots/chat-activity-closed.jpg b/docs/verification/screenshots/chat-activity-closed.jpg
deleted file mode 100644
index 5e13baf9ea..0000000000
Binary files a/docs/verification/screenshots/chat-activity-closed.jpg and /dev/null differ
diff --git a/docs/verification/screenshots/chat-activity-open.jpg b/docs/verification/screenshots/chat-activity-open.jpg
deleted file mode 100644
index 5e13baf9ea..0000000000
Binary files a/docs/verification/screenshots/chat-activity-open.jpg and /dev/null differ
diff --git a/docs/verification/videos/advanced-run-logs.mp4 b/docs/verification/videos/advanced-run-logs.mp4
deleted file mode 100644
index fda20c860d..0000000000
Binary files a/docs/verification/videos/advanced-run-logs.mp4 and /dev/null differ
diff --git a/src/components/ChatActivity.tsx b/src/components/ChatActivity.tsx
new file mode 100644
index 0000000000..d9e0a3d666
--- /dev/null
+++ b/src/components/ChatActivity.tsx
@@ -0,0 +1,81 @@
+import { useMemo, useState, type CSSProperties } from "react";
+import { List } from "lucide-react";
+import { Switch } from "./SettingsPrimitives";
+import { t } from "@/lib/i18n";
+import type { Message } from "@/state/store";
+import { useStoreDispatch } from "@/state/store-select";
+
+/** Advanced mode's "Chat activity": whether routine updates and finished tool entries show in the chat, kept on this device. */
+export interface ChatActivity {
+ routines: boolean;
+ tools: boolean;
+ toggleRoutines(): void;
+ toggleTools(): void;
+}
+
+function useVisibility(key: string) {
+ const [visible, setVisible] = useState(() => {
+ try { return localStorage.getItem(key) !== "hide"; }
+ catch { return true; }
+ });
+ const toggle = () => {
+ setVisible(!visible);
+ try { localStorage.setItem(key, visible ? "hide" : "show"); }
+ catch { /* Keep the preference for this visit. */ }
+ };
+ return [visible, toggle] as const;
+}
+
+export function useChatActivity(): ChatActivity {
+ const [routines, toggleRoutines] = useVisibility("omb-advanced-chat-automation");
+ const [tools, toggleTools] = useVisibility("omb-advanced-chat-tools");
+ // One object per pair of choices, so the chat's filtered list changes only when a switch does.
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- each toggle is fresh exactly when its value changes
+ return useMemo(() => ({ routines, tools, toggleRoutines, toggleTools }), [routines, tools]);
+}
+
+/** The messages the chat draws: everything outside Advanced mode; there, without what the person hid. Anything that
+ * still needs the person (a pending approval, a waiting or failed run) always stays. */
+export function chatActivityMessages(messages: Message[], advanced: boolean, activity: ChatActivity, pinnedMessageId?: string): Message[] {
+ if (!advanced || (activity.routines && activity.tools)) return messages;
+ return messages.filter((message) => {
+ if (message.role !== "bot" || message.id === pinnedMessageId) return true;
+ const approval = message.kind === "options" && message.card?.requestId && message.card.tool ? message.card : undefined;
+ if (approval && !approval.answered && !approval.dismissed && !approval.expired) return true;
+ if (approval && !activity.tools) return false;
+ if (activity.routines) return true;
+ if (message.kind === "routine.run") return message.routineRun?.status === "waiting" || message.routineRun?.status === "failed";
+ return !message.automation || Boolean(message.automation.needsYou || message.automation.failed || message.automation.partial || message.automation.copyOf);
+ });
+}
+
+/** The chat header's Chat activity button and, once opened, its two switches and the way to the bot's run history. */
+export function ChatActivityControls({ activity, botId, style }: { activity: ChatActivity; botId: string; style?: CSSProperties }) {
+ const dispatch = useStoreDispatch();
+ const [open, setOpen] = useState(false);
+ return (
+ <section aria-label={t("chat.automation.activity")} className="flex min-w-0 flex-wrap items-center gap-1.5" style={style}>
+ <button
+ type="button"
+ aria-expanded={open}
+ onClick={() => setOpen((was) => !was)}
+ className="ui-pill shrink-0"
+ ><List size={14} aria-hidden="true" />{t("chat.automation.activity")}</button>
+ {open && (
+ <section className="chat-run-log-actions flex min-w-0 flex-wrap items-center gap-1.5">
+ <label className="ui-pill shrink-0">
+ {t("chat.automation.showInChat")}
+ <Switch compact aria-label={t("chat.automation.showInChat")} checked={activity.routines} onClick={activity.toggleRoutines} />
+ </label>
+ <label className="ui-pill shrink-0">
+ {t("chat.automation.showTools")}
+ <Switch compact aria-label={t("chat.automation.showTools")} checked={activity.tools} onClick={activity.toggleTools} />
+ </label>
+ <button type="button" className="ui-pill" onClick={() => dispatch({ type: "showRoutines", section: "logs", botId })}>
+ {t("chat.automation.openLogs")}
+ </button>
+ </section>
+ )}
+ </section>
+ );
+}
diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsx
index 673bd8cff9..6251016d34 100644
--- a/src/components/ChatView.tsx
+++ b/src/components/ChatView.tsx
@@ -1,10 +1,9 @@
-import { Switch } from "./SettingsPrimitives";
import { createContext, memo, use, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type Dispatch, type ReactNode } from "react";
import { useAdvancedMode } from "@/lib/interface-mode";
import { PHONE_LAYOUT, useMediaQuery } from "@/lib/use-media-query";
import { ThreadLinkContext } from "@/components/ThreadLinkMenu";
import { useShowThreads } from "@/lib/thread-preferences";
-import { AlertTriangle, ChevronLeft, ChevronRight, List, Monitor, RefreshCw, Square, Webhook } from "lucide-react";
+import { AlertTriangle, ChevronLeft, ChevronRight, Monitor, RefreshCw, Square, Webhook } from "lucide-react";
import { WorkingDots } from "@/components/WorkingIndicator";
import { ChatBusyContext, CopyButton, MESSAGE_ROW, MessageActions, messageActionClass, ReplyAction } from "@/components/MessageActions";
import { ReactAction, ReactionChips } from "@/components/Reactions";
@@ -93,7 +92,7 @@ import { AttachmentGallery, collectMessageFiles, replyAttachmentGroup, splitMess
import { ScreenFrame } from "./ScreenFrame";
import { CompactionChip, DigestChip } from "./DigestChip";
import { RenameTitle } from "./RenameTitle"; import { ChatHeadRole, chiefOfStaffBadge } from "./BotRole";
-import { BotActivityPicker } from "./TaskPicker"; import { ChatHeadPill } from "./ChatHeadPill"; import { HeaderShare } from "./bot-access/HeaderShare"; import { ThreadPresenceFaces } from "./TeamPresence"; import { useStoreRef } from "@/state/store-ref"; import { sameFields, useStoreDispatch, useStoreSelector } from "@/state/store-select"; import { sameDrawnBots } from "@/lib/drawn-bots";
+import { BotActivityPicker } from "./TaskPicker"; import { ChatHeadPill } from "./ChatHeadPill"; import { HeaderShare } from "./bot-access/HeaderShare"; import { ThreadPresenceFaces } from "./TeamPresence"; import { useStoreRef } from "@/state/store-ref"; import { sameFields, useStoreDispatch, useStoreSelector } from "@/state/store-select"; import { sameDrawnBots } from "@/lib/drawn-bots"; import { ChatActivityControls, chatActivityMessages, useChatActivity } from "./ChatActivity";
import { ELEVATED_FLOAT, ELEVATED_HOVER } from "./elevated";
import { ModelPicker } from "./ModelPicker"; import { useFailedTurnFix } from "./FailedTurnFix";
import { ChatHeaderMenu, ChatMoreMenu } from "./ChatMoreMenu"; import { TeamOwnHelperHeader, TeamPrivateFirstLine, TeamPrivateHeader, TeamSharedHeader } from "./TeamPrivateChatsLine"; import { ownChatStarted } from "@/state/team-chats";
@@ -796,19 +795,6 @@ const MessagesList = memo(function MessagesList({
const CHATHEAD_PILL = `flex min-w-0 items-center gap-2 rounded-full py-0.5 pl-1.5 text-ink ${ELEVATED_FLOAT}`;
-function useChatActivityVisibility(key: string) {
- const [visible, setVisible] = useState(() => {
- try { return localStorage.getItem(key) !== "hide"; }
- catch { return true; }
- });
- const toggle = () => {
- setVisible(!visible);
- try { localStorage.setItem(key, visible ? "hide" : "show"); }
- catch { /* Keep the preference for this visit. */ }
- };
- return [visible, toggle] as const;
-}
-
export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = false }: { bot: Bot; inForkPanel?: boolean }) {
const bot = useMemo(() => currentTaskBot(profile), [profile]);
const state = useStoreSelector((s) => ({ computerStart: s.computerStarts[profile.id], mascotMotion: s.mascotMotion?.botId === profile.id ? s.mascotMotion : null, instances: s.instances, config: s.config, focusMessage: s.focusMessage, forkPanelOpen: s.forkPanel !== null, settingsOpen: s.settingsOpen, computerOpen: s.computerOpen, error: s.error, notice: s.notice }), sameFields), dispatch = useStoreDispatch(), store = useStoreRef();
@@ -819,11 +805,7 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal
const composerDock = useComposerDockPad(composerDockRef);
// An opened page fills the messages area, between the header and the message box, which stays usable.
const [pagePane, setPagePane] = useState<HTMLDivElement | null>(null);
- const advanced = useAdvancedMode();
- const [automationLogsOpen, setAutomationLogsOpen] = useState(false);
- const [showAutomationInChat, toggleAutomationInChat] = useChatActivityVisibility("omb-advanced-chat-automation");
- const [showToolsInChat, toggleToolsInChat] = useChatActivityVisibility("omb-advanced-chat-tools");
- useEffect(() => setAutomationLogsOpen(false), [bot.threadId]);
+ const advanced = useAdvancedMode(), activity = useChatActivity();
const phone = useMediaQuery(PHONE_LAYOUT);
const phoneMenu = phone && !remoteClient;
const simpleHead = !advanced && !remoteClient;
@@ -842,19 +824,7 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal
useChatFindShortcut(inForkPanel, state.forkPanelOpen, setFindOpen);
const { messages: allMessages, activeLeafId } = bot;
- const messages = useMemo(() => visibleMessages({ messages: allMessages, activeLeafId }), [allMessages, activeLeafId]);
- const chatMessages = useMemo(() => {
- if (!advanced || (showAutomationInChat && showToolsInChat)) return messages;
- return messages.filter((message) => {
- if (message.role !== "bot" || message.id === bot.pinnedMessageId) return true;
- const approval = message.kind === "options" && message.card?.requestId && message.card.tool ? message.card : undefined;
- if (approval && !approval.answered && !approval.dismissed && !approval.expired) return true;
- if (approval && !showToolsInChat) return false;
- if (showAutomationInChat) return true;
- if (message.kind === "routine.run") return message.routineRun?.status === "waiting" || message.routineRun?.status === "failed";
- return !message.automation || Boolean(message.automation.needsYou || message.automation.failed || message.automation.partial || message.automation.copyOf);
- });
- }, [advanced, showAutomationInChat, showToolsInChat, messages, bot.pinnedMessageId]);
+ const messages = useMemo(() => visibleMessages({ messages: allMessages, activeLeafId }), [allMessages, activeLeafId]), chatMessages = useMemo(() => chatActivityMessages(messages, advanced, activity, bot.pinnedMessageId), [advanced, activity, messages, bot.pinnedMessageId]);
const lookups = useMemo(() => transcriptLookups(allMessages, messages), [allMessages, messages]);
const liveTools = useLiveToolIds(messages, bot);
const recordedRun = useMemo(() => runSteps(messages, liveTools), [messages, liveTools]);
@@ -898,7 +868,7 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal
const bots = useStoreSelector((s) => s.bots, sameDrawnBots);
const teammates = useTeammates(); const mentionPeers = useMemo(() => [...bots.filter((peer) => peer.id !== bot.id), ...teammates.peers], [bots, bot.id, teammates]);
const focus = state.focusMessage?.threadId === bot.threadId ? state.focusMessage : null;
- const showToolCalls = showToolCallsEnabled(state.config) && (!advanced || showToolsInChat);
+ const showToolCalls = showToolCallsEnabled(state.config) && (!advanced || activity.tools);
const tts = state.config?.tts;
const localVoice = localSystemVoiceActive();
const locale = activeLocale();
@@ -1023,32 +993,7 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal
simpleHead ? "px-5 pt-2.5 pb-2.5 max-md:pl-14 max-md:pr-3" : "px-5 py-3 pl-11 md:pl-5 max-md:pl-14 max-md:pr-3",
)}
>
- <div data-chathead-row className={cn("flex items-center justify-between", phone ? "gap-2" : "@max-[30rem]/chathead:flex-wrap @max-[30rem]/chathead:gap-y-1 @min-[30rem]/chathead:grid @min-[30rem]/chathead:grid-cols-[minmax(0,1fr)_minmax(0,auto)_minmax(max-content,1fr)]")}>
- {advanced && !inForkPanel && (
- <section aria-label={t("chat.automation.activity")} className="flex min-w-0 flex-wrap items-center gap-1.5" style={headerNoDragStyle}>
- <button
- type="button"
- aria-expanded={automationLogsOpen}
- onClick={() => setAutomationLogsOpen((open) => !open)}
- className="ui-pill shrink-0"
- ><List size={14} aria-hidden="true" />{t("chat.automation.activity")}</button>
- {automationLogsOpen && (
- <section className="chat-run-log-actions flex min-w-0 flex-wrap items-center gap-1.5">
- <label className="ui-pill shrink-0">
- {t("chat.automation.showInChat")}
- <Switch compact aria-label={t("chat.automation.showInChat")} checked={showAutomationInChat} onClick={toggleAutomationInChat} />
- </label>
- <label className="ui-pill shrink-0">
- {t("chat.automation.showTools")}
- <Switch compact aria-label={t("chat.automation.showTools")} checked={showToolsInChat} onClick={toggleToolsInChat} />
- </label>
- <button type="button" className="ui-pill" onClick={() => dispatch({ type: "showRoutines", section: "logs", botId: bot.id })}>
- {t("chat.automation.openLogs")}
- </button>
- </section>
- )}
- </section>
- )}
+ <div data-chathead-row className={cn("flex items-center justify-between", phone ? "gap-2" : "@max-[30rem]/chathead:flex-wrap @max-[30rem]/chathead:gap-y-1 @min-[30rem]/chathead:grid @min-[30rem]/chathead:grid-cols-[minmax(0,1fr)_minmax(0,auto)_minmax(max-content,1fr)]")}>{advanced && !inForkPanel && <ChatActivityControls key={bot.threadId} activity={activity} botId={bot.id} style={headerNoDragStyle} />}
<div data-chathead-identity className={cn("flex min-w-0 items-center gap-2", phone ? "flex-1" : "@max-[30rem]/chathead:basis-full @min-[30rem]/chathead:col-start-2 @min-[30rem]/chathead:justify-self-center", simpleHead && phone && "justify-center")} style={headerNoDragStyle}>
{simpleHead ? (
<ChatHeadPill
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index b98283cb05..d439331a4e 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -2449,6 +2449,10 @@
"chat.peer.requested": "enviou um pedido",
"chat.peer.viewExchange": "Ver conversa",
"chat.peer.exchangeTitle": "{peer} e {bot}",
+ "chat.automation.activity": "Atividade do chat",
+ "chat.automation.showInChat": "Atualizações de rotinas",
+ "chat.automation.showTools": "Atividade de ferramentas",
+ "chat.automation.openLogs": "Abrir histórico de execuções",
"chat.automation.openRun": "Ver execução",
"chat.automation.openRunFor": "Ver a execução que gerou esta mensagem de {name}",
"chat.automation.needsYou": "aguardando você",