Skip to content

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

Show the main thread star in the bot details panel's Conversations list

Bugfixer 22359c38a098d
diff --git a/src/components/SidebarThreadRow.tsx b/src/components/SidebarThreadRow.tsx
index aa1c9ea648..8f2665a683 100644
--- a/src/components/SidebarThreadRow.tsx
+++ b/src/components/SidebarThreadRow.tsx
@@ -1,6 +1,6 @@
import { memo, useEffect, useRef, useState, type Dispatch, type ReactNode } from "react";
import { createPortal } from "react-dom";
-import { Archive, ArchiveRestore, BellOff, Check, ChevronRight, Clock, Clock3, FolderInput, Link2, Link2Off, Loader2, MoreHorizontal, Pencil, Pin, PinOff, RefreshCw, Trash2 } from "lucide-react";
+import { Archive, ArchiveRestore, BellOff, Check, ChevronRight, Clock, Clock3, FolderInput, Link2, Link2Off, Loader2, MoreHorizontal, Pencil, Pin, PinOff, RefreshCw, Star, Trash2 } from "lucide-react";
import type { Action, AppState, BotProject, Task } from "@/state/store";
import { api } from "@/state/store";
import type { RoutineRun } from "@/lib/routines";
@@ -251,6 +251,8 @@ type ThreadRowProps = {
* has worked. */
panel?: boolean;
preview?: string;
+ /** The bot's main thread ("Set as main thread"), starred like it is in the sidebar's thread list. */
+ main?: boolean;
};
const sameFields = <T extends object>(a: T, b: T): boolean => {
@@ -261,7 +263,7 @@ const sameFields = <T extends object>(a: T, b: T): boolean => {
const sameThreadRow = ({ task: previousTask, ...previous }: ThreadRowProps, { task, ...next }: ThreadRowProps): boolean =>
sameFields(previousTask, task) && sameFields(previous, next);
-export const SidebarThreadRow = memo(function SidebarThreadRow({ task, ownerId, current, folders, onSelect, onRename, onRegenerateTitle, onDelete, onMove, onArchive, onPin, onSnooze, onLink, onRefreshPermissions, activityLabel: liveActivity, now, selectMode = false, checked = false, onToggleSelect, panel = false, preview }: ThreadRowProps) {
+export const SidebarThreadRow = memo(function SidebarThreadRow({ task, ownerId, current, folders, onSelect, onRename, onRegenerateTitle, onDelete, onMove, onArchive, onPin, onSnooze, onLink, onRefreshPermissions, activityLabel: liveActivity, now, selectMode = false, checked = false, onToggleSelect, panel = false, preview, main = false }: ThreadRowProps) {
const activityLabel = useHeldText(liveActivity);
const [menu, setMenu] = useState<{ left: number; top: number } | null>(null);
const [webLink, setWebLink] = useState<string | null>(null);
@@ -335,8 +337,9 @@ export const SidebarThreadRow = memo(function SidebarThreadRow({ task, ownerId,
window.addEventListener("resize", keepOnScreen);
return () => { observer?.disconnect(); window.removeEventListener("resize", keepOnScreen); };
}, [menu]);
- const heading = <span className="flex min-w-0 flex-1 items-baseline gap-1.5">
- <span dir="auto" className={cn("min-w-0 flex-1 max-w-max", panel ? "truncate pe-6" : "truncate", task.unread && "font-semibold text-ink", (closed || archived || snoozed) && !current && "text-ink-tertiary")}>{displayTitle}</span>
+ const heading = <span className={cn("flex min-w-0 flex-1 items-baseline gap-1.5", panel && "pe-6")}>
+ <span dir="auto" className={cn("min-w-0 flex-1 max-w-max truncate", task.unread && "font-semibold text-ink", (closed || archived || snoozed) && !current && "text-ink-tertiary")}>{displayTitle}</span>
+ {main && <span role="img" className="shrink-0 self-center text-ink-secondary" aria-label={t("sidebar.bot.simple.mainThread")} title={t("sidebar.bot.simple.mainThread")}><Star size={12} aria-hidden="true" /></span>}
{byline && (
<span className="min-w-0 max-w-[45%] shrink truncate font-normal text-ink-tertiary">{byline}</span>
)}
diff --git a/src/components/bot-panel/Conversations.dom.test.ts b/src/components/bot-panel/Conversations.dom.test.ts
index 04f7cac1ac..e39d1f86c0 100644
--- a/src/components/bot-panel/Conversations.dom.test.ts
+++ b/src/components/bot-panel/Conversations.dom.test.ts
@@ -187,6 +187,19 @@ describe("a bot's conversations in its panel", () => {
expect(host.querySelectorAll("[data-thread-working]")).toHaveLength(1);
});
+ it("marks the bot's main thread with the same star as the sidebar's thread list, and no other row", () => {
+ render(research({ mainThreadId: "launch" }));
+ const star = row("launch").querySelector('[role="img"][aria-label="Main thread"]');
+ expect(star?.getAttribute("title")).toBe("Main thread");
+ expect(star?.querySelector("svg")).not.toBeNull();
+ expect(row("who").querySelector('[aria-label="Main thread"]')).toBeNull();
+ render(research({ mainThreadId: "who" }));
+ expect(row("who").querySelector('[aria-label="Main thread"]')).not.toBeNull();
+ expect(row("launch").querySelector('[aria-label="Main thread"]')).toBeNull();
+ render(research());
+ expect(host.querySelector('[aria-label="Main thread"]')).toBeNull();
+ });
+
it("shows each listed conversation's last line, fetching only the listed ones that are not open", async () => {
render(research());
await settle();
diff --git a/src/components/bot-panel/Conversations.tsx b/src/components/bot-panel/Conversations.tsx
index 3e585e630d..ba91d8916e 100644
--- a/src/components/bot-panel/Conversations.tsx
+++ b/src/components/bot-panel/Conversations.tsx
@@ -117,7 +117,7 @@ export function BotConversations({ bot }: { bot: Bot }) {
const row = (task: (typeof threads)[number]) => (
<div role="listitem" key={task.threadId} data-conversation={task.threadId}>
<SidebarThreadRow panel preview={preview(task.threadId)} task={task} ownerId={bot.id} current={task.threadId === bot.threadId}
- folders={bot.projects} now={stampClock(threadRecency(task), now)} locale={activeLocale()} onSelect={select} {...actions} />
+ main={task.threadId === bot.mainThreadId} folders={bot.projects} now={stampClock(threadRecency(task), now)} locale={activeLocale()} onSelect={select} {...actions} />
</div>
);