Skip to content

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

Mark a bot's main thread wherever its threads are listed

luishron123c9fc8deaf467
diff --git a/src/components/ChatMoreMenu.test.ts b/src/components/ChatMoreMenu.test.ts
index a44daa669c..33ea565a62 100644
--- a/src/components/ChatMoreMenu.test.ts
+++ b/src/components/ChatMoreMenu.test.ts
@@ -129,6 +129,7 @@ describe("ChatMoreMenu, the round ⋯ for the bot panel", () => {
["Untitled chat", false],
["Our chat", false],
]);
+ expect(threads.submenu!.map((item) => renderToStaticMarkup(createElement("div", null, item.trailing)).includes('aria-label="Main thread"'))).toEqual([false, false, true]);
threads.submenu![2].onSelect();
expect(fixture.dispatch).toHaveBeenCalledWith({ type: "switchTask", botId: "pepper", threadId: "main" });
});
diff --git a/src/components/ChatMoreMenu.tsx b/src/components/ChatMoreMenu.tsx
index 379276a6cd..fe229640a6 100644
--- a/src/components/ChatMoreMenu.tsx
+++ b/src/components/ChatMoreMenu.tsx
@@ -18,6 +18,7 @@ import { useContextAction } from "./ContextWarning";
import { ELEVATED_CONTROL, ELEVATED_HOVER, ELEVATED_OPEN } from "./elevated";
import { ShortcutHint } from "./ShortcutHint";
import { SidebarPopoverMenu, type SidebarMenuItem } from "./SidebarPopoverMenu";
+import { MainThreadMark } from "./SidebarRowMarkers";
import { orderedThreadList } from "./SidebarThreadRow";
import { openBotSettings } from "./bot-panel/panel-link";
import { ShareBotButton, useTeamName } from "./bot-access/ShareBotButton";
@@ -116,6 +117,7 @@ export function useChatMoreItems(profile: Bot, phoneHeader = false): { items: Si
key: `thread:${task.threadId}`,
label: localizedTaskTitle(task.title || t("task.newShort")),
active: task.threadId === bot.threadId,
+ trailing: task.threadId === profile.mainThreadId ? <MainThreadMark /> : undefined,
onSelect: () => openBotThread(dispatch, profile, task.threadId, showThreads),
})),
onSelect: () => {},
diff --git a/src/components/Sidebar.pinned-show-all.dom.test.ts b/src/components/Sidebar.pinned-show-all.dom.test.ts
index 6b0509435d..d670d8e70b 100644
--- a/src/components/Sidebar.pinned-show-all.dom.test.ts
+++ b/src/components/Sidebar.pinned-show-all.dom.test.ts
@@ -90,6 +90,31 @@ describe("a bot's Show all threads", () => {
});
});
+describe("a bot's main thread", () => {
+ const marked = () => [...host.querySelectorAll("[data-main-thread-mark]")].map((mark) => mark.closest("[data-sidebar-thread-row]")?.getAttribute("data-sidebar-thread-row"));
+
+ it("is marked in the thread list and stays listed when it is older than the short list", async () => {
+ bot.mainThreadId = "loose-0";
+ await mount();
+ expect(marked()).toEqual(["loose-0"]);
+ const mark = host.querySelector("[data-main-thread-mark]")!;
+ expect([mark.getAttribute("role"), mark.getAttribute("aria-label"), mark.textContent]).toEqual(["img", "Main thread", "Main"]);
+ expect(host.textContent).not.toContain("Loose chat 1");
+ await unmount();
+ delete bot.mainThreadId;
+ await mount();
+ expect(marked()).toEqual([]);
+ await unmount();
+ });
+
+ it("is marked on a collapsed bot's row for it", () => {
+ const html = renderToStaticMarkup(createElement(SidebarBotActivity, {
+ bot: { ...bot, mainThreadId: "filed-pinned" }, rowThreadId: bot.threadId, density: "comfortable", pendingQueued: {}, dispatch: vi.fn(),
+ }));
+ expect(html.match(/data-main-thread-mark/g)).toHaveLength(1);
+ });
+});
+
describe("a collapsed folder", () => {
it("keeps showing its pinned threads and hides the rest", async () => {
await mount();
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index cd214c953d..8b89ba4d9b 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -482,7 +482,7 @@ export function BotThreadList({ bot, selected, drafting, query, pendingQueued, r
useSnoozeExpiry(tasks);
const bulk = useBulkSelect();
const { own: ownTasks, helpers } = bulk.active ? { own: tasks, helpers: [] } : partitionHelperThreads(tasks, bot.threadId, query, projects);
- const visibleTasks = orderedThreadList(visibleSidebarThreads(ownTasks, bot.threadId, query, projects, showAll || bulk.active, routineRuns));
+ const visibleTasks = orderedThreadList(visibleSidebarThreads(ownTasks, bot.threadId, query, projects, showAll || bulk.active, routineRuns, bot.mainThreadId));
const visibleProjectIndex = (projectId: string) => visibleTasks.findIndex((task) => task.projectId === projectId);
const folderRank = (projectId: string) => {
const index = visibleProjectIndex(projectId);
@@ -512,7 +512,7 @@ export function BotThreadList({ bot, selected, drafting, query, pendingQueued, r
}), [botId, dispatch]);
const renderThread = (task: (typeof tasks)[number]) => {
const thread = currentTaskBot(bot, task.threadId);
- return <SidebarThreadRow key={task.threadId} task={{ ...task, busy: thread.busy, activity: thread.activity, waitingForTeammates: thread.waitingForTeammates }} ownerId={bot.id} current={selected && !drafting && task.threadId === bot.threadId} folders={projects}
+ return <SidebarThreadRow key={task.threadId} task={{ ...task, busy: thread.busy, activity: thread.activity, waitingForTeammates: thread.waitingForTeammates }} ownerId={bot.id} current={selected && !drafting && task.threadId === bot.threadId} main={task.threadId === bot.mainThreadId} folders={projects}
activityLabel={task.threadId === bot.threadId ? activityLabel : undefined} now={stampClock(threadRecency(task), now)} locale={locale} {...actions}
selectMode={bulk.active} checked={selection.has(task.threadId)} onToggleSelect={bulk.toggle} />;
};
@@ -626,7 +626,7 @@ export function BotThreadList({ bot, selected, drafting, query, pendingQueued, r
{ungrouped.map(renderThread)}
<HelperThreadGroup tasks={orderedThreadList(helpers)} renderThread={renderThread} />
<ThreadListFooter bulk={bulk} rows={shownRows} selected={selection} total={ownTasks.length} canShowAll={!query && !showAll && ownTasks.length > visibleTasks.length} canSelect={tasks.length > 1}
- onShowAll={() => setShowAll(true)} onShowFewer={showAll && !query && !bulk.active && visibleSidebarThreads(ownTasks, bot.threadId, query, projects, false, routineRuns).length < ownTasks.length ? () => setShowAll(false) : undefined} freshConversation onDelete={(threadIds) => deleteThreadsInBulk({ botId: bot.id }, threadIds, dispatch)}
+ onShowAll={() => setShowAll(true)} onShowFewer={showAll && !query && !bulk.active && visibleSidebarThreads(ownTasks, bot.threadId, query, projects, false, routineRuns, bot.mainThreadId).length < ownTasks.length ? () => setShowAll(false) : undefined} freshConversation onDelete={(threadIds) => deleteThreadsInBulk({ botId: bot.id }, threadIds, dispatch)}
onRetitle={(threadIds) => retitleThreadsInBulk(bot.id, threadIds)} />
<LocalComputerAutoWarning
open={permissionRefresh?.kind === "local-auto"}
diff --git a/src/components/SidebarBotActivity.tsx b/src/components/SidebarBotActivity.tsx
index d838d11bf8..64c638fee1 100644
--- a/src/components/SidebarBotActivity.tsx
+++ b/src/components/SidebarBotActivity.tsx
@@ -8,7 +8,7 @@ import { isArchived, orderedSidebarThreads, orderedThreadList, threadRecency, th
import type { SidebarDensity } from "@/lib/sidebar-preferences";
import { localizedTaskTitle } from "@/lib/task-title";
import { endedOnFailure } from "@/lib/mascot";
-import { rowSelectedSurface } from "./SidebarRowMarkers";
+import { MainThreadMark, rowSelectedSurface } from "./SidebarRowMarkers";
import { handoffStatusText } from "./HandoffStatusChip";
export function sidebarBotActivityTasks(bot: Bot, queued: Record<string, unknown[]>, archivedApprovals = false): Array<Task & { queued: boolean }> {
@@ -257,7 +257,7 @@ export function SidebarBotActivity({ bot, rowThreadId, density, pendingQueued, d
onClick={() => dispatch({ type: "switchTask", botId: bot.id, threadId: task.threadId })}
className={cn("flex min-h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 py-1 text-left text-[13px] leading-[18px] outline-none hover:bg-ink/[0.06] focus-visible:ring-1 focus-visible:ring-accent/60", iconOnly && "justify-center", waiting ? "text-warning" : "text-ink-secondary")}>
<Icon size={14} aria-hidden="true" className={cn("shrink-0", working && "animate-spin text-success", teammateWait && "text-warning", task.unread && !waiting && !working && !teammateWait && "text-accent")} />
- {!iconOnly && <><span className="min-w-0 flex-1 truncate">{title}</span>{!pinnedOnly && <span className="shrink-0 text-[12px] leading-4">{waiting ? t("task.waiting") : status}</span>}
+ {!iconOnly && <><span className="min-w-0 flex-1 truncate">{title}</span>{task.threadId === bot.mainThreadId && <MainThreadMark />}{!pinnedOnly && <span className="shrink-0 text-[12px] leading-4">{waiting ? t("task.waiting") : status}</span>}
{task.unread && (waiting || working || teammateWait || task.queued) && <span className="size-1.5 shrink-0 rounded-full bg-accent" aria-hidden="true" />}</>}
</button>;
})}
diff --git a/src/components/SidebarRowMarkers.tsx b/src/components/SidebarRowMarkers.tsx
index 5b62ad4d86..b4548ec4d0 100644
--- a/src/components/SidebarRowMarkers.tsx
+++ b/src/components/SidebarRowMarkers.tsx
@@ -1,3 +1,4 @@
+import { Star } from "lucide-react";
import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
@@ -55,3 +56,13 @@ export function RowStatusText({ working = false, failed = false, unread }: { wor
const text = [working ? t("chat.activity.working") : "", failed ? t("sidebar.preview.failed") : "", unread ? t("task.unread") : ""].filter(Boolean).join(", ");
return text ? <span className="sr-only">{text}</span> : null;
}
+
+/** The bot's main thread ("Set as main thread"): one mark for every list of its threads. It never shrinks, so a long
+ * title is cut short before it. */
+export function MainThreadMark({ className }: { className?: string }) {
+ const label = t("sidebar.bot.simple.mainThread");
+ return <span role="img" data-main-thread-mark="" aria-label={label} title={label}
+ className={cn("flex shrink-0 items-center gap-1 text-[12px] font-medium leading-4 text-ink-secondary", className)}>
+ <Star size={14} aria-hidden="true" className="fill-current" />{t("sidebar.threads.main")}
+ </span>;
+}
diff --git a/src/components/SidebarThreadLabels.dom.test.ts b/src/components/SidebarThreadLabels.dom.test.ts
new file mode 100644
index 0000000000..104d251ac3
--- /dev/null
+++ b/src/components/SidebarThreadLabels.dom.test.ts
@@ -0,0 +1,49 @@
+// @vitest-environment happy-dom
+import { createElement } from "react";
+import { flushSync } from "react-dom";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import type { Bot, Task } from "@/state/store";
+import { setThreadsUnfolded } from "@/lib/thread-fold-preferences";
+import { SidebarThreadLabels } from "./SidebarThreadLabels";
+
+const now = Date.now();
+const task = (threadId: string, title: string, hoursAgo: number, extra: Partial<Task> = {}): Task =>
+ ({ threadId, title, createdAt: now - hoursAgo * 3_600_000, updatedAt: now - hoursAgo * 3_600_000, ...extra });
+const research = (extra: Partial<Bot> = {}): Bot => ({
+ id: "research", threadId: "pricing", name: "Research", title: "", description: "", notifications: true, color: "green",
+ unread: false, modelSelection: { instanceId: "fake", model: "fake" }, messages: [],
+ tasks: [task("pricing", "Competitor pricing", 1), task("home", "A long title for the conversation this bot always comes back to", 2), task("deck", "Board deck", 3)],
+ ...extra,
+});
+
+let host: HTMLDivElement;
+let root: Root;
+const render = (bot: Bot) => flushSync(() => root.render(createElement(SidebarThreadLabels, { bot, selected: true, rowThreadId: bot.threadId, pendingQueued: {}, dispatch: vi.fn() })));
+const marked = () => [...host.querySelectorAll("[data-main-thread-mark]")].map((mark) => mark.closest("[data-thread-label]")?.getAttribute("data-thread-label"));
+
+beforeEach(() => {
+ localStorage.clear();
+ setThreadsUnfolded("research", true);
+ host = document.createElement("div");
+ document.body.append(host);
+ root = createRoot(host);
+});
+afterEach(() => {
+ flushSync(() => root.unmount());
+ host.remove();
+});
+
+describe("a bot's threads unfolded under its row in Simple mode", () => {
+ it("marks the bot's main thread, and no other row, with a mark a long title cannot push out", () => {
+ render(research({ mainThreadId: "home" }));
+ expect(marked()).toEqual(["home"]);
+ const mark = host.querySelector("[data-main-thread-mark]")!;
+ expect([mark.getAttribute("role"), mark.getAttribute("aria-label"), mark.textContent]).toEqual(["img", "Main thread", "Main"]);
+ expect(mark.className).toContain("shrink-0");
+ render(research({ mainThreadId: "deck" }));
+ expect(marked()).toEqual(["deck"]);
+ render(research());
+ expect(marked()).toEqual([]);
+ });
+});
diff --git a/src/components/SidebarThreadLabels.tsx b/src/components/SidebarThreadLabels.tsx
index 9c052b04a0..062cee9743 100644
--- a/src/components/SidebarThreadLabels.tsx
+++ b/src/components/SidebarThreadLabels.tsx
@@ -12,6 +12,7 @@ import { canUnfold, threadLabels, type LabelRow } from "./sidebar-thread-labels"
import { isWorking } from "./SidebarThreadRow";
import { showAllConversations } from "./bot-panel/Conversations";
import { reducedMotion } from "./MenuMotion";
+import { MainThreadMark } from "./SidebarRowMarkers";
const SLOT = "pointer-events-none absolute end-[30px] top-1.5 flex size-6 items-center justify-center rounded-lg text-ink-secondary opacity-0 transition-opacity hover:bg-raised hover:text-ink group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 max-md:hidden touch:pointer-events-auto touch:opacity-70 motion-reduce:transition-none";
const ROW = "group/label relative flex h-8 w-full min-w-0 items-center gap-2 rounded-lg ps-2.5 pe-2 text-start text-[13px] leading-[18px] outline-none transition-colors duration-[120ms] focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus motion-reduce:transition-none";
@@ -175,6 +176,7 @@ export function SidebarThreadLabels({ bot, selected, drafting = false, rowThread
className="-ms-1.5 h-7 min-w-0 flex-1 rounded-md border border-focus bg-transparent px-1.5 text-[13px] text-ink outline-none" />
) : <>
<span dir="auto" className={cn("min-w-0 flex-1 truncate", hideable(row) && YIELDS)}>{title}</span>
+ {row.task.threadId === bot.mainThreadId && <MainThreadMark />}
<span className={cn("flex shrink-0 items-center", hideable(row) && "transition-opacity duration-[120ms] group-hover/label:opacity-0 motion-reduce:transition-none")}><StatusMark row={row} /></span>
{hideable(row) && (
<button type="button" tabIndex={-1} aria-label={t("sidebar.threads.hide", { title })} title={t("sidebar.threads.hideShort")}
diff --git a/src/components/SidebarThreadRow.test.ts b/src/components/SidebarThreadRow.test.ts
index e125be17bd..23725378d0 100644
--- a/src/components/SidebarThreadRow.test.ts
+++ b/src/components/SidebarThreadRow.test.ts
@@ -57,6 +57,11 @@ describe("sidebar thread visibility", () => {
expect(visibleSidebarThreads(rows, "8", "", [], true)).toEqual(rows);
});
+ it("keeps the bot's main thread listed when it is older than the six recent rows", () => {
+ expect(visibleSidebarThreads(tasks, "0", "", [], false, [], "9").map((task) => task.threadId)).toEqual(["0", "1", "2", "3", "4", "5", "9"]);
+ expect(visibleSidebarThreads(tasks, "0").map((task) => task.threadId)).toEqual(["0", "1", "2", "3", "4", "5"]);
+ });
+
it("leaves a burst's parts to its card, unless one is open or needs the person", () => {
const openedBy = { botId: "b", name: "Bot", at: 1, burstId: "run-1" };
const parts = [{ threadId: "quiet", title: "Quiet", openedBy }, { threadId: "open", title: "Open", openedBy }, { threadId: "asks", title: "Asks", openedBy, unread: true }];
diff --git a/src/components/SidebarThreadRow.tsx b/src/components/SidebarThreadRow.tsx
index 3477159e74..5924b16b9c 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, Brain, Check, ChevronRight, Clock, Clock3, FolderInput, Link2, Link2Off, Loader2, MoreHorizontal, Pencil, Pin, PinOff, RefreshCw, Star, Trash2 } from "lucide-react";
+import { Archive, ArchiveRestore, BellOff, Brain, Check, ChevronRight, Clock, Clock3, FolderInput, Link2, Link2Off, Loader2, MoreHorizontal, Pencil, Pin, PinOff, RefreshCw, Trash2 } from "lucide-react";
import type { Action, AppState, BotProject, Task } from "@/state/store";
import { api } from "@/state/store";
import type { RoutineRun } from "@/lib/routines";
@@ -18,7 +18,7 @@ import { threadLinkLabel } from "../../shared/thread-link";
import { isSnoozed, orderedThreadList } from "../../shared/wire";
import { Select } from "./Select";
import { WorkingTimer } from "./WorkingIndicator";
-import { rowSelectedSurface } from "./SidebarRowMarkers";
+import { MainThreadMark, rowSelectedSurface } from "./SidebarRowMarkers";
import { useHeldText } from "./SidebarWorkingStep";
import { localizedTaskTitle } from "@/lib/task-title";
import { useAdvancedMode } from "@/lib/interface-mode";
@@ -130,7 +130,7 @@ export function HelperThreadGroup<T>({ tasks, renderThread }: { tasks: T[]; rend
}
/** Default list shows each routine's newest run only; older runs stay under "Show all". */
-export function visibleSidebarThreads<T extends ThreadRowTask>(tasks: T[], activeId: string, query = "", folders: BotProject[] = [], showAll = false, routineRuns: readonly Pick<RoutineRun, "routineId" | "threadId" | "createdAt">[] = []): T[] {
+export function visibleSidebarThreads<T extends ThreadRowTask>(tasks: T[], activeId: string, query = "", folders: BotProject[] = [], showAll = false, routineRuns: readonly Pick<RoutineRun, "routineId" | "threadId" | "createdAt">[] = [], mainId?: string): T[] {
const needle = query.trim().toLowerCase();
if (needle) {
return tasks.filter((task) => task.title.toLowerCase().includes(needle) || folders.some((folder) => folder.id === task.projectId && folder.name.toLowerCase().includes(needle)));
@@ -155,7 +155,7 @@ export function visibleSidebarThreads<T extends ThreadRowTask>(tasks: T[], activ
if (run && newestRun.get(run.routineId) !== run) return demandsAttention(task, activeId);
return task.closedBy || isSnoozed(task)
? demandsAttention(task, activeId)
- : open++ < 6 || demandsAttention(task, activeId);
+ : open++ < 6 || task.threadId === mainId || demandsAttention(task, activeId);
});
}
@@ -256,7 +256,7 @@ 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. */
+ /** The bot's main thread ("Set as main thread"). */
main?: boolean;
};
@@ -346,7 +346,7 @@ export const SidebarThreadRow = memo(function SidebarThreadRow({ task, ownerId,
}, [menu]);
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>}
+ {main && <MainThreadMark className="self-center" />}
{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 7d7c31ec1b..dd62219861 100644
--- a/src/components/bot-panel/Conversations.dom.test.ts
+++ b/src/components/bot-panel/Conversations.dom.test.ts
@@ -203,6 +203,7 @@ describe("a bot's conversations in its panel", () => {
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(star?.textContent).toBe("Main");
expect(row("who").querySelector('[aria-label="Main thread"]')).toBeNull();
render(research({ mainThreadId: "who" }));
expect(row("who").querySelector('[aria-label="Main thread"]')).not.toBeNull();
diff --git a/src/components/sidebar-thread-labels.test.ts b/src/components/sidebar-thread-labels.test.ts
index 374d8c6f17..b6210a59a2 100644
--- a/src/components/sidebar-thread-labels.test.ts
+++ b/src/components/sidebar-thread-labels.test.ts
@@ -32,6 +32,13 @@ describe("a bot's threads under its sidebar row", () => {
expect(open.more).toBe(3);
});
+ it("unfolded, keeps the main thread listed however old it is, in place of the oldest active one", () => {
+ const tasks = [thread("main", 30), thread("a", 1), thread("b", 2), thread("c", 3), thread("d", 4), thread("e", 5)];
+ const labels = threadLabels({ ...bot(tasks, "e"), mainThreadId: "main" }, {}, { unfolded: true, current: "e", rowThreadId: "e", now: NOW });
+ expect(ids(labels)).toEqual(["a", "b", "e", "main"]);
+ expect(labels.more).toBe(2);
+ });
+
it("leaves a week-old thread nobody touched in the count, not the list", () => {
const labels = threadLabels(bot([thread("main", 1), thread("stale", 8)]), {}, { unfolded: true, rowThreadId: "main", now: NOW });
expect(ids(labels)).toEqual(["main"]);
diff --git a/src/components/sidebar-thread-labels.ts b/src/components/sidebar-thread-labels.ts
index 3ef74d5a77..4ae97fccba 100644
--- a/src/components/sidebar-thread-labels.ts
+++ b/src/components/sidebar-thread-labels.ts
@@ -46,8 +46,9 @@ function capRunning(tasks: LabelTask[]): { kept: LabelTask[]; runningMore: numbe
/**
* The rows under a bot in Simple mode's sidebar. Folded: its threads that are working, wait on the person or have an
- * unread reply, except the one its row opens. Unfolded: also its active threads of the person's own (the open one, any
- * still going, and those used in the last week), at most `ACTIVE_LIMIT`, and how many more the bot panel lists.
+ * unread reply, except the one its row opens. Unfolded: also its active threads of the person's own (the open one, its
+ * main thread, any still going, and those used in the last week), at most `ACTIVE_LIMIT`, and how many more the bot
+ * panel lists.
*/
export function threadLabels(
bot: LabelBot,
@@ -63,11 +64,11 @@ export function threadLabels(
}
const own = ownOpen(bot).map((task) => ({ ...task, queued: Boolean(queued[task.threadId]?.length) }));
const recent = (task: LabelTask) => now - threadRecency(task) < ACTIVE_DAYS * DAY_MS;
- const active = own.filter((task) => task.threadId === current || labelStatus(task) !== null || recent(task))
+ const anchored = (task: LabelTask) => task.threadId === current || task.threadId === bot.mainThreadId;
+ const active = own.filter((task) => anchored(task) || labelStatus(task) !== null || recent(task))
.sort((a, b) => threadRecency(b) - threadRecency(a));
- let shown = active.slice(0, ACTIVE_LIMIT);
- const open = active.find((task) => task.threadId === current);
- if (open && !shown.includes(open)) shown = [...shown.slice(0, ACTIVE_LIMIT - 1), open];
+ const others = active.filter((task) => !anchored(task)).slice(0, Math.max(0, ACTIVE_LIMIT - active.filter(anchored).length));
+ const shown = active.filter((task) => anchored(task) || others.includes(task));
const listed = new Set(shown.map((task) => task.threadId));
const { kept, runningMore } = capRunning([...shown, ...attention.filter((task) => !listed.has(task.threadId))]);
const rows = new Set(kept.map((task) => task.threadId));
diff --git a/src/locales/en.json b/src/locales/en.json
index 350b00b653..b063d2f703 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -11548,6 +11548,7 @@
"sidebar.threads.hideShort": "Hide",
"sidebar.threads.running": "+{count} running",
"sidebar.threads.more": "{count} more",
+ "sidebar.threads.main": "Main",
"skillBurger.aria": "Skill Burger",
"skillBurger.layers": "Steps",
"skillBurger.layersOne": "1 step",
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index e060f07de9..7f3d873a8f 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -11548,6 +11548,7 @@
"sidebar.threads.hideShort": "Ocultar",
"sidebar.threads.running": "+{count} em andamento",
"sidebar.threads.more": "mais {count}",
+ "sidebar.threads.main": "Principal",
"skillBurger.aria": "Skill Burger",
"skillBurger.layers": "Etapas",
"skillBurger.layersOne": "1 etapa",