Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(inbox): agent activity on Work panel Inbox rows; open at the oldest unread comment (MUL-9301) (#10640)

Jiayuan Zhangd2a80517d3db
diff --git a/apps/mobile/lib/inbox-display.test.ts b/apps/mobile/lib/inbox-display.test.ts
index 43d268d64d..5639e05be4 100644
--- a/apps/mobile/lib/inbox-display.test.ts
+++ b/apps/mobile/lib/inbox-display.test.ts
@@ -57,6 +57,20 @@ describe("deduplicateInboxItems", () => {
},
});
});
+
+ it("anchors at the oldest unread comment, or the newest once all are read", () => {
+ const unread = deduplicateInboxItems([
+ item({ id: "older", created_at: "2026-06-15T08:00:00Z", details: { comment_id: "comment-1" } }),
+ item({ id: "newer", created_at: "2026-06-15T08:02:00Z", details: { comment_id: "comment-2" } }),
+ ]);
+ expect(unread[0]?.details?.comment_id).toBe("comment-1");
+
+ const read = deduplicateInboxItems([
+ item({ id: "older", read: true, created_at: "2026-06-15T08:00:00Z", details: { comment_id: "comment-1" } }),
+ item({ id: "newer", read: true, created_at: "2026-06-15T08:02:00Z", details: { comment_id: "comment-2" } }),
+ ]);
+ expect(read[0]?.details?.comment_id).toBe("comment-2");
+ });
});
describe("getInboxDisplayTitle", () => {
diff --git a/apps/mobile/lib/inbox-display.ts b/apps/mobile/lib/inbox-display.ts
index 693095db62..62ab293676 100644
--- a/apps/mobile/lib/inbox-display.ts
+++ b/apps/mobile/lib/inbox-display.ts
@@ -149,8 +149,8 @@ export function getInboxNavigationTarget(
* 2. Group by `issue_id` (fall back to `id` for items with no issue
* attached — e.g. quick_create_failed).
* 3. In each group, keep the newest by `created_at`.
- * 4. Preserve the newest grouped `comment_id` anchor when the newest row
- * is a later status/metadata event for the same issue.
+ * 4. Anchor the row where the reader left off: the oldest unread
+ * `comment_id` in the group, or the newest one once all are read.
* 5. Sort the result newest-first.
*/
export function deduplicateInboxItems(items: InboxItem[]): InboxItem[] {
@@ -171,9 +171,11 @@ export function deduplicateInboxItems(items: InboxItem[]): InboxItem[] {
const newest = group[0];
if (!newest) continue;
- const commentId =
- newest.details?.comment_id ??
- group.find((item) => item.details?.comment_id)?.details?.comment_id;
+ const hasComment = (item: InboxItem) => !!item.details?.comment_id;
+ const commentId = (
+ group.findLast((item) => item.read !== true && hasComment(item)) ??
+ group.find(hasComment)
+ )?.details?.comment_id;
if (commentId && newest.details?.comment_id !== commentId) {
merged.push({
diff --git a/packages/core/inbox/group.ts b/packages/core/inbox/group.ts
index a4a8a36f22..4589ec4091 100644
--- a/packages/core/inbox/group.ts
+++ b/packages/core/inbox/group.ts
@@ -19,15 +19,18 @@ export function groupInboxRows(items: readonly InboxItem[]): InboxItem[][] {
}
/**
- * The row a group renders as. It keeps the group's newest comment anchor when
- * it has none of its own, so opening it still scrolls to the comment. An app
- * notification lands on its own request instead, so it never borrows one.
+ * The row a group renders as, opening where the reader left off: the oldest
+ * unread comment, so the thread reads forward from there, or the newest
+ * comment once the issue is read. An app notification lands on its own
+ * request instead, so it never borrows one.
*/
export function withCommentAnchor(row: InboxItem, group: readonly InboxItem[]): InboxItem {
- if (row.details?.comment_id) return row;
if (row.type.startsWith("app_") && row.details?.request_id) return row;
- const commentId = group.find((item) => item.details?.comment_id)?.details?.comment_id;
- if (!commentId) return row;
+ const hasComment = (item: InboxItem) => !!item.details?.comment_id;
+ const anchor =
+ group.findLast((item) => item.read !== true && hasComment(item)) ?? group.find(hasComment);
+ const commentId = anchor?.details?.comment_id;
+ if (!commentId || commentId === row.details?.comment_id) return row;
return { ...row, details: { ...(row.details ?? {}), comment_id: commentId } };
}
diff --git a/packages/core/inbox/queries.test.ts b/packages/core/inbox/queries.test.ts
index 3ec61d7a78..52f06bdd8a 100644
--- a/packages/core/inbox/queries.test.ts
+++ b/packages/core/inbox/queries.test.ts
@@ -79,22 +79,24 @@ describe("deduplicateInboxItems", () => {
expect(merged[0]?.details).toEqual({ request_id: "request-1" });
});
- it("preserves the newest row's own comment anchor", () => {
+ it("opens at the oldest unread comment, so the thread reads forward from there", () => {
const merged = deduplicateInboxItems([
- item({
- id: "older-comment",
- created_at: "2026-06-15T08:00:00Z",
- details: { comment_id: "comment-1" },
- }),
- item({
- id: "newer-comment",
- created_at: "2026-06-15T08:02:00Z",
- details: { comment_id: "comment-2" },
- }),
+ item({ id: "read-comment", read: true, created_at: "2026-06-15T07:00:00Z", details: { comment_id: "comment-0" } }),
+ item({ id: "older-comment", created_at: "2026-06-15T08:00:00Z", details: { comment_id: "comment-1" } }),
+ item({ id: "newer-comment", created_at: "2026-06-15T08:02:00Z", details: { comment_id: "comment-2" } }),
]);
expect(merged).toHaveLength(1);
expect(merged[0]?.id).toBe("newer-comment");
+ expect(merged[0]?.details?.comment_id).toBe("comment-1");
+ });
+
+ it("opens at the newest comment once every notification is read", () => {
+ const merged = deduplicateInboxItems([
+ item({ id: "older-comment", read: true, created_at: "2026-06-15T08:00:00Z", details: { comment_id: "comment-1" } }),
+ item({ id: "newer-comment", read: true, created_at: "2026-06-15T08:02:00Z", details: { comment_id: "comment-2" } }),
+ ]);
+
expect(merged[0]?.details?.comment_id).toBe("comment-2");
});
diff --git a/packages/views/inbox/components/inbox-page.test.tsx b/packages/views/inbox/components/inbox-page.test.tsx
index 3abd736c8d..c8251d1070 100644
--- a/packages/views/inbox/components/inbox-page.test.tsx
+++ b/packages/views/inbox/components/inbox-page.test.tsx
@@ -287,6 +287,68 @@ function inboxCommands() {
}
describe("InboxPage", () => {
+ it("chooses a fresh anchor after returning to the list and reopening the same issue", () => {
+ reset();
+ layout.width = PHONE;
+ searchParams = new URLSearchParams("issue=issue-1");
+ listData.active = [
+ item({ id: "n1", read: false, created_at: "2026-11-15T08:00:00Z", details: { comment_id: "c1" } }),
+ item({ id: "n2", read: false, created_at: "2026-11-15T08:02:00Z", details: { comment_id: "c2" } }),
+ ];
+ markReadMutate.mockImplementation(() => {
+ listData.active = listData.active.map((current) => ({ ...current, read: true }));
+ });
+ const { rerender } = render(<InboxPage />);
+ expect(issueDetailProps.at(-1)?.highlightCommentId).toBe("c1");
+ rerender(<InboxPage />);
+ const back = issueDetailProps.at(-1)?.leadingAction as { props: { onClick: () => void } };
+ act(() => back.props.onClick());
+ expect(screen.queryByTestId("issue-detail")).toBeNull();
+ fireEvent.click(screen.getByTestId("row"));
+ expect(issueDetailProps.at(-1)?.highlightCommentId).toBe("c2");
+ });
+
+ it("keeps the selected landing when opening the phone inbox auto-marks the issue read", () => {
+ reset();
+ layout.width = PHONE;
+ searchParams = new URLSearchParams("issue=issue-1");
+ listData.active = [
+ item({ id: "n1", read: false, created_at: "2026-11-15T08:00:00Z", details: { comment_id: "c1" } }),
+ item({ id: "n2", read: false, created_at: "2026-11-15T08:01:00Z", details: { comment_id: "c2" } }),
+ item({ id: "n3", read: false, created_at: "2026-11-15T08:02:00Z", details: { comment_id: "c3" } }),
+ ];
+ markReadMutate.mockImplementation(() => {
+ listData.active = listData.active.map((current) => ({ ...current, read: true }));
+ });
+ const { rerender } = render(<InboxPage />);
+ expect(markReadMutate).toHaveBeenCalledWith("n3", expect.anything());
+ expect(issueDetailProps.at(-1)?.highlightCommentId).toBe("c1");
+ rerender(<InboxPage />);
+ expect(issueDetailProps.at(-1)?.highlightCommentId).toBe("c1");
+ });
+
+ it("picks the landing again when the open row is clicked again", () => {
+ reset();
+ layout.width = DESKTOP;
+ searchParams = new URLSearchParams("view=archived");
+ listData.archived = [
+ item({ id: "n1", archived: true, read: false, created_at: "2026-11-15T08:00:00Z", details: { comment_id: "c1" } }),
+ item({ id: "n2", archived: true, read: false, created_at: "2026-11-15T08:02:00Z", details: { comment_id: "c2" } }),
+ ];
+ markReadMutate.mockImplementation(() => {
+ listData.archived = listData.archived.map((current) => ({ ...current, read: true }));
+ });
+ const { rerender } = render(<InboxPage />);
+ fireEvent.click(screen.getByTestId("row"));
+ expect(issueDetailProps.at(-1)?.highlightCommentId).toBe("c1");
+ rerender(<InboxPage />);
+ expect(issueDetailProps.at(-1)?.highlightCommentId).toBe("c1");
+
+ // Everything is read by now, so a fresh click opens at the newest comment.
+ fireEvent.click(screen.getByTestId("row"));
+ expect(issueDetailProps.at(-1)?.highlightCommentId).toBe("c2");
+ });
+
it("opens a notification the Work panel offered despite a type filter", () => {
reset();
layout.width = DESKTOP;
diff --git a/packages/views/inbox/components/inbox-page.tsx b/packages/views/inbox/components/inbox-page.tsx
index 57e1935607..7a9184f47a 100644
--- a/packages/views/inbox/components/inbox-page.tsx
+++ b/packages/views/inbox/components/inbox-page.tsx
@@ -499,6 +499,22 @@ export function InboxPage() {
setSelectedKey(nextKey);
};
+ // The comment a notification opens at is chosen once per opening or
+ // re-click. Opening reads the issue, which moves the row's anchor from the
+ // oldest unread comment to the newest; following it would land a second
+ // time, past the comments the reader came for. Taken from the selected row,
+ // not the deferred detail, which renders only after the read has landed.
+ const [landing, setLanding] = useState<{ key: string; token: number; commentId: string | undefined } | null>(null);
+ if (selected && (landing?.key !== selectedKey || landing.token !== highlightRequestToken)) {
+ setLanding({ key: selectedKey, token: highlightRequestToken, commentId: selected.details?.comment_id ?? undefined });
+ } else if (landing && !selectedKey && !detailKey) {
+ // Back on the list: opening the row again chooses afresh.
+ setLanding(null);
+ }
+ const detailItemKey = detailItem ? (detailItem.issue_id ?? detailItem.id) : null;
+ const landingCommentId =
+ landing?.key === detailItemKey ? landing.commentId : (detailItem?.details?.comment_id ?? undefined);
+
const handleMarkRead = (id: string) => {
// Reading it back explicitly cancels an earlier park on the same row.
if (manualUnreadIdRef.current === id) manualUnreadIdRef.current = null;
@@ -912,7 +928,7 @@ export function InboxPage() {
issueId={detailItem.issue_id}
defaultSidebarOpen={false}
layoutId="multica_inbox_issue_detail_layout"
- highlightCommentId={detailItem.details?.comment_id ?? undefined}
+ highlightCommentId={landingCommentId}
highlightRequestToken={highlightRequestToken}
highlightAppRequestId={
detailItem.type.startsWith("app_") ? (detailItem.details?.request_id ?? undefined) : undefined
diff --git a/packages/views/issues/components/issue-detail-route-comment-links.test.tsx b/packages/views/issues/components/issue-detail-route-comment-links.test.tsx
index 6b5a3c5451..9f0167e7b6 100644
--- a/packages/views/issues/components/issue-detail-route-comment-links.test.tsx
+++ b/packages/views/issues/components/issue-detail-route-comment-links.test.tsx
@@ -86,13 +86,17 @@ describe("IssueDetailRoute comment deep links", () => {
expect(replace).not.toHaveBeenCalled();
});
- it("retains the adapter fragment when canonicalizing a UUID route", async () => {
- render(route("#comment-adapter-comment", issueId));
+ it("retains the adapter fragment when canonicalizing a UUID route, and lands on the canonical page", async () => {
+ const { rerender } = render(route("#comment-adapter-comment", issueId));
await waitFor(() => {
- expectHighlight("adapter-comment");
expect(replace).toHaveBeenCalledWith("/acme/issues/TRS-134#comment-adapter-comment");
});
expect(push).not.toHaveBeenCalled();
+ // The rewrite mounts a new page on web; landing on this one would be lost.
+ expectHighlight(undefined);
+
+ rerender(route("#comment-adapter-comment"));
+ expectHighlight("adapter-comment");
});
it("updates the highlight when only the adapter hash changes", async () => {
diff --git a/packages/views/issues/components/issue-detail-route.tsx b/packages/views/issues/components/issue-detail-route.tsx
index a54e5be071..1ef963927d 100644
--- a/packages/views/issues/components/issue-detail-route.tsx
+++ b/packages/views/issues/components/issue-detail-route.tsx
@@ -98,6 +98,10 @@ export function IssueDetailRoute({ routeId, onDelete, deliverable }: IssueDetail
const navigation = useNavigation();
useCanonicalIssueUrl(routeId, issue?.identifier, highlight.hash, deliverable);
+ // A UUID or differently-cased address is about to be rewritten, which mounts
+ // a new page (a new route segment on web). Landing here would scroll a page
+ // that is about to go, and record the landing as done for the next one.
+ const landsHere = routeId === issue?.identifier;
// Once the link has opened its file and the viewer has closed (or the file
// is missing), the address becomes the plain issue page. A replace: Back
@@ -131,8 +135,8 @@ export function IssueDetailRoute({ routeId, onDelete, deliverable }: IssueDetail
issueId={canonicalId}
skipInitialRefetch={hasLoaded}
onDelete={onDelete}
- highlightCommentId={highlight.commentId}
- highlightAppRequestId={highlight.appRequestId}
+ highlightCommentId={landsHere ? highlight.commentId : undefined}
+ highlightAppRequestId={landsHere ? highlight.appRequestId : undefined}
highlightRequestToken={landingToken}
openDeliverable={deliverable}
onDeliverableLinkDone={deliverable ? onDeliverableLinkDone : undefined}
diff --git a/packages/views/layout/panels/inbox-section.test.tsx b/packages/views/layout/panels/inbox-section.test.tsx
index 240383d5c3..f0995c7594 100644
--- a/packages/views/layout/panels/inbox-section.test.tsx
+++ b/packages/views/layout/panels/inbox-section.test.tsx
@@ -9,7 +9,7 @@ import {
import { useInboxFilterStore } from "@multica/core/inbox/filter-store";
import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";
import { agentTaskSnapshotOptions } from "@multica/core/agents";
-import type { InboxItem } from "@multica/core/types";
+import type { AgentTask, InboxItem } from "@multica/core/types";
import { renderWithI18n } from "../../test/i18n";
import { NavigationProvider, type NavigationAdapter } from "../../navigation";
import { InboxSection, useInboxSectionRows } from "./inbox-section";
@@ -51,6 +51,9 @@ vi.mock("@multica/core/workspace/hooks", () => ({
useActorName: () => ({ getActorName: () => "Leo Park", getActorInitials: () => "LP", getActorAvatarUrl: () => null }),
}));
vi.mock("../../common/actor-avatar", () => ({ ActorAvatar: () => null }));
+vi.mock("../../agents/components/agent-avatar-stack", () => ({
+ AgentAvatarStack: ({ agentIds }: { agentIds: string[] }) => <span data-testid="agents">{agentIds.join(",")}</span>,
+}));
vi.mock("@multica/ui/hooks/use-mobile", async (importOriginal) => ({
...(await importOriginal<typeof import("@multica/ui/hooks/use-mobile")>()),
useIsCompact: () => state.compact,
@@ -99,10 +102,15 @@ function Harness({ activeIssueId, pathname, openKey }: { activeIssueId: string |
return <InboxSection wsId="ws-1" rows={rows} pathname={pathname} activeIssueId={activeIssueId} />;
}
-function renderSection(items: InboxItem[], activeIssueId: string | null = null, url = "/acme/issues") {
+function renderSection(
+ items: InboxItem[],
+ activeIssueId: string | null = null,
+ url = "/acme/issues",
+ tasks: Partial<AgentTask>[] = [],
+) {
const client = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity } } });
client.setQueryData(["inbox", "ws-1", "list"], items);
- client.setQueryData(agentTaskSnapshotOptions("ws-1").queryKey, []);
+ client.setQueryData(agentTaskSnapshotOptions("ws-1").queryKey, tasks as AgentTask[]);
const nav = adapter(url);
// As the Work panel keys it: the issue opened from the section, or the Inbox page's notification.
const openKey = nav.pathname === "/acme/inbox" ? nav.searchParams.get("issue") : activeIssueId;
@@ -167,6 +175,41 @@ describe("InboxSection", () => {
expect(screen.getByRole("link", { name: /^Autopilot paused/ })).toHaveAttribute("href", "/acme/inbox?issue=n3");
});
+ it("opens the issue at its oldest unread comment, or its newest once read", () => {
+ renderSection([
+ item({ id: "n1", issue_id: "issue-a", title: "Unread thread", details: { comment_id: "c-2" }, created_at: "2026-11-10T09:00:00Z" }),
+ item({ id: "n2", issue_id: "issue-a", title: "Unread thread", details: { comment_id: "c-1" }, created_at: "2026-11-10T08:00:00Z" }),
+ item({ id: "n3", issue_id: "issue-b", title: "Read thread", read: true, details: { comment_id: "c-4" }, created_at: "2026-11-09T09:00:00Z" }),
+ item({ id: "n4", issue_id: "issue-b", title: "Read thread", read: true, details: { comment_id: "c-3" }, created_at: "2026-11-09T08:00:00Z" }),
+ ]);
+
+ expect(screen.getByRole("link", { name: /^Unread thread/ })).toHaveAttribute("href", "/acme/issues/issue-a#comment-c-1");
+ expect(screen.getByRole("link", { name: /^Read thread/ })).toHaveAttribute("href", "/acme/issues/issue-b#comment-c-4");
+ });
+
+ it("marks issues an agent is working on or queued for", () => {
+ renderSection(
+ [
+ item({ id: "n1", issue_id: "issue-a", title: "Working one" }),
+ item({ id: "n2", issue_id: "issue-b", title: "Queued one", created_at: "2026-11-09T08:00:00Z" }),
+ item({ id: "n3", issue_id: "issue-c", title: "Idle one", created_at: "2026-11-08T08:00:00Z" }),
+ ],
+ null,
+ "/acme/issues",
+ [
+ { id: "t1", issue_id: "issue-a", agent_id: "a1", status: "running" },
+ { id: "t2", issue_id: "issue-b", agent_id: "a2", status: "queued" },
+ ],
+ );
+
+ const [working, queued, idle] = rows();
+ expect(working).toHaveTextContent("Working");
+ expect(working!.querySelector(".shimmer-text")).not.toBeNull();
+ expect(queued).toHaveTextContent("Queued");
+ expect(queued!.querySelector(".shimmer-text")).toBeNull();
+ expect(idle!.querySelector("[data-testid=agents]")).toBeNull();
+ });
+
it("opens an app's request on its issue at that request", () => {
renderSection([
item({ id: "n1", issue_id: "issue-a", title: "Confirm deploy", type: "app_action_requested", details: { request_id: "r-1" } }),
diff --git a/packages/views/layout/panels/inbox-section.tsx b/packages/views/layout/panels/inbox-section.tsx
index d62cae8a40..0b07a907d5 100644
--- a/packages/views/layout/panels/inbox-section.tsx
+++ b/packages/views/layout/panels/inbox-section.tsx
@@ -7,6 +7,7 @@ import { Archive, BookCheck, CheckCheck, History, ListChecks, MoreHorizontal } f
import { cn } from "@multica/ui/lib/utils";
import { useIsCompact } from "@multica/ui/hooks/use-mobile";
import { TooltipHint } from "@multica/ui/components/common/tooltip-hint";
+import { ShimmerText } from "@multica/ui/components/common/shimmer-text";
import { Button, buttonVariants } from "@multica/ui/components/ui/button";
import { HoverCard, HoverCardContent, HoverCardTrigger } from "@multica/ui/components/ui/hover-card";
import {
@@ -58,7 +59,13 @@ import {
panelRowStateClass,
} from "../panel-nav";
import { InboxSectionSettings, SECTION_SETTINGS_REVEAL_CLASS } from "./sidebar-settings";
-import { ISSUE_ROW_LINK_CLASS, TREE_ROW_BUTTON_CLASS } from "./sidebar-tree";
+import {
+ ISSUE_ROW_LINK_CLASS,
+ IssueAgentBadge,
+ SIDEBAR_SHIMMER_CLASS,
+ TREE_ROW_BUTTON_CLASS,
+ useIssueAgentState,
+} from "./sidebar-tree";
/**
* The unread count sits in the panel's number column (the rows' trailing
@@ -327,6 +334,8 @@ function InboxRow({
writeViewState(issueHighlightMementoKey(item.issue_id), undefined);
requestLanding(item.issue_id);
};
+ const agents = useIssueAgentState(item.workspace_id, item.issue_id ?? "");
+ const running = !!agents?.running;
const unread = item.read !== true;
const archiveLabel = t(($) => $.list.archive_tooltip);
// Hidden while the archive button stands in its place.
@@ -336,9 +345,25 @@ function InboxRow({
{timeAgo(item.created_at)}
</span>
);
+ // Takes the time's place while an agent runs or waits on the issue.
+ const agentBadge = agents && (
+ <span className={cn("flex shrink-0 items-center", yields)}>
+ <IssueAgentBadge agents={agents} />
+ </span>
+ );
const dot = <span data-mc="unread-dot" aria-hidden className="size-1.5 shrink-0 rounded-full bg-brand" />;
const titleText = (
- <span className={cn("min-w-0 flex-1 truncate", unread && "font-medium text-foreground")}>{title}</span>
+ <ShimmerText
+ active={running}
+ className={cn(
+ "min-w-0 flex-1 truncate",
+ SIDEBAR_SHIMMER_CLASS,
+ unread && "font-medium",
+ unread && !running && "text-foreground",
+ )}
+ >
+ {title}
+ </ShimmerText>
);
return (
@@ -371,13 +396,14 @@ function InboxRow({
{compact ? (
<>
{titleText}
- {unread ? <span className={cn("flex shrink-0 items-center", yields)}>{dot}</span> : time}
+ {agentBadge ||
+ (unread ? <span className={cn("flex shrink-0 items-center", yields)}>{dot}</span> : time)}
</>
) : (
<>
<span className="flex min-w-0 items-center gap-2 leading-5">
{titleText}
- {time}
+ {agentBadge || time}
</span>
<span className="flex min-w-0 items-center gap-2 text-caption leading-4 text-muted-foreground">
<span className="min-w-0 flex-1 truncate">