Skip to content

feat(inbox): render report charts in the detail view - #3979

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/inbox-report-charts
Draft

feat(inbox): render report charts in the detail view#3979
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/inbox-report-charts

Conversation

@posthog

@posthog posthog Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Problem

Reports can carry charts, and a report summary places one inline where it writes a [label](chart:<id>) link. The desktop client discarded the charts field entirely, so a chart-backed report rendered the link label as dead text and the chart evidence never appeared at all — it was only visible on web.

Why: raised from a Self-driving inbox parity report — desktop was silently dropping evidence that reports had gone to the trouble of drawing.

Changes

  • Contract (@posthog/shared): ReportChart + charts on SignalReport, with the backend's id/title/caption limits.
  • Trust boundary (@posthog/api-client): report reads normalize charts. A chart's query gets POSTed to /api/projects/:id/query/ to draw it, so a chart with a missing/malformed id, a query kind we don't render, or an executable node (HogQuery, bytecode, …) nested anywhere inside it is dropped before it can reach the endpoint. Malformed entries drop individually — one bad chart doesn't cost the report its other charts. Adds runInsightQuery beside the existing runHogQLQuery.
  • Layout (@posthog/core): layoutReportSummary splits a summary into prose and the charts it places, so a chart renders as a block instead of being nested inside a <p>. Only a paragraph consisting solely of chart references places charts; a reference in a sentence, list item, table cell, or code fence stays as its label text, as on web.
  • Renderer (@posthog/ui): a read-only chart card in the report detail view. Charts the summary never references render after the prose.

Desktop has a charting library but no insight-visualization stack, so it draws what maps cleanly onto it — trends line/bar, BoldNumber, SQL result grids — and for anything else (funnels, retention, paths, saved insights, world maps) keeps the title and caption and offers the report in PostHog. Unsupported and failed charts degrade visibly rather than disappearing.

Reports with no charts render exactly as before.

How did you test this?

  • pnpm typecheck — clean across all 24 packages.
  • pnpm --filter @posthog/shared --filter @posthog/api-client --filter @posthog/core --filter @posthog/ui test — 6,185 passing, including 56 new tests over the layout pass, query-shape planning, response shaping, and the chart-normalization gate (id/title validation, unrenderable kinds, nested executable nodes, per-entry drops, duplicate ids, the list cap).
  • biome check clean; zero noRestrictedImports in core; check-host-boundaries.mjs reports no new violations.
  • Not verified in the running app. I couldn't drive the Electron app in this environment, and I had no report carrying a non-empty charts array to render against — the drawing itself is unexercised against live data and wants a look before this leaves draft.

Mobile is untouched; @posthog/quill-charts is canvas-based and won't run on React Native, so that treatment needs its own change. The shared contract this adds is what it would build on.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code from an inbox report

Reports can carry charts, and the summary places one where it writes a
`[label](chart:<id>)` link. The desktop client dropped the field entirely, so
readers saw the link label as dead text and lost the chart-based evidence.

Adds the `charts` contract to `SignalReport`, a portable summary/chart layout
pass in core, and a read-only chart renderer in the inbox detail view.

Desktop has a charting library but no insight-visualization stack, so it draws
the query shapes that map onto it — trends line/bar, BoldNumber, SQL result
grids — and for the rest keeps the chart's title, caption, and a link to the
report in PostHog rather than dropping the evidence silently.

Chart queries are executed against `/query/`, so normalization is a trust
boundary: a chart with no id, an unrenderable query kind, or an executable node
nested in its query is dropped before it can reach the endpoint.

Generated-By: PostHog Code
Task-Id: c766bf25-1e2c-4eda-af9c-b111b3c15064
@trunk-io

trunk-io Bot commented Jul 29, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

Copy link
Copy Markdown

React Doctor found 2 issues in 2 files · 2 warnings.

2 warnings

src/features/inbox/components/detail/ReportChart.tsx

src/features/inbox/components/utils/SignalReportSummaryMarkdown.tsx

Reviewed by React Doctor for commit 1b71f14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants