Skip to content

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

inbox: keep finished conversations, pinned ones on top, and what came before

way568bedfa6f5f72e
diff --git a/server/host/place-inbox.ts b/server/host/place-inbox.ts
index a9eb904bf0..1d8442e26c 100644
--- a/server/host/place-inbox.ts
+++ b/server/host/place-inbox.ts
@@ -25,6 +25,8 @@ const MAX_LINES = 2_000;
const MAX_SEEN_ASKS = 2_000;
const KEEP_MS = 30 * 24 * 60 * 60_000;
const VIEW_ROWS = 200;
+/** How many finished, already-read lines the inbox keeps under its active list. */
+const SETTLED_ROWS = 5;
const ROW_TEXT_MAX = 4_000;
const NOTICE_TEXT_MAX = 2_000;
const HOUR_MS = 60 * 60_000;
@@ -191,11 +193,17 @@ export function createPlaceInbox(deps: PlaceInboxDeps) {
});
function view(auth: RequestAuth): InboxView {
- const rows = [...askRows(auth), ...lines.filter((line) => lineFor(auth, line)).map(lineRow)].sort((a, b) => b.at - a.at).slice(0, VIEW_ROWS);
+ const visible = [...askRows(auth), ...lines.filter((line) => lineFor(auth, line)).map(lineRow)].sort((a, b) => b.at - a.at);
+ // The finished lines the list would otherwise drop follow the active ones, so the panel can show them in its
+ // own Finished list instead of losing them the moment they are read.
+ const listed = visible.filter((row) => row.tab !== "done");
+ const settled = visible.filter((row) => row.tab === "done" && row.kind !== "ask").slice(0, SETTLED_ROWS);
+ const rows = [...listed, ...settled].slice(0, VIEW_ROWS + SETTLED_ROWS);
return { botId: null, threadId: null, rows, anchor: null };
}
function addLine(line: Line): Line {
+ // A job's next unread result replaces its last one, so one job keeps one row; a line already read stays for Finished.
if (line.job) lines = lines.filter((one) => one.job !== line.job || one.seen || one.done);
lines.push(line);
save();
diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsx
index d84cbbfe04..b7ef4622a5 100644
--- a/src/components/ChatView.tsx
+++ b/src/components/ChatView.tsx
@@ -121,7 +121,7 @@ import { PagePaneContext } from "./app/PageTools";
import { useTranscriptViewport } from "@/hooks/use-transcript-viewport"; import { staysInView } from "../../shared/person-wait";
import { useUnreadDivider } from "@/hooks/use-unread-divider";
import { NewMessagesDivider } from "./NewMessagesDivider";
-import { unreadMessageIds } from "@/lib/unread-divider";
+import { unreadMessageIds } from "@/lib/unread-divider"; import { UnreadContextOverlay } from "./UnreadContextOverlay";
import { appendComposerDraft, appendDraftAttachments, useReplyDraft } from "@/lib/drafts";
import { botLineText, localDay, transcriptLookups, type TranscriptLookups } from "@/lib/transcript-derivations"; import { DaySeparator } from "./DaySeparator";
import { splitTranscriptCitations, type CitationAttachment } from "@/lib/citations";
@@ -862,8 +862,7 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal
const lastBotTextId = useMemo(
() => [...messages].reverse().find((m) => m.role === "bot" && m.kind === "text")?.id,
[messages],
- );
- const unreadDivider = useUnreadDivider({ threadId: bot.threadId, messages, following });
+ ); const unreadDivider = useUnreadDivider({ threadId: bot.threadId, messages, following });
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]);
@@ -1123,6 +1122,7 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal
<ChatErrorBanner message={state.error} onDismiss={() => dispatch({ type: "error", message: null })} />
<ChatNotice notice={state.notice} />
+ <UnreadContextOverlay messages={messages} windowedMessages={windowedMessages} unreadMessageId={unreadDivider.messageId} scrollRef={scrollRef} visitKey={`${bot.id}:${bot.threadId}:${openedAt}`} onJump={(messageId) => dispatch({ type: "focusMessage", threadId: bot.threadId, messageId })} />
</GlassBar>
diff --git a/src/components/SidebarBotActivity.tsx b/src/components/SidebarBotActivity.tsx
index d918f5f194..6193483f4f 100644
--- a/src/components/SidebarBotActivity.tsx
+++ b/src/components/SidebarBotActivity.tsx
@@ -76,6 +76,20 @@ export type AttentionThread =
| { kind: "bot"; botId: string; botName: string; task: Task & { queued: boolean } }
| { kind: "group"; groupId: string; groupName: string; groupThreadId: string; task: Task & { queued: boolean } };
+/** The conversation the chat window has open, matched against the rows these lists render. */
+export type OpenThread =
+ | { kind: "bot"; botId: string; threadId: string }
+ | { kind: "group"; groupId: string; threadId: string };
+
+export function isOpenThread(entry: AttentionThread, open: OpenThread | undefined): boolean {
+ if (!open || entry.task.threadId !== open.threadId) return false;
+ if (entry.kind === "bot") return open.kind === "bot" && entry.botId === open.botId;
+ return open.kind === "group" && entry.groupId === open.groupId;
+}
+
+/** The row of the conversation the chat window has open: a tint, a left accent bar and an inset outline read as one mark at a glance. */
+export const openThreadRow = "bg-accent/15 shadow-[inset_3px_0_0_0_var(--color-accent)] ring-1 ring-inset ring-accent/30 hover:bg-accent/20";
+
export function attentionOwnerName(entry: AttentionThread): string {
return entry.kind === "bot" ? entry.botName : entry.groupName;
}
@@ -160,20 +174,30 @@ export function crossBotPinnedThreads(bots: Bot[], groups: Group[], queued: Reco
: { kind: "bot", botId: botId!, botName: botName!, task });
}
-export function AttentionThreadRows({ entries, onJump, inset = false }: { entries: AttentionThread[]; onJump: (entry: AttentionThread) => void; inset?: boolean }) {
+export function AttentionThreadRows({ entries, onJump, inset = false, unreadDot = false, current }: {
+ entries: AttentionThread[]; onJump: (entry: AttentionThread) => void; inset?: boolean;
+ /** Mark an unread conversation with a dot and a heavier title, the way the Inbox's own rows are marked. */
+ unreadDot?: boolean;
+ /** The conversation the chat window has open, tinted like a selected sidebar row. */
+ current?: OpenThread;
+}) {
return <>
{entries.map((entry) => {
const { Icon, colorClass, label: status } = attentionRowStatus(entry.task);
const name = attentionOwnerName(entry);
const label = t("attention.item", { title: entry.task.title, name, status });
+ const unread = unreadDot && entry.task.unread === true;
+ const open = isOpenThread(entry, current);
return <button key={`${entry.kind}-${entry.kind === "bot" ? entry.botId : entry.groupId}-${entry.task.threadId}`} type="button" aria-label={label} title={label}
+ aria-current={open ? "page" : undefined} data-open-thread={open || undefined}
onClick={() => onJump(entry)}
- className={cn("flex w-full items-center gap-2.5 text-left text-[13px] text-ink hover:bg-menu-hover", inset ? "rounded-md px-2 py-1.5" : "px-3.5 py-2")}>
+ className={cn("flex w-full items-center gap-2.5 text-left text-[13px] text-ink hover:bg-menu-hover", inset ? "rounded-md px-2 py-1.5" : "px-3.5 py-2", open && openThreadRow)}>
<Icon size={inset ? 16 : 15} aria-hidden="true" className={cn("shrink-0", colorClass)} />
<span className="min-w-0 flex-1">
- <span className="block truncate">{entry.task.title}</span>
+ <span className={cn("block truncate", unread && "font-medium text-ink")}>{entry.task.title}</span>
<span className="block truncate text-[11px] text-ink-secondary">{name} · {status}</span>
</span>
+ {unread && <span data-attention-unread-dot aria-hidden="true" className="size-1.5 shrink-0 rounded-full bg-accent" />}
</button>;
})}
</>;
diff --git a/src/components/SidebarInboxRow.tsx b/src/components/SidebarInboxRow.tsx
index 16b6e308fd..fe67dcc10d 100644
--- a/src/components/SidebarInboxRow.tsx
+++ b/src/components/SidebarInboxRow.tsx
@@ -4,8 +4,10 @@ import { Inbox } from "lucide-react";
import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
import { closeInbox, openInbox, useInboxPanel, useInboxSupport, useInboxView } from "@/state/inbox";
+import { useStore } from "@/state/store";
import { useTeamPeople } from "@/state/team-people";
import { inboxFixes, waitingCount } from "./inbox/inbox-view";
+import { inboxAttentionEntries, unreadConversations } from "./inbox/InboxActive";
export function SidebarInboxRow({ icons, large, running, onOpened }: {
icons: boolean;
@@ -16,10 +18,11 @@ export function SidebarInboxRow({ icons, large, running, onOpened }: {
}) {
const support = useInboxSupport();
const view = useInboxView();
+ const { state } = useStore();
const team = useTeamPeople();
const { open } = useInboxPanel();
if (support === "no") return null;
- const count = waitingCount(view) + inboxFixes(team?.needsYou, view).length;
+ const count = waitingCount(view) + inboxFixes(team?.needsYou, view).length + unreadConversations(inboxAttentionEntries(state, view), view);
const shown = count > 9 ? "9+" : String(count);
const label = count > 0 ? t("inbox.row.count", { count }) : t("inbox.panel.title");
const toggle = () => {
diff --git a/src/components/UnreadContextCard.test.ts b/src/components/UnreadContextCard.test.ts
new file mode 100644
index 0000000000..469e87ba6b
--- /dev/null
+++ b/src/components/UnreadContextCard.test.ts
@@ -0,0 +1,129 @@
+// @vitest-environment happy-dom
+import { act, createElement, type ReactElement } from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, describe, expect, it } from "vitest";
+import { serializeCitation, type CitationAttachment } from "@/lib/citations";
+import { t } from "@/lib/i18n";
+import type { Message } from "@/state/store";
+import { UnreadContextCard } from "./UnreadContextCard";
+
+(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+const citation = (id: string, quote: string, comment?: string): CitationAttachment => ({
+ kind: "citation",
+ version: 1,
+ id,
+ quote,
+ ...(comment ? { comment } : {}),
+ source: { ownerType: "bot", ownerId: "bot-1", threadId: "t1", messageId: "m1", start: 0, end: quote.length, prefix: "", suffix: "" },
+ size: quote.length,
+});
+
+const quoted = (...citations: CitationAttachment[]) => citations.map(serializeCitation).join("\n");
+const message = (text: string): Message => ({ id: "u1", role: "user", kind: "text", text, at: Date.parse("2026-11-16T12:00:00Z") });
+
+let root: Root | null = null;
+let container: HTMLDivElement | null = null;
+
+function draw(element: ReactElement) {
+ container = document.createElement("div");
+ document.body.append(container);
+ root = createRoot(container);
+ act(() => root!.render(element));
+}
+
+afterEach(() => {
+ if (root) act(() => root!.unmount());
+ root = null;
+ container?.remove();
+ container = null;
+});
+
+const card = () => document.querySelector<HTMLElement>('[data-testid="unread-context-card"]');
+const blocks = () => [...document.querySelectorAll<HTMLElement>("[data-unread-context-citation]")];
+
+function renderCard(text: string) {
+ draw(createElement(UnreadContextCard, { message: message(text), onJump: () => {}, onClose: () => {} }));
+}
+
+describe("UnreadContextCard", () => {
+ it("shows three citations whole, with no fixed height or clipping around them", () => {
+ renderCard(`正文\n\n${quoted(citation("c1", "第一段", "第一条评论"), citation("c2", "第二段"), citation("c3", "第三段"))}`);
+ expect(blocks()).toHaveLength(3);
+ expect(card()?.textContent).toContain("第三段");
+ expect(card()?.textContent).not.toContain(t("chat.unreadContext.moreCitations", { count: 1 }));
+
+ const body = document.querySelector<HTMLElement>("[data-unread-context-body]")!;
+ for (const className of ["max-h-32", "overflow-hidden", "overflow-auto", "overflow-y-auto"]) {
+ expect(body.className).not.toContain(className);
+ }
+ expect(document.querySelector("[data-unread-context-text]")?.className).toContain("line-clamp-2");
+ for (const quote of document.querySelectorAll("[data-unread-context-quote]")) expect(quote.className).toContain("line-clamp-2");
+ expect(document.querySelector("[data-unread-context-comment]")?.className).toContain("line-clamp-2");
+ });
+
+ it("gives each of three citations its own long comment, two lines each, with nothing crossing over", () => {
+ const comments = [
+ "第一条评论:说明为什么要改成可见优先,以及固定六行会切掉半条引用的原因。",
+ "第二条评论:这条关注卡片的出现时机,进入未读对话且原消息在首屏外才显示。",
+ "第三条评论:这条补充关闭行为,只影响本次停留,离开再进入会重新判断。",
+ ];
+ renderCard(`正文\n\n${quoted(
+ citation("c1", "第一段", comments[0]),
+ citation("c2", "第二段", comments[1]),
+ citation("c3", "第三段", comments[2]),
+ )}`);
+
+ const citations = blocks();
+ const rendered = citations.map((block) => block.querySelector<HTMLElement>("[data-unread-context-comment]"));
+ expect(citations).toHaveLength(3);
+ expect(rendered).toHaveLength(3);
+ rendered.forEach((comment, index) => {
+ expect(comment).not.toBeNull();
+ expect(comment!.className).toContain("line-clamp-2");
+ expect(comment!.closest("[data-unread-context-citation]")).toBe(citations[index]);
+ expect(comment!.textContent).toContain(comments[index]!);
+ for (const other of comments) if (other !== comments[index]) expect(comment!.textContent).not.toContain(other);
+ });
+ });
+
+ it("keeps the header text-only and puts the two actions in the last row", () => {
+ let jumped = 0;
+ let closed = 0;
+ draw(createElement(UnreadContextCard, {
+ message: message(`正文\n\n${quoted(citation("c1", "第一段", "一条评论"))}`),
+ onJump: () => { jumped += 1; },
+ onClose: () => { closed += 1; },
+ }));
+
+ const rendered = card();
+ expect(rendered).not.toBeNull();
+ const header = rendered!.querySelector<HTMLElement>("[data-unread-context-header]");
+ expect(header).not.toBeNull();
+ expect(header!.querySelectorAll("button")).toHaveLength(0);
+ expect(header!.textContent).toContain(t("chat.unreadContext.title"));
+
+ const actions = rendered!.querySelector<HTMLElement>("[data-unread-context-actions]");
+ expect(actions).not.toBeNull();
+ expect(actions!.parentElement?.lastElementChild).toBe(actions);
+ const buttons = [...actions!.querySelectorAll("button")];
+ expect(buttons).toHaveLength(2);
+ expect(buttons[0]!.textContent).toBe(t("chat.citation.goToSource"));
+ expect(buttons[0]!.className).toContain("rounded-lg");
+ expect(buttons[0]!.className).toContain("border");
+ expect(buttons[1]!.textContent).toBe(t("common.close"));
+ expect(buttons[1]!.className).toContain("bg-accent");
+
+ act(() => buttons[0]!.click());
+ act(() => buttons[1]!.click());
+ expect({ jumped, closed }).toEqual({ jumped: 1, closed: 1 });
+ });
+
+ it("shows the first three of four citations and counts the rest", () => {
+ renderCard(`正文\n\n${quoted(citation("c1", "第一段"), citation("c2", "第二段"), citation("c3", "第三段"), citation("c4", "第四段"))}`);
+ expect(blocks()).toHaveLength(3);
+ expect(card()?.textContent).toContain("第三段");
+ expect(card()?.textContent).not.toContain("第四段");
+ expect(card()?.textContent).toContain(t("chat.unreadContext.moreCitations", { count: 1 }));
+ });
+});
diff --git a/src/components/UnreadContextCard.tsx b/src/components/UnreadContextCard.tsx
new file mode 100644
index 0000000000..0a4600760b
--- /dev/null
+++ b/src/components/UnreadContextCard.tsx
@@ -0,0 +1,76 @@
+import type { Message } from "@/state/store";
+import { activeLocale, t } from "@/lib/i18n";
+import { localizedRelativeTime } from "@/lib/relative-time";
+import { hasUnreadContextContent, unreadContextCitations, unreadContextContent, type UnreadContextAttachment } from "@/lib/unread-context";
+
+function attachmentLabel(kind: UnreadContextAttachment): string {
+ if (kind === "images") return t("chat.unreadContext.images");
+ if (kind === "files") return t("chat.unreadContext.files");
+ return `${t("chat.unreadContext.images")} / ${t("chat.unreadContext.files")}`;
+}
+
+/** The message that started the turn waiting above the unread divider, shown at the top of the conversation. */
+export function UnreadContextCard({
+ message,
+ onJump,
+ onClose,
+}: {
+ message: Message;
+ onJump: () => void;
+ onClose: () => void;
+}) {
+ const content = unreadContextContent(message);
+ if (!hasUnreadContextContent(content)) return null;
+ const { shown: citations, hidden: hiddenCitations } = unreadContextCitations(content.citations);
+ return (
+ <div className="w-full px-5" data-unread-context-card data-testid="unread-context-card">
+ <div className="mb-2 rounded-lg border border-hairline/40 bg-inset/60 px-3 py-2">
+ <div data-unread-context-header className="flex min-w-0 items-center gap-2">
+ <span className="shrink-0 text-[12px] font-medium text-ink-secondary">{t("chat.unreadContext.title")}</span>
+ <span className="shrink-0 text-[11px] text-ink-tertiary">{localizedRelativeTime(message.at, activeLocale())}</span>
+ </div>
+ {/* Each part carries its own line limit, so the card grows to fit them instead of cutting a citation in half. */}
+ <div className="mt-1" data-unread-context-body>
+ {content.text && (
+ <div dir="auto" data-unread-context-text className="line-clamp-2 whitespace-pre-wrap [overflow-wrap:anywhere] text-[13px] leading-relaxed text-ink">
+ {content.text}
+ </div>
+ )}
+ {citations.map((citation) => (
+ <div key={citation.id} className="mt-1.5 rounded-md border border-accent/20 bg-accent/[0.05] px-2.5 py-1.5" data-unread-context-citation>
+ <div className="text-[10px] font-semibold uppercase tracking-wide text-ink-secondary">{t("chat.citation.quoted")}</div>
+ <div dir="auto" data-unread-context-quote className="mt-0.5 line-clamp-2 whitespace-pre-wrap break-words text-[12px] leading-relaxed text-ink">{citation.quote}</div>
+ {citation.comment && (
+ <div data-unread-context-comment className="mt-1 line-clamp-2 text-[12px] text-ink-secondary">
+ <span className="font-semibold">{t("chat.citation.comment")}</span> {citation.comment}
+ </div>
+ )}
+ </div>
+ ))}
+ {content.attachment && (
+ <div className="mt-1 text-[13px] text-ink-secondary">{attachmentLabel(content.attachment)}</div>
+ )}
+ </div>
+ {hiddenCitations > 0 && (
+ <div className="mt-1 text-[11px] text-ink-tertiary">{t("chat.unreadContext.moreCitations", { count: hiddenCitations })}</div>
+ )}
+ <div data-unread-context-actions className="mt-2 flex items-center justify-end gap-2">
+ <button
+ type="button"
+ onClick={onJump}
+ className="rounded-lg border border-hairline/40 px-3 py-1.5 text-[12px] hover:bg-raised"
+ >
+ {t("chat.citation.goToSource")}
+ </button>
+ <button
+ type="button"
+ onClick={onClose}
+ className="rounded-lg bg-accent px-3 py-1.5 text-[12px] text-white"
+ >
+ {t("common.close")}
+ </button>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/src/components/UnreadContextOverlay.tsx b/src/components/UnreadContextOverlay.tsx
new file mode 100644
index 0000000000..8e4a4989d7
--- /dev/null
+++ b/src/components/UnreadContextOverlay.tsx
@@ -0,0 +1,55 @@
+import { useEffect, useMemo, useRef, useState } from "react";
+import type { RefObject } from "react";
+import { isRowOffscreen, unreadContextMessage } from "@/lib/unread-context";
+import type { Message } from "@/state/store";
+import { UnreadContextCard } from "./UnreadContextCard";
+
+/** The card that brings back the person's line above the unread divider, judged once per visit. */
+export function UnreadContextOverlay({ messages, windowedMessages, unreadMessageId, scrollRef, visitKey, onJump }: {
+ messages: readonly Message[];
+ windowedMessages: readonly Message[];
+ unreadMessageId?: string | null;
+ scrollRef: RefObject<HTMLDivElement | null>;
+ visitKey: string;
+ onJump: (messageId: string) => void;
+}) {
+ const unreadContext = useMemo(() => unreadContextMessage(messages, unreadMessageId), [messages, unreadMessageId]);
+ const unreadContextKey = unreadContext ? `${visitKey}:${unreadContext.id}` : null;
+ const unreadContextDecided = useRef<string | null>(null);
+ const [unreadContextShown, setUnreadContextShown] = useState<string | null>(null);
+ const [unreadContextDismissed, setUnreadContextDismissed] = useState<string | null>(null);
+ useEffect(() => {
+ if (!unreadContext || !unreadContextKey || unreadContextDecided.current === unreadContextKey) return;
+ const messageId = unreadContext.id;
+ if (!windowedMessages.some((message) => message.id === messageId)) {
+ unreadContextDecided.current = unreadContextKey;
+ setUnreadContextShown(unreadContextKey);
+ return;
+ }
+ // After paint, with the opening scroll in place: measure where the message ended up.
+ const frame = requestAnimationFrame(() => {
+ const scroller = scrollRef.current;
+ const wrapper = scroller && [...scroller.querySelectorAll<HTMLElement>("[data-mid]")].find((row) => row.dataset.mid === messageId);
+ const row = wrapper?.querySelector<HTMLElement>("[data-message-row]") ?? (wrapper?.lastElementChild as HTMLElement | null);
+ unreadContextDecided.current = unreadContextKey;
+ setUnreadContextShown(isRowOffscreen(row?.getBoundingClientRect() ?? null, scroller?.getBoundingClientRect() ?? null) ? unreadContextKey : null);
+ });
+ return () => cancelAnimationFrame(frame);
+ }, [unreadContext, unreadContextKey, windowedMessages, scrollRef]);
+ useEffect(() => {
+ if (!unreadContextKey || unreadContextShown !== unreadContextKey || unreadContextDismissed === unreadContextKey) return;
+ const onKey = (event: KeyboardEvent) => {
+ if (event.key === "Escape") setUnreadContextDismissed(unreadContextKey);
+ };
+ window.addEventListener("keydown", onKey);
+ return () => window.removeEventListener("keydown", onKey);
+ }, [unreadContextKey, unreadContextShown, unreadContextDismissed]);
+ if (!unreadContextKey || !unreadContext || unreadContextShown !== unreadContextKey || unreadContextDismissed === unreadContextKey) return null;
+ return (
+ <UnreadContextCard
+ message={unreadContext}
+ onJump={() => { onJump(unreadContext.id); setUnreadContextDismissed(unreadContextKey); }}
+ onClose={() => setUnreadContextDismissed(unreadContextKey)}
+ />
+ );
+}
diff --git a/src/components/attention-unread-dot.dom.test.ts b/src/components/attention-unread-dot.dom.test.ts
new file mode 100644
index 0000000000..297cfcb371
--- /dev/null
+++ b/src/components/attention-unread-dot.dom.test.ts
@@ -0,0 +1,37 @@
+// @vitest-environment happy-dom
+// The Inbox's active list marks an unread conversation with a dot.
+import { act, createElement } from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, it } from "vitest";
+import { AttentionThreadRows, type AttentionThread } from "./SidebarBotActivity";
+
+(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+let root: Root;
+const entry = (threadId: string, unread: boolean): AttentionThread => ({
+ kind: "bot", botId: "eli", botName: "Eli",
+ task: { threadId, title: threadId, createdAt: 1, updatedAt: 1, queued: false, ...(unread ? { unread: true } : {}) },
+});
+const mount = (unreadDot: boolean) => act(async () => {
+ root.render(createElement(AttentionThreadRows, {
+ entries: [entry("unread-thread", true), entry("read-thread", false)],
+ inset: true, unreadDot, onJump: () => undefined,
+ }));
+});
+
+beforeEach(() => { root = createRoot(document.body.appendChild(document.createElement("div"))); });
+afterEach(() => { act(() => root.unmount()); document.body.innerHTML = ""; });
+
+describe("the unread dot on the active list", () => {
+ it("marks only the unread conversation", async () => {
+ await mount(true);
+ const dots = [...document.querySelectorAll("[data-attention-unread-dot]")];
+ expect(dots).toHaveLength(1);
+ expect(dots[0]!.closest("button")!.textContent).toContain("unread-thread");
+ });
+
+ it("draws nothing extra with the switch off", async () => {
+ await mount(false);
+ expect(document.querySelectorAll("[data-attention-unread-dot]")).toHaveLength(0);
+ });
+});
diff --git a/src/components/inbox/FinishedThreads.tsx b/src/components/inbox/FinishedThreads.tsx
new file mode 100644
index 0000000000..e9a58519ab
--- /dev/null
+++ b/src/components/inbox/FinishedThreads.tsx
@@ -0,0 +1,99 @@
+// The conversations that are finished and already read, under the Inbox's active list, so a thread the person
+// just read stays findable for a while instead of vanishing. Nothing here is stored: a thread qualifies while it is
+// idle, has nothing unread and is not archived, and the ten most recent ones are shown.
+import { CheckCircle2 } from "lucide-react";
+import type { Bot, Group, Task } from "@/state/store";
+import { cn } from "@/lib/cn";
+import { t } from "@/lib/i18n";
+import { roomThreadSpeakerId, roomThreadWorking } from "@/lib/room-threads";
+import { attentionOwnerName, isOpenThread, openThreadRow, type AttentionThread, type OpenThread } from "../SidebarBotActivity";
+import { formatUpdatedAt, threadRecency, threadUpdatedLabel } from "../SidebarThreadRow";
+
+export const FINISHED_LIMIT = 10;
+
+/** A finished conversation, a bot's or a room's, opened the way the Inbox's active list opens it. */
+export type FinishedThread = AttentionThread;
+
+/** A thread that never moved is an empty "New thread" unless it was opened from a message or was read. */
+function everStarted(task: { createdAt?: number; updatedAt?: number; origin?: unknown; lastReadMessageId?: string }): boolean {
+ return (task.updatedAt ?? 0) > (task.createdAt ?? 0) || task.origin !== undefined || task.lastReadMessageId !== undefined;
+}
+
+/** Finished, already-read conversations, newest first: idle, nothing unread, not archived, bot threads and rooms. */
+export function finishedThreads(bots: readonly Bot[], groups: readonly Group[] = [], queued: Record<string, unknown[]> = {},
+ limit = FINISHED_LIMIT, readThreads?: ReadonlySet<string>, exclude?: ReadonlySet<string>): FinishedThread[] {
+ const found: Array<FinishedThread & { at: number }> = [];
+ for (const bot of bots) {
+ if (bot.hidden) continue;
+ for (const task of bot.tasks ?? []) {
+ if (exclude?.has(task.threadId)) continue;
+ if ((task.unread && !readThreads?.has(task.threadId)) || task.busy || task.routineRunId || task.archivedAt) continue;
+ if (!everStarted(task)) continue;
+ if (task.activity === "working" || task.activity === "waiting-on-you" || task.waitingForTeammates === true) continue;
+ if (queued[task.threadId]?.length) continue;
+ found.push({ kind: "bot", botId: bot.id, botName: bot.name, task: { ...task, queued: false }, at: threadRecency(task) });
+ }
+ }
+ for (const group of groups) {
+ if (group.dm) continue;
+ for (const task of group.tasks ?? []) {
+ if (exclude?.has(task.threadId)) continue;
+ const mainThread = task.threadId === group.threadId;
+ const unread = task.unread ?? (mainThread && group.unread);
+ if ((unread && !readThreads?.has(task.threadId)) || task.archivedAt) continue;
+ if (roomThreadWorking(group, task.threadId)) continue;
+ if (!everStarted({ ...task, lastReadMessageId: task.lastReadMessageId ?? (mainThread ? group.lastReadMessageId : undefined) })) continue;
+ const speaker = roomThreadSpeakerId(group, task.threadId);
+ const waiting = Boolean(speaker) && bots.find((bot) => bot.id === speaker)?.activity === "waiting-on-you";
+ if (waiting || task.activity === "waiting-on-you") continue;
+ if (queued[task.threadId]?.length) continue;
+ found.push({ kind: "group", groupId: group.id, groupName: group.name, groupThreadId: group.threadId,
+ task: { ...task, queued: false } as Task & { queued: boolean }, at: threadRecency(task) });
+ }
+ }
+ return found.sort((a, b) => b.at - a.at).slice(0, limit).map(({ at: _at, ...row }) => row);
+}
+
+export function FinishedThreads({ bots, groups, queued, readThreads, exclude, now, current, onOpen }: {
+ bots: readonly Bot[];
+ groups: readonly Group[];
+ queued: Record<string, unknown[]>;
+ /** Conversations the person has already read in the Inbox, even if the chat itself was never opened. */
+ readThreads?: ReadonlySet<string>;
+ /** Conversations the pinned section at the top already shows: this list leaves them out. */
+ exclude?: ReadonlySet<string>;
+ /** The clock the row's last-activity label is relative to. */
+ now: number;
+ /** The conversation the chat window has open, tinted like a selected sidebar row. */
+ current?: OpenThread;
+ onOpen(row: FinishedThread): void;
+}) {
+ const rows = finishedThreads(bots, groups, queued, FINISHED_LIMIT, readThreads, exclude);
+ if (!rows.length) return null;
+ return (
+ <section data-inbox-finished aria-label={t("inbox.settled.title")} className="border-t border-hairline/40 px-1.5 py-1.5">
+ <div className="flex items-center gap-1 px-2 py-0.5">
+ <span className="min-w-0 flex-1 truncate text-[12px] font-medium text-ink-secondary">{t("inbox.settled.title")}</span>
+ </div>
+ {rows.map((row) => {
+ const name = attentionOwnerName(row);
+ const at = threadRecency(row.task);
+ const label = t("attention.item", { title: row.task.title, name, status: t("inbox.settled.read") });
+ const open = isOpenThread(row, current);
+ return (
+ <button key={`${row.kind}-${row.kind === "bot" ? row.botId : row.groupId}-${row.task.threadId}`} type="button" aria-label={label} title={label}
+ aria-current={open ? "page" : undefined} data-open-thread={open || undefined} onClick={() => onOpen(row)}
+ className={cn("flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-[13px] text-ink hover:bg-menu-hover", open && openThreadRow)}>
+ <CheckCircle2 size={16} aria-hidden="true" className="shrink-0 text-ink-tertiary" />
+ <span className="min-w-0 flex-1">
+ <span className="block truncate">{row.task.title}</span>
+ <span className="block truncate text-[11px] text-ink-secondary">
+ {name} · {t("inbox.settled.read")} · <time data-finished-when dateTime={new Date(at).toISOString()} title={formatUpdatedAt(at)}>{threadUpdatedLabel(at, now)}</time>
+ </span>
+ </span>
+ </button>
+ );
+ })}
+ </section>
+ );
+}
diff --git a/src/components/inbox/InboxActive.tsx b/src/components/inbox/InboxActive.tsx
index 49fe01f653..2a89bf49ae 100644
--- a/src/components/inbox/InboxActive.tsx
+++ b/src/components/inbox/InboxActive.tsx
@@ -3,24 +3,68 @@
import { Pin, PinOff } from "lucide-react";
import type { InboxView } from "../../../shared/inbox";
import { t } from "@/lib/i18n";
-import { useStore } from "@/state/store";
+import { useStore, type AppState } from "@/state/store";
import { useTeamPeople } from "@/state/team-people";
-import { AttentionThreadRows, attentionJumpAction, crossBotAttentionThreads } from "../SidebarBotActivity";
+import { AttentionThreadRows, attentionJumpAction, crossBotAttentionThreads, type AttentionThread, type OpenThread } from "../SidebarBotActivity";
import { NeedsYouLine } from "../TeamOwner";
import { setAttentionPinned, useAttentionPinned } from "./attention-pinned";
import { closeInbox } from "@/state/inbox";
import { inboxFixes } from "./inbox-view";
-export function InboxActive({ view }: { view: InboxView | null }) {
- const { state, dispatch } = useStore();
- const team = useTeamPeople();
- const pinned = useAttentionPinned();
+/** The conversations this list shows: the work in progress — at work, waiting on a teammate or on the person, or
+ * finished but still unread. A conversation the person has read leaves for the finished list below, so the two lists
+ * never show the same thread. */
+export function inboxAttentionEntries(state: Pick<AppState, "bots" | "pendingQueued" | "groups">, view: InboxView | null): AttentionThread[] {
const rows = view?.rows ?? [];
const asked = new Set(rows.filter((row) => row.tab === "needs-you").map((row) => row.origin?.threadId));
- const news = new Set(rows.filter((row) => row.tab === "info").map((row) => row.origin?.threadId));
+ const read = readNewsThreads(view);
const atWork = (task: { busy?: boolean; activity?: string; queued?: boolean }) => task.busy === true || task.activity === "working" || task.queued === true;
- const entries = crossBotAttentionThreads(state.bots, state.pendingQueued, undefined, state.groups)
- .filter((entry) => !asked.has(entry.task.threadId) && (atWork(entry.task) || !news.has(entry.task.threadId)));
+ // A conversation counts as read once the person opened it, or read the news line that stands for it.
+ const inProgress = (task: AttentionThread["task"]) => atWork(task) || task.activity === "waiting-on-you" || task.waitingForTeammates === true
+ || (task.unread === true && !read.has(task.threadId));
+ return crossBotAttentionThreads(state.bots, state.pendingQueued, undefined, state.groups)
+ .filter((entry) => !asked.has(entry.task.threadId) && inProgress(entry.task));
+}
+
+/** The conversation the chat window has open, if it shows one: a bot's current thread, or the room's. */
+export function inboxOpenThread(state: Pick<AppState, "activeView" | "selectedId" | "bots" | "groups">): OpenThread | undefined {
+ if (state.activeView !== "chat") return undefined;
+ const bot = state.bots.find((one) => one.id === state.selectedId);
+ if (bot) return { kind: "bot", botId: bot.id, threadId: bot.threadId };
+ const group = state.groups.find((one) => one.id === state.selectedId);
+ return group ? { kind: "group", groupId: group.id, threadId: group.threadId } : undefined;
+}
+
+/** The conversations whose news lines have all been read: reading in the Inbox counts as reading them. */
+export function readNewsThreads(view: InboxView | null): Set<string> {
+ const read = new Set<string>();
+ const unread = new Set<string>();
+ for (const row of view?.rows ?? []) {
+ const threadId = row.origin?.threadId;
+ if (!threadId || row.tab !== "info") continue;
+ (row.unread ? unread : read).add(threadId);
+ }
+ for (const threadId of unread) read.delete(threadId);
+ return read;
+}
+
+/** How many of those conversations still wait to be read: only news with no unread line of its own in the list, so a
+ * conversation the line count already covers is never counted twice. */
+export function unreadConversations(entries: readonly AttentionThread[], view?: InboxView | null): number {
+ const lined = new Set<string>();
+ for (const row of view?.rows ?? []) if (row.tab === "info" && row.unread && row.origin?.threadId) lined.add(row.origin.threadId);
+ return entries.filter((entry) => entry.task.unread === true && !lined.has(entry.task.threadId)).length;
+}
+
+export function InboxActive({ view, current, exclude }: {
+ view: InboxView | null; current?: OpenThread;
+ /** Conversations the pinned section at the top already shows: these lists leave them out so none appears twice. */
+ exclude?: ReadonlySet<string>;
+}) {
+ const { state, dispatch } = useStore();
+ const team = useTeamPeople();
+ const pinned = useAttentionPinned();
+ const entries = inboxAttentionEntries(state, view).filter((entry) => !exclude?.has(entry.task.threadId));
const fixes = inboxFixes(team?.needsYou, view);
return (
<>
@@ -38,7 +82,7 @@ export function InboxActive({ view }: { view: InboxView | null }) {
{pinned ? <PinOff size={14} aria-hidden="true" /> : <Pin size={14} aria-hidden="true" />}
</button>
</div>
- <AttentionThreadRows inset entries={entries} onJump={(entry) => dispatch(attentionJumpAction(entry))} />
+ <AttentionThreadRows inset entries={entries} unreadDot current={current} onJump={(entry) => dispatch(attentionJumpAction(entry))} />
</section>
)}
</>
diff --git a/src/components/inbox/InboxEverywhere.dom.test.ts b/src/components/inbox/InboxEverywhere.dom.test.ts
index 91cbcaf3db..55ad3bd9b8 100644
--- a/src/components/inbox/InboxEverywhere.dom.test.ts
+++ b/src/components/inbox/InboxEverywhere.dom.test.ts
@@ -241,7 +241,8 @@ describe("a place's inbox in the panel", () => {
const section = document.querySelector<HTMLElement>("[data-inbox-active]")!;
expect(section.textContent).toContain("Writing the page");
expect(section.textContent).not.toContain("Pricing work");
- expect(section.textContent, "unread news is already a line above").not.toContain("Told already");
+ expect(section.textContent, "an unread conversation stays until it is read").toContain("Told already");
+ expect(section.querySelector("[data-attention-unread-dot]"), "marked as unread").not.toBeNull();
expect(section.textContent, "work still going stays reachable").toContain("Told and still working");
await act(async () => { [...section.querySelectorAll<HTMLElement>("button")].find((one) => one.textContent?.includes("Writing the page"))!.click(); });
expect(dispatch).toHaveBeenCalledWith({ type: "switchTask", botId: "eli", threadId: "eli-work" });
diff --git a/src/components/inbox/InboxPanel.dom.test.ts b/src/components/inbox/InboxPanel.dom.test.ts
index 88a2d4eb87..745d5bb441 100644
--- a/src/components/inbox/InboxPanel.dom.test.ts
+++ b/src/components/inbox/InboxPanel.dom.test.ts
@@ -18,7 +18,7 @@ vi.mock("../../state/api", () => ({
import { initialState, StoreContext, type AppState, type Bot } from "@/state/store";
import { BOT_BUTTON, botButtonTone } from "@/lib/bot-button";
import { closeInbox, currentInbox, currentInboxPanel, inboxVersion, openInbox, setInboxView, useInboxLoader } from "@/state/inbox";
-import { approvalRow, inboxView, messageRow, questionRow, reportRow, settledRow } from "@/testing/inbox-fixture";
+import { approvalRow, INBOX_NOW, inboxView, messageRow, questionRow, reportRow, settledRow } from "@/testing/inbox-fixture";
import type { InboxView } from "../../../shared/inbox";
import { InboxCardSlot } from "./InboxCard";
import { InboxPanel } from "./InboxPanel";
@@ -112,6 +112,24 @@ describe("the inbox panel", () => {
expect(document.querySelector('[data-inbox-panel="sheet"]')).not.toBeNull();
expect(document.querySelector('[data-inbox-panel="side"]')).toBeNull();
});
+
+ it("shows a pinned conversation once, and counts its unread news once", async () => {
+ const reporter = {
+ id: "reporter", name: "Reporter", threadId: "rep-main", tasks: [
+ { threadId: "rep-daily", title: "Daily digest", createdAt: 0, updatedAt: INBOX_NOW, pinned: true, unread: true },
+ { threadId: "rep-old", title: "Older digest", createdAt: 0, updatedAt: INBOX_NOW - 60_000, pinned: true },
+ ],
+ } as unknown as Bot;
+ shown(inboxView([{ ...reportRow, unread: true }]));
+ openInbox();
+ await mount(createElement(InboxPanel), [reporter]);
+ expect([...document.querySelectorAll("[data-pinned-title]")].map((el) => el.textContent)).toEqual(["Daily digest", "Older digest"]);
+ const active = [...document.querySelectorAll("[data-inbox-active] button")].map((button) => button.textContent).join(" ");
+ expect(active, "the pinned section already shows it").not.toContain("Daily digest");
+ const finished = [...document.querySelectorAll("[data-inbox-finished] button")].map((button) => button.textContent).join(" ");
+ expect(finished).not.toContain("Older digest");
+ expect(document.querySelector("[data-inbox-tab-count]")?.textContent, "one line plus the same conversation is one").toBe("1");
+ });
});
describe("the inbox's card in the chat", () => {
diff --git a/src/components/inbox/InboxPanel.tsx b/src/components/inbox/InboxPanel.tsx
index 76f042dd95..3ad4a46170 100644
--- a/src/components/inbox/InboxPanel.tsx
+++ b/src/components/inbox/InboxPanel.tsx
@@ -7,9 +7,13 @@ import { useAdvancedMode } from "@/lib/interface-mode";
import { t } from "@/lib/i18n";
import { PHONE_LAYOUT, useMediaQuery } from "@/lib/use-media-query";
import { closeInbox, markAllInboxRead, readInboxLine, readInboxRow, useInboxMarkingAll, useInboxPanel, useInboxView, widenInbox } from "@/state/inbox";
-import { InboxActive } from "./InboxActive";
+import { useStore } from "@/state/store";
+import { InboxActive, inboxAttentionEntries, inboxOpenThread, readNewsThreads, unreadConversations } from "./InboxActive";
+import { attentionJumpAction, attentionUnpinAction } from "../SidebarBotActivity";
import { InboxReading } from "./InboxReading";
import { InboxRowItem } from "./InboxRow";
+import { FinishedThreads } from "./FinishedThreads";
+import { PinnedThreads, pinnedThreadRows } from "./PinnedThreads";
import { matchesSearch, nextAfter } from "./inbox-answer";
import { listedRows, waitingCount } from "./inbox-view";
import { useInboxActions } from "./use-inbox-actions";
@@ -18,6 +22,7 @@ import { roundButtonCls } from "../bot-panel/rows";
export function InboxPanel() {
const view = useInboxView();
+ const { state, dispatch } = useStore();
const panel = useInboxPanel();
const markingAll = useInboxMarkingAll();
const phone = useMediaQuery(PHONE_LAYOUT);
@@ -37,7 +42,10 @@ export function InboxPanel() {
};
const reading = panel.reading ? view?.rows.find((row) => row.id === panel.reading) : undefined;
const open = (row: InboxRow) => { readInboxRow(row); readInboxLine(row.id); };
- const rows = listedRows(view).filter((row) => matchesSearch(row, query));
+ // The notice list is upstream's: a read line stays until the person marks it done. Reading a conversation moves the
+ // conversation to Finished; it does not remove the notice it came from.
+ const listed = listedRows(view);
+ const rows = listed.filter((row) => matchesSearch(row, query));
const ids = rows.map((row) => row.id);
const at = reading ? ids.indexOf(reading.id) : -1;
@@ -59,7 +67,9 @@ export function InboxPanel() {
const row = rows[at + by];
if (row) open(row);
};
- const count = waitingCount(view);
+ const pinnedThreads = new Set(pinnedThreadRows(state.bots, state.groups, state.pendingQueued).map((row) => row.task.threadId));
+ const count = waitingCount(view) + unreadConversations(inboxAttentionEntries(state, view), view);
+ const openThread = inboxOpenThread(state);
const body = (
<>
<div className="flex h-[50px] shrink-0 items-start gap-2.5 px-[13px] pt-[13px]">
@@ -90,14 +100,16 @@ export function InboxPanel() {
) : (
<>
<div className="min-h-0 flex-1 overflow-y-auto">
- {listedRows(view).length > 0 && <label className="mx-[13px] my-2.5 flex h-8 items-center gap-2 rounded-lg bg-ink/[0.045] px-2.5 ring-[0.5px] ring-ink/[0.12] focus-within:ring-ink/30">
+ {/* The conversations each bot and room pinned, at the top of the list. */}
+ {!query.trim() && <PinnedThreads bots={state.bots} groups={state.groups} queued={state.pendingQueued} now={now} current={openThread} onOpen={(row) => dispatch(attentionJumpAction(row))} onUnpin={(row) => dispatch(attentionUnpinAction(row))} />}
+ {listed.length > 0 && <label className="mx-[13px] my-2.5 flex h-8 items-center gap-2 rounded-lg bg-ink/[0.045] px-2.5 ring-[0.5px] ring-ink/[0.12] focus-within:ring-ink/30">
<Search size={14} aria-hidden="true" className="shrink-0 text-ink-tertiary" />
<input type="search" value={query} onChange={(event) => setQuery(event.target.value)} placeholder={t("inbox.search")} aria-label={t("inbox.search")}
className="min-w-0 flex-1 bg-transparent text-[13px] text-ink outline-none placeholder:text-ink-tertiary [&::-webkit-search-cancel-button]:hidden" />
</label>}
<div role="list" data-inbox-list aria-label={t("inbox.panel.title")} className="space-y-0.5 px-1.5 pb-1.5">
{rows.length === 0
- ? query.trim() && listedRows(view).length
+ ? query.trim() && listed.length
? <p className="px-4 py-8 text-center text-[13px] text-ink-secondary">{t("inbox.noMatch")}</p>
: (
<div data-inbox-empty className="mx-auto flex max-w-[16rem] flex-col items-center px-4 py-10 text-center">
@@ -108,7 +120,9 @@ export function InboxPanel() {
)
: rows.map((row) => <InboxRowItem key={row.id} row={row} now={now} onOpen={open} onAction={run} />)}
</div>
- {!query.trim() && <InboxActive view={view} />}
+ {!query.trim() && <InboxActive view={view} current={openThread} exclude={pinnedThreads} />}
+ {/* The finished, already-read conversations. */}
+ {!query.trim() && <FinishedThreads bots={state.bots} groups={state.groups} queued={state.pendingQueued} readThreads={readNewsThreads(view)} exclude={pinnedThreads} now={now} current={openThread} onOpen={(row) => dispatch(attentionJumpAction(row))} />}
</div>
</>
)}
diff --git a/src/components/inbox/PinnedThreads.tsx b/src/components/inbox/PinnedThreads.tsx
new file mode 100644
index 0000000000..e9692208b7
--- /dev/null
+++ b/src/components/inbox/PinnedThreads.tsx
@@ -0,0 +1,74 @@
+// The conversations each bot and room has pinned, gathered at the top of the Inbox so the person reaches them
+// without leaving it: the last-activity label and open-row mark the finished list uses, plus an unpin button that
+// dispatches the official action. Nothing here is stored; `task.pinned` is upstream's own field.
+import { Pin, PinOff } from "lucide-react";
+import type { Bot, Group } from "@/state/store";
+import { cn } from "@/lib/cn";
+import { t } from "@/lib/i18n";
+import {
+ attentionOwnerName, attentionRowStatus, crossBotPinnedThreads, isOpenThread, openThreadRow,
+ type AttentionThread, type OpenThread,
+} from "../SidebarBotActivity";
+import { formatUpdatedAt, threadRecency, threadUpdatedLabel } from "../SidebarThreadRow";
+
+/** Pinned conversations from every bot and room, most recently active first, so the label beside a row and the
+ * order rows sit in agree. Upstream's cross-bot list orders by sidebar position instead. */
+export function pinnedThreadRows(bots: readonly Bot[], groups: readonly Group[], queued: Record<string, unknown[]>): AttentionThread[] {
+ return crossBotPinnedThreads([...bots], [...groups], queued)
+ .sort((a, b) => threadRecency(b.task) - threadRecency(a.task));
+}
+
+export function PinnedThreads({ bots, groups, queued, now, current, onOpen, onUnpin }: {
+ bots: readonly Bot[];
+ groups: readonly Group[];
+ queued: Record<string, unknown[]>;
+ /** The clock each row's last-activity label is relative to. */
+ now: number;
+ /** The conversation the chat window has open, tinted like a selected sidebar row. */
+ current?: OpenThread;
+ onOpen(row: AttentionThread): void;
+ onUnpin(row: AttentionThread): void;
+}) {
+ const rows = pinnedThreadRows(bots, groups, queued);
+ if (!rows.length) return null;
+ return (
+ <section data-inbox-pinned aria-label={t("sidebar.pinnedThreads.title")} className="border-b border-hairline/40 px-1.5 py-1.5">
+ <div className="flex items-center gap-1.5 px-2 py-0.5">
+ <Pin size={12} aria-hidden="true" className="shrink-0 text-ink-secondary" />
+ <span className="min-w-0 flex-1 truncate text-[12px] font-medium text-ink-secondary">{t("sidebar.pinnedThreads.title")}</span>
+ </div>
+ {rows.map((row) => {
+ const name = attentionOwnerName(row);
+ const { Icon, colorClass, label: status, active } = attentionRowStatus(row.task);
+ const at = threadRecency(row.task);
+ const when = threadUpdatedLabel(at, now);
+ const meta = active ? `${name} · ${status}` : name;
+ const label = t("sidebar.pinnedThreads.item", { title: row.task.title, name: when ? `${meta} · ${when}` : meta });
+ const open = isOpenThread(row, current);
+ return (
+ <div key={`${row.kind}-${row.kind === "bot" ? row.botId : row.groupId}-${row.task.threadId}`} className="group/pinned flex w-full items-center">
+ <button type="button" aria-label={label} title={label} data-pinned-row
+ aria-current={open ? "page" : undefined} data-open-thread={open || undefined}
+ onClick={() => onOpen(row)}
+ className={cn("flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-[13px] text-ink hover:bg-menu-hover", open && openThreadRow)}>
+ {active
+ ? <Icon size={16} aria-hidden="true" className={cn("shrink-0", colorClass)} />
+ : <Pin size={16} aria-hidden="true" className="shrink-0 text-ink-tertiary" />}
+ <span className="min-w-0 flex-1">
+ <span className="block truncate" data-pinned-title>{row.task.title}</span>
+ <span className="block truncate text-[11px] text-ink-secondary">
+ {meta}{when && <> · <time data-pinned-when dateTime={new Date(at).toISOString()} title={formatUpdatedAt(at)}>{when}</time></>}
+ </span>
+ </span>
+ </button>
+ <button type="button" data-inbox-unpin aria-label={t("sidebar.bot.unpin")} title={t("sidebar.bot.unpin")}
+ onClick={() => onUnpin(row)}
+ className="mr-1 flex size-6 shrink-0 items-center justify-center rounded text-ink-secondary opacity-0 hover:bg-raised hover:text-ink focus-visible:opacity-100 group-hover/pinned:opacity-100 max-md:opacity-70 touch:opacity-70">
+ <PinOff size={13} aria-hidden="true" />
+ </button>
+ </div>
+ );
+ })}
+ </section>
+ );
+}
diff --git a/src/components/inbox/attention-read.test.ts b/src/components/inbox/attention-read.test.ts
new file mode 100644
index 0000000000..504e8e2cae
--- /dev/null
+++ b/src/components/inbox/attention-read.test.ts
@@ -0,0 +1,56 @@
+// A finished conversation stays in the active list until it is
+// read, then leaves for the finished list instead of showing in both. Reading means either opening the conversation or
+// reading the news line that stands for it.
+import { describe, expect, it } from "vitest";
+import type { AppState } from "@/state/store";
+import { inboxAttentionEntries, inboxOpenThread, readNewsThreads, unreadConversations } from "./InboxActive";
+
+const bot = (id: string, tasks: Array<Record<string, unknown>>) =>
+ ({ id, name: id, hidden: false, threadId: `${id}-main`, tasks } as unknown as AppState["bots"][number]);
+const state = (bots: AppState["bots"]) =>
+ ({ bots, pendingQueued: {}, groups: [] } as unknown as Pick<AppState, "bots" | "pendingQueued" | "groups">);
+const view = (rows: Array<Record<string, unknown>>) =>
+ ({ botId: null, threadId: null, rows, anchor: null } as never);
+
+const bots = [bot("eli", [
+ { threadId: "eli-a", title: "Finished but unread", createdAt: 1, updatedAt: 2, unread: true },
+ { threadId: "eli-b", title: "Finished and read", createdAt: 1, updatedAt: 3, unread: false },
+])];
+const line = (unread: boolean) => [{ id: "l1", tab: "info", origin: { threadId: "eli-a" }, unread }];
+
+describe("inboxAttentionEntries", () => {
+ it("keeps a finished conversation in the active list while its news is unread, counted once with that line", () => {
+ expect(inboxAttentionEntries(state(bots), view(line(true))).map((entry) => entry.task.threadId)).toEqual(["eli-a"]);
+ expect(unreadConversations(inboxAttentionEntries(state(bots), view(line(true))), view(line(true)))).toBe(0);
+ });
+
+ it("counts an unread conversation whose news has no line of its own in the list", () => {
+ const quiet = [bot("eli", [{ threadId: "eli-c", title: "News without a line", createdAt: 1, updatedAt: 4, unread: true }])];
+ expect(unreadConversations(inboxAttentionEntries(state(quiet), view([])), view([]))).toBe(1);
+ });
+
+ it("moves it off the active list once its news line is read, even before the chat is opened", () => {
+ expect(inboxAttentionEntries(state(bots), view(line(false)))).toEqual([]);
+ });
+
+ it("counts a conversation read when every one of its news lines is read", () => {
+ expect([...readNewsThreads(view(line(false)))]).toEqual(["eli-a"]);
+ expect([...readNewsThreads(view(line(true)))]).toEqual([]);
+ });
+});
+
+const open = (selectedId: string, activeView = "chat") =>
+ ({ bots, pendingQueued: {}, groups: [{ id: "room", threadId: "room-thread" }], activeView, selectedId } as unknown as
+ Pick<AppState, "activeView" | "selectedId" | "bots" | "groups">);
+
+describe("inboxOpenThread", () => {
+ it("names the open bot thread or room thread so both lists can tint that row", () => {
+ expect(inboxOpenThread(open("eli"))).toEqual({ kind: "bot", botId: "eli", threadId: "eli-main" });
+ expect(inboxOpenThread(open("room"))).toEqual({ kind: "group", groupId: "room", threadId: "room-thread" });
+ });
+
+ it("names nothing while the chat is not what the window shows", () => {
+ expect(inboxOpenThread(open("eli", "routines"))).toBeUndefined();
+ expect(inboxOpenThread(open("nobody"))).toBeUndefined();
+ });
+});
diff --git a/src/components/inbox/finished.dom.test.ts b/src/components/inbox/finished.dom.test.ts
new file mode 100644
index 0000000000..06bf14ed82
--- /dev/null
+++ b/src/components/inbox/finished.dom.test.ts
@@ -0,0 +1,49 @@
+// @vitest-environment happy-dom
+// The finished list shows when each conversation last moved.
+import { act, createElement } from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import type { Bot, Group, Task } from "@/state/store";
+import { t } from "@/lib/i18n";
+import { FinishedThreads } from "./FinishedThreads";
+
+(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+const NOW = Date.parse("2026-11-15T16:00:00Z");
+const task = (threadId: string, patch: Partial<Task> = {}): Task => ({ threadId, title: threadId, createdAt: 0, updatedAt: NOW, ...patch });
+const bot = (id: string, tasks: Task[]): Bot => ({ id, name: id, tasks } as unknown as Bot);
+
+let root: Root;
+const mount = (bots: Bot[], groups: Group[] = [], current?: { kind: "bot"; botId: string; threadId: string }) => act(async () => {
+ root.render(createElement(FinishedThreads, { bots, groups, queued: {}, now: NOW, current, onOpen: vi.fn() }));
+});
+
+beforeEach(() => {
+ root = createRoot(document.body.appendChild(document.createElement("div")));
+});
+afterEach(() => {
+ act(() => root.unmount());
+ document.body.innerHTML = "";
+});
+
+describe("the finished list", () => {
+ it("says how long ago each conversation last moved", async () => {
+ const bots = [bot("eli", [task("recent", { updatedAt: NOW - 5 * 60_000 }), task("older", { updatedAt: NOW - 3 * 60 * 60_000 })])];
+ await mount(bots);
+ const stamps = [...document.querySelectorAll<HTMLElement>("[data-finished-when]")];
+ expect(stamps.map((stamp) => stamp.textContent)).toEqual([
+ t("task.updated.minutes", { count: 5 }),
+ t("task.updated.hours", { count: 3 }),
+ ]);
+ expect(stamps[0]!.getAttribute("dateTime")).toBe(new Date(NOW - 5 * 60_000).toISOString());
+ });
+
+ it("tints the conversation the chat window has open, and only that one", async () => {
+ const bots = [bot("eli", [task("open", { updatedAt: NOW }), task("elsewhere", { updatedAt: NOW - 60_000 })])];
+ await mount(bots, [], { kind: "bot", botId: "eli", threadId: "open" });
+ const rows = [...document.querySelectorAll<HTMLElement>("[data-inbox-finished] button")];
+ expect(rows.map((row) => row.getAttribute("aria-current"))).toEqual(["page", null]);
+ expect(rows.map((row) => row.hasAttribute("data-open-thread"))).toEqual([true, false]);
+ expect(rows[0]!.className).toContain("bg-accent/15");
+ });
+});
diff --git a/src/components/inbox/finished.test.ts b/src/components/inbox/finished.test.ts
new file mode 100644
index 0000000000..cb5f4c88bb
--- /dev/null
+++ b/src/components/inbox/finished.test.ts
@@ -0,0 +1,82 @@
+// Which conversations the Inbox's finished list shows.
+import { describe, expect, it } from "vitest";
+import type { Bot, Group, GroupTask, Task } from "@/state/store";
+import { finishedThreads } from "./FinishedThreads";
+
+const task = (threadId: string, patch: Partial<Task> = {}): Task => ({ threadId, title: threadId, createdAt: 0, updatedAt: 1, ...patch });
+const bot = (id: string, tasks: Task[]): Bot => ({ id, name: id, tasks } as unknown as Bot);
+const group = (tasks: GroupTask[], patch: Partial<Group> = {}): Group =>
+ ({ id: "room", threadId: "room-main", name: "Room", memberIds: [], unread: false, createdAt: 0, tasks, ...patch } as unknown as Group);
+
+describe("finishedThreads", () => {
+ it("shows read, idle conversations and hides unread, busy or archived ones", () => {
+ const bots = [bot("eli", [
+ task("read", { updatedAt: 30 }),
+ task("unread", { updatedAt: 40, unread: true }),
+ task("busy", { updatedAt: 50, busy: true }),
+ task("working", { updatedAt: 60, activity: "working" }),
+ task("archived", { updatedAt: 70, archivedAt: 5 }),
+ task("routine", { updatedAt: 80, routineRunId: "run-1" }),
+ ])];
+ expect(finishedThreads(bots).map((row) => row.task.threadId)).toEqual(["read"]);
+ });
+
+ it("keeps the ten newest by when the conversation last moved", () => {
+ const bots = [bot("eli", Array.from({ length: 12 }, (_, i) => i + 1).map((n) => task(`t${n}`, { updatedAt: n })))];
+ expect(finishedThreads(bots).map((row) => row.task.threadId)).toEqual(["t12", "t11", "t10", "t9", "t8", "t7", "t6", "t5", "t4", "t3"]);
+ });
+
+ it("leaves out a thread that never got going", () => {
+ const bots = [bot("eli", [task("empty", { createdAt: 5, updatedAt: 5 }), task("used", { updatedAt: 9 })])];
+ expect(finishedThreads(bots).map((row) => row.task.threadId)).toEqual(["used"]);
+ });
+
+ it("keeps a conversation opened from a message although it never moved again", () => {
+ const quoted = task("quoted", { createdAt: 5, updatedAt: 5, origin: { threadId: "main", messageId: "m1" } as Task["origin"] });
+ const bots = [bot("eli", [quoted, task("empty", { createdAt: 6, updatedAt: 6 })])];
+ expect(finishedThreads(bots).map((row) => row.task.threadId)).toEqual(["quoted"]);
+ });
+
+ it("shows a conversation the person read in the Inbox although the chat was never opened", () => {
+ const bots = [bot("eli", [task("read-in-inbox", { updatedAt: 9, unread: true })])];
+ expect(finishedThreads(bots).map((row) => row.task.threadId)).toEqual([]);
+ expect(finishedThreads(bots, [], {}, 5, new Set(["read-in-inbox"])).map((row) => row.task.threadId)).toEqual(["read-in-inbox"]);
+ });
+
+ it("leaves out a conversation the pinned section already shows", () => {
+ const bots = [bot("eli", [task("pinned", { updatedAt: 2 }), task("plain", { updatedAt: 1 })])];
+ expect(finishedThreads(bots, [], {}, 5, undefined, new Set(["pinned"])).map((row) => row.task.threadId)).toEqual(["plain"]);
+ });
+
+ it("leaves out a conversation still queued behind another", () => {
+ const bots = [bot("eli", [task("read", { updatedAt: 1 }), task("queued", { updatedAt: 2 })])];
+ expect(finishedThreads(bots, [], { queued: [{}] }).map((row) => row.task.threadId)).toEqual(["read"]);
+ });
+
+ it("shows a room's read, idle conversation and leaves out the working, unread or archived ones", () => {
+ const room = group([
+ { threadId: "room-main", title: "room", createdAt: 0, updatedAt: 7 },
+ { threadId: "room-working", title: "working", createdAt: 0, updatedAt: 8, working: true },
+ { threadId: "room-unread", title: "unread", createdAt: 0, updatedAt: 9, unread: true },
+ { threadId: "room-archived", title: "archived", createdAt: 0, updatedAt: 10, archivedAt: 1 },
+ ]);
+ expect(finishedThreads([], [room]).map((row) => [row.kind, row.task.threadId])).toEqual([["group", "room-main"]]);
+ });
+
+ it("leaves out a room whose latest word waits on the person", () => {
+ const chief = { id: "chief", name: "Chief", activity: "waiting-on-you", tasks: [] } as unknown as Bot;
+ const room = group([{ threadId: "room-ask", title: "ask", createdAt: 0, updatedAt: 9, busyBotId: "chief" }]);
+ expect(finishedThreads([chief], [room])).toEqual([]);
+ });
+
+ it("sorts bot conversations and rooms together, newest first", () => {
+ const bots = [bot("eli", [task("bot-new", { updatedAt: 20 })])];
+ const room = group([{ threadId: "room-main", title: "room", createdAt: 0, updatedAt: 30 }]);
+ expect(finishedThreads(bots, [room]).map((row) => row.task.threadId)).toEqual(["room-main", "bot-new"]);
+ });
+
+ it("leaves out one-to-one bot channels", () => {
+ const room = group([{ threadId: "room-main", title: "room", createdAt: 0, updatedAt: 9 }], { dm: true });
+ expect(finishedThreads([], [room])).toEqual([]);
+ });
+});
diff --git a/src/components/inbox/pinned.dom.test.ts b/src/components/inbox/pinned.dom.test.ts
new file mode 100644
index 0000000000..180c2b3320
--- /dev/null
+++ b/src/components/inbox/pinned.dom.test.ts
@@ -0,0 +1,84 @@
+// @vitest-environment happy-dom
+// The Inbox's pinned section.
+import { act, createElement } from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import type { Bot, Group, GroupTask, Task } from "@/state/store";
+import { t } from "@/lib/i18n";
+import type { AttentionThread } from "../SidebarBotActivity";
+import { PinnedThreads, pinnedThreadRows } from "./PinnedThreads";
+
+(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+const NOW = Date.parse("2026-11-16T08:00:00Z");
+const task = (threadId: string, patch: Partial<Task> = {}): Task => ({ threadId, title: threadId, createdAt: 0, updatedAt: NOW, ...patch });
+const bot = (id: string, tasks: Task[]): Bot => ({ id, name: id, tasks } as unknown as Bot);
+const room = (tasks: GroupTask[]): Group =>
+ ({ id: "room", threadId: "room-main", name: "Room", memberIds: [], unread: false, createdAt: 0, tasks } as unknown as Group);
+
+let root: Root;
+const onOpen = vi.fn();
+const onUnpin = vi.fn();
+const mount = (bots: Bot[], groups: Group[] = [], current?: { kind: "bot"; botId: string; threadId: string }) => act(async () => {
+ root.render(createElement(PinnedThreads, { bots, groups, queued: {}, now: NOW, current, onOpen, onUnpin }));
+});
+const rowTitles = () => [...document.querySelectorAll<HTMLElement>("[data-pinned-row]")].map((row) => row.querySelector("[data-pinned-title]")?.textContent);
+
+beforeEach(() => {
+ onOpen.mockReset();
+ onUnpin.mockReset();
+ root = createRoot(document.body.appendChild(document.createElement("div")));
+});
+afterEach(() => {
+ act(() => root.unmount());
+ document.body.innerHTML = "";
+});
+
+describe("the pinned section", () => {
+ it("lists only the pinned conversations", async () => {
+ await mount([bot("eli", [task("pinned", { pinned: true }), task("loose")])]);
+ expect(rowTitles()).toEqual(["pinned"]);
+ });
+
+ it("puts the most recently active conversation first, the order its label reads in", async () => {
+ await mount([bot("eli", [
+ task("older", { pinned: true, updatedAt: NOW - 3 * 60 * 60_000 }),
+ task("newer", { pinned: true, updatedAt: NOW - 60_000 }),
+ ])]);
+ expect(rowTitles()).toEqual(["newer", "older"]);
+ });
+
+ it("says who the conversation belongs to and when it last moved", async () => {
+ await mount([bot("eli", [task("pinned", { pinned: true, updatedAt: NOW - 5 * 60_000 })])]);
+ const stamp = document.querySelector("[data-pinned-when]");
+ expect(stamp?.textContent).toBe(t("task.updated.minutes", { count: 5 }));
+ expect(stamp?.getAttribute("dateTime")).toBe(new Date(NOW - 5 * 60_000).toISOString());
+ });
+
+ it("tints the conversation the chat window has open, and only that one", async () => {
+ await mount([bot("eli", [task("open", { pinned: true }), task("elsewhere", { pinned: true, updatedAt: NOW - 60_000 })])],
+ [], { kind: "bot", botId: "eli", threadId: "open" });
+ const rows = [...document.querySelectorAll<HTMLElement>("[data-pinned-row]")];
+ expect(rows.map((row) => row.getAttribute("aria-current"))).toEqual(["page", null]);
+ expect(rows[0]!.className).toContain("bg-accent/15");
+ });
+
+ it("gathers a room's pinned conversation too", async () => {
+ await mount([], [room([{ threadId: "room-main", title: "room chat", createdAt: 0, updatedAt: NOW, pinned: true }])]);
+ expect(rowTitles()).toEqual(["room chat"]);
+ expect(pinnedThreadRows([], [room([{ threadId: "room-main", title: "room chat", createdAt: 0, pinned: true }])], {})[0]!.kind).toBe("group");
+ });
+
+ it("unpins the row it was asked to, naming that row's own conversation", async () => {
+ await mount([bot("eli", [task("pinned", { pinned: true })])]);
+ await act(async () => { document.querySelector<HTMLElement>("[data-inbox-unpin]")!.click(); });
+ expect(onUnpin).toHaveBeenCalledTimes(1);
+ const entry = onUnpin.mock.calls[0]![0] as AttentionThread;
+ expect([entry.kind, entry.kind === "bot" ? entry.botId : null, entry.task.threadId]).toEqual(["bot", "eli", "pinned"]);
+ });
+
+ it("renders nothing when nothing is pinned", async () => {
+ await mount([bot("eli", [task("loose")])]);
+ expect(document.querySelector("[data-inbox-pinned]")).toBeNull();
+ });
+});
diff --git a/src/lib/unread-context.test.ts b/src/lib/unread-context.test.ts
new file mode 100644
index 0000000000..b17aa540a0
--- /dev/null
+++ b/src/lib/unread-context.test.ts
@@ -0,0 +1,129 @@
+import { describe, expect, it } from "vitest";
+import { serializeCitation, type CitationAttachment } from "./citations";
+import { hasUnreadContextContent, isRowOffscreen, unreadContextCitations, unreadContextContent, unreadContextMessage } from "./unread-context";
+import type { Message } from "@/state/store";
+
+const line = (id: string, role: Message["role"], fields: Partial<Message> = {}): Message =>
+ ({ id, role, kind: "text", text: id, at: Number(id.replace(/\D/g, "")) || 1, ...fields });
+
+const citation = (id: string, quote: string, comment?: string): CitationAttachment => ({
+ kind: "citation",
+ version: 1,
+ id,
+ quote,
+ ...(comment ? { comment } : {}),
+ source: { ownerType: "bot", ownerId: "bot-1", threadId: "t1", messageId: "m1", start: 0, end: quote.length, prefix: "", suffix: "" },
+ size: quote.length + (comment?.length ?? 0),
+});
+
+const attachmentImage = '\n\n<attached-image path="/tmp/shot.png" />';
+const attachmentFile = '\n\n<attached-file path="/tmp/report.pdf" />';
+
+const viewport = { top: 100, bottom: 900, height: 800 };
+
+describe("unreadContextMessage", () => {
+ it("takes the person's own text line just above the unread divider", () => {
+ const rows = [
+ line("u1", "user"),
+ line("b2", "bot"),
+ line("u3", "user"),
+ line("b4", "bot"),
+ line("b5", "bot", { kind: "activity" }),
+ line("u6", "user", { text: " " }),
+ ];
+ expect(unreadContextMessage(rows, "b5")?.id).toBe("u3");
+ });
+
+ it("skips another bot's line and non-text rows", () => {
+ const peer = line("p4", "user", { peerAsk: { botId: "chief", name: "Chief" } });
+ const legacyPeer = line("p5", "user", { text: "[Message from @Chief, another bot in this OpenMausBot workspace] hi" });
+ const rows = [line("u1", "user"), line("b2", "bot"), peer, legacyPeer, line("a6", "user", { kind: "activity" }), line("b7", "bot")];
+ expect(unreadContextMessage(rows, "b7")?.id).toBe("u1");
+ expect(unreadContextMessage([line("b2", "bot"), line("u3", "user")], "b2")).toBeNull();
+ });
+
+ it("is null without unread, without a placed divider, or without a person's line before it", () => {
+ const rows = [line("u1", "user"), line("b2", "bot")];
+ expect(unreadContextMessage(rows, null)).toBeNull();
+ expect(unreadContextMessage(rows, "gone")).toBeNull();
+ expect(unreadContextMessage([line("b1", "bot"), line("b2", "bot")], "b2")).toBeNull();
+ });
+
+ it("never takes a line at or after the divider", () => {
+ const rows = [line("b1", "bot"), line("b2", "bot"), line("u3", "user")];
+ expect(unreadContextMessage(rows, "b2")).toBeNull();
+ });
+});
+
+describe("unreadContextContent", () => {
+ it("keeps the typed text and pulls citations out of the encoded marker", () => {
+ const first = citation("c1", "被引用的原文", "我的评论");
+ const text = `看看这个\n\n${serializeCitation(first)}`;
+ const content = unreadContextContent({ text });
+ expect(content.text).toBe("看看这个");
+ expect(content.citations).toHaveLength(1);
+ expect(content.citations[0]).toMatchObject({ quote: "被引用的原文", comment: "我的评论", source: { messageId: "m1" } });
+ expect(content.attachment).toBeNull();
+ });
+
+ it("keeps every citation so the card can expand the first and badge the rest", () => {
+ const text = `两条引用\n\n${serializeCitation(citation("c1", "第一段"))}\n${serializeCitation(citation("c2", "第二段", "说明"))}`;
+ const content = unreadContextContent({ text });
+ expect(content.text).toBe("两条引用");
+ expect(content.citations.map((entry) => entry.id)).toEqual(["c1", "c2"]);
+ expect(content.citations[1]?.comment).toBe("说明");
+ });
+
+ it("lays out the first three citations flat and counts the rest", () => {
+ const citations = ["一", "二", "三", "四"].map((quote, index) => citation(`c${index + 1}`, quote));
+ const { shown, hidden } = unreadContextCitations(citations);
+ expect(shown.map((entry) => entry.quote)).toEqual(["一", "二", "三"]);
+ expect(hidden).toBe(1);
+ expect(unreadContextCitations(citations.slice(0, 3))).toEqual({ shown: citations.slice(0, 3), hidden: 0 });
+ expect(unreadContextCitations([])).toEqual({ shown: [], hidden: 0 });
+ });
+
+ it("reports an image-only or file-only message instead of leaving the card blank", () => {
+ const image = unreadContextContent({ text: attachmentImage });
+ expect(image.text).toBe("");
+ expect(image.attachment).toBe("images");
+ expect(image.imageCount).toBe(1);
+ expect(hasUnreadContextContent(image)).toBe(true);
+
+ const file = unreadContextContent({ text: attachmentFile });
+ expect(file.attachment).toBe("files");
+ expect(file.fileCount).toBe(1);
+
+ const both = unreadContextContent({ text: `${attachmentImage}${attachmentFile}` });
+ expect(both.attachment).toBe("both");
+ expect(both.imageCount).toBe(1);
+ expect(both.fileCount).toBe(1);
+ });
+
+ it("keeps a message with text and attachments readable as text", () => {
+ const content = unreadContextContent({ text: `带图片的说明${attachmentImage}` });
+ expect(content.text).toBe("带图片的说明");
+ expect(content.attachment).toBeNull();
+ expect(content.imageCount).toBe(1);
+ });
+
+ it("has nothing to show for a message with no text, citation or attachment", () => {
+ expect(hasUnreadContextContent(unreadContextContent({ text: " " }))).toBe(false);
+ });
+});
+
+describe("isRowOffscreen", () => {
+ it("is true only when the row sits entirely above or below the first screen", () => {
+ expect(isRowOffscreen({ top: 20, bottom: 80, height: 60 }, viewport)).toBe(true);
+ expect(isRowOffscreen({ top: 920, bottom: 980, height: 60 }, viewport)).toBe(true);
+ expect(isRowOffscreen({ top: 80, bottom: 140, height: 60 }, viewport)).toBe(false);
+ expect(isRowOffscreen({ top: 200, bottom: 260, height: 60 }, viewport)).toBe(false);
+ expect(isRowOffscreen({ top: 880, bottom: 940, height: 60 }, viewport)).toBe(false);
+ });
+
+ it("stays closed when layout is not measurable yet", () => {
+ expect(isRowOffscreen(null, viewport)).toBe(false);
+ expect(isRowOffscreen({ top: 0, bottom: 0, height: 0 }, viewport)).toBe(false);
+ expect(isRowOffscreen({ top: 20, bottom: 80, height: 60 }, { top: 0, bottom: 0, height: 0 })).toBe(false);
+ });
+});
diff --git a/src/lib/unread-context.ts b/src/lib/unread-context.ts
new file mode 100644
index 0000000000..966ad78da2
--- /dev/null
+++ b/src/lib/unread-context.ts
@@ -0,0 +1,72 @@
+import { splitTranscriptCitations, type CitationAttachment } from "@/lib/citations";
+import { splitTranscriptAttachments } from "@/lib/composer-attachments";
+import { peerLine } from "@/lib/peer-message";
+import type { Message } from "@/state/store";
+
+/**
+ * The person's own text line just above the unread divider: the message that started the turn
+ * they are coming back to. It uses the same boundary and the same person filter as the divider.
+ */
+export function unreadContextMessage(messages: readonly Message[], unreadMessageId?: string | null): Message | null {
+ if (!unreadMessageId) return null;
+ const at = messages.findIndex((message) => message.id === unreadMessageId);
+ if (at < 0) return null;
+ for (let i = at - 1; i >= 0; i--) {
+ const message = messages[i]!;
+ if (message.role === "user" && message.kind === "text" && !peerLine(message)) return message;
+ }
+ return null;
+}
+
+export type UnreadContextAttachment = "images" | "files" | "both";
+
+export type UnreadContextContent = {
+ /** The typed text with citation markers and attachment tags removed. */
+ text: string;
+ citations: CitationAttachment[];
+ imageCount: number;
+ fileCount: number;
+ /** Set only when the message has no visible text: the card says what was attached instead of staying blank. */
+ attachment: UnreadContextAttachment | null;
+};
+
+export function unreadContextContent(message: Pick<Message, "text">): UnreadContextContent {
+ const cited = splitTranscriptCitations(message.text ?? "");
+ const attached = splitTranscriptAttachments(cited.display);
+ const text = attached.display.trim();
+ const empty = !text && cited.citations.length === 0;
+ const attachment: UnreadContextAttachment | null = !empty
+ ? null
+ : attached.images.length > 0 && attached.files.length > 0
+ ? "both"
+ : attached.images.length > 0
+ ? "images"
+ : attached.files.length > 0 ? "files" : null;
+ return { text, citations: cited.citations, imageCount: attached.images.length, fileCount: attached.files.length, attachment };
+}
+
+export function hasUnreadContextContent(content: UnreadContextContent): boolean {
+ return Boolean(content.text || content.citations.length > 0 || content.attachment);
+}
+
+/** The card lays out this many citations flat; the rest fold into one count line. */
+export const UNREAD_CONTEXT_CITATION_LIMIT = 3;
+
+export function unreadContextCitations(
+ citations: readonly CitationAttachment[],
+ limit = UNREAD_CONTEXT_CITATION_LIMIT,
+): { shown: CitationAttachment[]; hidden: number } {
+ const keep = Math.max(0, limit);
+ return { shown: citations.slice(0, keep), hidden: Math.max(0, citations.length - keep) };
+}
+
+export type RowRect = { top: number; bottom: number; height: number };
+
+/**
+ * Whether the row sits entirely outside the scroller's viewport, so the person has to scroll to it.
+ * A zero-sized rect means layout is not measurable yet; keep the card away instead of guessing.
+ */
+export function isRowOffscreen(row: RowRect | null, viewport: RowRect | null): boolean {
+ if (!row || !viewport || row.height <= 0 || viewport.height <= 0) return false;
+ return row.bottom <= viewport.top || row.top >= viewport.bottom;
+}
diff --git a/src/locales/de.json b/src/locales/de.json
index 474ad685b1..7014fece1f 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -2880,6 +2880,8 @@
"ask.detail.more": "Alles anzeigen",
"inbox.action.closeQuestion": "Ohne Antwort schließen",
"inbox.markAllRead": "Alle als gelesen markieren",
+ "inbox.settled.title": "Erledigt",
+ "inbox.settled.read": "Gelesen",
"question.somethingElse": "Etwas anderes…",
"question.answerPlaceholder": "Deine Antwort",
"question.status.closed": "Ohne Antwort geschlossen",
@@ -4010,5 +4012,6 @@
"server.rooms.linkedEnded": "{place} hat sich 30 Tage lang nicht verbunden, deshalb wurde die Verbindung dorthin beendet. Nicht mehr in diesem Raum: {bots}.",
"room.members.far.place": "auf {place}",
"room.members.far.off": "Verbindung ist aus",
- "room.members.far.missing": "Nicht mehr verfügbar"
+ "room.members.far.missing": "Nicht mehr verfügbar",
+ "devices.computers.typeCode": "Öffne auf deinem anderen Computer in {app} „Mit einem Server verbinden“ und gib diesen Code ein."
}
diff --git a/src/locales/en.json b/src/locales/en.json
index 8eedb385af..c2c8680f53 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -2286,6 +2286,7 @@
"sidebar.people.yourInboxWaiting": "Your inbox: waiting on you, {count}",
"sidebar.people.invite": "Invite someone",
"inbox.panel.title": "Inbox",
+ "inbox.settled.title": "Finished",
"inbox.empty": "Nothing for you yet.",
"inbox.emptyHint": "When a bot needs your OK, has a question or finishes something, it shows up here.",
"inbox.row.count": "Inbox, {count} waiting",
@@ -2734,6 +2735,10 @@
"chat.jumpToLatestAria": "Jump to latest messages",
"chat.newMessages": "New",
"chat.newMessagesAria": "New messages",
+ "chat.unreadContext.title": "Previous message",
+ "chat.unreadContext.images": "Image",
+ "chat.unreadContext.files": "File",
+ "chat.unreadContext.moreCitations": "and {count} more",
"chat.verify.title": "This run",
"chat.verify.aria": "This run",
"chat.verify.steps": "Run steps",
@@ -11016,5 +11021,6 @@
"templateImport.remove": "Remove {name}",
"sidebar.addDepartment": "Add department",
"sidebar.import": "Import…",
- "team.shareDepartment": "Share"
+ "team.shareDepartment": "Share",
+ "inbox.settled.read": "Read"
}
diff --git a/src/locales/es.json b/src/locales/es.json
index 2bc84006c6..424f4ee4e4 100644
--- a/src/locales/es.json
+++ b/src/locales/es.json
@@ -5568,6 +5568,8 @@
"ask.detail.more": "Mostrar todo",
"inbox.action.closeQuestion": "Cerrar sin responder",
"inbox.markAllRead": "Marcar todo como leído",
+ "inbox.settled.title": "Terminado",
+ "inbox.settled.read": "Leído",
"question.somethingElse": "Otra cosa…",
"question.done": "Listo",
"common.done": "Listo",
@@ -6392,5 +6394,6 @@
"remote.tailscale.needsApproval": "Este ordenador espera la aprobación en tu red de Tailscale. Apruébalo en la consola de administración de Tailscale y vuelve a intentarlo.",
"together.switch.title": "Este equipo y My Cloud juntos",
"together.switch.line": "Desactivado de forma predeterminada. Los bots del Cloud y los de este equipo aparecen en una sola lista, y cada uno se abre donde está.",
- "together.switch.failed": "No se pudo guardar. Inténtalo de nuevo."
+ "together.switch.failed": "No se pudo guardar. Inténtalo de nuevo.",
+ "devices.computers.typeCode": "En tu otro ordenador, abre Conectar a un servidor en {app} y escribe este código."
}
diff --git a/src/locales/fr.json b/src/locales/fr.json
index 6f78654fac..a743d423e7 100644
--- a/src/locales/fr.json
+++ b/src/locales/fr.json
@@ -2751,6 +2751,8 @@
"ask.detail.more": "Tout afficher",
"inbox.action.closeQuestion": "Fermer sans répondre",
"inbox.markAllRead": "Tout marquer comme lu",
+ "inbox.settled.title": "Terminé",
+ "inbox.settled.read": "Lu",
"question.somethingElse": "Autre chose…",
"question.done": "Terminé",
"common.done": "Terminé",
@@ -3796,5 +3798,6 @@
"remote.tailscale.needsApproval": "Cet ordinateur attend d'être approuvé sur votre réseau Tailscale. Approuvez-le dans la console d'administration Tailscale, puis réessayez.",
"together.switch.title": "Cet ordinateur et Mon Cloud ensemble",
"together.switch.line": "Désactivé par défaut. Les bots du Cloud et ceux de cet ordinateur s'affichent dans une seule liste, et chacun s'ouvre là où il se trouve.",
- "together.switch.failed": "Impossible d'enregistrer. Réessayez."
+ "together.switch.failed": "Impossible d'enregistrer. Réessayez.",
+ "devices.computers.typeCode": "Sur votre autre ordinateur, ouvrez Se connecter à un serveur dans {app} et saisissez ce code."
}
diff --git a/src/locales/hi.json b/src/locales/hi.json
index e14db2b7f7..dcc0ad3f4f 100644
--- a/src/locales/hi.json
+++ b/src/locales/hi.json
@@ -2751,6 +2751,8 @@
"ask.detail.more": "सब दिखाएँ",
"inbox.action.closeQuestion": "बिना जवाब दिए बंद करें",
"inbox.markAllRead": "सभी को पढ़ा हुआ चिह्नित करें",
+ "inbox.settled.title": "पूर्ण",
+ "inbox.settled.read": "पढ़ा गया",
"question.somethingElse": "कुछ और…",
"question.done": "हो गया",
"common.done": "हो गया",
@@ -3650,5 +3652,6 @@
"remote.tailscale.needsApproval": "यह कंप्यूटर आपके Tailscale नेटवर्क पर मंज़ूरी का इंतज़ार कर रहा है। Tailscale एडमिन कंसोल में इसे मंज़ूर करें, फिर दोबारा कोशिश करें।",
"together.switch.title": "यही कंप्यूटर और मेरा क्लाउड एक साथ",
"together.switch.line": "डिफ़ॉल्ट रूप से बंद। क्लाउड के बॉट और इस कंप्यूटर के बॉट एक ही सूची में दिखते हैं, और हर बॉट वहीं खुलता है जहाँ वह है।",
- "together.switch.failed": "इसे सहेजा नहीं जा सका। फिर से कोशिश करें।"
+ "together.switch.failed": "इसे सहेजा नहीं जा सका। फिर से कोशिश करें।",
+ "devices.computers.typeCode": "अपने दूसरे कंप्यूटर पर {app} में सर्वर से कनेक्ट करें खोलें और यह कोड लिखें।"
}
diff --git a/src/locales/it.json b/src/locales/it.json
index 44c992df81..7d87c1c85d 100644
--- a/src/locales/it.json
+++ b/src/locales/it.json
@@ -6180,6 +6180,8 @@
"ask.detail.more": "Mostra tutto",
"inbox.action.closeQuestion": "Chiudi senza rispondere",
"inbox.markAllRead": "Segna tutto come letto",
+ "inbox.settled.title": "Completato",
+ "inbox.settled.read": "Letto",
"question.somethingElse": "Altro…",
"question.done": "Fatto",
"approval.status.timedOut": "Nessuna risposta in tempo: non eseguito",
@@ -6966,5 +6968,6 @@
"remote.tailscale.needsApproval": "Questo computer è in attesa di approvazione sulla tua rete Tailscale. Approvalo nella console di amministrazione di Tailscale, poi riprova.",
"together.switch.title": "Questo computer e Il mio Cloud insieme",
"together.switch.line": "Disattivato per impostazione predefinita. I bot del Cloud e quelli di questo computer compaiono in un unico elenco, e ognuno si apre dove si trova.",
- "together.switch.failed": "Non è stato possibile salvare. Riprova."
+ "together.switch.failed": "Non è stato possibile salvare. Riprova.",
+ "devices.computers.typeCode": "Sull'altro computer, apri Connetti a un server in {app} e digita questo codice."
}
diff --git a/src/locales/ja.json b/src/locales/ja.json
index 9743408d2e..3a5f5db632 100644
--- a/src/locales/ja.json
+++ b/src/locales/ja.json
@@ -7191,6 +7191,8 @@
"ask.detail.more": "すべて表示",
"inbox.action.closeQuestion": "回答せずに閉じる",
"inbox.markAllRead": "すべて既読にする",
+ "inbox.settled.title": "完了",
+ "inbox.settled.read": "既読",
"question.somethingElse": "その他…",
"question.done": "完了",
"question.yourAnswer": "自分の回答",
@@ -7938,5 +7940,6 @@
"remote.tailscale.needsApproval": "このコンピューターは Tailscale ネットワークでの承認を待っています。Tailscale の管理コンソールで承認してから、もう一度お試しください。",
"together.switch.title": "このコンピューターと My Cloud をまとめる",
"together.switch.line": "既定ではオフです。Cloud のボットとこのコンピューターのボットを 1 つの一覧に表示し、それぞれがある場所で開きます。",
- "together.switch.failed": "保存できませんでした。もう一度お試しください。"
+ "together.switch.failed": "保存できませんでした。もう一度お試しください。",
+ "devices.computers.typeCode": "もう一台のコンピュータで {app} の「サーバーに接続」を開き、このコードを入力してください。"
}
diff --git a/src/locales/ko.json b/src/locales/ko.json
index f8cdd2515c..43ed4a6cf0 100644
--- a/src/locales/ko.json
+++ b/src/locales/ko.json
@@ -1872,6 +1872,8 @@
"inbox.reviewInChat": "답하려면 이 내용이 온 채팅에서 확인하세요.",
"inbox.youReplied": "답장함",
"inbox.markAllRead": "모두 읽음으로 표시",
+ "inbox.settled.title": "완료됨",
+ "inbox.settled.read": "읽음",
"sidebar.people.mention": "{name}에게 쓰기",
"sidebar.bot.markUnread": "읽지 않음으로 표시",
"sidebar.bot.rename": "이름 바꾸기",
@@ -7631,5 +7633,6 @@
"remote.tailscale.needsApproval": "이 컴퓨터는 Tailscale 네트워크에서 승인을 기다리고 있습니다. Tailscale 관리 콘솔에서 승인한 다음 다시 시도하세요.",
"together.switch.title": "이 컴퓨터와 내 클라우드 함께 보기",
"together.switch.line": "기본값은 꺼짐입니다. 클라우드의 봇과 이 컴퓨터의 봇이 하나의 목록에 표시되며, 각 봇은 자기가 있는 곳에서 열립니다.",
- "together.switch.failed": "저장하지 못했습니다. 다시 시도하세요."
+ "together.switch.failed": "저장하지 못했습니다. 다시 시도하세요.",
+ "devices.computers.typeCode": "다른 컴퓨터의 {app}에서 서버에 연결을 열고 이 코드를 입력하세요."
}
diff --git a/src/locales/pl.json b/src/locales/pl.json
index 890dbc48b2..681cf47673 100644
--- a/src/locales/pl.json
+++ b/src/locales/pl.json
@@ -6311,6 +6311,8 @@
"ask.detail.more": "Pokaż wszystko",
"inbox.action.closeQuestion": "Zamknij bez odpowiedzi",
"inbox.markAllRead": "Oznacz wszystko jako przeczytane",
+ "inbox.settled.title": "Zakończone",
+ "inbox.settled.read": "Przeczytane",
"question.somethingElse": "Coś innego…",
"question.done": "Gotowe",
"approval.status.timedOut": "Brak odpowiedzi na czas — nie uruchomiono",
@@ -7100,5 +7102,6 @@
"remote.tailscale.needsApproval": "Ten komputer czeka na zatwierdzenie w Twojej sieci Tailscale. Zatwierdź go w konsoli administracyjnej Tailscale, a potem spróbuj ponownie.",
"together.switch.title": "Ten komputer i My Cloud razem",
"together.switch.line": "Domyślnie wyłączone. Boty z Cloud i boty z tego komputera są na jednej liście, a każdy otwiera się tam, gdzie działa.",
- "together.switch.failed": "Nie udało się zapisać. Spróbuj ponownie."
+ "together.switch.failed": "Nie udało się zapisać. Spróbuj ponownie.",
+ "devices.computers.typeCode": "Na drugim komputerze otwórz Połącz z serwerem w {app} i wpisz ten kod."
}
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index 1c8e1c7cbd..914ead097c 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -8008,6 +8008,12 @@
"ask.detail.more": "Mostrar tudo",
"inbox.action.closeQuestion": "Fechar sem responder",
"inbox.markAllRead": "Marcar tudo como lido",
+ "inbox.settled.title": "Concluído",
+ "inbox.settled.read": "Lido",
+ "chat.unreadContext.title": "Mensagem anterior",
+ "chat.unreadContext.images": "Imagem",
+ "chat.unreadContext.files": "Arquivo",
+ "chat.unreadContext.moreCitations": "e mais {count}",
"question.somethingElse": "Outra coisa…",
"question.done": "Concluir",
"question.yourAnswer": "Sua resposta",
diff --git a/src/locales/ru.json b/src/locales/ru.json
index a9ff1c91ce..d0f7f647d3 100644
--- a/src/locales/ru.json
+++ b/src/locales/ru.json
@@ -6372,6 +6372,8 @@
"ask.detail.more": "Показать всё",
"inbox.action.closeQuestion": "Закрыть без ответа",
"inbox.markAllRead": "Отметить всё как прочитанное",
+ "inbox.settled.title": "Завершено",
+ "inbox.settled.read": "Прочитано",
"question.somethingElse": "Что-то другое…",
"question.done": "Готово",
"approval.status.timedOut": "Нет ответа вовремя — не выполнено",
@@ -7154,5 +7156,6 @@
"remote.tailscale.needsApproval": "Этот компьютер ждёт одобрения в вашей сети Tailscale. Одобрите его в консоли администратора Tailscale, затем попробуйте снова.",
"together.switch.title": "Этот компьютер и Моё облако вместе",
"together.switch.line": "По умолчанию выключено. Боты из облака и боты этого компьютера показаны в одном списке, и каждый открывается там, где он находится.",
- "together.switch.failed": "Не удалось сохранить. Попробуйте ещё раз."
+ "together.switch.failed": "Не удалось сохранить. Попробуйте ещё раз.",
+ "devices.computers.typeCode": "На другом компьютере откройте «Подключиться к серверу» в {app} и введите этот код."
}
diff --git a/src/locales/tr.json b/src/locales/tr.json
index 827c40b2e3..cd26927c6a 100644
--- a/src/locales/tr.json
+++ b/src/locales/tr.json
@@ -5060,6 +5060,8 @@
"ask.detail.more": "Tümünü göster",
"inbox.action.closeQuestion": "Yanıtlamadan kapat",
"inbox.markAllRead": "Tümünü okundu olarak işaretle",
+ "inbox.settled.title": "Tamamlandı",
+ "inbox.settled.read": "Okundu",
"question.somethingElse": "Başka bir şey…",
"question.done": "Tamam",
"common.done": "Tamam",
@@ -5892,5 +5894,6 @@
"remote.tailscale.needsApproval": "Bu bilgisayar Tailscale ağınızda onay bekliyor. Tailscale yönetici konsolunda onaylayın, ardından tekrar deneyin.",
"together.switch.title": "Bu bilgisayar ve Cloud'um birlikte",
"together.switch.line": "Varsayılan olarak kapalı. Cloud'daki botlar ile bu bilgisayardaki botlar tek listede görünür ve her biri bulunduğu yerde açılır.",
- "together.switch.failed": "Kaydedilemedi. Yeniden deneyin."
+ "together.switch.failed": "Kaydedilemedi. Yeniden deneyin.",
+ "devices.computers.typeCode": "Diğer bilgisayarınızda {app} içinde Sunucuya bağlan'ı açın ve bu kodu yazın."
}
diff --git a/src/locales/uk.json b/src/locales/uk.json
index 7009669e87..b833dac489 100644
--- a/src/locales/uk.json
+++ b/src/locales/uk.json
@@ -3187,6 +3187,8 @@
"ask.detail.more": "Показати все",
"inbox.action.closeQuestion": "Закрити без відповіді",
"inbox.markAllRead": "Позначити все як прочитане",
+ "inbox.settled.title": "Завершено",
+ "inbox.settled.read": "Прочитано",
"question.somethingElse": "Щось інше…",
"question.done": "Готово",
"common.done": "Готово",
@@ -4070,5 +4072,6 @@
"remote.tailscale.needsApproval": "Цей комп’ютер чекає на схвалення у вашій мережі Tailscale. Схваліть його в консолі адміністратора Tailscale, потім спробуйте ще раз.",
"together.switch.title": "Цей комп'ютер і Моя хмара разом",
"together.switch.line": "Типово вимкнено. Боти з хмари й боти цього комп'ютера показані в одному списку, і кожен відкривається там, де він є.",
- "together.switch.failed": "Не вдалося зберегти. Спробуйте ще раз."
+ "together.switch.failed": "Не вдалося зберегти. Спробуйте ще раз.",
+ "devices.computers.typeCode": "На іншому комп’ютері відкрийте «Підключитися до сервера» в {app} і введіть цей код."
}
diff --git a/src/locales/vi.json b/src/locales/vi.json
index 91e686dad6..f7bc0c80cc 100644
--- a/src/locales/vi.json
+++ b/src/locales/vi.json
@@ -5060,6 +5060,8 @@
"ask.detail.more": "Hiện tất cả",
"inbox.action.closeQuestion": "Đóng mà không trả lời",
"inbox.markAllRead": "Đánh dấu tất cả là đã đọc",
+ "inbox.settled.title": "Đã xong",
+ "inbox.settled.read": "Đã đọc",
"question.somethingElse": "Điều khác…",
"question.done": "Xong",
"common.done": "Xong",
@@ -5892,5 +5894,6 @@
"remote.tailscale.needsApproval": "Máy tính này đang chờ được phê duyệt trên mạng Tailscale của bạn. Hãy phê duyệt trong bảng điều khiển quản trị Tailscale, rồi thử lại.",
"together.switch.title": "Máy tính này và My Cloud cùng nhau",
"together.switch.line": "Mặc định là tắt. Bot trên Cloud và bot trên máy tính này hiện trong một danh sách, và mỗi bot mở ở nơi nó đang ở.",
- "together.switch.failed": "Không lưu được. Hãy thử lại."
+ "together.switch.failed": "Không lưu được. Hãy thử lại.",
+ "devices.computers.typeCode": "Trên máy tính kia, mở Kết nối với máy chủ trong {app} và nhập mã này."
}
diff --git a/src/locales/zh-tw.json b/src/locales/zh-tw.json
index ec5b260e4e..f3bb7bac96 100644
--- a/src/locales/zh-tw.json
+++ b/src/locales/zh-tw.json
@@ -9598,6 +9598,8 @@
"settings.userBubbles.simpleTitle": "將我的訊息套用機器人的顏色",
"sidebar.newConversationWith": "與 {name} 開始新對話",
"inbox.emptyHint": "當機器人需要你的同意、有問題想問或完成某件事時,都會顯示在這裡。",
+ "inbox.settled.title": "已完成",
+ "inbox.settled.read": "已讀",
"chat.engineCompactionTitle": "對話已整理成摘要",
"chat.engineCompactionHint": "AI 已將較早的訊息整理成摘要以騰出空間。完整對話仍會保留,但機器人可能無法準確記住較早的細節。",
"chat.openBotPanel": "詳細資料與對話",
@@ -10166,5 +10168,6 @@
"remote.tailscale.needsApproval": "這台電腦正在等待你的 Tailscale 網路核准。請在 Tailscale 管理主控台中核准它,然後再試一次。",
"together.switch.title": "這台電腦和 My Cloud 合在一起",
"together.switch.line": "預設為關閉。Cloud 上的機器人和這台電腦上的機器人顯示在同一個清單中,各自在所在的位置開啟。",
- "together.switch.failed": "無法儲存。請再試一次。"
+ "together.switch.failed": "無法儲存。請再試一次。",
+ "devices.computers.typeCode": "在另一台電腦上,於 {app} 開啟「連線到伺服器」並輸入這組代碼。"
}
diff --git a/src/locales/zh.json b/src/locales/zh.json
index 24e2bba039..0c6a054760 100644
--- a/src/locales/zh.json
+++ b/src/locales/zh.json
@@ -2548,6 +2548,10 @@
"chat.jumpToLatestAria": "跳到最新消息",
"chat.newMessages": "新消息",
"chat.newMessagesAria": "新消息",
+ "chat.unreadContext.title": "之前的消息",
+ "chat.unreadContext.images": "图片",
+ "chat.unreadContext.files": "文件",
+ "chat.unreadContext.moreCitations": "还有 {count} 条引用",
"chat.verify.title": "这次运行",
"chat.verify.aria": "这次运行",
"chat.verify.steps": "运行步骤",
@@ -9884,6 +9888,8 @@
"inbox.you": "你",
"inbox.headline.signIn": "登录 {site}",
"inbox.headline.connect": "连接 {app}",
+ "inbox.settled.title": "已完成",
+ "inbox.settled.read": "已读",
"sidebar.bot.simple.viewThreads": "查看对话",
"sidebar.bot.simple.setMainThread": "设为主对话",
"sidebar.bot.simple.isMainThread": "这已经是主对话",