Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Merge main into the notification-pin branch
milind-soni14602002621b
diff --cc src/components/NotificationsPanel.tsxindex 9ed3c037e2,dfa9af6b97..365794f732--- a/src/components/NotificationsPanel.tsx+++ b/src/components/NotificationsPanel.tsx@@@ -1,9 -1,8 +1,9 @@@import { useEffect, useState } from "react";- import { AlertTriangle, AtSign, Bell, CheckCircle2, CircleHelp, HandHelping, Info, LogIn, Newspaper, Pin, RotateCcw, Wallet, X, type LucideIcon } from "lucide-react";- import { api, useStore, openNotificationTarget, type Action } from "@/state/store";+ import { AlertTriangle, AtSign, Bell, CheckCircle2, CircleHelp, HandHelping, Info, KeyRound, LogIn, Newspaper, Pin, RotateCcw, Wallet, X, type LucideIcon } from "lucide-react";+ import { api, useStore, openThread, type Action } from "@/state/store";import { cn } from "@/lib/cn";import { t } from "@/lib/i18n";+import { setNotificationTrayPinned } from "@/lib/notification-preferences";import { useShowThreads } from "@/lib/thread-preferences";import type { LocaleKey } from "@/locales";import { BotAvatar, type BotAvatarProps } from "./Avatar";@@@ -124,14 -124,7 +125,14 @@@ export function NotificationsPanel()dispatch({ type: "notificationRead", id: entry.id });void postNotificationRead(`/api/notifications/${entry.id}/read`, dispatch);}- openNotificationTarget(dispatch, { botId: entry.botId, threadId: entry.threadId }, state, showThreads);+ openThread(dispatch, { botId: entry.botId, threadId: entry.threadId }, state, showThreads);+ if (!state.notificationsPinned) dispatch({ type: "toggleNotifications", open: false });+ };++ const togglePinned = () => {+ const pinned = !state.notificationsPinned;+ dispatch({ type: "toggleNotificationsPinned", pinned });+ setNotificationTrayPinned(pinned);};const markAllRead = () => {diff --cc src/state/store.tsxindex b8bfed52cd,ddb8dc3d51..e5ce9a36b7--- a/src/state/store.tsx+++ b/src/state/store.tsx@@@ -19,7 -19,7 +19,7 @@@ import { DATA_ROUTES, type DataSheet, timport type { NotificationLogEntry } from "../../shared/notification";import { isNotificationFeedAction, reduceNotificationFeed, type NotificationFeedAction } from "./notification-feed";import { bumpThreadUpdatedAt, mergeTaskStamps, rewindThreadUpdatedAt } from "./thread-stamps";- import { botOpensTo, closeTrayUnlessShown, closeUnpinnedTray, openBot, openNotificationTarget, visibleNotificationThread, withRememberedTrayPin } from "./thread-navigation";-import { botOpensTo, openBot, openThread, visibleNotificationThread } from "./thread-navigation";++import { botOpensTo, closeTrayUnlessShown, closeUnpinnedTray, openBot, openThread, visibleNotificationThread, withRememberedTrayPin } from "./thread-navigation";import { patchGroupTask } from "./thread-edits";import type { EngineInstall } from "./engine-install";import { optimisticMessageId, optimisticUserMessage, sendArrived, sendReconciled } from "./optimistic-send";@@@ -1735,10 -1733,11 +1735,11 @@@ export function reducer(state: AppStatecase "regenerateTaskTitle":return state;case "newTask":- return action.cwd !== undefined ? state : { ...state, selectedId: action.botId, activeView: "chat" };+ return action.cwd !== undefined ? state : { ...closeUnpinnedTray(state), selectedId: action.botId, activeView: "chat" };case "switchTask": {const { [action.threadId]: _old, ...backgroundThreadEvents } = state.backgroundThreadEvents;- return updateBot({ ...closeTrayUnlessShown(state, action.botId, action.threadId), backgroundThreadEvents, selectedId: action.botId, activeView: "chat" }, action.botId, (bot) => ({ ...bot, switchingTo: action.threadId }));- return updateBot({ ...state, backgroundThreadEvents, selectedId: action.botId, activeView: "chat", revealThread: { threadId: action.threadId, nonce: (state.revealThread?.nonce ?? 0) + 1 } }, action.botId,++ return updateBot({ ...closeTrayUnlessShown(state, action.botId, action.threadId), backgroundThreadEvents, selectedId: action.botId, activeView: "chat", revealThread: { threadId: action.threadId, nonce: (state.revealThread?.nonce ?? 0) + 1 } }, action.botId,+ (bot) => ({ ...bot, switchingTo: action.threadId }));}case "switchTaskFailed":return updateBot(state, action.botId, (bot) => bot.switchingTo === action.threadId ? { ...bot, switchingTo: undefined } : bot);diff --cc src/state/thread-navigation.tsindex aaf7330822,5774b35c4e..d5564cf01e--- a/src/state/thread-navigation.ts+++ b/src/state/thread-navigation.ts@@@ -1,7 -1,5 +1,6 @@@+import { notificationTrayPinned } from "@/lib/notification-preferences";- import type { NotificationTarget } from "@/lib/notify";import type { Action, AppState } from "./store";- import { openOwnTeamChat } from "./team-chats";+ import { openOwnTeamChat, teamChats } from "./team-chats";interface NotificationThreadOwner {id: string;@@@ -108,31 -115,16 +116,34 @@@ export function openThread): boolean {const owns = (owner: NotificationThreadOwner) =>owner.threadId === target.threadId || (owner.tasks ?? []).some((task) => task.threadId === target.threadId);- if (state.groups.some(owns) || state.bots.some(owns)) {- openNotificationTarget(dispatch, target, state, threadsShown);- dispatch({ type: "revealThread", threadId: target.threadId });- return true;- }- const bot = state.bots.find((candidate) => candidate.id === target.botId);- if (bot) openBot(dispatch, bot, threadsShown);- dispatch({ type: "notice", notice: { kind: "thread-gone", botName: bot?.name ?? null } });+ // A room notification carries the asker bot with the room's thread id; switching the bot to it would 404.+ const group = state.groups.find(owns), owner = group ? undefined : state.bots.find(owns);+ const named = state.bots.find((candidate) => candidate.id === target.botId);+ if (group) {+ dispatch({ type: "select", id: group.id });+ if (group.threadId !== target.threadId) dispatch({ type: "switchGroupTask", groupId: group.id, threadId: target.threadId });+ } else if (owner) openBotThread(dispatch, owner, target.threadId, threadsShown);+ else if (named) openBot(dispatch, named, threadsShown);+ dispatch({ type: "revealThread", threadId: target.threadId });+ if (group || owner) return true;+ dispatch({ type: "notice", notice: { kind: "thread-gone", botName: named?.name ?? null } });return false;}++type NotificationTray = Pick<AppState, "notificationsOpen" | "notificationsPinned">;++export function closeUnpinnedTray<T extends NotificationTray>(state: T): T {+ return state.notificationsOpen && !state.notificationsPinned ? { ...state, notificationsOpen: false } : state;+}++/** Opening the chat already on screen is not leaving it. */+export function closeTrayUnlessShown(state: AppState, id: string, threadId: string): AppState {+ const chat = [...state.bots, ...state.groups].find((candidate) => candidate.id === id);+ const shownThreadId = chat && "switchingTo" in chat ? chat.switchingTo ?? chat.threadId : chat?.threadId;+ const shown = state.activeView === "chat" && id === state.selectedId && shownThreadId === threadId;+ return shown ? state : closeUnpinnedTray(state);+}++export function withRememberedTrayPin<T extends NotificationTray>(state: T): T {+ return notificationTrayPinned() ? { ...state, notificationsPinned: true } : state;+}