Skip to content

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

Merge #7503: Inbox: show each bot's picture on Pinned, Active and Finished rows

milind-soni29aacfd581f0
diff --cc src/components/inbox/InboxActive.tsx
index 02cb00ce36,77322e0357..4a7a9dfc9c
--- a/src/components/inbox/InboxActive.tsx
+++ b/src/components/inbox/InboxActive.tsx
@@@ -66,12 -65,12 +66,14 @@@ export function unreadConversations(ent
return entries.filter((entry) => entry.task.unread === true && !lined.has(entry.task.threadId)).length;
}
- export function InboxActive({ view, current, exclude, filter = {} }: {
-export function InboxActive({ view, current, exclude, faces }: {
++export function InboxActive({ view, current, exclude, faces, filter = {} }: {
view: InboxView | null; current?: OpenThread;
+ /** The bots' pictures, from botFaces: each row leads with its own. */
+ faces: readonly BotFace[];
/** Conversations the pinned section at the top already shows: these lists leave them out so none appears twice. */
exclude?: ReadonlySet<string>;
+ /** The bot and status the person picked above the lists. */
+ filter?: ThreadFilter;
}) {
const jump = useInboxJump();
const team = useTeamPeople();
diff --cc src/components/inbox/InboxPanel.tsx
index 190e1a4c46,e99371e288..b8141d7d1c
--- a/src/components/inbox/InboxPanel.tsx
+++ b/src/components/inbox/InboxPanel.tsx
@@@ -11,10 -11,10 +11,10 @@@ import { sameJson } from "@/state/same-
import { useStoreDispatch, useStoreSelector } from "@/state/store-select";
import { useActiveLocale } from "@/lib/use-active-locale";
import { InboxActive, inboxAttentionEntries, inboxOpenThread, readNewsThreads, unreadConversations } from "./InboxActive";
- import { attentionUnpinAction } from "../SidebarBotActivity";
+ import { attentionUnpinAction, botFaces } from "../SidebarBotActivity";
import { InboxReading } from "./InboxReading";
import { InboxRowItem } from "./InboxRow";
-import { FinishedThreads, finishedThreads } from "./FinishedThreads";
+import { FINISHED_LIMIT, FinishedThreads, finishedThreads } from "./FinishedThreads";
import { PinnedThreads, pinnedThreadRows } from "./PinnedThreads";
import { matchesSearch, nextAfter } from "./inbox-answer";
import { listedRows, rowsIn, waitingCount } from "./inbox-view";
@@@ -80,20 -77,12 +80,21 @@@ export const InboxPanel = memo(functio
const row = rows[at + by];
if (row) open(row);
};
+ const faces = useStoreSelector((state) => botFaces(state.bots), sameJson);
const pinnedRows = useStoreSelector((state) => pinnedThreadRows(state.bots, state.groups, state.pendingQueued), sameJson);
const pinnedThreads = useMemo(() => new Set(pinnedRows.map((row) => row.task.threadId)), [pinnedRows]);
- const finishedRows = useStoreSelector((state) => finishedThreads(state.bots, state.groups, state.pendingQueued, undefined, readNewsThreads(view), pinnedThreads), sameJson);
- const unread = useStoreSelector((state) => unreadConversations(inboxAttentionEntries(state, view), view));
- const count = waitingCount(view) + unread;
+ // The filter picks from every finished conversation before the list keeps its newest ten.
+ const threads = useStoreSelector((state) => {
+ const entries = inboxAttentionEntries(state, view);
+ const active = entries.filter((entry) => !pinnedThreads.has(entry.task.threadId));
+ const finished = finishedThreads(state.bots, state.groups, state.pendingQueued, Infinity, readNewsThreads(view), pinnedThreads);
+ const finishedRows = finished.filter((row) => matchesThreadFilter(row, filter)).slice(0, FINISHED_LIMIT);
+ return {
+ owners: threadOwners([...active, ...finished], filter.owner), finishedRows, unread: unreadConversations(entries, view),
+ any: finishedRows.length > 0 || active.some((entry) => matchesThreadFilter(entry, filter)),
+ };
+ }, sameJson);
+ const count = waitingCount(view) + threads.unread;
const openThread = useStoreSelector((state) => inboxOpenThread(state), sameJson);
const body = (
<>
@@@ -145,16 -134,9 +146,16 @@@
)
: rows.map((row) => <InboxRowItem key={row.id} row={row} now={now} onOpen={open} onAction={run} />)}
</div>
- {!query.trim() && <InboxActive view={view} current={openThread} exclude={pinnedThreads} faces={faces} />}
+ {!query.trim() && threads.owners.length > 0 && <ThreadFilterBar owners={threads.owners} filter={filter} onChange={setFilter} />}
+ {!query.trim() && threadFilterOn(filter) && !threads.any && (
+ <div data-inbox-filter-empty className="flex flex-col items-center gap-1 px-4 py-6 text-center">
+ <p className="text-[13px] text-ink-secondary">{t("inbox.filter.noMatch")}</p>
+ <button type="button" onClick={() => setFilter({})} className="text-[12px] text-accent hover:underline">{t("inbox.filter.clear")}</button>
+ </div>
+ )}
- {!query.trim() && <InboxActive view={view} current={openThread} exclude={pinnedThreads} filter={filter} />}
++ {!query.trim() && <InboxActive view={view} current={openThread} exclude={pinnedThreads} faces={faces} filter={filter} />}
{/* The finished, already-read conversations. */}
- {!query.trim() && <FinishedThreads rows={threads.finishedRows} now={now} current={openThread} onOpen={jump} />}
- {!query.trim() && <FinishedThreads rows={finishedRows} faces={faces} now={now} current={openThread} onOpen={jump} />}
++ {!query.trim() && <FinishedThreads rows={threads.finishedRows} faces={faces} now={now} current={openThread} onOpen={jump} />}
{done.length > 0 && (
<section data-inbox-done className="px-1.5 pb-1.5">
<button type="button" data-inbox-done-toggle aria-expanded={showDone} onClick={() => setShowDone(!showDone)}