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): give self-driving its own rail column (#98441)

Adam Leithaa7bc2e558e2
diff --git a/products/desktop/AGENTS.md b/products/desktop/AGENTS.md
index 89872f8c2f15..ecae316b2f69 100644
--- a/products/desktop/AGENTS.md
+++ b/products/desktop/AGENTS.md
@@ -331,6 +331,7 @@ Pulling in a Radix package is not the fallback.
- No barrel files (`index.ts`).
- Use Tailwind first. Keep classes sorted. Use inline `style` only for runtime values, library configuration, or CSS variables.
- Empty/placeholder/loading screens (canvas and elsewhere) are a `@posthog/quill` `<Empty>` (`EmptyHeader` → `EmptyMedia variant="icon"` → `EmptyTitle` → `EmptyDescription`, then `EmptyContent` for CTAs). Don't hand-roll the centered Flex + dashed icon box. CTAs are quill `Button`s: primary action `variant="primary"`, secondary `variant="outline"`, `size="default"`. For a link CTA use `render={<Link … />}` (Base UI), not `asChild`.
+- The bar across the top of a pane, a column or a side panel is `ChromeBar` (`packages/ui/src/primitives`), never a hand-written row. It fixes the height at 40px, the border and the colour; the caller supplies the breadcrumb, title or search header inside it and the controls through `actions`. `inset` says how far from the edges the contents sit: `control` when the bar starts with a button, `text` when it starts with a label, `even` for a bar with the same padding both ends. Fifteen copies of this row had drifted into three border colours and four paddings before it existed.
- Loading indicators are `Spinner` and `LoadingState` from `packages/ui/src/primitives`. `LoadingState` fills a pane or section while its data loads (24px spinner, optional label). `Spinner` sits inline in a button, row or badge; omit `size` inside quill buttons and media slots so it matches the icons beside it, and pick `xs`/`sm`/`md`/`lg` elsewhere. Do not import `Spinner` from `@posthog/quill` or `@radix-ui/themes`, and do not spin phosphor's `CircleNotch` or `SpinnerGap`: Biome rejects those imports. Pass `aria-hidden="true"` when the spinner sits next to visible loading text or inside an element that already announces the loading state, so the label is not read twice. The braille `DotsCircleSpinner` and `DotRingSpinner` mark agent activity (a running tool call, a working task), not data loading.
- Abort controllers before awaiting cleanup that depends on them.
diff --git a/products/desktop/docs/SELF-DRIVING-REPORTS.md b/products/desktop/docs/SELF-DRIVING-REPORTS.md
new file mode 100644
index 000000000000..2c5dfdac0ca3
--- /dev/null
+++ b/products/desktop/docs/SELF-DRIVING-REPORTS.md
@@ -0,0 +1,31 @@
+# Self-driving reports
+
+Every report starts with a Summary tab. Reports with a pull request also have a Changed code tab.
+The report text does not repeat the Summary heading.
+The title shows the change type and scope. The metadata row shows the time and links to related work.
+Priority and reviewer scope remain in the report list. Evidence counts remain in the Evidence section, which starts expanded.
+
+Chat opens the report conversation beside the document, including an existing implementation session when one is available.
+Select text in either report view to ask about that passage.
+Reports with a PR show Open in GitHub as the first header button, followed by Chat.
+Copy-link options are in the More report actions menu. Report actions do not offer canvas creation.
+
+A draft pull request shows the approval and merge controls, a draft note, and a secondary Ready for review button.
+Marking a draft ready does not approve or merge it. Existing merge checks still apply.
+Eligible pull requests show Refund in the header. The existing feature flag, billing checks, and confirmation dialog still apply.
+
+The report ends with feedback after its evidence, reviewers, and other supporting sections.
+The recommendation keeps its boxed layout and its Ask about it and Dismiss controls.
+
+Informational recommendations, including Likely already fixed, use a blue callout. Decisions use an amber callout.
+Unread reports show a small blue dot in the list. Open a report to mark it as read without dismissing or resolving it.
+Select the dot or use the right-click menu to mark a report as read or unread. Read reports stay in the list.
+Read state is saved on this device for the current user and project. It does not sync across devices or recover earlier report visits.
+Select Triage mode to review reports in sequence.
+Triage hides the sidebar. Exiting triage or opening a report restores it without changing its saved width or open setting.
+Press T from the report list or an open report to start triage when triage is enabled. The shortcut does not run while you type in a field.
+
+To filter reports for a user, open Filter reports, then hover over Scope.
+Hover opens the user list without moving keyboard focus. Click the search field to type, or use the keyboard to open Scope and focus the search field.
+The search starts empty and shows up to 20 options, including For you and Entire project.
+Search by name or email across all users. The search field stays visible above the results.
diff --git a/products/desktop/packages/core/src/inbox/reportAgeGroups.test.ts b/products/desktop/packages/core/src/inbox/reportAgeGroups.test.ts
new file mode 100644
index 000000000000..8e665473d82a
--- /dev/null
+++ b/products/desktop/packages/core/src/inbox/reportAgeGroups.test.ts
@@ -0,0 +1,63 @@
+import type { SignalReport } from "@posthog/shared/types";
+import { describe, expect, it } from "vitest";
+import { groupReportsByAge } from "./reportAgeGroups";
+
+const DAY = 24 * 60 * 60 * 1000;
+
+function report(id: string, daysAgo: number): SignalReport {
+ const createdAt = new Date(Date.now() - daysAgo * DAY).toISOString();
+ return {
+ id,
+ title: id,
+ summary: null,
+ status: "ready",
+ total_weight: 0,
+ signal_count: 0,
+ created_at: createdAt,
+ updated_at: createdAt,
+ artefact_count: 0,
+ };
+}
+
+describe("groupReportsByAge", () => {
+ it("widens the buckets with age instead of naming every day", () => {
+ expect(
+ groupReportsByAge([
+ report("now", 0),
+ report("earlier-today", 0),
+ report("yesterday", 1),
+ report("this-week", 3),
+ report("this-month", 12),
+ report("older", 90),
+ ]).map((group) => [group.label, ...group.reports.map((r) => r.id)]),
+ ).toEqual([
+ ["Today", "now", "earlier-today"],
+ ["Yesterday", "yesterday"],
+ ["This week", "this-week"],
+ ["This month", "this-month"],
+ ["Earlier", "older"],
+ ]);
+ });
+
+ it("keeps the list's own order inside each bucket, newest bucket first", () => {
+ expect(
+ groupReportsByAge([
+ report("p0-this-month", 12),
+ report("p1-today", 0),
+ report("p2-this-month", 14),
+ ]).map((group) => [group.label, ...group.reports.map((r) => r.id)]),
+ ).toEqual([
+ ["Today", "p1-today"],
+ ["This month", "p0-this-month", "p2-this-month"],
+ ]);
+ });
+
+ it("runs the buckets oldest first when the list is sorted that way", () => {
+ expect(
+ groupReportsByAge(
+ [report("today", 0), report("yesterday", 1), report("older", 90)],
+ { oldestFirst: true },
+ ).map((group) => group.label),
+ ).toEqual(["Earlier", "Yesterday", "Today"]);
+ });
+});
diff --git a/products/desktop/packages/core/src/inbox/reportAgeGroups.ts b/products/desktop/packages/core/src/inbox/reportAgeGroups.ts
new file mode 100644
index 000000000000..84ac74326ead
--- /dev/null
+++ b/products/desktop/packages/core/src/inbox/reportAgeGroups.ts
@@ -0,0 +1,42 @@
+import { getRelativeDateGroup } from "@posthog/shared";
+import type { SignalReport } from "@posthog/shared/types";
+
+export interface ReportAgeGroup {
+ label: string;
+ reports: SignalReport[];
+}
+
+const AGE_ORDER = [
+ "Today",
+ "Yesterday",
+ "This week",
+ "This month",
+ "Earlier",
+] as const;
+
+/**
+ * The buckets widen with age (`getRelativeDateGroup`, the same ones the task
+ * list uses) because reports arrive over weeks: a separator per calendar day
+ * left most of this list one row per header.
+ */
+export function groupReportsByAge(
+ reports: readonly SignalReport[],
+ options: { now?: Date; oldestFirst?: boolean } = {},
+): ReportAgeGroup[] {
+ const now = options.now ?? new Date();
+ const buckets = new Map<string, SignalReport[]>();
+ for (const report of reports) {
+ // A clock skewed ahead of ours would otherwise fall out of every bucket.
+ const timestamp = Math.min(new Date(report.created_at).getTime(), +now);
+ const label = getRelativeDateGroup(timestamp) ?? "Today";
+ const bucket = buckets.get(label);
+ if (bucket) bucket.push(report);
+ else buckets.set(label, [report]);
+ }
+ // Oldest first means oldest first, so the buckets run the other way too.
+ // Reading down the list otherwise contradicts the sort that built it.
+ const order = options.oldestFirst ? [...AGE_ORDER].reverse() : AGE_ORDER;
+ return order
+ .filter((label) => buckets.has(label))
+ .map((label) => ({ label, reports: buckets.get(label) ?? [] }));
+}
diff --git a/products/desktop/packages/ui/src/features/canvas/AGENTS.md b/products/desktop/packages/ui/src/features/canvas/AGENTS.md
index 4c2f2183e69a..cac26a700f97 100644
--- a/products/desktop/packages/ui/src/features/canvas/AGENTS.md
+++ b/products/desktop/packages/ui/src/features/canvas/AGENTS.md
@@ -25,6 +25,13 @@ changing breadcrumbs, canvas naming, or the canvas generation harness. The root
other surface. Trust the defaults. Layout-only utilities (`flex`, `gap`,
width/`max-w`, `truncate`) on wrappers are fine; reach for `className` overrides
on Quill items only when there is a real, deliberate exception — and call it out.
+- **A list's filter menu is `primitives/FilterMenu`, not a new one.** The funnel
+ button with its active dot, the "Label value ›" rows, the radio and
+ checkbox submenus, and the destructive "Clear filters" footer are one set of
+ parts. Canvases, Activity and Self-driving all draw them; three hand-written
+ copies drifted in spacing and in what counted as "active". A new filter is a
+ `FilterRadioSubMenu` or `FilterCheckboxSubMenu` with an option table, and a
+ filter whose default is a selection rather than an empty one passes `active`.
- **Suffix `…` on anything that opens another step.** A menu item or button whose
click opens a follow-up surface — a dialog, a nested menu, a picker, a
confirmation — gets a trailing ellipsis (`…`, the character, not three dots) to
@@ -45,9 +52,17 @@ changing breadcrumbs, canvas naming, or the canvas generation harness. The root
Canonical report pages (`/reports/$reportId`) are not a new rail button.
`useRailPane` keeps the source pane from the validated `?from=` search param;
a report with no source selects no rail button and has no contextual sidebar.
+ It reads one thing, the location being navigated to. `location`, `matches` and
+ `resolvedLocation` land at different points in a transition, so a rule mixing
+ two of them answers with a destination neither is on, and the column blinks
+ off and back mid-navigation.
Space and feed sources retain their own sidebar, not the report's owning space.
- Only Spaces and Activity own the column beside the rail; the rest are
- whole-screen, so no route under them may draw a second nav.
+ Spaces, Activity and Self-driving own the column beside the rail; the rest
+ are whole-screen, so no route under them may draw a second nav.
+- **The column's contents are a dispatch, not a conditional chain.**
+ `RailPaneBody` (`ChannelsSidebar.tsx`) returns the pane for the destination,
+ so a new destination adds a case rather than another rung on a nested ternary
+ the next reader has to unwind.
- **A rail pick returns you to where that destination was**, not to its index.
`BrowserTabStrip` records the settled route per destination in the active
tab's `viewState.lastByPane`, and `pickRailDestination` replays it. Only Spaces
@@ -57,6 +72,15 @@ changing breadcrumbs, canvas naming, or the canvas generation harness. The root
Anything a destination does besides navigating must live in its route
component, not its `onPick`: the restore path navigates by href and never
reaches the navigation bridge.
+ A destination that owns a column is never somewhere else when you are in it,
+ so its `onReclick` hands the keyboard to the column's search rather than
+ navigating to its root. Navigating there would close what you are reading and
+ then record the emptied route as where you were, which is how a destination
+ forgets. Spaces is the exception only in what it does instead: it shows the
+ list, the one thing above the space you are in.
+ Both ends ask which destination an href belongs to, and the answer comes from
+ `railPaneForHref` — the href, never the route pattern, because a report page
+ belongs to the list that opened it and only its `?from=` says which.
Both ends share `isRestorableVisitHref` (`railPane.ts`): the writer never records an href a click may not restore (settings, folder settings, redirect aliases) and the restore path re-checks the stored one, so bad persisted state falls through to the destination's root.
- **Testing flag-off locally:** dev builds default `project-bluebird` and
`code-spaces-layout` on, and that default beats posthog's own override. Force
@@ -240,6 +264,19 @@ changing breadcrumbs, canvas naming, or the canvas generation harness. The root
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.
+- **An empty pane that says "pick something from the list" offers a way back to
+ a collapsed one.** The sidebar collapses with ⌘B and the rail stays, so a pane
+ whose empty state points at the list can be the only thing on screen with no
+ list beside it. Those empty states carry `OpenSidebarButton`
+ (`features/sidebar/components`), which draws nothing while the sidebar is on
+ screen. Activity, saved searches, canvases and Self-driving all use it; a new
+ rail destination with a list and a detail pane joins them.
+- **Every Activity detail header must have a close button.** This rule applies
+ to sessions, Self-driving reports, and each future item type that Activity
+ renders. The button must call the shared Activity route helper. It must clear
+ the search selection and keep the user on `/activity`, so the main panel
+ returns to its empty state. Keep the session close button available when the
+ shell cannot resolve `TaskHeaderActions`.
- **An activity row acts on its task from the same menu the spaces surfaces use.** `useActivityTaskMenu` builds one `TaskRowMenuProps` per row and `ActivityRow` hangs it off a `TaskRowDropdownMenu`, beside the mark-read and copy-link buttons the row already reveals on hover, so pin, "Add to Command Center", "File to…" and Archive can't drift from the space lists.
Rename, hand off and analysis are the items the feed drops: the first needs an inline editor the feed has no row for, and the other two need the task itself, which an activity row does not carry.
The actions are built once for the feed and handed to the rows, the way `useSpaceTaskActions` serves the tree — one pin and one archive mutation for the page instead of one per row.
@@ -273,6 +310,11 @@ changing breadcrumbs, canvas naming, or the canvas generation harness. The root
dashboard's name is the h1 below, not a crumb.
- Crumbs reflect navigable parents above the current page; the current page is
the H1, never a crumb of itself.
+- **A control that acts on the leaf rides with the leaf.** Copy-link buttons go
+ in `ChannelBreadcrumb`'s `leafTrailing`, beside the name, the way a thread's
+ does (`CopyThreadLinkButton`, `CopyCanvasLinkButton`). The bar's far end is
+ for actions on the page as a whole (Edit, New canvas, the overflow menu); a
+ copy button parked out there reads as unrelated to the thing it copies.
## Canvas naming
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailCloseButton.stories.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailCloseButton.stories.tsx
new file mode 100644
index 000000000000..aa1958fe1ec9
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailCloseButton.stories.tsx
@@ -0,0 +1,13 @@
+import { ActivityDetailCloseButton } from "@posthog/ui/features/canvas/components/ActivityDetailCloseButton";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+
+const meta: Meta<typeof ActivityDetailCloseButton> = {
+ title: "Canvas/Activity/Detail close button",
+ component: ActivityDetailCloseButton,
+ parameters: { layout: "centered" },
+};
+
+export default meta;
+type Story = StoryObj<typeof ActivityDetailCloseButton>;
+
+export const Default: Story = {};
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailCloseButton.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailCloseButton.tsx
new file mode 100644
index 000000000000..36edebbf53aa
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailCloseButton.tsx
@@ -0,0 +1,31 @@
+import { XIcon } from "@phosphor-icons/react";
+import {
+ Button,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@posthog/quill";
+import { clearActivitySelection } from "@posthog/ui/features/canvas/stores/activityDetailStore";
+
+export function ActivityDetailCloseButton() {
+ return (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ type="button"
+ variant="outline"
+ size="icon-sm"
+ className="no-drag shrink-0"
+ aria-label="Close activity item"
+ data-attr="activity-detail-close"
+ onClick={clearActivitySelection}
+ />
+ }
+ >
+ <XIcon size={14} />
+ </TooltipTrigger>
+ <TooltipContent side="bottom">Close activity item</TooltipContent>
+ </Tooltip>
+ );
+}
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
index 6f5dbb223052..02739a45f880 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailPane.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailPane.test.tsx
@@ -1,10 +1,12 @@
import type { SignalReport } from "@posthog/shared/types";
-import { render, screen } from "@testing-library/react";
+import { fireEvent, render, screen } from "@testing-library/react";
+import type { ReactNode } from "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,
+ clearSelection: vi.fn(),
}));
vi.mock("@posthog/ui/features/canvas/hooks/useChannels", () => ({
@@ -14,6 +16,7 @@ vi.mock("@posthog/ui/features/canvas/hooks/useInboxActivityPreview", () => ({
useInboxActivityPreview: () => ({ reports: mocks.reports }),
}));
vi.mock("@posthog/ui/features/canvas/stores/activityDetailStore", () => ({
+ clearActivitySelection: mocks.clearSelection,
useActivitySelection: () => mocks.selection,
}));
vi.mock("@posthog/ui/features/tasks/useResolvedTask", () => ({
@@ -30,14 +33,17 @@ vi.mock("@posthog/ui/features/inbox/components/ReportDetail", () => ({
reportId,
cachedReport,
statusRedirect,
+ headerTrailingAction,
}: {
reportId: string;
cachedReport?: SignalReport;
statusRedirect?: boolean;
+ headerTrailingAction?: ReactNode;
}) => (
<div data-testid="report-detail">
{reportId}:{cachedReport?.title}:
{statusRedirect === false ? "instant" : "loading"}
+ {headerTrailingAction}
</div>
),
}));
@@ -48,6 +54,7 @@ describe("ActivityDetailPane", () => {
beforeEach(() => {
mocks.reports = [];
mocks.selection = null;
+ mocks.clearSelection.mockClear();
});
it("renders a selected feed report immediately from the preview data", () => {
@@ -68,5 +75,8 @@ describe("ActivityDetailPane", () => {
expect(screen.getByTestId("report-detail")).toHaveTextContent(
"report-1:Checkout conversion dropped:instant",
);
+
+ fireEvent.click(screen.getByLabelText("Close activity item"));
+ expect(mocks.clearSelection).toHaveBeenCalledOnce();
});
});
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 43c6ecc412db..015dbe080c16 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailPane.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityDetailPane.tsx
@@ -1,15 +1,18 @@
import { BellIcon } from "@phosphor-icons/react";
import {
Empty,
+ EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
} from "@posthog/quill";
+import { ActivityDetailCloseButton } from "@posthog/ui/features/canvas/components/ActivityDetailCloseButton";
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 { OpenSidebarButton } from "@posthog/ui/features/sidebar/components/OpenSidebarButton";
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";
@@ -36,6 +39,9 @@ export function ActivityDetailPane() {
Pick something from the feed to read it here.
</EmptyDescription>
</EmptyHeader>
+ <EmptyContent>
+ <OpenSidebarButton />
+ </EmptyContent>
</Empty>
</div>
);
@@ -53,6 +59,7 @@ export function ActivityDetailPane() {
backTo="/activity"
backLabel="Back to activity"
statusRedirect={false}
+ headerTrailingAction={<ActivityDetailCloseButton />}
/>
</div>
);
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ActivityIncludeMenuSection.tsx b/products/desktop/packages/ui/src/features/canvas/components/ActivityIncludeMenuSection.tsx
index ff1910131e21..e6b95f1919fc 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ActivityIncludeMenuSection.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ActivityIncludeMenuSection.tsx
@@ -1,17 +1,9 @@
import { getAuthIdentity } from "@posthog/core/auth/authIdentity";
import {
- cn,
DropdownMenuCheckboxItem,
- DropdownMenuItem,
- 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,
@@ -20,60 +12,34 @@ import {
} from "@posthog/ui/features/canvas/stores/activityFilterStore";
import { useReportsInboxEnabled } from "@posthog/ui/features/feature-flags/useReportsInboxEnabled";
import {
- INBOX_PRIORITY_OPTIONS,
- INBOX_SORT_OPTIONS,
+ INBOX_PRIORITY_MENU_OPTIONS,
+ INBOX_SORT_MENU_OPTIONS,
inboxPriorityFilterLabel,
+ inboxSortOptionFromKey,
+ inboxSortOptionKey,
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";
+import {
+ FilterCheckboxSubMenu,
+ FilterClearItem,
+ type FilterOption,
+ FilterRadioSubMenu,
+} from "@posthog/ui/primitives/FilterMenu";
+import type { ReactElement } from "react";
-const SCOPE_OPTIONS: readonly {
- value: ActivityInboxScope;
- label: string;
-}[] = [
+const SCOPE_OPTIONS: readonly FilterOption<ActivityInboxScope>[] = [
{ value: "for-you", label: "For you" },
{ value: "entire-project", label: "Entire project" },
];
-const REPORT_OPTIONS: readonly { value: InboxPrFilter; label: string }[] = [
+const REPORT_OPTIONS: readonly FilterOption<InboxPrFilter>[] = [
{ 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);
@@ -128,14 +94,6 @@ export function ActivityIncludeMenuSection(): ReactElement {
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>
@@ -160,169 +118,55 @@ export function ActivityIncludeMenuSection(): ReactElement {
<>
<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>
- </>
- )}
- {filtersActive && (
- <>
- <DropdownMenuSeparator />
- <DropdownMenuItem
- data-attr="clear-activity-filters"
- variant="destructive"
- onClick={() => resetMenuFilters(authIdentity)}
- >
- Clear filters
- </DropdownMenuItem>
+ <FilterRadioSubMenu
+ label="Scope"
+ options={SCOPE_OPTIONS}
+ value={inboxScope}
+ defaultValue="for-you"
+ onChange={setInboxScope}
+ />
+ <FilterCheckboxSubMenu
+ label="Source"
+ summary={inboxSourceFilterLabel(sourceProductFilter)}
+ allLabel="All sources"
+ options={sourceOptions}
+ selected={sourceProductFilter}
+ onToggle={toggleSourceProduct}
+ onClear={clearSourceProductFilter}
+ />
+ <FilterRadioSubMenu
+ label="Reports"
+ options={REPORT_OPTIONS}
+ value={prFilter}
+ defaultValue="all"
+ onChange={setPrFilter}
+ />
+ <FilterRadioSubMenu
+ label="Sort by"
+ options={INBOX_SORT_MENU_OPTIONS}
+ value={inboxSortOptionKey(sortField, sortDirection)}
+ defaultValue={inboxSortOptionKey("priority", "asc")}
+ onChange={(key) => {
+ const option = inboxSortOptionFromKey(key);
+ if (option) setSort(option.field, option.direction);
+ }}
+ />
+ <FilterCheckboxSubMenu
+ label="Priority"
+ summary={inboxPriorityFilterLabel(priorityFilter)}
+ allLabel="All priorities"
+ options={INBOX_PRIORITY_MENU_OPTIONS}
+ selected={priorityFilter}
+ onToggle={togglePriority}
+ onClear={clearPriorityFilter}
+ />
</>
)}
+ <FilterClearItem
+ active={filtersActive}
+ dataAttr="clear-activity-filters"
+ onClear={() => resetMenuFilters(authIdentity)}
+ />
</>
);
}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/CanvasFilterMenu.tsx b/products/desktop/packages/ui/src/features/canvas/components/CanvasFilterMenu.tsx
index 48372c930237..b30dab5b256b 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/CanvasFilterMenu.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/CanvasFilterMenu.tsx
@@ -1,4 +1,3 @@
-import { FunnelSimple as FunnelSimpleIcon } from "@phosphor-icons/react";
import {
type CanvasListSettings,
DEFAULT_CANVAS_LIST_GROUPING,
@@ -7,18 +6,9 @@ import {
hasCustomizedCanvasList,
} from "@posthog/core/canvas/canvasListService";
import {
- Button,
- cn,
DropdownMenu,
DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuRadioGroup,
- DropdownMenuRadioItem,
DropdownMenuSeparator,
- DropdownMenuSub,
- DropdownMenuSubContent,
- DropdownMenuSubTrigger,
- DropdownMenuTrigger,
} from "@posthog/quill";
import { CanvasFilterMultiSelectSubmenu } from "@posthog/ui/features/canvas/components/CanvasFilterMultiSelectSubmenu";
import {
@@ -27,6 +17,11 @@ import {
summarizeCreatorSelection,
summarizeSpaceSelection,
} from "@posthog/ui/features/canvas/components/canvasFilterSelection";
+import {
+ FilterClearItem,
+ FilterMenuTrigger,
+ FilterRadioSubMenu,
+} from "@posthog/ui/primitives/FilterMenu";
import type { ReactElement } from "react";
const SORT_OPTIONS: readonly CanvasFilterOption<CanvasListSettings["sort"]>[] =
@@ -43,54 +38,6 @@ const GROUPING_OPTIONS: readonly CanvasFilterOption<
{ value: "date", label: "Date" },
];
-function RadioSubmenu<Value extends string>({
- label,
- options,
- value,
- defaultValue,
- onChange,
-}: {
- label: string;
- options: readonly CanvasFilterOption<Value>[];
- value: Value;
- defaultValue: Value;
- onChange: (value: Value) => void;
-}): ReactElement {
- const selected =
- options.find((option) => option.value === value)?.label ?? "None";
-
- return (
- <DropdownMenuSub>
- <DropdownMenuSubTrigger className="pr-1">
- <span>{label}</span>
- <span
- title={selected}
- className={cn(
- "min-w-0 flex-1 truncate pl-4 text-right",
- value === defaultValue
- ? "text-muted-foreground/80"
- : "text-primary",
- )}
- >
- {selected}
- </span>
- </DropdownMenuSubTrigger>
- <DropdownMenuSubContent>
- <DropdownMenuRadioGroup
- value={value}
- onValueChange={(nextValue) => onChange(nextValue as Value)}
- >
- {options.map((option) => (
- <DropdownMenuRadioItem key={option.value} value={option.value}>
- {option.label}
- </DropdownMenuRadioItem>
- ))}
- </DropdownMenuRadioGroup>
- </DropdownMenuSubContent>
- </DropdownMenuSub>
- );
-}
-
export function CanvasFilterMenu({
spaceOptions,
creatorOptions,
@@ -112,24 +59,11 @@ export function CanvasFilterMenu({
return (
<DropdownMenu>
- <DropdownMenuTrigger
- render={
- <Button
- variant="default"
- size="icon-xs"
- aria-label="Filter canvases"
- data-attr="canvas-list-filter"
- className="relative"
- >
- <FunnelSimpleIcon />
- {active && (
- <span
- aria-hidden
- className="absolute top-0 right-0 size-1.5 rounded-full bg-primary"
- />
- )}
- </Button>
- }
+ <FilterMenuTrigger
+ active={active}
+ label="Filter canvases"
+ dataAttr="canvas-list-filter"
+ size="icon-xs"
/>
<DropdownMenuContent
align="end"
@@ -138,14 +72,14 @@ export function CanvasFilterMenu({
className="w-64"
aria-label="Filter canvases"
>
- <RadioSubmenu
+ <FilterRadioSubMenu
label="Group by"
options={GROUPING_OPTIONS}
value={settings.grouping}
defaultValue={DEFAULT_CANVAS_LIST_GROUPING}
onChange={(grouping) => updateSetting("grouping", grouping)}
/>
- <RadioSubmenu
+ <FilterRadioSubMenu
label="Sort by"
options={SORT_OPTIONS}
value={settings.sort}
@@ -178,18 +112,11 @@ export function CanvasFilterMenu({
emptyLabel="No users found."
disabled={createdByDisabled}
/>
- {active && (
- <>
- <DropdownMenuSeparator />
- <DropdownMenuItem
- data-attr="clear-canvas-list-filters"
- variant="destructive"
- onClick={() => onChange(DEFAULT_CANVAS_LIST_SETTINGS)}
- >
- Clear filters
- </DropdownMenuItem>
- </>
- )}
+ <FilterClearItem
+ active={active}
+ dataAttr="clear-canvas-list-filters"
+ onClear={() => onChange(DEFAULT_CANVAS_LIST_SETTINGS)}
+ />
</DropdownMenuContent>
</DropdownMenu>
);
diff --git a/products/desktop/packages/ui/src/features/canvas/components/CanvasFilterMultiSelectSubmenu.tsx b/products/desktop/packages/ui/src/features/canvas/components/CanvasFilterMultiSelectSubmenu.tsx
index e4ee0ea6e2b3..0efdbcfaf986 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/CanvasFilterMultiSelectSubmenu.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/CanvasFilterMultiSelectSubmenu.tsx
@@ -7,9 +7,9 @@ import {
ComboboxList,
DropdownMenuSub,
DropdownMenuSubContent,
- DropdownMenuSubTrigger,
} from "@posthog/quill";
import type { CanvasMultiSelectOption } from "@posthog/ui/features/canvas/components/canvasFilterSelection";
+import { FilterSubMenuTrigger } from "@posthog/ui/primitives/FilterMenu";
import type { ReactElement, SyntheticEvent } from "react";
const DEFAULT_OPTION_KEY = "__canvas_filter_default__";
@@ -61,19 +61,12 @@ export function CanvasFilterMultiSelectSubmenu({
return (
<DropdownMenuSub>
- <DropdownMenuSubTrigger className="pr-1" disabled={disabled}>
- <span>{label}</span>
- <span
- title={summary}
- className={
- values.length === 0
- ? "min-w-0 flex-1 truncate pl-4 text-right text-muted-foreground/80"
- : "min-w-0 flex-1 truncate pl-4 text-right text-primary"
- }
- >
- {summary}
- </span>
- </DropdownMenuSubTrigger>
+ <FilterSubMenuTrigger
+ label={label}
+ value={summary}
+ active={values.length > 0}
+ disabled={disabled}
+ />
<DropdownMenuSubContent className="w-64 [&>div]:overflow-hidden [&>div]:p-0">
<Combobox<CanvasMultiSelectOption, true>
multiple
diff --git a/products/desktop/packages/ui/src/features/canvas/components/CanvasesRoute.tsx b/products/desktop/packages/ui/src/features/canvas/components/CanvasesRoute.tsx
index 8a0841d8c78f..3ac161dff563 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/CanvasesRoute.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/CanvasesRoute.tsx
@@ -1,6 +1,7 @@
import { BlueprintIcon } from "@phosphor-icons/react";
import {
Empty,
+ EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
@@ -9,6 +10,7 @@ import {
import { WebsiteDashboard } from "@posthog/ui/features/canvas/components/WebsiteDashboard";
import { useSelectedCanvasId } from "@posthog/ui/features/canvas/hooks/useSelectedCanvasId";
import { useCanvasViewedStore } from "@posthog/ui/features/canvas/stores/canvasViewedStore";
+import { OpenSidebarButton } from "@posthog/ui/features/sidebar/components/OpenSidebarButton";
import { useEffect } from "react";
export function CanvasesRoute() {
@@ -33,6 +35,9 @@ export function CanvasesRoute() {
Choose a canvas from the list to open it here.
</EmptyDescription>
</EmptyHeader>
+ <EmptyContent>
+ <OpenSidebarButton />
+ </EmptyContent>
</Empty>
</div>
);
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.test.tsx
index ab1af7561ccc..b4a32d011bbf 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.test.tsx
@@ -98,13 +98,14 @@ vi.mock("@tanstack/react-router", () => ({
}: {
select: (s: {
matches: { fullPath: string }[];
- location: { pathname: string; state: { tabId?: string } };
+ location: { pathname: string; href: string; state: { tabId?: string } };
}) => unknown;
}) =>
select({
matches: [{ fullPath: mocks.fullPath }],
location: {
pathname: mocks.fullPath,
+ href: mocks.fullPath,
state: { tabId: mocks.historyTabId },
},
}),
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 12b3dd40cd5f..aa9adfa611df 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelsSidebar.tsx
@@ -17,6 +17,7 @@ import { useCurrentChannel } from "@posthog/ui/features/canvas/hooks/useCurrentC
import { useMarkChannelSeen } from "@posthog/ui/features/canvas/hooks/useMarkChannelSeen";
import { useRailSurface } from "@posthog/ui/features/canvas/hooks/useRailSurface";
import { useTrackChannelsSpaceViewed } from "@posthog/ui/features/canvas/hooks/useTrackChannelsSpaceViewed";
+import type { NavRailPane } from "@posthog/ui/features/canvas/railPane";
import {
selectActivityItem,
selectActivityReport,
@@ -28,6 +29,7 @@ import {
useChannelPaneStore,
} from "@posthog/ui/features/canvas/stores/channelPaneStore";
import { useCurrentChannelStore } from "@posthog/ui/features/canvas/stores/currentChannelStore";
+import { InboxPane } from "@posthog/ui/features/inbox/components/InboxPane";
import { useOnboardingStore } from "@posthog/ui/features/onboarding/onboardingStore";
import { NavResizeTooltip } from "@posthog/ui/features/sidebar/components/NavResizeTooltip";
import { ProjectSwitcher } from "@posthog/ui/features/sidebar/components/ProjectSwitcher";
@@ -56,7 +58,14 @@ import {
resolveNavigationSource,
} from "@posthog/ui/router/reportNavigation";
import { useParams, useRouterState } from "@tanstack/react-router";
-import { memo, useDeferredValue, useEffect, useRef } from "react";
+import {
+ type ComponentProps,
+ memo,
+ type ReactElement,
+ useDeferredValue,
+ useEffect,
+ useRef,
+} from "react";
/**
* The sidebar slider: the channel list and the channel you're in, laid out side
@@ -137,6 +146,64 @@ function ChannelPanes({
</div>
);
}
+type ActivityFeedListProps = ComponentProps<typeof ActivityFeedList>;
+
+/**
+ * What the rail's column shows: the destination decides, so a new one adds a
+ * case here rather than another rung on a conditional.
+ */
+function RailPaneBody({
+ railPane,
+ showsActivityDetail,
+ selectedActivityId,
+ onActivityActivate,
+ onActivityReportActivate,
+ feedId,
+ channelId,
+ showList,
+ sidebarVisible,
+ pendingTabSwitch,
+}: {
+ railPane: NavRailPane;
+ showsActivityDetail: boolean;
+ selectedActivityId: string | undefined;
+ // Taken from the list rather than restated, so the row's payload can change
+ // shape without this seam disagreeing about it.
+ onActivityActivate: ActivityFeedListProps["onActivate"];
+ onActivityReportActivate: ActivityFeedListProps["onReportActivate"];
+ feedId: string | undefined;
+ channelId: string | null;
+ showList: boolean;
+ sidebarVisible: boolean;
+ pendingTabSwitch: boolean;
+}): ReactElement {
+ if (showsActivityDetail) {
+ return (
+ <ActivityFeedList
+ className="min-h-0 flex-1"
+ selectedId={selectedActivityId}
+ onActivate={onActivityActivate}
+ onReportActivate={onActivityReportActivate}
+ />
+ );
+ }
+ if (railPane === "inbox") return <InboxPane className="min-h-0 flex-1" />;
+ if (railPane === "canvases") {
+ return <CanvasesPane className="min-h-0 flex-1" />;
+ }
+ if (feedId) {
+ return <TaskFeedPane feedId={feedId} className="min-h-0 flex-1" />;
+ }
+ return (
+ <ChannelPanes
+ channelId={channelId}
+ showList={showList}
+ sidebarVisible={sidebarVisible}
+ pendingTabSwitch={pendingTabSwitch}
+ />
+ );
+}
+
function ChannelsSidebarImpl() {
const width = useChannelsSidebarStore((state) => state.width);
const setWidth = useChannelsSidebarStore((state) => state.setWidth);
@@ -273,25 +340,18 @@ function ChannelsSidebarImpl() {
)}
{channelsLayout ? (
- showsActivityDetail ? (
- <ActivityFeedList
- className="min-h-0 flex-1"
- selectedId={selectedActivityId}
- onActivate={selectActivityItem}
- onReportActivate={selectActivityReport}
- />
- ) : railPane === "canvases" ? (
- <CanvasesPane className="min-h-0 flex-1" />
- ) : feedId ? (
- <TaskFeedPane feedId={feedId} className="min-h-0 flex-1" />
- ) : (
- <ChannelPanes
- channelId={presentedChannelId}
- showList={showList}
- sidebarVisible={open || peek}
- pendingTabSwitch={pendingTabSwitch}
- />
- )
+ <RailPaneBody
+ railPane={railPane}
+ showsActivityDetail={showsActivityDetail}
+ selectedActivityId={selectedActivityId}
+ onActivityActivate={selectActivityItem}
+ onActivityReportActivate={selectActivityReport}
+ feedId={feedId}
+ channelId={presentedChannelId}
+ showList={showList}
+ sidebarVisible={open || peek}
+ pendingTabSwitch={pendingTabSwitch}
+ />
) : bodyChannelsWorld ? (
<>
<Separator />
diff --git a/products/desktop/packages/ui/src/features/canvas/components/CopyCanvasLinkButton.tsx b/products/desktop/packages/ui/src/features/canvas/components/CopyCanvasLinkButton.tsx
new file mode 100644
index 000000000000..0334a9f3ffd3
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/canvas/components/CopyCanvasLinkButton.tsx
@@ -0,0 +1,40 @@
+import { LinkIcon } from "@phosphor-icons/react";
+import {
+ Button,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@posthog/quill";
+import { copyCanvasLink } from "@posthog/ui/features/canvas/utils/copyCanvasLink";
+import type { ReactElement } from "react";
+
+// Header affordance on a canvas, beside its name the way a thread's copy button
+// sits beside its title: the control acts on the leaf, so it rides with it
+// rather than joining the actions at the far end of the bar.
+export function CopyCanvasLinkButton({
+ channelId,
+ dashboardId,
+}: {
+ channelId: string;
+ dashboardId: string;
+}): ReactElement {
+ return (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ size="icon-sm"
+ aria-label="Copy link to canvas"
+ className="no-drag"
+ onClick={() =>
+ void copyCanvasLink(channelId, dashboardId, "canvas")
+ }
+ >
+ <LinkIcon size={14} />
+ </Button>
+ }
+ />
+ <TooltipContent side="bottom">Copy link to canvas</TooltipContent>
+ </Tooltip>
+ );
+}
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 2c455428cd23..42aadf823552 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
@@ -31,7 +31,7 @@ vi.mock("@tanstack/react-router", () => ({
matches: [{ fullPath: mocks.fullPath }],
location: {
pathname: mocks.fullPath,
- href: mocks.fullPath,
+ href: mocks.href,
search: {},
},
}),
@@ -105,6 +105,7 @@ import {
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 { NavRail } from "./NavRail";
it("stays above floating sidebar layers", () => {
@@ -151,6 +152,7 @@ describe("NavRail", () => {
useActivityFilterStore.setState({ mentionsEnabled: true });
useCurrentChannelStore.setState({ currentChannelId: null });
useChannelPaneStore.setState({ pane: "channel" });
+ useSidebarSearchStore.setState({ focusRequest: 0 });
rememberVisits({});
clearKeepListForRoute();
});
@@ -212,6 +214,7 @@ describe("NavRail", () => {
["/spaces/$channelId/tasks/$taskId", "Spaces"],
])("lights %s as %s", (fullPath, label) => {
mocks.fullPath = fullPath;
+ mocks.href = fullPath;
render(<NavRail />);
expect(screen.getByLabelText(label)).toHaveAttribute(
@@ -254,6 +257,7 @@ describe("NavRail", () => {
it("routes to Activity from a screen that has no column for it", async () => {
const user = userEvent.setup();
mocks.fullPath = "/inbox";
+ mocks.href = "/inbox";
render(<NavRail />);
await user.click(screen.getByLabelText("Activity"));
@@ -331,6 +335,7 @@ describe("NavRail", () => {
it("keeps the list open for a visit with no space in it", async () => {
const user = userEvent.setup();
mocks.fullPath = "/inbox";
+ mocks.href = "/inbox";
useChannelPaneStore.setState({ pane: "channel" });
rememberVisits({
spaces: { href: "/spaces", listOpen: true },
@@ -345,6 +350,7 @@ describe("NavRail", () => {
it("ignores a remembered visit that is not a Spaces page", async () => {
const user = userEvent.setup();
mocks.fullPath = "/activity";
+ mocks.href = "/activity";
rememberVisits({
spaces: { href: "/settings/general", listOpen: false },
});
@@ -391,6 +397,7 @@ describe("NavRail", () => {
it("remembers each destination separately", async () => {
const user = userEvent.setup();
mocks.fullPath = "/";
+ mocks.href = "/";
rememberVisits({
inbox: { href: "/inbox/pulls/42" },
loops: { href: "/loops/abc" },
@@ -408,6 +415,7 @@ describe("NavRail", () => {
it("slides Spaces back to the list without navigating", async () => {
const user = userEvent.setup();
mocks.fullPath = "/spaces/$channelId/loops";
+ mocks.href = "/spaces/chan-1/loops";
useCurrentChannelStore.setState({ currentChannelId: "chan-1" });
rememberVisits({
spaces: { href: "/spaces/chan-1", listOpen: false, spaceId: "chan-1" },
@@ -421,19 +429,32 @@ describe("NavRail", () => {
expect(mocks.navigateToChannel).not.toHaveBeenCalled();
});
- // The remembered page is where you are, so restoring it would be a no-op
- // that also refuses to take you up to the destination's index.
- it("goes up to the index rather than restoring", async () => {
+ it("focuses the column's search instead of emptying the pane", async () => {
const user = userEvent.setup();
mocks.fullPath = "/inbox/pulls/$reportId";
+ mocks.href = "/inbox/pulls/42";
rememberVisits({ inbox: { href: "/inbox/pulls/42" } });
render(<NavRail />);
await user.click(screen.getByLabelText("Self-driving"));
- expect(mocks.navigateToInbox).toHaveBeenCalledOnce();
+ expect(useSidebarSearchStore.getState().focusRequest).toBeGreaterThan(0);
+ expect(mocks.navigateToInbox).not.toHaveBeenCalled();
expect(mocks.navigate).not.toHaveBeenCalled();
});
+
+ it("counts the report a list opened as being on the list", async () => {
+ const user = userEvent.setup();
+ mocks.fullPath = "/reports/$reportId";
+ mocks.href = "/reports/42?from=%2Finbox";
+ rememberVisits({ inbox: { href: "/reports/42?from=%2Finbox" } });
+ render(<NavRail />);
+
+ await user.click(screen.getByLabelText("Self-driving"));
+
+ expect(useSidebarSearchStore.getState().focusRequest).toBeGreaterThan(0);
+ expect(mocks.navigateToInbox).not.toHaveBeenCalled();
+ });
});
it("peeks at the feed on hover while Activity is somewhere else", async () => {
@@ -450,6 +471,7 @@ describe("NavRail", () => {
it("drops the peek once Activity is the destination", async () => {
const user = userEvent.setup();
mocks.fullPath = "/activity";
+ mocks.href = "/activity";
render(<NavRail />);
const bell = screen.getByLabelText("Activity");
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.test.tsx
index 0575fa807bd5..1f2016230a85 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.test.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.test.tsx
@@ -41,13 +41,13 @@ vi.mock("@tanstack/react-router", () => ({
select,
}: {
select: (s: {
- location: { pathname: string };
+ location: { pathname: string; href: string };
matches: { routeId: string }[];
}) => unknown;
}) => {
const pathname = usePathname();
return select({
- location: { pathname },
+ location: { pathname, href: pathname },
matches: [{ routeId: "/spaces/$channelId/tasks/$taskId" }],
});
},
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.tsx b/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.tsx
index 668e57d6be8a..145b096695d9 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ShellLayout.tsx
@@ -21,12 +21,10 @@ import {
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
} from "@posthog/quill";
import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";
import { ChannelBreadcrumb } from "@posthog/ui/features/canvas/components/ChannelBreadcrumb";
+import { CopyCanvasLinkButton } from "@posthog/ui/features/canvas/components/CopyCanvasLinkButton";
import { iconForTemplate } from "@posthog/ui/features/canvas/components/canvasTemplateIcon";
import { NewCanvasMenu } from "@posthog/ui/features/canvas/components/NewCanvasMenu";
import { SpaceHeaderRow } from "@posthog/ui/features/canvas/components/SpaceHeaderRow";
@@ -64,6 +62,7 @@ import {
PRIVATE_SPACE_MENTIONS_DISABLED,
} from "@posthog/ui/features/sessions/mentionAvailability";
import { useTasks } from "@posthog/ui/features/tasks/useTasks";
+import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";
import { toast } from "@posthog/ui/primitives/toast";
import { track } from "@posthog/ui/shell/analytics";
import { Flex } from "@radix-ui/themes";
@@ -164,22 +163,6 @@ function FreeformEditControls({
return (
<div className="no-drag flex items-center gap-2">
- <Tooltip>
- <TooltipTrigger
- render={
- <Button
- size="icon-sm"
- aria-label="Copy link to canvas"
- onClick={() =>
- void copyCanvasLink(channelId, dashboardId, "canvas")
- }
- >
- <LinkIcon size={14} />
- </Button>
- }
- />
- <TooltipContent side="bottom">Copy link to canvas</TooltipContent>
- </Tooltip>
<DropdownMenu>
<DropdownMenuTrigger
render={
@@ -329,6 +312,9 @@ function CanvasBreadcrumb({
leafLabel={name}
editScopeKey={dashboardId}
onRename={(next) => void renameDashboard(dashboardId, next)}
+ leafTrailing={
+ <CopyCanvasLinkButton channelId={channelId} dashboardId={dashboardId} />
+ }
trailing={
<>
{commentTaskId && (
@@ -420,7 +406,7 @@ export function ShellLayout() {
canvas actions (Edit / New canvas) on the right.
Freeform canvases own their own date control in-app (DateTimePicker). */}
{showToolbar && (
- <div className="flex h-10 shrink-0 items-center border-border border-b px-3">
+ <ChromeBar inset="control">
{isDashboardDetail && toolbarDashboardId && toolbarChannelId ? (
<CanvasBreadcrumb
channelName={toolbarChannelName}
@@ -441,7 +427,7 @@ export function ShellLayout() {
trailing={<NewCanvasMenu channelId={channelId} />}
/>
) : null}
- </div>
+ </ChromeBar>
)}
{/* The right panel lays itself over this row's right edge and pins its
switcher to the row's top right, so the row is its positioning context
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SidebarSearchHeader.tsx b/products/desktop/packages/ui/src/features/canvas/components/SidebarSearchHeader.tsx
index 15b7cfeca422..df205838685e 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/SidebarSearchHeader.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/SidebarSearchHeader.tsx
@@ -4,6 +4,7 @@ import {
formatHotkey,
SHORTCUTS,
} from "@posthog/ui/features/command/keyboard-shortcuts";
+import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";
import {
type ReactElement,
type KeyboardEvent as ReactKeyboardEvent,
@@ -54,14 +55,9 @@ export function SidebarSearchHeader({
return (
<>
- <div className="flex h-10 shrink-0 items-center gap-2 border-border border-b pr-2 pl-3">
+ <ChromeBar actions={actions}>
<h2 className="font-bold text-base">{title}</h2>
- {actions && (
- <div className="ml-auto flex shrink-0 items-center gap-1">
- {actions}
- </div>
- )}
- </div>
+ </ChromeBar>
<div className="shrink-0 px-2 pt-2">
<AutocompleteInput
ref={searchRef}
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 ae69658aa827..d1324e76e092 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
@@ -1,7 +1,22 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { render } from "@testing-library/react";
+import { fireEvent, render, screen } from "@testing-library/react";
import { useMemo } from "react";
-import { describe, expect, it, vi } from "vitest";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const activityMocks = vi.hoisted(() => ({
+ clearSelection: vi.fn(),
+ selection: null as {
+ kind: "task";
+ id: string;
+ taskId: string;
+ channelId: string | null;
+ } | null,
+}));
+
+vi.mock("@posthog/ui/features/canvas/stores/activityDetailStore", () => ({
+ clearActivitySelection: activityMocks.clearSelection,
+ useActivitySelection: () => activityMocks.selection,
+}));
vi.mock("@posthog/ui/features/canvas/hooks/useChannelsLayout", () => ({
useChannelsLayout: () => true,
@@ -41,7 +56,7 @@ vi.mock("@tanstack/react-router", () => ({
select,
}: {
select: (s: {
- location: { pathname: string };
+ location: { pathname: string; href: string };
matches: {
routeId: string;
fullPath: string;
@@ -50,7 +65,10 @@ vi.mock("@tanstack/react-router", () => ({
}) => unknown;
}) =>
select({
- location: { pathname: "/spaces/chan-1/tasks/task-1" },
+ location: {
+ pathname: "/spaces/chan-1/tasks/task-1",
+ href: "/spaces/chan-1/tasks/task-1",
+ },
matches: [
{
routeId: "/spaces/$channelId/tasks/$taskId",
@@ -138,8 +156,14 @@ vi.mock("@posthog/ui/features/task-detail/components/TaskDetail", () => ({
import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";
import { ActivityDetailPane } from "./ActivityDetailPane";
import { ShellLayout } from "./ShellLayout";
+import { SpaceHeaderRow } from "./SpaceHeaderRow";
describe("SpaceHeaderRow", () => {
+ beforeEach(() => {
+ activityMocks.clearSelection.mockClear();
+ activityMocks.selection = null;
+ });
+
it("keeps the header store off the layout that renders its writer", () => {
const client = new QueryClient({
defaultOptions: { queries: { retry: false } },
@@ -152,4 +176,18 @@ describe("SpaceHeaderRow", () => {
// A layout that subscribes to the header store blows the update depth here.
expect(taskDetailRenders).toBeLessThan(20);
});
+
+ it("can close an Activity session before task actions resolve", () => {
+ activityMocks.selection = {
+ kind: "task",
+ id: "activity-1",
+ taskId: "task-1",
+ channelId: null,
+ };
+
+ render(<SpaceHeaderRow />);
+
+ fireEvent.click(screen.getByLabelText("Close activity item"));
+ expect(activityMocks.clearSelection).toHaveBeenCalledOnce();
+ });
});
diff --git a/products/desktop/packages/ui/src/features/canvas/components/SpaceHeaderRow.tsx b/products/desktop/packages/ui/src/features/canvas/components/SpaceHeaderRow.tsx
index bec7e3770fb6..9d55cb585aec 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/SpaceHeaderRow.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/SpaceHeaderRow.tsx
@@ -1,5 +1,8 @@
import type { Task } from "@posthog/shared/domain-types";
+import { ActivityDetailCloseButton } from "@posthog/ui/features/canvas/components/ActivityDetailCloseButton";
+import { useActivitySelection } from "@posthog/ui/features/canvas/stores/activityDetailStore";
import { TaskHeaderActions } from "@posthog/ui/features/task-detail/components/TaskHeaderActions";
+import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";
import { useHeaderStore } from "@posthog/ui/shell/headerStore";
/**
@@ -9,10 +12,12 @@ import { useHeaderStore } from "@posthog/ui/shell/headerStore";
*/
export function SpaceHeaderRow({ task }: { task?: Task }) {
const content = useHeaderStore((s) => s.content);
- if (!content && !task) return null;
+ const activitySelection = useActivitySelection();
+ const showsActivitySession = activitySelection?.kind === "task";
+ if (!content && !task && !showsActivitySession) return null;
return (
- <div className="flex h-10 shrink-0 items-center gap-2 border-border border-b pr-2 pl-1">
+ <ChromeBar inset="control">
<div className="flex h-full min-w-0 flex-1 items-center justify-between overflow-hidden">
{content}
</div>
@@ -20,6 +25,7 @@ export function SpaceHeaderRow({ task }: { task?: Task }) {
bar, and a wrapper that hugs their content resolves that percentage
against itself, which clips them. */}
{task && <TaskHeaderActions task={task} />}
- </div>
+ {showsActivitySession && <ActivityDetailCloseButton />}
+ </ChromeBar>
);
}
diff --git a/products/desktop/packages/ui/src/features/canvas/components/TaskFeedDetailPane.tsx b/products/desktop/packages/ui/src/features/canvas/components/TaskFeedDetailPane.tsx
index bb13cb5de8ce..70b0d3ebb397 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/TaskFeedDetailPane.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/TaskFeedDetailPane.tsx
@@ -1,6 +1,7 @@
import { MagnifyingGlassIcon } from "@phosphor-icons/react";
import {
Empty,
+ EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
@@ -8,6 +9,7 @@ import {
} from "@posthog/quill";
import { useChannels } from "@posthog/ui/features/canvas/hooks/useChannels";
import { useTaskFeedSelection } from "@posthog/ui/features/canvas/stores/taskFeedSelectionStore";
+import { OpenSidebarButton } from "@posthog/ui/features/sidebar/components/OpenSidebarButton";
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";
@@ -40,6 +42,9 @@ export function TaskFeedDetailPane({
Pick a task from the search to read it here.
</EmptyDescription>
</EmptyHeader>
+ <EmptyContent>
+ <OpenSidebarButton />
+ </EmptyContent>
</Empty>
</div>
);
diff --git a/products/desktop/packages/ui/src/features/canvas/components/TaskFeedPane.tsx b/products/desktop/packages/ui/src/features/canvas/components/TaskFeedPane.tsx
index f82f4209e86f..b4453d5c889b 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/TaskFeedPane.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/TaskFeedPane.tsx
@@ -30,6 +30,7 @@ import {
useTaskFeedSelectionStore,
} from "@posthog/ui/features/canvas/stores/taskFeedSelectionStore";
import { usePinnedTasks } from "@posthog/ui/features/sidebar/usePinnedTasks";
+import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";
import { toast } from "@posthog/ui/primitives/toast";
import { getRouterOrNull } from "@posthog/ui/router/routerRef";
import { track } from "@posthog/ui/shell/analytics";
@@ -134,30 +135,33 @@ export function TaskFeedPane({
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">
+ <ChromeBar
+ actions={
+ <>
+ <Button
+ variant="default"
+ size="icon-xs"
+ aria-label="Edit saved search"
+ onClick={openEdit}
+ >
+ <PencilSimpleIcon size={14} />
+ </Button>
+ <Button
+ variant="default"
+ size="icon-xs"
+ aria-label="Delete saved search…"
+ onClick={requestDelete}
+ >
+ <TrashIcon size={14} />
+ </Button>
+ </>
+ }
+ >
<SavedSearchSwitcher
currentFeedId={feedId}
className="min-w-0 flex-1"
/>
- <div className="ml-auto flex shrink-0 items-center gap-1">
- <Button
- variant="default"
- size="icon-xs"
- aria-label="Edit saved search"
- onClick={openEdit}
- >
- <PencilSimpleIcon size={14} />
- </Button>
- <Button
- variant="default"
- size="icon-xs"
- aria-label="Delete saved search…"
- onClick={requestDelete}
- >
- <TrashIcon size={14} />
- </Button>
- </div>
- </div>
+ </ChromeBar>
<Button
variant="default"
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 684dd5402d1a..c1dc0cda63e2 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/railDestinations.ts
+++ b/products/desktop/packages/ui/src/features/canvas/components/railDestinations.ts
@@ -21,14 +21,15 @@ import {
showChannelList,
} from "@posthog/ui/features/canvas/stores/channelPaneStore";
import { useCurrentChannelStore } from "@posthog/ui/features/canvas/stores/currentChannelStore";
+import { requestSidebarSearchFocus } from "@posthog/ui/features/canvas/stores/sidebarSearchStore";
import {
formatHotkey,
SHORTCUTS,
} from "@posthog/ui/features/command/keyboard-shortcuts";
+import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";
import type { CountBadgeTone } from "@posthog/ui/primitives/CountBadge";
import { LoopIcon } from "@posthog/ui/primitives/LoopIcon";
import {
- getCurrentMatches,
navigateToActivity,
navigateToCanvases,
navigateToChannel,
@@ -94,6 +95,12 @@ function showSpaces(): void {
navigateToChannel(channelId);
}
+/** Navigating to the root instead would close what you are reading. */
+function focusColumnSearch(): void {
+ useSidebarStore.getState().setOpen(true);
+ requestSidebarSearchFocus();
+}
+
/**
* Where each rail destination was when the ACTIVE TAB last left it. Per tab, so
* a pick in one tab can never restore an href another tab established, and so
@@ -134,11 +141,12 @@ export function pickRailDestination(
destination: RailDestination,
current: NavRailPane,
): void {
- const matches = getCurrentMatches();
- const routePath = matches[matches.length - 1]?.fullPath ?? "";
+ // A report page belongs to the list that opened it, and only its `?from=`
+ // says which, so a route pattern cannot answer this.
+ const here = currentHref() ?? "";
const onDestination =
destination.pane === current &&
- isRestorableVisitHref(destination.pane, routePath);
+ isRestorableVisitHref(destination.pane, here);
if (onDestination) {
(destination.onReclick ?? destination.onPick)();
return;
@@ -183,6 +191,7 @@ const RAIL_DESTINATIONS: readonly RailDestination[] = [
Icon: BellIcon,
href: "/activity",
onPick: navigateToActivity,
+ onReclick: focusColumnSearch,
count: (counts) => counts.activity,
},
{
@@ -192,6 +201,7 @@ const RAIL_DESTINATIONS: readonly RailDestination[] = [
Icon: ShapesIcon,
href: "/canvases",
onPick: () => navigateToCanvases(),
+ onReclick: focusColumnSearch,
},
{
pane: "inbox",
@@ -200,6 +210,7 @@ const RAIL_DESTINATIONS: readonly RailDestination[] = [
Icon: EnvelopeSimple,
href: "/inbox",
onPick: navigateToInbox,
+ onReclick: focusColumnSearch,
shortcut: formatHotkey(SHORTCUTS.INBOX),
count: (counts) => counts.inbox,
enabled: (flags) => flags.inbox,
diff --git a/products/desktop/packages/ui/src/features/canvas/freeform/CanvasSidePanel.tsx b/products/desktop/packages/ui/src/features/canvas/freeform/CanvasSidePanel.tsx
index 995066564bf3..3e9845d95051 100644
--- a/products/desktop/packages/ui/src/features/canvas/freeform/CanvasSidePanel.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/freeform/CanvasSidePanel.tsx
@@ -21,6 +21,7 @@ import { useCanvasChatPanelStore } from "@posthog/ui/features/canvas/stores/canv
import type { EditorHandle } from "@posthog/ui/features/message-editor/types";
import { EmbeddedSessionView } from "@posthog/ui/features/sessions/components/EmbeddedSessionView";
import { taskDetailQuery } from "@posthog/ui/features/tasks/queries";
+import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";
import { LoadingState } from "@posthog/ui/primitives/LoadingState";
import { useQuery } from "@tanstack/react-query";
import { type Ref, useEffect, useRef } from "react";
@@ -83,7 +84,26 @@ export function CanvasSidePanel({
return (
<div className="flex h-full min-w-0 flex-col bg-gray-1">
- <div className="flex h-10 shrink-0 items-center justify-between border-b bg-chrome pr-2 pl-3">
+ <ChromeBar
+ className="bg-chrome"
+ actions={
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ size="icon"
+ variant="default"
+ aria-label="Minimize panel"
+ onClick={onMinimize}
+ >
+ <SidebarSimpleIcon size={16} />
+ </Button>
+ }
+ />
+ <TooltipContent>Minimize panel</TooltipContent>
+ </Tooltip>
+ }
+ >
<Tabs
value={tab}
onValueChange={(value) => setTab(value as "chat" | "comments")}
@@ -101,22 +121,7 @@ export function CanvasSidePanel({
</TabsTrigger>
</TabsList>
</Tabs>
- <Tooltip>
- <TooltipTrigger
- render={
- <Button
- size="icon"
- variant="default"
- aria-label="Minimize panel"
- onClick={onMinimize}
- >
- <SidebarSimpleIcon size={16} />
- </Button>
- }
- />
- <TooltipContent>Minimize panel</TooltipContent>
- </Tooltip>
- </div>
+ </ChromeBar>
<div className="min-h-0 flex-1">
{tab === "comments" && commentTaskId ? (
diff --git a/products/desktop/packages/ui/src/features/canvas/freeform/FreeformCanvasView.tsx b/products/desktop/packages/ui/src/features/canvas/freeform/FreeformCanvasView.tsx
index 7939098d658a..5968111a463e 100644
--- a/products/desktop/packages/ui/src/features/canvas/freeform/FreeformCanvasView.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/freeform/FreeformCanvasView.tsx
@@ -85,6 +85,7 @@ import {
import { useCommentsQuery } from "@posthog/ui/features/sessions/components/useComments";
import { useSessionForTask } from "@posthog/ui/features/sessions/useSession";
import { taskDetailQuery } from "@posthog/ui/features/tasks/queries";
+import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";
import { LoadingState } from "@posthog/ui/primitives/LoadingState";
import { ResizableSidebar } from "@posthog/ui/primitives/ResizableSidebar";
import { Spinner } from "@posthog/ui/primitives/Spinner";
@@ -865,209 +866,206 @@ export function FreeformCanvasView({
overflow="hidden"
>
{showToolbar && (
- <Flex
- align="center"
- justify="between"
- className="h-10 shrink-0 items-center border-b bg-chrome px-3"
- >
- <Flex align="center" gap="1">
- {interactive && (
- <>
- <Button
- size="icon"
- variant="default"
- aria-label="Undo"
- disabled={!canUndo}
- onClick={onUndo}
- >
- <ArrowUUpLeftIcon size={16} />
- </Button>
- <Button
- size="icon"
- variant="default"
- aria-label="Redo"
- disabled={!canRedo}
- onClick={onRedo}
- >
- <ArrowUUpRightIcon size={16} />
- </Button>
- {browsingDraft ? (
- <Badge variant="warning" className="ml-1">
- Draft preview
- </Badge>
- ) : (
- versions.length > 0 && (
- <DropdownMenu>
- <DropdownMenuTrigger
- render={
- <Button
- size="sm"
- variant="default"
- className="ml-1"
- aria-label="Version history"
- />
- }
+ <ChromeBar
+ inset="even"
+ className="bg-chrome"
+ actions={
+ <>
+ <CanvasBuildStatus
+ dashboardId={dashboardId}
+ lifecycle={lifecycle}
+ onAskAgentToFix={interactive ? prefillComposer : undefined}
+ />
+ {interactive &&
+ (isGenerating && effectiveTaskId ? (
+ <>
+ <Spinner size="md" className="text-accent-9" />
+ <Text size="1" className="text-gray-10">
+ Generating
+ </Text>
+ <RadixButton size="1" variant="soft" asChild>
+ <Link
+ to="/spaces/$channelId/tasks/$taskId"
+ params={{ channelId, taskId: effectiveTaskId }}
>
- v{versions.length - currentIndex}/{versions.length}
- {!browsing && " · Live"}
- <CaretDownIcon size={12} />
- </DropdownMenuTrigger>
- <DropdownMenuContent align="start" side="bottom">
- {versions.map((version, index) => (
- <DropdownMenuItem
- key={version.id}
+ View task
+ </Link>
+ </RadixButton>
+ </>
+ ) : (
+ runtimeError && (
+ <>
+ <TooltipProvider delay={0}>
+ <QuillTooltip>
+ <TooltipTrigger
render={
- <ItemMenuItem size="xs" className="w-full" />
+ <div className="flex items-center gap-1 text-red-11">
+ <WarningIcon size={14} />
+ <Text size="1">Runtime error</Text>
+ </div>
}
- onClick={() =>
- setBrowseVersion(
- threadId,
- version.id === headVersionId
- ? null
- : version.id,
- )
- }
- >
- <ItemContent variant="menuItem">
- <ItemTitle>
- v{versions.length - index}
- {version.id === headVersionId && " · Live"}
- </ItemTitle>
- <ItemDescription className="leading-none">
- {describeCanvasVersion(version)}
- </ItemDescription>
- </ItemContent>
- </DropdownMenuItem>
- ))}
- </DropdownMenuContent>
- </DropdownMenu>
+ />
+ <TooltipContent>
+ <span className="block max-w-sm whitespace-pre-wrap break-words">
+ {runtimeError}
+ </span>
+ </TooltipContent>
+ </QuillTooltip>
+ </TooltipProvider>
+ <Button
+ size="sm"
+ variant="outline"
+ onClick={askAgentToFix}
+ >
+ Ask agent to fix
+ </Button>
+ </>
)
+ ))}
+ {interactive &&
+ showPanel &&
+ collapsed &&
+ !generatingPanelOpen && (
+ <Tooltip content={chatTaskId ? "Show chat" : "Edit canvas"}>
+ <Button
+ size="icon"
+ variant="default"
+ aria-label="Show panel"
+ onClick={() => setCollapsed(false)}
+ >
+ <SidebarSimpleIcon size={16} />
+ </Button>
+ </Tooltip>
)}
- {browsing && !browsingDraft && (
- <Button
- size="sm"
- variant="primary"
- className="ml-1"
- disabled={isReverting}
- onClick={() => void onRevert()}
- >
- {isReverting ? "Reverting…" : "Revert to this version"}
- </Button>
- )}
- {browsingDraft && (
- <Button
- size="sm"
- variant="primary"
- className="ml-1"
- disabled={isPromoting}
- onClick={() => void onPromote()}
- >
- {isPromoting ? "Publishing…" : "Publish draft"}
- </Button>
- )}
- {drafts.length > 0 && (
+ </>
+ }
+ >
+ {interactive && (
+ <>
+ <Button
+ size="icon"
+ variant="default"
+ aria-label="Undo"
+ disabled={!canUndo}
+ onClick={onUndo}
+ >
+ <ArrowUUpLeftIcon size={16} />
+ </Button>
+ <Button
+ size="icon"
+ variant="default"
+ aria-label="Redo"
+ disabled={!canRedo}
+ onClick={onRedo}
+ >
+ <ArrowUUpRightIcon size={16} />
+ </Button>
+ {browsingDraft ? (
+ <Badge variant="warning" className="ml-1">
+ Draft preview
+ </Badge>
+ ) : (
+ versions.length > 0 && (
<DropdownMenu>
<DropdownMenuTrigger
render={
- <Button size="sm" variant="default" className="ml-1">
- Drafts ({drafts.length})
- <CaretDownIcon size={12} />
- </Button>
+ <Button
+ size="sm"
+ variant="default"
+ className="ml-1"
+ aria-label="Version history"
+ />
}
- />
+ >
+ v{versions.length - currentIndex}/{versions.length}
+ {!browsing && " · Live"}
+ <CaretDownIcon size={12} />
+ </DropdownMenuTrigger>
<DropdownMenuContent align="start" side="bottom">
- {drafts.map((draft) => (
+ {versions.map((version, index) => (
<DropdownMenuItem
- key={draft.versionId}
+ key={version.id}
+ render={
+ <ItemMenuItem size="xs" className="w-full" />
+ }
onClick={() =>
- setBrowseVersion(threadId, draft.versionId)
+ setBrowseVersion(
+ threadId,
+ version.id === headVersionId
+ ? null
+ : version.id,
+ )
}
>
- <span className="mr-2 truncate">
- {draft.prompt || "Untitled draft"}
- </span>
- <Badge
- variant={draftBadgeVariant(draft.buildStatus)}
- >
- {draft.buildStatus ?? "pending"}
- </Badge>
+ <ItemContent variant="menuItem">
+ <ItemTitle>
+ v{versions.length - index}
+ {version.id === headVersionId && " · Live"}
+ </ItemTitle>
+ <ItemDescription className="leading-none">
+ {describeCanvasVersion(version)}
+ </ItemDescription>
+ </ItemContent>
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
- )}
- </>
- )}
- </Flex>
- <Flex align="center" gap="2">
- <CanvasBuildStatus
- dashboardId={dashboardId}
- lifecycle={lifecycle}
- onAskAgentToFix={interactive ? prefillComposer : undefined}
- />
- {interactive &&
- (isGenerating && effectiveTaskId ? (
- <>
- <Spinner size="md" className="text-accent-9" />
- <Text size="1" className="text-gray-10">
- Generating
- </Text>
- <RadixButton size="1" variant="soft" asChild>
- <Link
- to="/spaces/$channelId/tasks/$taskId"
- params={{ channelId, taskId: effectiveTaskId }}
- >
- View task
- </Link>
- </RadixButton>
- </>
- ) : (
- runtimeError && (
- <>
- <TooltipProvider delay={0}>
- <QuillTooltip>
- <TooltipTrigger
- render={
- <div className="flex items-center gap-1 text-red-11">
- <WarningIcon size={14} />
- <Text size="1">Runtime error</Text>
- </div>
- }
- />
- <TooltipContent>
- <span className="block max-w-sm whitespace-pre-wrap break-words">
- {runtimeError}
- </span>
- </TooltipContent>
- </QuillTooltip>
- </TooltipProvider>
- <Button
- size="sm"
- variant="outline"
- onClick={askAgentToFix}
- >
- Ask agent to fix
- </Button>
- </>
)
- ))}
- {interactive &&
- showPanel &&
- collapsed &&
- !generatingPanelOpen && (
- <Tooltip content={chatTaskId ? "Show chat" : "Edit canvas"}>
- <Button
- size="icon"
- variant="default"
- aria-label="Show panel"
- onClick={() => setCollapsed(false)}
- >
- <SidebarSimpleIcon size={16} />
- </Button>
- </Tooltip>
)}
- </Flex>
- </Flex>
+ {browsing && !browsingDraft && (
+ <Button
+ size="sm"
+ variant="primary"
+ className="ml-1"
+ disabled={isReverting}
+ onClick={() => void onRevert()}
+ >
+ {isReverting ? "Reverting…" : "Revert to this version"}
+ </Button>
+ )}
+ {browsingDraft && (
+ <Button
+ size="sm"
+ variant="primary"
+ className="ml-1"
+ disabled={isPromoting}
+ onClick={() => void onPromote()}
+ >
+ {isPromoting ? "Publishing…" : "Publish draft"}
+ </Button>
+ )}
+ {drafts.length > 0 && (
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button size="sm" variant="default" className="ml-1">
+ Drafts ({drafts.length})
+ <CaretDownIcon size={12} />
+ </Button>
+ }
+ />
+ <DropdownMenuContent align="start" side="bottom">
+ {drafts.map((draft) => (
+ <DropdownMenuItem
+ key={draft.versionId}
+ onClick={() =>
+ setBrowseVersion(threadId, draft.versionId)
+ }
+ >
+ <span className="mr-2 truncate">
+ {draft.prompt || "Untitled draft"}
+ </span>
+ <Badge variant={draftBadgeVariant(draft.buildStatus)}>
+ {draft.buildStatus ?? "pending"}
+ </Badge>
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </>
+ )}
+ </ChromeBar>
)}
<Box position="relative" className="min-h-0 flex-1">
diff --git a/products/desktop/packages/ui/src/features/canvas/grid/GridCanvasView.tsx b/products/desktop/packages/ui/src/features/canvas/grid/GridCanvasView.tsx
index 0a37a4520e8b..e66426b0f363 100644
--- a/products/desktop/packages/ui/src/features/canvas/grid/GridCanvasView.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/grid/GridCanvasView.tsx
@@ -12,6 +12,7 @@ import {
} from "@posthog/ui/features/canvas/hooks/useDashboards";
import { useGenerateFreeformCanvas } from "@posthog/ui/features/canvas/hooks/useGenerateFreeformCanvas";
import { useCanvasChatPanelStore } from "@posthog/ui/features/canvas/stores/canvasChatPanelStore";
+import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";
import { LoadingState } from "@posthog/ui/primitives/LoadingState";
import { ResizableSidebar } from "@posthog/ui/primitives/ResizableSidebar";
import { useCallback, useMemo, useState } from "react";
@@ -210,25 +211,27 @@ export function GridCanvasView({
{interactive ? (
// The freeform canvas's toolbar shape: version info on the left,
// panel controls on the right, in the bar rather than floating.
- <div className="flex h-10 shrink-0 items-center justify-between border-(--gray-5) border-b px-3">
- <div className="flex items-center gap-1">
- {versionText ? (
- <Text size="sm" className="text-(--gray-9)">
- {versionText}
- </Text>
- ) : null}
- </div>
- {collapsed && !widgetTarget ? (
- <Button
- variant="default"
- size="icon"
- aria-label="Show chat"
- onClick={() => setCollapsed(false)}
- >
- <SidebarSimpleIcon size={16} />
- </Button>
+ <ChromeBar
+ inset="even"
+ actions={
+ collapsed && !widgetTarget ? (
+ <Button
+ variant="default"
+ size="icon"
+ aria-label="Show chat"
+ onClick={() => setCollapsed(false)}
+ >
+ <SidebarSimpleIcon size={16} />
+ </Button>
+ ) : null
+ }
+ >
+ {versionText ? (
+ <Text size="sm" className="text-(--gray-9)">
+ {versionText}
+ </Text>
) : null}
- </div>
+ </ChromeBar>
) : null}
<GridSurface
grid={layout.grid}
diff --git a/products/desktop/packages/ui/src/features/canvas/grid/GridChatPanel.tsx b/products/desktop/packages/ui/src/features/canvas/grid/GridChatPanel.tsx
index 68612b5130ed..222ec4c2b76a 100644
--- a/products/desktop/packages/ui/src/features/canvas/grid/GridChatPanel.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/grid/GridChatPanel.tsx
@@ -14,6 +14,7 @@ import { useThreadConversation } from "@posthog/ui/features/canvas/hooks/useThre
import { useCanvasChatPanelStore } from "@posthog/ui/features/canvas/stores/canvasChatPanelStore";
import { EmbeddedSessionView } from "@posthog/ui/features/sessions/components/EmbeddedSessionView";
import { taskDetailQuery } from "@posthog/ui/features/tasks/queries";
+import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";
import { LoadingState } from "@posthog/ui/primitives/LoadingState";
import { useQuery } from "@tanstack/react-query";
import { useState } from "react";
@@ -82,7 +83,7 @@ export function GridChatPanel({
if (target) {
return (
<div className="flex h-full flex-col border-(--gray-5) border-l">
- <div className="flex h-10 shrink-0 items-center gap-1 border-(--gray-5) border-b px-2">
+ <ChromeBar inset="control" className="gap-1" actions={minimize}>
<Button
variant="default"
size="icon"
@@ -94,8 +95,7 @@ export function GridChatPanel({
<Text size="sm" weight="medium" className="min-w-0 flex-1 truncate">
{target.title}
</Text>
- {minimize}
- </div>
+ </ChromeBar>
{target.taskId ? (
<TaskChat taskId={target.taskId} />
) : (
@@ -109,7 +109,7 @@ export function GridChatPanel({
return (
<div className="flex h-full flex-col border-(--gray-5) border-l">
- <div className="flex h-10 shrink-0 items-center justify-between border-(--gray-5) border-b pr-2 pl-3">
+ <ChromeBar actions={minimize}>
<Tabs
value={tab}
onValueChange={(value) => setTab(value as "chat" | "comments")}
@@ -127,8 +127,7 @@ export function GridChatPanel({
</TabsTrigger>
</TabsList>
</Tabs>
- {minimize}
- </div>
+ </ChromeBar>
{tab === "comments" && commentTaskId ? (
<CanvasComments
taskId={commentTaskId}
diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useRailSurface.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useRailSurface.ts
index b8bcc5b29007..e27192887dc0 100644
--- a/products/desktop/packages/ui/src/features/canvas/hooks/useRailSurface.ts
+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useRailSurface.ts
@@ -1,11 +1,10 @@
import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";
import {
type NavRailPane,
- railPaneForMatches,
- railPaneForPath,
+ railPaneForHref,
railPaneHasSidebar,
} from "@posthog/ui/features/canvas/railPane";
-import { reportSourceHrefFromLocation } from "@posthog/ui/router/reportNavigation";
+import { isInboxTriagePath } from "@posthog/ui/features/inbox/triageRoute";
import { useRouterState } from "@tanstack/react-router";
export interface RailSurface {
@@ -18,17 +17,10 @@ export interface RailSurface {
* stable and unrelated route changes don't re-render every consumer. */
export function useRailPane(): NavRailPane {
return useRouterState({
- select: (state) => {
- // The settled location, not the in-flight one: during a pending
- // navigation `location` is already the destination while `matches` still
- // describe the page being left. Pairing the two unmounts the sidebar for
- // one painted frame (the yieldToPaint skeleton) and rebuilds it after.
- const location = state.resolvedLocation ?? state.location;
- const source = reportSourceHrefFromLocation(location);
- return source
- ? railPaneForPath(source.split(/[?#]/)[0])
- : railPaneForMatches(state.matches);
- },
+ // One location decides. `location`, `matches` and `resolvedLocation` land
+ // at different points in a transition, so a rule reading two of them
+ // answers with a destination neither is on, and the column blinks.
+ select: (state) => railPaneForHref(state.location.href),
});
}
@@ -37,10 +29,13 @@ export function useRailPane(): NavRailPane {
export function useRailSurface(): RailSurface {
const channelsLayout = useChannelsLayout();
const pane = useRailPane();
+ const inTriage = useRouterState({
+ select: (state) => isInboxTriagePath(state.location.pathname),
+ });
return {
pane,
- hasSidebar: !channelsLayout || railPaneHasSidebar(pane),
+ hasSidebar: !inTriage && (!channelsLayout || railPaneHasSidebar(pane)),
showsActivityDetail: channelsLayout && pane === "activity",
};
}
diff --git a/products/desktop/packages/ui/src/features/canvas/railPane.test.ts b/products/desktop/packages/ui/src/features/canvas/railPane.test.ts
index 75989132cd52..f5f927f33b13 100644
--- a/products/desktop/packages/ui/src/features/canvas/railPane.test.ts
+++ b/products/desktop/packages/ui/src/features/canvas/railPane.test.ts
@@ -1,11 +1,34 @@
-import { describe, expect, it } from "vitest";
+import { useRailSurface } from "@posthog/ui/features/canvas/hooks/useRailSurface";
+import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";
+import { renderHook } from "@testing-library/react";
+import { describe, expect, it, vi } from "vitest";
import {
isRestorableVisitHref,
RAIL_PANE_ROOT,
+ railPaneForHref,
railPaneForPath,
railPaneHasSidebar,
} from "./railPane";
+const routing = vi.hoisted(() => ({ href: "/inbox", channelsLayout: true }));
+
+vi.mock("@posthog/ui/features/canvas/hooks/useChannelsLayout", () => ({
+ useChannelsLayout: () => routing.channelsLayout,
+}));
+
+vi.mock("@tanstack/react-router", () => ({
+ useRouterState: ({
+ select,
+ }: {
+ select: (state: {
+ location: { href: string; pathname: string };
+ }) => unknown;
+ }) =>
+ select({
+ location: { href: routing.href, pathname: routing.href.split("?")[0] },
+ }),
+}));
+
describe("railPaneForPath", () => {
it.each([
["/", "home"],
@@ -48,6 +71,18 @@ describe("railPaneForPath", () => {
});
});
+describe("railPaneForHref", () => {
+ it.each([
+ ["/reports/report-1?from=%2Finbox", "inbox"],
+ ["/reports/report-1?from=%2Finbox%2Ftriage", "inbox"],
+ ["/reports/report-1?from=%2Fspaces%2Fchan-1", "spaces"],
+ ["/reports/report-1", "reports"],
+ ["/inbox?item=1", "inbox"],
+ ] as const)("puts %s on %s", (href, pane) => {
+ expect(railPaneForHref(href)).toBe(pane);
+ });
+});
+
describe("isRestorableVisitHref", () => {
it.each([
["spaces", "/spaces/chan-1/tasks/task-1"],
@@ -55,6 +90,8 @@ describe("isRestorableVisitHref", () => {
["spaces", "/new"],
["activity", "/activity?task=task-1"],
["inbox", "/inbox/pulls/report-1"],
+ ["inbox", "/inbox/triage"],
+ ["inbox", "/reports/report-1?from=%2Finbox"],
["home", "/"],
] as const)("lets %s replay %s", (pane, href) => {
expect(isRestorableVisitHref(pane, href)).toBe(true);
@@ -71,20 +108,55 @@ describe("isRestorableVisitHref", () => {
["inbox", "/inbox/agents"],
["spaces", "/activity"],
["activity", "/spaces/chan-1"],
+ ["activity", "/reports/report-1?from=%2Finbox"],
+ ["reports", "/reports/report-1?from=%2Finbox"],
] as const)("does not let %s replay %s", (pane, href) => {
expect(isRestorableVisitHref(pane, href)).toBe(false);
});
});
describe("railPaneHasSidebar", () => {
- it.each(["home", "inbox", "reports", "command-center", "loops"] as const)(
+ it.each([true, false])(
+ "hides the sidebar only on triage with channels layout %s",
+ (channelsLayout) => {
+ routing.channelsLayout = channelsLayout;
+ routing.href = "/inbox/triage";
+ useSidebarStore.setState({
+ open: true,
+ hasUserSetOpen: true,
+ width: 320,
+ });
+ const { result, rerender } = renderHook(() => useRailSurface());
+ expect(result.current.hasSidebar).toBe(false);
+ expect(result.current.pane).toBe("inbox");
+
+ for (const [href, hasSidebar] of [
+ ["/inbox", true],
+ ["/inbox/triage/", false],
+ ["/reports/report-1?from=%2Finbox%2Ftriage", true],
+ ["/inbox/triage?reportId=report-1", false],
+ ["/inbox/reports", true],
+ ] as const) {
+ routing.href = href;
+ rerender();
+ expect(result.current.hasSidebar).toBe(hasSidebar);
+ }
+ expect(useSidebarStore.getState()).toMatchObject({
+ open: true,
+ hasUserSetOpen: true,
+ width: 320,
+ });
+ },
+ );
+
+ it.each(["home", "reports", "command-center", "loops"] as const)(
"gives %s the whole screen",
(pane) => {
expect(railPaneHasSidebar(pane)).toBe(false);
},
);
- it.each(["spaces", "activity", "feeds"] as const)(
+ it.each(["spaces", "activity", "feeds", "inbox"] as const)(
"gives %s a column",
(pane) => {
expect(railPaneHasSidebar(pane)).toBe(true);
diff --git a/products/desktop/packages/ui/src/features/canvas/railPane.ts b/products/desktop/packages/ui/src/features/canvas/railPane.ts
index 82be31d3d786..d2c597823b47 100644
--- a/products/desktop/packages/ui/src/features/canvas/railPane.ts
+++ b/products/desktop/packages/ui/src/features/canvas/railPane.ts
@@ -1,4 +1,7 @@
-import { getCurrentMatches } from "@posthog/ui/router/navigationBridge";
+import {
+ hrefPath,
+ reportSourceHrefFromHref,
+} from "@posthog/ui/router/reportNavigation";
/**
* Which rail destination the app is on, and whether that destination owns the
@@ -66,16 +69,12 @@ export function railPaneForPath(fullPath: string): NavRailPane {
return "spaces";
}
-export function railPaneForMatches(
- matches: readonly { fullPath: string }[],
-): NavRailPane {
- return railPaneForPath(matches[matches.length - 1]?.fullPath ?? "");
-}
-
-/** Read the destination outside React (event handlers, imperative picks). */
-/** Not wired to a caller yet. The @public tag stops knip from reporting it. */
-export function getRailPane(): NavRailPane {
- return railPaneForMatches(getCurrentMatches());
+/**
+ * A report page belongs to the list it was opened from rather than to its own
+ * path, so `/reports/$id` under `?from=/inbox` is Self-driving.
+ */
+export function railPaneForHref(href: string): NavRailPane {
+ return railPaneForPath(reportSourceHrefFromHref(href) ?? hrefPath(href));
}
const NON_RESTORABLE_ROOTS = [
@@ -91,12 +90,12 @@ export function isRestorableVisitHref(
pane: NavRailPane,
href: string,
): boolean {
- const path = href.replace(/[?#].*$/, "");
+ const path = hrefPath(href);
const blocked = NON_RESTORABLE_ROOTS.some(
(root) => path === root || path.startsWith(`${root}/`),
);
if (blocked) return false;
- return railPaneForPath(path) === pane;
+ return railPaneForHref(href) === pane;
}
const PANES_WITH_SIDEBAR = new Set<NavRailPane>([
@@ -104,6 +103,7 @@ const PANES_WITH_SIDEBAR = new Set<NavRailPane>([
"activity",
"canvases",
"feeds",
+ "inbox",
]);
export function railPaneHasSidebar(pane: NavRailPane): boolean {
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
index 03b368602971..1d8e61fec597 100644
--- a/products/desktop/packages/ui/src/features/canvas/stores/activityDetailStore.test.ts
+++ b/products/desktop/packages/ui/src/features/canvas/stores/activityDetailStore.test.ts
@@ -1,7 +1,19 @@
-import { describe, expect, it } from "vitest";
-import { activityReportIdFromHref } from "./activityDetailStore";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const navigate = vi.hoisted(() => vi.fn());
+
+vi.mock("@posthog/ui/router/routerRef", () => ({
+ getRouterOrNull: () => ({ navigate }),
+}));
+
+import {
+ activityReportIdFromHref,
+ clearActivitySelection,
+} from "./activityDetailStore";
+
+describe("activityDetailStore", () => {
+ beforeEach(() => navigate.mockClear());
-describe("activityReportIdFromHref", () => {
it("identifies persisted Activity report tabs", () => {
expect(
activityReportIdFromHref("/activity?item=report-1&report=report-1"),
@@ -10,4 +22,14 @@ describe("activityReportIdFromHref", () => {
activityReportIdFromHref("/activity?item=task-1&session=session-1"),
).toBeNull();
});
+
+ it("clears the selected item without leaving Activity", () => {
+ clearActivitySelection();
+
+ expect(navigate).toHaveBeenCalledWith({
+ to: "/activity",
+ search: {},
+ replace: true,
+ });
+ });
});
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 97c57ca3f403..c84ff08909a2 100644
--- a/products/desktop/packages/ui/src/features/canvas/stores/activityDetailStore.ts
+++ b/products/desktop/packages/ui/src/features/canvas/stores/activityDetailStore.ts
@@ -97,6 +97,14 @@ export function getActivitySelection(): ActivitySelection | null {
return toSelection(match.search as ActivitySearch);
}
+export function clearActivitySelection(): void {
+ void getRouterOrNull()?.navigate({
+ to: "/activity",
+ search: {},
+ replace: true,
+ });
+}
+
export function selectActivityItem(item: TaskActivityItem): void {
void getRouterOrNull()?.navigate({
to: "/activity",
diff --git a/products/desktop/packages/ui/src/features/code-editor/components/DocumentPreviewHeader.tsx b/products/desktop/packages/ui/src/features/code-editor/components/DocumentPreviewHeader.tsx
index 1657f7dbf6c7..58033cb69abe 100644
--- a/products/desktop/packages/ui/src/features/code-editor/components/DocumentPreviewHeader.tsx
+++ b/products/desktop/packages/ui/src/features/code-editor/components/DocumentPreviewHeader.tsx
@@ -5,6 +5,7 @@ import {
TooltipContent,
TooltipTrigger,
} from "@posthog/quill";
+import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";
import { type ReactElement, type ReactNode, useState } from "react";
interface DocumentPreviewHeaderProps {
@@ -48,76 +49,78 @@ export function DocumentPreviewHeader({
};
return (
- <div className="flex h-10 shrink-0 items-center justify-between gap-2 border-b border-b-(--gray-6) px-3">
- <div className="flex min-w-0 items-center gap-2">
- <span className="truncate font-[var(--code-font-family)] text-[13px] text-muted-foreground">
- {label}
- </span>
- {versionNav}
- </div>
- <div className="flex shrink-0 items-center gap-1">
- {actions}
- {!editing && onToggleRendered && (
+ <ChromeBar
+ inset="even"
+ actions={
+ <>
+ {actions}
+ {!editing && onToggleRendered && (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ size="icon"
+ variant="default"
+ onClick={onToggleRendered}
+ aria-label={showRendered ? "View source" : "View preview"}
+ >
+ {showRendered ? <Code size={14} /> : <Eye size={14} />}
+ </Button>
+ }
+ />
+ <TooltipContent>
+ {showRendered ? "View source" : "View preview"}
+ </TooltipContent>
+ </Tooltip>
+ )}
<Tooltip>
<TooltipTrigger
render={
<Button
size="icon"
variant="default"
- onClick={onToggleRendered}
- aria-label={showRendered ? "View source" : "View preview"}
+ onClick={handleCopySource}
+ aria-label="Copy source"
>
- {showRendered ? <Code size={14} /> : <Eye size={14} />}
+ {copied ? <Check size={14} /> : <Copy size={14} />}
</Button>
}
/>
- <TooltipContent>
- {showRendered ? "View source" : "View preview"}
- </TooltipContent>
+ <TooltipContent>{copied ? "Copied" : "Copy source"}</TooltipContent>
</Tooltip>
- )}
- <Tooltip>
- <TooltipTrigger
- render={
+ {editing ? (
+ <>
<Button
- size="icon"
- variant="default"
- onClick={handleCopySource}
- aria-label="Copy source"
+ size="sm"
+ variant="outline"
+ disabled={saving}
+ onClick={onCancel}
>
- {copied ? <Check size={14} /> : <Copy size={14} />}
+ Cancel
</Button>
- }
- />
- <TooltipContent>{copied ? "Copied" : "Copy source"}</TooltipContent>
- </Tooltip>
- {editing ? (
- <>
- <Button
- size="sm"
- variant="outline"
- disabled={saving}
- onClick={onCancel}
- >
- Cancel
- </Button>
- <Button
- size="sm"
- variant="primary"
- loading={saving}
- onClick={onSave}
- >
- Save
- </Button>
- </>
- ) : (
- canEdit && (
- <Button size="sm" variant="outline" onClick={onEdit}>
- Edit
- </Button>
- )
- )}
- </div>
- </div>
+ <Button
+ size="sm"
+ variant="primary"
+ loading={saving}
+ onClick={onSave}
+ >
+ Save
+ </Button>
+ </>
+ ) : (
+ canEdit && (
+ <Button size="sm" variant="outline" onClick={onEdit}>
+ Edit
+ </Button>
+ )
+ )}
+ </>
+ }
+ >
+ <span className="truncate font-[var(--code-font-family)] text-[13px] text-muted-foreground">
+ {label}
+ </span>
+ {versionNav}
+ </ChromeBar>
);
}
diff --git a/products/desktop/packages/ui/src/features/inbox/AGENTS.md b/products/desktop/packages/ui/src/features/inbox/AGENTS.md
index 896fb3c8e483..2c7a92d4e36c 100644
--- a/products/desktop/packages/ui/src/features/inbox/AGENTS.md
+++ b/products/desktop/packages/ui/src/features/inbox/AGENTS.md
@@ -89,6 +89,56 @@ Do not add frontend-only controls that imply a backend capability. If the UI exp
`InboxView` is the layout shell for `/inbox/*`. It owns the page header, tab bar, reviewer scope control, and nested route outlet. Route files live in `apps/code/src/renderer/routes/inbox/`.
+Under the spaces layout Self-driving is a rail destination that owns the column
+beside the rail (`railPaneHasSidebar`, `railPane.ts`). `InboxPane` draws the
+report list there and `ChannelsSidebar` mounts it; the pane beside it holds the
+report you picked. So `/inbox` renders `InboxHomePane` (nothing selected, or
+triage) instead of the page list, and a row opens the canonical
+`/reports/$reportId` with `?from=/inbox`, which is what keeps the rail lit and
+the list in place. Off that layout nothing changes: `/inbox` is still the full
+`ReportsInboxView` page.
+
+The pane's list is grouped by how long ago each report was found, in the same
+widening buckets the task list uses (`groupReportsByAge`, over
+`getRelativeDateGroup`): Today, Yesterday, This week, This month, Earlier. A
+separator per calendar day left most of the list one row per header, because
+reports arrive over weeks. The bucket leads and the chosen sort orders the rows
+inside it, so "Priority first" reads as the most urgent thing found today, then
+the most urgent thing found this week.
+
+A report opened from a pane closes back to it: `ReportDetailCloseButton` sits at
+the end of the header row and navigates to the `?from=` source, leaving the list
+standing and the pane on its empty state, the way Activity closes an item. A
+report with no source draws no button, because there is no list beside it.
+
+`InboxDetailFrameView` draws one header row, and only its container changes: on
+the report's own page it goes to the app header bar through the header store,
+and in a pane (Activity) the frame draws its own `ChromeBar` at the top. There
+is no second, padded header shape. `DetailBackLink` takes the report as a prop
+and renders its crumb trail.
+
+The trail names where the report lives, not the surface it is being read on. So
+a report opened from Activity still reads "Self-driving / <report>": the first
+crumb is the `?from=` source when a route carried one, and Self-driving
+otherwise. Activity is a place you can read a report from, not a place a report
+belongs to.
+
+Triage is a route, `/inbox/triage` (`triageRoute.ts`), not a mode flag. It is a
+place you can be, so it survives a reload, restores with the rail, and a report
+opened out of it carries `?from=/inbox/triage`, which is what makes the close
+button land back in the queue. `InboxTriagePane` renders it for both layouts;
+the button in the list header is a `Link`, and `useInboxTriageHotkey` gives the
+list its "t". Nothing holds triage in a store: the URL is the state.
+
+`useSetHeaderContent` takes the title row or `null`; a view with nothing to name
+pushes null. Beside the rail's list the pane names nothing, so `InboxView`
+pushes null there and the row collapses. The report a row opens pushes its own.
+
+`useInboxSectionedReports` assembles the list both surfaces read, so the sidebar
+and the page can never disagree about what is in the inbox. React Query dedupes
+the requests, but paging is a side effect, so only one caller may drive it: the
+sidebar pages, `InboxHomePane` passes `autoPage: false`.
+
The tab components are intentionally simple:
- `PullRequestsTab` partitions scoped reports with `isPullRequestReport`.
@@ -98,6 +148,12 @@ The tab components are intentionally simple:
The detail components share the same shape: load the report, render a common header, then render tab-specific sections. Detail sections should explain the report in product terms, not expose backend object names.
+Filter option tables and their labels live in `filterOptions.tsx`, not in the
+component that draws them: the page's separate controls and the pane's menu are
+two renderings of one set of choices, and they drifted when each held its own
+copy. `hasActiveReportsListFilters` (the filter store) is the single answer to
+"is this list filtered", so every surface drawing the list agrees.
+
## Data Flow
`useInboxAllReports` is the list source of truth. It reads UI scope/filter state, calls the paginated report list hook, returns filtered reports, and computes counts used by the tabs. Multiple tab bodies can call it because React Query dedupes the underlying request.
@@ -147,7 +203,13 @@ An empty Reports view has two distinct causes, and they need different copy: not
## UI Architecture
-The current UI is single-column, route-based, and card/list oriented. Do not reintroduce the old split-pane list/detail layout.
+The page body is single-column, route-based, and card/list oriented. Do not reintroduce the old split-pane list/detail layout inside it: under the spaces layout the list moved out to the rail's sidebar column, which is app chrome shared with Spaces and Activity, not a pane the page draws.
+
+Header and toolbar buttons take their size from the `Button` prop, never from
+hand-written height, padding or text classes: `size="sm"` for a button with a
+label, `size="icon-sm"` for an icon-only one. A row of buttons that each carry
+their own `h-7 px-2.5 text-[12px]` drifts apart the moment one of them is
+edited, and it sits a size away from every other toolbar in the app.
Shared primitives exist to keep the surfaces consistent:
@@ -165,7 +227,7 @@ Components come from `@posthog/quill`; layout is `div`s with Tailwind. Radix is
- Do not add any `@radix-ui/*` import. Use `@posthog/quill` plus `div` + Tailwind.
- Do not reuse the deleted legacy `ReportListRow`, `ReportDetailPane`, or old list/detail stores.
-- Do not put page-level Inbox title or navigation into the global app header; `InboxView` owns the Inbox page chrome.
+- The Inbox title is a breadcrumb row, not a page header. `InboxView` pushes it into the header store and `ContentHeader` draws it, the same tight row task detail and the loop scenes use. Do not add a second in-page title above the list. Beside the rail's list the pane draws no row at all, because an empty pane and triage name nothing the column's own title does not already say. The row comes back for the report a row opens, which pushes its own crumb and actions.
- Responder configuration stays in Settings (`/settings/agents`). The Inbox header carries a "Configure agents" link toward it, but do not embed configuration UI in the Inbox itself.
- Scout (`signals_scout`) is a real Cloud source product. Keep it covered wherever source products surface: `INBOX_SOURCE_OPTIONS`, `SOURCE_PRODUCT_META`, and the scout-name display in `SignalCard`.
- Scout management UI (fleet configuration, run history) lives in `features/scouts/` and is backed by the PostHog Cloud scout endpoints (`/api/projects/{teamId}/signals/scout/`). Do not add scout controls that have no backing endpoint there.
diff --git a/products/desktop/packages/ui/src/features/inbox/components/DetailBackLink.tsx b/products/desktop/packages/ui/src/features/inbox/components/DetailBackLink.tsx
index b1c5d999b323..190d13228749 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/DetailBackLink.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/DetailBackLink.tsx
@@ -1,70 +1,17 @@
import { ArrowLeftIcon } from "@phosphor-icons/react";
-import { humanizeReportTitle } from "@posthog/core/inbox/reportPresentation";
-import { prettifyScoutSkillName } from "@posthog/core/scouts/scoutPresentation";
-import type { SignalReport } from "@posthog/shared/types";
-import { useChannels } from "@posthog/ui/features/canvas/hooks/useChannels";
-import { useReportPage } from "@posthog/ui/features/inbox/components/ReportPageContext";
-import {
- type InboxTriageOrigin,
- useInboxTriageOrigin,
-} from "@posthog/ui/features/inbox/hooks/useInboxBackTarget";
-import {
- BreadcrumbSegment,
- BreadcrumbSeparator,
-} from "@posthog/ui/primitives/Breadcrumb";
-import {
- type NavigationSource,
- resolveNavigationSource,
- useReportSourceHref,
-} from "@posthog/ui/router/reportNavigation";
+import { useInboxTriageOrigin } from "@posthog/ui/features/inbox/hooks/useInboxBackTarget";
import { Link } from "@tanstack/react-router";
import type { ReactElement } from "react";
-interface DetailBackLinkProps {
+/** The way back from a detail screen with no report to name (a missing one). */
+export function DetailBackLink({
+ to,
+ label,
+}: {
to: string;
label: string;
-}
-
-interface Crumb {
- label: string;
- render?: ReactElement;
-}
-
-export function DetailBackLink({ to, label }: DetailBackLinkProps) {
+}): ReactElement {
const triageOrigin = useInboxTriageOrigin();
- const report = useReportPage();
- const sourceHref = useReportSourceHref();
- const { channels } = useChannels({ enabled: report !== null });
-
- if (report) {
- const spaceName = (id: string) => channels.find((c) => c.id === id)?.name;
- const crumbs = reportCrumbs(
- resolveNavigationSource(sourceHref),
- report,
- triageOrigin,
- spaceName,
- );
- return (
- <div className="flex min-w-0 items-center gap-0.5">
- {crumbs.map((crumb, index) => (
- <div
- key={`${index}-${crumb.label}`}
- className="flex min-w-0 items-center gap-0.5"
- >
- {index > 0 && <BreadcrumbSeparator />}
- <BreadcrumbSegment
- label={crumb.label}
- strong={index === 0}
- muted={index === crumbs.length - 1}
- shrink={index === crumbs.length - 1}
- render={crumb.render}
- />
- </div>
- ))}
- </div>
- );
- }
-
const returnsToTriage = to === "/inbox/reports" && triageOrigin !== null;
return (
@@ -85,81 +32,3 @@ export function DetailBackLink({ to, label }: DetailBackLinkProps) {
</Link>
);
}
-
-function reportCrumbs(
- source: NavigationSource | null,
- report: SignalReport,
- triageOrigin: InboxTriageOrigin | null,
- spaceName: (id: string) => string | undefined,
-): Crumb[] {
- const crumbs: Crumb[] = [];
- // TanStack blanks history state on a plain Link, so the Reports-list crumb
- // must carry the triage origin forward or triage focus mode dies on the way
- // back.
- const exact = source ? (
- <Link
- to={source.href}
- state={
- source.path === "/inbox/reports" && triageOrigin
- ? (previous) => ({ ...previous, inboxTriageOrigin: triageOrigin })
- : undefined
- }
- />
- ) : undefined;
-
- if (source?.settingsCategory) {
- crumbs.push({
- label: source.label,
- render: source.agentSkillName ? (
- <Link
- to="/settings/$category"
- params={{ category: source.settingsCategory }}
- />
- ) : (
- exact
- ),
- });
- if (source.agentSkillName) {
- crumbs.push({
- label: prettifyScoutSkillName(source.agentSkillName),
- render: exact,
- });
- }
- } else if (source?.spaceId) {
- const name = spaceName(source.spaceId);
- crumbs.push({ label: name ? `#${name}` : source.label, render: exact });
- } else if (source) {
- crumbs.push({ label: source.label, render: exact });
- } else {
- crumbs.push({
- label: "Self-driving",
- render: (
- <Link
- to="/inbox/reports"
- state={
- triageOrigin
- ? (previous) => ({ ...previous, inboxTriageOrigin: triageOrigin })
- : undefined
- }
- />
- ),
- });
- }
-
- const ownSpace =
- report.channel_id && report.channel_id !== source?.spaceId
- ? report.channel_id
- : null;
- const ownSpaceName = ownSpace ? spaceName(ownSpace) : undefined;
- if (ownSpace && ownSpaceName) {
- crumbs.push({
- label: `#${ownSpaceName}`,
- render: <Link to="/spaces/$channelId" params={{ channelId: ownSpace }} />,
- });
- }
-
- crumbs.push({
- label: humanizeReportTitle(report.title, "Untitled report"),
- });
- return crumbs;
-}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/DetailSection.tsx b/products/desktop/packages/ui/src/features/inbox/components/DetailSection.tsx
index c74e4bfdc230..ae0c9b257f60 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/DetailSection.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/DetailSection.tsx
@@ -43,11 +43,11 @@ export function DetailSection({
);
return (
- <section className="flex min-w-0 flex-col rounded-(--radius-2) border border-(--gray-4) bg-(--color-panel-solid)">
+ <section className="flex min-w-0 flex-col rounded-sm border border-border bg-card">
<header
className={cn(
- "flex select-none items-center gap-3 px-3.5",
- open && "border-(--gray-4) border-b",
+ "flex select-none items-center gap-2 pr-2 pl-3 hover:bg-fill-hover",
+ open && "border-border border-b",
collapsible ? "py-0" : "cursor-default py-2.5",
)}
>
@@ -56,7 +56,7 @@ export function DetailSection({
type="button"
onClick={toggle}
aria-expanded={open}
- className="flex min-w-0 flex-1 items-center gap-2 py-2.5 text-left"
+ className="flex min-w-0 flex-1 items-center gap-2 py-2 text-left"
>
{titleCluster}
</button>
diff --git a/products/desktop/packages/ui/src/features/inbox/components/DismissedReportDetail.tsx b/products/desktop/packages/ui/src/features/inbox/components/DismissedReportDetail.tsx
index c5dd979fea43..ea78dde2eec8 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/DismissedReportDetail.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/DismissedReportDetail.tsx
@@ -11,10 +11,7 @@ import { InboxReportCopyLinkMenu } from "@posthog/ui/features/inbox/components/I
import { InboxReportDetailGate } from "@posthog/ui/features/inbox/components/InboxReportDetailGate";
import { useReportPage } from "@posthog/ui/features/inbox/components/ReportPageContext";
import { ReportTrackerIssueLink } from "@posthog/ui/features/inbox/components/utils/ReportTrackerIssueLink";
-import {
- type InboxBackTarget,
- useInboxBackTarget,
-} from "@posthog/ui/features/inbox/hooks/useInboxBackTarget";
+import { useInboxBackTarget } from "@posthog/ui/features/inbox/hooks/useInboxBackTarget";
import { useInboxRestoreReport } from "@posthog/ui/features/inbox/hooks/useInboxRestoreReport";
import { Spinner } from "@posthog/ui/primitives/Spinner";
import { useNavigate } from "@tanstack/react-router";
@@ -59,17 +56,15 @@ export function DismissedReportDetail({
backLinkLabel={back.label}
missingCopy="This report couldn't be found. It may have been deleted."
>
- {(report) => <DismissedReportDetailContent report={report} back={back} />}
+ {(report) => <DismissedReportDetailContent report={report} />}
</InboxReportDetailGate>
);
}
export function DismissedReportDetailContent({
report,
- back,
}: {
report: SignalReport;
- back: InboxBackTarget;
}) {
// Resolved reports are terminal (their PR already merged) — nothing to
// restore, so only suppressed reports get a Restore action.
@@ -77,8 +72,6 @@ export function DismissedReportDetailContent({
return (
<InboxDetailFrame
report={report}
- backTo={back.to}
- backLabel={back.label}
fallbackTitle="Untitled report"
showDismiss={false}
metaSuffix={<ReportTrackerIssueLink report={report} />}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrame.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrame.test.tsx
index 1924d60388fc..cac2f32d9598 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrame.test.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrame.test.tsx
@@ -1,10 +1,19 @@
import { FileTextIcon } from "@phosphor-icons/react";
import type { SignalReport } from "@posthog/shared/types";
-import { render, screen } from "@testing-library/react";
-import { describe, expect, it, vi } from "vitest";
+import {
+ ANONYMOUS_AUTH_STATE,
+ useAuthStore,
+} from "@posthog/ui/features/auth/store";
+import { useInboxReportReadStore } from "@posthog/ui/features/inbox/stores/inboxReportReadStore";
+import { act, render, screen } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
-vi.mock("@posthog/ui/features/inbox/components/DetailBackLink", () => ({
- DetailBackLink: () => null,
+vi.mock("@posthog/ui/features/auth/useCurrentUser", () => ({
+ useCurrentUser: () => ({ data: { uuid: "reader-1" } }),
+}));
+
+vi.mock("@posthog/ui/features/inbox/components/ReportBreadcrumbs", () => ({
+ ReportBreadcrumbs: () => null,
}));
vi.mock("@posthog/ui/features/inbox/hooks/useInboxReportDismissAction", () => ({
@@ -40,20 +49,74 @@ const report: SignalReport = {
};
describe("InboxDetailFrame", () => {
- it("shows the conventional commit tag beside the report title", () => {
+ beforeEach(() => {
+ useAuthStore.setState({
+ authState: {
+ ...ANONYMOUS_AUTH_STATE,
+ status: "authenticated",
+ cloudRegion: "us",
+ currentProjectId: 1,
+ },
+ });
+ useInboxReportReadStore.setState({ readByKey: {}, hasHydrated: true });
+ });
+
+ it.each([
+ report,
+ {
+ ...report,
+ implementation_pr_url: "https://github.com/example/project/pull/1",
+ },
+ { ...report, status: "resolved" as const },
+ ])(
+ "marks an opened report read but preserves an explicit unread choice until it reopens %#",
+ (openedReport) => {
+ const key = JSON.stringify(["us:1", "reader-1", openedReport.id]);
+ const frame = (
+ <InboxDetailFrame
+ report={openedReport}
+ fallbackTitle="Report"
+ summarySection={{ Icon: FileTextIcon, title: "Summary" }}
+ evidenceSection={null}
+ showMetadata={false}
+ />
+ );
+ const { rerender, unmount } = render(frame);
+ expect(useInboxReportReadStore.getState().readByKey[key]).toBe(true);
+ act(() => useInboxReportReadStore.getState().setRead(key, false));
+ rerender(frame);
+ expect(useInboxReportReadStore.getState().readByKey[key]).toBe(false);
+ unmount();
+ render(frame);
+ expect(useInboxReportReadStore.getState().readByKey[key]).toBe(true);
+ },
+ );
+
+ it("keeps report context quiet and feedback after the supporting sections", () => {
render(
<InboxDetailFrame
- report={report}
- backTo="/inbox/reports"
- backLabel="Back to reports"
+ report={{ ...report, priority: "P2", is_suggested_reviewer: true }}
fallbackTitle="Untitled report"
summarySection={{ Icon: FileTextIcon, title: "Summary" }}
evidenceSection={null}
showDismiss={false}
- />,
+ footer={<div>Was this report useful?</div>}
+ >
+ <section>Reviewers</section>
+ </InboxDetailFrame>,
);
expect(screen.getByText("feat(dashboards)")).toBeInTheDocument();
expect(screen.getByText("Add compact legend controls")).toBeInTheDocument();
+ expect(screen.getByRole("tab", { name: "Summary" })).toBeInTheDocument();
+ expect(screen.getAllByText("Summary")).toHaveLength(1);
+ expect(screen.queryByText("For you")).not.toBeInTheDocument();
+ expect(screen.queryByText("P2")).not.toBeInTheDocument();
+ expect(
+ screen
+ .getByText("Reviewers")
+ .compareDocumentPosition(screen.getByText("Was this report useful?")) &
+ Node.DOCUMENT_POSITION_FOLLOWING,
+ ).toBeTruthy();
});
});
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrame.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrame.tsx
index 805c90a992cc..f5dd65ba7bab 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrame.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrame.tsx
@@ -1,23 +1,17 @@
import type { IconProps } from "@phosphor-icons/react";
-import { extractRepoSelectionRepository } from "@posthog/core/inbox/artefacts";
import type { SignalReport } from "@posthog/shared/types";
import { InboxDetailFrameView } from "@posthog/ui/features/inbox/components/InboxDetailFrameView";
import {
SignalsList,
SignalsListSkeleton,
} from "@posthog/ui/features/inbox/components/SignalsList";
-import type { InboxListRoute } from "@posthog/ui/features/inbox/hooks/useInboxBackTarget";
import { useInboxReportDismissAction } from "@posthog/ui/features/inbox/hooks/useInboxReportDismissAction";
-import {
- useInboxReportArtefacts,
- useInboxReportSignals,
-} from "@posthog/ui/features/inbox/hooks/useInboxReports";
-import type { ComponentType, ReactNode } from "react";
+import { useInboxReportReadState } from "@posthog/ui/features/inbox/hooks/useInboxReportReadState";
+import { useInboxReportSignals } from "@posthog/ui/features/inbox/hooks/useInboxReports";
+import { type ComponentType, type ReactNode, useEffect } from "react";
interface InboxDetailFrameProps {
report: SignalReport;
- backTo: InboxListRoute | (string & {});
- backLabel: string;
showDismiss?: boolean;
showMetadata?: boolean;
fallbackTitle: string;
@@ -43,8 +37,6 @@ interface InboxDetailFrameProps {
export function InboxDetailFrame({
report,
- backTo,
- backLabel,
fallbackTitle,
breadcrumb,
metaPrefix,
@@ -61,11 +53,15 @@ export function InboxDetailFrame({
showMetadata = true,
children,
}: InboxDetailFrameProps): React.JSX.Element {
+ const { enabled: readStateEnabled, setRead } = useInboxReportReadState(
+ report.id,
+ );
+ useEffect(() => {
+ if (readStateEnabled) setRead(true);
+ }, [readStateEnabled, setRead]);
const { data: signalsResp } = useInboxReportSignals(report.id);
const signals = signalsResp?.signals ?? [];
const signalsLoaded = signalsResp !== undefined;
- const { data: artefactsResp } = useInboxReportArtefacts(report.id);
- const runRepository = extractRepoSelectionRepository(artefactsResp?.results);
const { actionButton: dismissButton, dialog: dismissDialog } =
useInboxReportDismissAction(report);
@@ -89,8 +85,6 @@ export function InboxDetailFrame({
return (
<InboxDetailFrameView
report={report}
- backTo={backTo}
- backLabel={backLabel}
fallbackTitle={fallbackTitle}
breadcrumb={breadcrumb}
metaPrefix={metaPrefix}
@@ -103,7 +97,6 @@ export function InboxDetailFrame({
evidenceSection={evidenceSection}
evidenceCount={evidenceCount}
evidenceContent={evidenceContent}
- runRepository={runRepository}
aboveEvidence={aboveEvidence}
secondaryTab={secondaryTab}
showMetadata={showMetadata}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrameView.stories.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrameView.stories.tsx
index c04da0125322..8392c7fcecfc 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrameView.stories.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrameView.stories.tsx
@@ -7,10 +7,12 @@ import {
GitPullRequestIcon,
MagnifyingGlassIcon,
PlusIcon,
+ ReceiptIcon,
TerminalIcon,
UsersThreeIcon,
XIcon,
} from "@phosphor-icons/react";
+import { deriveReportVerdict } from "@posthog/core/inbox/reportVerdict";
import { Button } from "@posthog/quill";
import { DetailSection } from "@posthog/ui/features/inbox/components/DetailSection";
import { InboxDetailFrameView } from "@posthog/ui/features/inbox/components/InboxDetailFrameView";
@@ -18,6 +20,7 @@ import {
inboxStoryReport,
inboxStorySignal,
} from "@posthog/ui/features/inbox/components/inboxStoryFixtures";
+import { ReportVerdictCallout } from "@posthog/ui/features/inbox/components/ReportVerdictCallout";
import { SignalsList } from "@posthog/ui/features/inbox/components/SignalsList";
import type { Meta, StoryObj } from "@storybook/react-vite";
import type { ReactNode } from "react";
@@ -34,7 +37,7 @@ const signals = [
];
const pageAt = (width: number) => (Story: () => ReactNode) => (
- <div className="min-h-[760px] bg-gray-1" style={{ width }}>
+ <div className="min-h-[760px] w-full bg-gray-1" style={{ maxWidth: width }}>
<Story />
</div>
);
@@ -46,8 +49,6 @@ const meta: Meta<typeof InboxDetailFrameView> = {
decorators: [pageAt(1360)],
args: {
report,
- backTo: "/inbox/reports",
- backLabel: "Back to reports",
fallbackTitle: "Untitled report",
primaryAction: (
<>
@@ -65,12 +66,11 @@ const meta: Meta<typeof InboxDetailFrameView> = {
</Button>
</>
),
- showMetadata: false,
- summarySection: { Icon: FileTextIcon, title: "Report summary" },
+ showMetadata: true,
+ summarySection: { Icon: FileTextIcon, title: "Summary" },
evidenceSection: { Icon: MagnifyingGlassIcon, title: "Evidence" },
evidenceCount: signals.length,
evidenceContent: <SignalsList signals={signals} />,
- runRepository: "PostHog/posthog",
belowSummary: (
<div className="flex select-none flex-col gap-3 rounded-lg border border-(--amber-6) bg-(--amber-2) p-4">
<div className="flex flex-col gap-1">
@@ -98,6 +98,9 @@ const meta: Meta<typeof InboxDetailFrameView> = {
</div>
</div>
),
+ footer: (
+ <p className="m-0 text-[13px] text-gray-11">Was this report useful?</p>
+ ),
children: (
<>
<DetailSection
@@ -155,6 +158,31 @@ type Story = StoryObj<typeof InboxDetailFrameView>;
export const EvidenceFirst: Story = {};
+export const LikelyAlreadyFixed: Story = {
+ args: {
+ report: inboxStoryReport({ already_addressed: true }),
+ belowSummary: (
+ <ReportVerdictCallout
+ verdict={deriveReportVerdict(
+ inboxStoryReport({ already_addressed: true }),
+ { hasExistingPr: false },
+ )}
+ >
+ <div className="flex flex-wrap items-center gap-2.5">
+ <Button variant="outline">
+ <ChatCircleIcon />
+ Ask about it
+ </Button>
+ <Button variant="outline">
+ <EyeSlashIcon />
+ Dismiss…
+ </Button>
+ </div>
+ </ReportVerdictCallout>
+ ),
+ },
+};
+
export const WaitingForInput: Story = {
args: {
report: inboxStoryReport({
@@ -209,5 +237,38 @@ export const LongTitle: Story = {
};
export const Narrow: Story = {
- decorators: [pageAt(720)],
+ decorators: [pageAt(520)],
+};
+
+export const WithPullRequest: Story = {
+ args: {
+ report: inboxStoryReport({
+ implementation_pr_url: "https://github.com/example/project/pull/42",
+ }),
+ primaryAction: (
+ <>
+ <Button variant="outline" size="sm">
+ Open in GitHub
+ </Button>
+ <Button variant="outline" size="sm">
+ <ChatCircleIcon />
+ Chat
+ </Button>
+ <Button variant="outline" size="sm">
+ <EyeSlashIcon />
+ Dismiss
+ </Button>
+ <Button variant="outline" size="sm">
+ <ReceiptIcon />
+ Refund
+ </Button>
+ </>
+ ),
+ summarySection: { Icon: FileTextIcon, title: "Summary" },
+ secondaryTab: {
+ label: "Changed code",
+ content: <p>Changed files appear here.</p>,
+ },
+ belowSummary: null,
+ },
};
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrameView.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrameView.tsx
index 1ca89aa446ef..b4bcc036970c 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrameView.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrameView.tsx
@@ -3,37 +3,24 @@ import {
humanizeReportTitle,
parseConventionalCommitTitle,
} from "@posthog/core/inbox/reportPresentation";
-import {
- Tabs,
- TabsList,
- TabsTrigger,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from "@posthog/quill";
+import { Tabs, TabsList, TabsTrigger } from "@posthog/quill";
import type { SignalReport } from "@posthog/shared/types";
import { ConventionalCommitScopeTag } from "@posthog/ui/features/inbox/components/ConventionalCommitScopeTag";
-import { DetailBackLink } from "@posthog/ui/features/inbox/components/DetailBackLink";
-import {
- InboxMetaRow,
- InboxMetaSeparator,
- InboxMetaText,
-} from "@posthog/ui/features/inbox/components/InboxMetaRow";
-import { InboxMetaSourceStack } from "@posthog/ui/features/inbox/components/InboxMetaSourceStack";
+import { InboxMetaRow } from "@posthog/ui/features/inbox/components/InboxMetaRow";
+import { ReportBreadcrumbs } from "@posthog/ui/features/inbox/components/ReportBreadcrumbs";
+import { ReportDetailCloseButton } from "@posthog/ui/features/inbox/components/ReportDetailCloseButton";
+import { useReportPage } from "@posthog/ui/features/inbox/components/ReportPageContext";
import { ReportSummaryDocument } from "@posthog/ui/features/inbox/components/ReportSummaryDocument";
import { RightColumnSection } from "@posthog/ui/features/inbox/components/RightColumnSection";
-import { ForYouBadge } from "@posthog/ui/features/inbox/components/utils/ForYouBadge";
import { SignalReportStatusBadge } from "@posthog/ui/features/inbox/components/utils/SignalReportStatusBadge";
-import { hasKnownSourceProduct } from "@posthog/ui/features/inbox/components/utils/source-product-icons";
-import type { InboxListRoute } from "@posthog/ui/features/inbox/hooks/useInboxBackTarget";
+import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";
+import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";
import { RelativeTimestamp } from "@posthog/ui/primitives/RelativeTimestamp";
import type { ComponentType, ReactNode } from "react";
-import { useState } from "react";
+import { useMemo, useState } from "react";
export interface InboxDetailFrameViewProps {
report: SignalReport;
- backTo: InboxListRoute | (string & {});
- backLabel: string;
fallbackTitle: string;
breadcrumb?: ReactNode;
metaPrefix?: ReactNode;
@@ -49,7 +36,6 @@ export interface InboxDetailFrameViewProps {
} | null;
evidenceCount: number;
evidenceContent?: ReactNode;
- runRepository?: string | null;
aboveEvidence?: ReactNode;
secondaryTab?: { label: ReactNode; content: ReactNode };
dismissButton?: ReactNode;
@@ -60,8 +46,6 @@ export interface InboxDetailFrameViewProps {
export function InboxDetailFrameView({
report,
- backTo,
- backLabel,
fallbackTitle,
breadcrumb,
metaPrefix,
@@ -74,7 +58,6 @@ export function InboxDetailFrameView({
evidenceSection,
evidenceCount,
evidenceContent,
- runRepository,
aboveEvidence,
secondaryTab,
dismissButton,
@@ -83,7 +66,7 @@ export function InboxDetailFrameView({
children,
}: InboxDetailFrameViewProps): React.JSX.Element {
const [activeTab, setActiveTab] = useState("overview");
- const hasSource = hasKnownSourceProduct(report.source_products);
+ const ownsChrome = useReportPage() !== null;
const EvidenceIcon = evidenceSection?.Icon;
const hasEvidence =
evidenceSection != null && EvidenceIcon != null && evidenceCount > 0;
@@ -104,98 +87,69 @@ export function InboxDetailFrameView({
const reportMeta = (
<>
{metaPrefix}
- {evidenceCount > 0 && (
- <>
- <InboxMetaText className="tabular-nums">
- {evidenceCount} signal{evidenceCount === 1 ? "" : "s"}
- </InboxMetaText>
- <InboxMetaSeparator />
- </>
- )}
<RelativeTimestamp
timestamp={report.updated_at ?? report.created_at}
className="text-[13px]"
/>
- {hasSource && (
- <>
- <InboxMetaSeparator />
- <InboxMetaSourceStack
- sourceProducts={report.source_products}
- labelPrefix="Agent · "
- />
- </>
- )}
- {report.priority && (
- <>
- <InboxMetaSeparator />
- <InboxMetaText>{report.priority}</InboxMetaText>
- </>
- )}
- {runRepository && (
- <>
- <InboxMetaSeparator />
- <Tooltip>
- <TooltipTrigger
- render={<InboxMetaText mono className="cursor-help" />}
- >
- {runRepository}
- </TooltipTrigger>
- <TooltipContent side="top">
- Agent runs for this report work in this repository
- </TooltipContent>
- </Tooltip>
- </>
- )}
{metaSuffix}
</>
);
+ const trail = useMemo(
+ () => (
+ <div className="flex min-w-0 flex-1 items-center gap-2 text-[13px] text-gray-11">
+ <ReportBreadcrumbs report={report} />
+ {breadcrumb}
+ </div>
+ ),
+ [report, breadcrumb],
+ );
+ const actions = useMemo(
+ () => (
+ <>
+ {primaryAction}
+ {dismissButton}
+ {ownsChrome && <ReportDetailCloseButton />}
+ </>
+ ),
+ [primaryAction, dismissButton, ownsChrome],
+ );
+ const header = useMemo(
+ () => (
+ <>
+ {trail}
+ <div className="flex shrink-0 items-center gap-2">{actions}</div>
+ </>
+ ),
+ [trail, actions],
+ );
+ useSetHeaderContent(header, ownsChrome);
+
return (
<div className="@container flex min-h-full flex-col">
- <div className="mx-auto flex w-full max-w-[calc(160ch+5rem)] flex-wrap items-center justify-between gap-3 px-6 py-4">
- <div className="flex items-center gap-2 text-[13.5px] text-gray-11">
- <DetailBackLink to={backTo} label={backLabel} />
- {breadcrumb}
- </div>
- <div className="flex flex-wrap items-center justify-end gap-2.5">
- {primaryAction}
- {dismissButton}
- </div>
- </div>
+ {!ownsChrome && (
+ <ChromeBar inset="control" actions={actions}>
+ {trail}
+ </ChromeBar>
+ )}
- <div className="mx-auto w-full max-w-[calc(160ch+5rem)] px-6 pb-5 text-[14px]">
- <div className="flex @5xl:flex-row flex-col @5xl:items-start overflow-hidden rounded-(--radius-3) border border-(--gray-5) bg-(--color-panel-solid)">
- <aside className="@5xl:order-none order-2 flex @5xl:w-[26rem] w-full min-w-0 @5xl:shrink-0 flex-col gap-5 @5xl:self-stretch border-(--gray-5) border-t @5xl:border-t-0 @5xl:border-r p-5">
- {hasEvidence && (
- <RightColumnSection
- Icon={EvidenceIcon}
- title={evidenceSection.title}
- collapsible
- rightSlot={
- <span className="cursor-default select-none text-[12px] text-gray-10 tabular-nums">
- {evidenceCount} signal{evidenceCount === 1 ? "" : "s"}
- </span>
- }
+ <div className="mx-auto w-full max-w-[calc(160ch+5rem)]">
+ <div className="flex @5xl:flex-row flex-col @5xl:items-start overflow-hidden">
+ <main className="@5xl:order-none order-1 flex min-w-0 flex-1 flex-col">
+ <Tabs
+ value={secondaryTab ? activeTab : "overview"}
+ onValueChange={setActiveTab}
+ >
+ <TabsList
+ variant="line"
+ className="h-auto w-full justify-start gap-0.5 border-border border-b"
>
- {evidenceContent}
- </RightColumnSection>
- )}
- {aboveEvidence}
- {children}
- </aside>
-
- <main className="@5xl:order-none order-1 flex min-w-0 flex-1 flex-col @5xl:px-8 px-6 py-5">
- {secondaryTab ? (
- <Tabs value={activeTab} onValueChange={setActiveTab}>
- <TabsList
- variant="line"
- className="mb-5 h-auto w-full justify-start gap-0.5 border-(--gray-5) border-b"
- >
- <TabsTrigger value="overview" className="gap-1.5 px-2.5 py-2">
- <span className="font-bold text-[14px]">
- {summarySection.title}
- </span>
- </TabsTrigger>
+ <TabsTrigger value="overview" className="gap-1.5 px-2.5 py-2">
+ <span className="font-bold text-[14px]">
+ {summarySection.title}
+ </span>
+ </TabsTrigger>
+ {secondaryTab && (
<TabsTrigger
value="secondary"
className="gap-1.5 px-2.5 py-2"
@@ -204,29 +158,19 @@ export function InboxDetailFrameView({
{secondaryTab.label}
</span>
</TabsTrigger>
- </TabsList>
- </Tabs>
- ) : (
- <div className="mb-5 flex items-center gap-2.5 border-(--gray-5) border-b pb-3">
- <span className="font-bold text-[14px] text-gray-12">
- {summarySection.title}
- </span>
- <span className="flex-1" />
- <span className="text-[12px] text-gray-10">
- Generated <RelativeTimestamp timestamp={report.created_at} />
- </span>
- </div>
- )}
+ )}
+ </TabsList>
+ </Tabs>
{secondaryTab && activeTab === "secondary" ? (
- <div className="flex min-w-0 flex-col gap-5">
+ <div className="flex min-w-0 flex-col gap-5 p-4">
<h1 className="m-0 min-w-0 font-bold text-[24px] text-gray-12 leading-tight tracking-tight">
{title}
</h1>
{secondaryTab.content}
</div>
) : (
- <div className="flex min-h-full min-w-0 flex-col gap-6">
+ <div className="flex min-h-full min-w-0 flex-col gap-6 p-4">
<div className="flex flex-col gap-2">
<h1 className="m-0 min-w-0 font-bold text-[24px] text-gray-12 leading-tight tracking-tight">
{title}
@@ -236,7 +180,6 @@ export function InboxDetailFrameView({
{report.status !== "ready" && (
<SignalReportStatusBadge status={report.status} />
)}
- {report.is_suggested_reviewer && <ForYouBadge />}
<InboxMetaRow>{reportMeta}</InboxMetaRow>
</div>
)}
@@ -244,11 +187,31 @@ export function InboxDetailFrameView({
{aboveSummary}
<ReportSummaryDocument report={report} />
{belowSummary}
- {footer && <div className="mt-auto">{footer}</div>}
</div>
)}
</main>
+ <aside className="@5xl:order-none order-2 flex @5xl:w-[26rem] w-full min-w-0 @5xl:shrink-0 flex-col gap-2 @5xl:self-stretch p-2">
+ {hasEvidence && (
+ <RightColumnSection
+ Icon={EvidenceIcon}
+ title={evidenceSection.title}
+ collapsible
+ rightSlot={
+ <span className="cursor-default select-none text-[12px] text-gray-10 tabular-nums">
+ {evidenceCount} signal{evidenceCount === 1 ? "" : "s"}
+ </span>
+ }
+ >
+ {evidenceContent}
+ </RightColumnSection>
+ )}
+ {aboveEvidence}
+ {children}
+ </aside>
</div>
+ {footer && (!secondaryTab || activeTab === "overview") && (
+ <div className="mx-4 mt-4 border-border border-t py-4">{footer}</div>
+ )}
{dismissDialog}
</div>
</div>
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxFilterMenu.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxFilterMenu.tsx
new file mode 100644
index 000000000000..63461bada6ba
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxFilterMenu.tsx
@@ -0,0 +1,174 @@
+import {
+ INBOX_SCOPE_ENTIRE_PROJECT,
+ INBOX_SCOPE_FOR_YOU,
+ type InboxScope,
+ parseTeammateInboxScope,
+ teammateInboxScope,
+} from "@posthog/core/inbox/reportMembership";
+import { DropdownMenu, DropdownMenuContent } from "@posthog/quill";
+import {
+ getSuggestedReviewerDisplayName,
+ INBOX_PRIORITY_MENU_OPTIONS,
+ INBOX_REPORT_STATE_OPTIONS,
+ INBOX_SORT_MENU_OPTIONS,
+ inboxPriorityFilterLabel,
+ inboxReportStateFilterLabel,
+ inboxSortOptionFromKey,
+ inboxSortOptionKey,
+ isDefaultInboxReportStateFilter,
+} from "@posthog/ui/features/inbox/filterOptions";
+import { useInboxScopeOptions } from "@posthog/ui/features/inbox/hooks/useInboxScopeOptions";
+import { useInboxReviewerScopeStore } from "@posthog/ui/features/inbox/stores/inboxReviewerScopeStore";
+import { useInboxSignalsFilterStore } from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
+import {
+ FilterCheckboxSubMenu,
+ FilterClearItem,
+ FilterMenuTrigger,
+ type FilterOption,
+ FilterRadioSubMenu,
+} from "@posthog/ui/primitives/FilterMenu";
+import { type ReactElement, useState } from "react";
+
+const DEFAULT_SORT_KEY = inboxSortOptionKey("created_at", "desc");
+
+export function InboxFilterMenu({
+ active,
+ onClearFilters,
+}: {
+ active: boolean;
+ onClearFilters: () => void;
+}): ReactElement {
+ const [activated, setActivated] = useState(false);
+
+ return (
+ <DropdownMenu
+ onOpenChange={(open) => {
+ if (open) setActivated(true);
+ }}
+ >
+ <FilterMenuTrigger
+ active={active}
+ label="Filter reports"
+ dataAttr="inbox-pane-filter"
+ />
+ {/* The reviewer list is a request of its own, so it waits for a first
+ open rather than firing on every visit to the pane. */}
+ {activated && (
+ <InboxFilterMenuContent
+ active={active}
+ onClearFilters={onClearFilters}
+ />
+ )}
+ </DropdownMenu>
+ );
+}
+
+function InboxFilterMenuContent({
+ active,
+ onClearFilters,
+}: {
+ active: boolean;
+ onClearFilters: () => void;
+}): ReactElement {
+ const sortField = useInboxSignalsFilterStore((state) => state.sortField);
+ const sortDirection = useInboxSignalsFilterStore(
+ (state) => state.sortDirection,
+ );
+ const setSort = useInboxSignalsFilterStore((state) => state.setSort);
+ const priorityFilter = useInboxSignalsFilterStore(
+ (state) => state.priorityFilter,
+ );
+ const togglePriority = useInboxSignalsFilterStore(
+ (state) => state.togglePriority,
+ );
+ const setPriorityFilter = useInboxSignalsFilterStore(
+ (state) => state.setPriorityFilter,
+ );
+ const reportStateFilter = useInboxSignalsFilterStore(
+ (state) => state.reportStateFilter,
+ );
+ const toggleReportState = useInboxSignalsFilterStore(
+ (state) => state.toggleReportState,
+ );
+ const setReportStateFilter = useInboxSignalsFilterStore(
+ (state) => state.setReportStateFilter,
+ );
+ const scope = useInboxReviewerScopeStore((state) => state.scope);
+ const setScope = useInboxReviewerScopeStore((state) => state.setScope);
+ const { teammateOptions } = useInboxScopeOptions();
+
+ const activeSortKey = inboxSortOptionKey(sortField, sortDirection);
+ const teammateUuid = parseTeammateInboxScope(scope);
+ const selectedTeammate = teammateUuid
+ ? teammateOptions.find((option) => option.uuid === teammateUuid)
+ : undefined;
+ const scopeOptions: FilterOption<InboxScope>[] = [
+ { value: INBOX_SCOPE_FOR_YOU, label: "For you" },
+ { value: INBOX_SCOPE_ENTIRE_PROJECT, label: "Entire project" },
+ ...teammateOptions.map((teammate) => ({
+ value: teammateInboxScope(teammate.uuid),
+ label: getSuggestedReviewerDisplayName(teammate),
+ searchLabel: teammate.email,
+ })),
+ ];
+
+ return (
+ <DropdownMenuContent
+ align="end"
+ side="bottom"
+ sideOffset={6}
+ className="min-w-64"
+ aria-label="Filter reports"
+ >
+ <FilterCheckboxSubMenu
+ label="Status"
+ summary={inboxReportStateFilterLabel(reportStateFilter)}
+ allLabel="All statuses"
+ options={INBOX_REPORT_STATE_OPTIONS}
+ selected={reportStateFilter}
+ active={!isDefaultInboxReportStateFilter(reportStateFilter)}
+ onToggle={toggleReportState}
+ onClear={() => setReportStateFilter([])}
+ />
+ <FilterCheckboxSubMenu
+ label="Priority"
+ summary={inboxPriorityFilterLabel(priorityFilter)}
+ allLabel="All priorities"
+ options={INBOX_PRIORITY_MENU_OPTIONS}
+ selected={priorityFilter}
+ onToggle={togglePriority}
+ onClear={() => setPriorityFilter([])}
+ />
+ <FilterRadioSubMenu
+ label="Sort by"
+ options={INBOX_SORT_MENU_OPTIONS}
+ value={activeSortKey}
+ defaultValue={DEFAULT_SORT_KEY}
+ onChange={(key) => {
+ const option = inboxSortOptionFromKey(key);
+ if (option) setSort(option.field, option.direction);
+ }}
+ />
+ <FilterRadioSubMenu
+ label="Scope"
+ searchPlaceholder="Search users…"
+ options={scopeOptions}
+ value={scope}
+ defaultValue={INBOX_SCOPE_FOR_YOU}
+ // A teammate scope outlives the list that names them, so the row falls
+ // back to the id's own label rather than going blank.
+ valueLabel={
+ selectedTeammate
+ ? getSuggestedReviewerDisplayName(selectedTeammate)
+ : undefined
+ }
+ onChange={setScope}
+ />
+ <FilterClearItem
+ active={active}
+ dataAttr="clear-inbox-pane-filters"
+ onClear={onClearFilters}
+ />
+ </DropdownMenuContent>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxHomePane.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxHomePane.tsx
new file mode 100644
index 000000000000..f6a5a868d2e0
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxHomePane.tsx
@@ -0,0 +1,94 @@
+import { EnvelopeSimpleIcon, SparkleIcon } from "@phosphor-icons/react";
+import {
+ Button,
+ Empty,
+ EmptyContent,
+ EmptyDescription,
+ EmptyHeader,
+ EmptyMedia,
+ EmptyTitle,
+ Kbd,
+} from "@posthog/quill";
+import { useTriageFocusEnabled } from "@posthog/ui/features/feature-flags/useTriageFocusEnabled";
+import { useInboxSectionedReports } from "@posthog/ui/features/inbox/hooks/useInboxSectionedReports";
+import { useInboxTriageHotkey } from "@posthog/ui/features/inbox/hooks/useInboxTriageHotkey";
+import { useSelfDrivingSetupStatus } from "@posthog/ui/features/inbox/hooks/useSelfDrivingSetupStatus";
+import {
+ hasActiveReportsListFilters,
+ useInboxSignalsFilterStore,
+} from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
+import { INBOX_TRIAGE_ROUTE } from "@posthog/ui/features/inbox/triageRoute";
+import { OpenSidebarButton } from "@posthog/ui/features/sidebar/components/OpenSidebarButton";
+import { navigateToSettings } from "@posthog/ui/router/navigationBridge";
+import { Link } from "@tanstack/react-router";
+import type { ReactElement } from "react";
+
+/**
+ * What Self-driving shows beside its list until a report is picked. Paging is
+ * the sidebar list's job, so this reads the same reports without driving it.
+ */
+export function InboxHomePane(): ReactElement {
+ const inbox = useInboxSectionedReports({ autoPage: false });
+ const triageEnabled = useTriageFocusEnabled();
+ const setupStatus = useSelfDrivingSetupStatus();
+ const hasActiveFilters = useInboxSignalsFilterStore(
+ hasActiveReportsListFilters,
+ );
+
+ useInboxTriageHotkey({
+ enabled: triageEnabled,
+ triageReportCount: inbox.triageReports.length,
+ });
+
+ const needsSetup =
+ inbox.isEmpty &&
+ !hasActiveFilters &&
+ !setupStatus.isLoading &&
+ !setupStatus.isConfigured;
+ const canTriage = triageEnabled && inbox.triageReports.length > 0;
+
+ return (
+ <div className="flex h-full items-center justify-center">
+ <Empty className="max-w-md border-0">
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ {needsSetup ? <SparkleIcon /> : <EnvelopeSimpleIcon />}
+ </EmptyMedia>
+ <EmptyTitle>
+ {needsSetup ? "Ship fixes while you sleep" : "Nothing selected"}
+ </EmptyTitle>
+ <EmptyDescription>
+ {needsSetup
+ ? "PostHog watches your session replays, errors, and Slack, then opens a pull request when it finds something worth fixing. Connect a source to get started."
+ : "Pick a report from the list to read it here."}
+ </EmptyDescription>
+ </EmptyHeader>
+ <EmptyContent>
+ {needsSetup ? (
+ <Button
+ variant="primary"
+ size="default"
+ onClick={() => navigateToSettings("agents")}
+ >
+ Configure agents
+ </Button>
+ ) : (
+ <>
+ <OpenSidebarButton />
+ {canTriage && (
+ <Button
+ variant="outline"
+ size="default"
+ render={<Link to={INBOX_TRIAGE_ROUTE} />}
+ >
+ Triage mode
+ <Kbd>T</Kbd>
+ </Button>
+ )}
+ </>
+ )}
+ </EmptyContent>
+ </Empty>
+ </div>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxPane.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxPane.tsx
new file mode 100644
index 000000000000..08ab89737ca3
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxPane.tsx
@@ -0,0 +1,76 @@
+import { filterReportsBySearch } from "@posthog/core/inbox/reportFiltering";
+import { InboxFilterMenu } from "@posthog/ui/features/inbox/components/InboxFilterMenu";
+import { InboxPanePresentation } from "@posthog/ui/features/inbox/components/InboxPanePresentation";
+import { InboxPaneRow } from "@posthog/ui/features/inbox/components/InboxPaneRow";
+import { InboxTriageButton } from "@posthog/ui/features/inbox/components/InboxTriageButton";
+import { useInboxSectionedReports } from "@posthog/ui/features/inbox/hooks/useInboxSectionedReports";
+import {
+ hasActiveReportsListFilters,
+ useInboxSignalsFilterStore,
+} from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
+import { reportIdFromHref } from "@posthog/ui/router/reportNavigation";
+import { useRouterState } from "@tanstack/react-router";
+import { type ReactElement, useMemo, useState } from "react";
+
+/**
+ * Self-driving's column beside the rail. The list is the navigation, so it
+ * stays put while you move between the reports it opens.
+ */
+export function InboxPane({ className }: { className?: string }): ReactElement {
+ const inbox = useInboxSectionedReports();
+ const [query, setQuery] = useState("");
+ const hasActiveFilters = useInboxSignalsFilterStore(
+ hasActiveReportsListFilters,
+ );
+ const resetFilters = useInboxSignalsFilterStore(
+ (state) => state.resetFilters,
+ );
+ const oldestFirst = useInboxSignalsFilterStore(
+ (state) =>
+ state.sortField === "created_at" && state.sortDirection === "asc",
+ );
+ // The report being read, taken from the location so the row stays marked
+ // across a reload or a restored tab.
+ const selectedReportId = useRouterState({
+ select: (state) =>
+ reportIdFromHref((state.resolvedLocation ?? state.location).pathname),
+ });
+
+ const reports = useMemo(
+ () => filterReportsBySearch(inbox.reports, query),
+ [inbox.reports, query],
+ );
+
+ return (
+ <InboxPanePresentation
+ className={className}
+ reports={reports}
+ query={query}
+ onQueryChange={setQuery}
+ isLoading={inbox.isLoading}
+ isFetchingNextPage={inbox.isFetchingNextPage}
+ hasNextPage={inbox.hasNextPage}
+ hasActiveFilters={hasActiveFilters}
+ oldestFirst={oldestFirst}
+ filterControl={
+ <>
+ <InboxTriageButton triageReportCount={inbox.triageReports.length} />
+ <InboxFilterMenu
+ active={hasActiveFilters}
+ onClearFilters={resetFilters}
+ />
+ </>
+ }
+ renderReport={(report) => (
+ <InboxPaneRow
+ key={report.id}
+ report={report}
+ optionValue={report.id}
+ isSelected={report.id === selectedReportId}
+ />
+ )}
+ onClearFilters={resetFilters}
+ onLoadMore={inbox.loadMore}
+ />
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxPanePresentation.stories.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxPanePresentation.stories.tsx
new file mode 100644
index 000000000000..82c753d7a85c
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxPanePresentation.stories.tsx
@@ -0,0 +1,150 @@
+import { Button } from "@posthog/quill";
+import type { SignalReport } from "@posthog/shared/types";
+import {
+ ANONYMOUS_AUTH_STATE,
+ useAuthStore,
+} from "@posthog/ui/features/auth/store";
+import { authKeys } from "@posthog/ui/features/auth/useCurrentUser";
+import { InboxFilterMenu } from "@posthog/ui/features/inbox/components/InboxFilterMenu";
+import { InboxPanePresentation } from "@posthog/ui/features/inbox/components/InboxPanePresentation";
+import { InboxPaneRow } from "@posthog/ui/features/inbox/components/InboxPaneRow";
+import { inboxStoryReport } from "@posthog/ui/features/inbox/components/inboxStoryFixtures";
+import { useInboxReportReadStore } from "@posthog/ui/features/inbox/stores/inboxReportReadStore";
+import { CHANNELS_SIDEBAR_MIN_WIDTH } from "@posthog/ui/features/sidebar/constants";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { useQueryClient } from "@tanstack/react-query";
+import { type ReactNode, useEffect } from "react";
+
+function WithReadState({
+ children,
+}: {
+ children: ReactNode;
+}): React.JSX.Element {
+ const queryClient = useQueryClient();
+ useEffect(() => {
+ const previousAuth = useAuthStore.getState().authState;
+ queryClient.setQueryData(authKeys.currentUser("us:1"), {
+ uuid: "storybook-reader",
+ });
+ useAuthStore.setState({
+ authState: {
+ ...ANONYMOUS_AUTH_STATE,
+ status: "authenticated",
+ cloudRegion: "us",
+ currentProjectId: 1,
+ },
+ });
+ useInboxReportReadStore.setState({
+ readByKey: {
+ [JSON.stringify(["us:1", "storybook-reader", "needs-1"])]: true,
+ },
+ hasHydrated: true,
+ });
+ return () => {
+ useAuthStore.setState({ authState: previousAuth });
+ };
+ }, [queryClient]);
+ return <>{children}</>;
+}
+
+const reports = [
+ inboxStoryReport({
+ id: "review-1",
+ title: "fix(cohorts): keep recurring calculations within their budget",
+ implementation_pr_url: "https://github.com/PostHog/posthog/pull/12345",
+ }),
+ inboxStoryReport({
+ id: "needs-1",
+ title: "feat(replay): expose buffer health in the player controls",
+ priority: "P2",
+ }),
+ inboxStoryReport({
+ id: "needs-2",
+ title: "fix(flags): avoid duplicate evaluations after a reconnect",
+ priority: "P0",
+ }),
+ inboxStoryReport({
+ id: "needs-3",
+ title:
+ "feat(insights): preserve breakdown order in saved results so a shared link opens the way it was left",
+ priority: "P3",
+ }),
+ inboxStoryReport({
+ id: "resolved-1",
+ status: "resolved",
+ title: "fix(webhooks): retry delivery after a transient timeout",
+ priority: "P2",
+ implementation_pr_url: "https://github.com/PostHog/posthog/pull/12346",
+ }),
+];
+
+function paneRow(report: SignalReport): React.JSX.Element {
+ return (
+ <InboxPaneRow
+ key={report.id}
+ report={report}
+ optionValue={report.id}
+ isSelected={report.id === "needs-1"}
+ />
+ );
+}
+
+const meta: Meta<typeof InboxPanePresentation> = {
+ title: "Inbox/Reports/Sidebar pane",
+ component: InboxPanePresentation,
+ parameters: { layout: "fullscreen" },
+ decorators: [
+ (Story) => (
+ <div
+ className="h-[760px] border-border border-r bg-chrome"
+ style={{ width: CHANNELS_SIDEBAR_MIN_WIDTH }}
+ >
+ <WithReadState>
+ <Story />
+ </WithReadState>
+ </div>
+ ),
+ ],
+ args: {
+ reports,
+ query: "",
+ isLoading: false,
+ isFetchingNextPage: false,
+ hasNextPage: false,
+ hasActiveFilters: false,
+ oldestFirst: false,
+ filterControl: (
+ <>
+ <Button variant="outline" size="sm">
+ Triage mode
+ </Button>
+ <InboxFilterMenu active={false} onClearFilters={() => {}} />
+ </>
+ ),
+ renderReport: paneRow,
+ onQueryChange: () => {},
+ onClearFilters: () => {},
+ onLoadMore: () => {},
+ className: "h-full",
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof InboxPanePresentation>;
+
+export const ReportList: Story = {};
+
+export const NothingToReview: Story = {
+ args: { reports: [] },
+};
+
+export const NoSearchMatches: Story = {
+ args: { reports: [], query: "checkout" },
+};
+
+export const FiltersActive: Story = {
+ args: {
+ hasActiveFilters: true,
+ filterControl: <InboxFilterMenu active onClearFilters={() => {}} />,
+ },
+};
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxPanePresentation.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxPanePresentation.tsx
new file mode 100644
index 000000000000..23465f4e07f1
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxPanePresentation.tsx
@@ -0,0 +1,148 @@
+import { EnvelopeSimpleIcon } from "@phosphor-icons/react";
+import { groupReportsByAge } from "@posthog/core/inbox/reportAgeGroups";
+import {
+ Autocomplete,
+ AutocompleteList,
+ Button,
+ cn,
+ Empty,
+ EmptyContent,
+ EmptyDescription,
+ EmptyHeader,
+ EmptyMedia,
+ EmptyTitle,
+ MenuLabel,
+} from "@posthog/quill";
+import type { SignalReport } from "@posthog/shared/types";
+import { SidebarSearchHeader } from "@posthog/ui/features/canvas/components/SidebarSearchHeader";
+import { LoadingState } from "@posthog/ui/primitives/LoadingState";
+import { Fragment, type ReactElement, type ReactNode, useMemo } from "react";
+
+export interface InboxPanePresentationProps {
+ reports: SignalReport[];
+ query: string;
+ onQueryChange: (query: string) => void;
+ isLoading: boolean;
+ isFetchingNextPage: boolean;
+ hasNextPage: boolean;
+ hasActiveFilters: boolean;
+ /** Runs the age buckets the other way, so the list reads oldest first. */
+ oldestFirst: boolean;
+ filterControl: ReactNode;
+ renderReport: (report: SignalReport) => ReactNode;
+ onClearFilters: () => void;
+ onLoadMore: () => void;
+ className?: string;
+}
+
+/**
+ * The rail's Self-driving column: a permanently open inline Autocomplete, so
+ * the search box keeps focus while the arrows walk the reports under it. Same
+ * shape as the Activity feed and the canvases list beside it.
+ */
+export function InboxPanePresentation({
+ reports,
+ query,
+ onQueryChange,
+ isLoading,
+ isFetchingNextPage,
+ hasNextPage,
+ hasActiveFilters,
+ oldestFirst,
+ filterControl,
+ renderReport,
+ onClearFilters,
+ onLoadMore,
+ className,
+}: InboxPanePresentationProps): ReactElement {
+ const isSearching = query.trim() !== "";
+ const optionValues = reports.map((report) => report.id);
+ const groups = useMemo(
+ () => groupReportsByAge(reports, { oldestFirst }),
+ [reports, oldestFirst],
+ );
+
+ return (
+ <Autocomplete<string>
+ inline
+ open
+ value={query}
+ items={optionValues}
+ filter={null}
+ onValueChange={(value, eventDetails) => {
+ if (
+ eventDetails.reason === "input-change" &&
+ typeof value === "string"
+ ) {
+ onQueryChange(value);
+ }
+ }}
+ >
+ <div className={cn("flex min-h-0 flex-col", className)}>
+ <SidebarSearchHeader
+ title="Self-driving"
+ query={query}
+ placeholder="Search reports…"
+ searchLabel="Search reports"
+ onClear={() => onQueryChange("")}
+ actions={filterControl}
+ />
+ <AutocompleteList className="sidebar-autocomplete-tree scroll-mask-8 !max-h-none !p-1.5 min-h-0 flex-1 overflow-y-auto">
+ {isLoading && reports.length === 0 ? (
+ <LoadingState className="py-10" />
+ ) : reports.length === 0 ? (
+ <Empty className="border-0 py-8">
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ <EnvelopeSimpleIcon />
+ </EmptyMedia>
+ <EmptyTitle>
+ {isSearching
+ ? "No matching reports"
+ : hasActiveFilters
+ ? "No reports match your filters"
+ : "Nothing to review"}
+ </EmptyTitle>
+ <EmptyDescription>
+ {isSearching
+ ? "Try a different search."
+ : hasActiveFilters
+ ? "Clear the filters to check for hidden reports."
+ : "Reports show up here as your agents find things worth acting on."}
+ </EmptyDescription>
+ </EmptyHeader>
+ {!isSearching && hasActiveFilters && (
+ <EmptyContent>
+ <Button variant="outline" size="sm" onClick={onClearFilters}>
+ Clear filters
+ </Button>
+ </EmptyContent>
+ )}
+ </Empty>
+ ) : (
+ <div className="flex flex-col gap-px">
+ {groups.map((group) => (
+ <Fragment key={group.label}>
+ <MenuLabel>{group.label}</MenuLabel>
+ {group.reports.map((report) => renderReport(report))}
+ </Fragment>
+ ))}
+ </div>
+ )}
+ {hasNextPage && (
+ <div className="flex justify-center py-2">
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={isFetchingNextPage}
+ onClick={onLoadMore}
+ >
+ {isFetchingNextPage ? "Loading…" : "Load more"}
+ </Button>
+ </div>
+ )}
+ </AutocompleteList>
+ </div>
+ </Autocomplete>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxPaneRow.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxPaneRow.tsx
new file mode 100644
index 000000000000..af7d6c2090ab
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxPaneRow.tsx
@@ -0,0 +1,107 @@
+import {
+ deriveHeadline,
+ humanizeReportTitle,
+ parsePrUrl,
+} from "@posthog/core/inbox/reportPresentation";
+import { AutocompleteItem, Button, cn } from "@posthog/quill";
+import { formatRelativeAge } from "@posthog/shared";
+import type { SignalReport } from "@posthog/shared/types";
+import { InboxReportContextMenu } from "@posthog/ui/features/inbox/components/InboxReportContextMenu";
+import { PriorityMonogram } from "@posthog/ui/features/inbox/components/PriorityMonogram";
+import { useInboxReportDetailPrefetch } from "@posthog/ui/features/inbox/hooks/useInboxReportDetailPrefetch";
+import { useInboxReportReadState } from "@posthog/ui/features/inbox/hooks/useInboxReportReadState";
+import { navigateToInboxReportDetail } from "@posthog/ui/router/navigationBridge";
+import type { ReactElement } from "react";
+
+/** One report in the rail's Self-driving list. */
+export function InboxPaneRow({
+ report,
+ isSelected,
+ optionValue,
+}: {
+ report: SignalReport;
+ isSelected: boolean;
+ optionValue: string;
+}): ReactElement {
+ const { isUnread, enabled, setRead } = useInboxReportReadState(report.id);
+ const { pointerHandlers } = useInboxReportDetailPrefetch({
+ to: "/reports/$reportId",
+ params: { reportId: report.id },
+ });
+ const title = humanizeReportTitle(report.title, "Untitled report");
+ // The same lead sentence the page rows show, clamped to two lines here. The
+ // row is a button, whose wrapper truncates on one line, so the preview has to
+ // opt back into wrapping.
+ const headline = deriveHeadline(report.summary);
+ const pr = report.implementation_pr_url
+ ? parsePrUrl(report.implementation_pr_url)
+ : null;
+
+ return (
+ <InboxReportContextMenu report={report}>
+ <div className="group/report-row relative">
+ <AutocompleteItem
+ value={optionValue}
+ nativeButton
+ aria-label={
+ report.priority
+ ? `${title}, priority ${report.priority}`
+ : `${title}, priority unknown`
+ }
+ className={cn(
+ "h-auto w-full items-start py-1.5 pr-8 text-left 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",
+ isSelected && "bg-fill-selected",
+ )}
+ onClick={() => navigateToInboxReportDetail(report.id)}
+ {...pointerHandlers}
+ >
+ <span className="mt-0.5 shrink-0">
+ <PriorityMonogram priority={report.priority} />
+ </span>
+ <span className="min-w-0 flex-1">
+ <span
+ className={cn(
+ "block truncate text-[13px]",
+ isUnread ? "font-semibold" : "font-medium",
+ )}
+ >
+ {title}
+ </span>
+ {headline && (
+ <span className="line-clamp-2 whitespace-normal text-[12px] text-muted-foreground leading-snug">
+ {headline}
+ </span>
+ )}
+ <span className="mt-1 block truncate text-muted-foreground/70 text-xxs">
+ {formatRelativeAge(report.created_at)}
+ {pr ? ` · ${pr.repoSlug}` : ""}
+ </span>
+ </span>
+ </AutocompleteItem>
+ {enabled && (
+ <Button
+ variant="default"
+ size="icon-sm"
+ className={cn(
+ "absolute top-1 right-0.5",
+ !isUnread &&
+ "opacity-0 focus-visible:opacity-100 group-focus-within/report-row:opacity-100 group-hover/report-row:opacity-100",
+ )}
+ aria-label={
+ isUnread ? "Mark report as read" : "Mark report as unread"
+ }
+ title={isUnread ? "Unread. Mark as read" : "Mark as unread"}
+ onClick={() => setRead(isUnread)}
+ >
+ <span
+ className={cn(
+ "size-2 rounded-full",
+ isUnread ? "bg-(--blue-9)" : "border border-(--gray-9)",
+ )}
+ />
+ </Button>
+ )}
+ </div>
+ </InboxReportContextMenu>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxReportContextMenu.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxReportContextMenu.test.tsx
index 24c405ba650b..7fb606d9878a 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/InboxReportContextMenu.test.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxReportContextMenu.test.tsx
@@ -1,9 +1,15 @@
import type { SignalReport } from "@posthog/shared/types";
+import {
+ ANONYMOUS_AUTH_STATE,
+ useAuthStore,
+} from "@posthog/ui/features/auth/store";
+import { useInboxReportReadStore } from "@posthog/ui/features/inbox/stores/inboxReportReadStore";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
const mocks = vi.hoisted(() => ({
+ readerUuid: "reader-1",
copyLink: vi.fn(),
createPr: vi.fn(),
createPrOptions: undefined as
@@ -22,6 +28,10 @@ const mocks = vi.hoisted(() => ({
| undefined,
}));
+vi.mock("@posthog/ui/features/auth/useCurrentUser", () => ({
+ useCurrentUser: () => ({ data: { uuid: mocks.readerUuid } }),
+}));
+
vi.mock("@posthog/ui/features/inbox/hooks/useInboxReportResolveAction", () => ({
useInboxReportResolveAction: () => {
mocks.actionHooksMounted += 1;
@@ -125,6 +135,16 @@ const LINK_ITEMS = ["Copy link"];
describe("InboxReportContextMenu", () => {
beforeEach(() => {
+ mocks.readerUuid = "reader-1";
+ useAuthStore.setState({
+ authState: {
+ ...ANONYMOUS_AUTH_STATE,
+ status: "authenticated",
+ cloudRegion: "us",
+ currentProjectId: 1,
+ },
+ });
+ useInboxReportReadStore.setState({ readByKey: {}, hasHydrated: true });
vi.clearAllMocks();
mocks.trackerSurface = undefined;
mocks.createPrOptions = undefined;
@@ -160,7 +180,11 @@ describe("InboxReportContextMenu", () => {
"offers the right actions when a report is $name",
({ report, actions }) => {
openMenu(report);
- expect(menuItemText()).toEqual([...actions, ...LINK_ITEMS]);
+ expect(menuItemText()).toEqual([
+ "Mark as read",
+ ...actions,
+ ...LINK_ITEMS,
+ ]);
},
);
@@ -170,12 +194,55 @@ describe("InboxReportContextMenu", () => {
status: "suppressed",
refund: { id: "refund-1", reason: "other" },
}),
- ])("keeps the native context menu for terminal report %#", (report) => {
+ ])(
+ "offers read controls without state changes for terminal report %#",
+ (report) => {
+ openMenu(report);
+ expect(menuItemText()).toEqual(["Mark as read", ...LINK_ITEMS]);
+ },
+ );
+
+ it("marks a report read and unread without dismissing or resolving it", async () => {
+ const user = userEvent.setup();
+ const report = makeReport();
+ const key = JSON.stringify(["us:1", "reader-1", report.id]);
openMenu(report);
- expect(menuItemText()).toEqual([]);
- expect(mocks.actionHooksMounted).toBe(0);
+ await user.click(screen.getByRole("menuitem", { name: "Mark as read" }));
+ expect(useInboxReportReadStore.getState().readByKey[key]).toBe(true);
+ fireEvent.contextMenu(screen.getByText(report.title ?? ""));
+ await user.click(screen.getByRole("menuitem", { name: "Mark as unread" }));
+ expect(useInboxReportReadStore.getState().readByKey[key]).toBe(false);
+ expect(mocks.dismissWithReason).not.toHaveBeenCalled();
+ expect(mocks.resolveWithReason).not.toHaveBeenCalled();
});
+ it.each([
+ { readerUuid: "reader-2", projectId: 1 },
+ { readerUuid: "reader-1", projectId: 2 },
+ ])(
+ "keeps read state separate for $readerUuid in project $projectId",
+ ({ readerUuid, projectId }) => {
+ const report = makeReport();
+ useInboxReportReadStore
+ .getState()
+ .setRead(JSON.stringify(["us:1", "reader-1", report.id]), true);
+ mocks.readerUuid = readerUuid;
+ useAuthStore.setState({
+ authState: {
+ ...useAuthStore.getState().authState,
+ currentProjectId: projectId,
+ },
+ });
+ openMenu(report);
+ expect(
+ screen.getByRole("menuitem", { name: "Mark as read" }),
+ ).toBeInTheDocument();
+ expect(
+ screen.queryByRole("menuitem", { name: "Mark as unread" }),
+ ).not.toBeInTheDocument();
+ },
+ );
+
it("applies resolve and dismiss reasons directly", async () => {
const user = userEvent.setup();
openMenu(makeReport());
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxReportContextMenu.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxReportContextMenu.tsx
index f58af39c68aa..20217b562031 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/InboxReportContextMenu.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxReportContextMenu.tsx
@@ -12,12 +12,6 @@ export function InboxReportContextMenu({
}): React.JSX.Element {
const [open, setOpen] = useState(false);
const [activated, setActivated] = useState(false);
- const isDismissed = report.status === "suppressed";
- const hasMenu =
- report.status !== "resolved" && !(isDismissed && report.refund != null);
-
- if (!hasMenu) return <>{children}</>;
-
return (
<ContextMenu
open={open}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxReportContextMenuContent.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxReportContextMenuContent.tsx
index a5656c5ee612..2ab783769f5c 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/InboxReportContextMenuContent.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxReportContextMenuContent.tsx
@@ -3,6 +3,8 @@ import {
CheckCircleIcon,
CopyIcon,
DesktopIcon,
+ EnvelopeSimpleIcon,
+ EnvelopeSimpleOpenIcon,
EyeSlashIcon,
GitPullRequestIcon,
GlobeIcon,
@@ -33,6 +35,7 @@ import type { SignalReport } from "@posthog/shared/types";
import { ReviewerSearchList } from "@posthog/ui/features/inbox/components/ReviewerSearchList";
import { useCreatePrReport } from "@posthog/ui/features/inbox/hooks/useCreatePrReport";
import { useInboxReportDismissAction } from "@posthog/ui/features/inbox/hooks/useInboxReportDismissAction";
+import { useInboxReportReadState } from "@posthog/ui/features/inbox/hooks/useInboxReportReadState";
import { useInboxReportResolveAction } from "@posthog/ui/features/inbox/hooks/useInboxReportResolveAction";
import { useInboxReportArtefacts } from "@posthog/ui/features/inbox/hooks/useInboxReports";
import { useInboxRestoreReport } from "@posthog/ui/features/inbox/hooks/useInboxRestoreReport";
@@ -51,6 +54,11 @@ export function InboxReportContextMenuContent({
report: SignalReport;
open: boolean;
}): React.JSX.Element {
+ const {
+ isUnread,
+ enabled: readStateEnabled,
+ setRead,
+ } = useInboxReportReadState(report.id);
const [reviewersOpen, setReviewersOpen] = useState(false);
const openedDialogRef = useRef(false);
const fireAction = useReportActionTracker(report, "context_menu");
@@ -75,6 +83,8 @@ export function InboxReportContextMenuContent({
});
const isDismissed = report.status === "suppressed";
+ const readOnly =
+ report.status === "resolved" || (isDismissed && report.refund != null);
const hasOpenPr =
Boolean(report.implementation_pr_url) &&
report.implementation_pr_merged !== true;
@@ -118,7 +128,19 @@ export function InboxReportContextMenuContent({
return undefined;
}}
>
- {isDismissed ? (
+ <ContextMenuItem
+ disabled={!readStateEnabled}
+ onClick={() => setRead(isUnread)}
+ >
+ {isUnread ? (
+ <EnvelopeSimpleOpenIcon size={14} />
+ ) : (
+ <EnvelopeSimpleIcon size={14} />
+ )}
+ {isUnread ? "Mark as read" : "Mark as unread"}
+ </ContextMenuItem>
+ <ContextMenuSeparator />
+ {readOnly ? null : isDismissed ? (
<ContextMenuGroup>
<ContextMenuItem
disabled={restore.isPending}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxReportDetailGate.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxReportDetailGate.test.tsx
new file mode 100644
index 000000000000..2bdf069a4307
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxReportDetailGate.test.tsx
@@ -0,0 +1,68 @@
+import { render, screen } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const mocks = vi.hoisted(() => ({
+ reportQuery: {
+ data: undefined,
+ isLoading: true,
+ isFetching: true,
+ isFetchedAfterMount: false,
+ },
+}));
+
+vi.mock("@posthog/ui/features/inbox/components/DetailBackLink", () => ({
+ DetailBackLink: () => null,
+}));
+vi.mock("@posthog/ui/features/inbox/hooks/useInboxReports", () => ({
+ useInboxReportById: () => mocks.reportQuery,
+}));
+vi.mock("@posthog/ui/features/inbox/hooks/useInboxBackTarget", async () => ({
+ asInboxBackTarget: () => null,
+ useInboxTriageOrigin: () => null,
+}));
+vi.mock("@posthog/ui/features/inbox/hooks/useReportOpenTracker", () => ({
+ useReportOpenTracker: () => undefined,
+}));
+vi.mock("@tanstack/react-router", () => ({
+ useNavigate: () => vi.fn(),
+}));
+
+import { InboxReportDetailGate } from "./InboxReportDetailGate";
+
+describe("InboxReportDetailGate", () => {
+ beforeEach(() => {
+ mocks.reportQuery = {
+ data: undefined,
+ isLoading: true,
+ isFetching: true,
+ isFetchedAfterMount: false,
+ };
+ });
+
+ it.each([
+ ["while the report loads", true],
+ ["when the report is missing", false],
+ ])("keeps the fallback action available %s", (_case, isLoading) => {
+ mocks.reportQuery = {
+ data: undefined,
+ isLoading,
+ isFetching: isLoading,
+ isFetchedAfterMount: !isLoading,
+ };
+
+ render(
+ <InboxReportDetailGate
+ reportId="report-1"
+ backTo="/activity"
+ backLabel="Back to activity"
+ statusRedirect={false}
+ missingCopy="Report not found"
+ fallbackAction={<button type="button">Close activity item</button>}
+ >
+ {() => <div>Report</div>}
+ </InboxReportDetailGate>,
+ );
+
+ expect(screen.getByText("Close activity item")).toBeInTheDocument();
+ });
+});
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 78dbd4c5051d..b05a332c3b42 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/InboxReportDetailGate.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxReportDetailGate.tsx
@@ -48,6 +48,7 @@ interface InboxReportDetailGateProps {
*/
trackTab?: InboxDetailTab | null;
missingCopy: string;
+ fallbackAction?: ReactNode;
children: (report: SignalReport) => ReactNode;
}
@@ -86,6 +87,7 @@ export function InboxReportDetailGate({
backLinkLabel,
trackTab = tabFromBackTo(backTo),
missingCopy,
+ fallbackAction,
children,
}: InboxReportDetailGateProps) {
const navigate = useNavigate();
@@ -162,7 +164,14 @@ export function InboxReportDetailGate({
}, [redirectTo, redirectReportId, navigate, backTo, backLabel, triageOrigin]);
if ((isLoading && !resolvedReport) || statusUnconfirmed) {
- return <LoadingState className="py-16" />;
+ return (
+ <div className="relative h-full">
+ <LoadingState className="py-16" />
+ {fallbackAction && (
+ <div className="absolute top-4 right-6">{fallbackAction}</div>
+ )}
+ </div>
+ );
}
if (redirectTo) {
@@ -175,10 +184,13 @@ export function InboxReportDetailGate({
return (
<div className="flex h-full min-h-0 flex-col">
<div className="flex flex-col gap-3 border-(--gray-5) border-b px-6 py-6">
- <DetailBackLink
- to={backLinkTo ?? backTo}
- label={backLinkLabel ?? backLabel}
- />
+ <div className="flex items-center justify-between gap-3">
+ <DetailBackLink
+ to={backLinkTo ?? backTo}
+ label={backLinkLabel ?? backLabel}
+ />
+ {fallbackAction}
+ </div>
<p className="m-0 text-[13px] text-gray-11">{missingCopy}</p>
</div>
</div>
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxReportFilters.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxReportFilters.tsx
index 9cdc5639f29d..483ee5380e0d 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/InboxReportFilters.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxReportFilters.tsx
@@ -13,35 +13,14 @@ import {
} from "@posthog/quill";
import {
INBOX_PRIORITY_OPTIONS,
+ INBOX_REPORT_STATE_OPTIONS,
INBOX_SORT_OPTIONS,
inboxPriorityFilterLabel,
+ inboxReportStateFilterLabel,
+ inboxSortOptionFromKey,
inboxSortOptionKey,
} from "@posthog/ui/features/inbox/filterOptions";
-import {
- type InboxReportStateFilter,
- useInboxSignalsFilterStore,
-} from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
-
-const REPORT_STATE_OPTIONS: {
- value: InboxReportStateFilter;
- label: string;
-}[] = [
- { value: "review_and_merge", label: "Review and merge" },
- { value: "needs_decision", label: "Needs decision" },
- { value: "resolved", label: "Resolved" },
- { value: "dismissed", label: "Dismissed" },
-];
-
-function reportStateFilterLabel(selected: InboxReportStateFilter[]): string {
- if (selected.length === 0) return "All statuses";
- if (selected.length === 1) {
- return (
- REPORT_STATE_OPTIONS.find((option) => option.value === selected[0])
- ?.label ?? "1 status"
- );
- }
- return `${selected.length} statuses`;
-}
+import { useInboxSignalsFilterStore } from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
export function InboxReportFilters(): React.JSX.Element {
const sortField = useInboxSignalsFilterStore((state) => state.sortField);
@@ -107,7 +86,7 @@ export function InboxReportFilters(): React.JSX.Element {
size="default"
data-attr="inbox-filter-state"
>
- {reportStateFilterLabel(reportStateFilter)}
+ {inboxReportStateFilterLabel(reportStateFilter)}
<CaretDownIcon size={12} />
</Button>
}
@@ -118,7 +97,7 @@ export function InboxReportFilters(): React.JSX.Element {
sideOffset={6}
className="min-w-48"
>
- {REPORT_STATE_OPTIONS.map((option) => (
+ {INBOX_REPORT_STATE_OPTIONS.map((option) => (
<DropdownMenuCheckboxItem
key={option.value}
checked={reportStateFilter.includes(option.value)}
@@ -138,10 +117,7 @@ export function InboxReportFilters(): React.JSX.Element {
label: option.label,
}))}
onValueChange={(key) => {
- const option = INBOX_SORT_OPTIONS.find(
- (candidate) =>
- inboxSortOptionKey(candidate.field, candidate.direction) === key,
- );
+ const option = inboxSortOptionFromKey(key ?? "");
if (option) setSort(option.field, option.direction);
}}
>
@@ -149,11 +125,7 @@ export function InboxReportFilters(): React.JSX.Element {
<span>Sort:</span>
<SelectValue>
{(selected: string) =>
- INBOX_SORT_OPTIONS.find(
- (option) =>
- inboxSortOptionKey(option.field, option.direction) ===
- selected,
- )?.label ?? selected
+ inboxSortOptionFromKey(selected)?.label ?? selected
}
</SelectValue>
</SelectTrigger>
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxTriageButton.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxTriageButton.tsx
new file mode 100644
index 000000000000..7d397cb7ca36
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxTriageButton.tsx
@@ -0,0 +1,44 @@
+import {
+ Button,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@posthog/quill";
+import { useTriageFocusEnabled } from "@posthog/ui/features/feature-flags/useTriageFocusEnabled";
+import {
+ INBOX_TRIAGE_ROUTE,
+ isInboxTriagePath,
+} from "@posthog/ui/features/inbox/triageRoute";
+import { Link, useRouterState } from "@tanstack/react-router";
+import type { ReactElement } from "react";
+
+/** Starts triage from the report list. Triage is a route, so this is a link. */
+export function InboxTriageButton({
+ triageReportCount,
+}: {
+ triageReportCount: number;
+}): ReactElement | null {
+ const enabled = useTriageFocusEnabled();
+ const inTriage = useRouterState({
+ select: (state) => isInboxTriagePath(state.location.pathname),
+ });
+ if (!enabled || inTriage || triageReportCount === 0) return null;
+
+ return (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ variant="outline"
+ size="sm"
+ data-attr="inbox-triage-reports"
+ render={<Link to={INBOX_TRIAGE_ROUTE} />}
+ >
+ Triage mode
+ </Button>
+ }
+ />
+ <TooltipContent side="bottom">Press T to start triage</TooltipContent>
+ </Tooltip>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxTriagePane.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxTriagePane.tsx
new file mode 100644
index 000000000000..dc6f4860eec3
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxTriagePane.tsx
@@ -0,0 +1,40 @@
+import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";
+import { ReportTriageFocus } from "@posthog/ui/features/inbox/components/ReportTriageFocus";
+import { useInboxTriageOrigin } from "@posthog/ui/features/inbox/hooks/useInboxBackTarget";
+import { useInboxSectionedReports } from "@posthog/ui/features/inbox/hooks/useInboxSectionedReports";
+import {
+ hasActiveReportsListFilters,
+ useInboxSignalsFilterStore,
+} from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
+import { LoadingState } from "@posthog/ui/primitives/LoadingState";
+import { useNavigate } from "@tanstack/react-router";
+import type { ReactElement } from "react";
+
+export function InboxTriagePane(): ReactElement {
+ // Beside the rail the sidebar list owns paging; without it, nothing else is
+ // reading this list, so triage walks the pages itself.
+ const spacesLayout = useChannelsLayout();
+ const inbox = useInboxSectionedReports({ autoPage: !spacesLayout });
+ const triageOrigin = useInboxTriageOrigin();
+ const hasActiveFilters = useInboxSignalsFilterStore(
+ hasActiveReportsListFilters,
+ );
+ const navigate = useNavigate();
+
+ if (inbox.isLoading) {
+ return <LoadingState className="h-full" />;
+ }
+
+ return (
+ <div className="h-full min-h-0">
+ <ReportTriageFocus
+ reports={inbox.triageReports}
+ allReports={inbox.reports}
+ scope={inbox.scope}
+ hasActiveFilters={hasActiveFilters}
+ initialReportId={triageOrigin?.reportId}
+ onExit={() => void navigate({ to: "/inbox", replace: true })}
+ />
+ </div>
+ );
+}
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 0cd4698a179e..87999a71cf42 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/InboxView.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxView.tsx
@@ -1,14 +1,17 @@
import { EnvelopeSimpleIcon } from "@phosphor-icons/react";
import { isInboxDetailPath } from "@posthog/core/inbox/reportMembership";
+import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";
import { useInboxAvailable } from "@posthog/ui/features/feature-flags/useInboxAvailable";
import { useReportsInboxEnabled } from "@posthog/ui/features/feature-flags/useReportsInboxEnabled";
+import { InboxHomePane } from "@posthog/ui/features/inbox/components/InboxHomePane";
import { InboxPageHeader } from "@posthog/ui/features/inbox/components/InboxPageHeader";
+import { InboxTriagePane } from "@posthog/ui/features/inbox/components/InboxTriagePane";
import { ReportsInboxView } from "@posthog/ui/features/inbox/components/ReportsInboxView";
import { useInboxAllReports } from "@posthog/ui/features/inbox/hooks/useInboxAllReports";
import { resetReportOpenTrackerHistory } from "@posthog/ui/features/inbox/hooks/useReportOpenTracker";
import { useTrackInboxViewed } from "@posthog/ui/features/inbox/hooks/useTrackInboxViewed";
+import { isInboxTriagePath } from "@posthog/ui/features/inbox/triageRoute";
import { useSetHeaderContent } from "@posthog/ui/hooks/useSetHeaderContent";
-import { Flex, Text } from "@radix-ui/themes";
import { Navigate, Outlet, useRouterState } from "@tanstack/react-router";
import { useEffect, useMemo } from "react";
@@ -20,21 +23,19 @@ import { useEffect, useMemo } from "react";
export function InboxView() {
const headerContent = useMemo(
() => (
- <Flex align="center" gap="2" className="w-full min-w-0">
+ <div className="flex w-full min-w-0 items-center gap-2">
<EnvelopeSimpleIcon size={12} className="shrink-0 text-gray-10" />
- <Text
+ <span
className="truncate whitespace-nowrap font-medium text-[13px]"
title="Self-driving"
>
Self-driving
- </Text>
- </Flex>
+ </span>
+ </div>
),
[],
);
- useSetHeaderContent(headerContent);
-
// Scope report-to-report navigation history to this inbox visit so the first
// report opened after (re)entering the inbox has no stale previous_report_id.
useEffect(() => {
@@ -49,6 +50,11 @@ 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 spacesLayout = useChannelsLayout();
+ // Beside the rail's list the pane names nothing the column has not said.
+ const paneOwnsTitle = spacesLayout && reportsInboxEnabled && !isDetailView;
+ useSetHeaderContent(paneOwnsTitle ? null : headerContent);
+
const listEnabled = !isDetailView && inboxAvailable;
const legacyListEnabled = listEnabled && !reportsInboxEnabled;
const { counts } = useInboxAllReports({
@@ -59,9 +65,10 @@ export function InboxView() {
useTrackInboxViewed({ enabled: legacyListEnabled });
if (reportsInboxEnabled && !isDetailView) {
+ if (isInboxTriagePath(pathname)) return <InboxTriagePane />;
// The view owns its height so its page header stays pinned while the
// sections scroll — the same shape ActivityView has.
- return <ReportsInboxView />;
+ return spacesLayout ? <InboxHomePane /> : <ReportsInboxView />;
}
// With channel reports on, spaces replace the inbox as the home for reports.
@@ -73,11 +80,11 @@ export function InboxView() {
}
return (
- <Flex direction="column" className="h-full min-h-0">
+ <div className="flex h-full min-h-0 flex-col">
{!isDetailView && <InboxPageHeader counts={counts} />}
<div className="min-h-0 flex-1 overflow-auto">
<Outlet />
</div>
- </Flex>
+ </div>
);
}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/PullRequestDetail.tsx b/products/desktop/packages/ui/src/features/inbox/components/PullRequestDetail.tsx
index eb45801348f5..c9259ba84411 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/PullRequestDetail.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/PullRequestDetail.tsx
@@ -6,6 +6,7 @@ import { InboxDetailFrame } from "@posthog/ui/features/inbox/components/InboxDet
import { InboxMetaSeparator } from "@posthog/ui/features/inbox/components/InboxMetaRow";
import { InboxReportDetailGate } from "@posthog/ui/features/inbox/components/InboxReportDetailGate";
import { PrDiffStats } from "@posthog/ui/features/inbox/components/PrDiffStats";
+import { ReportChatLayout } from "@posthog/ui/features/inbox/components/ReportDetail";
import { ReportDetailActions } from "@posthog/ui/features/inbox/components/ReportDetailActions";
import { ReportReviewersSection } from "@posthog/ui/features/inbox/components/ReportReviewersSection";
import { ReportImplementationPrLink } from "@posthog/ui/features/inbox/components/utils/ReportImplementationPrLink";
@@ -50,49 +51,56 @@ export function PullRequestDetailContent({ report }: { report: SignalReport }) {
const prUrl = prRef ? report.implementation_pr_url : null;
return (
- <InboxDetailFrame
- report={report}
- backTo="/inbox/pulls"
- backLabel="Back to pull requests"
- fallbackTitle="Untitled pull request"
- metaSuffix={
- prUrl ? (
- <>
- <InboxMetaSeparator />
- <ReportImplementationPrLink prUrl={prUrl} size="md" />
+ <ReportChatLayout report={report}>
+ <InboxDetailFrame
+ report={report}
+ fallbackTitle="Untitled pull request"
+ metaSuffix={
+ prUrl ? (
+ <>
+ <InboxMetaSeparator />
+ <ReportImplementationPrLink prUrl={prUrl} size="md" />
+ <ReportTrackerIssueLink report={report} />
+ </>
+ ) : (
<ReportTrackerIssueLink report={report} />
- </>
- ) : (
- <ReportTrackerIssueLink report={report} />
- )
- }
- primaryAction={<ReportDetailActions report={report} prUrl={prUrl} />}
- summarySection={{ Icon: GitPullRequestIcon, title: "Summary" }}
- secondaryTab={
- prUrl
- ? {
- label: (
- <>
- Changed code
- <PrDiffStats prUrl={prUrl} hideWhileLoading />
- </>
- ),
- content: <PrFilesChangedSection prUrl={prUrl} bare />,
- }
- : undefined
- }
- belowSummary={
- prUrl && (
- <>
- <PrDecisionBlock prUrl={prUrl} />
- <PrCommentsSection prUrl={prUrl} />
- </>
- )
- }
- footer={<ReportFeedbackFooter report={report} />}
- evidenceSection={{ Icon: MagnifyingGlassIcon, title: "Evidence" }}
- >
- <ReportReviewersSection report={report} />
- </InboxDetailFrame>
+ )
+ }
+ primaryAction={
+ <ReportDetailActions
+ report={report}
+ prUrl={prUrl}
+ placement="header"
+ />
+ }
+ showDismiss={false}
+ summarySection={{ Icon: GitPullRequestIcon, title: "Summary" }}
+ secondaryTab={
+ prUrl
+ ? {
+ label: (
+ <>
+ Changed code
+ <PrDiffStats prUrl={prUrl} hideWhileLoading />
+ </>
+ ),
+ content: <PrFilesChangedSection prUrl={prUrl} bare />,
+ }
+ : undefined
+ }
+ belowSummary={
+ prUrl && (
+ <>
+ <PrDecisionBlock prUrl={prUrl} />
+ <PrCommentsSection prUrl={prUrl} />
+ </>
+ )
+ }
+ footer={<ReportFeedbackFooter report={report} />}
+ evidenceSection={{ Icon: MagnifyingGlassIcon, title: "Evidence" }}
+ >
+ <ReportReviewersSection report={report} />
+ </InboxDetailFrame>
+ </ReportChatLayout>
);
}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/DetailBackLink.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportBreadcrumbs.test.tsx
similarity index 89%
rename from products/desktop/packages/ui/src/features/inbox/components/DetailBackLink.test.tsx
rename to products/desktop/packages/ui/src/features/inbox/components/ReportBreadcrumbs.test.tsx
index 973f69f130ca..11414c0864db 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/DetailBackLink.test.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportBreadcrumbs.test.tsx
@@ -1,5 +1,4 @@
import type { SignalReport } from "@posthog/shared/types";
-import { ReportPageContext } from "@posthog/ui/features/inbox/components/ReportPageContext";
import { render } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";
@@ -41,7 +40,7 @@ vi.mock("@posthog/ui/features/canvas/hooks/useChannels", () => ({
useChannels: () => ({ channels: [] }),
}));
-import { DetailBackLink } from "./DetailBackLink";
+import { ReportBreadcrumbs } from "./ReportBreadcrumbs";
const report = {
id: "report-1",
@@ -49,7 +48,7 @@ const report = {
status: "ready",
} as SignalReport;
-describe("DetailBackLink", () => {
+describe("ReportBreadcrumbs", () => {
beforeEach(() => {
mocks.sourceHref = "/inbox/reports";
mocks.triageOrigin = null;
@@ -57,11 +56,7 @@ describe("DetailBackLink", () => {
});
const renderCrumbs = () => {
- const { container } = render(
- <ReportPageContext value={report}>
- <DetailBackLink to="/inbox/reports" label="Self-driving" />
- </ReportPageContext>,
- );
+ const { container } = render(<ReportBreadcrumbs report={report} />);
return container.querySelectorAll("a");
};
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportBreadcrumbs.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportBreadcrumbs.tsx
new file mode 100644
index 000000000000..fd6e1f04575e
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportBreadcrumbs.tsx
@@ -0,0 +1,144 @@
+import { humanizeReportTitle } from "@posthog/core/inbox/reportPresentation";
+import { prettifyScoutSkillName } from "@posthog/core/scouts/scoutPresentation";
+import type { SignalReport } from "@posthog/shared/types";
+import { useChannels } from "@posthog/ui/features/canvas/hooks/useChannels";
+import {
+ type InboxTriageOrigin,
+ useInboxTriageOrigin,
+} from "@posthog/ui/features/inbox/hooks/useInboxBackTarget";
+import {
+ BreadcrumbSegment,
+ BreadcrumbSeparator,
+} from "@posthog/ui/primitives/Breadcrumb";
+import {
+ type NavigationSource,
+ resolveNavigationSource,
+ useReportSourceHref,
+} from "@posthog/ui/router/reportNavigation";
+import { Link } from "@tanstack/react-router";
+import type { ReactElement } from "react";
+
+interface Crumb {
+ label: string;
+ render?: ReactElement;
+}
+
+/** Where a report sits: the list that opened it, its space, then its title. */
+export function ReportBreadcrumbs({
+ report,
+}: {
+ report: SignalReport;
+}): ReactElement {
+ const triageOrigin = useInboxTriageOrigin();
+ const sourceHref = useReportSourceHref();
+ const { channels } = useChannels();
+ const spaceName = (id: string) => channels.find((c) => c.id === id)?.name;
+ const crumbs = reportCrumbs(
+ resolveNavigationSource(sourceHref),
+ report,
+ triageOrigin,
+ spaceName,
+ );
+
+ return (
+ <div className="flex min-w-0 items-center gap-0.5 overflow-hidden">
+ {crumbs.map((crumb, index) => (
+ <div
+ key={`${index}-${crumb.label}`}
+ className={
+ index === crumbs.length - 1
+ ? "flex min-w-0 items-center gap-0.5"
+ : "flex shrink-0 items-center gap-0.5"
+ }
+ >
+ {index > 0 && <BreadcrumbSeparator />}
+ <BreadcrumbSegment
+ label={crumb.label}
+ strong={index === 0}
+ muted={index === crumbs.length - 1}
+ shrink={index === crumbs.length - 1}
+ render={crumb.render}
+ />
+ </div>
+ ))}
+ </div>
+ );
+}
+
+function reportCrumbs(
+ source: NavigationSource | null,
+ report: SignalReport,
+ triageOrigin: InboxTriageOrigin | null,
+ spaceName: (id: string) => string | undefined,
+): Crumb[] {
+ const crumbs: Crumb[] = [];
+ // TanStack blanks history state on a plain Link, so the Reports-list crumb
+ // must carry the triage origin forward or triage focus mode dies on the way
+ // back.
+ const exact = source ? (
+ <Link
+ to={source.href}
+ state={
+ source.path === "/inbox/reports" && triageOrigin
+ ? (previous) => ({ ...previous, inboxTriageOrigin: triageOrigin })
+ : undefined
+ }
+ />
+ ) : undefined;
+
+ if (source?.settingsCategory) {
+ crumbs.push({
+ label: source.label,
+ render: source.agentSkillName ? (
+ <Link
+ to="/settings/$category"
+ params={{ category: source.settingsCategory }}
+ />
+ ) : (
+ exact
+ ),
+ });
+ if (source.agentSkillName) {
+ crumbs.push({
+ label: prettifyScoutSkillName(source.agentSkillName),
+ render: exact,
+ });
+ }
+ } else if (source?.spaceId) {
+ const name = spaceName(source.spaceId);
+ crumbs.push({ label: name ? `#${name}` : source.label, render: exact });
+ } else if (source) {
+ crumbs.push({ label: source.label, render: exact });
+ } else {
+ crumbs.push({
+ label: "Self-driving",
+ render: (
+ <Link
+ to="/inbox/reports"
+ state={
+ triageOrigin
+ ? (previous) => ({ ...previous, inboxTriageOrigin: triageOrigin })
+ : undefined
+ }
+ />
+ ),
+ });
+ }
+
+ const ownSpace =
+ report.channel_id && report.channel_id !== source?.spaceId
+ ? report.channel_id
+ : null;
+ const ownSpaceName = ownSpace ? spaceName(ownSpace) : undefined;
+ if (ownSpace && ownSpaceName) {
+ crumbs.push({
+ label: `#${ownSpaceName}`,
+ render: <Link to="/spaces/$channelId" params={{ channelId: ownSpace }} />,
+ });
+ }
+
+ crumbs.push({
+ label: humanizeReportTitle(report.title, "Untitled report"),
+ });
+ return crumbs;
+}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportChatSidebar.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportChatSidebar.tsx
index d330c8df11b8..708ee66ee0d3 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportChatSidebar.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportChatSidebar.tsx
@@ -24,6 +24,7 @@ import { useDraftStore } from "@posthog/ui/features/message-editor/draftStore";
import { EmbeddedSessionView } from "@posthog/ui/features/sessions/components/EmbeddedSessionView";
import { SessionStartupStatus } from "@posthog/ui/features/sessions/components/SessionStartupStatus";
import { taskDetailQuery } from "@posthog/ui/features/tasks/queries";
+import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";
import { ResizableSidebar } from "@posthog/ui/primitives/ResizableSidebar";
import { useOpenTask } from "@posthog/ui/router/useOpenTask";
import { useQuery, useQueryClient } from "@tanstack/react-query";
@@ -97,33 +98,37 @@ export function ReportChatSidebar({
side="right"
>
<div className="flex h-full min-w-0 flex-col border-border border-l bg-gray-1">
- <div className="flex h-10 shrink-0 items-center justify-between border-b bg-chrome pr-2 pl-3">
- <span className="flex items-center gap-1.5 font-medium text-[14px] text-gray-12">
- <ChatCircleIcon size={14} />
- Chat
- </span>
- <span className="flex items-center gap-1">
- {boundTask && (
+ <ChromeBar
+ className="bg-chrome"
+ actions={
+ <>
+ {boundTask && (
+ <Button
+ size="icon-sm"
+ variant="default"
+ aria-label="Open the full task"
+ title="Open the full task"
+ onClick={() => void openTask(boundTask)}
+ >
+ <ArrowsOutSimpleIcon size={14} />
+ </Button>
+ )}
<Button
size="icon-sm"
variant="default"
- aria-label="Open the full task"
- title="Open the full task"
- onClick={() => void openTask(boundTask)}
+ aria-label="Close chat"
+ onClick={() => setOpen(false)}
>
- <ArrowsOutSimpleIcon size={14} />
+ <XIcon size={14} />
</Button>
- )}
- <Button
- size="icon-sm"
- variant="default"
- aria-label="Close chat"
- onClick={() => setOpen(false)}
- >
- <XIcon size={14} />
- </Button>
+ </>
+ }
+ >
+ <span className="flex items-center gap-1.5 font-medium text-[14px] text-gray-12">
+ <ChatCircleIcon size={14} />
+ Chat
</span>
- </div>
+ </ChromeBar>
<div className="min-h-0 flex-1">
{taskId ? (
<ReportChatConversation report={report} taskId={taskId} />
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportChatToggle.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportChatToggle.tsx
index bdc28dac79a7..8cd5a8c59acb 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportChatToggle.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportChatToggle.tsx
@@ -38,8 +38,8 @@ export function ReportChatToggle({ report }: { report: SignalReport }) {
<Button
type="button"
variant={chatOpen ? "primary" : "outline"}
- size="xs"
- className="relative h-7 gap-1.5 px-2.5 text-[12px]"
+ size="sm"
+ className="relative"
aria-label={actionLabel}
aria-pressed={chatOpen}
data-attr="report-chat-toggle"
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportDetail.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportDetail.tsx
index 0b9b49f9a027..d3ad715fad2c 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportDetail.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportDetail.tsx
@@ -15,7 +15,7 @@ import { ReportRunsSection } from "@posthog/ui/features/inbox/components/ReportR
import { ReportVerdictBanner } from "@posthog/ui/features/inbox/components/ReportVerdictBanner";
import { ReportTrackerIssueLink } from "@posthog/ui/features/inbox/components/utils/ReportTrackerIssueLink";
import { useReportChatPanelStore } from "@posthog/ui/features/inbox/stores/reportChatPanelStore";
-import { useCallback, useEffect, useRef } from "react";
+import { type ReactNode, useCallback, useEffect, useRef } from "react";
interface ReportDetailProps {
reportId: string;
@@ -25,6 +25,7 @@ interface ReportDetailProps {
backLabel?: string;
/** Off when hosted on the in-space route, which has no per-status URLs. */
statusRedirect?: boolean;
+ headerTrailingAction?: ReactNode;
}
export function ReportDetail({
@@ -33,6 +34,7 @@ export function ReportDetail({
backTo = "/inbox/reports",
backLabel = "Back to reports",
statusRedirect = true,
+ headerTrailingAction,
}: ReportDetailProps) {
return (
<InboxReportDetailGate
@@ -42,12 +44,12 @@ export function ReportDetail({
backLabel={backLabel}
statusRedirect={statusRedirect}
missingCopy="This report couldn't be found. It may have been deleted."
+ fallbackAction={headerTrailingAction}
>
{(report) => (
<ReportDetailContent
report={report}
- backTo={backTo}
- backLabel={backLabel}
+ headerTrailingAction={headerTrailingAction}
/>
)}
</InboxReportDetailGate>
@@ -66,13 +68,52 @@ export function ReportDetail({
*/
export function ReportDetailContent({
report,
- backTo,
- backLabel,
+ headerTrailingAction,
}: {
report: SignalReport;
- backTo: string;
- backLabel: string;
+ headerTrailingAction?: ReactNode;
}) {
+ return (
+ <ReportChatLayout report={report}>
+ <InboxDetailFrame
+ report={report}
+ fallbackTitle="Untitled report"
+ primaryAction={
+ <>
+ <ReportDetailActions report={report} placement="header" />
+ {headerTrailingAction}
+ </>
+ }
+ belowSummary={
+ <>
+ <ReportVerdictBanner
+ key={report.id}
+ report={report}
+ initialEngagementOnly
+ />
+ <ReportTrackerIssueLink report={report} />
+ </>
+ }
+ summarySection={{ Icon: FileTextIcon, title: "Summary" }}
+ footer={<ReportFeedbackFooter report={report} />}
+ evidenceSection={{ Icon: MagnifyingGlassIcon, title: "Evidence" }}
+ showDismiss={false}
+ >
+ <ReportReviewersSection report={report} />
+ <ReportRunsSection report={report} />
+ <ReportActivitySection reportId={report.id} />
+ </InboxDetailFrame>
+ </ReportChatLayout>
+ );
+}
+
+export function ReportChatLayout({
+ report,
+ children,
+}: {
+ report: SignalReport;
+ children: ReactNode;
+}): React.JSX.Element {
const chatOpen = useReportChatPanelStore((s) => s.open);
const setChatOpen = useReportChatPanelStore((s) => s.setOpen);
const setPendingQuote = useReportChatPanelStore((s) => s.setPendingQuote);
@@ -95,34 +136,7 @@ export function ReportDetailContent({
return (
<div className="flex h-full min-h-0">
<div ref={contentRef} className="min-w-0 flex-1 overflow-y-auto">
- <InboxDetailFrame
- report={report}
- backTo={backTo}
- backLabel={backLabel}
- fallbackTitle="Untitled report"
- primaryAction={
- <ReportDetailActions report={report} placement="header" />
- }
- belowSummary={
- <>
- <ReportVerdictBanner
- key={report.id}
- report={report}
- initialEngagementOnly
- />
- <ReportTrackerIssueLink report={report} />
- </>
- }
- summarySection={{ Icon: FileTextIcon, title: "Report summary" }}
- footer={<ReportFeedbackFooter report={report} />}
- evidenceSection={{ Icon: MagnifyingGlassIcon, title: "Evidence" }}
- showDismiss={false}
- showMetadata={false}
- >
- <ReportReviewersSection report={report} />
- <ReportRunsSection report={report} />
- <ReportActivitySection reportId={report.id} />
- </InboxDetailFrame>
+ {children}
</div>
<AskAboutSelection containerRef={contentRef} onAsk={handleAsk} />
{chatOpen && <ReportChatSidebar report={report} />}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportDetailActions.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportDetailActions.tsx
index 911d7b6f59ae..db62bc1ddd12 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportDetailActions.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportDetailActions.tsx
@@ -5,7 +5,6 @@ import {
EyeSlashIcon,
LinkIcon,
ReceiptIcon,
- ShapesIcon,
} from "@phosphor-icons/react";
import { canResolveReport } from "@posthog/core/inbox/reportActions";
import { parsePrUrl } from "@posthog/core/inbox/reportPresentation";
@@ -18,30 +17,19 @@ import {
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuTrigger,
- Popover,
- PopoverContent,
- PopoverTrigger,
- Textarea,
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@posthog/quill";
import type { SignalReport } from "@posthog/shared/types";
-import { useTaskChannels } from "@posthog/ui/features/canvas/hooks/useTaskChannels";
-import { useChannelReportsEnabled } from "@posthog/ui/features/feature-flags/useChannelReportsEnabled";
-import { InboxReportCopyLinkMenu } from "@posthog/ui/features/inbox/components/InboxReportCopyLinkMenu";
import { RefundReportDialog } from "@posthog/ui/features/inbox/components/RefundReportDialog";
import { ReportChatToggle } from "@posthog/ui/features/inbox/components/ReportChatToggle";
-import { useCreateCanvasReport } from "@posthog/ui/features/inbox/hooks/useCreateCanvasReport";
import { useInboxReportDismissAction } from "@posthog/ui/features/inbox/hooks/useInboxReportDismissAction";
import { useInboxReportResolveAction } from "@posthog/ui/features/inbox/hooks/useInboxReportResolveAction";
import { useRefundReport } from "@posthog/ui/features/inbox/hooks/useRefundReport";
-import { useReportActionTracker } from "@posthog/ui/features/inbox/hooks/useReportActionTracker";
-import { useReportChatPanelStore } from "@posthog/ui/features/inbox/stores/reportChatPanelStore";
import { copyInboxReportLink } from "@posthog/ui/features/inbox/utils/copyInboxReportLink";
-import { Spinner } from "@posthog/ui/primitives/Spinner";
import { openExternalUrl } from "@posthog/ui/shell/openExternal";
-import { useCallback, useState } from "react";
+import { useState } from "react";
interface ReportDetailActionsProps {
report: SignalReport;
@@ -50,10 +38,6 @@ interface ReportDetailActionsProps {
placement?: "standalone" | "header";
}
-const isMac =
- typeof navigator !== "undefined" && /Mac/i.test(navigator.platform);
-const HEADER_ACTION_CLASS = "h-7 gap-1.5 px-2.5 text-[12px]";
-
/** Report actions split between page-level housekeeping and conversation work. */
export function ReportDetailActions({
report,
@@ -68,37 +52,6 @@ export function ReportDetailActions({
// drop out; only the read-only overflow menu (copy link, PR link) stays.
const isResolved = report.status === "resolved";
- const fireAction = useReportActionTracker(report);
- const setChatOpen = useReportChatPanelStore((s) => s.setOpen);
-
- // Canvases started from a report file into the report's space, or #general
- // when the report has none — a task without a channel shows in no space's
- // sidebar at all.
- const { generalChannel, isLoading: channelsLoading } = useTaskChannels();
- const taskChannelId = report.channel_id ?? generalChannel?.id ?? null;
- // Until the channels query settles, an unassigned report has no fallback
- // channel yet — creating a task then would file it into no space at all.
- const awaitingChannel = taskChannelId === null && channelsLoading;
-
- const canvasActionEnabled = useChannelReportsEnabled();
- const rememberStartedTask = useReportChatPanelStore(
- (s) => s.rememberStartedTask,
- );
- const handleCanvasTaskCreated = useCallback(
- (task: { id: string }) => {
- rememberStartedTask(report.id, task.id);
- setChatOpen(true);
- },
- [rememberStartedTask, report.id, setChatOpen],
- );
- const { createCanvasReport, isCreatingCanvas } = useCreateCanvasReport({
- reportId: report.id,
- reportTitle: report.title ?? null,
- channelId: taskChannelId,
- cloudRepository: null,
- onTaskCreated: handleCanvasTaskCreated,
- });
-
// implementation_pr_url comes from raw task-run output; only a verified
// GitHub PR URL may be opened or labeled as GitHub.
const safePrUrl = prUrl && parsePrUrl(prUrl) ? prUrl : null;
@@ -107,20 +60,6 @@ export function ReportDetailActions({
const dismiss = useInboxReportDismissAction(report);
const resolve = useInboxReportResolveAction(report);
- const [canvasOpen, setCanvasOpen] = useState(false);
- const [canvasDirection, setCanvasDirection] = useState("");
-
- const handleCreateCanvas = useCallback(() => {
- const trimmed = canvasDirection.trim();
- fireAction("create_canvas", { has_feedback: trimmed.length > 0 });
- setCanvasDirection("");
- setCanvasOpen(false);
- void createCanvasReport(trimmed || undefined);
- }, [canvasDirection, createCanvasReport, fireAction]);
-
- // Read-only conveniences plus Refund. These are the only occasional actions,
- // and the read-only ones stay even on a resolved report; Refund is a mutation,
- // so it's gated out below.
const overflowMenu = (
<DropdownMenu>
<DropdownMenuTrigger
@@ -128,7 +67,7 @@ export function ReportDetailActions({
<Button
type="button"
variant="outline"
- size="sm"
+ size="icon-sm"
aria-label="More report actions"
>
<DotsThreeIcon size={14} weight="bold" />
@@ -160,7 +99,7 @@ export function ReportDetailActions({
</DropdownMenuItem>
</DropdownMenuSubContent>
</DropdownMenuSub>
- {refund.canRefund && !isResolved && (
+ {placement === "standalone" && refund.canRefund && !isResolved && (
<DropdownMenuItem
disabled={refund.disabledReason !== null}
onClick={() => setRefundOpen(true)}
@@ -177,23 +116,21 @@ export function ReportDetailActions({
<Button
type="button"
variant="outline"
- size="xs"
- className={HEADER_ACTION_CLASS}
+ size="sm"
onClick={() => openExternalUrl(safePrUrl)}
>
<ArrowSquareOutIcon size={14} />
- Open PR in GitHub
+ Open in GitHub
</Button>
) : (
<Button
type="button"
variant="outline"
- size="xs"
- className={HEADER_ACTION_CLASS}
+ size="sm"
onClick={() => openExternalUrl(safePrUrl)}
>
<ArrowSquareOutIcon size={16} />
- Open PR in GitHub
+ Open in GitHub
</Button>
)
) : null;
@@ -207,8 +144,7 @@ export function ReportDetailActions({
<Button
type="button"
variant="outline"
- size="xs"
- className={HEADER_ACTION_CLASS}
+ size="sm"
loading={resolve.isPending}
disabled={resolve.isPending}
data-attr="inbox-report-resolve"
@@ -222,8 +158,7 @@ export function ReportDetailActions({
<Button
type="button"
variant="outline"
- size="xs"
- className={HEADER_ACTION_CLASS}
+ size="sm"
data-attr="inbox-report-dismiss"
onClick={() => dismiss.openDialog()}
>
@@ -231,21 +166,7 @@ export function ReportDetailActions({
Dismiss
</Button>
)}
- <InboxReportCopyLinkMenu
- report={report}
- trigger={
- <Button
- type="button"
- variant="outline"
- size="icon-xs"
- className="h-7 w-7"
- aria-label="Copy link"
- title="Copy link"
- >
- <LinkIcon size={13} />
- </Button>
- }
- />
+ {overflowMenu}
{refund.canRefund && (
<Tooltip>
<TooltipTrigger
@@ -253,8 +174,7 @@ export function ReportDetailActions({
<Button
type="button"
variant="outline"
- size="icon-xs"
- className="h-7 w-7"
+ size="sm"
aria-label="Refund"
disabled={refund.disabledReason !== null}
onClick={() => setRefundOpen(true)}
@@ -262,6 +182,7 @@ export function ReportDetailActions({
}
>
<ReceiptIcon />
+ Refund
</TooltipTrigger>
<TooltipContent>
{refund.disabledReason ?? "Refund this PR and archive the report"}
@@ -301,71 +222,6 @@ export function ReportDetailActions({
<>
{githubButton}
- {canvasActionEnabled && (
- <Popover
- open={canvasOpen}
- onOpenChange={(next) => {
- setCanvasOpen(next);
- if (!next) setCanvasDirection("");
- }}
- >
- <PopoverTrigger
- render={
- <Button
- type="button"
- variant="outline"
- size="xs"
- disabled={isCreatingCanvas || awaitingChannel}
- className={HEADER_ACTION_CLASS}
- title="Have the agent build a canvas from this report"
- >
- {isCreatingCanvas ? <Spinner /> : <ShapesIcon size={16} />}
- Visualize on a canvas
- </Button>
- }
- />
- <PopoverContent
- align="end"
- side="bottom"
- sideOffset={6}
- className="flex w-[420px] flex-col gap-2 p-3"
- >
- <span className="text-[13px] text-gray-11">
- What should the canvas focus on? The agent builds it from this
- report's evidence and live data.
- </span>
- <Textarea
- aria-label="What the canvas should focus on"
- autoFocus
- placeholder="Focus on… (optional)"
- rows={3}
- value={canvasDirection}
- onChange={(event) => setCanvasDirection(event.target.value)}
- onKeyDown={(event) => {
- if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
- event.preventDefault();
- handleCreateCanvas();
- }
- }}
- />
- <div className="flex items-center justify-between gap-2">
- <span className="text-[12px] text-gray-10">
- {isMac ? "⌘↵" : "Ctrl+↵"} to create
- </span>
- <Button
- type="button"
- variant="primary"
- size="sm"
- disabled={isCreatingCanvas || awaitingChannel}
- onClick={handleCreateCanvas}
- >
- Create canvas
- </Button>
- </div>
- </PopoverContent>
- </Popover>
- )}
-
{placement === "standalone" && overflowMenu}
{placement === "standalone" && refund.canRefund && (
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportDetailCloseButton.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportDetailCloseButton.tsx
new file mode 100644
index 000000000000..598bc68d97ef
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportDetailCloseButton.tsx
@@ -0,0 +1,56 @@
+import { XIcon } from "@phosphor-icons/react";
+import {
+ Button,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@posthog/quill";
+import { useInboxTriageOrigin } from "@posthog/ui/features/inbox/hooks/useInboxBackTarget";
+import {
+ resolveNavigationSource,
+ useReportSourceHref,
+} from "@posthog/ui/router/reportNavigation";
+import { getRouterOrNull } from "@posthog/ui/router/routerRef";
+import type { ReactElement } from "react";
+
+/**
+ * Puts the report down and leaves its list standing, the way Activity closes an
+ * item. Drawn only when the report names where it was opened from: without a
+ * source there is no list beside it and nothing to close back to.
+ */
+export function ReportDetailCloseButton(): ReactElement | null {
+ const source = resolveNavigationSource(useReportSourceHref());
+ // TanStack blanks history state on a plain navigate, so triage's place in
+ // the queue has to travel with the click or the queue restarts at the top.
+ const triageOrigin = useInboxTriageOrigin();
+ if (!source) return null;
+
+ return (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ type="button"
+ variant="outline"
+ size="icon-sm"
+ className="no-drag shrink-0"
+ aria-label="Close report"
+ data-attr="report-detail-close"
+ onClick={() =>
+ void getRouterOrNull()?.navigate({
+ href: source.href,
+ state: (previous) => ({
+ ...previous,
+ ...(triageOrigin ? { inboxTriageOrigin: triageOrigin } : {}),
+ }),
+ })
+ }
+ />
+ }
+ >
+ <XIcon size={14} />
+ </TooltipTrigger>
+ <TooltipContent side="bottom">Close report</TooltipContent>
+ </Tooltip>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportPage.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportPage.test.tsx
index b4acadbfed49..272c36940fdf 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportPage.test.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportPage.test.tsx
@@ -1,5 +1,5 @@
import type { SignalReport } from "@posthog/shared/types";
-import { render, screen, waitFor } from "@testing-library/react";
+import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import type { ReactNode } from "react";
import { beforeEach, describe, expect, it, vi } from "vitest";
@@ -8,9 +8,12 @@ const mocks = vi.hoisted(() => ({
source: undefined as string | undefined,
gate: vi.fn(),
tracker: vi.fn(() => null),
+ navigate: vi.fn(),
+ triageEnabled: true,
}));
vi.mock("@tanstack/react-router", () => ({
+ useNavigate: () => mocks.navigate,
useRouterState: ({ select }: { select: (state: unknown) => unknown }) =>
select({
location: {
@@ -21,6 +24,10 @@ vi.mock("@tanstack/react-router", () => ({
}),
}));
+vi.mock("@posthog/ui/features/feature-flags/useTriageFocusEnabled", () => ({
+ useTriageFocusEnabled: () => mocks.triageEnabled,
+}));
+
vi.mock("@posthog/ui/features/inbox/components/InboxReportDetailGate", () => ({
InboxReportDetailGate: (props: {
children: (report: SignalReport) => ReactNode;
@@ -68,9 +75,32 @@ describe("ReportPage", () => {
beforeEach(() => {
vi.clearAllMocks();
mocks.source = undefined;
+ mocks.triageEnabled = true;
mocks.report = { id: "report-1", status: "ready" } as SignalReport;
});
+ it.each([null, "https://github.com/example/repo/pull/1"])(
+ "starts triage from an open report with PR %s without intercepting typing",
+ (prUrl) => {
+ mocks.report = { ...mocks.report, implementation_pr_url: prUrl };
+ render(
+ <>
+ <ReportPage reportId="report-1" cachedReport={null} />
+ <input aria-label="Chat input" />
+ </>,
+ );
+
+ fireEvent.keyDown(screen.getByLabelText("Chat input"), { key: "t" });
+ fireEvent.keyDown(window, { key: "t", metaKey: true });
+ expect(mocks.navigate).not.toHaveBeenCalled();
+
+ fireEvent.keyDown(window, { key: "t" });
+ fireEvent.keyDown(window, { key: "T" });
+ expect(mocks.navigate).toHaveBeenCalledTimes(2);
+ expect(mocks.navigate).toHaveBeenCalledWith({ to: "/inbox/triage" });
+ },
+ );
+
it.each([
["/settings/agents", "Settings agents"],
["/settings/agents?agent=account-mrr", "Settings agents"],
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportPage.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportPage.tsx
index aa3a16b0a1dd..986af310d201 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportPage.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportPage.tsx
@@ -1,5 +1,6 @@
import { isDismissedReport } from "@posthog/core/inbox/reportMembership";
import type { SignalReport } from "@posthog/shared/types";
+import { useTriageFocusEnabled } from "@posthog/ui/features/feature-flags/useTriageFocusEnabled";
import { DismissedReportDetailContent } from "@posthog/ui/features/inbox/components/DismissedReportDetail";
import {
InboxReportDetailGate,
@@ -8,6 +9,7 @@ import {
import { PullRequestDetailContent } from "@posthog/ui/features/inbox/components/PullRequestDetail";
import { ReportDetailContent } from "@posthog/ui/features/inbox/components/ReportDetail";
import { ReportPageContext } from "@posthog/ui/features/inbox/components/ReportPageContext";
+import { useInboxTriageHotkey } from "@posthog/ui/features/inbox/hooks/useInboxTriageHotkey";
import { LoadingState } from "@posthog/ui/primitives/LoadingState";
import {
resolveNavigationSource,
@@ -65,6 +67,8 @@ export function ReportPage({
function ReportPageContent({ report }: { report: SignalReport }) {
const archived = isDismissedReport(report);
+ const triageEnabled = useTriageFocusEnabled();
+ useInboxTriageHotkey({ enabled: triageEnabled });
const hasPr = Boolean(report.implementation_pr_url);
return (
<ReportPageContext value={report}>
@@ -72,14 +76,11 @@ function ReportPageContent({ report }: { report: SignalReport }) {
<ReportOpenTracker report={report} tab={hasPr ? "pulls" : "reports"} />
)}
{archived ? (
- <DismissedReportDetailContent
- report={report}
- back={{ to: "/inbox/dismissed", label: "Report" }}
- />
+ <DismissedReportDetailContent report={report} />
) : hasPr ? (
<PullRequestDetailContent report={report} />
) : (
- <ReportDetailContent report={report} backTo="/" backLabel="Report" />
+ <ReportDetailContent report={report} />
)}
</ReportPageContext>
);
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportTriageFocusView.stories.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportTriageFocusView.stories.tsx
index 03e7e57c3448..b9726b77707c 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportTriageFocusView.stories.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportTriageFocusView.stories.tsx
@@ -2,13 +2,23 @@ import {
ArrowSquareOutIcon,
CheckCircleIcon,
EyeSlashIcon,
+ FileTextIcon,
GitPullRequestIcon,
} from "@phosphor-icons/react";
import { Button } from "@posthog/quill";
+import { useRailSurface } from "@posthog/ui/features/canvas/hooks/useRailSurface";
+import { InboxDetailFrameView } from "@posthog/ui/features/inbox/components/InboxDetailFrameView";
+import { InboxPanePresentation } from "@posthog/ui/features/inbox/components/InboxPanePresentation";
+import { InboxPaneRow } from "@posthog/ui/features/inbox/components/InboxPaneRow";
import { inboxStoryReport } from "@posthog/ui/features/inbox/components/inboxStoryFixtures";
-import { ReportTriageFocusView } from "@posthog/ui/features/inbox/components/ReportTriageFocusView";
+import {
+ ReportTriageFocusView,
+ type ReportTriageFocusViewProps,
+} from "@posthog/ui/features/inbox/components/ReportTriageFocusView";
+import { isInboxTriagePath } from "@posthog/ui/features/inbox/triageRoute";
import type { Meta, StoryObj } from "@storybook/react-vite";
-import type { ReactNode } from "react";
+import { useNavigate, useRouterState } from "@tanstack/react-router";
+import { type ReactNode, useEffect } from "react";
const report = inboxStoryReport();
const previousReport = inboxStoryReport({
@@ -155,3 +165,92 @@ export const LongTitle: Story = {
export const CompactViewport: Story = {
decorators: [viewportAt(720)],
};
+
+function SidebarRestorationPreview(
+ props: ReportTriageFocusViewProps,
+): React.JSX.Element {
+ const navigate = useNavigate();
+ const pathname = useRouterState({
+ select: (state) => state.location.pathname,
+ });
+ const { hasSidebar } = useRailSurface();
+ useEffect(() => {
+ void navigate({ to: "/inbox" });
+ }, [navigate]);
+ const enterTriage = () => void navigate({ to: "/inbox/triage" });
+ return (
+ <div className="flex h-full min-w-0">
+ {hasSidebar && (
+ <aside
+ aria-label="Self-driving sidebar"
+ className="w-[272px] shrink-0 border-border border-r bg-chrome"
+ >
+ <InboxPanePresentation
+ reports={[previousReport, report, nextReport]}
+ query=""
+ onQueryChange={() => {}}
+ isLoading={false}
+ isFetchingNextPage={false}
+ hasNextPage={false}
+ hasActiveFilters={false}
+ oldestFirst={false}
+ filterControl={
+ <Button size="sm" variant="outline" onClick={enterTriage}>
+ Triage mode
+ </Button>
+ }
+ renderReport={(item) => (
+ <InboxPaneRow
+ key={item.id}
+ report={item}
+ isSelected={false}
+ optionValue={item.id}
+ />
+ )}
+ onClearFilters={() => {}}
+ onLoadMore={() => {}}
+ />
+ </aside>
+ )}
+ <main className="min-w-0 flex-1 overflow-auto">
+ {isInboxTriagePath(pathname) ? (
+ <ReportTriageFocusView
+ {...props}
+ onExit={() => void navigate({ to: "/inbox" })}
+ onOpenReport={() =>
+ void navigate({
+ to: "/reports/$reportId",
+ params: { reportId: report.id },
+ search: { from: "/inbox/triage" },
+ })
+ }
+ />
+ ) : pathname.startsWith("/reports/") ? (
+ <InboxDetailFrameView
+ report={report}
+ fallbackTitle="Report"
+ primaryAction={
+ <Button size="sm" variant="outline" onClick={enterTriage}>
+ Triage mode
+ </Button>
+ }
+ summarySection={{ Icon: FileTextIcon, title: "Summary" }}
+ evidenceSection={null}
+ evidenceCount={0}
+ evidenceContent={null}
+ />
+ ) : (
+ <div className="flex h-full items-center justify-center">
+ <Button variant="outline" onClick={enterTriage}>
+ Start triage
+ </Button>
+ </div>
+ )}
+ </main>
+ </div>
+ );
+}
+
+export const SidebarRestoration: Story = {
+ render: (args) => <SidebarRestorationPreview {...args} />,
+};
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportVerdictBanner.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportVerdictBanner.tsx
index a9c1e207557e..419a8433156d 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportVerdictBanner.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportVerdictBanner.tsx
@@ -12,13 +12,9 @@ import {
canResolveReport,
} from "@posthog/core/inbox/reportActions";
import { parsePrUrl } from "@posthog/core/inbox/reportPresentation";
-import {
- deriveReportVerdict,
- type ReportVerdictTone,
-} from "@posthog/core/inbox/reportVerdict";
+import { deriveReportVerdict } from "@posthog/core/inbox/reportVerdict";
import {
Button,
- cn,
Field,
FieldDescription,
FieldLabel,
@@ -30,6 +26,7 @@ import {
import type { InboxReportActionSurface } from "@posthog/shared/analytics-events";
import type { SignalReport, Task } from "@posthog/shared/types";
import { useTaskChannels } from "@posthog/ui/features/canvas/hooks/useTaskChannels";
+import { ReportVerdictCallout } from "@posthog/ui/features/inbox/components/ReportVerdictCallout";
import { useCreatePrReport } from "@posthog/ui/features/inbox/hooks/useCreatePrReport";
import { useDiscussReport } from "@posthog/ui/features/inbox/hooks/useDiscussReport";
import { useInboxReportDismissAction } from "@posthog/ui/features/inbox/hooks/useInboxReportDismissAction";
@@ -57,13 +54,6 @@ const isMac =
// Same sizing as PrDecisionBlock: the decision is the page's one ask.
const BIG_BUTTON = "h-9 gap-2 px-4 text-[14px]";
-const TONE_CLASS: Record<ReportVerdictTone, string> = {
- decision: "border-(--amber-6) bg-(--amber-2)",
- danger: "border-(--red-6) bg-(--red-2)",
- progress: "border-(--gray-5) bg-(--gray-1)",
- info: "border-(--gray-5) bg-(--gray-1)",
-};
-
type ReportVerdictBannerVariant = "full" | "header-actions" | "triage-actions";
const TYPING_TAGS = new Set(["INPUT", "TEXTAREA", "SELECT"]);
@@ -636,19 +626,11 @@ export function ReportVerdictBanner({
}
return (
- <div
- className={cn(
- "flex select-none flex-col gap-3 rounded-lg border p-4",
- TONE_CLASS[verdict.tone],
- )}
- >
- <div className="flex flex-col gap-1">
- <span className="flex items-center gap-2 font-semibold text-[15px] text-gray-12">
- {verdict.tone === "progress" && <Spinner />}
- {verdict.title}
- </span>
- <span className="text-[14px] text-gray-11">{verdict.body}</span>
- {mergedPr && report.implementation_pr_url && (
+ <ReportVerdictCallout
+ verdict={verdict}
+ details={
+ mergedPr &&
+ report.implementation_pr_url && (
<a
href={report.implementation_pr_url}
target="_blank"
@@ -659,11 +641,11 @@ export function ReportVerdictBanner({
An earlier fix (#{mergedPr.number}) merged, but evidence kept
arriving afterwards
</a>
- )}
- </div>
-
+ )
+ }
+ >
{actionsRow}
{dismissDialog}
- </div>
+ </ReportVerdictCallout>
);
}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportVerdictCallout.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportVerdictCallout.tsx
new file mode 100644
index 000000000000..1470b9aef4ae
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportVerdictCallout.tsx
@@ -0,0 +1,43 @@
+import type {
+ ReportVerdict,
+ ReportVerdictTone,
+} from "@posthog/core/inbox/reportVerdict";
+import { cn } from "@posthog/quill";
+import { Spinner } from "@posthog/ui/primitives/Spinner";
+import type { ReactNode } from "react";
+
+const TONE_CLASS: Record<ReportVerdictTone, string> = {
+ decision: "border-(--amber-6) bg-(--amber-2)",
+ danger: "border-(--red-6) bg-(--red-2)",
+ progress: "border-(--gray-5) bg-(--gray-1)",
+ info: "border-(--blue-6) bg-(--blue-2)",
+};
+
+export function ReportVerdictCallout({
+ verdict,
+ details,
+ children,
+}: {
+ verdict: ReportVerdict;
+ details?: ReactNode;
+ children?: ReactNode;
+}): React.JSX.Element {
+ return (
+ <div
+ className={cn(
+ "flex select-none flex-col gap-3 rounded-lg border p-4",
+ TONE_CLASS[verdict.tone],
+ )}
+ >
+ <div className="flex flex-col gap-1">
+ <span className="flex items-center gap-2 font-semibold text-[15px] text-gray-12">
+ {verdict.tone === "progress" && <Spinner />}
+ {verdict.title}
+ </span>
+ <span className="text-[14px] text-gray-11">{verdict.body}</span>
+ {details}
+ </div>
+ {children}
+ </div>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportsInboxView.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportsInboxView.test.tsx
index f1c2654ec238..d6df23224c3e 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportsInboxView.test.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportsInboxView.test.tsx
@@ -190,6 +190,11 @@ vi.mock("@posthog/ui/features/inbox/components/InboxScopeSelect", () => ({
InboxScopeSelect: () => null,
}));
+vi.mock("@posthog/ui/features/canvas/hooks/useChannelsLayout", () => ({
+ useChannelsLayout: () => false,
+}));
+
+import { InboxTriagePane } from "./InboxTriagePane";
import { ReportsInboxView } from "./ReportsInboxView";
function archivedReport(id: string, title: string): SignalReport {
@@ -371,7 +376,7 @@ describe("ReportsInboxView", () => {
).toBe(true);
});
- it("returns to the same report in triage mode", () => {
+ it("resumes triage on the report it opened", () => {
mocks.activeReports = [
{
...activeReport("merge-report", "Merge report"),
@@ -385,7 +390,7 @@ describe("ReportsInboxView", () => {
inboxTriageOrigin: { reportId: "second-report" },
};
- render(<ReportsInboxView />);
+ render(<InboxTriagePane />);
expect(mocks.triageProps?.initialReportId).toBe("second-report");
expect(mocks.triageProps?.reports.map((report) => report.id)).toEqual([
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 adac25507531..2de5dd867b4a 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportsInboxView.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportsInboxView.tsx
@@ -1,327 +1,81 @@
-import {
- buildStatusFilterParam,
- INBOX_ACTIONABLE_ACTIONABILITY_FILTER,
- INBOX_ACTIONABLE_REPORT_STATUS_FILTER,
- sortInboxReports,
-} from "@posthog/core/inbox/reportFiltering";
import { inboxReviewerScopeValue } from "@posthog/core/inbox/reportMembership";
-import type { SignalReportStatus } from "@posthog/shared/types";
import { useTriageFocusEnabled } from "@posthog/ui/features/feature-flags/useTriageFocusEnabled";
import { InboxReportFilters } from "@posthog/ui/features/inbox/components/InboxReportFilters";
import { InboxReportRow } from "@posthog/ui/features/inbox/components/InboxReportRow";
import { InboxScopeSelect } from "@posthog/ui/features/inbox/components/InboxScopeSelect";
import { ReportsInboxViewPresentation } from "@posthog/ui/features/inbox/components/ReportsInboxViewPresentation";
-import { ReportTriageFocus } from "@posthog/ui/features/inbox/components/ReportTriageFocus";
-import { useInboxAllReports } from "@posthog/ui/features/inbox/hooks/useInboxAllReports";
-import { useInboxTriageOrigin } from "@posthog/ui/features/inbox/hooks/useInboxBackTarget";
+import { useInboxSectionedReports } from "@posthog/ui/features/inbox/hooks/useInboxSectionedReports";
+import { useInboxTriageHotkey } from "@posthog/ui/features/inbox/hooks/useInboxTriageHotkey";
import { useSelfDrivingSetupStatus } from "@posthog/ui/features/inbox/hooks/useSelfDrivingSetupStatus";
import { useTrackReportsInboxViewed } from "@posthog/ui/features/inbox/hooks/useTrackReportsInboxViewed";
import {
DEFAULT_INBOX_REPORT_STATE_FILTER,
- hasActiveInboxFilters,
+ hasActiveReportsListFilters,
useInboxSignalsFilterStore,
} from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
+import { INBOX_TRIAGE_ROUTE } from "@posthog/ui/features/inbox/triageRoute";
import { navigateToSettings } from "@posthog/ui/router/navigationBridge";
import { useNavigate } from "@tanstack/react-router";
-import { useCallback, useEffect, useMemo, useState } from "react";
-
-function isTypingTarget(target: EventTarget | null): boolean {
- if (!(target instanceof HTMLElement)) return false;
- return (
- target.isContentEditable ||
- target.tagName === "INPUT" ||
- target.tagName === "TEXTAREA" ||
- target.tagName === "SELECT"
- );
-}
-
-const AUTOPAGE_REPORT_LIMIT = 400;
export function ReportsInboxView(): React.JSX.Element {
- const reportStateFilter = useInboxSignalsFilterStore(
- (state) => state.reportStateFilter,
- );
- const showAllStates = reportStateFilter.length === 0;
- const showReviewAndMerge =
- showAllStates || reportStateFilter.includes("review_and_merge");
- const showNeedsDecision =
- showAllStates || reportStateFilter.includes("needs_decision");
- const showResolved = showAllStates || reportStateFilter.includes("resolved");
- const showDismissed =
- showAllStates || reportStateFilter.includes("dismissed");
- const terminalStatusFilter = useMemo(() => {
- const statuses: SignalReportStatus[] = [];
- if (showResolved) statuses.push("resolved");
- if (showDismissed) statuses.push("suppressed");
- return buildStatusFilterParam(statuses);
- }, [showDismissed, showResolved]);
- const reviewAndMergeQuery = useInboxAllReports({
- enabled: showReviewAndMerge,
- statusFilter: "ready",
- hasImplementationPr: true,
- applySourceFilter: false,
- applySearchFilter: false,
- groupByStatus: false,
- withPullRequestCount: false,
- });
- const needsDecisionQuery = useInboxAllReports({
- enabled: showNeedsDecision,
- statusFilter: INBOX_ACTIONABLE_REPORT_STATUS_FILTER,
- actionabilityFilter: INBOX_ACTIONABLE_ACTIONABILITY_FILTER,
- hasImplementationPr: false,
- applySourceFilter: false,
- applySearchFilter: false,
- groupByStatus: false,
- withPullRequestCount: false,
- });
- const terminalQuery = useInboxAllReports({
- enabled: showResolved || showDismissed,
- statusFilter: terminalStatusFilter,
- applySourceFilter: false,
- applySearchFilter: false,
- groupByStatus: false,
- withPullRequestCount: false,
- });
- const {
- searchQuery,
- scope,
- sourceProductFilter,
- priorityFilter,
- sortField,
- sortDirection,
- } = reviewAndMergeQuery;
- const triageFocusEnabled = useTriageFocusEnabled();
+ const inbox = useInboxSectionedReports();
+ const triageEnabled = useTriageFocusEnabled();
const setupStatus = useSelfDrivingSetupStatus();
- const triageOrigin = useInboxTriageOrigin();
const navigate = useNavigate();
- const [focusMode, setFocusMode] = useState(() => triageOrigin !== null);
-
- const exitFocusMode = useCallback(() => {
- setFocusMode(false);
- if (!triageOrigin) return;
- void navigate({
- to: "/inbox/reports",
- replace: true,
- state: (previous) => ({
- ...previous,
- inboxTriageOrigin: undefined,
- }),
- });
- }, [navigate, triageOrigin]);
-
- const hasActiveFilters = useInboxSignalsFilterStore((state) =>
- hasActiveInboxFilters(state, {
- includePrFilter: false,
- includeSourceFilter: false,
- includeReportStateFilter: true,
- includeSearchFilter: false,
- }),
+ const hasActiveFilters = useInboxSignalsFilterStore(
+ hasActiveReportsListFilters,
);
const resetFilters = useInboxSignalsFilterStore(
(state) => state.resetFilters,
);
- const reviewAndMergeCount = showReviewAndMerge
- ? reviewAndMergeQuery.totalCount
- : 0;
- const needsPrCount = showNeedsDecision ? needsDecisionQuery.totalCount : 0;
- const triageReports = showNeedsDecision
- ? needsDecisionQuery.scopedReports
- : [];
- const visibleReports = useMemo(() => {
- const reports = [
- ...(showReviewAndMerge ? reviewAndMergeQuery.scopedReports : []),
- ...(showNeedsDecision ? needsDecisionQuery.scopedReports : []),
- ...(showResolved || showDismissed ? terminalQuery.scopedReports : []),
- ];
- return sortInboxReports(
- Array.from(
- new Map(reports.map((report) => [report.id, report])).values(),
- ),
- sortField === "priority" ||
- sortField === "created_at" ||
- sortField === "total_weight"
- ? sortField
- : "created_at",
- sortDirection,
- );
- }, [
- needsDecisionQuery.scopedReports,
- reviewAndMergeQuery.scopedReports,
- showDismissed,
- showNeedsDecision,
- showResolved,
- showReviewAndMerge,
- sortDirection,
- sortField,
- terminalQuery.scopedReports,
- ]);
- const terminalCount =
- showResolved || showDismissed ? terminalQuery.totalCount : 0;
- const reportCount = reviewAndMergeCount + needsPrCount + terminalCount;
- const selectedQueries = [
- ...(showReviewAndMerge ? [reviewAndMergeQuery] : []),
- ...(showNeedsDecision ? [needsDecisionQuery] : []),
- ...(showResolved || showDismissed ? [terminalQuery] : []),
- ];
- const allReports = visibleReports;
- const isLoading = selectedQueries.some((query) => query.isPending);
- const isSuccess = selectedQueries.every((query) => query.isSuccess);
- const isError =
- visibleReports.length === 0 &&
- selectedQueries.some((query) => query.isError);
- const isFetchingNextPage = selectedQueries.some(
- (query) => query.isFetchingNextPage,
- );
- const hasNextPage = selectedQueries.some(
- (query) =>
- query.hasNextPage && query.allReports.length >= AUTOPAGE_REPORT_LIMIT,
- );
+ useInboxTriageHotkey({
+ enabled: triageEnabled,
+ triageReportCount: inbox.triageReports.length,
+ });
useTrackReportsInboxViewed({
- reports: visibleReports,
- totalCount: reportCount,
- isReady: isSuccess,
- sourceProductFilter,
- priorityFilter,
- searchQuery,
- scope: inboxReviewerScopeValue(scope),
- reportStateFilter,
+ reports: inbox.reports,
+ totalCount: inbox.reportCount,
+ isReady: inbox.isSuccess,
+ sourceProductFilter: inbox.sourceProductFilter,
+ priorityFilter: inbox.priorityFilter,
+ searchQuery: inbox.searchQuery,
+ scope: inboxReviewerScopeValue(inbox.scope),
+ reportStateFilter: inbox.reportStateFilter,
defaultReportStateFilter: DEFAULT_INBOX_REPORT_STATE_FILTER,
});
- useEffect(() => {
- if (
- !showReviewAndMerge ||
- !reviewAndMergeQuery.hasNextPage ||
- reviewAndMergeQuery.isFetchingNextPage ||
- reviewAndMergeQuery.isLoading ||
- reviewAndMergeQuery.allReports.length >= AUTOPAGE_REPORT_LIMIT
- ) {
- return;
- }
- void reviewAndMergeQuery.fetchNextPage();
- }, [
- reviewAndMergeQuery.allReports.length,
- reviewAndMergeQuery.fetchNextPage,
- reviewAndMergeQuery.hasNextPage,
- reviewAndMergeQuery.isFetchingNextPage,
- reviewAndMergeQuery.isLoading,
- showReviewAndMerge,
- ]);
-
- useEffect(() => {
- if (
- !showNeedsDecision ||
- !needsDecisionQuery.hasNextPage ||
- needsDecisionQuery.isFetchingNextPage ||
- needsDecisionQuery.isLoading ||
- needsDecisionQuery.allReports.length >= AUTOPAGE_REPORT_LIMIT
- ) {
- return;
- }
- void needsDecisionQuery.fetchNextPage();
- }, [
- needsDecisionQuery.allReports.length,
- needsDecisionQuery.fetchNextPage,
- needsDecisionQuery.hasNextPage,
- needsDecisionQuery.isFetchingNextPage,
- needsDecisionQuery.isLoading,
- showNeedsDecision,
- ]);
-
- useEffect(() => {
- if (
- (!showResolved && !showDismissed) ||
- !terminalQuery.hasNextPage ||
- terminalQuery.isFetchingNextPage ||
- terminalQuery.isLoading ||
- terminalQuery.allReports.length >= AUTOPAGE_REPORT_LIMIT
- ) {
- return;
- }
- void terminalQuery.fetchNextPage();
- }, [
- showDismissed,
- showResolved,
- terminalQuery.allReports.length,
- terminalQuery.fetchNextPage,
- terminalQuery.hasNextPage,
- terminalQuery.isFetchingNextPage,
- terminalQuery.isLoading,
- ]);
-
- const loadMore = (): void => {
- for (const query of selectedQueries) {
- if (query.hasNextPage && !query.isFetchingNextPage) {
- void query.fetchNextPage();
- }
- }
- };
- const retry = (): void => {
- for (const query of selectedQueries) void query.refetch();
- };
-
- useEffect(() => {
- if (!triageFocusEnabled || focusMode) return;
- const onKeyDown = (event: KeyboardEvent): void => {
- if (isTypingTarget(event.target)) return;
- if (event.metaKey || event.ctrlKey || event.altKey) return;
- if (event.key === "t" && triageReports.length > 0) {
- event.preventDefault();
- setFocusMode(true);
- }
- };
- window.addEventListener("keydown", onKeyDown);
- return () => window.removeEventListener("keydown", onKeyDown);
- }, [triageFocusEnabled, focusMode, triageReports.length]);
-
- if (triageFocusEnabled && focusMode && !isLoading) {
- return (
- <div className="h-full min-h-0">
- <ReportTriageFocus
- reports={triageReports}
- allReports={allReports}
- scope={scope}
- hasActiveFilters={hasActiveFilters}
- initialReportId={triageOrigin?.reportId}
- onExit={exitFocusMode}
- />
- </div>
- );
- }
-
- const isEmpty = isSuccess && reportCount === 0;
const isAgentConfigurationLoading =
- isEmpty && !hasActiveFilters && setupStatus.isLoading;
+ inbox.isEmpty && !hasActiveFilters && setupStatus.isLoading;
const showConfigureAgentsEmptyState =
- isEmpty &&
+ inbox.isEmpty &&
!hasActiveFilters &&
!setupStatus.isLoading &&
!setupStatus.isConfigured;
return (
<ReportsInboxViewPresentation
- reports={visibleReports}
- triageReportCount={needsPrCount}
- isLoading={isLoading || isAgentConfigurationLoading}
- isFetchingNextPage={isFetchingNextPage}
- hasNextPage={hasNextPage}
- isError={isError}
- isEmpty={isEmpty}
+ reports={inbox.reports}
+ triageReportCount={inbox.triageReportCount}
+ isLoading={inbox.isLoading || isAgentConfigurationLoading}
+ isFetchingNextPage={inbox.isFetchingNextPage}
+ hasNextPage={inbox.hasNextPage}
+ isError={inbox.isError}
+ isEmpty={inbox.isEmpty}
hasActiveFilters={hasActiveFilters}
showConfigureAgentsEmptyState={showConfigureAgentsEmptyState}
- triageEnabled={triageFocusEnabled}
+ triageEnabled={triageEnabled}
filterControl={<InboxReportFilters />}
scopeControl={<InboxScopeSelect />}
renderReport={(report) => (
<InboxReportRow key={report.id} report={report} />
)}
onConfigureAgents={() => navigateToSettings("agents")}
- onEnterTriage={() => setFocusMode(true)}
+ onEnterTriage={() => void navigate({ to: INBOX_TRIAGE_ROUTE })}
onClearFilters={resetFilters}
- onLoadMore={loadMore}
- onRetry={retry}
+ onLoadMore={inbox.loadMore}
+ onRetry={inbox.retry}
/>
);
}
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportsInboxViewPresentation.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportsInboxViewPresentation.tsx
index 5a04e6bb3a2e..76b0560a4cbf 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportsInboxViewPresentation.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportsInboxViewPresentation.tsx
@@ -18,14 +18,6 @@ import {
TooltipTrigger,
} from "@posthog/quill";
import type { SignalReport } from "@posthog/shared/types";
-import {
- PageHeader,
- PageHeaderActions,
- PageHeaderDescription,
- PageHeaderHeading,
- PageHeaderTitle,
- PageHeaderTitleRow,
-} from "@posthog/ui/primitives/PageHeader";
import { Spinner } from "@posthog/ui/primitives/Spinner";
import type { ReactNode } from "react";
@@ -72,34 +64,21 @@ export function ReportsInboxViewPresentation({
}: ReportsInboxViewPresentationProps): React.JSX.Element {
return (
<div className="flex h-full min-h-0 flex-col bg-gray-1">
- <PageHeader>
- <PageHeaderHeading>
- <PageHeaderTitleRow>
- <PageHeaderTitle>Self-driving</PageHeaderTitle>
- {!showConfigureAgentsEmptyState && (
- <PageHeaderActions>
+ <div className="min-h-0 flex-1 overflow-y-auto">
+ <div className="mx-auto flex w-full max-w-5xl flex-col gap-4 px-6 py-4">
+ <div className="flex w-full flex-wrap items-center justify-between gap-2">
+ {filterControl}
+ <div className="flex flex-wrap items-center justify-end gap-2">
+ {!showConfigureAgentsEmptyState && (
<Button
type="button"
- variant="primary"
- size="sm"
+ variant="outline"
+ size="default"
onClick={onConfigureAgents}
>
Configure agents
</Button>
- </PageHeaderActions>
- )}
- </PageHeaderTitleRow>
- <PageHeaderDescription>
- Issues and opportunities found in your product, ready to review
- </PageHeaderDescription>
- </PageHeaderHeading>
- </PageHeader>
-
- <div className="min-h-0 flex-1 overflow-y-auto">
- <div className="mx-auto flex w-full max-w-5xl flex-col gap-4 px-6 py-4">
- <div className="flex w-full flex-wrap items-center justify-between gap-2">
- {filterControl}
- <div className="flex flex-wrap items-center justify-end gap-2">
+ )}
{triageEnabled && (
<Tooltip>
<TooltipTrigger
diff --git a/products/desktop/packages/ui/src/features/inbox/filterOptions.tsx b/products/desktop/packages/ui/src/features/inbox/filterOptions.tsx
index 504f9a11f572..d113af2ad74e 100644
--- a/products/desktop/packages/ui/src/features/inbox/filterOptions.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/filterOptions.tsx
@@ -19,6 +19,11 @@ import type {
SourceProduct,
} from "@posthog/shared/types";
import { getSourceProductMeta } from "@posthog/ui/features/inbox/components/utils/source-product-icons";
+import {
+ DEFAULT_INBOX_REPORT_STATE_FILTER,
+ type InboxReportStateFilter,
+} from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
+import type { FilterOption } from "@posthog/ui/primitives/FilterMenu";
import type { ReactNode } from "react";
export type InboxSortField = Extract<
@@ -26,7 +31,7 @@ export type InboxSortField = Extract<
"priority" | "created_at" | "total_weight"
>;
-type InboxSortOption = {
+export type InboxSortOption = {
label: string;
field: InboxSortField;
direction: "asc" | "desc";
@@ -116,6 +121,66 @@ export const INBOX_SOURCE_OPTIONS: InboxSourceOption[] = [
}),
];
+export const INBOX_REPORT_STATE_OPTIONS: readonly FilterOption<InboxReportStateFilter>[] =
+ [
+ { value: "review_and_merge", label: "Review and merge" },
+ { value: "needs_decision", label: "Needs decision" },
+ { value: "resolved", label: "Resolved" },
+ { value: "dismissed", label: "Dismissed" },
+ ];
+
+/** The priority list as menu rows: the priority names itself, in its colour. */
+export const INBOX_PRIORITY_MENU_OPTIONS: readonly FilterOption<SignalReportPriority>[] =
+ INBOX_PRIORITY_OPTIONS.map((option) => ({
+ value: option.value,
+ label: option.value,
+ icon: (
+ <span
+ aria-hidden
+ className="size-2 shrink-0 rounded-full"
+ style={{ backgroundColor: option.accent }}
+ />
+ ),
+ }));
+
+/** The sort list as menu rows, keyed by field and direction together. */
+export const INBOX_SORT_MENU_OPTIONS: readonly FilterOption<string>[] =
+ INBOX_SORT_OPTIONS.map((option) => ({
+ value: inboxSortOptionKey(option.field, option.direction),
+ label: option.label,
+ icon: option.icon,
+ }));
+
+export function inboxSortOptionFromKey(
+ key: string,
+): InboxSortOption | undefined {
+ return INBOX_SORT_OPTIONS.find(
+ (option) => inboxSortOptionKey(option.field, option.direction) === key,
+ );
+}
+
+export function inboxReportStateFilterLabel(
+ selected: readonly InboxReportStateFilter[],
+): string {
+ if (selected.length === 0) return "All statuses";
+ if (selected.length === 1) {
+ return (
+ INBOX_REPORT_STATE_OPTIONS.find((option) => option.value === selected[0])
+ ?.label ?? "1 status"
+ );
+ }
+ return `${selected.length} statuses`;
+}
+
+export function isDefaultInboxReportStateFilter(
+ selected: readonly InboxReportStateFilter[],
+): boolean {
+ return (
+ selected.length === DEFAULT_INBOX_REPORT_STATE_FILTER.length &&
+ selected.every((value) => DEFAULT_INBOX_REPORT_STATE_FILTER.includes(value))
+ );
+}
+
export function inboxSortOptionKey(
field: InboxSortField,
direction: "asc" | "desc",
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReportDismissAction.tsx b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReportDismissAction.tsx
index ea779b4cb9f6..1446d7f5ccfc 100644
--- a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReportDismissAction.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReportDismissAction.tsx
@@ -108,8 +108,7 @@ export function useInboxReportDismissAction(
<Button
type="button"
variant="outline"
- size="icon-xs"
- className="h-7 w-7"
+ size="icon-sm"
aria-label="Dismiss this report for everyone in the project"
disabled={isPending}
onClick={() => setOpen(true)}
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReportReadState.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReportReadState.ts
new file mode 100644
index 000000000000..ecbd242a8b27
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxReportReadState.ts
@@ -0,0 +1,33 @@
+import {
+ getAuthIdentity,
+ useAuthStateValue,
+} from "@posthog/ui/features/auth/store";
+import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser";
+import { useInboxReportReadStore } from "@posthog/ui/features/inbox/stores/inboxReportReadStore";
+import { useCallback } from "react";
+
+export function useInboxReportReadState(reportId: string): {
+ isUnread: boolean;
+ enabled: boolean;
+ setRead: (read: boolean) => void;
+} {
+ const identity = useAuthStateValue(getAuthIdentity);
+ const { data: user } = useCurrentUser();
+ const key =
+ identity && user?.uuid
+ ? JSON.stringify([identity, user.uuid, reportId])
+ : null;
+ const hasHydrated = useInboxReportReadStore((state) => state.hasHydrated);
+ const isRead = useInboxReportReadStore(
+ (state) => key !== null && state.readByKey[key] === true,
+ );
+ const setStoredRead = useInboxReportReadStore((state) => state.setRead);
+ const setRead = useCallback(
+ (read: boolean) => {
+ if (key !== null) setStoredRead(key, read);
+ },
+ [key, setStoredRead],
+ );
+ const enabled = key !== null && hasHydrated;
+ return { isUnread: enabled && !isRead, enabled, setRead };
+}
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxSectionedReports.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxSectionedReports.ts
new file mode 100644
index 000000000000..eb1b55372dd7
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxSectionedReports.ts
@@ -0,0 +1,206 @@
+import {
+ buildStatusFilterParam,
+ INBOX_ACTIONABLE_ACTIONABILITY_FILTER,
+ INBOX_ACTIONABLE_REPORT_STATUS_FILTER,
+ sortInboxReports,
+} from "@posthog/core/inbox/reportFiltering";
+import type { InboxScope } from "@posthog/core/inbox/reportMembership";
+import type {
+ SignalReport,
+ SignalReportPriority,
+ SignalReportStatus,
+ SourceProduct,
+} from "@posthog/shared/types";
+import { useInboxAllReports } from "@posthog/ui/features/inbox/hooks/useInboxAllReports";
+import {
+ type InboxReportStateFilter,
+ useInboxSignalsFilterStore,
+} from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";
+import { useEffect, useMemo } from "react";
+
+const AUTOPAGE_REPORT_LIMIT = 400;
+
+/** Stable identity, so a section that is off does not churn its consumers. */
+const EMPTY_REPORTS: SignalReport[] = [];
+
+type InboxQuery = ReturnType<typeof useInboxAllReports>;
+
+const SECTION_QUERY_DEFAULTS = {
+ applySourceFilter: false,
+ applySearchFilter: false,
+ groupByStatus: false,
+ withPullRequestCount: false,
+} as const;
+
+export interface InboxSectionedReports {
+ reports: SignalReport[];
+ /** The subset triage steps through: reports that still need a decision. */
+ triageReports: SignalReport[];
+ triageReportCount: number;
+ reportCount: number;
+ isLoading: boolean;
+ isSuccess: boolean;
+ isError: boolean;
+ isEmpty: boolean;
+ isFetchingNextPage: boolean;
+ hasNextPage: boolean;
+ loadMore: () => void;
+ retry: () => void;
+ scope: InboxScope;
+ reportStateFilter: InboxReportStateFilter[];
+ searchQuery: string;
+ sourceProductFilter: SourceProduct[];
+ priorityFilter: SignalReportPriority[];
+}
+
+function useAutoPage(query: InboxQuery, enabled: boolean): void {
+ const shouldPage =
+ enabled &&
+ query.hasNextPage &&
+ !query.isFetchingNextPage &&
+ !query.isLoading &&
+ query.allReports.length < AUTOPAGE_REPORT_LIMIT;
+ const { fetchNextPage } = query;
+
+ useEffect(() => {
+ if (shouldPage) void fetchNextPage();
+ }, [shouldPage, fetchNextPage]);
+}
+
+/**
+ * Both surfaces that draw the inbox list read it from here, so they cannot
+ * disagree about what is in it. React Query dedupes the requests, but paging is
+ * a side effect, so only one caller may drive it (`autoPage`).
+ */
+export function useInboxSectionedReports(options?: {
+ autoPage?: boolean;
+}): InboxSectionedReports {
+ const autoPage = options?.autoPage ?? true;
+ const reportStateFilter = useInboxSignalsFilterStore(
+ (state) => state.reportStateFilter,
+ );
+ // Straight from the store, where the type is already the set
+ // `sortInboxReports` accepts. The query hook widens it for its own archive
+ // mode, which this list never asks for.
+ const sortField = useInboxSignalsFilterStore((state) => state.sortField);
+ const sortDirection = useInboxSignalsFilterStore(
+ (state) => state.sortDirection,
+ );
+
+ const showAllStates = reportStateFilter.length === 0;
+ const showReviewAndMerge =
+ showAllStates || reportStateFilter.includes("review_and_merge");
+ const showNeedsDecision =
+ showAllStates || reportStateFilter.includes("needs_decision");
+ const showTerminal =
+ showAllStates ||
+ reportStateFilter.includes("resolved") ||
+ reportStateFilter.includes("dismissed");
+ const terminalStatusFilter = useMemo(() => {
+ const statuses: SignalReportStatus[] = [];
+ if (showAllStates || reportStateFilter.includes("resolved")) {
+ statuses.push("resolved");
+ }
+ if (showAllStates || reportStateFilter.includes("dismissed")) {
+ statuses.push("suppressed");
+ }
+ return buildStatusFilterParam(statuses);
+ }, [reportStateFilter, showAllStates]);
+
+ const reviewAndMergeQuery = useInboxAllReports({
+ ...SECTION_QUERY_DEFAULTS,
+ enabled: showReviewAndMerge,
+ statusFilter: "ready",
+ hasImplementationPr: true,
+ });
+ const needsDecisionQuery = useInboxAllReports({
+ ...SECTION_QUERY_DEFAULTS,
+ enabled: showNeedsDecision,
+ statusFilter: INBOX_ACTIONABLE_REPORT_STATUS_FILTER,
+ actionabilityFilter: INBOX_ACTIONABLE_ACTIONABILITY_FILTER,
+ hasImplementationPr: false,
+ });
+ const terminalQuery = useInboxAllReports({
+ ...SECTION_QUERY_DEFAULTS,
+ enabled: showTerminal,
+ statusFilter: terminalStatusFilter,
+ });
+
+ useAutoPage(reviewAndMergeQuery, autoPage && showReviewAndMerge);
+ useAutoPage(needsDecisionQuery, autoPage && showNeedsDecision);
+ useAutoPage(terminalQuery, autoPage && showTerminal);
+
+ const { searchQuery, scope, sourceProductFilter, priorityFilter } =
+ reviewAndMergeQuery;
+ const triageReports = showNeedsDecision
+ ? needsDecisionQuery.scopedReports
+ : EMPTY_REPORTS;
+
+ const visibleReports = useMemo(() => {
+ const reports = [
+ ...(showReviewAndMerge ? reviewAndMergeQuery.scopedReports : []),
+ ...(showNeedsDecision ? needsDecisionQuery.scopedReports : []),
+ ...(showTerminal ? terminalQuery.scopedReports : []),
+ ];
+ return sortInboxReports(
+ Array.from(
+ new Map(reports.map((report) => [report.id, report])).values(),
+ ),
+ sortField,
+ sortDirection,
+ );
+ }, [
+ needsDecisionQuery.scopedReports,
+ reviewAndMergeQuery.scopedReports,
+ showNeedsDecision,
+ showReviewAndMerge,
+ showTerminal,
+ sortDirection,
+ sortField,
+ terminalQuery.scopedReports,
+ ]);
+
+ const selected = [
+ ...(showReviewAndMerge ? [reviewAndMergeQuery] : []),
+ ...(showNeedsDecision ? [needsDecisionQuery] : []),
+ ...(showTerminal ? [terminalQuery] : []),
+ ];
+ const reportCount = selected.reduce(
+ (total, query) => total + query.totalCount,
+ 0,
+ );
+ const isSuccess = selected.every((query) => query.isSuccess);
+
+ return {
+ reports: visibleReports,
+ triageReports,
+ triageReportCount: showNeedsDecision ? needsDecisionQuery.totalCount : 0,
+ reportCount,
+ isLoading: selected.some((query) => query.isPending),
+ isSuccess,
+ isError:
+ visibleReports.length === 0 && selected.some((query) => query.isError),
+ isEmpty: isSuccess && reportCount === 0,
+ isFetchingNextPage: selected.some((query) => query.isFetchingNextPage),
+ hasNextPage: selected.some(
+ (query) =>
+ query.hasNextPage && query.allReports.length >= AUTOPAGE_REPORT_LIMIT,
+ ),
+ loadMore: () => {
+ for (const query of selected) {
+ if (query.hasNextPage && !query.isFetchingNextPage) {
+ void query.fetchNextPage();
+ }
+ }
+ },
+ retry: () => {
+ if (selected.some((query) => query.isFetching)) return;
+ for (const query of selected) void query.refetch();
+ },
+ scope,
+ reportStateFilter,
+ searchQuery,
+ sourceProductFilter,
+ priorityFilter,
+ };
+}
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxTriageHotkey.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxTriageHotkey.ts
new file mode 100644
index 000000000000..e93dcdad0aff
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxTriageHotkey.ts
@@ -0,0 +1,35 @@
+import { INBOX_TRIAGE_ROUTE } from "@posthog/ui/features/inbox/triageRoute";
+import { useNavigate } from "@tanstack/react-router";
+import { useEffect } from "react";
+
+function isTypingTarget(target: EventTarget | null): boolean {
+ if (!(target instanceof HTMLElement)) return false;
+ return (
+ target.isContentEditable ||
+ target.tagName === "INPUT" ||
+ target.tagName === "TEXTAREA" ||
+ target.tagName === "SELECT"
+ );
+}
+
+/** "t" from the reports list or an open report starts triage. */
+export function useInboxTriageHotkey(options: {
+ enabled: boolean;
+ triageReportCount?: number;
+}): void {
+ const { enabled, triageReportCount } = options;
+ const navigate = useNavigate();
+
+ useEffect(() => {
+ if (!enabled || triageReportCount === 0) return;
+ const onKeyDown = (event: KeyboardEvent): void => {
+ if (isTypingTarget(event.target)) return;
+ if (event.metaKey || event.ctrlKey || event.altKey) return;
+ if (event.key.toLowerCase() !== "t") return;
+ event.preventDefault();
+ void navigate({ to: INBOX_TRIAGE_ROUTE });
+ };
+ window.addEventListener("keydown", onKeyDown);
+ return () => window.removeEventListener("keydown", onKeyDown);
+ }, [enabled, navigate, triageReportCount]);
+}
diff --git a/products/desktop/packages/ui/src/features/inbox/stores/inboxReportReadStore.ts b/products/desktop/packages/ui/src/features/inbox/stores/inboxReportReadStore.ts
new file mode 100644
index 000000000000..d928f284eadc
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/stores/inboxReportReadStore.ts
@@ -0,0 +1,39 @@
+import { electronStorage } from "@posthog/ui/shell/rendererStorage";
+import { create } from "zustand";
+import { persist } from "zustand/middleware";
+
+interface InboxReportReadState {
+ readByKey: Record<string, boolean>;
+ hasHydrated: boolean;
+ setRead: (key: string, read: boolean) => void;
+}
+
+export const useInboxReportReadStore = create<InboxReportReadState>()(
+ persist(
+ (set) => ({
+ readByKey: {},
+ hasHydrated: false,
+ setRead: (key, read) =>
+ set((state) =>
+ state.readByKey[key] === read
+ ? state
+ : { readByKey: { ...state.readByKey, [key]: read } },
+ ),
+ }),
+ {
+ name: "inbox-report-read",
+ storage: electronStorage,
+ partialize: (state) => ({ readByKey: state.readByKey }),
+ merge: (persisted, current) => ({
+ ...current,
+ readByKey: {
+ ...(persisted as Partial<InboxReportReadState>)?.readByKey,
+ ...current.readByKey,
+ },
+ }),
+ onRehydrateStorage: () => () => {
+ useInboxReportReadStore.setState({ hasHydrated: true });
+ },
+ },
+ ),
+);
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 271c2aebe116..14eceb7e9101 100644
--- a/products/desktop/packages/ui/src/features/inbox/stores/inboxSignalsFilterStore.ts
+++ b/products/desktop/packages/ui/src/features/inbox/stores/inboxSignalsFilterStore.ts
@@ -96,6 +96,22 @@ export function hasActiveInboxFilters(
);
}
+/**
+ * What "filtered" counts as for the reports list: exactly the controls its
+ * filter menu shows. Pass it straight to the store hook, so every surface
+ * drawing that list agrees, and the selector keeps one identity.
+ */
+export function hasActiveReportsListFilters(
+ state: InboxSignalsFilterState,
+): boolean {
+ return hasActiveInboxFilters(state, {
+ includePrFilter: false,
+ includeSourceFilter: false,
+ includeReportStateFilter: true,
+ includeSearchFilter: false,
+ });
+}
+
/**
* v2 dropped per-status and per-reviewer filter UI; surviving consumers are sort,
* search, source-product, and priority. Bumping the persist version drops the
diff --git a/products/desktop/packages/ui/src/features/inbox/triageRoute.ts b/products/desktop/packages/ui/src/features/inbox/triageRoute.ts
new file mode 100644
index 000000000000..8af7949f8bb7
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/triageRoute.ts
@@ -0,0 +1,9 @@
+/** Triage is a place, so it has a URL: it survives a reload, restores with the
+ * rail, and a report it opens can point back at it. */
+export const INBOX_TRIAGE_ROUTE = "/inbox/triage";
+
+export function isInboxTriagePath(pathname: string): boolean {
+ return (
+ pathname === INBOX_TRIAGE_ROUTE || pathname === `${INBOX_TRIAGE_ROUTE}/`
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.stories.tsx b/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.stories.tsx
new file mode 100644
index 000000000000..d97d1fb68e51
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.stories.tsx
@@ -0,0 +1,57 @@
+import { useHostTRPC } from "@posthog/host-router/react";
+import { PrDecisionBlock } from "@posthog/ui/features/pr-review/PrDecisionBlock";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { useQueryClient } from "@tanstack/react-query";
+
+const prUrl = "https://github.com/example/project/pull/42";
+
+const meta = {
+ title: "Inbox/Reports/PR decision",
+ component: PrDecisionBlock,
+ args: { prUrl },
+ decorators: [
+ (Story, context) => {
+ const trpc = useHostTRPC();
+ const queryClient = useQueryClient();
+ queryClient.setQueryData(trpc.git.getPrInfoByUrl.queryKey({ prUrl }), {
+ number: 42,
+ title: "Fix the empty state",
+ body: "Show the next step when no results match.",
+ author: null,
+ state: "open",
+ merged: false,
+ draft: context.parameters.draft ?? true,
+ mergeable: true,
+ mergeStateStatus: "clean",
+ baseRefName: "main",
+ headRefName: "fix-empty-state",
+ additions: 8,
+ deletions: 2,
+ changedFiles: 1,
+ });
+ queryClient.setQueryData(trpc.git.getPrChecks.queryKey({ prUrl }), [
+ {
+ name: "Unit tests",
+ bucket: context.parameters.failing ? "fail" : "pass",
+ link: null,
+ workflow: "Tests",
+ description: null,
+ },
+ ]);
+ return (
+ <div className="w-full max-w-[900px]">
+ <Story />
+ </div>
+ );
+ },
+ ],
+} satisfies Meta<typeof PrDecisionBlock>;
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+export const Draft: Story = {};
+export const DraftWithFailingChecks: Story = { parameters: { failing: true } };
+export const Ready: Story = { parameters: { draft: false } };
+export const ReadyWithFailingChecks: Story = {
+ parameters: { draft: false, failing: true },
+};
diff --git a/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.tsx b/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.tsx
index 0d1263360e6b..bd192615d3b7 100644
--- a/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.tsx
+++ b/products/desktop/packages/ui/src/features/pr-review/PrDecisionBlock.tsx
@@ -148,6 +148,7 @@ export function PrDecisionBlock({ prUrl }: PrDecisionBlockProps) {
<Button
type="button"
variant="outline"
+ loading={approve.isPending}
disabled={approveDisabled}
onClick={() => approve.mutate({ prUrl })}
className={BIG_BUTTON}
@@ -165,6 +166,7 @@ export function PrDecisionBlock({ prUrl }: PrDecisionBlockProps) {
<Button
type="button"
variant="primary"
+ loading={merge.isPending}
disabled={mergeDisabled}
onClick={() => merge.mutate({ prUrl, method })}
className={BIG_BUTTON}
@@ -204,11 +206,11 @@ export function PrDecisionBlock({ prUrl }: PrDecisionBlockProps) {
type="button"
variant="outline"
size="sm"
+ loading={markReady.isPending}
disabled={markReady.isPending}
onClick={() => markReady.mutate({ prUrl, action: "ready" })}
className="gap-1.5"
>
- {markReady.isPending && <Spinner />}
Ready for review
</Button>
</>
diff --git a/products/desktop/packages/ui/src/features/sessions/components/ArtifactPreviewContent.tsx b/products/desktop/packages/ui/src/features/sessions/components/ArtifactPreviewContent.tsx
index b49998c5eb03..3f726886e42b 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/ArtifactPreviewContent.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/ArtifactPreviewContent.tsx
@@ -12,6 +12,7 @@ import {
} from "@posthog/quill";
import { isAllowedImageMimeType } from "@posthog/shared";
import type { UserBasic } from "@posthog/shared/domain-types";
+import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";
import { LoadingState } from "@posthog/ui/primitives/LoadingState";
import type {
Dispatch,
@@ -57,15 +58,12 @@ function GenericArtifactHeader({
actions?: ReactNode;
}): ReactElement {
return (
- <header className="flex h-10 shrink-0 items-center justify-between gap-2 border-border border-b px-3">
- <div className="flex min-w-0 items-center gap-2">
- <span className="truncate font-[var(--code-font-family)] text-[13px] text-muted-foreground">
- {name}
- </span>
- {versionNav}
- </div>
- {actions}
- </header>
+ <ChromeBar inset="even" actions={actions}>
+ <span className="truncate font-[var(--code-font-family)] text-[13px] text-muted-foreground">
+ {name}
+ </span>
+ {versionNav}
+ </ChromeBar>
);
}
diff --git a/products/desktop/packages/ui/src/features/sidebar/components/OpenSidebarButton.tsx b/products/desktop/packages/ui/src/features/sidebar/components/OpenSidebarButton.tsx
new file mode 100644
index 000000000000..fc15ebb6ca8a
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/sidebar/components/OpenSidebarButton.tsx
@@ -0,0 +1,35 @@
+import { SidebarSimpleIcon } from "@phosphor-icons/react";
+import { Button, Kbd } from "@posthog/quill";
+import {
+ formatHotkey,
+ SHORTCUTS,
+} from "@posthog/ui/features/command/keyboard-shortcuts";
+import { cancelSidebarPeek } from "@posthog/ui/features/sidebar/sidebarPeekStore";
+import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";
+import type { ReactElement } from "react";
+
+/**
+ * Way back to a collapsed sidebar, for the panes whose empty state tells the
+ * reader to pick something from it. Renders nothing while the sidebar is on
+ * screen, so the empty state keeps its one instruction.
+ */
+export function OpenSidebarButton(): ReactElement | null {
+ const open = useSidebarStore((state) => state.open);
+ const setOpen = useSidebarStore((state) => state.setOpen);
+ if (open) return null;
+
+ return (
+ <Button
+ variant="outline"
+ size="default"
+ onClick={() => {
+ cancelSidebarPeek();
+ setOpen(true);
+ }}
+ >
+ <SidebarSimpleIcon />
+ Open the sidebar
+ <Kbd>{formatHotkey(SHORTCUTS.TOGGLE_LEFT_SIDEBAR)}</Kbd>
+ </Button>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.tsx
index 3d9f57236369..a5083a4ee806 100644
--- a/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.tsx
+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskHeaderActions.tsx
@@ -48,10 +48,10 @@ export function TaskHeaderActions({ task }: { task: Task }) {
return (
<div className="flex h-full max-w-[50%] shrink-0 items-center justify-end gap-1 overflow-hidden px-1">
- <div className="no-drag">
+ <div className="no-drag flex">
<AutoresearchHeaderButton taskId={task.id} />
</div>
- <div className="no-drag">
+ <div className="no-drag flex">
<TaskAnalysisButton task={task} />
</div>
{workspace && (workspace.branchName || workspace.baseBranch) && (
diff --git a/products/desktop/packages/ui/src/hooks/useSetHeaderContent.ts b/products/desktop/packages/ui/src/hooks/useSetHeaderContent.ts
index 09516a9a49f0..d5e500006629 100644
--- a/products/desktop/packages/ui/src/hooks/useSetHeaderContent.ts
+++ b/products/desktop/packages/ui/src/hooks/useSetHeaderContent.ts
@@ -1,14 +1,20 @@
import { useHeaderStore } from "@posthog/ui/shell/headerStore";
import { type ReactNode, useLayoutEffect } from "react";
-export function useSetHeaderContent(content: ReactNode) {
+/**
+ * Push `null` for a view with nothing to name; the row collapses. `enabled` is
+ * for the one leaf that shares a route with a layout writing here too: pushing
+ * null there would clear the layout's title instead of leaving it alone.
+ */
+export function useSetHeaderContent(content: ReactNode, enabled = true) {
const setContent = useHeaderStore((state) => state.setContent);
useLayoutEffect(() => {
+ if (!enabled) return;
setContent(content);
return () => {
setContent(null);
};
- }, [content, setContent]);
+ }, [content, enabled, setContent]);
}
diff --git a/products/desktop/packages/ui/src/primitives/ChromeBar.tsx b/products/desktop/packages/ui/src/primitives/ChromeBar.tsx
new file mode 100644
index 000000000000..667a9370d950
--- /dev/null
+++ b/products/desktop/packages/ui/src/primitives/ChromeBar.tsx
@@ -0,0 +1,47 @@
+import { cn } from "@posthog/quill";
+import type { ReactElement, ReactNode } from "react";
+
+/** A leading button carries its own padding; leading text does not. */
+type ChromeBarInset = "control" | "text" | "even";
+
+const INSET_CLASS: Record<ChromeBarInset, string> = {
+ control: "pr-2 pl-1",
+ text: "pr-2 pl-3",
+ even: "px-3",
+};
+
+/**
+ * The bar across the top of a pane, a column, or a side panel. Every such bar
+ * in the app is this one, so they stay the same height and colour.
+ *
+ * `actions` is what reaches the far end. Children spread instead only look
+ * right-aligned while the title is long enough to push them.
+ */
+export function ChromeBar({
+ children,
+ actions,
+ inset = "text",
+ className,
+}: {
+ children?: ReactNode;
+ actions?: ReactNode;
+ inset?: ChromeBarInset;
+ className?: string;
+}): ReactElement {
+ return (
+ <div
+ className={cn(
+ "flex h-10 shrink-0 items-center gap-2 border-border border-b",
+ INSET_CLASS[inset],
+ className,
+ )}
+ >
+ {children}
+ {actions && (
+ <div className="ml-auto flex shrink-0 items-center gap-1">
+ {actions}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/products/desktop/packages/ui/src/primitives/FilterMenu.stories.tsx b/products/desktop/packages/ui/src/primitives/FilterMenu.stories.tsx
new file mode 100644
index 000000000000..c04ea134e173
--- /dev/null
+++ b/products/desktop/packages/ui/src/primitives/FilterMenu.stories.tsx
@@ -0,0 +1,57 @@
+import { DropdownMenu, DropdownMenuContent } from "@posthog/quill";
+import {
+ FilterMenuTrigger,
+ FilterRadioSubMenu,
+} from "@posthog/ui/primitives/FilterMenu";
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { useState } from "react";
+
+function SearchableScope(): React.JSX.Element {
+ const [scope, setScope] = useState("for-you");
+ return (
+ <DropdownMenu>
+ <FilterMenuTrigger
+ active={scope !== "for-you"}
+ label="Filter reports"
+ dataAttr="story-report-filter"
+ />
+ <DropdownMenuContent>
+ <FilterRadioSubMenu
+ label="Scope"
+ value={scope}
+ defaultValue="for-you"
+ onChange={setScope}
+ searchPlaceholder="Search users…"
+ options={[
+ { value: "for-you", label: "For you" },
+ { value: "project", label: "Entire project" },
+ {
+ value: "alex",
+ label: "Alex Example",
+ searchLabel: "[email protected]",
+ },
+ {
+ value: "sam",
+ label: "Sam Sample",
+ searchLabel: "[email protected]",
+ },
+ ...Array.from({ length: 30 }, (_, index) => ({
+ value: `user-${index}`,
+ label: `Example user ${index}`,
+ searchLabel: `user-${index}@example.com`,
+ })),
+ ]}
+ />
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
+
+const meta = {
+ title: "Primitives/Filter menu",
+ component: SearchableScope,
+} satisfies Meta<typeof SearchableScope>;
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+export const SearchUsers: Story = {};
diff --git a/products/desktop/packages/ui/src/primitives/FilterMenu.tsx b/products/desktop/packages/ui/src/primitives/FilterMenu.tsx
new file mode 100644
index 000000000000..f41329e6ff46
--- /dev/null
+++ b/products/desktop/packages/ui/src/primitives/FilterMenu.tsx
@@ -0,0 +1,306 @@
+import { FunnelSimpleIcon } from "@phosphor-icons/react";
+import {
+ Button,
+ Combobox,
+ ComboboxCollection,
+ ComboboxEmpty,
+ ComboboxInput,
+ ComboboxItem,
+ ComboboxList,
+ cn,
+ DropdownMenuCheckboxItem,
+ DropdownMenuItem,
+ DropdownMenuRadioGroup,
+ DropdownMenuRadioItem,
+ DropdownMenuSeparator,
+ DropdownMenuSub,
+ DropdownMenuSubContent,
+ DropdownMenuSubTrigger,
+ DropdownMenuTrigger,
+} from "@posthog/quill";
+import { type ReactElement, type ReactNode, useState } from "react";
+
+export interface FilterOption<Value extends string> {
+ value: Value;
+ label: string;
+ searchLabel?: string;
+ icon?: ReactNode;
+}
+
+/**
+ * The parts every list-filter menu is built from. Canvases, Activity and
+ * Self-driving all draw them, so they live here rather than per feature.
+ */
+export function FilterMenuTrigger({
+ active,
+ label,
+ dataAttr,
+ size = "icon-sm",
+}: {
+ active: boolean;
+ label: string;
+ dataAttr: string;
+ size?: "icon-xs" | "icon-sm";
+}): ReactElement {
+ return (
+ <DropdownMenuTrigger
+ render={
+ <Button
+ variant="default"
+ size={size}
+ aria-label={label}
+ data-attr={dataAttr}
+ className="relative"
+ >
+ <FunnelSimpleIcon />
+ {active && (
+ <span
+ aria-hidden
+ className="absolute top-0 right-0 size-1.5 rounded-full bg-primary"
+ />
+ )}
+ </Button>
+ }
+ />
+ );
+}
+
+export function FilterSubMenuTrigger({
+ label,
+ value,
+ active,
+ disabled,
+}: {
+ label: string;
+ value: string;
+ active: boolean;
+ disabled?: boolean;
+}): ReactElement {
+ return (
+ <DropdownMenuSubTrigger className="pr-1" disabled={disabled}>
+ <span>{label}</span>
+ <span
+ title={value}
+ className={cn(
+ "min-w-0 flex-1 truncate pl-4 text-right",
+ active ? "text-primary" : "text-muted-foreground/80",
+ )}
+ >
+ {value}
+ </span>
+ </DropdownMenuSubTrigger>
+ );
+}
+
+export function FilterSubMenu({
+ label,
+ value,
+ active,
+ children,
+}: {
+ label: string;
+ value: string;
+ active: boolean;
+ children: ReactNode;
+}): ReactElement {
+ return (
+ <DropdownMenuSub>
+ <FilterSubMenuTrigger label={label} value={value} active={active} />
+ <DropdownMenuSubContent side="right" sideOffset={4}>
+ {children}
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+ );
+}
+
+export function FilterRadioSubMenu<Value extends string>({
+ label,
+ options,
+ value,
+ defaultValue,
+ valueLabel,
+ onChange,
+ searchPlaceholder,
+}: {
+ label: string;
+ options: readonly FilterOption<Value>[];
+ value: Value;
+ defaultValue: Value;
+ /** Overrides the option's own label, for a value the list cannot name. */
+ valueLabel?: string;
+ onChange: (value: Value) => void;
+ searchPlaceholder?: string;
+}): ReactElement {
+ const [open, setOpen] = useState(false);
+ const [autoFocusSearch, setAutoFocusSearch] = useState(false);
+ const [search, setSearch] = useState("");
+ const selected =
+ valueLabel ?? options.find((option) => option.value === value)?.label ?? "";
+
+ if (searchPlaceholder) {
+ return (
+ <DropdownMenuSub
+ open={open}
+ onOpenChange={(next, details) => {
+ setAutoFocusSearch(next && details.event.type === "keydown");
+ setOpen(next);
+ setSearch("");
+ }}
+ >
+ <FilterSubMenuTrigger
+ label={label}
+ value={selected}
+ active={value !== defaultValue}
+ />
+ <DropdownMenuSubContent className="w-64 [&>div]:overflow-hidden [&>div]:p-0">
+ <Combobox<FilterOption<Value>>
+ inline
+ autoHighlight
+ items={options}
+ limit={20}
+ inputValue={search}
+ onInputValueChange={(next, details) => {
+ if (details.reason === "input-change") setSearch(next);
+ }}
+ value={options.find((option) => option.value === value) ?? null}
+ itemToStringLabel={(option) =>
+ `${option.label} ${option.searchLabel ?? ""}`
+ }
+ itemToStringValue={(option) => option.value}
+ onValueChange={(option) => {
+ if (option) {
+ onChange(option.value);
+ setOpen(false);
+ setSearch("");
+ }
+ }}
+ >
+ <div className="p-1">
+ <ComboboxInput
+ autoFocus={autoFocusSearch}
+ showTrigger={false}
+ placeholder={searchPlaceholder}
+ aria-label={searchPlaceholder}
+ onClick={(event) => event.stopPropagation()}
+ onKeyDown={(event) => {
+ if (event.key !== "Escape") event.stopPropagation();
+ }}
+ />
+ </div>
+ <ComboboxList className="group/combobox-list max-h-72 border-border border-t">
+ <ComboboxCollection>
+ {(option: FilterOption<Value>) => (
+ <ComboboxItem
+ key={option.value}
+ value={option}
+ className="!ps-7.5"
+ onClick={(event) => event.stopPropagation()}
+ >
+ {option.icon}
+ {option.label}
+ </ComboboxItem>
+ )}
+ </ComboboxCollection>
+ <ComboboxEmpty className="group-data-empty/combobox-list:flex">
+ No matches. Try another search.
+ </ComboboxEmpty>
+ </ComboboxList>
+ </Combobox>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+ );
+ }
+
+ return (
+ <FilterSubMenu
+ label={label}
+ value={selected}
+ active={value !== defaultValue}
+ >
+ <DropdownMenuRadioGroup
+ value={value}
+ onValueChange={(next) => onChange(next as Value)}
+ >
+ {options.map((option) => (
+ <DropdownMenuRadioItem key={option.value} value={option.value}>
+ {option.icon}
+ {option.label}
+ </DropdownMenuRadioItem>
+ ))}
+ </DropdownMenuRadioGroup>
+ </FilterSubMenu>
+ );
+}
+
+export function FilterCheckboxSubMenu<Value extends string>({
+ label,
+ summary,
+ allLabel,
+ options,
+ selected,
+ active,
+ onToggle,
+ onClear,
+}: {
+ label: string;
+ summary: string;
+ allLabel: string;
+ options: readonly FilterOption<Value>[];
+ selected: readonly Value[];
+ /** For a filter whose default is a selection rather than an empty one. */
+ active?: boolean;
+ onToggle: (value: Value) => void;
+ onClear: () => void;
+}): ReactElement {
+ return (
+ <FilterSubMenu
+ label={label}
+ value={summary}
+ active={active ?? selected.length > 0}
+ >
+ <DropdownMenuCheckboxItem
+ checked={selected.length === 0}
+ closeOnClick={false}
+ onCheckedChange={onClear}
+ >
+ {allLabel}
+ </DropdownMenuCheckboxItem>
+ {options.map((option) => (
+ <DropdownMenuCheckboxItem
+ key={option.value}
+ checked={selected.includes(option.value)}
+ closeOnClick={false}
+ onCheckedChange={() => onToggle(option.value)}
+ >
+ {option.icon}
+ {option.label}
+ </DropdownMenuCheckboxItem>
+ ))}
+ </FilterSubMenu>
+ );
+}
+
+export function FilterClearItem({
+ active,
+ dataAttr,
+ onClear,
+}: {
+ active: boolean;
+ dataAttr: string;
+ onClear: () => void;
+}): ReactElement | null {
+ if (!active) return null;
+
+ return (
+ <>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ data-attr={dataAttr}
+ variant="destructive"
+ onClick={onClear}
+ >
+ Clear filters
+ </DropdownMenuItem>
+ </>
+ );
+}
diff --git a/products/desktop/packages/ui/src/router/reportNavigation.ts b/products/desktop/packages/ui/src/router/reportNavigation.ts
index e5efebae9775..0d68aed44fb4 100644
--- a/products/desktop/packages/ui/src/router/reportNavigation.ts
+++ b/products/desktop/packages/ui/src/router/reportNavigation.ts
@@ -96,6 +96,17 @@ export function resolveNavigationSource(
};
}
+export function hrefPath(href: string): string {
+ return href.replace(/[?#].*$/, "");
+}
+
+/** For callers holding a location as a string, not a parsed one. */
+export function reportSourceHrefFromHref(href: string): string | undefined {
+ const [path, query] = href.split(/[?#]/, 2);
+ if (!isReportPath(path) || !query) return undefined;
+ return validSourceHref(new URLSearchParams(query).get("from") ?? undefined);
+}
+
export function sourceHrefFromSearch(
location: SourceLocation,
): string | undefined {
diff --git a/products/desktop/packages/ui/src/router/routeTree.gen.ts b/products/desktop/packages/ui/src/router/routeTree.gen.ts
index 48a05cea9b73..0d1f630c7c59 100644
--- a/products/desktop/packages/ui/src/router/routeTree.gen.ts
+++ b/products/desktop/packages/ui/src/router/routeTree.gen.ts
@@ -26,6 +26,7 @@ import { Route as TasksTaskIdRouteImport } from './routes/tasks/$taskId'
import { Route as ReportsReportIdRouteImport } from './routes/reports/$reportId'
import { Route as LoopsNewRouteImport } from './routes/loops/new'
import { Route as LoopsLoopIdRouteImport } from './routes/loops/$loopId'
+import { Route as InboxTriageRouteImport } from './routes/inbox/triage'
import { Route as InboxRunsRouteImport } from './routes/inbox/runs'
import { Route as InboxReportsRouteImport } from './routes/inbox/reports'
import { Route as InboxPullsRouteImport } from './routes/inbox/pulls'
@@ -152,6 +153,11 @@ const LoopsLoopIdRoute = LoopsLoopIdRouteImport.update({
path: '/loops/$loopId',
getParentRoute: () => rootRouteImport,
} as any)
+const InboxTriageRoute = InboxTriageRouteImport.update({
+ id: '/triage',
+ path: '/triage',
+ getParentRoute: () => InboxRoute,
+} as any)
const InboxRunsRoute = InboxRunsRouteImport.update({
id: '/runs',
path: '/runs',
@@ -389,6 +395,7 @@ export interface FileRoutesByFullPath {
'/inbox/pulls': typeof InboxPullsRouteWithChildren
'/inbox/reports': typeof InboxReportsRouteWithChildren
'/inbox/runs': typeof InboxRunsRouteWithChildren
+ '/inbox/triage': typeof InboxTriageRoute
'/loops/$loopId': typeof LoopsLoopIdRouteWithChildren
'/loops/new': typeof LoopsNewRoute
'/reports/$reportId': typeof ReportsReportIdRoute
@@ -442,6 +449,7 @@ export interface FileRoutesByTo {
'/code/$': typeof CodeSplatRoute
'/folders/$folderId': typeof FoldersFolderIdRoute
'/inbox/agents': typeof InboxAgentsRoute
+ '/inbox/triage': typeof InboxTriageRoute
'/loops/new': typeof LoopsNewRoute
'/reports/$reportId': typeof ReportsReportIdRoute
'/tasks/$taskId': typeof TasksTaskIdRoute
@@ -502,6 +510,7 @@ export interface FileRoutesById {
'/inbox/pulls': typeof InboxPullsRouteWithChildren
'/inbox/reports': typeof InboxReportsRouteWithChildren
'/inbox/runs': typeof InboxRunsRouteWithChildren
+ '/inbox/triage': typeof InboxTriageRoute
'/loops/$loopId': typeof LoopsLoopIdRouteWithChildren
'/loops/new': typeof LoopsNewRoute
'/reports/$reportId': typeof ReportsReportIdRoute
@@ -564,6 +573,7 @@ export interface FileRouteTypes {
| '/inbox/pulls'
| '/inbox/reports'
| '/inbox/runs'
+ | '/inbox/triage'
| '/loops/$loopId'
| '/loops/new'
| '/reports/$reportId'
@@ -617,6 +627,7 @@ export interface FileRouteTypes {
| '/code/$'
| '/folders/$folderId'
| '/inbox/agents'
+ | '/inbox/triage'
| '/loops/new'
| '/reports/$reportId'
| '/tasks/$taskId'
@@ -676,6 +687,7 @@ export interface FileRouteTypes {
| '/inbox/pulls'
| '/inbox/reports'
| '/inbox/runs'
+ | '/inbox/triage'
| '/loops/$loopId'
| '/loops/new'
| '/reports/$reportId'
@@ -858,6 +870,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof LoopsLoopIdRouteImport
parentRoute: typeof rootRouteImport
}
+ '/inbox/triage': {
+ id: '/inbox/triage'
+ path: '/triage'
+ fullPath: '/inbox/triage'
+ preLoaderRoute: typeof InboxTriageRouteImport
+ parentRoute: typeof InboxRoute
+ }
'/inbox/runs': {
id: '/inbox/runs'
path: '/runs'
@@ -1268,6 +1287,7 @@ interface InboxRouteChildren {
InboxPullsRoute: typeof InboxPullsRouteWithChildren
InboxReportsRoute: typeof InboxReportsRouteWithChildren
InboxRunsRoute: typeof InboxRunsRouteWithChildren
+ InboxTriageRoute: typeof InboxTriageRoute
InboxIndexRoute: typeof InboxIndexRoute
}
@@ -1277,6 +1297,7 @@ const InboxRouteChildren: InboxRouteChildren = {
InboxPullsRoute: InboxPullsRouteWithChildren,
InboxReportsRoute: InboxReportsRouteWithChildren,
InboxRunsRoute: InboxRunsRouteWithChildren,
+ InboxTriageRoute: InboxTriageRoute,
InboxIndexRoute: InboxIndexRoute,
}
diff --git a/products/desktop/packages/ui/src/router/routes/inbox/triage.tsx b/products/desktop/packages/ui/src/router/routes/inbox/triage.tsx
new file mode 100644
index 000000000000..38d41a050050
--- /dev/null
+++ b/products/desktop/packages/ui/src/router/routes/inbox/triage.tsx
@@ -0,0 +1,7 @@
+import { createFileRoute } from "@tanstack/react-router";
+
+// `InboxView` renders triage for this path, the way it renders the list for
+// `/inbox/reports`, so the route itself only has to exist.
+export const Route = createFileRoute("/inbox/triage")({
+ component: () => null,
+});
diff --git a/products/desktop/packages/ui/src/shell/ContentHeader.tsx b/products/desktop/packages/ui/src/shell/ContentHeader.tsx
index cb13a0e35281..424a4a2df32c 100644
--- a/products/desktop/packages/ui/src/shell/ContentHeader.tsx
+++ b/products/desktop/packages/ui/src/shell/ContentHeader.tsx
@@ -1,8 +1,8 @@
import { TaskHeaderActions } from "@posthog/ui/features/task-detail/components/TaskHeaderActions";
import { useTasks } from "@posthog/ui/features/tasks/useTasks";
+import { ChromeBar } from "@posthog/ui/primitives/ChromeBar";
import { useAppView } from "@posthog/ui/router/useAppView";
import { useHeaderStore } from "@posthog/ui/shell/headerStore";
-import { Flex } from "@radix-ui/themes";
// The in-pane content header for the unified Bluebird chrome. Shows the active
// view's title (pushed into the header store by each view) on the left and that
@@ -10,16 +10,17 @@ import { Flex } from "@radix-ui/themes";
// review-panel toggle, skill buttons and task actions that
// used to live in the Code header bar.
//
-// This breadcrumb row is scoped to views that have somewhere to walk back to:
-// task detail, and the loop scenes (list / detail / form), which live outside
-// the space routes but can belong to a space. Every other page drops it (the
-// title bar search carries wayfinding instead). The /website (Channels) space
-// keeps its own header (ShellLayout), so it's unaffected — this is mounted
-// only outside it.
+// This breadcrumb row is scoped to views that name what you are looking at:
+// task detail, the loop scenes (list / detail / form), which live outside the
+// space routes but can belong to a space, and Self-driving with the reports it
+// opens, whose list moved into the rail's sidebar and left the pane with no
+// title of its own. Every other page drops it (the title bar search carries
+// wayfinding instead). The /website (Channels) space keeps its own header
+// (ShellLayout), so it's unaffected — this is mounted only outside it.
//
// A loop with no space pushes null, so the row collapses for it too: what a
// view puts in the header store decides, this only says who may.
-const BREADCRUMB_VIEWS = new Set(["task-detail", "loops"]);
+const BREADCRUMB_VIEWS = new Set(["task-detail", "loops", "inbox", "report"]);
export function ContentHeader() {
const content = useHeaderStore((state) => state.content);
@@ -37,18 +38,14 @@ export function ContentHeader() {
if (!content && !showTaskSection) return null;
return (
- <Flex align="center" className="h-10 shrink-0 border-border border-b px-3">
+ <ChromeBar inset="control">
{content && (
- <Flex
- align="center"
- justify="between"
- className="h-full min-w-0 flex-1 overflow-hidden"
- >
+ <div className="flex h-full min-w-0 flex-1 items-center justify-between overflow-hidden">
{content}
- </Flex>
+ </div>
)}
{showTaskSection && activeTask && <TaskHeaderActions task={activeTask} />}
- </Flex>
+ </ChromeBar>
);
}