Skip to content

: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.

fix(desktop): refine activity notifications (#88333)

Adam Leithd1c4288d33c2
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.test.tsx
index d74b392ae84e..9145fe0e6cea 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.test.tsx
@@ -71,20 +71,49 @@ describe("ActivityRow", () => {
);
const title = screen.getByText("Tell me a joke");
- const metadata = screen.getByText("just now · Agent completed · Personal");
+ const metadata = screen.getByText("just now · Agent finished in");
+ const spaceBadge = screen.getByText("Personal").closest(".quill-badge");
expect(title.compareDocumentPosition(metadata)).toBe(
Node.DOCUMENT_POSITION_FOLLOWING,
);
+ expect(spaceBadge).toHaveClass("quill-badge--variant-default");
const row = title.closest("button");
+ expect(row).toHaveAccessibleName(
+ "Tell me a joke just now · Agent finished in Personal",
+ );
expect(row?.querySelector(".quill-avatar")).toHaveClass(
"bg-primary",
"text-primary-foreground",
+ "size-4",
);
expect(row).not.toHaveClass("bg-primary/10");
expect(row).not.toHaveClass("outline-primary/20");
expect(screen.queryByTitle("New activity")).not.toBeInTheDocument();
});
+ it.each([
+ { label: "unread", isUnread: true, hasActionPadding: true },
+ { label: "read", isUnread: false, hasActionPadding: false },
+ ])(
+ "reserves trailing room for a compact $label row only when it has a read action",
+ ({ isUnread, hasActionPadding }) => {
+ render(
+ <ActivityRow
+ item={item({ isUnread })}
+ onMarkRead={vi.fn()}
+ onActivate={vi.fn()}
+ blockedTaskIds={NO_BLOCKED_TASKS}
+ compact
+ />,
+ );
+
+ const row = screen.getByText("Say hello").closest("button");
+ expect(row).toHaveClass("py-1.5");
+ expect(row).not.toHaveClass("pr-10");
+ expect(row?.classList.contains("pr-8")).toBe(hasActionPadding);
+ },
+ );
+
it("opens an activity mention at its exact comment thread", () => {
const activity = item({
activityKind: "mention",
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.tsx
index cd108290f731..a1d01aba7c7f 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.tsx
@@ -1,11 +1,12 @@
import {
ChatCircleIcon,
CheckIcon,
+ ChecksIcon,
LinkIcon,
QuestionIcon,
} from "@phosphor-icons/react";
import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";
-import { Avatar, AvatarFallback, Badge, Button } from "@posthog/quill";
+import { Avatar, AvatarFallback, Badge, Button, cn } 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";
@@ -28,7 +29,7 @@ function AgentActivityIcon({
}): ReactElement {
switch (kind) {
case "check":
- return <CheckIcon size={13} weight="bold" className={className} />;
+ return <ChecksIcon size={13} weight="bold" className={className} />;
case "question":
return <QuestionIcon size={12} weight="bold" className={className} />;
case "chat":
@@ -93,12 +94,21 @@ export function ActivityRow({
<Button
type="button"
onClick={openTask}
+ aria-label={`${item.taskTitle} ${presentation.metadata}${presentation.spaceLabel ? ` ${presentation.spaceLabel}` : ""}`}
left
- className={`h-auto w-full items-start text-left ${compact ? "py-1.5 pr-10" : "py-2"} ${isSelected ? "bg-fill-selected" : ""}`}
+ className={cn(
+ "h-auto w-full items-start text-left",
+ compact ? "py-1.5" : "py-2",
+ compact && item.isUnread && "pr-8",
+ isSelected && "bg-fill-selected",
+ )}
>
<span className="mt-0.5 shrink-0">
{presentation.agentIcon ? (
- <Avatar size="xs" className={agentIconWrapperClassName}>
+ <Avatar
+ size="xs"
+ className={cn(agentIconWrapperClassName, compact && "size-4")}
+ >
<AvatarFallback>
<AgentActivityIcon
kind={presentation.agentIcon}
@@ -108,7 +118,11 @@ export function ActivityRow({
</Avatar>
) : (
<span className="mt-1 flex shrink-0">
- <UserAvatar user={item.author ?? currentUser} size="xs" />
+ <UserAvatar
+ user={item.author ?? currentUser}
+ size="xs"
+ className={compact ? "size-4" : undefined}
+ />
</span>
)}
</span>
@@ -121,8 +135,17 @@ export function ActivityRow({
</span>
{item.isUnread && !compact && <Badge variant="info">New</Badge>}
</span>
- <span className="block truncate text-muted-foreground text-xxs">
- {presentation.metadata}
+ <span className="flex min-w-0 items-center gap-1 text-muted-foreground text-xxs">
+ <span className="truncate">{presentation.metadata}</span>
+ {presentation.spaceLabel && (
+ <Badge
+ variant="default"
+ className="min-w-0 shrink rounded-xs bg-muted/70 p-0"
+ title={presentation.spaceLabel}
+ >
+ <span className="truncate">{presentation.spaceLabel}</span>
+ </Badge>
+ )}
</span>
{item.snippet && !compact && (
<MentionText
diff --git a/products/desktop/packages/ui/src/features/canvas/components/NavRail.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/NavRail.test.tsx
index df78251fe04a..678bff7a01c8 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/NavRail.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/NavRail.test.tsx
@@ -48,7 +48,7 @@ vi.mock("@posthog/ui/features/canvas/hooks/useChannelsLayout", () => ({
useChannelsLayout: () => true,
}));
vi.mock("@posthog/ui/features/inbox/hooks/useInboxAllReports", () => ({
- useInboxAllReports: () => ({ counts: { pulls: 0 } }),
+ useInboxAllReports: () => ({ counts: { pulls: 1 } }),
}));
vi.mock("@posthog/ui/features/sidebar/components/ProjectSwitcher", () => ({
ProjectSwitcher: () => (
@@ -160,6 +160,18 @@ describe("NavRail", () => {
]);
});
+ it("puts numberless notification dots on the Activity and Self-driving buttons", () => {
+ render(<NavRail />);
+
+ for (const label of ["Activity", "Self-driving"]) {
+ const button = screen.getByLabelText(label);
+ const dot = button.querySelector('[data-slot="dot"]');
+
+ expect(dot).toHaveClass("absolute", "top-0", "right-0");
+ expect(dot).toHaveTextContent("");
+ }
+ });
+
// The route is the whole answer, so a destination can never be lit over a
// screen that isn't it.
it.each([
diff --git a/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx b/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx
index 6895aaaff2e7..08e1982ad1ca 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx
@@ -53,6 +53,8 @@ const INBOX_REFETCH_INTERVAL_MS = 60_000;
const ICON_BADGE_CLASS =
"-top-1 -right-1 absolute h-3.5 min-w-3.5 w-auto px-1 font-semibold text-[9px] ring-2 ring-chrome";
+const NOTIFICATION_DOT_CLASS =
+ "top-0 right-0 absolute ring-2 ring-chrome size-2 bg-primary rounded-full";
function NavIcon({
icon,
@@ -240,13 +242,27 @@ export function NavRail() {
{destinations.map((destination) => {
const { pane, label, Icon, count, countTone } = destination;
const isActive = railPane === pane;
- const badge = (
- <CountBadge
- count={count?.(counts) ?? 0}
- tone={countTone}
- className={ICON_BADGE_CLASS}
- />
- );
+ const destinationCount = count?.(counts) ?? 0;
+ const usesNotificationDot = pane === "activity" || pane === "inbox";
+ let badge: ReactNode;
+ if (usesNotificationDot) {
+ badge =
+ destinationCount > 0 ? (
+ <span
+ data-slot="dot"
+ className={NOTIFICATION_DOT_CLASS}
+ aria-hidden
+ />
+ ) : null;
+ } else {
+ badge = (
+ <CountBadge
+ count={destinationCount}
+ tone={countTone}
+ className={ICON_BADGE_CLASS}
+ />
+ );
+ }
const onClick = pick(destination);
if (pane === "activity") {
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.ts
index b18b1b424a43..5ea2b333f612 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/activityPresentation.test.ts
+++ b/products/desktop/packages/ui/src/features/canvas/components/activityPresentation.test.ts
@@ -46,7 +46,7 @@ describe("activityPresentation", () => {
activityKind: "completed",
activityAt: "2026-07-26T16:00:00Z",
}),
- "18h ago · Agent completed",
+ "18h ago · Agent finished",
"check",
],
[
@@ -99,6 +99,7 @@ describe("activityPresentation", () => {
expect(activityPresentation(activity, "[email protected]")).toEqual({
metadata,
agentIcon,
+ spaceLabel: null,
});
});
@@ -106,15 +107,49 @@ describe("activityPresentation", () => {
[
"shared channel",
"engineering",
- "just now · Agent completed · #engineering",
+ "just now · Agent finished in",
+ "#engineering",
],
- ["personal channel", "personal", "just now · Agent completed · Personal"],
- ])("formats the %s label", (_name, channelName, metadata) => {
+ [
+ "personal channel",
+ "personal",
+ "just now · Agent finished in",
+ "Personal",
+ ],
+ ])("formats the %s label", (_name, channelName, metadata, spaceLabel) => {
expect(
activityPresentation(
item({ activityKind: "completed", channelName }),
- ).metadata,
- ).toBe(metadata);
+ ),
+ ).toMatchObject({ metadata, spaceLabel });
+ });
+
+ it("describes a created task with the space badge after the sentence", () => {
+ expect(
+ activityPresentation(
+ item({ activityKind: "created", channelName: "personal" }),
+ ),
+ ).toMatchObject({
+ metadata: "just now · You created task in:",
+ spaceLabel: "Personal",
+ });
+ });
+
+ it("avoids a duplicate preposition in thread reply metadata", () => {
+ expect(
+ activityPresentation(
+ item({
+ activityKind: "thread_reply",
+ author: AUTHOR,
+ channelName: "engineering",
+ }),
+ ),
+ ).toMatchObject({
+ metadata: "just now · Ann replied to a thread in",
+ spaceLabel: "#engineering",
+ });
});
});
diff --git a/products/desktop/packages/ui/src/features/canvas/components/activityPresentation.ts b/products/desktop/packages/ui/src/features/canvas/components/activityPresentation.ts
index 3878c8db0d62..f28166bfc4f8 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/activityPresentation.ts
+++ b/products/desktop/packages/ui/src/features/canvas/components/activityPresentation.ts
@@ -11,10 +11,12 @@ export type AgentActivityIconKind = "chat" | "check" | "question";
export interface ActivityPresentation {
agentIcon: AgentActivityIconKind | null;
metadata: string;
+ spaceLabel: string | null;
}
interface ActivityEventPresentation {
action: string;
+ actionInSpace: string;
agentIcon: AgentActivityIconKind | null;
}
@@ -37,38 +39,57 @@ function activityEventPresentation(
case "awaiting_input":
return {
action: "Agent is waiting for your reply",
+ actionInSpace: "Agent is waiting for your reply in",
agentIcon: "question",
};
case "completed":
- return { action: "Agent completed", agentIcon: "check" };
- case "message":
+ return {
+ action: "Agent finished",
+ actionInSpace: "Agent finished in",
+ agentIcon: "check",
+ };
+ case "message": {
if (!item.author) {
- return { action: "Agent replied", agentIcon: "chat" };
+ return {
+ action: "Agent replied",
+ actionInSpace: "Agent replied in",
+ agentIcon: "chat",
+ };
}
+ const replyAction =
+ item.author.email === currentUserEmail
+ ? "You replied"
+ : `${userDisplayName(item.author)} replied`;
return {
- action:
- item.author.email === currentUserEmail
- ? "You replied"
- : `${userDisplayName(item.author)} replied`,
+ action: replyAction,
+ actionInSpace: `${replyAction} in`,
agentIcon: null,
};
+ }
case "mention":
return {
action: `${userDisplayName(item.author)} mentioned you`,
+ actionInSpace: `${userDisplayName(item.author)} mentioned you in`,
agentIcon: null,
};
case "thread_reply":
return {
action: `${userDisplayName(item.author)} replied to a thread you participated in`,
+ actionInSpace: `${userDisplayName(item.author)} replied to a thread in`,
agentIcon: null,
};
case "owned_item_comment":
return {
action: `${userDisplayName(item.author)} commented on your ${ownedItemName(item)}`,
+ actionInSpace: `${userDisplayName(item.author)} commented on your ${ownedItemName(item)} in`,
agentIcon: null,
};
case "created":
- return { action: "You created", agentIcon: null };
+ return {
+ action: "You created",
+ actionInSpace: "You created task in:",
+ agentIcon: null,
+ };
default: {
const exhaustiveActivityKind: never = item.activityKind;
return exhaustiveActivityKind;
@@ -89,14 +110,11 @@ export function activityPresentation(
currentUserEmail?: string | null,
): ActivityPresentation {
const event = activityEventPresentation(item, currentUserEmail);
+ const spaceLabel = activitySpace(item.channelName);
+ const action = spaceLabel ? event.actionInSpace : event.action;
return {
agentIcon: event.agentIcon,
- metadata: [
- formatRelativeAge(item.activityAt),
- event.action,
- activitySpace(item.channelName),
- ]
- .filter((part): part is string => part !== null)
- .join(" · "),
+ metadata: [formatRelativeAge(item.activityAt), action].join(" · "),
+ spaceLabel,
};
}