:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(desktop): link Inbox report task references (#92103)
Dylan Martinab5a8bbb1039
diff --git a/products/desktop/apps/mobile/src/features/chat/components/ObjectTagChip.tsx b/products/desktop/apps/mobile/src/features/chat/components/ObjectTagChip.tsxindex 418ecff32fab..15ae24159cb8 100644--- a/products/desktop/apps/mobile/src/features/chat/components/ObjectTagChip.tsx+++ b/products/desktop/apps/mobile/src/features/chat/components/ObjectTagChip.tsx@@ -21,6 +21,7 @@ import {ShieldCheck,Sparkle,SquaresFour,+ Tray,User,UsersThree,} from "phosphor-react-native";@@ -42,6 +43,7 @@ const KIND_ICONS: Record<string, Icon> = {experiment: Flask,survey: ClipboardText,ticket: ChatCircleText,+ report: Tray,trace: Sparkle,eval: ShieldCheck,event: Lightning,diff --git a/products/desktop/packages/api-client/src/evidence-previews.test.ts b/products/desktop/packages/api-client/src/evidence-previews.test.tsindex ac81902b7438..32431083384d 100644--- a/products/desktop/packages/api-client/src/evidence-previews.test.ts+++ b/products/desktop/packages/api-client/src/evidence-previews.test.ts@@ -18,6 +18,7 @@ import {shapeExperimentPreview,shapeExperimentResults,shapeFlagPreview,+ shapeInboxReportPreview,shapePersonPreview,shapeRecordingPreview,shapeSurveyPreview,@@ -792,6 +793,29 @@ describe("evidence preview shaping", () => {expect(preview.title).toBe("Ticket #841");});+ it("summarizes an Inbox report separately from a support ticket", () => {+ const preview = shapeInboxReportPreview({+ id: "rep-1",+ title: "Checkout latency increased",+ summary: "Requests became slower after the latest release.",+ status: "pending_input",+ priority: "P2",+ signal_count: 4,+ total_weight: 4,+ artefact_count: 2,+ source_products: ["error_tracking"],+ created_at: "2026-01-02T10:00:00Z",+ updated_at: "2026-01-03T10:00:00Z",+ });++ expect(preview).toMatchObject({+ title: "Checkout latency increased",+ detail: "Requests became slower after the latest release.",+ status: { label: "Pending input", tone: "caution" },+ facts: ["P2", "4 signals", "Error tracking"],+ });+ });+it("identifies a person by name or email and carries the uuid for links", () => {expect(shapePersonPreview({diff --git a/products/desktop/packages/api-client/src/evidence-previews.ts b/products/desktop/packages/api-client/src/evidence-previews.tsindex 65daa29a932d..53c0db779eb5 100644--- a/products/desktop/packages/api-client/src/evidence-previews.ts+++ b/products/desktop/packages/api-client/src/evidence-previews.ts@@ -6,6 +6,7 @@// The per-kind shaping is kept here (pure, unit-tested) so the client method// stays a thin "fetch by kind, shape result" dispatch.+import type { SignalReport } from "@posthog/shared/domain-types";import type { Schemas } from "./generated";export interface EvidenceDetailField {@@ -1629,6 +1630,45 @@ export function shapeTicketPreview(ticket: Schemas.Ticket): EvidencePreview {};}+export function shapeInboxReportPreview(report: SignalReport): EvidencePreview {+ const status = humanizeStatus(report.status);+ const sources = report.source_products?.map(humanizeStatus).join(", ");+ const summary = report.summary?.replace(/\s+/g, " ").trim();+ const detail = summary+ ? summary.length > 160+ ? `${summary.slice(0, 160)}…`+ : summary+ : undefined;+ const facts = [+ report.priority ?? null,+ count(report.signal_count, "signal"),+ sources || null,+ ].filter((value): value is string => Boolean(value));+ const statusTone: NonNullable<EvidencePreview["status"]>["tone"] =+ report.status === "failed"+ ? "critical"+ : report.status === "pending_input"+ ? "caution"+ : report.status === "ready" || report.status === "resolved"+ ? "positive"+ : "neutral";++ return {+ title: report.title?.trim() || "Inbox report",+ detail,+ status: { label: status, tone: statusTone },+ facts,+ sections: detailSection("Report", [+ ["Status", status],+ ["Priority", report.priority ?? null],+ ["Signals", count(report.signal_count, "signal")],+ ["Sources", sources || null],+ ["Created", report.created_at ? formatDay(report.created_at) : null],+ ["Updated", report.updated_at ? formatDay(report.updated_at) : null],+ ]),+ };+}+export function shapePersonPreview(person: Schemas.PersonRecord,): EvidencePreview {diff --git a/products/desktop/packages/api-client/src/posthog-client.test.ts b/products/desktop/packages/api-client/src/posthog-client.test.tsindex 44a472003447..621dd481f266 100644--- a/products/desktop/packages/api-client/src/posthog-client.test.ts+++ b/products/desktop/packages/api-client/src/posthog-client.test.ts@@ -138,6 +138,43 @@ describe("PostHogAPIClient", () => {});describe("getEvidencePreview", () => {+ it("retrieves an Inbox report from the signals endpoint", async () => {+ const fetch = vi.fn().mockResolvedValue(+ new Response(+ JSON.stringify({+ id: "rep-1",+ title: "Checkout latency increased",+ summary: "Requests became slower after the latest release.",+ status: "ready",+ priority: "P1",+ signal_count: 3,+ total_weight: 3,+ artefact_count: 1,+ created_at: "2026-01-02T10:00:00Z",+ updated_at: "2026-01-03T10:00:00Z",+ }),+ { status: 200, headers: { "Content-Type": "application/json" } },+ ),+ );+ const client = new PostHogAPIClient(+ "https://app.posthog.test",+ async () => "token",+ async () => "token",+ 42,+ { fetch },+ );++ await expect(+ client.getEvidencePreview("report", "rep-1"),+ ).resolves.toMatchObject({+ title: "Checkout latency increased",+ status: { label: "Ready", tone: "positive" },+ });+ expect((fetch.mock.calls[0][0] as URL).pathname).toBe(+ "/api/projects/42/signals/reports/rep-1/",+ );+ });+it("builds experiment presentation data from metric and exposure query responses", async () => {const metricResponse = {kind: "ExperimentQuery",diff --git a/products/desktop/packages/api-client/src/posthog-client.ts b/products/desktop/packages/api-client/src/posthog-client.tsindex 89f60485346a..c60ab229eef5 100644--- a/products/desktop/packages/api-client/src/posthog-client.ts+++ b/products/desktop/packages/api-client/src/posthog-client.ts@@ -94,6 +94,7 @@ import {shapeExperimentPreview,shapeExperimentResults,shapeFlagPreview,+ shapeInboxReportPreview,shapePersonPreview,shapeRecordingPreview,shapeSurveyPreview,@@ -6948,6 +6949,10 @@ export class PostHogAPIClient {);return shapeTicketPreview(ticket);}+ case "report": {+ const report = await this.getSignalReport(id);+ return report ? shapeInboxReportPreview(report) : null;+ }case "person": {if (/^[0-9a-f]{8}-[0-9a-f-]{27,}$/i.test(id)) {// A UUID-shaped id can be a person uuid or a UUID-shaped distinct iddiff --git a/products/desktop/packages/core/src/inbox/objectTags.test.ts b/products/desktop/packages/core/src/inbox/objectTags.test.tsindex 4cc4bdb728c4..9cc7767ae4ae 100644--- a/products/desktop/packages/core/src/inbox/objectTags.test.ts+++ b/products/desktop/packages/core/src/inbox/objectTags.test.ts@@ -24,6 +24,12 @@ describe("parseObjectTags", () => {]);});+ it("keeps Inbox reports distinct from support tickets", () => {+ expect(tags('<report id="rep-1">Latency regression</report>')).toEqual([+ { kind: "report", id: "rep-1", label: "Latency regression" },+ ]);+ });+it("uses the body as the label for an open/close tag", () => {expect(tags('<insight id="9pQx3">checkout funnel</insight>')).toEqual([{ kind: "insight", id: "9pQx3", label: "checkout funnel" },@@ -67,6 +73,7 @@ describe("parseObjectTags", () => {describe("objectWebPath", () => {it("builds a page path for a known kind", () => {expect(objectWebPath("insight", "9pQx3")).toBe("/insights/9pQx3");+ expect(objectWebPath("report", "rep-1")).toBe("/inbox/rep-1");});it("returns null for a flag cited by key", () => {diff --git a/products/desktop/packages/core/src/inbox/objectTags.ts b/products/desktop/packages/core/src/inbox/objectTags.tsindex 7bd0726b0237..4632c844300a 100644--- a/products/desktop/packages/core/src/inbox/objectTags.ts+++ b/products/desktop/packages/core/src/inbox/objectTags.ts@@ -73,6 +73,11 @@ const OBJECT_KINDS: Record<string, ObjectKindMeta> = {source: "Conversations",webPath: (id) => `/support/tickets/${id}`,},+ report: {+ kindLabel: "Inbox report",+ source: "Inbox",+ webPath: (id) => `/inbox/${id}`,+ },trace: {kindLabel: "LLM trace",source: "AI observability",diff --git a/products/desktop/packages/core/src/message-editor/content.test.ts b/products/desktop/packages/core/src/message-editor/content.test.tsindex e961ef496b4f..44a79559db51 100644--- a/products/desktop/packages/core/src/message-editor/content.test.ts+++ b/products/desktop/packages/core/src/message-editor/content.test.ts@@ -1,8 +1,10 @@+import { RICH_OUTPUT_TAGS_PROMPT } from "@posthog/shared/rich-output-prompt";import { describe, expect, it } from "vitest";import {contentToXml,type EditorContent,extractFilePaths,+ POSTHOG_OBJECT_KINDS,xmlToContent,xmlToPlainText,} from "./content";@@ -180,15 +182,34 @@ describe("xmlToContent", () => {});});- it("parses a dashboard tag into a PostHog object chip", () => {- expect(xmlToContent('<dashboard id="17" />').segments).toEqual([+ it.each([+ ["dashboard", "17"],+ ["report", "rep-1"],+ ] as const)("parses a %s tag into a PostHog object chip", (kind, id) => {+ expect(xmlToContent(`<${kind} id="${id}" />`).segments).toEqual([+ {+ type: "chip",+ chip: {+ type: "posthog_object",+ objectKind: kind,+ id,+ label: id,+ },+ },+ ]);+ });++ it("parses a paired report tag using its body as the label", () => {+ expect(+ xmlToContent('<report id="rep-1">Latency regression</report>').segments,+ ).toEqual([{type: "chip",chip: {type: "posthog_object",- objectKind: "dashboard",- id: "17",- label: "17",+ objectKind: "report",+ id: "rep-1",+ label: "Latency regression",},},]);@@ -372,3 +393,9 @@ describe("xmlToContent", () => {]);});});++describe("PostHog object kind prompt", () => {+ it.each(POSTHOG_OBJECT_KINDS)("teaches agents the %s tag", (kind) => {+ expect(RICH_OUTPUT_TAGS_PROMPT).toContain(kind);+ });+});diff --git a/products/desktop/packages/core/src/message-editor/content.ts b/products/desktop/packages/core/src/message-editor/content.tsindex 151e3163cc65..393886016ea0 100644--- a/products/desktop/packages/core/src/message-editor/content.ts+++ b/products/desktop/packages/core/src/message-editor/content.ts@@ -15,6 +15,7 @@ export const POSTHOG_OBJECT_KINDS = ["experiment","survey","ticket",+ "report","trace","eval","event",@@ -150,11 +151,10 @@ export function contentToXml(content: EditorContent): string {return parts.join("");}-// Self-closing chip tags, plus the paired `<hogql>...</hogql>` form whose SQL-// rides in the tag body. contentToXml XML-escapes that body, so the body is-// captured here and decoded on the way into a chip.+// Self-closing chip tags, paired report references, and the paired+// `<hogql>...</hogql>` form whose SQL rides in the tag body.const CHIP_TAG_REGEX =- /<(file|folder|skill|error|experiment|insight|feature_flag|dashboard|replay|flag|survey|ticket|trace|eval|event|cohort|action|person|github_issue|github_pr)\b([^>]*?)\s*\/>|<hogql\b[^>]*>([\s\S]*?)<\/hogql>/g;+ /<(file|folder|skill|error|experiment|insight|feature_flag|dashboard|replay|flag|survey|ticket|report|trace|eval|event|cohort|action|person|github_issue|github_pr)\b([^>]*?)\s*\/>|<report\b([^>]*?)>([\s\S]*?)<\/report>|<hogql\b[^>]*>([\s\S]*?)<\/hogql>/g;export function deriveFileLabel(filePath: string): string {const segments = filePath.split("/").filter(Boolean);@@ -163,7 +163,11 @@ export function deriveFileLabel(filePath: string): string {return parentDir ? `${parentDir}/${fileName}` : fileName;}-function chipFromTag(tag: string, rawAttrs: string): MentionChip | null {+function chipFromTag(+ tag: string,+ rawAttrs: string,+ bodyLabel?: string,+): MentionChip | null {const attrs = parseXmlAttrs(rawAttrs);switch (tag) {case "file": {@@ -205,6 +209,7 @@ function chipFromTag(tag: string, rawAttrs: string): MentionChip | null {case "flag":case "survey":case "ticket":+ case "report":case "trace":case "eval":case "event":@@ -217,7 +222,7 @@ function chipFromTag(tag: string, rawAttrs: string): MentionChip | null {type: "posthog_object",objectKind: tag,id,- label: id,+ label: bodyLabel?.trim() || id,};}case "github_issue":@@ -257,7 +262,9 @@ export function xmlToContent(xml: string): EditorContent {const matchIndex = match.index ?? 0;const chip = match[1]? chipFromTag(match[1], match[2] ?? "")- : hogqlChipFromBody(match[3] ?? "");+ : match[3] !== undefined+ ? chipFromTag("report", match[3], unescapeXmlAttr(match[4] ?? ""))+ : hogqlChipFromBody(match[5] ?? "");if (!chip) continue;if (matchIndex > lastIndex) {diff --git a/products/desktop/packages/shared/src/rich-output-prompt.ts b/products/desktop/packages/shared/src/rich-output-prompt.tsindex 693f734289bb..3a9456bc09c8 100644--- a/products/desktop/packages/shared/src/rich-output-prompt.ts+++ b/products/desktop/packages/shared/src/rich-output-prompt.ts@@ -5,7 +5,7 @@* parses.*/export const RICH_OUTPUT_TAGS_PROMPT = `Embed the PostHog objects behind your conclusions as XML tags, the same convention as \`<file path="..."/>\` attachments. Every tag is a live reference the app resolves when shown - never restate the object's data in your text, and never put tags inside code fences.-- Inline reference: \`<kind id="...">short human label</kind>\` inside a sentence, e.g. \`The <insight id="9pQx3">checkout funnel</insight> dropped after <flag id="42">new-checkout-flow</flag> rolled out.\` Kinds: insight, dashboard, error, replay, flag, experiment, survey, ticket, trace, eval, event, cohort, action, person. Use the object's id (insights: the short id; feature flags: the numeric id, falling back to the key; persons: the uuid). It renders as a chip with a live hover preview that opens the object in PostHog.+- Inline reference: \`<kind id="...">short human label</kind>\` inside a sentence, e.g. \`The <insight id="9pQx3">checkout funnel</insight> dropped after <flag id="42">new-checkout-flow</flag> rolled out.\` Kinds: insight, dashboard, error, replay, flag, experiment, survey, ticket, report, trace, eval, event, cohort, action, person. Use the object's id (insights: the short id; feature flags: the numeric id, falling back to the key; Inbox reports: the report uuid; persons: the uuid). It renders as a chip with a live hover preview that opens the object in PostHog.- Inline SQL: \`<hogql label="signups today">SELECT count() FROM events WHERE ...</hogql>\` - the SQL is the tag body, the label is what the sentence shows. Hovering runs the query live; clicking opens the SQL editor.- Full-size chart, for any numeric or time-series answer (always prefer this over a markdown table): a saved insight \`<insight id="9pQx3" display="block"/>\` or a query \`<hogql display="block" title="Daily active users, last 7 days" caption="optional context">SELECT ...</hogql>\`. The chart executes live on every view. Include the time range in the title, and keep blank lines out of the SQL body.- Recording card: \`<replay id="<session_id>" display="block"/>\` renders the recording's details with a link into PostHog's player. Use it when a specific session is the evidence.`;diff --git a/products/desktop/packages/ui/src/features/sessions/sessionServiceHost.test.ts b/products/desktop/packages/ui/src/features/sessions/sessionServiceHost.test.tsindex 9020185153ab..32da32904e96 100644--- a/products/desktop/packages/ui/src/features/sessions/sessionServiceHost.test.ts+++ b/products/desktop/packages/ui/src/features/sessions/sessionServiceHost.test.ts@@ -3070,7 +3070,7 @@ describe("SessionService", () => {sessionUpdate: "agent_message_chunk",content: {type: "text",- text: '<insight id="9pQx3">Checkout funnel</insight>',+ text: '<insight id="9pQx3">Checkout funnel</insight> <report id="rep-1">Latency regression</report>',},},},@@ -3106,6 +3106,12 @@ describe("SessionService", () => {object_id: "9pQx3",source_message_id: "turn-1700000000",},+ {+ name: "Latency regression",+ object_kind: "report",+ object_id: "rep-1",+ source_message_id: "turn-1700000000",+ },]);});});diff --git a/products/desktop/packages/ui/src/utils/evidenceLinks.test.ts b/products/desktop/packages/ui/src/utils/evidenceLinks.test.tsindex d7b9efe8334e..f671bc7498da 100644--- a/products/desktop/packages/ui/src/utils/evidenceLinks.test.ts+++ b/products/desktop/packages/ui/src/utils/evidenceLinks.test.ts@@ -41,6 +41,7 @@ describe("evidenceLinks", () => {["experiment", "7", "/experiments/7"],["survey", "srv-11", "/surveys/srv-11"],["ticket", "conv_88", "/support/tickets/conv_88"],+ ["report", "rep_1", "/inbox/rep_1"],["trace", "t_9f2ab4", "/ai-observability/traces/t_9f2ab4"],["eval", "ev_faith", "/ai-evals/evaluations/ev_faith"],["cohort", "31", "/cohorts/31"],diff --git a/products/desktop/packages/ui/src/utils/objectKinds.ts b/products/desktop/packages/ui/src/utils/objectKinds.tsindex 56ee068f33c0..99799fd9eb2d 100644--- a/products/desktop/packages/ui/src/utils/objectKinds.ts+++ b/products/desktop/packages/ui/src/utils/objectKinds.ts@@ -14,6 +14,7 @@ import {ShieldCheckIcon,SparkleIcon,SquaresFourIcon,+ TrayIcon,UserIcon,UsersThreeIcon,} from "@phosphor-icons/react";@@ -113,6 +114,12 @@ const OBJECT_KINDS: Record<string, ObjectKindDef> = {source: "Conversations",webPath: (id) => `/support/tickets/${id}`,},+ report: {+ icon: TrayIcon,+ kindLabel: "Inbox report",+ source: "Inbox",+ webPath: (id) => `/inbox/${id}`,+ },trace: {icon: SparkleIcon,kindLabel: "LLM trace",