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.

feat(desktop): add inbox reports to activity (#89110)

Adam Leith1811c09043f4
diff --git a/products/desktop/packages/core/src/inbox/engagement.test.ts b/products/desktop/packages/core/src/inbox/engagement.test.ts
index 2efa31dc8cd7..5d3da5a8e462 100644
--- a/products/desktop/packages/core/src/inbox/engagement.test.ts
+++ b/products/desktop/packages/core/src/inbox/engagement.test.ts
@@ -193,6 +193,17 @@ describe("buildInboxViewedProperties", () => {
expect(props.has_active_filters).toBe(false);
});
+
+ it("omits legacy tab counts for the sectioned reports inbox", () => {
+ const props = buildInboxViewedProperties({
+ visibleReports: [fakeReport()],
+ totalCount: 1,
+ filters: NO_FILTERS,
+ });
+
+ expect(props.pulls_tab_count).toBeUndefined();
+ expect(props.reports_tab_count).toBeUndefined();
+ });
});
describe("inboxDetailTabReports", () => {
diff --git a/products/desktop/packages/core/src/inbox/engagement.ts b/products/desktop/packages/core/src/inbox/engagement.ts
index b60fedbb284e..c23b86841391 100644
--- a/products/desktop/packages/core/src/inbox/engagement.ts
+++ b/products/desktop/packages/core/src/inbox/engagement.ts
@@ -214,7 +214,7 @@ export type BuildInboxViewedInput =
| (BuildInboxViewedInputBase & {
filters: DesktopInboxViewedFilterState;
/** Tab badge counts shown in the desktop header. */
- tabCounts: { pulls: number; reports: number };
+ tabCounts?: { pulls: number; reports: number };
})
| (BuildInboxViewedInputBase & {
filters: MobileInboxViewedFilterState;
@@ -233,7 +233,7 @@ export function buildInboxViewedProperties(
input: BuildInboxViewedInput,
): InboxViewedProperties {
const { visibleReports, totalCount, filters } = input;
- const tabCounts = input.tabCounts ?? { pulls: 0, reports: totalCount };
+ const tabCounts = input.tabCounts;
const priorityCounts = { P0: 0, P1: 0, P2: 0, P3: 0, P4: 0, unknown: 0 };
const actionabilityCounts = {
@@ -299,7 +299,11 @@ export function buildInboxViewedProperties(
actionabilityCounts.requires_human_input,
actionability_not_actionable_count: actionabilityCounts.not_actionable,
actionability_unknown_count: actionabilityCounts.unknown,
- pulls_tab_count: tabCounts.pulls,
- reports_tab_count: tabCounts.reports,
+ ...(tabCounts
+ ? {
+ pulls_tab_count: tabCounts.pulls,
+ reports_tab_count: tabCounts.reports,
+ }
+ : {}),
};
}
diff --git a/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsx b/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsx
index 905d418248c5..6863a0e98b6d 100644
--- a/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsx
+++ b/products/desktop/packages/ui/src/features/browser-tabs/BrowserTabStrip.tsx
@@ -22,6 +22,10 @@ import {
useDashboards,
} from "@posthog/ui/features/canvas/hooks/useDashboards";
import { useRailPane } from "@posthog/ui/features/canvas/hooks/useRailSurface";
+import {
+ activityReportIdFromHref,
+ useActivitySelection,
+} from "@posthog/ui/features/canvas/stores/activityDetailStore";
import {
applyTabViewState,
useChannelPaneStore,
@@ -29,6 +33,7 @@ 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 { useInboxReportById } from "@posthog/ui/features/inbox/hooks/useInboxReports";
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";
@@ -63,6 +68,7 @@ import { TabStrip, type TabView } from "./TabStrip";
import { TaskTabDot } from "./TaskTabMarks";
import {
isTabAppView,
+ resolveTabAppViewDisplay,
TAB_APP_VIEW_META,
type TabAppView,
} from "./tabAppViews";
@@ -165,6 +171,11 @@ export function BrowserTabStrip() {
const routeAppView: TabAppView | null = isTabAppView(view.type)
? view.type
: null;
+ const activitySelection = useActivitySelection();
+ const activeActivityReportId =
+ routeAppView === "activity" && activitySelection?.kind === "report"
+ ? activitySelection.reportId
+ : null;
const { channels, isLoading: channelsLoading } = useChannels();
// The scoped space is null until the channel list has loaded and the route
@@ -240,6 +251,9 @@ export function BrowserTabStrip() {
...taskDetailQuery(activeSession.taskId ?? ""),
enabled: !!activeSession.taskId,
});
+ const { data: activeReportRecord } = useInboxReportById(
+ activeActivityReportId,
+ );
// Remember names so a background tab from another channel keeps its label
// after its channel's list unloads. Written in an effect (not during render)
// to keep render pure; the tabs memo reads the live lists first anyway.
@@ -273,13 +287,19 @@ export function BrowserTabStrip() {
if (activeRecord?.id === params.dashboardId) return activeRecord.name;
return dashboards.find((d) => d.id === params.dashboardId)?.name ?? null;
}
+ if (activeActivityReportId) {
+ if (activeReportRecord?.id !== activeActivityReportId) return null;
+ return activeReportRecord.title?.trim() || "Untitled report";
+ }
return null;
}, [
activeSession.taskId,
params.dashboardId,
+ activeActivityReportId,
activeTaskRecord,
allTasks,
activeRecord,
+ activeReportRecord,
dashboards,
]);
@@ -291,12 +311,16 @@ export function BrowserTabStrip() {
const channel = channelName(currentChannelId);
return channelSectionFor(routeChannelSection)?.label ?? channel;
}
+ // A selected Activity report owns the tab label. While its query resolves,
+ // keep the tab's stored title instead of replacing it with "Activity".
+ if (activeActivityReportId) return null;
if (routeAppView) return TAB_APP_VIEW_META[routeAppView].label;
return null;
}, [
activeTitle,
params.channelId,
activeSession.channelId,
+ activeActivityReportId,
channelName,
routeChannelSection,
routeAppView,
@@ -554,6 +578,29 @@ export function BrowserTabStrip() {
pinned,
};
}
+ // A top-level app page (Inbox, Agents, Skills, …).
+ // Resolve this before channel state: when navigation crosses from a
+ // space to Activity, persisted channel context must not turn the new
+ // top-level tab into a space tab.
+ if (appView && isTabAppView(appView)) {
+ const activityReportId = isActive
+ ? activeActivityReportId
+ : activityReportIdFromHref(t.href);
+ const activityReport = activityReportId
+ ? {
+ title: isActive
+ ? (activeTitle ?? t.viewState?.title)
+ : t.viewState?.title,
+ }
+ : null;
+ const display = resolveTabAppViewDisplay(appView, activityReport);
+ return {
+ id: t.id,
+ ...display,
+ channelName: null,
+ pinned,
+ };
+ }
// A channel tab: a sub-section (Recents/CONTEXT.md/…) or the channel home.
// The section drives the label; the channel name carries the space
// context. Home has no section, so it labels by the channel name.
@@ -576,16 +623,6 @@ export function BrowserTabStrip() {
pinned,
};
}
- // A top-level app page (Inbox, Agents, Skills, …).
- if (appView && isTabAppView(appView)) {
- return {
- id: t.id,
- label: TAB_APP_VIEW_META[appView].label,
- icon: TAB_APP_VIEW_META[appView].icon,
- channelName: null,
- pinned,
- };
- }
return {
id: t.id,
label: t.viewState?.title ?? "New tab",
@@ -608,6 +645,8 @@ export function BrowserTabStrip() {
params.dashboardId,
activeSession.taskId,
activeSession.channelId,
+ activeActivityReportId,
+ activeTitle,
routeChannelSection,
routeAppView,
spacesLayout,
diff --git a/products/desktop/packages/ui/src/features/browser-tabs/tabAppViews.test.tsx b/products/desktop/packages/ui/src/features/browser-tabs/tabAppViews.test.tsx
new file mode 100644
index 000000000000..b6a3a7aa7aa4
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/browser-tabs/tabAppViews.test.tsx
@@ -0,0 +1,25 @@
+import { EnvelopeSimple } from "@phosphor-icons/react";
+import { isValidElement } from "react";
+import { describe, expect, it } from "vitest";
+import { resolveTabAppViewDisplay } from "./tabAppViews";
+
+describe("resolveTabAppViewDisplay", () => {
+ it("shows the report title and rail mail icon for an Activity report", () => {
+ const display = resolveTabAppViewDisplay("activity", {
+ title: "Checkout errors increased",
+ });
+
+ expect(display.label).toBe("Checkout errors increased");
+ expect(isValidElement(display.icon)).toBe(true);
+ if (!isValidElement(display.icon)) return;
+ expect(display.icon.type).toBe(EnvelopeSimple);
+ });
+
+ it("keeps static labels for top-level destinations", () => {
+ expect(resolveTabAppViewDisplay("activity", null).label).toBe("Activity");
+ expect(
+ resolveTabAppViewDisplay("inbox", { title: "Ignored report title" })
+ .label,
+ ).toBe("Self-driving");
+ });
+});
diff --git a/products/desktop/packages/ui/src/features/browser-tabs/tabAppViews.tsx b/products/desktop/packages/ui/src/features/browser-tabs/tabAppViews.tsx
index cbb8e5b3a040..42de74b23c95 100644
--- a/products/desktop/packages/ui/src/features/browser-tabs/tabAppViews.tsx
+++ b/products/desktop/packages/ui/src/features/browser-tabs/tabAppViews.tsx
@@ -3,6 +3,7 @@ import {
BellIcon,
BookOpenTextIcon,
BrainIcon,
+ EnvelopeSimple,
GearIcon,
PlugsConnectedIcon,
RepeatIcon,
@@ -57,3 +58,20 @@ export const TAB_APP_VIEW_META: Record<
export function isTabAppView(value: string): value is TabAppView {
return Object.hasOwn(TAB_APP_VIEW_META, value);
}
+
+interface ActivityReportTabContext {
+ title: string | null | undefined;
+}
+
+export function resolveTabAppViewDisplay(
+ appView: TabAppView,
+ activityReport: ActivityReportTabContext | null,
+): { label: string; icon: ReactNode } {
+ if (appView === "activity" && activityReport) {
+ return {
+ label: activityReport.title?.trim() || TAB_APP_VIEW_META.activity.label,
+ icon: <EnvelopeSimple size={14} />,
+ };
+ }
+ return TAB_APP_VIEW_META[appView];
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/AGENTS.md b/products/desktop/packages/ui/src/features/canvas/AGENTS.md
index f612fd53e123..7990eed2033e 100644
--- a/products/desktop/packages/ui/src/features/canvas/AGENTS.md
+++ b/products/desktop/packages/ui/src/features/canvas/AGENTS.md
@@ -204,12 +204,16 @@ changing breadcrumbs, canvas naming, or the canvas generation harness. The root
tree scrolls rows under a stationary cursor, so prefetching straight from
`pointerenter` fired a request for every row the list passed and made each
keypress take a second.
-- **Keyboard contract of the list.** The search box holds focus and drives
- everything: ↑/↓ walk every visible row, → opens the highlighted space (and
+- **Keyboard contract of the list.** `SidebarSearchHeader` gives Spaces and
+ Activity the same title and search treatment. Its shared focus request means
+ ⌘⇧S opens the sidebar and focuses whichever search is visible. Both lists
+ are permanently open inline Autocompletes: the search box keeps focus while
+ ↑/↓ walk every visible row and Enter opens it. In Spaces, the input also
+ drives the tree: → opens the highlighted space (and
again steps into it), ← closes the space you're in and puts the highlight back
on it. Both arrows defer to the text caret first, so they still edit the
- query. ⌘⇧S from anywhere opens the sidebar, slides back to the list and takes
- the keyboard; it is advertised on the search box (until a query replaces it
+ query. From elsewhere, ⌘⇧S slides Spaces back to the list and takes the
+ keyboard; it is advertised on the search box (until a query replaces it
with the clear button) and on the space's back row, which is what it does from
inside a space. Autocomplete has no API for setting the highlight, so moving it
means synthesizing the arrow keys it listens for — and moving *before*
@@ -219,6 +223,18 @@ changing breadcrumbs, canvas naming, or the canvas generation harness. The root
instead. Off the layout it keeps its original two-item menu.
Archived moves out of the sidebar and into the account menu
(`ProjectSwitcher`), beside Settings.
+- **Activity mixes task updates with a bounded Self-driving preview.** Both
+ `ActivityFeedList` and `ActivityView` merge their task activity with up to
+ three reports matching Activity's persisted Inbox filters, then sort and group
+ the combined rows by activity time. The Activity actions menu has an Include
+ section: Mentions are on by default and Self-driving is off. Enabling
+ Self-driving reveals its P1/For you defaults plus scope, source, PR state,
+ sort, and priority filters without changing the Inbox page's filters. Inbox
+ reports do not have the task activity read model, so the unreads-only view
+ hides them. If more than three match, the overflow row copies Activity's Inbox
+ filters into `/inbox/reports` before opening it.
+ Picking a preview report stays on `/activity` and renders that already-loaded
+ report beside the feed while its detail query refreshes in the background.
- **Which pane shows is view state, not a route.** `channelPaneStore` holds it,
separately from the scoped channel (`currentChannelStore`): "back to channels"
browses the list while the route, the main pane and the scoped channel stay
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityActionsMenu.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityActionsMenu.tsx
index 075330c6fae4..a7a7dd58d02e 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityActionsMenu.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityActionsMenu.tsx
@@ -4,8 +4,10 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
+ DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@posthog/quill";
+import { ActivityIncludeMenuSection } from "@posthog/ui/features/canvas/components/ActivityIncludeMenuSection";
import { markLoadedReadLabel } from "@posthog/ui/features/canvas/components/activityFeed";
import type { ReactElement } from "react";
@@ -42,7 +44,7 @@ export function ActivityActionsMenu({
align="end"
side="bottom"
sideOffset={4}
- className="w-max"
+ className="min-w-64"
>
<DropdownMenuItem
disabled={isMarkingRead || loadedUnreadCount === 0}
@@ -51,6 +53,9 @@ export function ActivityActionsMenu({
<ChecksIcon size={14} />
{markLoadedReadLabel(loadedUnreadCount, totalUnreadCount)}
</DropdownMenuItem>
+
+ <DropdownMenuSeparator />
+ <ActivityIncludeMenuSection />
</DropdownMenuContent>
</DropdownMenu>
);
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailPane.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailPane.test.tsx
new file mode 100644
index 000000000000..6f5dbb223052
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailPane.test.tsx
@@ -0,0 +1,72 @@
+import type { SignalReport } from "@posthog/shared/types";
+import { render, screen } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const mocks = vi.hoisted(() => ({
+ reports: [] as SignalReport[],
+ selection: null as { kind: "report"; id: string; reportId: string } | null,
+}));
+
+vi.mock("@posthog/ui/features/canvas/hooks/useChannels", () => ({
+ useChannels: () => ({ channels: [] }),
+}));
+vi.mock("@posthog/ui/features/canvas/hooks/useInboxActivityPreview", () => ({
+ useInboxActivityPreview: () => ({ reports: mocks.reports }),
+}));
+vi.mock("@posthog/ui/features/canvas/stores/activityDetailStore", () => ({
+ useActivitySelection: () => mocks.selection,
+}));
+vi.mock("@posthog/ui/features/tasks/useResolvedTask", () => ({
+ useResolvedTask: () => undefined,
+}));
+vi.mock("@posthog/ui/features/task-detail/components/TaskDetail", () => ({
+ TaskDetail: () => <div>Task detail</div>,
+}));
+vi.mock("@posthog/ui/router/routeSkeletons", () => ({
+ TaskDetailSkeleton: () => <div>Task loading</div>,
+}));
+vi.mock("@posthog/ui/features/inbox/components/ReportDetail", () => ({
+ ReportDetail: ({
+ reportId,
+ cachedReport,
+ statusRedirect,
+ }: {
+ reportId: string;
+ cachedReport?: SignalReport;
+ statusRedirect?: boolean;
+ }) => (
+ <div data-testid="report-detail">
+ {reportId}:{cachedReport?.title}:
+ {statusRedirect === false ? "instant" : "loading"}
+ </div>
+ ),
+}));
+
+import { ActivityDetailPane } from "./ActivityDetailPane";
+
+describe("ActivityDetailPane", () => {
+ beforeEach(() => {
+ mocks.reports = [];
+ mocks.selection = null;
+ });
+
+ it("renders a selected feed report immediately from the preview data", () => {
+ mocks.selection = {
+ kind: "report",
+ id: "report-1",
+ reportId: "report-1",
+ };
+ mocks.reports = [
+ {
+ id: "report-1",
+ title: "Checkout conversion dropped",
+ } as SignalReport,
+ ];
+
+ render(<ActivityDetailPane />);
+
+ expect(screen.getByTestId("report-detail")).toHaveTextContent(
+ "report-1:Checkout conversion dropped:instant",
+ );
+ });
+});
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailPane.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailPane.tsx
index a4d48985ce30..43c6ecc412db 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailPane.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailPane.tsx
@@ -7,7 +7,9 @@ import {
EmptyTitle,
} from "@posthog/quill";
import { useChannels } from "@posthog/ui/features/canvas/hooks/useChannels";
+import { useInboxActivityPreview } from "@posthog/ui/features/canvas/hooks/useInboxActivityPreview";
import { useActivitySelection } from "@posthog/ui/features/canvas/stores/activityDetailStore";
+import { ReportDetail } from "@posthog/ui/features/inbox/components/ReportDetail";
import { TaskDetail } from "@posthog/ui/features/task-detail/components/TaskDetail";
import { useResolvedTask } from "@posthog/ui/features/tasks/useResolvedTask";
import { TaskDetailSkeleton } from "@posthog/ui/router/routeSkeletons";
@@ -15,8 +17,11 @@ import { TaskDetailSkeleton } from "@posthog/ui/router/routeSkeletons";
/** What the Activity destination shows beside its feed. */
export function ActivityDetailPane() {
const selected = useActivitySelection();
- const task = useResolvedTask(selected?.taskId);
+ const selectedTaskId =
+ selected?.kind === "task" ? selected.taskId : undefined;
+ const task = useResolvedTask(selectedTaskId);
const { channels } = useChannels();
+ const { reports } = useInboxActivityPreview();
if (!selected) {
return (
@@ -36,6 +41,23 @@ export function ActivityDetailPane() {
);
}
+ if (selected.kind === "report") {
+ const cachedReport = reports.find(
+ (report) => report.id === selected.reportId,
+ );
+ return (
+ <div className="h-full min-w-0">
+ <ReportDetail
+ reportId={selected.reportId}
+ cachedReport={cachedReport}
+ backTo="/activity"
+ backLabel="Back to activity"
+ statusRedirect={false}
+ />
+ </div>
+ );
+ }
+
if (!task) return <TaskDetailSkeleton />;
const { channelId } = selected;
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.tsx
index 6a2d12be7f77..a21d3f4b8549 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,5 +1,7 @@
import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";
+import type { SignalReport } from "@posthog/shared/types";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
import type { ReactElement, ReactNode } from "react";
import { beforeEach, describe, expect, it, vi } from "vitest";
@@ -9,10 +11,14 @@ const mocks = vi.hoisted(() => ({
isFetchingNextPage: false,
items: [] as TaskActivityItem[],
markRead: vi.fn(),
+ inboxReportCount: 0,
+ inboxReports: [] as SignalReport[],
+ reportOpened: vi.fn(),
unreadCount: 0,
}));
-vi.mock("@posthog/quill", () => ({
+vi.mock("@posthog/quill", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("@posthog/quill")>()),
cn: (...args: unknown[]) => args.filter(Boolean).join(" "),
Button: ({
children,
@@ -90,19 +96,112 @@ vi.mock("@posthog/ui/features/auth/authClient", () => ({
vi.mock("@posthog/ui/features/auth/useCurrentUser", () => ({
useCurrentUser: () => ({ data: null }),
}));
-vi.mock("@posthog/ui/features/canvas/components/ActivityRow", () => ({
- ActivityRow: ({
- item,
- onMarkRead,
- }: {
- item: TaskActivityItem;
- onMarkRead: (item: TaskActivityItem) => void;
- }) => (
- <button type="button" onClick={() => onMarkRead(item)}>
- Activity row
- </button>
+vi.mock("@posthog/ui/features/canvas/components/ActivityActionsMenu", () => ({
+ ActivityActionsMenu: ({ onMarkAllRead }: { onMarkAllRead: () => void }) => (
+ <>
+ <button type="button" aria-label="Activity actions" />
+ <button type="button" onClick={onMarkAllRead}>
+ Mark all as read
+ </button>
+ </>
),
}));
+vi.mock("@posthog/ui/features/canvas/components/ActivityRow", async () => {
+ const { ActivityRowSurface } = await import(
+ "@posthog/ui/features/canvas/components/ActivityRowSurface"
+ );
+ return {
+ ActivityRow: ({
+ item,
+ onMarkRead,
+ onActivate,
+ asOption,
+ optionValue,
+ }: {
+ item: TaskActivityItem;
+ onMarkRead: (item: TaskActivityItem) => void;
+ onActivate: (item: TaskActivityItem) => void;
+ asOption?: boolean;
+ optionValue?: string;
+ }) => (
+ <ActivityRowSurface
+ asOption={asOption}
+ optionValue={optionValue}
+ onClick={() => {
+ onMarkRead(item);
+ onActivate(item);
+ }}
+ >
+ <span>Activity row</span>
+ <span>{item.taskTitle}</span>
+ </ActivityRowSurface>
+ ),
+ };
+});
+vi.mock(
+ "@posthog/ui/features/canvas/components/InboxActivityOverflowRow",
+ async () => {
+ const { ActivityRowSurface } = await import(
+ "@posthog/ui/features/canvas/components/ActivityRowSurface"
+ );
+ return {
+ InboxActivityOverflowRow: ({
+ count,
+ onOpened,
+ asOption,
+ optionValue,
+ }: {
+ count: number;
+ onOpened?: () => void;
+ asOption?: boolean;
+ optionValue?: string;
+ }) => (
+ <ActivityRowSurface
+ asOption={asOption}
+ optionValue={optionValue}
+ onClick={onOpened}
+ >
+ View {count} more reports
+ </ActivityRowSurface>
+ ),
+ };
+ },
+);
+vi.mock("@posthog/ui/features/canvas/components/InboxActivityRow", async () => {
+ const { ActivityRowSurface } = await import(
+ "@posthog/ui/features/canvas/components/ActivityRowSurface"
+ );
+ return {
+ InboxActivityRow: ({
+ report,
+ onOpened,
+ asOption,
+ optionValue,
+ onActivate,
+ }: {
+ report: SignalReport;
+ onOpened?: () => void;
+ asOption?: boolean;
+ optionValue?: string;
+ onActivate?: (report: SignalReport) => void;
+ }) => (
+ <ActivityRowSurface
+ asOption={asOption}
+ optionValue={optionValue}
+ onClick={() => {
+ if (onActivate) {
+ onActivate(report);
+ } else {
+ mocks.reportOpened();
+ }
+ onOpened?.();
+ }}
+ >
+ Report row {report.id}
+ </ActivityRowSurface>
+ ),
+ };
+});
vi.mock("@posthog/ui/features/canvas/hooks/useChannels", () => ({
useChannels: () => ({ channels: [] }),
}));
@@ -125,6 +224,17 @@ vi.mock("@posthog/ui/features/canvas/hooks/useTaskActivity", () => ({
fetchNextPage: mocks.fetchNextPage,
}),
}));
+vi.mock("@posthog/ui/features/canvas/hooks/useInboxActivityPreview", () => ({
+ useInboxActivityPreview: () => ({
+ reports: mocks.inboxReports,
+ totalCount: mocks.inboxReportCount,
+ isLoading: false,
+ isIncluded: true,
+ }),
+}));
+vi.mock("@posthog/ui/features/inbox/hooks/useInboxSourceFilterOptions", () => ({
+ useInboxSourceFilterOptions: () => [],
+}));
vi.mock("@posthog/ui/primitives/hooks/useInView", () => ({
useInView: () => [vi.fn(), true],
}));
@@ -139,8 +249,13 @@ describe("ActivityFeedList", () => {
mocks.hasNextPage = true;
mocks.isFetchingNextPage = false;
mocks.items = [];
+ mocks.inboxReportCount = 0;
+ mocks.inboxReports = [];
mocks.unreadCount = 0;
- useActivityFilterStore.setState({ unreadsOnly: false });
+ useActivityFilterStore.setState({
+ unreadsOnly: false,
+ mentionsEnabled: true,
+ });
});
it("loads the next page when the bottom sentinel is visible", async () => {
@@ -228,13 +343,168 @@ describe("ActivityFeedList", () => {
isUnread: true,
} as TaskActivityItem,
];
+ mocks.inboxReportCount = 1;
+ mocks.inboxReports = [
+ {
+ id: "report-1",
+ updated_at: "2026-08-07T00:02:00Z",
+ } as SignalReport,
+ ];
render(<ActivityFeedList />);
expect(screen.getAllByText("Activity row")).toHaveLength(2);
+ expect(screen.getByText("Report row report-1")).toBeInTheDocument();
fireEvent.click(screen.getByRole("switch"));
expect(screen.getAllByText("Activity row")).toHaveLength(1);
+ expect(screen.queryByText("Report row report-1")).toBeNull();
+ });
+
+ it("hides task activity when mentions are excluded", () => {
+ useActivityFilterStore.setState({ mentionsEnabled: false });
+ mocks.items = [
+ {
+ id: "mention-1",
+ taskId: "task-1",
+ activityAt: "2026-08-07T00:00:00Z",
+ activityKind: "mention",
+ isUnread: true,
+ } as TaskActivityItem,
+ ];
+ mocks.inboxReportCount = 1;
+ mocks.inboxReports = [
+ {
+ id: "report-1",
+ updated_at: "2026-08-07T00:01:00Z",
+ } as SignalReport,
+ ];
+
+ render(<ActivityFeedList />);
+
+ expect(screen.queryByText("Activity row")).toBeNull();
+ expect(screen.getByText("Report row report-1")).toBeInTheDocument();
+ expect(mocks.fetchNextPage).not.toHaveBeenCalled();
+ });
+
+ it("interleaves the inbox preview by date and links to the remaining reports", () => {
+ mocks.hasNextPage = false;
+ mocks.items = [
+ {
+ id: "task-1",
+ taskId: "task-1",
+ activityAt: new Date(2026, 7, 25, 9).toISOString(),
+ activityKind: "completed",
+ isUnread: false,
+ } as TaskActivityItem,
+ ];
+ mocks.inboxReportCount = 5;
+ mocks.inboxReports = [
+ {
+ id: "report-newer",
+ updated_at: new Date(2026, 7, 25, 10).toISOString(),
+ } as SignalReport,
+ {
+ id: "report-older",
+ updated_at: new Date(2026, 7, 25, 8).toISOString(),
+ } as SignalReport,
+ ];
+
+ render(<ActivityFeedList />);
+
+ const newerReport = screen.getByText("Report row report-newer");
+ const task = screen.getByText("Activity row");
+ const olderReport = screen.getByText("Report row report-older");
+ expect(newerReport.compareDocumentPosition(task)).toBe(
+ Node.DOCUMENT_POSITION_FOLLOWING,
+ );
+ expect(task.compareDocumentPosition(olderReport)).toBe(
+ Node.DOCUMENT_POSITION_FOLLOWING,
+ );
+ expect(screen.getByText("View 3 more reports")).toBeInTheDocument();
+ });
+
+ it("filters tasks and reports from the activity search", () => {
+ mocks.hasNextPage = false;
+ mocks.items = [
+ {
+ id: "task-billing",
+ taskId: "task-billing",
+ taskTitle: "Fix billing dashboard",
+ channelName: "growth",
+ activityAt: "2026-08-25T10:00:00Z",
+ activityKind: "completed",
+ isUnread: false,
+ } as TaskActivityItem,
+ {
+ id: "task-onboarding",
+ taskId: "task-onboarding",
+ taskTitle: "Update onboarding",
+ channelName: "product",
+ activityAt: "2026-08-25T09:00:00Z",
+ activityKind: "completed",
+ isUnread: false,
+ } as TaskActivityItem,
+ ];
+ mocks.inboxReportCount = 1;
+ mocks.inboxReports = [
+ {
+ id: "report-checkout",
+ title: "Checkout conversion dropped",
+ updated_at: "2026-08-25T11:00:00Z",
+ } as SignalReport,
+ ];
+
+ render(<ActivityFeedList />);
+ fireEvent.change(screen.getByLabelText("Search activity"), {
+ target: { value: "billing" },
+ });
+
+ expect(screen.getByText("Fix billing dashboard")).toBeInTheDocument();
+ expect(screen.queryByText("Update onboarding")).toBeNull();
+ expect(screen.queryByText("Report row report-checkout")).toBeNull();
+ });
+
+ it("walks every activity row from the search input and opens the highlighted row", async () => {
+ const user = userEvent.setup();
+ const onActivate = vi.fn();
+ const onReportActivate = vi.fn();
+ const onOpened = vi.fn();
+ mocks.hasNextPage = false;
+ mocks.items = [
+ {
+ id: "task-keyboard",
+ taskId: "task-keyboard",
+ taskTitle: "Keyboard task",
+ activityAt: "2026-08-25T10:00:00Z",
+ activityKind: "completed",
+ isUnread: false,
+ } as TaskActivityItem,
+ ];
+ mocks.inboxReportCount = 2;
+ mocks.inboxReports = [
+ {
+ id: "report-keyboard",
+ title: "Keyboard report",
+ updated_at: "2026-08-25T09:00:00Z",
+ } as SignalReport,
+ ];
+
+ render(
+ <ActivityFeedList
+ onActivate={onActivate}
+ onReportActivate={onReportActivate}
+ onOpened={onOpened}
+ />,
+ );
+
+ expect(screen.getAllByRole("option")).toHaveLength(3);
+ await user.click(screen.getByLabelText("Search activity"));
+ await user.keyboard("{ArrowDown}{ArrowDown}{Enter}");
+
+ expect(onActivate).not.toHaveBeenCalled();
+ expect(onReportActivate).toHaveBeenCalledWith(mocks.inboxReports[0]);
+ expect(mocks.reportOpened).not.toHaveBeenCalled();
});
it("groups the panel rows by local calendar day", () => {
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityFeedList.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityFeedList.tsx
index 6c14ac0aeaa8..3484226b1c86 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityFeedList.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityFeedList.tsx
@@ -1,6 +1,8 @@
import { BellIcon } from "@phosphor-icons/react";
import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";
import {
+ Autocomplete,
+ AutocompleteList,
cn,
Empty,
EmptyDescription,
@@ -11,13 +13,18 @@ import {
Spinner,
} from "@posthog/quill";
import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";
+import type { SignalReport } from "@posthog/shared/types";
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 { InboxActivityOverflowRow } from "@posthog/ui/features/canvas/components/InboxActivityOverflowRow";
+import { InboxActivityRow } from "@posthog/ui/features/canvas/components/InboxActivityRow";
import { openActivityItem } from "@posthog/ui/features/canvas/components/openActivityItem";
+import { SidebarSearchHeader } from "@posthog/ui/features/canvas/components/SidebarSearchHeader";
import { useBlockedTaskIds } from "@posthog/ui/features/canvas/hooks/useBlockedSessionCount";
+import { useInboxActivityPreview } from "@posthog/ui/features/canvas/hooks/useInboxActivityPreview";
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";
@@ -26,13 +33,16 @@ import { useInView } from "@posthog/ui/primitives/hooks/useInView";
import { track } from "@posthog/ui/shell/analytics";
import { Fragment, useEffect, useMemo, useState } from "react";
import {
+ activityFeedSourceDescription,
activityReadPayload,
- getUnreadActivityItems,
+ deriveActivityFeedContent,
+ filterActivityFeedItems,
groupActivityItemsByDay,
} from "./activityFeed";
interface ActivityFeedListProps {
onActivate?: (item: TaskActivityItem) => void;
+ onReportActivate?: (report: SignalReport) => void;
onOpened?: () => void;
selectedId?: string;
className?: string;
@@ -42,35 +52,78 @@ interface ActivityFeedListProps {
* code layout's hover card. */
export function ActivityFeedList({
onActivate = openActivityItem,
+ onReportActivate,
onOpened,
selectedId,
className,
}: ActivityFeedListProps) {
+ const mentionsIncluded = useActivityFilterStore(
+ (state) => state.mentionsEnabled,
+ );
+ const unreadsOnly = useActivityFilterStore((state) => state.unreadsOnly);
const client = useOptionalAuthenticatedClient();
- const { data: currentUser } = useCurrentUser({ client });
+ const { data: currentUser } = useCurrentUser({
+ client,
+ enabled: mentionsIncluded,
+ });
+ const taskActivity = useTaskActivity({ enabled: mentionsIncluded });
+ const inboxActivity = useInboxActivityPreview();
const {
- items,
- unreadCount,
- isLoading,
- hasNextPage,
- isFetchingNextPage,
- fetchNextPage,
- } = useTaskActivity();
+ unreadItems,
+ feedItems,
+ lastShownReportId,
+ remainingInboxReportCount,
+ selfDrivingIncluded,
+ } = useMemo(
+ () =>
+ deriveActivityFeedContent({
+ taskItems: taskActivity.items,
+ reports: inboxActivity.reports,
+ totalReportCount: inboxActivity.totalCount,
+ mentionsIncluded,
+ reportsIncluded: inboxActivity.isIncluded,
+ unreadsOnly,
+ }),
+ [
+ taskActivity.items,
+ inboxActivity.reports,
+ inboxActivity.totalCount,
+ inboxActivity.isIncluded,
+ mentionsIncluded,
+ unreadsOnly,
+ ],
+ );
+ const unreadCount = mentionsIncluded ? taskActivity.unreadCount : 0;
+ const isLoading =
+ (mentionsIncluded && taskActivity.isLoading) ||
+ (!unreadsOnly && inboxActivity.isLoading);
// Selected once for the feed, not once per row.
const blockedTaskIds = useBlockedTaskIds();
const [scrollRoot, setScrollRoot] = useState<HTMLDivElement | null>(null);
+ const [query, setQuery] = useState("");
const [loadMoreRef, loadMoreInView] = useInView<HTMLDivElement>({
root: scrollRoot,
rootMargin: "100px 0px",
});
- const unreadsOnly = useActivityFilterStore((state) => state.unreadsOnly);
- const unreadItems = getUnreadActivityItems(items);
- const shownItems = unreadsOnly ? unreadItems : items;
+ const searchedFeedItems = useMemo(
+ () => filterActivityFeedItems(feedItems, query),
+ [feedItems, query],
+ );
+ const isSearching = query.trim() !== "";
const dayStart = useLocalDayStart();
const shownItemGroups = useMemo(
- () => groupActivityItemsByDay(shownItems, new Date(dayStart)),
- [shownItems, dayStart],
+ () => groupActivityItemsByDay(searchedFeedItems, new Date(dayStart)),
+ [searchedFeedItems, dayStart],
);
+ const overflowOptionValue = "activity:remaining-inbox-reports";
+ const optionValues = searchedFeedItems.flatMap((item) => [
+ item.id,
+ ...(item.kind === "report" &&
+ item.report.id === lastShownReportId &&
+ remainingInboxReportCount > 0
+ ? [overflowOptionValue]
+ : []),
+ ]);
const { mutate: markTasksRead, isPending: isMarkingRead } =
useMarkTaskActivityRead();
useEffect(() => {
@@ -80,12 +133,17 @@ export function ActivityFeedList({
});
}, []);
useEffect(() => {
- if (loadMoreInView && hasNextPage) {
- void fetchNextPage();
+ if (mentionsIncluded && loadMoreInView && taskActivity.hasNextPage) {
+ void taskActivity.fetchNextPage();
}
- }, [fetchNextPage, hasNextPage, loadMoreInView]);
+ }, [
+ mentionsIncluded,
+ taskActivity.fetchNextPage,
+ taskActivity.hasNextPage,
+ loadMoreInView,
+ ]);
- const markRead = (item: (typeof items)[number]) => {
+ const markRead = (item: (typeof taskActivity.items)[number]) => {
markTasksRead(activityReadPayload([item]));
};
@@ -94,72 +152,130 @@ export function ActivityFeedList({
};
return (
- <div className={cn("flex min-h-0 flex-col", className)}>
- <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">
- <ActivityUnreadsToggle />
- <ActivityActionsMenu
- loadedUnreadCount={unreadItems.length}
- totalUnreadCount={unreadCount}
- isMarkingRead={isMarkingRead}
- onMarkAllRead={markAllRead}
- />
- </div>
- </div>
- <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 />
- </div>
- ) : shownItems.length === 0 ? (
- <Empty className="border-0 py-8">
- <EmptyHeader>
- <EmptyMedia variant="icon">
- <BellIcon />
- </EmptyMedia>
- <EmptyTitle>
- {unreadsOnly ? "No unread activity" : "No recent activity"}
- </EmptyTitle>
- <EmptyDescription>
- {unreadsOnly
- ? "You're all caught up."
- : "New task updates will appear here."}
- </EmptyDescription>
- </EmptyHeader>
- </Empty>
- ) : (
- <div className="flex flex-col gap-px">
- {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>
- ))}
+ <Autocomplete<string>
+ inline
+ open
+ value={query}
+ items={optionValues}
+ filter={null}
+ onValueChange={(value, eventDetails) => {
+ if (
+ eventDetails.reason === "input-change" &&
+ typeof value === "string"
+ ) {
+ setQuery(value);
+ }
+ }}
+ >
+ <div className={cn("flex min-h-0 flex-col", className)}>
+ <SidebarSearchHeader
+ title="Activity"
+ query={query}
+ placeholder="Search activity…"
+ searchLabel="Search activity"
+ onClear={() => setQuery("")}
+ actions={
+ <>
+ <ActivityUnreadsToggle />
+ <ActivityActionsMenu
+ loadedUnreadCount={unreadItems.length}
+ totalUnreadCount={unreadCount}
+ isMarkingRead={isMarkingRead}
+ onMarkAllRead={markAllRead}
+ />
+ </>
+ }
+ />
+ <AutocompleteList
+ ref={setScrollRoot}
+ className="scroll-mask-8 !max-h-none !p-1.5 min-h-0 flex-1 overflow-y-auto"
+ >
+ {isLoading && feedItems.length === 0 ? (
+ <div className="flex justify-center py-10">
+ <Spinner />
+ </div>
+ ) : searchedFeedItems.length === 0 ? (
+ <Empty className="border-0 py-8">
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ <BellIcon />
+ </EmptyMedia>
+ <EmptyTitle>
+ {isSearching
+ ? "No matching activity"
+ : unreadsOnly
+ ? "No unread activity"
+ : "No recent activity"}
+ </EmptyTitle>
+ <EmptyDescription>
+ {isSearching
+ ? "Try a different search."
+ : unreadsOnly
+ ? "You're all caught up."
+ : activityFeedSourceDescription(
+ mentionsIncluded,
+ selfDrivingIncluded,
+ )}
+ </EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ ) : (
+ <div className="flex flex-col gap-px">
+ {shownItemGroups.map((group) => (
+ <Fragment key={group.key}>
+ <MenuLabel>{group.label}</MenuLabel>
+ {group.items.map((item) => (
+ <Fragment key={item.id}>
+ {item.kind === "task" ? (
+ <ActivityRow
+ item={item.task}
+ onMarkRead={markRead}
+ currentUser={currentUser}
+ blockedTaskIds={blockedTaskIds}
+ surface="activity_panel"
+ onActivate={(activated) => {
+ onActivate(activated);
+ onOpened?.();
+ }}
+ isSelected={item.task.id === selectedId}
+ compact
+ asOption
+ optionValue={item.id}
+ />
+ ) : (
+ <InboxActivityRow
+ report={item.report}
+ onOpened={onOpened}
+ compact
+ asOption
+ optionValue={item.id}
+ onActivate={onReportActivate}
+ isSelected={item.report.id === selectedId}
+ />
+ )}
+ {item.kind === "report" &&
+ item.report.id === lastShownReportId &&
+ remainingInboxReportCount > 0 && (
+ <InboxActivityOverflowRow
+ count={remainingInboxReportCount}
+ onOpened={onOpened}
+ asOption
+ optionValue={overflowOptionValue}
+ />
+ )}
+ </Fragment>
+ ))}
+ </Fragment>
+ ))}
+ </div>
+ )}
+ <div ref={loadMoreRef} className="flex h-8 justify-center py-2">
+ {mentionsIncluded &&
+ taskActivity.hasNextPage &&
+ taskActivity.isFetchingNextPage && <Spinner />}
</div>
- )}
- <div ref={loadMoreRef} className="flex h-8 justify-center py-2">
- {hasNextPage && isFetchingNextPage && <Spinner />}
- </div>
+ </AutocompleteList>
</div>
- </div>
+ </Autocomplete>
);
}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityIncludeMenuSection.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityIncludeMenuSection.tsx
new file mode 100644
index 000000000000..bfa8860e8c65
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityIncludeMenuSection.tsx
@@ -0,0 +1,309 @@
+import { getAuthIdentity } from "@posthog/core/auth/authIdentity";
+import {
+ cn,
+ DropdownMenuCheckboxItem,
+ DropdownMenuRadioGroup,
+ DropdownMenuRadioItem,
+ DropdownMenuSeparator,
+ DropdownMenuSub,
+ DropdownMenuSubContent,
+ DropdownMenuSubTrigger,
+ MenuLabel,
+} from "@posthog/quill";
+import type { SourceProduct } from "@posthog/shared/types";
+import { useAuthStateValue } from "@posthog/ui/features/auth/store";
+import {
+ type ActivityInboxScope,
+ useActivityFilterStore,
+} from "@posthog/ui/features/canvas/stores/activityFilterStore";
+import { useReportsInboxEnabled } from "@posthog/ui/features/feature-flags/useReportsInboxEnabled";
+import {
+ INBOX_PRIORITY_OPTIONS,
+ INBOX_SORT_OPTIONS,
+ inboxPriorityFilterLabel,
+ inboxSourceFilterLabel,
+} from "@posthog/ui/features/inbox/filterOptions";
+import { useInboxSourceFilterOptions } from "@posthog/ui/features/inbox/hooks/useInboxSourceFilterOptions";
+import type { InboxPrFilter } from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
+import { type ReactElement, useMemo } from "react";
+
+const SCOPE_OPTIONS: readonly {
+ value: ActivityInboxScope;
+ label: string;
+}[] = [
+ { value: "for-you", label: "For you" },
+ { value: "entire-project", label: "Entire project" },
+];
+
+const REPORT_OPTIONS: readonly { value: InboxPrFilter; label: string }[] = [
+ { value: "all", label: "All reports" },
+ { value: "with_pr", label: "Has a PR" },
+ { value: "without_pr", label: "No PR yet" },
+];
+
+function selectedLabel<T extends string>(
+ options: readonly { value: T; label: string }[],
+ value: T,
+): string {
+ return options.find((option) => option.value === value)?.label ?? "";
+}
+
+function ActivityFilterValue({
+ label,
+ value,
+ active,
+}: {
+ label: string;
+ value: string;
+ active: boolean;
+}): ReactElement {
+ return (
+ <>
+ <span>{label}</span>
+ <span
+ className={cn(
+ "flex-1 pl-4 text-right",
+ active ? "text-primary" : "text-muted-foreground/80",
+ )}
+ >
+ {value}
+ </span>
+ </>
+ );
+}
+
+export function ActivityIncludeMenuSection(): ReactElement {
+ const reportsInboxEnabled = useReportsInboxEnabled();
+ const authIdentity = useAuthStateValue(getAuthIdentity);
+ const mentionsEnabled = useActivityFilterStore(
+ (state) => state.mentionsEnabled,
+ );
+ const setMentionsEnabled = useActivityFilterStore(
+ (state) => state.setMentionsEnabled,
+ );
+ const inboxEnabled = useActivityFilterStore((state) =>
+ authIdentity
+ ? (state.inboxEnabledByAuthIdentity[authIdentity] ?? false)
+ : false,
+ );
+ const setInboxEnabled = useActivityFilterStore(
+ (state) => state.setInboxEnabled,
+ );
+ const inboxScope = useActivityFilterStore((state) => state.inboxScope);
+ const setInboxScope = useActivityFilterStore((state) => state.setInboxScope);
+ const sourceProductFilter = useActivityFilterStore(
+ (state) => state.inboxSourceProductFilter,
+ );
+ const toggleSourceProduct = useActivityFilterStore(
+ (state) => state.toggleInboxSourceProduct,
+ );
+ const clearSourceProductFilter = useActivityFilterStore(
+ (state) => state.clearInboxSourceProductFilter,
+ );
+ const prFilter = useActivityFilterStore((state) => state.inboxPrFilter);
+ const setPrFilter = useActivityFilterStore((state) => state.setInboxPrFilter);
+ const sortField = useActivityFilterStore((state) => state.inboxSortField);
+ const sortDirection = useActivityFilterStore(
+ (state) => state.inboxSortDirection,
+ );
+ const setSort = useActivityFilterStore((state) => state.setInboxSort);
+ const priorityFilter = useActivityFilterStore(
+ (state) => state.inboxPriorityFilter,
+ );
+ const togglePriority = useActivityFilterStore(
+ (state) => state.toggleInboxPriority,
+ );
+ const clearPriorityFilter = useActivityFilterStore(
+ (state) => state.clearInboxPriorityFilter,
+ );
+ const inboxAvailable = reportsInboxEnabled && authIdentity !== null;
+ const sourceOptions = useInboxSourceFilterOptions(sourceProductFilter, {
+ enabled: inboxAvailable && inboxEnabled,
+ });
+ const selectedSources = useMemo(
+ () => new Set(sourceProductFilter),
+ [sourceProductFilter],
+ );
+ const activeSort = INBOX_SORT_OPTIONS.find(
+ (option) =>
+ option.field === sortField && option.direction === sortDirection,
+ );
+
+ return (
+ <>
+ <MenuLabel>Include</MenuLabel>
+ <DropdownMenuCheckboxItem
+ checked={mentionsEnabled}
+ closeOnClick={false}
+ onCheckedChange={setMentionsEnabled}
+ >
+ Mentions
+ </DropdownMenuCheckboxItem>
+ {inboxAvailable && (
+ <DropdownMenuCheckboxItem
+ checked={inboxEnabled}
+ closeOnClick={false}
+ onCheckedChange={(enabled) => setInboxEnabled(authIdentity, enabled)}
+ >
+ Self-driving
+ </DropdownMenuCheckboxItem>
+ )}
+
+ {inboxAvailable && inboxEnabled && (
+ <>
+ <DropdownMenuSeparator />
+ <MenuLabel>Self-driving</MenuLabel>
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger className="pr-1">
+ <ActivityFilterValue
+ label="Scope"
+ value={selectedLabel(SCOPE_OPTIONS, inboxScope)}
+ active={inboxScope !== "for-you"}
+ />
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent side="right" sideOffset={4}>
+ <DropdownMenuRadioGroup
+ value={inboxScope}
+ onValueChange={(value) =>
+ setInboxScope(value as ActivityInboxScope)
+ }
+ >
+ {SCOPE_OPTIONS.map((option) => (
+ <DropdownMenuRadioItem
+ key={option.value}
+ value={option.value}
+ >
+ {option.label}
+ </DropdownMenuRadioItem>
+ ))}
+ </DropdownMenuRadioGroup>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger className="pr-1">
+ <ActivityFilterValue
+ label="Source"
+ value={inboxSourceFilterLabel(sourceProductFilter)}
+ active={sourceProductFilter.length > 0}
+ />
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent side="right" sideOffset={4}>
+ <DropdownMenuCheckboxItem
+ checked={sourceProductFilter.length === 0}
+ closeOnClick={false}
+ onCheckedChange={clearSourceProductFilter}
+ >
+ All sources
+ </DropdownMenuCheckboxItem>
+ {sourceOptions.map((option) => (
+ <DropdownMenuCheckboxItem
+ key={option.value}
+ checked={selectedSources.has(option.value)}
+ closeOnClick={false}
+ onCheckedChange={() =>
+ toggleSourceProduct(option.value as SourceProduct)
+ }
+ >
+ {option.icon}
+ {option.label}
+ </DropdownMenuCheckboxItem>
+ ))}
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger className="pr-1">
+ <ActivityFilterValue
+ label="Reports"
+ value={selectedLabel(REPORT_OPTIONS, prFilter)}
+ active={prFilter !== "all"}
+ />
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent side="right" sideOffset={4}>
+ <DropdownMenuRadioGroup
+ value={prFilter}
+ onValueChange={(value) => setPrFilter(value as InboxPrFilter)}
+ >
+ {REPORT_OPTIONS.map((option) => (
+ <DropdownMenuRadioItem
+ key={option.value}
+ value={option.value}
+ >
+ {option.label}
+ </DropdownMenuRadioItem>
+ ))}
+ </DropdownMenuRadioGroup>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger className="pr-1">
+ <ActivityFilterValue
+ label="Sort by"
+ value={activeSort?.label ?? "Priority first"}
+ active={sortField !== "priority" || sortDirection !== "asc"}
+ />
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent side="right" sideOffset={4}>
+ <DropdownMenuRadioGroup
+ value={`${sortField}:${sortDirection}`}
+ onValueChange={(value) => {
+ const option = INBOX_SORT_OPTIONS.find(
+ (candidate) =>
+ `${candidate.field}:${candidate.direction}` === value,
+ );
+ if (option) setSort(option.field, option.direction);
+ }}
+ >
+ {INBOX_SORT_OPTIONS.map((option) => (
+ <DropdownMenuRadioItem
+ key={`${option.field}:${option.direction}`}
+ value={`${option.field}:${option.direction}`}
+ >
+ {option.icon}
+ {option.label}
+ </DropdownMenuRadioItem>
+ ))}
+ </DropdownMenuRadioGroup>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger className="pr-1">
+ <ActivityFilterValue
+ label="Priority"
+ value={inboxPriorityFilterLabel(priorityFilter)}
+ active={priorityFilter.length > 0}
+ />
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent side="right" sideOffset={4}>
+ <DropdownMenuCheckboxItem
+ checked={priorityFilter.length === 0}
+ closeOnClick={false}
+ onCheckedChange={clearPriorityFilter}
+ >
+ All priorities
+ </DropdownMenuCheckboxItem>
+ {INBOX_PRIORITY_OPTIONS.map((option) => (
+ <DropdownMenuCheckboxItem
+ key={option.value}
+ checked={priorityFilter.includes(option.value)}
+ closeOnClick={false}
+ onCheckedChange={() => togglePriority(option.value)}
+ >
+ <span
+ aria-hidden
+ className="size-2 shrink-0 rounded-full"
+ style={{ backgroundColor: option.accent }}
+ />
+ {option.value}
+ </DropdownMenuCheckboxItem>
+ ))}
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+ </>
+ )}
+ </>
+ );
+}
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 a1d01aba7c7f..ffd861b19240 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityRow.tsx
@@ -10,6 +10,7 @@ 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";
+import { ActivityRowSurface } from "@posthog/ui/features/canvas/components/ActivityRowSurface";
import {
type AgentActivityIconKind,
activityPresentation,
@@ -50,6 +51,8 @@ interface ActivityRowProps {
onActivate: (item: TaskActivityItem) => void;
isSelected?: boolean;
compact?: boolean;
+ asOption?: boolean;
+ optionValue?: string;
}
export function ActivityRow({
@@ -61,6 +64,8 @@ export function ActivityRow({
onActivate,
isSelected = false,
compact = false,
+ asOption = false,
+ optionValue,
}: ActivityRowProps): ReactElement {
const presentation = activityPresentation(item, currentUser?.email);
const channelId = item.channelId;
@@ -91,13 +96,14 @@ export function ActivityRow({
return (
<div className="group relative">
- <Button
+ <ActivityRowSurface
type="button"
+ asOption={asOption}
+ optionValue={optionValue}
onClick={openTask}
aria-label={`${item.taskTitle} ${presentation.metadata}${presentation.spaceLabel ? ` ${presentation.spaceLabel}` : ""}`}
left
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",
@@ -155,7 +161,7 @@ export function ActivityRow({
/>
)}
</span>
- </Button>
+ </ActivityRowSurface>
{item.isUnread && (
<Button
variant="default"
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityRowSurface.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityRowSurface.tsx
new file mode 100644
index 000000000000..95e46f4b9a86
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityRowSurface.tsx
@@ -0,0 +1,44 @@
+import { AutocompleteItem, Button, cn } from "@posthog/quill";
+import type { ComponentProps, ReactElement } from "react";
+
+type ActivityRowSurfaceProps = ComponentProps<typeof Button> & {
+ asOption?: boolean;
+ optionValue?: string;
+};
+
+export function ActivityRowSurface({
+ asOption = false,
+ optionValue,
+ className,
+ children,
+ ...props
+}: ActivityRowSurfaceProps): ReactElement {
+ const surfaceClassName = cn(
+ "h-auto w-full items-start text-left",
+ asOption &&
+ "ring-offset-0 data-highlighted:border-transparent data-highlighted:bg-fill-hover data-highlighted:ring-0 [&>span]:w-full [&>span]:items-start [&>span]:gap-2",
+ className,
+ );
+
+ if (asOption) {
+ if (!optionValue) {
+ throw new Error("Activity autocomplete options require a value");
+ }
+ return (
+ <AutocompleteItem
+ value={optionValue}
+ nativeButton
+ className={surfaceClassName}
+ {...(props as ComponentProps<typeof AutocompleteItem>)}
+ >
+ {children}
+ </AutocompleteItem>
+ );
+ }
+
+ return (
+ <Button left className={surfaceClassName} {...props}>
+ {children}
+ </Button>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityView.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityView.tsx
index 51d79c3399b5..3e044a8e2655 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityView.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityView.tsx
@@ -16,8 +16,11 @@ 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 { InboxActivityOverflowRow } from "@posthog/ui/features/canvas/components/InboxActivityOverflowRow";
+import { InboxActivityRow } from "@posthog/ui/features/canvas/components/InboxActivityRow";
import { openActivityItem } from "@posthog/ui/features/canvas/components/openActivityItem";
import { useBlockedTaskIds } from "@posthog/ui/features/canvas/hooks/useBlockedSessionCount";
+import { useInboxActivityPreview } from "@posthog/ui/features/canvas/hooks/useInboxActivityPreview";
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";
@@ -25,8 +28,9 @@ import { useActivityFilterStore } from "@posthog/ui/features/canvas/stores/activ
import { track } from "@posthog/ui/shell/analytics";
import { Fragment, useCallback, useEffect, useMemo } from "react";
import {
+ activityFeedSourceDescription,
activityReadPayload,
- getUnreadActivityItems,
+ deriveActivityFeedContent,
groupActivityItemsByDay,
} from "./activityFeed";
@@ -38,27 +42,54 @@ import {
// The spaces layout has no page: the feed is the column beside the rail
// (ChannelsSidebar) and /activity's pane is whatever you picked from it.
export function ActivityView() {
+ const mentionsIncluded = useActivityFilterStore(
+ (state) => state.mentionsEnabled,
+ );
+ const unreadsOnly = useActivityFilterStore((state) => state.unreadsOnly);
const client = useOptionalAuthenticatedClient();
- const { data: currentUser } = useCurrentUser({ client });
+ const { data: currentUser } = useCurrentUser({
+ client,
+ enabled: mentionsIncluded,
+ });
+ const taskActivity = useTaskActivity({ enabled: mentionsIncluded });
+ const inboxActivity = useInboxActivityPreview();
const {
- items,
- unreadCount,
- isLoading,
- hasNextPage,
- isFetchingNextPage,
- fetchNextPage,
- } = useTaskActivity();
+ unreadItems,
+ feedItems,
+ lastShownReportId,
+ remainingInboxReportCount,
+ selfDrivingIncluded,
+ } = useMemo(
+ () =>
+ deriveActivityFeedContent({
+ taskItems: taskActivity.items,
+ reports: inboxActivity.reports,
+ totalReportCount: inboxActivity.totalCount,
+ mentionsIncluded,
+ reportsIncluded: inboxActivity.isIncluded,
+ unreadsOnly,
+ }),
+ [
+ taskActivity.items,
+ inboxActivity.reports,
+ inboxActivity.totalCount,
+ inboxActivity.isIncluded,
+ mentionsIncluded,
+ unreadsOnly,
+ ],
+ );
+ const unreadCount = mentionsIncluded ? taskActivity.unreadCount : 0;
+ const isLoading =
+ (mentionsIncluded && taskActivity.isLoading) ||
+ (!unreadsOnly && inboxActivity.isLoading);
// Selected once for the feed, not once per row.
const blockedTaskIds = useBlockedTaskIds();
const { mutate: markTasksRead, isPending: isMarkingRead } =
useMarkTaskActivityRead();
- const unreadItems = useMemo(() => getUnreadActivityItems(items), [items]);
- const unreadsOnly = useActivityFilterStore((state) => state.unreadsOnly);
- const shownItems = unreadsOnly ? unreadItems : items;
const dayStart = useLocalDayStart();
const shownItemGroups = useMemo(
- () => groupActivityItemsByDay(shownItems, new Date(dayStart)),
- [shownItems, dayStart],
+ () => groupActivityItemsByDay(feedItems, new Date(dayStart)),
+ [feedItems, 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.
@@ -78,13 +109,13 @@ export function ActivityView() {
// 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 && (
+ const loadMoreButton = mentionsIncluded && taskActivity.hasNextPage && (
<div className="mt-3 flex justify-center">
<Button
variant="outline"
- loading={isFetchingNextPage}
- disabled={isFetchingNextPage}
- onClick={() => void fetchNextPage()}
+ loading={taskActivity.isFetchingNextPage}
+ disabled={taskActivity.isFetchingNextPage}
+ onClick={() => void taskActivity.fetchNextPage()}
>
Load more
</Button>
@@ -94,11 +125,11 @@ export function ActivityView() {
// The feed body is identical in both shells; only the empty-state copy tracks
// the layout's naming ("spaces" vs "channels").
const feed =
- isLoading && shownItems.length === 0 ? (
+ isLoading && feedItems.length === 0 ? (
<div className="flex justify-center py-16">
<Spinner />
</div>
- ) : shownItems.length === 0 ? (
+ ) : feedItems.length === 0 ? (
<>
<Empty>
<EmptyHeader>
@@ -111,7 +142,10 @@ export function ActivityView() {
<EmptyDescription>
{unreadsOnly
? "You're all caught up."
- : "Task updates and comment notifications across channels appear here."}
+ : activityFeedSourceDescription(
+ mentionsIncluded,
+ selfDrivingIncluded,
+ )}
</EmptyDescription>
</EmptyHeader>
</Empty>
@@ -124,14 +158,26 @@ export function ActivityView() {
<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 key={item.id}>
+ {item.kind === "task" ? (
+ <ActivityRow
+ item={item.task}
+ onMarkRead={markRead}
+ onActivate={openActivityItem}
+ currentUser={currentUser}
+ blockedTaskIds={blockedTaskIds}
+ />
+ ) : (
+ <InboxActivityRow report={item.report} />
+ )}
+ {item.kind === "report" &&
+ item.report.id === lastShownReportId &&
+ remainingInboxReportCount > 0 && (
+ <InboxActivityOverflowRow
+ count={remainingInboxReportCount}
+ />
+ )}
+ </Fragment>
))}
</Fragment>
))}
@@ -147,7 +193,10 @@ export function ActivityView() {
<div>
<h1 className="font-bold text-2xl">Activity</h1>
<p className="text-muted-foreground text-sm">
- Task updates and comment notifications across channels.
+ {activityFeedSourceDescription(
+ mentionsIncluded,
+ selfDrivingIncluded,
+ )}
</p>
</div>
<div className="flex shrink-0 items-center gap-2">
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelBackRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelBackRow.tsx
index 662d993b2dbc..0ee3dfcb1290 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelBackRow.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelBackRow.tsx
@@ -128,7 +128,7 @@ export function ChannelBackRow({ channelId }: { channelId: string }) {
{/* Same key as the search box's hint: from inside a space it is
the way back to the list, which is what this row does. */}
<Kbd className="mr-0! shrink-0 opacity-50">
- {formatHotkey(SHORTCUTS.FOCUS_SPACE_SEARCH)}
+ {formatHotkey(SHORTCUTS.FOCUS_SIDEBAR_SEARCH)}
</Kbd>
{/* The star's well. Its height is unconditional — it is what
sets the row's height, and a row that changed height between a
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelHotkeys.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelHotkeys.test.tsx
index d46e4f6812b4..ca6689fb9b88 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelHotkeys.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelHotkeys.test.tsx
@@ -27,14 +27,20 @@ vi.mock("@posthog/ui/router/navigationBridge", () => ({
}));
vi.mock("@posthog/ui/shell/analytics", () => ({ track: vi.fn() }));
+import {
+ showChannelPane,
+ useChannelPaneStore,
+} from "@posthog/ui/features/canvas/stores/channelPaneStore";
import { useCurrentChannelStore } from "@posthog/ui/features/canvas/stores/currentChannelStore";
+import { useSidebarSearchStore } from "@posthog/ui/features/canvas/stores/sidebarSearchStore";
+import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";
import { ChannelHotkeys } from "./ChannelHotkeys";
-function press(digit: string, modifiers: Partial<KeyboardEventInit> = {}) {
+function press(key: string, modifiers: Partial<KeyboardEventInit> = {}) {
document.dispatchEvent(
new KeyboardEvent("keydown", {
- key: digit,
- code: `Digit${digit}`,
+ key,
+ code: /^\d$/.test(key) ? `Digit${key}` : `Key${key.toUpperCase()}`,
bubbles: true,
cancelable: true,
...modifiers,
@@ -52,6 +58,11 @@ describe("ChannelHotkeys", () => {
{ id: "eng-id", name: "eng", path: "/eng" },
];
useCurrentChannelStore.setState({ currentChannelId: null });
+ useSidebarSearchStore.setState({
+ focusRequest: 0,
+ });
+ useSidebarStore.setState({ open: false });
+ showChannelPane();
});
// The regression: this component is rendered ALONE — no sidebar at all.
@@ -109,4 +120,14 @@ describe("ChannelHotkeys", () => {
press("1", { metaKey: true });
expect(mocks.navigateToChannel).not.toHaveBeenCalled();
});
+
+ it("opens the space list and requests focus for its search", () => {
+ render(<ChannelHotkeys />);
+
+ press("s", { metaKey: true, shiftKey: true });
+
+ expect(useSidebarStore.getState().open).toBe(true);
+ expect(useChannelPaneStore.getState().pane).toBe("list");
+ expect(useSidebarSearchStore.getState().focusRequest).toBe(1);
+ });
});
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelHotkeys.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelHotkeys.tsx
index 788de5995b41..408679cdbd26 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelHotkeys.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelHotkeys.tsx
@@ -6,7 +6,7 @@ import {
showChannelPane,
} from "@posthog/ui/features/canvas/stores/channelPaneStore";
import { useCurrentChannelStore } from "@posthog/ui/features/canvas/stores/currentChannelStore";
-import { requestSpaceSearchFocus } from "@posthog/ui/features/canvas/stores/spaceTreeStore";
+import { requestSidebarSearchFocus } from "@posthog/ui/features/canvas/stores/sidebarSearchStore";
import { SHORTCUTS } from "@posthog/ui/features/command/keyboard-shortcuts";
import { useSpacesTabs } from "@posthog/ui/features/feature-flags/useSpacesTabs";
import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";
@@ -67,11 +67,11 @@ export function ChannelHotkeys() {
// slide it back to the list, and hand the keyboard to the search box, which
// is also the tree's keyboard driver.
useHotkeys(
- SHORTCUTS.FOCUS_SPACE_SEARCH,
+ SHORTCUTS.FOCUS_SIDEBAR_SEARCH,
() => {
useSidebarStore.getState().setOpen(true);
showChannelList();
- requestSpaceSearchFocus();
+ requestSidebarSearchFocus();
},
{
enabled: channelsLayout,
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.test.tsx
index ee63bd696240..c6d539e2b818 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.test.tsx
@@ -153,9 +153,10 @@ import {
} from "@posthog/ui/features/canvas/stores/channelPaneStore";
import { useCurrentChannelStore } from "@posthog/ui/features/canvas/stores/currentChannelStore";
import {
- requestSpaceSearchFocus,
- useSpaceTreeStore,
-} from "@posthog/ui/features/canvas/stores/spaceTreeStore";
+ requestSidebarSearchFocus,
+ useSidebarSearchStore,
+} from "@posthog/ui/features/canvas/stores/sidebarSearchStore";
+import { useSpaceTreeStore } from "@posthog/ui/features/canvas/stores/spaceTreeStore";
import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";
import { ChannelsList } from "./ChannelsList";
@@ -207,9 +208,11 @@ describe("ChannelsList", () => {
useSidebarStore.setState({ collapsedSections: new Set() });
useSpaceTreeStore.setState({
expandedSpaceIds: new Set(),
- searchFocusRequest: 0,
highlightedValue: undefined,
});
+ useSidebarSearchStore.setState({
+ focusRequest: 0,
+ });
mocks.totals = {};
useCurrentChannelStore.setState({ currentChannelId: null });
mocks.tasks = [
@@ -257,11 +260,13 @@ describe("ChannelsList", () => {
});
it("rebrands only the spaces layout", () => {
- renderList();
- expect(screen.getByText("Spaces")).toBeTruthy();
+ const view = renderList();
+ expect(screen.getByRole("heading", { name: "Spaces" })).toBeTruthy();
+ view.unmount();
mocks.channelsLayout = false;
renderList();
+ expect(screen.queryByRole("heading", { name: "Spaces" })).toBeNull();
expect(screen.getByText("Channels")).toBeTruthy();
});
});
@@ -415,7 +420,7 @@ describe("ChannelsList", () => {
renderList();
expect(screen.getByText("engineering")).toBeTruthy();
- await user.click(screen.getByText("Spaces"));
+ await user.click(screen.getByRole("option", { name: "Spaces" }));
expect(screen.queryByText("engineering")).toBeNull();
});
@@ -555,15 +560,22 @@ describe("ChannelsList", () => {
// ⌘⇧S is bound in ChannelHotkeys, which can only ask; the list is what
// actually takes the keyboard.
it("takes the keyboard on a focus request", async () => {
- renderList();
+ const firstRender = renderList();
- act(() => requestSpaceSearchFocus());
+ act(() => requestSidebarSearchFocus());
await waitFor(() =>
expect(document.activeElement).toBe(
screen.getByLabelText("Search spaces"),
),
);
+
+ firstRender.unmount();
+ renderList();
+
+ expect(document.activeElement).not.toBe(
+ screen.getByLabelText("Search spaces"),
+ );
});
it("focuses the search box when the pane slides back", async () => {
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx
index 8c8a05f4caf2..e1d21f903db6 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsList.tsx
@@ -19,8 +19,6 @@ import {
AlertDialogHeader,
AlertDialogTitle,
Autocomplete,
- AutocompleteClear,
- AutocompleteInput,
AutocompleteItem,
AutocompleteList,
Button,
@@ -55,6 +53,7 @@ import {
import type { ChannelActionItem } from "@posthog/ui/features/canvas/components/channelActions";
import { channelGlyph } from "@posthog/ui/features/canvas/components/channelGlyph";
import { RenameChannelModal } from "@posthog/ui/features/canvas/components/RenameChannelModal";
+import { SidebarSearchHeader } from "@posthog/ui/features/canvas/components/SidebarSearchHeader";
import type { SpacePreviewPayload } from "@posthog/ui/features/canvas/components/SpacePreview";
import {
TaskRowContextMenu,
@@ -96,12 +95,10 @@ import {
resetCurrentChannel,
useCurrentChannelStore,
} from "@posthog/ui/features/canvas/stores/currentChannelStore";
+import { requestSidebarSearchFocus } from "@posthog/ui/features/canvas/stores/sidebarSearchStore";
import { useSpaceTreeStore } from "@posthog/ui/features/canvas/stores/spaceTreeStore";
import { copyChannelLink } from "@posthog/ui/features/canvas/utils/copyChannelLink";
-import {
- formatHotkey,
- SHORTCUTS,
-} from "@posthog/ui/features/command/keyboard-shortcuts";
+import { formatHotkey } from "@posthog/ui/features/command/keyboard-shortcuts";
import {
TaskBadgeStack,
TaskStatusDot,
@@ -253,22 +250,6 @@ const PERSONAL_ROW_VALUE = "personal-row";
const ROW_LABEL_TONE =
"text-muted-foreground group-hover/button:text-foreground group-data-highlighted/button:text-foreground";
-/**
- * Hand the pane's keyboard to the search box: focus it, send the highlight back
- * to the top, and select whatever query was left there so it types over.
- */
-function focusSearch(input: HTMLInputElement): void {
- input.focus();
- // Autocomplete leaves its highlight where it was and exposes no way to move
- // it, so the list would open mid-scroll. Home is the key it listens for;
- // sending it is how the list reopens at the top.
- input.dispatchEvent(
- new KeyboardEvent("keydown", { key: "Home", bubbles: true }),
- );
- // After Home, so the caret it parks at the start doesn't undo the selection.
- input.select();
-}
-
/**
* Walk Autocomplete's highlight by synthesizing the arrow keys it already
* listens for. There is no API to set the highlighted row, and the input keeps
@@ -1745,25 +1726,13 @@ export function ChannelsList() {
// re-focusing on every render would steal focus from the rows themselves.
const pane = useChannelPaneStore((s) => s.pane);
const previousPane = useRef(pane);
- const searchRef = useRef<HTMLInputElement | null>(null);
useEffect(() => {
const cameFromChannel = previousPane.current === "channel";
previousPane.current = pane;
if (!channelsLayout || pane !== "list" || !cameFromChannel) return;
- const input = searchRef.current;
- if (input) focusSearch(input);
+ requestSidebarSearchFocus();
}, [pane, channelsLayout]);
- // ⌘⇧S from anywhere in the app ends here. A counter, not a flag: pressing the
- // key again while the box already has focus has to reach the list again, to
- // put the highlight back at the top and select the query.
- const searchFocusRequest = useSpaceTreeStore((s) => s.searchFocusRequest);
- useEffect(() => {
- if (!channelsLayout || searchFocusRequest === 0) return;
- const input = searchRef.current;
- if (input) focusSearch(input);
- }, [searchFocusRequest, channelsLayout]);
-
// Which row the keyboard is on. A ref rather than state: the arrow handlers
// read it during the event, and re-rendering the whole list on every ↑/↓ is
// exactly the cost this pane can't afford.
@@ -1941,43 +1910,14 @@ export function ChannelsList() {
const body = (
<Flex direction="column" className="h-full min-h-0">
{channelsLayout && (
- <Box className="shrink-0 px-2 pt-2">
- <AutocompleteInput
- ref={searchRef}
- placeholder="Search spaces…"
- aria-label="Search spaces"
- showSearchIcon={false}
- className="h-7 text-[13px] hover:bg-fill-hover"
- onKeyDown={(event) => {
- onTreeKeyDown(event);
- // Base UI's clear is a tabIndex=-1 decoration, so Escape is the
- // keyboard way out of a query. With the box already empty there's
- // nothing to clear, and Escape belongs to whoever is listening
- // above (closing the sidebar, dismissing a dialog).
- if (event.key !== "Escape" || query === "") return;
- event.preventDefault();
- event.stopPropagation();
- setQuery("");
- }}
- >
- {/* The key that lands here from anywhere, advertised where it lands.
- It gives way to the clear button once there's a query — by then
- you are in the box and clearing is the useful action. */}
- {query === "" ? (
- <Kbd className="-mr-0.5 shrink-0">
- {formatHotkey(SHORTCUTS.FOCUS_SPACE_SEARCH)}
- </Kbd>
- ) : (
- /* Rendered here rather than via `showClear` so it can be given a
- tab stop: quill passes no props to the one it renders itself. */
- <AutocompleteClear
- tabIndex={0}
- aria-label="Clear search"
- onClick={() => setQuery("")}
- />
- )}
- </AutocompleteInput>
- </Box>
+ <SidebarSearchHeader
+ title="Spaces"
+ query={query}
+ placeholder="Search spaces…"
+ searchLabel="Search spaces"
+ onClear={() => setQuery("")}
+ onKeyDown={onTreeKeyDown}
+ />
)}
{channelsLayout ? (
// Every row is an option, filtered or not, so ↑/↓/⏎ work the moment the
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.tsx
index b4504d627010..3980fffaedbe 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.tsx
@@ -18,6 +18,7 @@ import { useRailSurface } from "@posthog/ui/features/canvas/hooks/useRailSurface
import { useTrackChannelsSpaceViewed } from "@posthog/ui/features/canvas/hooks/useTrackChannelsSpaceViewed";
import {
selectActivityItem,
+ selectActivityReport,
useActivitySelection,
} from "@posthog/ui/features/canvas/stores/activityDetailStore";
import {
@@ -256,6 +257,7 @@ export function ChannelsSidebar() {
className="min-h-0 flex-1"
selectedId={selectedActivityId}
onActivate={selectActivityItem}
+ onReportActivate={selectActivityReport}
/>
) : feedId ? (
<TaskFeedPane feedId={feedId} className="min-h-0 flex-1" />
diff --git a/products/desktop/packages/ui/src/features/canvas/components/InboxActivityOverflowRow.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/InboxActivityOverflowRow.test.tsx
new file mode 100644
index 000000000000..b06b8f114150
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/InboxActivityOverflowRow.test.tsx
@@ -0,0 +1,58 @@
+import { fireEvent, render, screen } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const mocks = vi.hoisted(() => ({
+ navigateToInboxReports: vi.fn(),
+}));
+
+vi.mock("@posthog/ui/router/navigationBridge", () => ({
+ navigateToInboxReports: mocks.navigateToInboxReports,
+}));
+
+import { useActivityFilterStore } from "@posthog/ui/features/canvas/stores/activityFilterStore";
+import { useInboxReviewerScopeStore } from "@posthog/ui/features/inbox/stores/inboxReviewerScopeStore";
+import { useInboxSignalsFilterStore } from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
+import { InboxActivityOverflowRow } from "./InboxActivityOverflowRow";
+
+describe("InboxActivityOverflowRow", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ useActivityFilterStore.setState({
+ inboxScope: "entire-project",
+ inboxSourceProductFilter: ["github"],
+ inboxPrFilter: "with_pr",
+ inboxSortField: "created_at",
+ inboxSortDirection: "desc",
+ inboxPriorityFilter: ["P0", "P1"],
+ });
+ useInboxReviewerScopeStore.setState({ scope: "for-you" });
+ useInboxSignalsFilterStore.setState({
+ sourceProductFilter: [],
+ prFilter: "all",
+ sortField: "priority",
+ sortDirection: "asc",
+ priorityFilter: [],
+ });
+ });
+
+ it("opens the Reports tab with the Activity inbox filters", () => {
+ const onOpened = vi.fn();
+ render(<InboxActivityOverflowRow count={4} onOpened={onOpened} />);
+
+ fireEvent.click(screen.getByText("View 4 more reports"));
+
+ expect(useInboxReviewerScopeStore.getState().scope).toBe("entire-project");
+ expect(
+ useInboxSignalsFilterStore.getState().sourceProductFilter,
+ ).toStrictEqual(["github"]);
+ expect(useInboxSignalsFilterStore.getState().prFilter).toBe("with_pr");
+ expect(useInboxSignalsFilterStore.getState().sortField).toBe("created_at");
+ expect(useInboxSignalsFilterStore.getState().sortDirection).toBe("desc");
+ expect(useInboxSignalsFilterStore.getState().priorityFilter).toStrictEqual([
+ "P0",
+ "P1",
+ ]);
+ expect(mocks.navigateToInboxReports).toHaveBeenCalledOnce();
+ expect(onOpened).toHaveBeenCalledOnce();
+ });
+});
diff --git a/products/desktop/packages/ui/src/features/canvas/components/InboxActivityOverflowRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/InboxActivityOverflowRow.tsx
new file mode 100644
index 000000000000..885a0c65298f
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/InboxActivityOverflowRow.tsx
@@ -0,0 +1,70 @@
+import { ArrowRightIcon } from "@phosphor-icons/react";
+import { useActivityFilterStore } from "@posthog/ui/features/canvas/stores/activityFilterStore";
+import { useInboxReviewerScopeStore } from "@posthog/ui/features/inbox/stores/inboxReviewerScopeStore";
+import { useInboxSignalsFilterStore } from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
+import { navigateToInboxReports } from "@posthog/ui/router/navigationBridge";
+import type { ReactElement } from "react";
+import { ActivityRowSurface } from "./ActivityRowSurface";
+
+interface InboxActivityOverflowRowProps {
+ count: number;
+ onOpened?: () => void;
+ asOption?: boolean;
+ optionValue?: string;
+}
+
+export function InboxActivityOverflowRow({
+ count,
+ onOpened,
+ asOption = false,
+ optionValue,
+}: InboxActivityOverflowRowProps): ReactElement {
+ const inboxScope = useActivityFilterStore((state) => state.inboxScope);
+ const sourceProductFilter = useActivityFilterStore(
+ (state) => state.inboxSourceProductFilter,
+ );
+ const prFilter = useActivityFilterStore((state) => state.inboxPrFilter);
+ const sortField = useActivityFilterStore((state) => state.inboxSortField);
+ const sortDirection = useActivityFilterStore(
+ (state) => state.inboxSortDirection,
+ );
+ const priorityFilter = useActivityFilterStore(
+ (state) => state.inboxPriorityFilter,
+ );
+ const setScope = useInboxReviewerScopeStore((state) => state.setScope);
+ const setSourceProductFilter = useInboxSignalsFilterStore(
+ (state) => state.setSourceProductFilter,
+ );
+ const setPriorityFilter = useInboxSignalsFilterStore(
+ (state) => state.setPriorityFilter,
+ );
+ const setPrFilter = useInboxSignalsFilterStore((state) => state.setPrFilter);
+ const setSort = useInboxSignalsFilterStore((state) => state.setSort);
+
+ const viewMore = (): void => {
+ setScope(inboxScope);
+ setSourceProductFilter(sourceProductFilter);
+ setPrFilter(prFilter);
+ setSort(sortField, sortDirection);
+ setPriorityFilter(priorityFilter);
+ navigateToInboxReports();
+ onOpened?.();
+ };
+
+ return (
+ <ActivityRowSurface
+ type="button"
+ asOption={asOption}
+ optionValue={optionValue}
+ left
+ className="py-1.5 text-muted-foreground"
+ onClick={viewMore}
+ >
+ <span className="w-4 shrink-0" />
+ <span className="min-w-0 flex-1 truncate text-[13px]">
+ View {count} more reports
+ </span>
+ <ArrowRightIcon size={13} className="shrink-0" />
+ </ActivityRowSurface>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/InboxActivityRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/InboxActivityRow.tsx
new file mode 100644
index 000000000000..cdf22b61e6b8
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/InboxActivityRow.tsx
@@ -0,0 +1,88 @@
+import { humanizeReportTitle } from "@posthog/core/inbox/reportPresentation";
+import { Avatar, AvatarFallback } from "@posthog/quill";
+import { formatRelativeAge } from "@posthog/shared";
+import type { SignalReport } from "@posthog/shared/types";
+import { ActivityRowSurface } from "@posthog/ui/features/canvas/components/ActivityRowSurface";
+import { useOpenInboxReport } from "@posthog/ui/features/inbox/hooks/useOpenInboxReport";
+import { type ReactElement, useState } from "react";
+
+interface InboxActivityRowProps {
+ report: SignalReport;
+ onOpened?: () => void;
+ compact?: boolean;
+ asOption?: boolean;
+ optionValue?: string;
+ onActivate?: (report: SignalReport) => void;
+ isSelected?: boolean;
+}
+
+export function InboxActivityRow({
+ report,
+ onOpened,
+ compact = false,
+ asOption = false,
+ optionValue,
+ onActivate,
+ isSelected = false,
+}: InboxActivityRowProps): ReactElement {
+ const openInboxReport = useOpenInboxReport();
+ const [isOpening, setIsOpening] = useState(false);
+ const title = humanizeReportTitle(report.title, "Untitled report");
+
+ const openReport = async (): Promise<void> => {
+ if (isOpening) return;
+ setIsOpening(true);
+ try {
+ await openInboxReport(report.id);
+ onOpened?.();
+ } finally {
+ setIsOpening(false);
+ }
+ };
+
+ const activate = (): void => {
+ if (onActivate) {
+ onActivate(report);
+ onOpened?.();
+ return;
+ }
+ void openReport();
+ };
+
+ return (
+ <ActivityRowSurface
+ type="button"
+ asOption={asOption}
+ optionValue={optionValue}
+ onClick={activate}
+ loading={!onActivate && isOpening}
+ disabled={!onActivate && isOpening}
+ aria-label={
+ report.priority
+ ? `${title} ${report.priority} Self-driving report`
+ : `${title} Self-driving report`
+ }
+ left
+ className={`${compact ? "py-1.5" : "py-2"} ${isSelected ? "bg-fill-selected" : ""}`}
+ >
+ <span className="mt-0.5 shrink-0">
+ <Avatar
+ size="xs"
+ className={`bg-(--orange-3) text-(--orange-11) ring-(--orange-5) ring-1 ring-inset ${compact ? "size-4" : ""}`}
+ >
+ <AvatarFallback>
+ <span className="font-bold text-[7px]">
+ {report.priority ?? "–"}
+ </span>
+ </AvatarFallback>
+ </Avatar>
+ </span>
+ <span className="min-w-0 flex-1">
+ <span className="block truncate font-medium text-[13px]">{title}</span>
+ <span className="block truncate text-muted-foreground text-xxs">
+ {formatRelativeAge(report.updated_at)} · Self-driving
+ </span>
+ </span>
+ </ActivityRowSurface>
+ );
+}
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 678bff7a01c8..8f9f492353d0 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
@@ -47,8 +47,8 @@ vi.mock("@posthog/ui/features/feature-flags/useSpacesTabs", () => ({
vi.mock("@posthog/ui/features/canvas/hooks/useChannelsLayout", () => ({
useChannelsLayout: () => true,
}));
-vi.mock("@posthog/ui/features/inbox/hooks/useInboxAllReports", () => ({
- useInboxAllReports: () => ({ counts: { pulls: 1 } }),
+vi.mock("@posthog/ui/features/inbox/hooks/useInboxDecisionCount", () => ({
+ useInboxDecisionCount: () => 1,
}));
vi.mock("@posthog/ui/features/sidebar/components/ProjectSwitcher", () => ({
ProjectSwitcher: () => (
@@ -81,6 +81,7 @@ vi.mock("@posthog/ui/features/canvas/components/ActivityHoverCard", () => ({
import { browserTabsStore } from "@posthog/core/browser-tabs/browserTabsStore";
import { DESKTOP_HOME_FLAG, type RailVisit } from "@posthog/shared";
+import { useActivityFilterStore } from "@posthog/ui/features/canvas/stores/activityFilterStore";
import {
clearKeepListForRoute,
shouldKeepListForRoute,
@@ -132,6 +133,7 @@ describe("NavRail", () => {
mocks.fullPath = "/";
mocks.href = "/";
useSidebarStore.setState({ navItemOverrides: {}, navItemOrder: [] });
+ useActivityFilterStore.setState({ mentionsEnabled: true });
useCurrentChannelStore.setState({ currentChannelId: null });
useChannelPaneStore.setState({ pane: "channel" });
rememberVisits({});
@@ -172,6 +174,16 @@ describe("NavRail", () => {
}
});
+ it("hides the Activity notification dot when mentions are excluded", () => {
+ useActivityFilterStore.setState({ mentionsEnabled: false });
+
+ render(<NavRail />);
+
+ expect(
+ screen.getByLabelText("Activity").querySelector('[data-slot="dot"]'),
+ ).toBeNull();
+ });
+
// 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 262778d50457..9dfde38e0eba 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/NavRail.tsx
@@ -22,15 +22,18 @@ import {
} from "@posthog/ui/features/canvas/components/railDestinations";
import { useRailPane } from "@posthog/ui/features/canvas/hooks/useRailSurface";
import { useTaskActivity } from "@posthog/ui/features/canvas/hooks/useTaskActivity";
+import { useActivityFilterStore } from "@posthog/ui/features/canvas/stores/activityFilterStore";
import {
formatHotkey,
SHORTCUTS,
} from "@posthog/ui/features/command/keyboard-shortcuts";
import { useCommandCenterActiveCount } from "@posthog/ui/features/command-center/useCommandCenterActiveCount";
+import { useChannelReportsEnabled } from "@posthog/ui/features/feature-flags/useChannelReportsEnabled";
import { useContextLayerFlag } from "@posthog/ui/features/feature-flags/useContextLayerFlag";
import { useFeatureFlag } from "@posthog/ui/features/feature-flags/useFeatureFlag";
+import { useReportsInboxEnabled } from "@posthog/ui/features/feature-flags/useReportsInboxEnabled";
import { useSpacesTabs } from "@posthog/ui/features/feature-flags/useSpacesTabs";
-import { useInboxAllReports } from "@posthog/ui/features/inbox/hooks/useInboxAllReports";
+import { useInboxDecisionCount } from "@posthog/ui/features/inbox/hooks/useInboxDecisionCount";
import { openSettings } from "@posthog/ui/features/settings/hooks/useOpenSettings";
import { ProjectSwitcher } from "@posthog/ui/features/sidebar/components/ProjectSwitcher";
import {
@@ -49,8 +52,6 @@ import {
useState,
} from "react";
-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 =
@@ -186,33 +187,43 @@ export function NavRail() {
const homeEnabled = useFeatureFlag(DESKTOP_HOME_FLAG);
const loopsEnabled = useFeatureFlag(LOOPS_FLAG, import.meta.env.DEV);
const contextEnabled = useContextLayerFlag();
+ const channelReportsEnabled = useChannelReportsEnabled();
+ const reportsInboxEnabled = useReportsInboxEnabled();
const tabsEnabled = useSpacesTabs();
const openBrowserTab = useOpenBrowserTab();
+ const mentionsEnabled = useActivityFilterStore(
+ (state) => state.mentionsEnabled,
+ );
- const { counts: inboxCounts } = useInboxAllReports({
+ const navItemOverrides = useSidebarStore((s) => s.navItemOverrides);
+ const navItemOrder = useSidebarStore((s) => s.navItemOrder);
+ const inboxAvailable = !channelReportsEnabled || reportsInboxEnabled;
+ const destinations = visibleRailDestinations({
+ overrides: navItemOverrides,
+ order: navItemOrder,
+ home: homeEnabled,
+ inbox: inboxAvailable,
+ loops: loopsEnabled,
+ context: contextEnabled,
+ });
+ const inboxVisible = destinations.some(({ pane }) => pane === "inbox");
+ const inboxDecisionCount = useInboxDecisionCount({
+ enabled: inboxVisible,
ignoreFilters: true,
- refetchIntervalMs: INBOX_REFETCH_INTERVAL_MS,
});
- const { unreadCount: unseenActivity } = useTaskActivity();
+ const { unreadCount: unseenActivity } = useTaskActivity({
+ enabled: mentionsEnabled,
+ });
const commandCenterCount = useCommandCenterActiveCount();
const counts: RailCounts = {
- inbox: inboxCounts.pulls,
- activity: unseenActivity,
+ inbox: inboxDecisionCount,
+ activity: mentionsEnabled ? unseenActivity : 0,
commandCenter: commandCenterCount,
};
// The route is the only thing that says where you are, so the rail cannot
// light a destination the screen isn't on.
const railPane = useRailPane();
const toggleCommandMenu = useCommandMenuStore((s) => s.toggle);
- const navItemOverrides = useSidebarStore((s) => s.navItemOverrides);
- const navItemOrder = useSidebarStore((s) => s.navItemOrder);
- const destinations = visibleRailDestinations({
- overrides: navItemOverrides,
- order: navItemOrder,
- home: homeEnabled,
- loops: loopsEnabled,
- context: contextEnabled,
- });
const settingsVisible = isNavItemVisible(navItemOverrides, "configure");
const pick =
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SidebarSearchHeader.stories.tsx b/products/desktop/packages/ui/src/features/canvas/components/SidebarSearchHeader.stories.tsx
new file mode 100644
index 000000000000..3d9a7a644547
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/SidebarSearchHeader.stories.tsx
@@ -0,0 +1,35 @@
+import { Autocomplete, Button } from "@posthog/quill";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { SidebarSearchHeader } from "./SidebarSearchHeader";
+
+const meta = {
+ title: "Canvas/SidebarSearchHeader",
+ component: SidebarSearchHeader,
+ decorators: [
+ (Story) => (
+ <Autocomplete<string> value="" items={[]} filter={null}>
+ <div className="w-72 bg-chrome">
+ <Story />
+ </div>
+ </Autocomplete>
+ ),
+ ],
+ args: {
+ title: "Activity",
+ query: "",
+ placeholder: "Search activity…",
+ searchLabel: "Search activity",
+ onClear: () => {},
+ },
+} satisfies Meta<typeof SidebarSearchHeader>;
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+export const Default: Story = {};
+
+export const WithActions: Story = {
+ args: {
+ actions: <Button size="xs">Unreads</Button>,
+ },
+};
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SidebarSearchHeader.tsx b/products/desktop/packages/ui/src/features/canvas/components/SidebarSearchHeader.tsx
new file mode 100644
index 000000000000..15b7cfeca422
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/SidebarSearchHeader.tsx
@@ -0,0 +1,101 @@
+import { AutocompleteClear, AutocompleteInput, Kbd } from "@posthog/quill";
+import { useSidebarSearchStore } from "@posthog/ui/features/canvas/stores/sidebarSearchStore";
+import {
+ formatHotkey,
+ SHORTCUTS,
+} from "@posthog/ui/features/command/keyboard-shortcuts";
+import {
+ type ReactElement,
+ type KeyboardEvent as ReactKeyboardEvent,
+ type ReactNode,
+ useEffect,
+ useRef,
+} from "react";
+
+interface SidebarSearchHeaderProps {
+ title: string;
+ actions?: ReactNode;
+ query: string;
+ placeholder: string;
+ searchLabel: string;
+ onClear: () => void;
+ onKeyDown?: (event: ReactKeyboardEvent<HTMLInputElement>) => void;
+}
+
+function focusSearch(input: HTMLInputElement): void {
+ input.focus();
+ input.dispatchEvent(
+ new KeyboardEvent("keydown", { key: "Home", bubbles: true }),
+ );
+ input.select();
+}
+
+export function SidebarSearchHeader({
+ title,
+ actions,
+ query,
+ placeholder,
+ searchLabel,
+ onClear,
+ onKeyDown,
+}: SidebarSearchHeaderProps): ReactElement {
+ const searchRef = useRef<HTMLInputElement | null>(null);
+ const focusRequest = useSidebarSearchStore((state) => state.focusRequest);
+
+ useEffect(() => {
+ if (focusRequest === 0) return;
+ const input = searchRef.current;
+ if (!input || input.closest("[inert]")) return;
+ // Claim after the inert guard so an offscreen header leaves the request for
+ // the visible one, and so each request focuses a single header once.
+ if (!useSidebarSearchStore.getState().claimFocus(focusRequest)) return;
+ focusSearch(input);
+ }, [focusRequest]);
+
+ return (
+ <>
+ <div className="flex h-10 shrink-0 items-center gap-2 border-border border-b pr-2 pl-3">
+ <h2 className="font-bold text-base">{title}</h2>
+ {actions && (
+ <div className="ml-auto flex shrink-0 items-center gap-1">
+ {actions}
+ </div>
+ )}
+ </div>
+ <div className="shrink-0 px-2 pt-2">
+ <AutocompleteInput
+ ref={searchRef}
+ placeholder={placeholder}
+ aria-label={searchLabel}
+ showSearchIcon={false}
+ className="h-7 text-[13px] hover:bg-fill-hover"
+ onKeyDown={(event) => {
+ onKeyDown?.(event);
+ if (
+ event.defaultPrevented ||
+ event.key !== "Escape" ||
+ query === ""
+ ) {
+ return;
+ }
+ event.preventDefault();
+ event.stopPropagation();
+ onClear();
+ }}
+ >
+ {query === "" ? (
+ <Kbd className="-mr-0.5 shrink-0">
+ {formatHotkey(SHORTCUTS.FOCUS_SIDEBAR_SEARCH)}
+ </Kbd>
+ ) : (
+ <AutocompleteClear
+ tabIndex={0}
+ aria-label="Clear search"
+ onClick={onClear}
+ />
+ )}
+ </AutocompleteInput>
+ </div>
+ </>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceHeaderRow.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceHeaderRow.test.tsx
index 2887f52f13f4..f926a16e66ad 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/SpaceHeaderRow.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceHeaderRow.test.tsx
@@ -77,6 +77,9 @@ vi.mock("@posthog/ui/features/canvas/hooks/useChannelTasks", () => ({
vi.mock("@posthog/ui/features/canvas/hooks/useChannels", () => ({
useChannels: () => ({ channels: [{ id: "chan-1", name: "space" }] }),
}));
+vi.mock("@posthog/ui/features/canvas/hooks/useInboxActivityPreview", () => ({
+ useInboxActivityPreview: () => ({ reports: [] }),
+}));
vi.mock("@posthog/ui/features/canvas/hooks/useChannelStars", () => ({
useChannelStarMutations: () => ({ star: vi.fn(), unstar: vi.fn() }),
}));
diff --git a/products/desktop/packages/ui/src/features/canvas/components/activityFeed.test.ts b/products/desktop/packages/ui/src/features/canvas/components/activityFeed.test.ts
index fe2b1254b88b..a4c3535cc5b0 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,5 +1,13 @@
+import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";
+import type { SignalReport } from "@posthog/shared/types";
import { describe, expect, it } from "vitest";
-import { groupActivityItemsByDay, markLoadedReadLabel } from "./activityFeed";
+import {
+ deriveActivityFeedContent,
+ filterActivityFeedItems,
+ groupActivityItemsByDay,
+ markLoadedReadLabel,
+ mergeActivityFeedItems,
+} from "./activityFeed";
describe("activityFeed", () => {
it('says "Mark visible as read" while unread activity stays on unloaded pages', () => {
@@ -30,4 +38,60 @@ describe("activityFeed", () => {
["Wednesday", "last-wednesday"],
]);
});
+
+ it("searches task and report content in one activity feed", () => {
+ const tasks = [
+ {
+ id: "task-activity",
+ taskId: "task-1",
+ taskTitle: "Fix the billing dashboard",
+ channelName: "growth",
+ snippet: "The chart is empty",
+ author: { email: "[email protected]", first_name: "Max" },
+ activityAt: "2026-08-25T10:00:00Z",
+ } as TaskActivityItem,
+ ];
+ const reports = [
+ {
+ id: "report-1",
+ title: "Checkout conversion dropped",
+ summary: "Mobile customers abandon payment",
+ priority: "P3",
+ updated_at: "2026-08-25T11:00:00Z",
+ } as SignalReport,
+ ];
+ const feed = mergeActivityFeedItems(tasks, reports);
+
+ expect(
+ filterActivityFeedItems(feed, "billing").map((item) => item.id),
+ ).toEqual(["task:task-activity"]);
+ expect(
+ filterActivityFeedItems(feed, "mobile").map((item) => item.id),
+ ).toEqual(["report:report-1"]);
+ expect(filterActivityFeedItems(feed, "P3").map((item) => item.id)).toEqual([
+ "report:report-1",
+ ]);
+ expect(filterActivityFeedItems(feed, "P1")).toEqual([]);
+ });
+
+ it("removes reports and their copy state from unread-only activity", () => {
+ const content = deriveActivityFeedContent({
+ taskItems: [],
+ reports: [
+ {
+ id: "report-1",
+ updated_at: "2026-08-25T11:00:00Z",
+ } as SignalReport,
+ ],
+ totalReportCount: 4,
+ mentionsIncluded: true,
+ reportsIncluded: true,
+ unreadsOnly: true,
+ });
+
+ expect(content.feedItems).toEqual([]);
+ expect(content.lastShownReportId).toBeNull();
+ expect(content.remainingInboxReportCount).toBe(0);
+ expect(content.selfDrivingIncluded).toBe(false);
+ });
});
diff --git a/products/desktop/packages/ui/src/features/canvas/components/activityFeed.ts b/products/desktop/packages/ui/src/features/canvas/components/activityFeed.ts
index 592e2cac17ae..92cad049f10c 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/activityFeed.ts
+++ b/products/desktop/packages/ui/src/features/canvas/components/activityFeed.ts
@@ -1,5 +1,20 @@
import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";
import { formatShortDayLabel, getLocalDayKey } from "@posthog/shared";
+import type { SignalReport } from "@posthog/shared/types";
+
+export type ActivityFeedItem =
+ | {
+ kind: "task";
+ id: string;
+ activityAt: string;
+ task: TaskActivityItem;
+ }
+ | {
+ kind: "report";
+ id: string;
+ activityAt: string;
+ report: SignalReport;
+ };
export interface ActivityDayGroup<T> {
key: string;
@@ -7,6 +22,59 @@ export interface ActivityDayGroup<T> {
items: T[];
}
+export interface ActivityFeedContent {
+ unreadItems: TaskActivityItem[];
+ feedItems: ActivityFeedItem[];
+ lastShownReportId: string | null;
+ remainingInboxReportCount: number;
+ selfDrivingIncluded: boolean;
+}
+
+export function deriveActivityFeedContent({
+ taskItems,
+ reports,
+ totalReportCount,
+ mentionsIncluded,
+ reportsIncluded,
+ unreadsOnly,
+}: {
+ taskItems: TaskActivityItem[];
+ reports: SignalReport[];
+ totalReportCount: number;
+ mentionsIncluded: boolean;
+ reportsIncluded: boolean;
+ unreadsOnly: boolean;
+}): ActivityFeedContent {
+ const unreadItems = getUnreadActivityItems(taskItems);
+ const visibleReports = unreadsOnly ? [] : reports;
+
+ return {
+ unreadItems,
+ feedItems: mergeActivityFeedItems(
+ mentionsIncluded ? (unreadsOnly ? unreadItems : taskItems) : [],
+ visibleReports,
+ ),
+ lastShownReportId: visibleReports.at(-1)?.id ?? null,
+ remainingInboxReportCount: Math.max(
+ 0,
+ (unreadsOnly ? 0 : totalReportCount) - visibleReports.length,
+ ),
+ selfDrivingIncluded: !unreadsOnly && reportsIncluded,
+ };
+}
+
+export function activityFeedSourceDescription(
+ mentionsIncluded: boolean,
+ selfDrivingIncluded: boolean,
+): string {
+ if (mentionsIncluded && selfDrivingIncluded) {
+ return "Task updates and Self-driving reports appear here.";
+ }
+ if (mentionsIncluded) return "Task updates appear here.";
+ if (selfDrivingIncluded) return "Self-driving reports appear here.";
+ return "Choose what to include from the Activity actions menu.";
+}
+
export function groupActivityItemsByDay<T extends { activityAt: string }>(
items: readonly T[],
now: Date = new Date(),
@@ -29,6 +97,65 @@ export function groupActivityItemsByDay<T extends { activityAt: string }>(
return [...groups.values()];
}
+export function mergeActivityFeedItems(
+ tasks: readonly TaskActivityItem[],
+ reports: readonly SignalReport[],
+): ActivityFeedItem[] {
+ return [
+ ...tasks.map(
+ (task): ActivityFeedItem => ({
+ kind: "task",
+ id: `task:${task.id}`,
+ activityAt: task.activityAt,
+ task,
+ }),
+ ),
+ ...reports.map(
+ (report): ActivityFeedItem => ({
+ kind: "report",
+ id: `report:${report.id}`,
+ activityAt: report.updated_at,
+ report,
+ }),
+ ),
+ ].sort(
+ (left, right) =>
+ new Date(right.activityAt).getTime() -
+ new Date(left.activityAt).getTime(),
+ );
+}
+
+export function filterActivityFeedItems(
+ items: readonly ActivityFeedItem[],
+ query: string,
+): ActivityFeedItem[] {
+ const normalizedQuery = query.trim().toLowerCase();
+ if (!normalizedQuery) return [...items];
+
+ return items.filter((item) => {
+ const searchableText =
+ item.kind === "task"
+ ? [
+ item.task.taskTitle,
+ item.task.channelName,
+ item.task.snippet,
+ item.task.author?.first_name,
+ item.task.author?.last_name,
+ item.task.author?.email,
+ ]
+ : [
+ item.report.title,
+ item.report.summary,
+ item.report.priority,
+ "Self-driving",
+ ];
+
+ return searchableText.some((value) =>
+ value?.toLowerCase().includes(normalizedQuery),
+ );
+ });
+}
+
export function getUnreadActivityItems(
items: TaskActivityItem[],
): TaskActivityItem[] {
diff --git a/products/desktop/packages/ui/src/features/canvas/components/railDestinations.ts b/products/desktop/packages/ui/src/features/canvas/components/railDestinations.ts
index ed7cfa3b721a..1bcc2e382cfa 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/railDestinations.ts
+++ b/products/desktop/packages/ui/src/features/canvas/components/railDestinations.ts
@@ -66,6 +66,7 @@ export interface RailDestination {
countTone?: CountBadgeTone;
enabled?: (flags: {
home: boolean;
+ inbox: boolean;
loops: boolean;
context: boolean;
}) => boolean;
@@ -180,6 +181,7 @@ export const RAIL_DESTINATIONS: readonly RailDestination[] = [
onPick: navigateToInbox,
shortcut: formatHotkey(SHORTCUTS.INBOX),
count: (counts) => counts.inbox,
+ enabled: (flags) => flags.inbox,
},
{
pane: "command-center",
@@ -220,18 +222,20 @@ export function visibleRailDestinations({
overrides,
order,
home,
+ inbox,
loops,
context,
}: {
overrides: NavItemOverrides;
order: readonly CustomizableNavItemId[];
home: boolean;
+ inbox: boolean;
loops: boolean;
context: boolean;
}): readonly RailDestination[] {
const shown = RAIL_DESTINATIONS.filter(
({ customizableId, enabled }) =>
- (enabled?.({ home, loops, context }) ?? true) &&
+ (enabled?.({ home, inbox, loops, context }) ?? true) &&
(!customizableId || isNavItemVisible(overrides, customizableId)),
);
if (order.length === 0) return shown;
diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useInboxActivityPreview.test.tsx b/products/desktop/packages/ui/src/features/canvas/hooks/useInboxActivityPreview.test.tsx
new file mode 100644
index 000000000000..f04bcd43d5af
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useInboxActivityPreview.test.tsx
@@ -0,0 +1,137 @@
+import { renderHook } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const mocks = vi.hoisted(() => ({
+ reportsInboxEnabled: true,
+ currentUser: {
+ data: { uuid: "user-1" } as { uuid: string } | undefined,
+ isLoading: false,
+ },
+ useInboxReports: vi.fn(() => ({
+ data: { count: 1, results: [{ id: "report-1" }] },
+ isLoading: false,
+ })),
+}));
+
+vi.mock("@posthog/ui/features/auth/store", () => ({
+ useAuthStateValue: () => "us:1",
+}));
+vi.mock("@posthog/ui/features/auth/authClient", () => ({
+ useOptionalAuthenticatedClient: () => ({}),
+}));
+vi.mock("@posthog/ui/features/auth/useCurrentUser", () => ({
+ useCurrentUser: () => mocks.currentUser,
+}));
+vi.mock("@posthog/ui/features/inbox/hooks/useInboxReports", () => ({
+ useInboxReports: mocks.useInboxReports,
+}));
+vi.mock("@posthog/ui/features/feature-flags/useReportsInboxEnabled", () => ({
+ useReportsInboxEnabled: () => mocks.reportsInboxEnabled,
+}));
+
+import { useActivityFilterStore } from "@posthog/ui/features/canvas/stores/activityFilterStore";
+import { useInboxActivityPreview } from "./useInboxActivityPreview";
+
+describe("useInboxActivityPreview", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ mocks.reportsInboxEnabled = true;
+ mocks.currentUser = {
+ data: { uuid: "user-1" },
+ isLoading: false,
+ };
+ useActivityFilterStore.setState({
+ inboxEnabledByAuthIdentity: { "us:1": true },
+ inboxScope: "for-you",
+ inboxSourceProductFilter: [],
+ inboxPrFilter: "all",
+ inboxSortField: "priority",
+ inboxSortDirection: "asc",
+ inboxPriorityFilter: ["P1"],
+ });
+ });
+
+ it("requests the default P1 reports assigned to the current user", () => {
+ renderHook(() => useInboxActivityPreview());
+
+ expect(mocks.useInboxReports).toHaveBeenCalledWith(
+ expect.objectContaining({
+ has_implementation_pr: undefined,
+ limit: 3,
+ ordering: "status,priority,-created_at",
+ priority: "P1",
+ source_product: undefined,
+ suggested_reviewers: "user-1",
+ status: "ready",
+ }),
+ expect.objectContaining({ enabled: true, refetchInterval: 60_000 }),
+ );
+ });
+
+ it("applies the Activity inbox filters without a reviewer in project scope", () => {
+ useActivityFilterStore.setState({
+ inboxScope: "entire-project",
+ inboxSourceProductFilter: ["github", "session_replay"],
+ inboxPrFilter: "without_pr",
+ inboxSortField: "created_at",
+ inboxSortDirection: "desc",
+ inboxPriorityFilter: ["P0", "P2"],
+ });
+
+ renderHook(() => useInboxActivityPreview());
+
+ expect(mocks.useInboxReports).toHaveBeenCalledWith(
+ expect.objectContaining({
+ has_implementation_pr: false,
+ ordering: "status,-created_at,priority",
+ priority: "P0,P2",
+ source_product: "github,session_replay",
+ suggested_reviewers: undefined,
+ }),
+ expect.objectContaining({ enabled: true }),
+ );
+ });
+
+ it("stays loading while the For you reviewer is unresolved", () => {
+ mocks.currentUser = { data: undefined, isLoading: true };
+
+ const { result } = renderHook(() => useInboxActivityPreview());
+
+ expect(result.current.isLoading).toBe(true);
+ expect(mocks.useInboxReports).toHaveBeenCalledWith(
+ expect.anything(),
+ expect.objectContaining({ enabled: false }),
+ );
+ });
+
+ it.each([
+ [
+ "the project rollout is off",
+ () => {
+ mocks.reportsInboxEnabled = false;
+ },
+ ],
+ [
+ "the project has not opted in",
+ () => useActivityFilterStore.setState({ inboxEnabledByAuthIdentity: {} }),
+ ],
+ ])(
+ "hides cached reports and disables the query when %s",
+ (_name, disable) => {
+ disable();
+
+ const { result } = renderHook(() => useInboxActivityPreview());
+
+ expect(result.current).toEqual({
+ reports: [],
+ totalCount: 0,
+ isLoading: false,
+ isIncluded: false,
+ });
+ expect(mocks.useInboxReports).toHaveBeenCalledWith(
+ expect.anything(),
+ expect.objectContaining({ enabled: false }),
+ );
+ },
+ );
+});
diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useInboxActivityPreview.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useInboxActivityPreview.ts
new file mode 100644
index 000000000000..3e4f9cd2e6d7
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useInboxActivityPreview.ts
@@ -0,0 +1,104 @@
+import { getAuthIdentity } from "@posthog/core/auth/authIdentity";
+import {
+ buildPriorityFilterParam,
+ buildSignalReportListOrdering,
+ buildSuggestedReviewerFilterParam,
+ INBOX_REPORTS_TAB_STATUS_FILTER,
+} from "@posthog/core/inbox/reportFiltering";
+import { INBOX_SCOPE_FOR_YOU } from "@posthog/core/inbox/reportMembership";
+import type { SignalReport } from "@posthog/shared/types";
+import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";
+import { useAuthStateValue } from "@posthog/ui/features/auth/store";
+import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";
+import { useActivityFilterStore } from "@posthog/ui/features/canvas/stores/activityFilterStore";
+import { useReportsInboxEnabled } from "@posthog/ui/features/feature-flags/useReportsInboxEnabled";
+import { useInboxReports } from "@posthog/ui/features/inbox/hooks/useInboxReports";
+
+const INBOX_ACTIVITY_PREVIEW_LIMIT = 3;
+const INBOX_ACTIVITY_REFETCH_INTERVAL_MS = 60_000;
+const EMPTY_REPORTS: SignalReport[] = [];
+
+interface InboxActivityPreview {
+ reports: SignalReport[];
+ totalCount: number;
+ isLoading: boolean;
+ isIncluded: boolean;
+}
+
+export function useInboxActivityPreview(): InboxActivityPreview {
+ const reportsInboxEnabled = useReportsInboxEnabled();
+ const authIdentity = useAuthStateValue(getAuthIdentity);
+ const inboxEnabled = useActivityFilterStore((state) =>
+ authIdentity
+ ? (state.inboxEnabledByAuthIdentity[authIdentity] ?? false)
+ : false,
+ );
+ const inboxScope = useActivityFilterStore((state) => state.inboxScope);
+ const sourceProductFilter = useActivityFilterStore(
+ (state) => state.inboxSourceProductFilter,
+ );
+ const prFilter = useActivityFilterStore((state) => state.inboxPrFilter);
+ const sortField = useActivityFilterStore((state) => state.inboxSortField);
+ const sortDirection = useActivityFilterStore(
+ (state) => state.inboxSortDirection,
+ );
+ const priorityFilter = useActivityFilterStore(
+ (state) => state.inboxPriorityFilter,
+ );
+ const isIncluded = reportsInboxEnabled && inboxEnabled;
+ const needsReviewer = isIncluded && inboxScope === INBOX_SCOPE_FOR_YOU;
+ const client = useOptionalAuthenticatedClient();
+ const { data: currentUser, isLoading: isReviewerLoading } = useCurrentUser({
+ client,
+ enabled: needsReviewer,
+ });
+ const reviewerUuid =
+ inboxScope === INBOX_SCOPE_FOR_YOU ? currentUser?.uuid : undefined;
+ const scopeReady = !needsReviewer || reviewerUuid !== undefined;
+
+ const query = useInboxReports(
+ {
+ status: INBOX_REPORTS_TAB_STATUS_FILTER,
+ has_implementation_pr:
+ prFilter === "with_pr"
+ ? true
+ : prFilter === "without_pr"
+ ? false
+ : undefined,
+ ordering: buildSignalReportListOrdering(sortField, sortDirection),
+ source_product:
+ sourceProductFilter.length > 0
+ ? sourceProductFilter.join(",")
+ : undefined,
+ priority: buildPriorityFilterParam(priorityFilter),
+ suggested_reviewers: reviewerUuid
+ ? buildSuggestedReviewerFilterParam([reviewerUuid])
+ : undefined,
+ limit: INBOX_ACTIVITY_PREVIEW_LIMIT,
+ },
+ {
+ enabled: isIncluded && scopeReady,
+ refetchInterval: INBOX_ACTIVITY_REFETCH_INTERVAL_MS,
+ refetchIntervalInBackground: false,
+ },
+ );
+
+ if (!isIncluded) {
+ return {
+ reports: EMPTY_REPORTS,
+ totalCount: 0,
+ isLoading: false,
+ isIncluded: false,
+ };
+ }
+
+ return {
+ reports: query.data?.results ?? EMPTY_REPORTS,
+ totalCount: query.data?.count ?? 0,
+ isLoading:
+ query.isLoading ||
+ isReviewerLoading ||
+ (needsReviewer && reviewerUuid === undefined),
+ isIncluded: true,
+ };
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/stores/activityDetailStore.test.ts b/products/desktop/packages/ui/src/features/canvas/stores/activityDetailStore.test.ts
new file mode 100644
index 000000000000..03b368602971
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/stores/activityDetailStore.test.ts
@@ -0,0 +1,13 @@
+import { describe, expect, it } from "vitest";
+import { activityReportIdFromHref } from "./activityDetailStore";
+
+describe("activityReportIdFromHref", () => {
+ it("identifies persisted Activity report tabs", () => {
+ expect(
+ activityReportIdFromHref("/activity?item=report-1&report=report-1"),
+ ).toBe("report-1");
+ expect(
+ activityReportIdFromHref("/activity?item=task-1&session=session-1"),
+ ).toBeNull();
+ });
+});
diff --git a/products/desktop/packages/ui/src/features/canvas/stores/activityDetailStore.ts b/products/desktop/packages/ui/src/features/canvas/stores/activityDetailStore.ts
index f4bc8fc8efee..cae8392b07b3 100644
--- a/products/desktop/packages/ui/src/features/canvas/stores/activityDetailStore.ts
+++ b/products/desktop/packages/ui/src/features/canvas/stores/activityDetailStore.ts
@@ -1,12 +1,20 @@
import type { TaskActivityItem } from "@posthog/core/canvas/taskActivity";
+import type { SignalReport } from "@posthog/shared/types";
import { getRouterOrNull } from "@posthog/ui/router/routerRef";
import { useRouterState } from "@tanstack/react-router";
-export interface ActivitySelection {
- id: string;
- taskId: string;
- channelId: string | null;
-}
+export type ActivitySelection =
+ | {
+ kind: "task";
+ id: string;
+ taskId: string;
+ channelId: string | null;
+ }
+ | {
+ kind: "report";
+ id: string;
+ reportId: string;
+ };
/**
* What Activity is showing beside its feed, carried in `/activity`'s search
@@ -26,6 +34,7 @@ export interface ActivitySearch {
item?: string;
session?: string;
space?: string;
+ report?: string;
}
export function parseActivitySearch(
@@ -36,14 +45,31 @@ export function parseActivitySearch(
item: str(search.item),
session: str(search.session),
space: str(search.space),
+ report: str(search.report),
};
}
+export function activityReportIdFromHref(href: string | null): string | null {
+ if (!href) return null;
+ const queryStart = href.indexOf("?");
+ if (queryStart === -1) return null;
+ return new URLSearchParams(href.slice(queryStart + 1)).get("report");
+}
+
function toSelection(
search: ActivitySearch | undefined,
): ActivitySelection | null {
- if (!search?.item || !search.session) return null;
+ if (!search?.item) return null;
+ if (search.report) {
+ return {
+ kind: "report",
+ id: search.item,
+ reportId: search.report,
+ };
+ }
+ if (!search.session) return null;
return {
+ kind: "task",
id: search.item,
taskId: search.session,
channelId: search.space ?? null,
@@ -80,3 +106,13 @@ export function selectActivityItem(item: TaskActivityItem): void {
},
});
}
+
+export function selectActivityReport(report: SignalReport): void {
+ void getRouterOrNull()?.navigate({
+ to: "/activity",
+ search: {
+ item: report.id,
+ report: report.id,
+ },
+ });
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/stores/activityFilterStore.test.ts b/products/desktop/packages/ui/src/features/canvas/stores/activityFilterStore.test.ts
new file mode 100644
index 000000000000..35343c0ff17d
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/stores/activityFilterStore.test.ts
@@ -0,0 +1,37 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+describe("activityFilterStore", () => {
+ beforeEach(() => {
+ localStorage.clear();
+ vi.resetModules();
+ });
+
+ it("starts with mentions included and Self-driving excluded", async () => {
+ const { useActivityFilterStore } = await import("./activityFilterStore");
+
+ expect(useActivityFilterStore.getState()).toMatchObject({
+ mentionsEnabled: true,
+ inboxEnabledByAuthIdentity: {},
+ inboxScope: "for-you",
+ inboxSourceProductFilter: [],
+ inboxPrFilter: "all",
+ inboxSortField: "priority",
+ inboxSortDirection: "asc",
+ inboxPriorityFilter: ["P1"],
+ });
+ });
+
+ it("keeps the Self-driving opt-in separate for each project", async () => {
+ const { useActivityFilterStore } = await import("./activityFilterStore");
+
+ useActivityFilterStore.getState().setInboxEnabled("us:1", true);
+
+ expect(
+ useActivityFilterStore.getState().inboxEnabledByAuthIdentity,
+ ).toEqual({ "us:1": true });
+ expect(
+ useActivityFilterStore.getState().inboxEnabledByAuthIdentity["eu:1"] ??
+ false,
+ ).toBe(false);
+ });
+});
diff --git a/products/desktop/packages/ui/src/features/canvas/stores/activityFilterStore.ts b/products/desktop/packages/ui/src/features/canvas/stores/activityFilterStore.ts
index 002d6d71957e..ae988b17daeb 100644
--- a/products/desktop/packages/ui/src/features/canvas/stores/activityFilterStore.ts
+++ b/products/desktop/packages/ui/src/features/canvas/stores/activityFilterStore.ts
@@ -1,10 +1,38 @@
+import type {
+ SignalReportPriority,
+ SourceProduct,
+} from "@posthog/shared/types";
+import type { InboxSortField } from "@posthog/ui/features/inbox/filterOptions";
+import type { InboxPrFilter } from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
import { create } from "zustand";
import { persist } from "zustand/middleware";
+export type ActivityInboxScope = "for-you" | "entire-project";
+
interface ActivityFilterStore {
/** Show only activity that hasn't been read yet. */
unreadsOnly: boolean;
+ mentionsEnabled: boolean;
+ inboxEnabledByAuthIdentity: Record<string, boolean>;
+ inboxScope: ActivityInboxScope;
+ inboxSourceProductFilter: SourceProduct[];
+ inboxPrFilter: InboxPrFilter;
+ inboxSortField: InboxSortField;
+ inboxSortDirection: "asc" | "desc";
+ inboxPriorityFilter: SignalReportPriority[];
setUnreadsOnly: (unreadsOnly: boolean) => void;
+ setMentionsEnabled: (mentionsEnabled: boolean) => void;
+ setInboxEnabled: (authIdentity: string, inboxEnabled: boolean) => void;
+ setInboxScope: (inboxScope: ActivityInboxScope) => void;
+ toggleInboxSourceProduct: (source: SourceProduct) => void;
+ clearInboxSourceProductFilter: () => void;
+ setInboxPrFilter: (inboxPrFilter: InboxPrFilter) => void;
+ setInboxSort: (
+ inboxSortField: InboxSortField,
+ inboxSortDirection: "asc" | "desc",
+ ) => void;
+ toggleInboxPriority: (priority: SignalReportPriority) => void;
+ clearInboxPriorityFilter: () => void;
}
// Per-device preference shared by the Activity popover and the Activity page, so
@@ -13,8 +41,69 @@ export const useActivityFilterStore = create<ActivityFilterStore>()(
persist(
(set) => ({
unreadsOnly: false,
+ mentionsEnabled: true,
+ inboxEnabledByAuthIdentity: {},
+ inboxScope: "for-you",
+ inboxSourceProductFilter: [],
+ inboxPrFilter: "all",
+ inboxSortField: "priority",
+ inboxSortDirection: "asc",
+ inboxPriorityFilter: ["P1"],
setUnreadsOnly: (unreadsOnly) => set({ unreadsOnly }),
+ setMentionsEnabled: (mentionsEnabled) => set({ mentionsEnabled }),
+ setInboxEnabled: (authIdentity, inboxEnabled) =>
+ set((state) => ({
+ inboxEnabledByAuthIdentity: {
+ ...state.inboxEnabledByAuthIdentity,
+ [authIdentity]: inboxEnabled,
+ },
+ })),
+ setInboxScope: (inboxScope) => set({ inboxScope }),
+ toggleInboxSourceProduct: (source) =>
+ set((state) => ({
+ inboxSourceProductFilter: state.inboxSourceProductFilter.includes(
+ source,
+ )
+ ? state.inboxSourceProductFilter.filter((item) => item !== source)
+ : [...state.inboxSourceProductFilter, source],
+ })),
+ clearInboxSourceProductFilter: () =>
+ set({ inboxSourceProductFilter: [] }),
+ setInboxPrFilter: (inboxPrFilter) => set({ inboxPrFilter }),
+ setInboxSort: (inboxSortField, inboxSortDirection) =>
+ set({ inboxSortField, inboxSortDirection }),
+ toggleInboxPriority: (priority) =>
+ set((state) => ({
+ inboxPriorityFilter: state.inboxPriorityFilter.includes(priority)
+ ? state.inboxPriorityFilter.filter((item) => item !== priority)
+ : [...state.inboxPriorityFilter, priority],
+ })),
+ clearInboxPriorityFilter: () => set({ inboxPriorityFilter: [] }),
}),
- { name: "activity-filter-storage" },
+ {
+ name: "activity-filter-storage",
+ version: 1,
+ migrate: (persisted, version) => {
+ if (version >= 1 || !persisted || typeof persisted !== "object") {
+ return persisted;
+ }
+ const { inboxEnabled: _inboxEnabled, ...rest } = persisted as Record<
+ string,
+ unknown
+ >;
+ return { ...rest, inboxEnabledByAuthIdentity: {} };
+ },
+ partialize: (state) => ({
+ unreadsOnly: state.unreadsOnly,
+ mentionsEnabled: state.mentionsEnabled,
+ inboxEnabledByAuthIdentity: state.inboxEnabledByAuthIdentity,
+ inboxScope: state.inboxScope,
+ inboxSourceProductFilter: state.inboxSourceProductFilter,
+ inboxPrFilter: state.inboxPrFilter,
+ inboxSortField: state.inboxSortField,
+ inboxSortDirection: state.inboxSortDirection,
+ inboxPriorityFilter: state.inboxPriorityFilter,
+ }),
+ },
),
);
diff --git a/products/desktop/packages/ui/src/features/canvas/stores/sidebarSearchStore.test.ts b/products/desktop/packages/ui/src/features/canvas/stores/sidebarSearchStore.test.ts
new file mode 100644
index 000000000000..e13c37f8de05
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/stores/sidebarSearchStore.test.ts
@@ -0,0 +1,32 @@
+import { beforeEach, describe, expect, it } from "vitest";
+import {
+ requestSidebarSearchFocus,
+ useSidebarSearchStore,
+} from "./sidebarSearchStore";
+
+describe("sidebarSearchStore", () => {
+ beforeEach(() => {
+ useSidebarSearchStore.setState({ focusRequest: 0 });
+ });
+
+ it("claims a pending focus request once, then never again", () => {
+ requestSidebarSearchFocus();
+ const token = useSidebarSearchStore.getState().focusRequest;
+ expect(token).toBe(1);
+
+ const { claimFocus } = useSidebarSearchStore.getState();
+ expect(claimFocus(token)).toBe(true);
+ expect(useSidebarSearchStore.getState().focusRequest).toBe(0);
+ // A header that mounts later reads the same stale token and must not refocus.
+ expect(claimFocus(token)).toBe(false);
+ });
+
+ it.each([
+ ["the token is the empty sentinel", 0],
+ ["the token does not match the pending request", 2],
+ ])("leaves the request pending when %s", (_case, token) => {
+ requestSidebarSearchFocus();
+ expect(useSidebarSearchStore.getState().claimFocus(token)).toBe(false);
+ expect(useSidebarSearchStore.getState().focusRequest).toBe(1);
+ });
+});
diff --git a/products/desktop/packages/ui/src/features/canvas/stores/sidebarSearchStore.ts b/products/desktop/packages/ui/src/features/canvas/stores/sidebarSearchStore.ts
new file mode 100644
index 000000000000..1ceb21aebc23
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/stores/sidebarSearchStore.ts
@@ -0,0 +1,27 @@
+import { create } from "zustand";
+
+interface SidebarSearchState {
+ focusRequest: number;
+ requestFocus: () => void;
+ claimFocus: (token: number) => boolean;
+}
+
+export const useSidebarSearchStore = create<SidebarSearchState>()(
+ (set, get) => ({
+ focusRequest: 0,
+ requestFocus: () =>
+ set((state) => ({ focusRequest: state.focusRequest + 1 })),
+ // Consume a focus request so it fires once. Without this a stale request
+ // stays pending and steals the keyboard when any header later mounts, such
+ // as the Activity rail hover popover.
+ claimFocus: (token) => {
+ if (token === 0 || get().focusRequest !== token) return false;
+ set({ focusRequest: 0 });
+ return true;
+ },
+ }),
+);
+
+export function requestSidebarSearchFocus(): void {
+ useSidebarSearchStore.getState().requestFocus();
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/stores/spaceTreeStore.ts b/products/desktop/packages/ui/src/features/canvas/stores/spaceTreeStore.ts
index ef26adc2fa49..35235701b159 100644
--- a/products/desktop/packages/ui/src/features/canvas/stores/spaceTreeStore.ts
+++ b/products/desktop/packages/ui/src/features/canvas/stores/spaceTreeStore.ts
@@ -3,16 +3,13 @@ import { persist } from "zustand/middleware";
/**
* The space list's tree state: which spaces are expanded to show their recent
- * tasks, plus the request to put the keyboard back in the search box.
+ * tasks.
*
* Expansion persists — a space you opened to keep an eye on is still open after
- * a restart. The focus request is a counter rather than a boolean because it is
- * an event, not a state: pressing the shortcut twice in a row has to reach the
- * list twice.
+ * a restart.
*/
interface SpaceTreeState {
expandedSpaceIds: Set<string>;
- searchFocusRequest: number;
/**
* The row the keyboard is on, so a session row can open its card as the
* highlight lands on it. Not persisted. Only the rows read it, each through a
@@ -23,7 +20,6 @@ interface SpaceTreeState {
toggleSpace: (spaceId: string) => void;
expandSpace: (spaceId: string) => void;
collapseSpace: (spaceId: string) => void;
- requestSearchFocus: () => void;
setHighlightedValue: (value: string | undefined) => void;
}
@@ -31,7 +27,6 @@ export const useSpaceTreeStore = create<SpaceTreeState>()(
persist(
(set) => ({
expandedSpaceIds: new Set<string>(),
- searchFocusRequest: 0,
highlightedValue: undefined,
toggleSpace: (spaceId) =>
set((state) => {
@@ -53,8 +48,6 @@ export const useSpaceTreeStore = create<SpaceTreeState>()(
expanded.delete(spaceId);
return { expandedSpaceIds: expanded };
}),
- requestSearchFocus: () =>
- set((state) => ({ searchFocusRequest: state.searchFocusRequest + 1 })),
setHighlightedValue: (value) =>
set((state) =>
state.highlightedValue === value
@@ -79,11 +72,3 @@ export const useSpaceTreeStore = create<SpaceTreeState>()(
},
),
);
-
-/**
- * Ask the space list to take the keyboard — the ⌘⇧S shortcut's half of the job,
- * the list itself owns the focus.
- */
-export function requestSpaceSearchFocus(): void {
- useSpaceTreeStore.getState().requestSearchFocus();
-}
diff --git a/products/desktop/packages/ui/src/features/command/keyboard-shortcuts.ts b/products/desktop/packages/ui/src/features/command/keyboard-shortcuts.ts
index 0f424e5d1023..419f3bee6928 100644
--- a/products/desktop/packages/ui/src/features/command/keyboard-shortcuts.ts
+++ b/products/desktop/packages/ui/src/features/command/keyboard-shortcuts.ts
@@ -38,7 +38,7 @@ export const SHORTCUTS = {
// wherever it is shown; those two are disabled there so the keys have one
// owner at a time.
SWITCH_BROWSER_TAB: "mod+1,mod+2,mod+3,mod+4,mod+5,mod+6,mod+7,mod+8,mod+9",
- FOCUS_SPACE_SEARCH: "mod+shift+s",
+ FOCUS_SIDEBAR_SEARCH: "mod+shift+s",
TOGGLE_FOCUS: "mod+r",
PASTE_AS_FILE: "mod+shift+v",
INBOX: "mod+i",
@@ -159,11 +159,11 @@ export const KEYBOARD_SHORTCUTS: KeyboardShortcut[] = [
availability: "channels-layout",
},
{
- id: "focus-space-search",
- keys: SHORTCUTS.FOCUS_SPACE_SEARCH,
- description: "Search spaces",
+ id: "focus-sidebar-search",
+ keys: SHORTCUTS.FOCUS_SIDEBAR_SEARCH,
+ description: "Search sidebar",
category: "navigation",
- context: "Spaces",
+ context: "Sidebar",
availability: "channels-layout",
},
{
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxReportDetailGate.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxReportDetailGate.tsx
index 376e57f103e0..abae85486f59 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/InboxReportDetailGate.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxReportDetailGate.tsx
@@ -117,10 +117,10 @@ export function InboxReportDetailGate({
// fetch. Rendering the children then would briefly expose full triage actions
// (create PR, discuss, archive) for a report that another session has already
// suppressed, before the redirect kicks in. Hold the spinner until that same
- // fetch settles. The Archive route stays render-from-cache (the PR's instant-open
- // path): it's read-only and its one action, Restore, re-checks status server-side.
+ // fetch settles. Routes without status redirects and the Archive route render
+ // from cache: neither can expose actions for the wrong status route.
const statusUnconfirmed =
- !onDismissedRoute && isFetching && !isFetchedAfterMount;
+ statusRedirect && !onDismissedRoute && isFetching && !isFetchedAfterMount;
const redirectReportId = resolvedReport?.id;
useEffect(() => {
if (!redirectTo || !redirectReportId) return;
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxView.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxView.tsx
index 06e41e9f71ce..39a21153ae0f 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/InboxView.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxView.tsx
@@ -41,9 +41,6 @@ export function InboxView() {
resetReportOpenTrackerHistory();
}, []);
- useTrackInboxViewed();
-
- const { counts } = useInboxAllReports({ withReportsCount: true });
const pathname = useRouterState({ select: (s) => s.location.pathname });
const isDetailView = isInboxDetailPath(pathname);
@@ -52,6 +49,15 @@ export function InboxView() {
// keyboard-triageable page, and reclaims the inbox slot from the spaces
// redirect below. Detail routes keep their own bodies.
const reportsInboxEnabled = useReportsInboxEnabled();
+ const listEnabled =
+ !isDetailView && (reportsInboxEnabled || !channelReportsEnabled);
+ const legacyListEnabled = listEnabled && !reportsInboxEnabled;
+ const { counts } = useInboxAllReports({
+ enabled: legacyListEnabled,
+ withReportsCount: true,
+ });
+
+ useTrackInboxViewed({ enabled: legacyListEnabled });
if (reportsInboxEnabled && !isDetailView) {
// The view owns its height so its page header stays pinned while the
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportsInboxView.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportsInboxView.tsx
index a688f568a453..56abc873d6f1 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportsInboxView.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportsInboxView.tsx
@@ -14,6 +14,7 @@ import {
REPORTS_INBOX_STATUS_FILTER,
} from "@posthog/core/inbox/reportFiltering";
import { partitionInboxReports } from "@posthog/core/inbox/reportInboxSections";
+import { INBOX_SCOPE_FOR_YOU } from "@posthog/core/inbox/reportMembership";
import {
deriveHeadline,
humanizeReportTitle,
@@ -45,6 +46,7 @@ import { useInboxAllReports } from "@posthog/ui/features/inbox/hooks/useInboxAll
import { useInboxReportDismissAction } from "@posthog/ui/features/inbox/hooks/useInboxReportDismissAction";
import { useInboxReportsInfinite } from "@posthog/ui/features/inbox/hooks/useInboxReports";
import { useInboxSectionCounts } from "@posthog/ui/features/inbox/hooks/useInboxSectionCounts";
+import { useTrackReportsInboxViewed } from "@posthog/ui/features/inbox/hooks/useTrackReportsInboxViewed";
import {
hasActiveInboxFilters,
useInboxSignalsFilterStore,
@@ -101,6 +103,11 @@ export function ReportsInboxView() {
isFetchingNextPage,
fetchNextPage,
searchQuery,
+ totalCount,
+ scope,
+ isSuccess,
+ sourceProductFilter,
+ priorityFilter,
} = useInboxAllReports({
statusFilter: REPORTS_INBOX_STATUS_FILTER,
applyPrFilter: true,
@@ -127,6 +134,15 @@ export function ReportsInboxView() {
const monitoringCount = searchActive
? sections.monitoring.length
: serverCounts.monitoring;
+ useTrackReportsInboxViewed({
+ reports: scopedReports,
+ totalCount: searchActive ? scopedReports.length : totalCount,
+ isReady: isSuccess && !serverCounts.isLoading,
+ sourceProductFilter,
+ priorityFilter,
+ searchQuery,
+ isDefaultScope: scope === INBOX_SCOPE_FOR_YOU,
+ });
// Keep paging rows in (capped) so the sections have bodies to render —
// counts never depend on this; they come from the server queries above.
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxAllReports.test.tsx b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxAllReports.test.tsx
index 680161511867..0f033fbbc346 100644
--- a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxAllReports.test.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxAllReports.test.tsx
@@ -88,7 +88,10 @@ function reportsCountParams(): SignalReportsQueryParams | undefined {
return undefined;
}
-function renderCounts(options?: { withReportsCount?: boolean }) {
+function renderCounts(options?: {
+ enabled?: boolean;
+ withReportsCount?: boolean;
+}) {
const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false } },
});
@@ -129,4 +132,10 @@ describe("useInboxAllReports", () => {
expect(result.current.counts.reports).toBe(0);
expect(reportsCountParams()).toBeUndefined();
});
+
+ it("does not request reports when its surface is unavailable", () => {
+ renderCounts({ enabled: false, withReportsCount: true });
+
+ expect(mockGetSignalReports).not.toHaveBeenCalled();
+ });
});
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxAllReports.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxAllReports.ts
index 685622e3038d..e46856bd0098 100644
--- a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxAllReports.ts
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxAllReports.ts
@@ -37,12 +37,11 @@ const EMPTY_FILTER_ARRAY: never[] = [];
* values so unrelated filter changes don't re-render the consumer.
*
* `withReportsCount` opts into the extra count query behind `counts.reports`;
- * without it that count stays 0. Only the inbox tab bar renders it, and the
- * sidebar and channel nav mount this hook on every route to read `counts.pulls`
- * alone, so making it opt-in keeps them from polling a second endpoint for a
- * number they never show.
+ * without it that count stays 0. Only surfaces that render that count should
+ * pay for its request.
*/
export function useInboxAllReports(options?: {
+ enabled?: boolean;
ignoreScope?: boolean;
ignoreFilters?: boolean;
pullRequestsOnly?: boolean;
@@ -62,6 +61,7 @@ export function useInboxAllReports(options?: {
*/
applyPrFilter?: boolean;
}) {
+ const enabled = options?.enabled ?? true;
const ignoreScope = options?.ignoreScope ?? false;
const ignoreFilters = options?.ignoreFilters ?? false;
const applyPrFilter = options?.applyPrFilter ?? false;
@@ -92,14 +92,17 @@ export function useInboxAllReports(options?: {
const prFilter = useInboxSignalsFilterStore((s) =>
ignoreFilters || !applyPrFilter ? "all" : s.prFilter,
);
+ const isForYou = !ignoreScope && scope === INBOX_SCOPE_FOR_YOU;
+ const teammateUuid = ignoreScope ? null : parseTeammateInboxScope(scope);
const client = useOptionalAuthenticatedClient();
- const { data: currentUser } = useCurrentUser({ client });
+ const { data: currentUser } = useCurrentUser({
+ client,
+ enabled: enabled && isForYou && teammateUuid === null,
+ });
// Reviewer scope is applied server-side via `suggested_reviewers`: "For you"
// filters on the current user, a teammate scope on theirs, "Entire project"
// and the Runs tab (`ignoreScope`) send nothing.
- const isForYou = !ignoreScope && scope === INBOX_SCOPE_FOR_YOU;
- const teammateUuid = ignoreScope ? null : parseTeammateInboxScope(scope);
const reviewerUuid =
teammateUuid ?? (isForYou ? (currentUser?.uuid ?? null) : null);
@@ -132,7 +135,7 @@ export function useInboxAllReports(options?: {
// filter, so hold the query until that uuid resolves rather than firing a
// throwaway project-wide fetch first. Other scopes don't depend on the
// user and run immediately.
- enabled: !isForYou || reviewerUuid != null,
+ enabled: enabled && (!isForYou || reviewerUuid != null),
refetchInterval: refetchIntervalMs,
refetchIntervalInBackground: false,
},
@@ -161,7 +164,7 @@ export function useInboxAllReports(options?: {
limit: 1,
},
{
- enabled: !isForYou || reviewerUuid != null,
+ enabled: enabled && (!isForYou || reviewerUuid != null),
refetchInterval: refetchIntervalMs,
refetchIntervalInBackground: false,
},
@@ -188,7 +191,8 @@ export function useInboxAllReports(options?: {
limit: 1,
},
{
- enabled: withReportsCount && (!isForYou || reviewerUuid != null),
+ enabled:
+ enabled && withReportsCount && (!isForYou || reviewerUuid != null),
refetchInterval: refetchIntervalMs,
refetchIntervalInBackground: false,
},
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxDecisionCount.test.tsx b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxDecisionCount.test.tsx
new file mode 100644
index 000000000000..a3a3c50a7551
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxDecisionCount.test.tsx
@@ -0,0 +1,72 @@
+import { INBOX_SCOPE_ENTIRE_PROJECT } from "@posthog/core/inbox/reportMembership";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { renderHook, waitFor } from "@testing-library/react";
+import type { ReactNode } from "react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const mockGetSignalReports = vi.hoisted(() => vi.fn());
+
+vi.mock("@posthog/ui/features/auth/authClient", () => ({
+ useOptionalAuthenticatedClient: () => ({
+ getSignalReports: mockGetSignalReports,
+ }),
+}));
+vi.mock("@posthog/ui/features/auth/useCurrentUser", () => ({
+ AUTH_SCOPED_QUERY_META: {},
+ useCurrentUser: () => ({ data: null }),
+}));
+vi.mock("@posthog/ui/features/inbox/stores/inboxReviewerScopeStore", () => ({
+ useInboxReviewerScopeStore: (
+ selector: (state: { scope: string }) => unknown,
+ ) => selector({ scope: INBOX_SCOPE_ENTIRE_PROJECT }),
+}));
+vi.mock("@posthog/ui/features/inbox/stores/inboxSignalsFilterStore", () => ({
+ useInboxSignalsFilterStore: (selector: (state: unknown) => unknown) =>
+ selector({
+ sourceProductFilter: ["github"],
+ priorityFilter: ["P1"],
+ prFilter: "all",
+ }),
+}));
+
+import { useInboxDecisionCount } from "./useInboxDecisionCount";
+
+function renderCount(enabled: boolean) {
+ const queryClient = new QueryClient({
+ defaultOptions: { queries: { retry: false } },
+ });
+ const wrapper = ({ children }: { children: ReactNode }) => (
+ <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
+ );
+ return renderHook(
+ () => useInboxDecisionCount({ enabled, ignoreFilters: true }),
+ { wrapper },
+ );
+}
+
+describe("useInboxDecisionCount", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ mockGetSignalReports.mockResolvedValue({ count: 7, results: [] });
+ });
+
+ it("loads only a one-row server count for the navigation badge", async () => {
+ const { result } = renderCount(true);
+
+ await waitFor(() => expect(result.current).toBe(7));
+ expect(mockGetSignalReports).toHaveBeenCalledOnce();
+ expect(mockGetSignalReports).toHaveBeenCalledWith(
+ expect.objectContaining({
+ limit: 1,
+ priority: undefined,
+ source_product: undefined,
+ status: "ready",
+ }),
+ );
+ });
+
+ it("does not request a count when the navigation item is unavailable", () => {
+ expect(renderCount(false).result.current).toBe(0);
+ expect(mockGetSignalReports).not.toHaveBeenCalled();
+ });
+});
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxDecisionCount.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxDecisionCount.ts
index 080faa1c2292..4e00c6dfd536 100644
--- a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxDecisionCount.ts
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxDecisionCount.ts
@@ -1,12 +1,75 @@
-import { useInboxSectionCounts } from "@posthog/ui/features/inbox/hooks/useInboxSectionCounts";
+import {
+ buildPriorityFilterParam,
+ buildSuggestedReviewerFilterParam,
+} from "@posthog/core/inbox/reportFiltering";
+import {
+ INBOX_SCOPE_FOR_YOU,
+ parseTeammateInboxScope,
+} from "@posthog/core/inbox/reportMembership";
+import { useOptionalAuthenticatedClient } from "@posthog/ui/features/auth/authClient";
+import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";
+import { useInboxReports } from "@posthog/ui/features/inbox/hooks/useInboxReports";
+import { useInboxReviewerScopeStore } from "@posthog/ui/features/inbox/stores/inboxReviewerScopeStore";
+import { useInboxSignalsFilterStore } from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
+
+const EMPTY_FILTER_ARRAY: never[] = [];
/**
- * The number the inbox badges show: the server-side count of ready reports
- * under the current reviewer scope (and any persisted source/priority
- * filters). The same count the inbox page's "Needs a decision" header shows,
- * from the same queries — so the badge and the page cannot disagree, and
- * neither depends on how many pages a client happened to load.
+ * The navigation badge needs only the ready-report count. Keeping it separate
+ * from `useInboxSectionCounts` avoids polling the other two section counts on
+ * every route.
*/
-export function useInboxDecisionCount(): number {
- return useInboxSectionCounts().decision;
+export function useInboxDecisionCount(options?: {
+ enabled?: boolean;
+ ignoreFilters?: boolean;
+}): number {
+ const enabled = options?.enabled ?? true;
+ const ignoreFilters = options?.ignoreFilters ?? false;
+ const scope = useInboxReviewerScopeStore((state) => state.scope);
+ const sourceProductFilter = useInboxSignalsFilterStore((state) =>
+ ignoreFilters ? EMPTY_FILTER_ARRAY : state.sourceProductFilter,
+ );
+ const priorityFilter = useInboxSignalsFilterStore((state) =>
+ ignoreFilters ? EMPTY_FILTER_ARRAY : state.priorityFilter,
+ );
+ const prFilter = useInboxSignalsFilterStore((state) =>
+ ignoreFilters ? "all" : state.prFilter,
+ );
+ const isForYou = scope === INBOX_SCOPE_FOR_YOU;
+ const teammateUuid = parseTeammateInboxScope(scope);
+ const client = useOptionalAuthenticatedClient();
+ const { data: currentUser } = useCurrentUser({
+ client,
+ enabled: enabled && isForYou && teammateUuid === null,
+ });
+ const reviewerUuid =
+ teammateUuid ?? (isForYou ? (currentUser?.uuid ?? null) : null);
+ const scopeReady = !isForYou || reviewerUuid !== null;
+ const query = useInboxReports(
+ {
+ status: "ready",
+ has_implementation_pr:
+ prFilter === "with_pr"
+ ? true
+ : prFilter === "without_pr"
+ ? false
+ : undefined,
+ source_product:
+ sourceProductFilter.length > 0
+ ? sourceProductFilter.join(",")
+ : undefined,
+ priority: buildPriorityFilterParam(priorityFilter),
+ suggested_reviewers: reviewerUuid
+ ? buildSuggestedReviewerFilterParam([reviewerUuid])
+ : undefined,
+ limit: 1,
+ },
+ {
+ enabled: enabled && scopeReady,
+ refetchInterval: 60_000,
+ refetchIntervalInBackground: false,
+ },
+ );
+
+ return enabled ? (query.data?.count ?? 0) : 0;
}
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxSourceFilterOptions.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxSourceFilterOptions.ts
index 0a7fcda68ef4..6e4c2f8a6963 100644
--- a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxSourceFilterOptions.ts
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxSourceFilterOptions.ts
@@ -14,8 +14,9 @@ import { useMemo } from "react";
*/
export function useInboxSourceFilterOptions(
selected: SourceProduct[],
+ options?: { enabled?: boolean },
): InboxSourceOption[] {
- const { data: configs } = useSignalSourceConfigs();
+ const { data: configs } = useSignalSourceConfigs(options);
return useMemo(() => {
if (!configs) {
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useSignalSourceConfigs.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useSignalSourceConfigs.ts
index 23a3eb42ccde..1f440073c52b 100644
--- a/products/desktop/packages/ui/src/features/inbox/hooks/useSignalSourceConfigs.ts
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useSignalSourceConfigs.ts
@@ -2,7 +2,7 @@ import type { SignalSourceConfig } from "@posthog/api-client/posthog-client";
import { useAuthenticatedQuery } from "../../../hooks/useAuthenticatedQuery";
import { useAuthStateValue } from "../../auth/store";
-export function useSignalSourceConfigs() {
+export function useSignalSourceConfigs(options?: { enabled?: boolean }) {
const projectId = useAuthStateValue((state) => state.currentProjectId);
return useAuthenticatedQuery<SignalSourceConfig[]>(
["signals", "source-configs", projectId],
@@ -10,6 +10,9 @@ export function useSignalSourceConfigs() {
projectId
? client.listSignalSourceConfigs(projectId)
: Promise.resolve([]),
- { enabled: !!projectId, staleTime: 30_000 },
+ {
+ enabled: !!projectId && (options?.enabled ?? true),
+ staleTime: 30_000,
+ },
);
}
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useTrackInboxViewed.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useTrackInboxViewed.ts
index 2121a73aea1a..75630702d9a1 100644
--- a/products/desktop/packages/ui/src/features/inbox/hooks/useTrackInboxViewed.ts
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useTrackInboxViewed.ts
@@ -10,11 +10,12 @@ import { useEffect, useRef } from "react";
* with the counts the user sees on load (tab badges, total, ready, and the
* priority/actionability breakdown of the visible reports).
*
- * Restores the event dropped when Inbox 2.0 deleted `InboxSignalsTab`. Mounted
- * from `InboxView`, so it fires once per visit and survives tab switches (the
- * shell stays mounted while the `<Outlet />` swaps tab bodies).
+ * Mounted from `InboxView` for the legacy tabbed inbox, so it fires once per
+ * visit and survives tab switches. The sectioned reports inbox tracks from its
+ * existing list and count data to avoid mounting these legacy queries.
*/
-export function useTrackInboxViewed(): void {
+export function useTrackInboxViewed(options?: { enabled?: boolean }): void {
+ const enabled = options?.enabled ?? true;
const {
scopedReports,
totalCount,
@@ -27,11 +28,11 @@ export function useTrackInboxViewed(): void {
searchQuery,
// The badge counts come from their own requests, so opt in here too or the
// event records a zero the user never saw.
- } = useInboxAllReports({ withReportsCount: true });
+ } = useInboxAllReports({ enabled, withReportsCount: true });
const firedRef = useRef(false);
useEffect(() => {
- if (firedRef.current) return;
+ if (!enabled || firedRef.current) return;
// Gate on a successful load, not just `!isLoading`: an errored initial
// request also leaves `isLoading` false with an empty list, and `firedRef`
// would then lock in a bogus empty-inbox view that a later refetch can't fix.
@@ -65,5 +66,6 @@ export function useTrackInboxViewed(): void {
sourceProductFilter,
priorityFilter,
searchQuery,
+ enabled,
]);
}
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useTrackReportsInboxViewed.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useTrackReportsInboxViewed.ts
new file mode 100644
index 000000000000..e8bba9416009
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useTrackReportsInboxViewed.ts
@@ -0,0 +1,52 @@
+import { buildInboxViewedProperties } from "@posthog/core/inbox/engagement";
+import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";
+import type { SignalReport } from "@posthog/shared/types";
+import { track } from "@posthog/ui/shell/analytics";
+import { useEffect, useRef } from "react";
+
+export function useTrackReportsInboxViewed({
+ reports,
+ totalCount,
+ isReady,
+ sourceProductFilter,
+ priorityFilter,
+ searchQuery,
+ isDefaultScope,
+}: {
+ reports: SignalReport[];
+ totalCount: number;
+ isReady: boolean;
+ sourceProductFilter: string[];
+ priorityFilter: string[];
+ searchQuery: string;
+ isDefaultScope: boolean;
+}): void {
+ const firedRef = useRef(false);
+
+ useEffect(() => {
+ if (!isReady || firedRef.current) return;
+ firedRef.current = true;
+ track(
+ ANALYTICS_EVENTS.INBOX_VIEWED,
+ buildInboxViewedProperties({
+ visibleReports: reports,
+ totalCount,
+ filters: {
+ surface: "desktop",
+ sourceProductFilter,
+ priorityFilter,
+ searchQuery,
+ isDefaultScope,
+ },
+ }),
+ );
+ }, [
+ reports,
+ totalCount,
+ isReady,
+ sourceProductFilter,
+ priorityFilter,
+ searchQuery,
+ isDefaultScope,
+ ]);
+}
diff --git a/products/desktop/packages/ui/src/features/inbox/stores/inboxSignalsFilterStore.ts b/products/desktop/packages/ui/src/features/inbox/stores/inboxSignalsFilterStore.ts
index 2daca2e1597a..2d8715ac21bf 100644
--- a/products/desktop/packages/ui/src/features/inbox/stores/inboxSignalsFilterStore.ts
+++ b/products/desktop/packages/ui/src/features/inbox/stores/inboxSignalsFilterStore.ts
@@ -33,6 +33,7 @@ interface InboxSignalsFilterActions {
setSort: (field: SignalSortField, direction: SignalSortDirection) => void;
setSearchQuery: (query: string) => void;
toggleSourceProduct: (source: SourceProduct) => void;
+ setSourceProductFilter: (sources: SourceProduct[]) => void;
togglePriority: (priority: SignalReportPriority) => void;
setPriorityFilter: (priorities: SignalReportPriority[]) => void;
setPrFilter: (prFilter: InboxPrFilter) => void;
@@ -92,6 +93,8 @@ export const useInboxSignalsFilterStore = create<InboxSignalsFilterStore>()(
: [...current, source];
return { sourceProductFilter: next };
}),
+ setSourceProductFilter: (sources) =>
+ set({ sourceProductFilter: Array.from(new Set(sources)) }),
togglePriority: (priority) =>
set((state) => {
const current = state.priorityFilter;
diff --git a/products/desktop/packages/ui/src/features/navigation/useActiveSession.ts b/products/desktop/packages/ui/src/features/navigation/useActiveSession.ts
index a7af74c53686..0d2d5efe6fc4 100644
--- a/products/desktop/packages/ui/src/features/navigation/useActiveSession.ts
+++ b/products/desktop/packages/ui/src/features/navigation/useActiveSession.ts
@@ -19,9 +19,10 @@ export function useActiveSession(): ActiveSession {
const params = useParams({ strict: false });
if (showsActivityDetail) {
+ const taskSelection = selected?.kind === "task" ? selected : null;
return {
- taskId: selected?.taskId,
- channelId: selected?.channelId ?? undefined,
+ taskId: taskSelection?.taskId,
+ channelId: taskSelection?.channelId ?? undefined,
};
}
if (params.feedId && feedSelected?.feedId === params.feedId) {
diff --git a/products/desktop/packages/ui/src/features/sidebar/components/SidebarNavSection.tsx b/products/desktop/packages/ui/src/features/sidebar/components/SidebarNavSection.tsx
index 6ad7ad2f7ce8..da25de733c17 100644
--- a/products/desktop/packages/ui/src/features/sidebar/components/SidebarNavSection.tsx
+++ b/products/desktop/packages/ui/src/features/sidebar/components/SidebarNavSection.tsx
@@ -4,6 +4,7 @@ import {
type SidebarNavItem,
} from "@posthog/shared/analytics-events";
import { useOpenBrowserTab } from "@posthog/ui/features/browser-tabs/useOpenBrowserTab";
+import { useActivityFilterStore } from "@posthog/ui/features/canvas/stores/activityFilterStore";
import { useCommandCenterActiveCount } from "@posthog/ui/features/command-center/useCommandCenterActiveCount";
import { useChannelReportsEnabled } from "@posthog/ui/features/feature-flags/useChannelReportsEnabled";
import { useContextLayerFlag } from "@posthog/ui/features/feature-flags/useContextLayerFlag";
@@ -77,7 +78,15 @@ export function SidebarNavSection({
// inbox disappears as a destination.
const channelReportsEnabled = useChannelReportsEnabled();
const reportsInboxEnabled = useReportsInboxEnabled();
- const inboxDecisionCount = useInboxDecisionCount();
+ const mentionsEnabled = useActivityFilterStore(
+ (state) => state.mentionsEnabled,
+ );
+ const navItemOverrides = useSidebarStore((s) => s.navItemOverrides);
+ const navItemOrder = useSidebarStore((s) => s.navItemOrder);
+ const inboxAvailable = !channelReportsEnabled || reportsInboxEnabled;
+ const inboxVisible =
+ inboxAvailable && isNavItemVisible(navItemOverrides, "inbox");
+ const inboxDecisionCount = useInboxDecisionCount({ enabled: inboxVisible });
const contextEnabled = useContextLayerFlag();
const inSpaces = useRouterState({
select: (state) => state.location.pathname.startsWith("/spaces"),
@@ -129,8 +138,6 @@ export function SidebarNavSection({
action();
};
- const navItemOverrides = useSidebarStore((s) => s.navItemOverrides);
- const navItemOrder = useSidebarStore((s) => s.navItemOrder);
const orderedItems = orderedNavItems(navItemOrder);
const hidden = new Set<CustomizableNavItemId>(
CUSTOMIZABLE_NAV_ITEM_IDS.filter(
@@ -140,7 +147,7 @@ export function SidebarNavSection({
const navItemAvailable: Record<CustomizableNavItemId, boolean> = {
// The global reports inbox reclaims the slot from the channel-reports
// takeover; without it, spaces own reports and the entry goes away.
- inbox: !channelReportsEnabled || reportsInboxEnabled,
+ inbox: inboxAvailable,
"command-center": true,
contexts: contextEnabled,
activity: bluebirdEnabled,
@@ -181,6 +188,7 @@ export function SidebarNavSection({
<ActivityItem
depth={depth}
isActive={isActivityActive}
+ mentionsEnabled={mentionsEnabled}
onClick={withNavTrack("activity", navigateToActivity, depth, {
href: "/activity",
})}
diff --git a/products/desktop/packages/ui/src/features/sidebar/components/items/ActivityItem.test.tsx b/products/desktop/packages/ui/src/features/sidebar/components/items/ActivityItem.test.tsx
index 94d7596d5552..5a3fee3963f2 100644
--- a/products/desktop/packages/ui/src/features/sidebar/components/items/ActivityItem.test.tsx
+++ b/products/desktop/packages/ui/src/features/sidebar/components/items/ActivityItem.test.tsx
@@ -2,8 +2,9 @@ import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, expect, it, vi } from "vitest";
+const useTaskActivity = vi.hoisted(() => vi.fn(() => ({ unreadCount: 2 })));
vi.mock("@posthog/ui/features/canvas/hooks/useTaskActivity", () => ({
- useTaskActivity: () => ({ unreadCount: 2 }),
+ useTaskActivity,
}));
vi.mock("@posthog/ui/features/canvas/components/ActivityHoverCard", () => ({
ActivityHoverCard: () => <div>Recent activity card</div>,
@@ -16,7 +17,7 @@ describe("ActivityItem", () => {
const onClick = vi.fn();
const user = userEvent.setup();
const { container } = render(
- <ActivityItem isActive={false} onClick={onClick} />,
+ <ActivityItem isActive={false} onClick={onClick} mentionsEnabled />,
);
expect(container.querySelectorAll("button")).toHaveLength(1);
@@ -27,9 +28,24 @@ describe("ActivityItem", () => {
});
it("keeps the active Activity row enabled without mounting a popover", () => {
- const { container } = render(<ActivityItem isActive onClick={vi.fn()} />);
+ const { container } = render(
+ <ActivityItem isActive onClick={vi.fn()} mentionsEnabled />,
+ );
expect(screen.getByRole("button", { name: /Activity/ })).toBeEnabled();
expect(container.querySelector("[aria-haspopup]")).not.toBeInTheDocument();
});
+
+ it("stops mention polling and hides its badge when mentions are excluded", () => {
+ render(
+ <ActivityItem
+ isActive={false}
+ onClick={vi.fn()}
+ mentionsEnabled={false}
+ />,
+ );
+
+ expect(useTaskActivity).toHaveBeenCalledWith({ enabled: false });
+ expect(screen.queryByText("2")).not.toBeInTheDocument();
+ });
});
diff --git a/products/desktop/packages/ui/src/features/sidebar/components/items/ActivityItem.tsx b/products/desktop/packages/ui/src/features/sidebar/components/items/ActivityItem.tsx
index 6b7df3316099..0da631fb5829 100644
--- a/products/desktop/packages/ui/src/features/sidebar/components/items/ActivityItem.tsx
+++ b/products/desktop/packages/ui/src/features/sidebar/components/items/ActivityItem.tsx
@@ -9,6 +9,7 @@ import { SidebarCountBadge } from "./SidebarCountBadge";
interface ActivityItemProps {
isActive: boolean;
onClick: MouseEventHandler<Element>;
+ mentionsEnabled: boolean;
depth?: number;
}
@@ -18,9 +19,13 @@ interface ActivityItemProps {
export function ActivityItem({
isActive,
onClick,
+ mentionsEnabled,
depth = 0,
}: ActivityItemProps) {
- const { unreadCount } = useTaskActivity();
+ const { unreadCount: taskUnreadCount } = useTaskActivity({
+ enabled: mentionsEnabled,
+ });
+ const unreadCount = mentionsEnabled ? taskUnreadCount : 0;
const [open, setOpen] = useState(false);
const suppressClickOpenRef = useRef(false);
const item = (
diff --git a/products/desktop/packages/ui/src/router/navigationBridge.ts b/products/desktop/packages/ui/src/router/navigationBridge.ts
index 6175e5d9f06e..5d3b055da722 100644
--- a/products/desktop/packages/ui/src/router/navigationBridge.ts
+++ b/products/desktop/packages/ui/src/router/navigationBridge.ts
@@ -124,6 +124,10 @@ export function navigateToInbox(): void {
void getRouterOrNull()?.navigate({ to: "/inbox" });
}
+export function navigateToInboxReports(): void {
+ void getRouterOrNull()?.navigate({ to: "/inbox/reports" });
+}
+
export function navigateToInboxPullRequestDetail(reportId: string): void {
void getRouterOrNull()?.navigate({
to: "/inbox/pulls/$reportId",