:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(desktop): open new tabs on activity and refine activity (#88030)
Adam Leith932c2aa66879
diff --git a/products/desktop/packages/ui/src/features/browser-tabs/AGENTS.md b/products/desktop/packages/ui/src/features/browser-tabs/AGENTS.mdindex 45cd47e39d05..e71398e1e12a 100644--- a/products/desktop/packages/ui/src/features/browser-tabs/AGENTS.md+++ b/products/desktop/packages/ui/src/features/browser-tabs/AGENTS.md@@ -102,21 +102,18 @@ differ. Desktop ships first.— they update the instant you navigate, not after the server snapshotround-trips (see Gotchas).-### Opening, replacing, the new-tab page+### Opening, replacing, and blank tabs- **Navigating while a tab is active replaces that tab's location in place**(in-tab navigation). It does *not* open or focus another tab, ever.-- **New tabs come only from explicit new-tab actions.** `+` opens a tab on- `/spaces`; Cmd/Ctrl-clicking a navigation destination opens that destination's- root in a new tab (the rail in Spaces, the sidebar in the legacy layout). The- space index renders the space grid and acts as the new-tab page. Without the- spaces layout the Code new-task screen stands in.+- **New tabs come only from explicit new-tab actions.** `+` and Cmd/Ctrl+T open+ `/activity`. Cmd/Ctrl-clicking a navigation destination opens that destination's+ root in a new tab (the rail in Spaces, the sidebar in the legacy layout).- `openTab` always appends. There is no dedup to focus an existing tab.### Closing- Closing the active tab focuses its neighbour.- Closing the last tab of a **secondary** window closes the window; closing the- last tab of the **primary** window lands on the default (`#me` under the- spaces layout, the Code new-task screen otherwise), which opens a fresh tab.+ last tab of the **primary** window lands on `/activity`, which opens a fresh tab.### Keyboard- **⌘1-9 switches tabs**, the browser way: 1-8 pick that position, 9 picks the@@ -279,15 +276,12 @@ retarget its originating background tab as described below. `railHistoryStore`it's an absolutely-positioned sibling. The wrapper is `flex` so it hugs thebutton height (a block wrapper adds an inline line-box ~2px taller).- **`/spaces` is a page, not a redirect.** It used to bounce to `channels[0]`.- It is now where `+` lands, so a redirect there would send every new tab- somewhere the user did not ask for. Don't reintroduce one.+ The rail can land there and return to it, so don't reintroduce the redirect.- **All writes are local-first (`tabsSync.ts`).** Close/open/new/reorder apply- their shared transform to the mirror and navigate in the same tick; the- `/spaces` index therefore always renders against post-mutation state. Mutation results and- subscription pushes are never applied while writes are in flight — only the- last settle reconciles. Don't add a mutation `onSuccess` that calls- `setSnapshot`; route new writes through `applyLocalTransform` +- `persistWrite`.+ their shared transform to the mirror and navigate in the same tick. Mutation+ results and subscription pushes are never applied while writes are in flight —+ only the last settle reconciles. Don't add a mutation `onSuccess` that calls+ `setSnapshot`; route new writes through `applyLocalTransform` + `persistWrite`.## Testingdiff --git a/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsx b/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsxindex d369e87ac906..64b1867e9682 100644--- a/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsx+++ b/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsx@@ -4,7 +4,6 @@ import {closeTabs as closeTabsLocal,decideTabNavigation,openTab as openTabLocal,- PROJECT_BLUEBIRD_FLAG,primaryWindow,setTabOrder,setTabTarget as setTabTargetLocal,@@ -30,12 +29,10 @@ import {import { useCurrentChannelStore } from "@posthog/ui/features/canvas/stores/currentChannelStore";import { SHORTCUTS } from "@posthog/ui/features/command/keyboard-shortcuts";import { useChannelReportsEnabled } from "@posthog/ui/features/feature-flags/useChannelReportsEnabled";-import { useFeatureFlag } from "@posthog/ui/features/feature-flags/useFeatureFlag";import { useDraftStore } from "@posthog/ui/features/message-editor/draftStore";import { useActiveSession } from "@posthog/ui/features/navigation/useActiveSession";import { usePanelLayoutStore } from "@posthog/ui/features/panels/panelLayoutStore";import { getLeafPanel } from "@posthog/ui/features/panels/panelStoreHelpers";-import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";import { getTaskInputSessionId } from "@posthog/ui/features/task-detail/taskInputSession";import { taskDetailQuery } from "@posthog/ui/features/tasks/queries";import { useTasks } from "@posthog/ui/features/tasks/useTasks";@@ -83,6 +80,7 @@ import { useOpenBrowserTab } from "./useOpenBrowserTab";*/const canvasInfo = new Map<string, { name: string; templateId: string }>();const taskInfo = new Map<string, string>();+const BLANK_TAB_HREF = "/activity";/** Bounded insert (most-recent kept) so the caches don't grow unbounded over a* long session. */@@ -161,10 +159,6 @@ export function BrowserTabStrip() {// Which session the content pane is about, wherever it came from: a path// param, Activity's picked item, or a feed's.const activeSession = useActiveSession();- // Tabs work in both spaces: space-scoped tabs live under /spaces, while a- // plain task tab (no space) is unscoped. The space decides where a task or- // blank tab navigates.- const inChannels = pathname.startsWith("/spaces");// Top-level app pages are tab targets too. Their typed metadata keeps route// classification, persisted labels, and rendered labels in one vocabulary.const view = useAppView();@@ -173,19 +167,9 @@ export function BrowserTabStrip() {: null;const { channels } = useChannels();- // Whether the channels surface is live — the same gate the sidebar uses. This- // (not the current route) decides a new tab's default: with channels on a- // fresh tab opens #me, otherwise the Code new-task screen. Keying off the- // route would leave the behaviour stale right after the toggle flips.- const bluebirdEnabled = useFeatureFlag(- PROJECT_BLUEBIRD_FLAG,- import.meta.env.DEV,- );// With channel reports on, a restored inbox tab lands on the spaces index// (the inbox is gone as a destination).const channelReportsEnabled = useChannelReportsEnabled();- const channelsEnabled =- useSidebarStore((s) => s.channelsEnabled) && bluebirdEnabled;// The active channel sub-section (artifacts/history/context) is the// route segment after the channelId. Null when on the channel home or a@@ -723,12 +707,10 @@ export function BrowserTabStrip() {}}} else {- // Blank / landing tab: park on the space's home — the channels index, or- // the Code new-task screen.- navigate({ to: inChannels ? "/spaces" : "/new", state });+ navigate({ to: BLANK_TAB_HREF, state });}},- [channelReportsEnabled, inChannels, navigate, router.history],+ [channelReportsEnabled, navigate, router.history],);const handleSelect = useCallback(@@ -827,37 +809,12 @@ export function BrowserTabStrip() {);};- // Where closing the last tab lands, keyed off the channels toggle (not the- // current route, which lags a toggle flip): #me when channels are on, the- // Code new-task screen otherwise. The navigation opens a fresh tab, since by- // then the window has none.- const landOnDefault = (tabId?: string) => {+ const landOnDefault = (tabId?: string): void => {const state = tabId ? (prev: object) => ({ ...prev, tabId }) : undefined;- if (!channelsEnabled) {- navigate({ to: "/new", state });- return;- }- // Startup provisions #me, so its absence here means the list has not loaded rather- // than that there is nothing to open.- const personal = channels.find((c) => c.channelType === "personal");- if (personal) {- navigate({- to: "/spaces/$channelId",- params: { channelId: personal.id },- state,- });- } else {- navigate({ to: "/new", state });- }+ navigate({ to: BLANK_TAB_HREF, state });};- // Where `+` lands. The space index is the app's "pick something" screen, so- // a new tab shows the spaces rather than an empty placeholder. Without the- // spaces layout that page does not exist, so the Code new-task screen stands- // in. Keyed off the channels toggle, not the current route, which lags a flip.- const newTabHref = channelsEnabled ? "/spaces" : "/new";-- const handleNewTab = () => openBrowserTab(newTabHref);+ const handleNewTab = (): void => openBrowserTab(BLANK_TAB_HREF);// Cmd/Ctrl+T opens a new browser tab. Bound here (not globally) so it only// fires where the strip is mounted; the new-task shortcut owns Cmd/Ctrl+N.diff --git a/products/desktop/packages/ui/src/features/browser-tabs/tabAppViews.tsx b/products/desktop/packages/ui/src/features/browser-tabs/tabAppViews.tsxindex 335bda02f4ad..cbb8e5b3a040 100644--- a/products/desktop/packages/ui/src/features/browser-tabs/tabAppViews.tsx+++ b/products/desktop/packages/ui/src/features/browser-tabs/tabAppViews.tsx@@ -1,8 +1,8 @@import {ArchiveIcon,+ BellIcon,BookOpenTextIcon,BrainIcon,- ClockCounterClockwiseIcon,GearIcon,PlugsConnectedIcon,RepeatIcon,@@ -34,7 +34,7 @@ export const TAB_APP_VIEW_META: Record<> = {activity: {label: "Activity",- icon: <ClockCounterClockwiseIcon size={14} />,+ icon: <BellIcon size={14} />,},home: { label: "Home", icon: <SquaresFourIcon size={14} /> },inbox: { label: "Self-driving", icon: <TrayIcon size={14} /> },diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityActionsMenu.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityActionsMenu.tsxnew file mode 100644index 000000000000..075330c6fae4--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityActionsMenu.tsx@@ -0,0 +1,57 @@+import { ChecksIcon, DotsThreeIcon } from "@phosphor-icons/react";+import {+ Button,+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuTrigger,+} from "@posthog/quill";+import { markLoadedReadLabel } from "@posthog/ui/features/canvas/components/activityFeed";+import type { ReactElement } from "react";++interface ActivityActionsMenuProps {+ loadedUnreadCount: number;+ totalUnreadCount: number;+ isMarkingRead: boolean;+ onMarkAllRead: () => void;+}++export function ActivityActionsMenu({+ loadedUnreadCount,+ totalUnreadCount,+ isMarkingRead,+ onMarkAllRead,+}: ActivityActionsMenuProps): ReactElement {+ return (+ <DropdownMenu>+ <DropdownMenuTrigger+ render={+ <Button+ type="button"+ variant="default"+ size="icon-sm"+ aria-label="Activity actions"+ loading={isMarkingRead}+ disabled={isMarkingRead}+ >+ <DotsThreeIcon size={14} weight="bold" />+ </Button>+ }+ />+ <DropdownMenuContent+ align="end"+ side="bottom"+ sideOffset={4}+ className="w-max"+ >+ <DropdownMenuItem+ disabled={isMarkingRead || loadedUnreadCount === 0}+ onClick={onMarkAllRead}+ >+ <ChecksIcon size={14} />+ {markLoadedReadLabel(loadedUnreadCount, totalUnreadCount)}+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityFeedList.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityFeedList.test.tsxindex 44a455c3ac49..6a2d12be7f77 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityFeedList.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityFeedList.test.tsx@@ -1,6 +1,6 @@import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";import { fireEvent, render, screen, waitFor } from "@testing-library/react";-import type { ReactNode } from "react";+import type { ReactElement, ReactNode } from "react";import { beforeEach, describe, expect, it, vi } from "vitest";const mocks = vi.hoisted(() => ({@@ -9,13 +9,49 @@ const mocks = vi.hoisted(() => ({isFetchingNextPage: false,items: [] as TaskActivityItem[],markRead: vi.fn(),+ unreadCount: 0,}));vi.mock("@posthog/quill", () => ({cn: (...args: unknown[]) => args.filter(Boolean).join(" "),- Button: ({ children }: { children: ReactNode }) => (- <button type="button">{children}</button>+ Button: ({+ children,+ disabled,+ onClick,+ "aria-label": ariaLabel,+ }: {+ children: ReactNode;+ disabled?: boolean;+ onClick?: () => void;+ "aria-label"?: string;+ }) => (+ <button+ type="button"+ aria-label={ariaLabel}+ disabled={disabled}+ onClick={onClick}+ >+ {children}+ </button>),+ DropdownMenu: ({ children }: { children: ReactNode }) => <>{children}</>,+ DropdownMenuContent: ({ children }: { children: ReactNode }) => (+ <div>{children}</div>+ ),+ DropdownMenuItem: ({+ children,+ disabled,+ onClick,+ }: {+ children: ReactNode;+ disabled?: boolean;+ onClick?: () => void;+ }) => (+ <button type="button" disabled={disabled} onClick={onClick}>+ {children}+ </button>+ ),+ DropdownMenuTrigger: ({ render }: { render: ReactElement }) => render,Empty: ({ children }: { children: ReactNode }) => <div>{children}</div>,EmptyDescription: ({ children }: { children: ReactNode }) => (<div>{children}</div>@@ -23,6 +59,7 @@ vi.mock("@posthog/quill", () => ({EmptyHeader: ({ children }: { children: ReactNode }) => <div>{children}</div>,EmptyMedia: ({ children }: { children: ReactNode }) => <div>{children}</div>,EmptyTitle: ({ children }: { children: ReactNode }) => <div>{children}</div>,+ MenuLabel: ({ children }: { children: ReactNode }) => <div>{children}</div>,Label: ({ children, htmlFor }: { children: ReactNode; htmlFor?: string }) => (<label htmlFor={htmlFor}>{children}</label>),@@ -53,15 +90,15 @@ vi.mock("@posthog/ui/features/auth/authClient", () => ({vi.mock("@posthog/ui/features/auth/useCurrentUser", () => ({useCurrentUser: () => ({ data: null }),}));-vi.mock("@posthog/ui/features/canvas/components/ActivityView", () => ({+vi.mock("@posthog/ui/features/canvas/components/ActivityRow", () => ({ActivityRow: ({item,- onOpen,+ onMarkRead,}: {item: TaskActivityItem;- onOpen: (item: TaskActivityItem) => void;+ onMarkRead: (item: TaskActivityItem) => void;}) => (- <button type="button" onClick={() => onOpen(item)}>+ <button type="button" onClick={() => onMarkRead(item)}>Activity row</button>),@@ -75,10 +112,13 @@ vi.mock("@posthog/ui/features/canvas/hooks/useMarkTaskActivityRead", () => ({isPending: false,}),}));+vi.mock("@posthog/ui/features/canvas/hooks/useLocalDayStart", () => ({+ useLocalDayStart: () => new Date(2026, 7, 25).getTime(),+}));vi.mock("@posthog/ui/features/canvas/hooks/useTaskActivity", () => ({useTaskActivity: () => ({items: mocks.items,- unreadCount: 0,+ unreadCount: mocks.unreadCount,isLoading: false,hasNextPage: mocks.hasNextPage,isFetchingNextPage: mocks.isFetchingNextPage,@@ -99,6 +139,7 @@ describe("ActivityFeedList", () => {mocks.hasNextPage = true;mocks.isFetchingNextPage = false;mocks.items = [];+ mocks.unreadCount = 0;useActivityFilterStore.setState({ unreadsOnly: false });});@@ -139,6 +180,37 @@ describe("ActivityFeedList", () => {]);});+ it("puts the mark-all action in a menu after the unreads switch", () => {+ mocks.unreadCount = 1;+ mocks.items = [+ {+ id: "activity-1",+ taskId: "task-1",+ activityAt: "2026-08-07T00:00:00Z",+ activityKind: "completed",+ isUnread: true,+ } as TaskActivityItem,+ ];++ render(<ActivityFeedList />);++ const unreadsSwitch = screen.getByRole("switch", { name: "Unreads" });+ const activityActions = screen.getByRole("button", {+ name: "Activity actions",+ });+ expect(unreadsSwitch.compareDocumentPosition(activityActions)).toBe(+ Node.DOCUMENT_POSITION_FOLLOWING,+ );++ fireEvent.click(screen.getByRole("button", { name: "Mark all as read" }));+ expect(mocks.markRead).toHaveBeenCalledWith([+ {+ task_id: "task-1",+ seen_before: "2026-08-07T00:00:00Z",+ },+ ]);+ });+it("drops read activity while the unreads filter is on", () => {mocks.items = [{@@ -164,4 +236,34 @@ describe("ActivityFeedList", () => {expect(screen.getAllByText("Activity row")).toHaveLength(1);});++ it("groups the panel rows by local calendar day", () => {+ mocks.hasNextPage = false;+ mocks.items = [+ {+ id: "today",+ taskId: "task-1",+ activityAt: new Date(2026, 7, 25, 10).toISOString(),+ activityKind: "completed",+ isUnread: false,+ } as TaskActivityItem,+ {+ id: "yesterday",+ taskId: "task-2",+ activityAt: new Date(2026, 7, 24, 10).toISOString(),+ activityKind: "completed",+ isUnread: false,+ } as TaskActivityItem,+ ];++ render(<ActivityFeedList />);++ const rows = screen.getAllByText("Activity row");+ expect(screen.getByText("Today").compareDocumentPosition(rows[0])).toBe(+ Node.DOCUMENT_POSITION_FOLLOWING,+ );+ expect(screen.getByText("Yesterday").compareDocumentPosition(rows[1])).toBe(+ Node.DOCUMENT_POSITION_FOLLOWING,+ );+ });});diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityFeedList.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityFeedList.tsxindex a3cb84c8a51d..6c14ac0aeaa8 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityFeedList.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityFeedList.tsx@@ -1,32 +1,34 @@-import { BellIcon, ChecksIcon } from "@phosphor-icons/react";+import { BellIcon } from "@phosphor-icons/react";import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";import {- Button,cn,Empty,EmptyDescription,EmptyHeader,EmptyMedia,EmptyTitle,+ MenuLabel,Spinner,} from "@posthog/quill";import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";+import { ActivityActionsMenu } from "@posthog/ui/features/canvas/components/ActivityActionsMenu";+import { ActivityRow } from "@posthog/ui/features/canvas/components/ActivityRow";import { ActivityUnreadsToggle } from "@posthog/ui/features/canvas/components/ActivityUnreadsToggle";-import { ActivityRow } from "@posthog/ui/features/canvas/components/ActivityView";import { openActivityItem } from "@posthog/ui/features/canvas/components/openActivityItem";import { useBlockedTaskIds } from "@posthog/ui/features/canvas/hooks/useBlockedSessionCount";+import { useLocalDayStart } from "@posthog/ui/features/canvas/hooks/useLocalDayStart";import { useMarkTaskActivityRead } from "@posthog/ui/features/canvas/hooks/useMarkTaskActivityRead";import { useTaskActivity } from "@posthog/ui/features/canvas/hooks/useTaskActivity";import { useActivityFilterStore } from "@posthog/ui/features/canvas/stores/activityFilterStore";import { useInView } from "@posthog/ui/primitives/hooks/useInView";import { track } from "@posthog/ui/shell/analytics";-import { useEffect, useState } from "react";+import { Fragment, useEffect, useMemo, useState } from "react";import {activityReadPayload,getUnreadActivityItems,- markLoadedReadLabel,+ groupActivityItemsByDay,} from "./activityFeed";interface ActivityFeedListProps {@@ -64,6 +66,11 @@ export function ActivityFeedList({const unreadsOnly = useActivityFilterStore((state) => state.unreadsOnly);const unreadItems = getUnreadActivityItems(items);const shownItems = unreadsOnly ? unreadItems : items;+ const dayStart = useLocalDayStart();+ const shownItemGroups = useMemo(+ () => groupActivityItemsByDay(shownItems, new Date(dayStart)),+ [shownItems, dayStart],+ );const { mutate: markTasksRead, isPending: isMarkingRead } =useMarkTaskActivityRead();useEffect(() => {@@ -91,22 +98,19 @@ export function ActivityFeedList({<div className="flex h-10 shrink-0 items-center gap-2 border-border border-b pr-2 pl-3"><span className="font-bold text-base">Activity</span><div className="ml-auto flex shrink-0 items-center gap-1">- {unreadItems.length > 0 && (- <Button- variant="default"- size="sm"- loading={isMarkingRead}- disabled={isMarkingRead}- onClick={markAllRead}- >- <ChecksIcon size={14} />- {markLoadedReadLabel(unreadItems.length, unreadCount)}- </Button>- )}<ActivityUnreadsToggle />+ <ActivityActionsMenu+ loadedUnreadCount={unreadItems.length}+ totalUnreadCount={unreadCount}+ isMarkingRead={isMarkingRead}+ onMarkAllRead={markAllRead}+ /></div></div>- <div ref={setScrollRoot} className="min-h-0 flex-1 overflow-y-auto p-1.5">+ <div+ ref={setScrollRoot}+ className="scroll-mask-8 min-h-0 flex-1 overflow-y-auto p-1.5"+ >{isLoading && shownItems.length === 0 ? (<div className="flex justify-center py-10"><Spinner />@@ -129,23 +133,26 @@ export function ActivityFeedList({</Empty>) : (<div className="flex flex-col gap-px">- {shownItems.map((item) => (- <ActivityRow- key={item.id}- item={item}- channelId={item.channelId}- onOpen={markRead}- onMarkRead={markRead}- currentUser={currentUser}- blockedTaskIds={blockedTaskIds}- surface="activity_panel"- onActivate={(activated) => {- onActivate(activated);- onOpened?.();- }}- isSelected={item.id === selectedId}- compact- />+ {shownItemGroups.map((group) => (+ <Fragment key={group.key}>+ <MenuLabel>{group.label}</MenuLabel>+ {group.items.map((item) => (+ <ActivityRow+ key={item.id}+ item={item}+ onMarkRead={markRead}+ currentUser={currentUser}+ blockedTaskIds={blockedTaskIds}+ surface="activity_panel"+ onActivate={(activated) => {+ onActivate(activated);+ onOpened?.();+ }}+ isSelected={item.id === selectedId}+ compact+ />+ ))}+ </Fragment>))}</div>)}diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityView.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.test.tsxsimilarity index 55%rename from products/desktop/packages/ui/src/features/canvas/components/ActivityView.test.tsxrename to products/desktop/packages/ui/src/features/canvas/components/ActivityRow.test.tsxindex 9f6b7e4924f2..d74b392ae84e 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityView.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.test.tsx@@ -1,6 +1,6 @@import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";import { fireEvent, render, screen } from "@testing-library/react";-import { beforeEach, describe, expect, it, vi } from "vitest";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";const navigation = vi.hoisted(() => ({toChannelDashboard: vi.fn(),@@ -16,8 +16,7 @@ vi.mock("@posthog/ui/router/navigationBridge", () => ({vi.mock("@posthog/ui/shell/analytics", () => ({ track: vi.fn() }));import { useCommentNavigationStore } from "@posthog/ui/features/sessions/commentNavigationStore";-import { ActivityRow } from "./ActivityView";-import { activityHeadline } from "./activityHeadline";+import { ActivityRow } from "./ActivityRow";import { openActivityItem } from "./openActivityItem";function item(overrides: Partial<TaskActivityItem>): TaskActivityItem {@@ -39,8 +38,10 @@ function item(overrides: Partial<TaskActivityItem>): TaskActivityItem {const NO_BLOCKED_TASKS: ReadonlySet<string> = new Set();-describe("activityHeadline", () => {+describe("ActivityRow", () => {beforeEach(() => {+ vi.useFakeTimers();+ vi.setSystemTime(new Date("2026-07-27T10:00:00Z"));navigation.toChannelTask.mockReset();navigation.toChannelDashboard.mockReset();navigation.toTaskDetail.mockReset();@@ -49,73 +50,39 @@ describe("activityHeadline", () => {resolutionsByTarget: {},});});- it.each([- [- "completed run",- item({ activityKind: "completed" }),- "The agent completed this task",- ],- ["agent reply", item({ activityKind: "message" }), "The agent replied"],- [- "thread reply",- item({- activityKind: "thread_reply",- author: {- id: 2,- uuid: "author",- email: "[email protected]",- first_name: "Ann",- },- }),- "replied to a thread you participated in",- ],- [- "canvas owner comment",- item({- activityKind: "owned_item_comment",- commentTarget: { scope: "desktop_canvas", itemId: "canvas-1" },- author: {- id: 2,- uuid: "author",- email: "[email protected]",- first_name: "Ann",- },- }),- "commented on your canvas",- ],- [- "own reply",- item({- activityKind: "message",- author: {- id: 1,- uuid: "me",- email: "[email protected]",- first_name: "Me",- },- }),- "You replied",- ],- ])("labels a %s", (_name, activity, expected) => {- const { getByText } = render(- <div>{activityHeadline(activity, "[email protected]")}</div>,- );- expect(getByText(expected)).toBeInTheDocument();++ afterEach(() => {+ vi.useRealTimers();});- it.each([- ["shared channel", "engineering", "#engineering"],- ["personal channel", "personal", "your personal space"],- ])("formats the %s label", (_name, channelName, expected) => {- const { getByText } = render(- <div>- {activityHeadline(- item({ activityKind: "completed", channelName }),- "[email protected]",- )}- </div>,+ it("leads a completed activity row with the task title", () => {+ render(+ <ActivityRow+ item={item({+ activityKind: "completed",+ taskTitle: "Tell me a joke",+ channelName: "personal",+ })}+ onMarkRead={vi.fn()}+ onActivate={vi.fn()}+ blockedTaskIds={NO_BLOCKED_TASKS}+ compact+ />,+ );++ const title = screen.getByText("Tell me a joke");+ const metadata = screen.getByText("just now · Agent completed · Personal");+ expect(title.compareDocumentPosition(metadata)).toBe(+ Node.DOCUMENT_POSITION_FOLLOWING,+ );+ const row = title.closest("button");+ expect(row?.querySelector(".quill-avatar")).toHaveClass(+ "bg-primary",+ "text-primary-foreground",);- expect(getByText(expected)).toBeInTheDocument();+ expect(row).not.toHaveClass("bg-primary/10");+ expect(row).not.toHaveClass("outline-primary/20");+ expect(screen.queryByTitle("New activity")).not.toBeInTheDocument();});it("opens an activity mention at its exact comment thread", () => {@@ -135,14 +102,14 @@ describe("activityHeadline", () => {render(<ActivityRowitem={activity}- channelId="channel-1"- onOpen={vi.fn()}onMarkRead={vi.fn()}onActivate={openActivityItem}blockedTaskIds={NO_BLOCKED_TASKS}/>,);- const activityButton = screen.getByText("mentioned you").closest("button");+ const activityButton = screen+ .getByText("just now · Ann mentioned you")+ .closest("button");if (!activityButton) throw new Error("Expected activity row button");fireEvent.click(activityButton);diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.tsxnew file mode 100644index 000000000000..cd108290f731--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.tsx@@ -0,0 +1,163 @@+import {+ ChatCircleIcon,+ CheckIcon,+ LinkIcon,+ QuestionIcon,+} from "@phosphor-icons/react";+import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";+import { Avatar, AvatarFallback, Badge, Button } from "@posthog/quill";+import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";+import type { UserBasic } from "@posthog/shared/domain-types";+import { UserAvatar } from "@posthog/ui/features/auth/UserAvatar";+import {+ type AgentActivityIconKind,+ activityPresentation,+} from "@posthog/ui/features/canvas/components/activityPresentation";+import { MentionText } from "@posthog/ui/features/canvas/components/MentionText";+import { copyChannelLink } from "@posthog/ui/features/canvas/utils/copyChannelLink";+import { useCommentNavigationStore } from "@posthog/ui/features/sessions/commentNavigationStore";+import { track } from "@posthog/ui/shell/analytics";+import type { ReactElement } from "react";++function AgentActivityIcon({+ kind,+ className,+}: {+ kind: AgentActivityIconKind;+ className?: string;+}): ReactElement {+ switch (kind) {+ case "check":+ return <CheckIcon size={13} weight="bold" className={className} />;+ case "question":+ return <QuestionIcon size={12} weight="bold" className={className} />;+ case "chat":+ return <ChatCircleIcon size={13} weight="bold" className={className} />;+ default: {+ const exhaustiveIconKind: never = kind;+ return exhaustiveIconKind;+ }+ }+}++interface ActivityRowProps {+ item: TaskActivityItem;+ onMarkRead: (item: TaskActivityItem) => void;+ currentUser?: UserBasic | null;+ blockedTaskIds: ReadonlySet<string>;+ surface?: "activity" | "activity_panel";+ onActivate: (item: TaskActivityItem) => void;+ isSelected?: boolean;+ compact?: boolean;+}++export function ActivityRow({+ item,+ onMarkRead,+ currentUser,+ blockedTaskIds,+ surface = "activity",+ onActivate,+ isSelected = false,+ compact = false,+}: ActivityRowProps): ReactElement {+ const presentation = activityPresentation(item, currentUser?.email);+ const channelId = item.channelId;+ // The event records a past prompt; only the live session says whether it+ // still needs a reply after the row was created.+ const awaitsReply =+ item.activityKind === "awaiting_input" && blockedTaskIds.has(item.taskId);+ const agentIconClassName = awaitsReply ? "text-(--blue-11)" : undefined;+ const agentIconWrapperClassName =+ item.isUnread && !awaitsReply+ ? "bg-primary text-primary-foreground"+ : undefined;+ const openTask = (): void => {+ track(ANALYTICS_EVENTS.CHANNEL_ACTION, {+ action_type: "open_task",+ surface,+ channel_id: channelId ?? undefined,+ task_id: item.taskId,+ });+ onMarkRead(item);+ if (item.commentId && item.commentTarget) {+ useCommentNavigationStore+ .getState()+ .requestCommentFocus(item.taskId, item.commentTarget, item.commentId);+ }+ onActivate(item);+ };++ return (+ <div className="group relative">+ <Button+ type="button"+ onClick={openTask}+ left+ className={`h-auto w-full items-start text-left ${compact ? "py-1.5 pr-10" : "py-2"} ${isSelected ? "bg-fill-selected" : ""}`}+ >+ <span className="mt-0.5 shrink-0">+ {presentation.agentIcon ? (+ <Avatar size="xs" className={agentIconWrapperClassName}>+ <AvatarFallback>+ <AgentActivityIcon+ kind={presentation.agentIcon}+ className={agentIconClassName}+ />+ </AvatarFallback>+ </Avatar>+ ) : (+ <span className="mt-1 flex shrink-0">+ <UserAvatar user={item.author ?? currentUser} size="xs" />+ </span>+ )}+ </span>+ <span className="min-w-0 flex-1">+ <span className="flex items-baseline gap-2">+ <span+ className={`truncate text-[13px] ${item.isUnread ? "font-semibold" : "font-medium"}`}+ >+ {item.taskTitle}+ </span>+ {item.isUnread && !compact && <Badge variant="info">New</Badge>}+ </span>+ <span className="block truncate text-muted-foreground text-xxs">+ {presentation.metadata}+ </span>+ {item.snippet && !compact && (+ <MentionText+ content={item.snippet}+ currentUserEmail={currentUser?.email}+ className="mt-1 block whitespace-pre-wrap break-words text-xs"+ />+ )}+ </span>+ </Button>+ {item.isUnread && (+ <Button+ variant="default"+ size="icon-xs"+ aria-label="Mark as read"+ title="Mark as read"+ className={`absolute opacity-0 transition-opacity group-hover:opacity-100 ${compact ? "top-2 right-2" : `top-2 ${channelId ? "right-9" : "right-2"}`}`}+ onClick={() => onMarkRead(item)}+ >+ <CheckIcon size={14} />+ </Button>+ )}+ {channelId && !compact && (+ <Button+ variant="default"+ size="icon-xs"+ aria-label="Copy thread link"+ className="absolute top-2 right-2 opacity-0 transition-opacity group-hover:opacity-100"+ onClick={() =>+ void copyChannelLink(channelId, "activity", item.taskId)+ }+ >+ <LinkIcon size={14} />+ </Button>+ )}+ </div>+ );+}diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityView.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityView.tsxindex 11799600effa..51d79c3399b5 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityView.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityView.tsx@@ -1,306 +1,35 @@-import {- BellIcon,- CheckIcon,- ChecksIcon,- LinkIcon,- RobotIcon,-} from "@phosphor-icons/react";-import { channelDisplayReference } from "@posthog/core/canvas/channelName";+import { BellIcon } from "@phosphor-icons/react";import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";import {- Avatar,- AvatarFallback,- Badge,Button,Empty,EmptyDescription,EmptyHeader,EmptyMedia,EmptyTitle,+ MenuLabel,Spinner,} from "@posthog/quill";-import { formatRelativeTimeShort } from "@posthog/shared";import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";-import type { UserBasic } from "@posthog/shared/domain-types";import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";-import { UserAvatar } from "@posthog/ui/features/auth/UserAvatar";import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";+import { ActivityActionsMenu } from "@posthog/ui/features/canvas/components/ActivityActionsMenu";+import { ActivityRow } from "@posthog/ui/features/canvas/components/ActivityRow";import { ActivityUnreadsToggle } from "@posthog/ui/features/canvas/components/ActivityUnreadsToggle";-import { MentionText } from "@posthog/ui/features/canvas/components/MentionText";import { openActivityItem } from "@posthog/ui/features/canvas/components/openActivityItem";import { useBlockedTaskIds } from "@posthog/ui/features/canvas/hooks/useBlockedSessionCount";+import { useLocalDayStart } from "@posthog/ui/features/canvas/hooks/useLocalDayStart";import { useMarkTaskActivityRead } from "@posthog/ui/features/canvas/hooks/useMarkTaskActivityRead";import { useTaskActivity } from "@posthog/ui/features/canvas/hooks/useTaskActivity";import { useActivityFilterStore } from "@posthog/ui/features/canvas/stores/activityFilterStore";-import { copyChannelLink } from "@posthog/ui/features/canvas/utils/copyChannelLink";-import { userDisplayName } from "@posthog/ui/features/canvas/utils/userDisplay";-import { useCommentNavigationStore } from "@posthog/ui/features/sessions/commentNavigationStore";-import { DOT_TONE_VAR } from "@posthog/ui/features/sidebar/components/items/taskStatusVocabulary";import { track } from "@posthog/ui/shell/analytics";-import { Text } from "@radix-ui/themes";-import type { ReactNode } from "react";-import { useCallback, useEffect, useMemo } from "react";+import { Fragment, useCallback, useEffect, useMemo } from "react";import {activityReadPayload,getUnreadActivityItems,- markLoadedReadLabel,+ groupActivityItemsByDay,} from "./activityFeed";-function ChannelSuffix({ channelName }: { channelName: string | null }) {- if (!channelName) return null;- return (- <>- {" in "}- <span className="font-medium text-xs">- {channelDisplayReference(channelName)}- </span>- </>- );-}--function ownedItemName(item: TaskActivityItem): string {- switch (item.commentTarget?.scope) {- case "desktop_canvas":- return "canvas";- case "task_artifact":- return "artifact";- default:- return "task";- }-}--/** The lead line describing what happened, chosen by the row's activity kind. */-export function activityHeadline(- item: TaskActivityItem,- currentUserEmail?: string | null,-): ReactNode {- switch (item.activityKind) {- case "awaiting_input":- return (- <>- The agent is waiting for your reply- <ChannelSuffix channelName={item.channelName} />- </>- );- case "completed":- return (- <>- The agent completed this task- <ChannelSuffix channelName={item.channelName} />- </>- );- case "message":- if (!item.author) {- return (- <>- The agent replied- <ChannelSuffix channelName={item.channelName} />- </>- );- }- return (- <>- {item.author.email === currentUserEmail- ? "You replied"- : `${userDisplayName(item.author)} replied`}- <ChannelSuffix channelName={item.channelName} />- </>- );- case "mention":- return (- <>- <Text as="span" size="1" weight="medium">- {userDisplayName(item.author)}- </Text>{" "}- mentioned you- <ChannelSuffix channelName={item.channelName} />- </>- );- case "thread_reply":- return (- <>- <Text as="span" size="1" weight="medium">- {userDisplayName(item.author)}- </Text>{" "}- replied to a thread you participated in- <ChannelSuffix channelName={item.channelName} />- </>- );- case "owned_item_comment":- return (- <>- <Text as="span" size="1" weight="medium">- {userDisplayName(item.author)}- </Text>{" "}- commented on your {ownedItemName(item)}- <ChannelSuffix channelName={item.channelName} />- </>- );- default:- return "You created this task";- }-}--export function ActivityRow({- item,- channelId,- onOpen,- onMarkRead,- currentUser,- blockedTaskIds,- surface = "activity",- onActivate,- isSelected = false,- compact = false,-}: {- item: TaskActivityItem;- /** Backend channel id (the /website route param); null when the task is unfiled. */- channelId: string | null;- onOpen: (item: TaskActivityItem) => void;- onMarkRead: (item: TaskActivityItem) => void;- currentUser?: UserBasic | null;- /**- * Tasks whose session is waiting on you. Passed in rather than selected here:- * the feed renders one of these per item, and the selector behind it scans and- * sorts every live session on each store notification.- */- blockedTaskIds: ReadonlySet<string>;- surface?: "activity" | "activity_panel";- /** Where the row goes is the feed's business, not the row's. */- onActivate: (item: TaskActivityItem) => void;- isSelected?: boolean;- compact?: boolean;-}) {- const isAgentActivity =- item.activityKind === "awaiting_input" ||- item.activityKind === "completed" ||- (item.activityKind === "message" && !item.author);- // The one row here that is blocked on you, and the sidebar's session rows- // already say that in blue. Yellow is everything else the feed carries:- // something happened that you haven't read.- //- // Read against the live sessions rather than the row's kind alone, so this is- // the same fact the sidebar's blue dot is drawn from. The row records that the- // agent asked at a moment in time; whether it is still waiting is a question- // only the session can answer, and answering the prompt has to clear the dot.- const awaitsReply =- item.activityKind === "awaiting_input" && blockedTaskIds.has(item.taskId);- const openTask = () => {- track(ANALYTICS_EVENTS.CHANNEL_ACTION, {- action_type: "open_task",- surface,- channel_id: channelId ?? undefined,- task_id: item.taskId,- });- onOpen(item);- if (item.commentId && item.commentTarget) {- useCommentNavigationStore- .getState()- .requestCommentFocus(item.taskId, item.commentTarget, item.commentId);- }- onActivate(item);- };-- return (- <div className="group relative">- <Button- type="button"- onClick={openTask}- left- className={`h-auto w-full text-left ${compact ? "py-1.5 pr-10" : "py-2"} ${isSelected ? "bg-fill-selected" : item.isUnread ? "bg-primary/10 outline outline-primary/20 hover:bg-primary/15" : ""}`}- >- <span className="relative mt-0.5 shrink-0">- {isAgentActivity ? (- <Avatar size="xs">- <AvatarFallback>- <RobotIcon size={12} />- </AvatarFallback>- </Avatar>- ) : (- <UserAvatar user={item.author ?? currentUser} size="xs" />- )}- {/* Unread is a fact about the feed: you haven't looked at this yet.- Waiting on you is a fact about the session, and reading the row- doesn't answer the prompt — so it keeps its dot until you do. */}- {(item.isUnread || awaitsReply) && (- <span- className="-top-0.5 -right-0.5 absolute h-2 w-2 rounded-full"- // Off the table the status dots read, so a row that says the agent- // is waiting is the same blue as the session it is waiting in.- style={{- backgroundColor: awaitsReply- ? DOT_TONE_VAR.blue- : "var(--primary)",- }}- title={awaitsReply ? "Waiting on you" : "New activity"}- />- )}- </span>- <span className="min-w-0 flex-1">- <span className="flex items-baseline gap-2">- <Text- size="1"- weight={item.isUnread ? "medium" : "regular"}- className="truncate"- >- {activityHeadline(item, currentUser?.email)}- </Text>- {item.isUnread && !compact && <Badge variant="info">New</Badge>}- {!compact && (- <Text size="1" className="shrink-0 text-muted-foreground">- {formatRelativeTimeShort(item.activityAt)}- </Text>- )}- </span>- <span className="block truncate text-muted-foreground text-xs">- {item.taskTitle}- </span>- {item.snippet && !compact && (- <MentionText- content={item.snippet}- currentUserEmail={currentUser?.email}- className="mt-1 block whitespace-pre-wrap break-words text-xs"- />- )}- </span>- </Button>- {compact && (- <Text- size="1"- className="pointer-events-none absolute top-1.5 right-2 text-muted-foreground text-xs"- >- {formatRelativeTimeShort(item.activityAt)}- </Text>- )}- {item.isUnread && (- <Button- variant="default"- size="icon-xs"- aria-label="Mark as read"- title="Mark as read"- className={`absolute opacity-0 transition-opacity group-hover:opacity-100 ${compact ? "right-2 bottom-1" : `top-2 ${channelId ? "right-9" : "right-2"}`}`}- onClick={() => onMarkRead(item)}- >- <CheckIcon size={14} />- </Button>- )}- {channelId && !compact && (- <Button- variant="default"- size="icon-xs"- aria-label="Copy thread link"- className="absolute top-2 right-2 opacity-0 transition-opacity group-hover:opacity-100"- onClick={() =>- void copyChannelLink(channelId, "activity", item.taskId)- }- >- <LinkIcon size={14} />- </Button>- )}- </div>- );-}-// The Activity page for the code layout: every task the viewer is involved in —// created, mentioned in, or messaged in — newest activity first. Rows clear as// they are opened, not when the page is; merely landing here shouldn't dismiss@@ -323,25 +52,18 @@ export function ActivityView() {const blockedTaskIds = useBlockedTaskIds();const { mutate: markTasksRead, isPending: isMarkingRead } =useMarkTaskActivityRead();- const visibleItems = items;- const unreadItems = useMemo(- () => getUnreadActivityItems(visibleItems),- [visibleItems],- );+ const unreadItems = useMemo(() => getUnreadActivityItems(items), [items]);const unreadsOnly = useActivityFilterStore((state) => state.unreadsOnly);- const shownItems = unreadsOnly ? unreadItems : visibleItems;- const visibleUnreadCount = unreadCount;+ const shownItems = unreadsOnly ? unreadItems : items;+ const dayStart = useLocalDayStart();+ const shownItemGroups = useMemo(+ () => groupActivityItemsByDay(shownItems, new Date(dayStart)),+ [shownItems, dayStart],+ );// Opening a row is what marks it read. The server does the same when the task is// reached any other way, so the feed converges either way.const markRead = useCallback(- (item: TaskActivityItem) =>- markTasksRead([- {- task_id: item.taskId,- seen_before: item.activityAt,- ...(item.commentId ? { activity_id: item.id } : {}),- },- ]),+ (item: TaskActivityItem) => markTasksRead(activityReadPayload([item])),[markTasksRead],);const markAllRead = useCallback(() => {@@ -354,19 +76,6 @@ export function ActivityView() {});}, []);- const markAllReadButton = (- <Button- variant="default"- size="sm"- loading={isMarkingRead}- disabled={isMarkingRead}- onClick={markAllRead}- >- <ChecksIcon size={14} />- {markLoadedReadLabel(unreadItems.length, visibleUnreadCount)}- </Button>- );-// Sits below the rows and below the empty state alike: filtering to unreads can// empty a page that still has unread activity waiting on the next one.const loadMoreButton = hasNextPage && (@@ -411,17 +120,20 @@ export function ActivityView() {) : (<><div className="flex flex-col gap-0.5">- {shownItems.map((item) => (- <ActivityRow- key={item.id}- item={item}- channelId={item.channelId}- onOpen={markRead}- onMarkRead={markRead}- onActivate={openActivityItem}- currentUser={currentUser}- blockedTaskIds={blockedTaskIds}- />+ {shownItemGroups.map((group) => (+ <Fragment key={group.key}>+ <MenuLabel>{group.label}</MenuLabel>+ {group.items.map((item) => (+ <ActivityRow+ key={item.id}+ item={item}+ onMarkRead={markRead}+ onActivate={openActivityItem}+ currentUser={currentUser}+ blockedTaskIds={blockedTaskIds}+ />+ ))}+ </Fragment>))}</div>{loadMoreButton}@@ -433,16 +145,19 @@ export function ActivityView() {<div className="mx-auto w-full max-w-[680px] px-4 py-6"><div className="flex items-start justify-between gap-4"><div>- <Text size="5" weight="bold" className="block">- Activity- </Text>- <Text size="2" className="block text-muted-foreground">+ <h1 className="font-bold text-2xl">Activity</h1>+ <p className="text-muted-foreground text-sm">Task updates and comment notifications across channels.- </Text>+ </p></div><div className="flex shrink-0 items-center gap-2">- {unreadCount > 0 && markAllReadButton}<ActivityUnreadsToggle />+ <ActivityActionsMenu+ loadedUnreadCount={unreadItems.length}+ totalUnreadCount={unreadCount}+ isMarkingRead={isMarkingRead}+ onMarkAllRead={markAllRead}+ /></div></div><div className="mt-4">{feed}</div>diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelSidebar.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelSidebar.tsxindex 0cb599d90ebc..67e90afb3c37 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelSidebar.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelSidebar.tsx@@ -199,7 +199,7 @@ function RecentSectionHeader({))}</TabsList></Tabs>- <>+ <div className="ml-auto flex items-center gap-0.5"><Buttonvariant="default"size="icon-xs"@@ -224,7 +224,7 @@ function RecentSectionHeader({showRunFilters={showRunFilters}active={filtersActive}/>- </>+ </div></div>{searchOpen && (<div className="px-1 pb-1">@@ -797,65 +797,64 @@ export function ChannelSidebar({ channelId }: { channelId: string }) {)}{/* Pin and unpin stay reachable from the row's menu and its contextmenu, so the drag adds no keyboard-only path. */}- <>- {/* biome-ignore lint/a11y/noStaticElementInteractions: drag-and-drop container */}- <div- aria-busy={isLoading}- className="scroll-mask-4 min-h-0 flex-1 overflow-y-auto px-2 pt-1 pb-2"- onDragOver={pinDrag.listProps.onDragOver}- onDrop={pinDrag.listProps.onDrop}- >- {listState === "loading" && <ChannelItemsSkeleton />}- {listState === "unavailable" && (+ {/* biome-ignore lint/a11y/noStaticElementInteractions: drag-and-drop container */}+ <div+ aria-busy={isLoading}+ className="scroll-mask-4 min-h-0 flex-1 overflow-y-auto px-2 pt-1 pb-2"+ onDragOver={pinDrag.listProps.onDragOver}+ onDrop={pinDrag.listProps.onDrop}+ >+ {listState === "loading" && <ChannelItemsSkeleton />}++ {listState === "unavailable" && (+ <Empty className="border-0 py-6">+ <EmptyHeader>+ <EmptyMedia variant="icon">+ <PackageIcon size={18} />+ </EmptyMedia>+ <EmptyTitle>Space unavailable</EmptyTitle>+ <EmptyDescription>+ It may have been deleted, or belong to another project.+ </EmptyDescription>+ </EmptyHeader>+ </Empty>+ )}++ {showHeader &&+ (listState === "empty" ? (+ <TabEmptyState tab={tab} />+ ) : sections.length > 0 ? (+ <div className="flex flex-col gap-px">+ {/* Always mounted, empty or not. Inserting the run on+ dragstart restructures the list under the dragged row, and+ Chromium ends the drag on the spot: dragstart, then dragend,+ before the pointer moves. Growing one already there is+ fine. */}+ {pinnedRun()}+ {datedSections.map((section) => (+ <Fragment key={section.key}>+ {section.label && <MenuLabel>{section.label}</MenuLabel>}+ {section.items.map((item) => taskRow(item, true))}+ </Fragment>+ ))}+ </div>+ ) : (<Empty className="border-0 py-6"><EmptyHeader><EmptyMedia variant="icon">- <PackageIcon size={18} />+ <MagnifyingGlass size={18} /></EmptyMedia>- <EmptyTitle>Space unavailable</EmptyTitle>+ <EmptyTitle>No matches</EmptyTitle><EmptyDescription>- It may have been deleted, or belong to another project.+ Try a different search or clear the filters.</EmptyDescription></EmptyHeader></Empty>- )}-- {showHeader &&- (listState === "empty" ? (- <TabEmptyState tab={tab} />- ) : sections.length > 0 ? (- <div className="flex flex-col gap-px">- {/* Always mounted, empty or not. Inserting the run on- dragstart restructures the list under the dragged row, and- Chromium ends the drag on the spot: dragstart, then dragend,- before the pointer moves. Growing one already there is- fine. */}- {pinnedRun()}- {datedSections.map((section) => (- <Fragment key={section.key}>- {section.label && <MenuLabel>{section.label}</MenuLabel>}- {section.items.map((item) => taskRow(item, true))}- </Fragment>- ))}- </div>- ) : (- <Empty className="border-0 py-6">- <EmptyHeader>- <EmptyMedia variant="icon">- <MagnifyingGlass size={18} />- </EmptyMedia>- <EmptyTitle>No matches</EmptyTitle>- <EmptyDescription>- Try a different search or clear the filters.- </EmptyDescription>- </EmptyHeader>- </Empty>- ))}- </div>- <ChannelsFab channelId={channelId} />- <MarqueeOverlay rect={marquee} />- </>+ ))}+ </div>+ <ChannelsFab channelId={channelId} />+ <MarqueeOverlay rect={marquee} /></div>{/* Below the list rather than floating over it: the bottom rows are wherediff --git a/products/desktop/packages/ui/src/features/canvas/components/activityFeed.test.ts b/products/desktop/packages/ui/src/features/canvas/components/activityFeed.test.tsindex 2a0fd7e49b41..fe2b1254b88b 100644--- a/products/desktop/packages/ui/src/features/canvas/components/activityFeed.test.ts+++ b/products/desktop/packages/ui/src/features/canvas/components/activityFeed.test.ts@@ -1,9 +1,33 @@import { describe, expect, it } from "vitest";-import { markLoadedReadLabel } from "./activityFeed";+import { groupActivityItemsByDay, markLoadedReadLabel } from "./activityFeed";describe("activityFeed", () => {it('says "Mark visible as read" while unread activity stays on unloaded pages', () => {expect(markLoadedReadLabel(3, 8)).toBe("Mark visible as read");expect(markLoadedReadLabel(8, 8)).toBe("Mark all as read");});++ it("groups activity by the same local calendar days as the space list", () => {+ const now = new Date(2026, 7, 25, 12);+ const activity = (id: string, day: number, hour: number) => ({+ id,+ activityAt: new Date(2026, 7, day, hour).toISOString(),+ });++ expect(+ groupActivityItemsByDay(+ [+ activity("today-late", 25, 11),+ activity("yesterday", 24, 20),+ activity("today-early", 25, 8),+ activity("last-wednesday", 19, 9),+ ],+ now,+ ).map((group) => [group.label, ...group.items.map((item) => item.id)]),+ ).toEqual([+ ["Today", "today-late", "today-early"],+ ["Yesterday", "yesterday"],+ ["Wednesday", "last-wednesday"],+ ]);+ });});diff --git a/products/desktop/packages/ui/src/features/canvas/components/activityFeed.ts b/products/desktop/packages/ui/src/features/canvas/components/activityFeed.tsindex a0867a55d56b..592e2cac17ae 100644--- a/products/desktop/packages/ui/src/features/canvas/components/activityFeed.ts+++ b/products/desktop/packages/ui/src/features/canvas/components/activityFeed.ts@@ -1,4 +1,33 @@import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";+import { formatShortDayLabel, getLocalDayKey } from "@posthog/shared";++export interface ActivityDayGroup<T> {+ key: string;+ label: string;+ items: T[];+}++export function groupActivityItemsByDay<T extends { activityAt: string }>(+ items: readonly T[],+ now: Date = new Date(),+): ActivityDayGroup<T>[] {+ const groups = new Map<string, ActivityDayGroup<T>>();+ for (const item of items) {+ const timestamp = Math.min(new Date(item.activityAt).getTime(), +now);+ const key = `day:${getLocalDayKey(timestamp)}`;+ const group = groups.get(key);+ if (group) {+ group.items.push(item);+ continue;+ }+ groups.set(key, {+ key,+ label: formatShortDayLabel(timestamp, now),+ items: [item],+ });+ }+ return [...groups.values()];+}export function getUnreadActivityItems(items: TaskActivityItem[],diff --git a/products/desktop/packages/ui/src/features/canvas/components/activityHeadline.tsx b/products/desktop/packages/ui/src/features/canvas/components/activityHeadline.tsxdeleted file mode 100644index c97ba43c25c8..000000000000--- a/products/desktop/packages/ui/src/features/canvas/components/activityHeadline.tsx+++ /dev/null@@ -1,99 +0,0 @@-import { channelDisplayReference } from "@posthog/core/canvas/channelName";-import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";-import { userDisplayName } from "@posthog/ui/features/canvas/utils/userDisplay";-import type { ReactNode } from "react";--function ChannelSuffix({ channelName }: { channelName: string | null }) {- if (!channelName) return null;- return (- <>- {" in "}- <span className="font-medium text-xs">- {channelDisplayReference(channelName)}- </span>- </>- );-}--function ownedItemName(item: TaskActivityItem): string {- switch (item.commentTarget?.scope) {- case "desktop_canvas":- return "canvas";- case "task_artifact":- return "artifact";- default:- return "task";- }-}--/** The lead line describing what happened, chosen by the row's activity kind. */-export function activityHeadline(- item: TaskActivityItem,- currentUserEmail?: string | null,-): ReactNode {- switch (item.activityKind) {- case "awaiting_input":- return (- <>- The agent is waiting for your reply- <ChannelSuffix channelName={item.channelName} />- </>- );- case "completed":- return (- <>- The agent completed this task- <ChannelSuffix channelName={item.channelName} />- </>- );- case "message":- if (!item.author) {- return (- <>- The agent replied- <ChannelSuffix channelName={item.channelName} />- </>- );- }- return (- <>- {item.author.email === currentUserEmail- ? "You replied"- : `${userDisplayName(item.author)} replied`}- <ChannelSuffix channelName={item.channelName} />- </>- );- case "mention":- return (- <>- <span className="font-medium text-xs">- {userDisplayName(item.author)}- </span>{" "}- mentioned you- <ChannelSuffix channelName={item.channelName} />- </>- );- case "thread_reply":- return (- <>- <span className="font-medium text-xs">- {userDisplayName(item.author)}- </span>{" "}- replied to a thread you participated in- <ChannelSuffix channelName={item.channelName} />- </>- );- case "owned_item_comment":- return (- <>- <span className="font-medium text-xs">- {userDisplayName(item.author)}- </span>{" "}- commented on your {ownedItemName(item)}- <ChannelSuffix channelName={item.channelName} />- </>- );- default:- return "You created this task";- }-}diff --git a/products/desktop/packages/ui/src/features/canvas/components/activityPresentation.test.ts b/products/desktop/packages/ui/src/features/canvas/components/activityPresentation.test.tsnew file mode 100644index 000000000000..b18b1b424a43--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/activityPresentation.test.ts@@ -0,0 +1,120 @@+import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import {+ type AgentActivityIconKind,+ activityPresentation,+} from "./activityPresentation";++function item(overrides: Partial<TaskActivityItem>): TaskActivityItem {+ return {+ id: "activity-1",+ taskId: "task-1",+ taskTitle: "Say hello",+ channelId: null,+ channelName: null,+ activityAt: "2026-07-27T10:00:00Z",+ activityKind: "message",+ snippet: "Hello!",+ author: null,+ messageId: "message-1",+ isUnread: true,+ ...overrides,+ };+}++const AUTHOR = {+ id: 2,+ uuid: "author",+ email: "[email protected]",+ first_name: "Ann",+};++describe("activityPresentation", () => {+ beforeEach(() => {+ vi.useFakeTimers();+ vi.setSystemTime(new Date("2026-07-27T10:00:00Z"));+ });++ afterEach(() => {+ vi.useRealTimers();+ });++ it.each<[string, TaskActivityItem, string, AgentActivityIconKind | null]>([+ [+ "completed run",+ item({+ activityKind: "completed",+ activityAt: "2026-07-26T16:00:00Z",+ }),+ "18h ago · Agent completed",+ "check",+ ],+ [+ "waiting agent",+ item({ activityKind: "awaiting_input" }),+ "just now · Agent is waiting for your reply",+ "question",+ ],+ [+ "agent reply",+ item({ activityKind: "message" }),+ "just now · Agent replied",+ "chat",+ ],+ [+ "another person's reply",+ item({ activityKind: "message", author: AUTHOR }),+ "just now · Ann replied",+ null,+ ],+ [+ "mention",+ item({ activityKind: "mention", author: AUTHOR }),+ "just now · Ann mentioned you",+ null,+ ],+ [+ "thread reply",+ item({ activityKind: "thread_reply", author: AUTHOR }),+ "just now · Ann replied to a thread you participated in",+ null,+ ],+ [+ "canvas owner comment",+ item({+ activityKind: "owned_item_comment",+ commentTarget: { scope: "desktop_canvas", itemId: "canvas-1" },+ author: AUTHOR,+ }),+ "just now · Ann commented on your canvas",+ null,+ ],+ [+ "created task",+ item({ activityKind: "created" }),+ "just now · You created",+ null,+ ],+ ])("presents a %s", (_name, activity, metadata, agentIcon) => {+ expect(activityPresentation(activity, "[email protected]")).toEqual({+ metadata,+ agentIcon,+ });+ });++ it.each([+ [+ "shared channel",+ "engineering",+ "just now · Agent completed · #engineering",+ ],+ ["personal channel", "personal", "just now · Agent completed · Personal"],+ ])("formats the %s label", (_name, channelName, metadata) => {+ expect(+ activityPresentation(+ item({ activityKind: "completed", channelName }),+ "[email protected]",+ ).metadata,+ ).toBe(metadata);+ });+});diff --git a/products/desktop/packages/ui/src/features/canvas/components/activityPresentation.ts b/products/desktop/packages/ui/src/features/canvas/components/activityPresentation.tsnew file mode 100644index 000000000000..3878c8db0d62--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/components/activityPresentation.ts@@ -0,0 +1,102 @@+import {+ channelDisplayLabel,+ PERSONAL_CHANNEL_LABEL,+} from "@posthog/core/canvas/channelName";+import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";+import { formatRelativeAge } from "@posthog/shared";+import { userDisplayName } from "@posthog/ui/features/canvas/utils/userDisplay";++export type AgentActivityIconKind = "chat" | "check" | "question";++export interface ActivityPresentation {+ agentIcon: AgentActivityIconKind | null;+ metadata: string;+}++interface ActivityEventPresentation {+ action: string;+ agentIcon: AgentActivityIconKind | null;+}++function ownedItemName(item: TaskActivityItem): string {+ switch (item.commentTarget?.scope) {+ case "desktop_canvas":+ return "canvas";+ case "task_artifact":+ return "artifact";+ default:+ return "task";+ }+}++function activityEventPresentation(+ item: TaskActivityItem,+ currentUserEmail?: string | null,+): ActivityEventPresentation {+ switch (item.activityKind) {+ case "awaiting_input":+ return {+ action: "Agent is waiting for your reply",+ agentIcon: "question",+ };+ case "completed":+ return { action: "Agent completed", agentIcon: "check" };+ case "message":+ if (!item.author) {+ return { action: "Agent replied", agentIcon: "chat" };+ }+ return {+ action:+ item.author.email === currentUserEmail+ ? "You replied"+ : `${userDisplayName(item.author)} replied`,+ agentIcon: null,+ };+ case "mention":+ return {+ action: `${userDisplayName(item.author)} mentioned you`,+ agentIcon: null,+ };+ case "thread_reply":+ return {+ action: `${userDisplayName(item.author)} replied to a thread you participated in`,+ agentIcon: null,+ };+ case "owned_item_comment":+ return {+ action: `${userDisplayName(item.author)} commented on your ${ownedItemName(item)}`,+ agentIcon: null,+ };+ case "created":+ return { action: "You created", agentIcon: null };+ default: {+ const exhaustiveActivityKind: never = item.activityKind;+ return exhaustiveActivityKind;+ }+ }+}++function activitySpace(channelName: string | null): string | null {+ if (!channelName) {+ return null;+ }+ const label = channelDisplayLabel(channelName);+ return label === PERSONAL_CHANNEL_LABEL ? "Personal" : label;+}++export function activityPresentation(+ item: TaskActivityItem,+ currentUserEmail?: string | null,+): ActivityPresentation {+ const event = activityEventPresentation(item, currentUserEmail);+ return {+ agentIcon: event.agentIcon,+ metadata: [+ formatRelativeAge(item.activityAt),+ event.action,+ activitySpace(item.channelName),+ ]+ .filter((part): part is string => part !== null)+ .join(" · "),+ };+}