: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
feat: Add live widget platform (#70803)
Jordan Mryyanc89f32e720b2
diff --git a/.agents/skills/manage-dashboard-widgets/SKILL.md b/.agents/skills/manage-dashboard-widgets/SKILL.mdindex 717611ad04a3..414ba3c81742 100644--- a/.agents/skills/manage-dashboard-widgets/SKILL.md+++ b/.agents/skills/manage-dashboard-widgets/SKILL.md@@ -46,6 +46,8 @@ Shipped types (code truth): [architecture.md § Shipped types](references/architAfter spec confirmation → [checklist-new-widget-type.md](references/checklist-new-widget-type.md) **§1 → §8**. §5b (dedicated stories — required before the PR, not a follow-up) is sequenced once MVP tests are green.+Self-updating / real-time tile? Read [live-widgets.md](references/live-widgets.md) first — the live contract (`is_live`, `creation_flag`, `generatedAt` seeds) and the `widgets/live/` toolkit.+## 3. Update a shipped type**Skip intake.** Identify the type from the request or `EXPECTED_WIDGET_TYPES` in `widget_registry.py`.@@ -104,17 +106,18 @@ hogli test products/dashboards/backend/api/test/test_widget_openapi_enums.py ### Reference appendix-| Topic | Doc |-| -------------------------- | --------------------------------------------------------------------------------- |-| Intake (new types only) | [widget-intake.md](references/widget-intake.md) — canonical defaults + spec recap |-| New type checklist | [checklist-new-widget-type.md](references/checklist-new-widget-type.md) |-| Update shipped type | [managing-existing-widgets.md](references/managing-existing-widgets.md) |-| Architecture | [architecture.md](references/architecture.md) — file map, invariants |-| Config + codegen | [config-and-codegen.md](references/config-and-codegen.md) |-| WidgetCard / edit modal | [composition.md](references/composition.md) |-| List footer / tile filters | [list-widget-patterns.md](references/list-widget-patterns.md) |-| Tile min/max | [layout-and-ux.md](references/layout-and-ux.md) |-| RBAC / sharing | [permissions-and-sharing.md](references/permissions-and-sharing.md) |-| Setup gates | [availability-and-gating.md](references/availability-and-gating.md) |-| MCP after ship | [mcp.md](references/mcp.md) |-| Skill doc maintenance | [skill-maintenance.md](references/skill-maintenance.md) |+| Topic | Doc |+| -------------------------- | ---------------------------------------------------------------------------------- |+| Intake (new types only) | [widget-intake.md](references/widget-intake.md) — canonical defaults + spec recap |+| New type checklist | [checklist-new-widget-type.md](references/checklist-new-widget-type.md) |+| Update shipped type | [managing-existing-widgets.md](references/managing-existing-widgets.md) |+| Architecture | [architecture.md](references/architecture.md) — file map, invariants |+| Config + codegen | [config-and-codegen.md](references/config-and-codegen.md) |+| WidgetCard / edit modal | [composition.md](references/composition.md) |+| List footer / tile filters | [list-widget-patterns.md](references/list-widget-patterns.md) |+| Live / self-updating tiles | [live-widgets.md](references/live-widgets.md) — contract + `widgets/live/` toolkit |+| Tile min/max | [layout-and-ux.md](references/layout-and-ux.md) |+| RBAC / sharing | [permissions-and-sharing.md](references/permissions-and-sharing.md) |+| Setup gates | [availability-and-gating.md](references/availability-and-gating.md) |+| MCP after ship | [mcp.md](references/mcp.md) |+| Skill doc maintenance | [skill-maintenance.md](references/skill-maintenance.md) |diff --git a/.agents/skills/manage-dashboard-widgets/references/availability-and-gating.md b/.agents/skills/manage-dashboard-widgets/references/availability-and-gating.mdindex 60d71e0b19b0..4a21d49782a0 100644--- a/.agents/skills/manage-dashboard-widgets/references/availability-and-gating.md+++ b/.agents/skills/manage-dashboard-widgets/references/availability-and-gating.md@@ -2,6 +2,8 @@Project setup prerequisites (exception autocapture, session recording ingestion, etc.) — **not** RBAC. Product access (`productAccess`) is separate: it gates who can see widget data via `run_widgets` and locked tiles; availability gates whether the project is configured to produce data.+Also separate: **release gating**. The picker renders the hand-written FE catalog (`widget_types/catalog.ts`), so an unreleased widget group stays out of the picker by landing its catalog entries with the release; the backend creation gate is **`creation_flag`** on the `WidgetSpec` (resolved generically in `widget_create.py` via `widget_flag_enabled`), which also protects against direct API/MCP creation. That is a rollout kill-switch, not availability: already-placed tiles keep rendering when the flag turns off. There is no FE flag map for picker entries — if a family needs the picker card itself flag-gated (entry shipped but hidden), that mechanism doesn't exist yet and the catalog response would need to expose the resolved gate. The render-time rules below apply to availability only.+## Product rule: gate at render, never at addUsers **always** pick and add widgets in `AddWidgetModal` — no filtering, disabling, or hiding catalog entries based on availability.diff --git a/.agents/skills/manage-dashboard-widgets/references/checklist-new-widget-type.md b/.agents/skills/manage-dashboard-widgets/references/checklist-new-widget-type.mdindex ccc22994bea0..7b7b4f60aa5c 100644--- a/.agents/skills/manage-dashboard-widgets/references/checklist-new-widget-type.md+++ b/.agents/skills/manage-dashboard-widgets/references/checklist-new-widget-type.md@@ -15,6 +15,7 @@ Files: `products/dashboards/backend/widget_specs/` + `widgets/<widget_type>.py`- [ ] **`widget_specs/configs.py`** — new `*WidgetConfig` Pydantic model + `*_WIDGET_TYPE` constant; extend shared fields via `common.py` when appropriate- [ ] **`widgets/<widget_type>.py`** — `run_<type>_widget` calling `validate_widget_config(TYPE, config)` then the **same** product query runner (no parallel query path); pass `resolve_filter_test_accounts(config, team)` when supported- [ ] **`widget_specs/registry.py`** — add one `WidgetSpec` to `_load_widget_specs()` (lazy-import `run_*`): `config_model`, scopes, `group_id`/`group_label`/`label`/`description`, `required_product_access`, `product_access_denied_message`, `availability_requirements`+- [ ] **Live / self-updating tile?** Set `is_live=True` (+ usually `creation_flag`), return `generatedAt` from the seed query, and keep `dateRange`/`filterTestAccounts` off the config model — full contract in [live-widgets.md](live-widgets.md)- [ ] `EXPECTED_WIDGET_TYPES`, OpenAPI polymorphic serializers, and Zod codegen inputs update automatically from `WIDGET_SPECS` + `configs.py` — enforced in `test_run_widgets.py`- [ ] Use `DEFAULT_WIDGET_LIST_LIMIT` from `backend/constants.py` unless this type needs a different default- [ ] List widgets with `orderDirection`: use `WidgetOrderDirection` literal in Pydantic (`ASC` / `DESC`)@@ -112,6 +113,7 @@ Directory: `products/dashboards/frontend/widgets/<product>/` (snake_case product- [ ] Use `WidgetCardContent` for scrollable lists/tables; `WidgetCardBodyMessage` for empty states- [ ] **Adoption CTA on the "no entities yet" empty state** — when the product has nothing to show yet (no surveys, no experiments), render a primary `LemonButton` (`targetBlank`) to the product's create flow and fire `posthog.capture('dashboard widget create <product> clicked', { widget_type, tile_id })` on click. Measures adoption driven _from_ the widget, distinct from the platform `dashboard widget added` event. See [§ Product-adoption tracking](#product-adoption-tracking).- [ ] **List widgets:** follow [list-widget-patterns.md](list-widget-patterns.md) — `hasMore`, footer, tile filter bar, `titleHref`+- [ ] **Live widgets:** compose the `widgets/live/` toolkit (`liveWidgetStream`, `LiveWidgetSlidingWindow`, `useLiveWidgetSeed`, `LiveWidgetEmptyState`) — recipe in [live-widgets.md](live-widgets.md)- [ ] Do **not** render card chrome — `DashboardWidgetItem` + catalog handle headers/menusMinimal skeleton:diff --git a/.agents/skills/manage-dashboard-widgets/references/live-widgets.md b/.agents/skills/manage-dashboard-widgets/references/live-widgets.mdnew file mode 100644index 000000000000..f4c4b92bc74b--- /dev/null+++ b/.agents/skills/manage-dashboard-widgets/references/live-widgets.md@@ -0,0 +1,63 @@+# Live widgets (self-updating tiles)++A **live** widget seeds once from `run_widgets`, then self-updates client-side — it does not rely on the dashboard refresh loop for freshness.+This doc is the paved path for building one.+Examples below reference web analytics live widgets, the first consumer of the platform — they show how it is meant to be used rather than code the platform itself ships.++## The contract++Backend SSOT is two `WidgetSpec` fields in `widget_specs/registry.py`:++- **`is_live: bool`** — marks the type as live. Flows into `widget-form-fields.json` (via `hogli build:widget-types`), resolved onto the FE catalog as `entry.live` (read it there, or via `isLiveDashboardWidgetType()` where no entry is at hand); also exposed as `live` on the REST/MCP widget catalog. Do not hand-maintain FE live-type lists.+- **`creation_flag: str | None`** — adds-only rollout gate, resolved generically in `widget_create.py` via `feature_flags.widget_flag_enabled`. Creating a tile requires the flag; already-placed tiles keep rendering when it's off. Not live-specific — any spec may set it — but new live widget families should, as their kill switch.++What `is_live` buys for free: a pulsing "Live" marker in the tile header (`WidgetCardHeader`), a "Live" tag on the Add-widget picker card, and the `live` field agents see in `dashboard-widget-catalog-list`.++Rules a live type must follow (`WidgetSpec` enforces rule 3 at construction — a violating spec fails on any import of the registry, so tests, codegen, and web all catch it; rules 1-2 are conventions, with the merge behavior guarded by `LiveWidgetSlidingWindow.test.ts`):++1. **The `run_widgets` result is a seed, not the state.** Its payload must carry `generatedAt` — the server clock at query time (ISO-8601). See `LiveWidgetSeedPayload` in `widgets/live/liveWidgetTypes.ts`.+2. **Seeds must be idempotent.** Manual tile refresh and dashboard auto-refresh re-run `run_widgets` and re-seed; the platform does **not** skip live tiles (a re-seed heals stream gaps from dropped connections or hidden tabs). Merge seeds so a re-run never double counts — see the sliding-window semantics below.+3. **No `dateRange` or `filterTestAccounts` config.** Live tiles show a fixed real-time window (dateRange contradicts it), and the livestream can't apply test-account filters, so seed and stream would disagree. The header's date range hides automatically for live types (catalog resolution defaults `showDateRange` to false when `live`).++## Backend conventions++The seed query is ordinary product code — a `query_fn` in `products/dashboards/backend/widgets/<type>.py` delegating to the product's query module (the WA seeds will live in a dedicated module such as `products/web_analytics/backend/hogql_queries/live_widget_seeds.py`, named apart from the /web/live page's own client-side seed queries).+Conventions:++- Return `generatedAt` (`datetime.now(UTC).isoformat()` at query time) in every payload.+- Accept and ignore `include_total_count` — it's part of the generic `query_fn` calling convention.+- Keep the window length a constant in product code, mirrored by a FE constant (e.g. a 30-minute window on both sides), and cap payload size — the seed rides the batched `run_widgets` response.++## Frontend toolkit — `products/dashboards/frontend/widgets/live/`++Compose these; don't re-wire SSE/flush/tick by hand:++| Module | What it does |+| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| `liveWidgetTypes.ts` — `isLiveDashboardWidgetType()`, `LiveWidgetSeedPayload` | FE read of `WidgetSpec.is_live` from the generated manifest, plus the base seed-payload interface (`generatedAt`) — extend it in your result types |+| `LiveWidgetSlidingWindow` | Minute-bucketed window: overall count + named breakdown domains, each fed by an extractor `(event) => string \| null` (null = skip). Encodes the seed-merge correctness rules — see below |+| `liveWidgetStream(options)` | Kea logic builder: livestream SSE connection (`/events`, `live_events_token`), flush-batched `onEvents` (300ms), 60s `onMinuteTick`, all via `cache.disposables` (pauses on hidden tabs) |+| `useLiveWidgetSeed(payload, seed)` | The one prop→action React bridge: seeds your logic from the tile's `result` prop (pass `null` while the payload isn't ready) |+| `components.tsx` — `LiveWidgetEmptyState` | "No data in the window yet" body with optional CTA |+| `components.tsx` — `LiveWidgetIndicator` | The pulsing "Live" header marker (platform-rendered — you don't wire this) |++**Seed-merge semantics (do not "simplify" these):** the SSE stream reads Kafka (fresh) while seeds read ClickHouse (can lag ingestion). `LiveWidgetSlidingWindow` therefore merges seeds via per-bucket `max` (never replace — an empty lagging re-seed must not wipe stream-accumulated counts) and drops streamed events at or before the domain's seed `generatedAt` (strict `>`), so a re-seed never double counts. `widgets/live/LiveWidgetSlidingWindow.test.ts` guards these.++**kea-typegen constraint:** `liveWidgetStream` only adds `connect`/`events` wiring — typegen cannot see builder-injected symbols, so your logic declares its own actions/reducers/selectors and the builder dispatches into them via `onEvents`/`onMinuteTick` callbacks.++**One connection per dashboard:** make the product's live logic unkeyed and share it across the family's tiles — kea ref-counting keeps one SSE connection no matter how many live tiles are placed, and tears it down when the last unmounts. Reset state in `afterMount` so data can't leak across dashboards.++**Transports:** the shipped helper is livestream SSE. The contract is transport-agnostic — a polling helper with the same `onEvents`/`onMinuteTick` shape could be added for products without livestream data, with no contract changes.++## Recipe: shipping a new live widget family++On top of the normal [new-type checklist](checklist-new-widget-type.md):++1. Spec: `is_live=True`, `creation_flag="<your-rollout-flag>"`, no `dateRange`/`filterTestAccounts` on the config model (enforced at spec construction).+2. Seed query in your product's backend returning `generatedAt`; thin `query_fn` wrapper in `widgets/<type>.py`.+3. Catalog entry as normal — `showDateRange` hides automatically for live types. To keep the picker card hidden pre-release, land the FE catalog entry with the release; `creation_flag` is the backend gate either way ([availability-and-gating.md](availability-and-gating.md)).+4. One unkeyed shared logic on `liveWidgetStream` + `LiveWidgetSlidingWindow` (or your own windowing if minute buckets don't fit — keep the idempotent-seed rule).+5. Components: `useLiveWidgetSeed(payload, seedAction)`, render from selectors, `LiveWidgetEmptyState` when the window is empty.+6. `hogli build:widget-types` (regenerates the manifest the FE catalog reads `live` from), then the normal verify suite.++Web analytics live widgets (`products/dashboards/frontend/widgets/web_analytics/`) are the first consumer to follow this recipe end to end.diff --git a/.agents/skills/manage-dashboard-widgets/references/managing-existing-widgets.md b/.agents/skills/manage-dashboard-widgets/references/managing-existing-widgets.mdindex 788215794a54..93eaf8cca298 100644--- a/.agents/skills/manage-dashboard-widgets/references/managing-existing-widgets.md+++ b/.agents/skills/manage-dashboard-widgets/references/managing-existing-widgets.md@@ -28,6 +28,7 @@ Before finishing, apply [skill-maintenance.md](skill-maintenance.md) for any doc| **Min/max resize** on dashboard grid | `catalog.ts` `defaultLayout.minW` / `.minH` | [layout-and-ux.md](layout-and-ux.md) § Tile min/max size — **`tileLayouts.ts`**, `tileLayouts.test.ts` || Card header / date range display | `catalog.ts` (`headerLayout`, `headerMeta`, `headerTitle`, `titleHref`) | `WidgetCardHeader`, stories || Setup / availability gate | `catalog.ts` `availability`, `widgetAvailability.ts` | `WidgetRuntimeAvailabilityGuard`; BE `availability_requirements` for MCP catalog |+| **Live / self-updating tile behavior** | `widgets/live/*` (toolkit), product live logic (e.g. `webAnalyticsLiveWidgetsLogic.ts`), `WidgetSpec.is_live` / `creation_flag` | [live-widgets.md](live-widgets.md) — seed contract; `hogli build:widget-types` manifest; `widgets/live/LiveWidgetSlidingWindow.test.ts` || RBAC lock on tile | `widget_registry.py` `required_product_access`, FE `catalog.ts` `productAccess` | `types.ts`, `widgetProductAccess.ts` (`WIDGET_PRODUCT_ACCESS_CHECKS`) || Add-modal preview | `widgets/previews/` + `DASHBOARD_WIDGET_PREVIEWS` in `widget_types/catalog.ts` | Reuse demo data from `widgetOverviewStoryFixtures.ts` when possible || Public/shared placeholder copy | `catalog.ts` **`sharedPlaceholder`** | `DashboardWidgetItem.test.tsx` public placement; `test_sharing.py` |diff --git a/bin/build-dashboard-widget-types.py b/bin/build-dashboard-widget-types.pyindex 840facdc6475..d90e74493acb 100755--- a/bin/build-dashboard-widget-types.py+++ b/bin/build-dashboard-widget-types.py@@ -108,6 +108,7 @@ def main() -> int:"configTypeExport": _friendly_config_type_export(config_model_name),"formSchemaExport": config_schema_export.replace("ConfigSchema", "FormSchema"),"formFields": list(spec.form_fields),+ "live": spec.is_live,}FORM_FIELDS_JSON.write_text(json.dumps({"widgets": form_fields_manifest}, indent=2) + "\n", encoding="utf-8")diff --git a/frontend/src/scenes/web-analytics/LiveMetricsDashboard/createStreamConnection.test.ts b/frontend/src/lib/api-stream.test.tssimilarity index 95%rename from frontend/src/scenes/web-analytics/LiveMetricsDashboard/createStreamConnection.test.tsrename to frontend/src/lib/api-stream.test.tsindex ca7c00f57787..193960ddada1 100644--- a/frontend/src/scenes/web-analytics/LiveMetricsDashboard/createStreamConnection.test.ts+++ b/frontend/src/lib/api-stream.test.ts@@ -1,6 +1,6 @@import api from 'lib/api'-import { createStreamConnection } from './createStreamConnection'+import { createStreamConnection } from './api-stream'describe('createStreamConnection', () => {beforeEach(() => {diff --git a/frontend/src/scenes/web-analytics/LiveMetricsDashboard/createStreamConnection.ts b/frontend/src/lib/api-stream.tssimilarity index 86%rename from frontend/src/scenes/web-analytics/LiveMetricsDashboard/createStreamConnection.tsrename to frontend/src/lib/api-stream.tsindex 602494ba8aba..bc9f11026cf7 100644--- a/frontend/src/scenes/web-analytics/LiveMetricsDashboard/createStreamConnection.ts+++ b/frontend/src/lib/api-stream.ts@@ -14,6 +14,13 @@ export interface StreamConnection {abort: () => void}+/**+ * Long-lived SSE connection over `api.stream` with automatic reconnection.+ *+ * On error, reconnects with exponential backoff (1s doubling up to 30s); any successful message+ * resets the backoff. `abort()` tears down the in-flight request and any pending retry.+ * Transport-agnostic on the consumer side: callers only see `onMessage(data)` strings.+ */export const createStreamConnection = (config: StreamConnectionConfig): StreamConnection => {const { url, token, onMessage, onError } = configdiff --git a/frontend/src/lib/components/Cards/CardTopHeadingRow.tsx b/frontend/src/lib/components/Cards/CardTopHeadingRow.tsxindex 524a6191ba39..29763e30dc89 100644--- a/frontend/src/lib/components/Cards/CardTopHeadingRow.tsx+++ b/frontend/src/lib/components/Cards/CardTopHeadingRow.tsx@@ -6,6 +6,7 @@ export function CardTopHeadingRow({showTypeLabel = true,dateText,dateTooltip,+ separateChildren = false,children,}: {typeLabel?: string | null@@ -13,14 +14,18 @@ export function CardTopHeadingRow({showTypeLabel?: booleandateText?: string | nulldateTooltip?: string | null+ /** Render a • before children when a label/date precedes; leave off for inline adornments (e.g. the freshness clock). */+ separateChildren?: booleanchildren?: React.ReactNode}): JSX.Element {+ const showLabelSegment = Boolean(showTypeLabel && typeLabel)+return (<div className="flex items-center gap-1">- {showTypeLabel && typeLabel ? <span title={typeTitle ?? typeLabel}>{typeLabel}</span> : null}+ {showLabelSegment ? <span title={typeTitle ?? typeLabel ?? undefined}>{typeLabel}</span> : null}{dateText ? (<>- {showTypeLabel && typeLabel ? <span>•</span> : null}+ {showLabelSegment ? <span>•</span> : null}{dateTooltip ? (<Tooltip title={dateTooltip}><span className="whitespace-nowrap">{dateText}</span>@@ -30,7 +35,12 @@ export function CardTopHeadingRow({)}</>) : null}- {children}+ {children ? (+ <>+ {separateChildren && (showLabelSegment || dateText) ? <span>•</span> : null}+ {children}+ </>+ ) : null}</div>)}diff --git a/frontend/src/scenes/web-analytics/LiveMetricsDashboard/liveWebAnalyticsMetricsLogic.tsx b/frontend/src/scenes/web-analytics/LiveMetricsDashboard/liveWebAnalyticsMetricsLogic.tsxindex a2813174662f..c5cc608bda74 100644--- a/frontend/src/scenes/web-analytics/LiveMetricsDashboard/liveWebAnalyticsMetricsLogic.tsx+++ b/frontend/src/scenes/web-analytics/LiveMetricsDashboard/liveWebAnalyticsMetricsLogic.tsx@@ -4,6 +4,7 @@ import { subscriptions } from 'kea-subscriptions'import { lemonToast } from '@posthog/lemon-ui'+import { createStreamConnection } from 'lib/api-stream'import { FEATURE_FLAGS } from 'lib/constants'import { dayjs } from 'lib/dayjs'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'@@ -34,7 +35,6 @@ import { AnyPropertyFilter, BaseMathType, LiveEvent, PropertyOperator } from '~/import type { FeatureFlagsSet } from '../../../lib/logic/featureFlagLogic'import type { TeamPublicType, TeamType } from '../../../types'-import { createStreamConnection } from './createStreamConnection'import { LiveMetricsSlidingWindow } from './LiveMetricsSlidingWindow'import {BOT_ELIGIBLE_EVENTS,diff --git a/products/dashboards/CONTRIBUTING.md b/products/dashboards/CONTRIBUTING.mdindex 856787a60ecf..e7ec6b03faed 100644--- a/products/dashboards/CONTRIBUTING.md+++ b/products/dashboards/CONTRIBUTING.md@@ -24,17 +24,18 @@ Layer table, registry shapes, copy/move, analytics, and typing details: [`.agent**Canonical guide:** [`.agents/skills/manage-dashboard-widgets/`](../../.agents/skills/manage-dashboard-widgets/) (`/manage-dashboard-widgets` — ship new types or update shipped types; intake only for new types).-| Task | Doc |-| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |-| Add a new widget type | [`SKILL.md` §2 Ship](../../.agents/skills/manage-dashboard-widgets/SKILL.md#2-ship-a-new-widget_type) → intake, then checklist |-| First widget in a new product area | Same — checklist §4c |-| Update an existing widget type | [`SKILL.md` §3 Update](../../.agents/skills/manage-dashboard-widgets/SKILL.md#3-update-a-shipped-type) → managing-existing-widgets |-| Tile min/max size on dashboard grid | [`references/layout-and-ux.md`](../../.agents/skills/manage-dashboard-widgets/references/layout-and-ux.md) (§ Tile min/max size) |-| WidgetCard, loading, headers | [`references/composition.md`](../../.agents/skills/manage-dashboard-widgets/references/composition.md) |-| RBAC, copy/move, shared dashboards | [`references/permissions-and-sharing.md`](../../.agents/skills/manage-dashboard-widgets/references/permissions-and-sharing.md) |-| Architecture, naming, scaling rules | [`references/architecture.md`](../../.agents/skills/manage-dashboard-widgets/references/architecture.md) |-| MCP / REST | [`references/mcp.md`](../../.agents/skills/manage-dashboard-widgets/references/mcp.md) |-| Keep skill docs in sync | [`references/skill-maintenance.md`](../../.agents/skills/manage-dashboard-widgets/references/skill-maintenance.md) |+| Task | Doc |+| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |+| Add a new widget type | [`SKILL.md` §2 Ship](../../.agents/skills/manage-dashboard-widgets/SKILL.md#2-ship-a-new-widget_type) → intake, then checklist |+| First widget in a new product area | Same — checklist §4c |+| Update an existing widget type | [`SKILL.md` §3 Update](../../.agents/skills/manage-dashboard-widgets/SKILL.md#3-update-a-shipped-type) → managing-existing-widgets |+| Live / self-updating widget | [`references/live-widgets.md`](../../.agents/skills/manage-dashboard-widgets/references/live-widgets.md) → `frontend/widgets/live/` toolkit |+| Tile min/max size on dashboard grid | [`references/layout-and-ux.md`](../../.agents/skills/manage-dashboard-widgets/references/layout-and-ux.md) (§ Tile min/max size) |+| WidgetCard, loading, headers | [`references/composition.md`](../../.agents/skills/manage-dashboard-widgets/references/composition.md) |+| RBAC, copy/move, shared dashboards | [`references/permissions-and-sharing.md`](../../.agents/skills/manage-dashboard-widgets/references/permissions-and-sharing.md) |+| Architecture, naming, scaling rules | [`references/architecture.md`](../../.agents/skills/manage-dashboard-widgets/references/architecture.md) |+| MCP / REST | [`references/mcp.md`](../../.agents/skills/manage-dashboard-widgets/references/mcp.md) |+| Keep skill docs in sync | [`references/skill-maintenance.md`](../../.agents/skills/manage-dashboard-widgets/references/skill-maintenance.md) |**Critical rules:**diff --git a/products/dashboards/backend/feature_flags.py b/products/dashboards/backend/feature_flags.pyindex a189e89c36d8..72fd6985ca11 100644--- a/products/dashboards/backend/feature_flags.py+++ b/products/dashboards/backend/feature_flags.py@@ -13,9 +13,9 @@ if TYPE_CHECKING:DASHBOARD_WIDGETS_FLAG = "dashboard-widgets"-def dashboard_widgets_enabled(*, team: Team, user: User | None = None) -> bool:+def widget_flag_enabled(flag: str, *, team: Team, user: User | None = None) -> bool:"""Match in-app flag evaluation: user distinct_id plus project/org groups."""- if DASHBOARD_WIDGETS_FLAG in _FORCE_ENABLED_FLAGS:+ if flag in _FORCE_ENABLED_FLAGS:return Truedistinct_id = (user.distinct_id or str(user.uuid)) if user is not None else str(team.uuid)@@ -24,7 +24,7 @@ def dashboard_widgets_enabled(*, team: Team, user: User | None = None) -> bool:return bool(posthoganalytics.feature_enabled(- DASHBOARD_WIDGETS_FLAG,+ flag,distinct_id,groups={"organization": organization_id, "project": project_id},group_properties={"organization": {"id": organization_id}, "project": {"id": project_id}},@@ -32,3 +32,7 @@ def dashboard_widgets_enabled(*, team: Team, user: User | None = None) -> bool:send_feature_flag_events=False,))+++def dashboard_widgets_enabled(*, team: Team, user: User | None = None) -> bool:+ return widget_flag_enabled(DASHBOARD_WIDGETS_FLAG, team=team, user=user)diff --git a/products/dashboards/backend/widget_catalog.py b/products/dashboards/backend/widget_catalog.pyindex a6e7d07c0c14..6fdeb9a2b8f4 100644--- a/products/dashboards/backend/widget_catalog.py+++ b/products/dashboards/backend/widget_catalog.py@@ -15,6 +15,7 @@ class WidgetCatalogEntry(TypedDict):required_product_access: str | Noneproduct_access_denied_message: NotRequired[str | None]availability_requirements: list[str]+ live: booldef _build_catalog_entry(widget_type: str) -> WidgetCatalogEntry:@@ -29,6 +30,7 @@ def _build_catalog_entry(widget_type: str) -> WidgetCatalogEntry:"required_product_access": spec.required_product_access,"product_access_denied_message": spec.product_access_denied_message,"availability_requirements": list(spec.availability_requirements),+ "live": spec.is_live,}diff --git a/products/dashboards/backend/widget_create.py b/products/dashboards/backend/widget_create.pyindex 9dc02a446a52..199f95e70fb5 100644--- a/products/dashboards/backend/widget_create.py+++ b/products/dashboards/backend/widget_create.py@@ -8,10 +8,11 @@ from posthog.models.team import Teamfrom posthog.models.user import Userfrom posthog.rbac.user_access_control import UserAccessControl-from products.dashboards.backend.feature_flags import dashboard_widgets_enabled+from products.dashboards.backend.feature_flags import dashboard_widgets_enabled, widget_flag_enabledfrom products.dashboards.backend.models.dashboard_widget import DashboardWidgetfrom products.dashboards.backend.widget_access import check_widget_tile_product_access-from products.dashboards.backend.widget_registry import get_widget_registry_entry, validate_widget_config+from products.dashboards.backend.widget_registry import validate_widget_config+from products.dashboards.backend.widget_specs.registry import get_widget_specdef prepare_widget_tile_create(@@ -25,9 +26,14 @@ def prepare_widget_tile_create(if not dashboard_widgets_enabled(team=team, user=user):raise serializers.ValidationError({"widget": "Dashboard widgets are not enabled for this project."})- if get_widget_registry_entry(widget_type) is None:+ spec = get_widget_spec(widget_type)+ if spec is None:raise serializers.ValidationError({"widget_type": f"Unknown widget type: {widget_type}"})+ # Adds-only kill switch (already-placed tiles keep rendering when the flag is off).+ if spec.creation_flag and not widget_flag_enabled(spec.creation_flag, team=team, user=user):+ raise serializers.ValidationError({"widget_type": f"{spec.label} widgets are not enabled for this project."})+if not isinstance(config, dict):raise serializers.ValidationError({"config": "Config must be an object."})diff --git a/products/dashboards/backend/widget_specs/openapi.py b/products/dashboards/backend/widget_specs/openapi.pyindex 6824a6c17f39..67983e923080 100644--- a/products/dashboards/backend/widget_specs/openapi.py+++ b/products/dashboards/backend/widget_specs/openapi.py@@ -117,6 +117,13 @@ def _build_openapi_serializers() -> tuple[),),"required_product_access": serializers.CharField(required=False, allow_null=True),+ "live": serializers.BooleanField(+ help_text=(+ "Whether tiles of this type self-update in real time after load. Live tiles show a "+ "fixed real-time window and cannot apply test-account filtering to the stream, so "+ "their config takes neither dateRange nor filterTestAccounts."+ ),+ ),},)diff --git a/products/dashboards/backend/widget_specs/registry.py b/products/dashboards/backend/widget_specs/registry.pyindex a5505a1d53a6..aa8ac806ea47 100644--- a/products/dashboards/backend/widget_specs/registry.py+++ b/products/dashboards/backend/widget_specs/registry.py@@ -66,7 +66,26 @@ class WidgetSpec:# "dashboard widget filters updated" analytics event. Filters stored under a single `widgetFilters`# record list that key; widgets that keep filters as top-level config keys (e.g. experiments) list each.filter_fields: tuple[str, ...]+ # Live widgets: the run_widgets result is a one-shot SEED (its payload must carry a `generatedAt`+ # ISO-8601 server timestamp) and the tile self-updates client-side afterwards. Any re-run — manual+ # refresh or dashboard auto-refresh — re-seeds, so seed merges must be idempotent. Live widgets+ # show a fixed real-time window and must not offer `dateRange`/`filterTestAccounts` config.+ is_live: bool = False+ # Adds-only rollout gate: creating a tile of this type requires this feature flag (resolved via+ # feature_flags.widget_flag_enabled in widget_create). Existing tiles keep rendering when it's off.+ creation_flag: str | None = None+ def __post_init__(self) -> None:+ if self.is_live:+ forbidden = [field for field in _LIVE_FORBIDDEN_CONFIG_FIELDS if field in self.config_model.model_fields]+ if forbidden:+ raise ValueError(+ f"{self.widget_type}: live widgets show a fixed real-time window and the stream cannot "+ f"apply test-account filters; remove {', '.join(forbidden)} from {self.config_model.__name__}"+ )+++_LIVE_FORBIDDEN_CONFIG_FIELDS = ("dateRange", "filterTestAccounts")# Status filters use this sentinel for "no status filter applied" — it must not count as an active filter._STATUS_ANY_SENTINEL = "all"diff --git a/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.tsx b/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.tsxindex 39453600975a..b53fd042a4c8 100644--- a/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.tsx+++ b/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.tsx@@ -229,6 +229,7 @@ function DashboardWidgetItemContent({description={description}showDescription={showDescription}loading={loading}+ isLive={headerCatalogEntry.live}showEditingControls={showEditingControls}isDashboardEditMode={isDashboardEditMode}shouldHideMoreButton={widgetCardShouldHideMoreButton(placement, showEditingControls)}diff --git a/products/dashboards/frontend/components/WidgetCard/WidgetCardHeader.tsx b/products/dashboards/frontend/components/WidgetCard/WidgetCardHeader.tsxindex cf94c21b29b8..8a15642d1ce9 100644--- a/products/dashboards/frontend/components/WidgetCard/WidgetCardHeader.tsx+++ b/products/dashboards/frontend/components/WidgetCard/WidgetCardHeader.tsx@@ -13,6 +13,7 @@ import { dateFilterToText } from 'lib/utils/dateFilters'import { DashboardPlacement } from '~/types'import type { DashboardWidgetHeaderLayout, DashboardWidgetHeaderMeta } from '../../widget_types/catalog'+import { LiveWidgetIndicator } from '../../widgets/live/components'import type { DashboardWidgetSlot } from '../../widgets/registry'/** Props a widget type's optional TopHeading override receives so it can compose its own@@ -40,6 +41,8 @@ export type WidgetCardHeaderProps = {description?: stringshowDescription?: booleanloading?: boolean+ /** Live (self-updating) widget type — shows a pulsing "Live" marker where the date range would go. */+ isLive?: booleanshowEditingControls?: boolean/** When true, title is plain text so drag on the header does not compete with navigation. */isDashboardEditMode?: boolean@@ -174,6 +177,7 @@ export function WidgetCardHeader({description,showDescription = true,loading,+ isLive,showEditingControls,isDashboardEditMode,shouldHideMoreButton,@@ -188,10 +192,10 @@ export function WidgetCardHeader({? widgetDateRangeToText(config?.dateRange as Record<string, unknown> | null | undefined): nullconst derivedTopHeading =- widgetTypeLabel && (showWidgetType || dateText) ? (+ widgetTypeLabel && (showWidgetType || dateText || isLive) ? (// A widget type can supply its own top heading row (e.g. session replay surfaces the active// saved filter name in place of the now-overridden date range); otherwise fall back to the- // type + date range.+ // type + date range (or the live marker — live widgets have no date range).TopHeading ? (<Suspense fallback={null}><TopHeading@@ -202,7 +206,14 @@ export function WidgetCardHeader({/></Suspense>) : (- <CardTopHeadingRow typeLabel={widgetTypeLabel} showTypeLabel={showWidgetType} dateText={dateText} />+ <CardTopHeadingRow+ typeLabel={widgetTypeLabel}+ showTypeLabel={showWidgetType}+ dateText={dateText}+ separateChildren+ >+ {isLive ? <LiveWidgetIndicator /> : null}+ </CardTopHeadingRow>)) : nullconst resolvedTopHeading = topHeading !== undefined ? topHeading : derivedTopHeadingdiff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex 83ef56dcf30c..9879c3def10e 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -9090,6 +9090,8 @@ export interface ActivityEventsListWidgetCatalogEntryOpenApiApi {readonly config_schema: ActivityEventsListWidgetConfigApi/** @nullable */required_product_access?: string | null+ /** Whether tiles of this type self-update in real time after load. Live tiles show a fixed real-time window and cannot apply test-account filtering to the stream, so their config takes neither dateRange nor filterTestAccounts. */+ live: boolean}export type ErrorTrackingListWidgetCatalogEntryOpenApiApiWidgetType =@@ -9109,6 +9111,8 @@ export interface ErrorTrackingListWidgetCatalogEntryOpenApiApi {readonly config_schema: ErrorTrackingListWidgetConfigApi/** @nullable */required_product_access?: string | null+ /** Whether tiles of this type self-update in real time after load. Live tiles show a fixed real-time window and cannot apply test-account filtering to the stream, so their config takes neither dateRange nor filterTestAccounts. */+ live: boolean}export type SessionReplayListWidgetCatalogEntryOpenApiApiWidgetType =@@ -9128,6 +9132,8 @@ export interface SessionReplayListWidgetCatalogEntryOpenApiApi {readonly config_schema: SessionReplayListWidgetConfigApi/** @nullable */required_product_access?: string | null+ /** Whether tiles of this type self-update in real time after load. Live tiles show a fixed real-time window and cannot apply test-account filtering to the stream, so their config takes neither dateRange nor filterTestAccounts. */+ live: boolean}export type ExperimentsListWidgetCatalogEntryOpenApiApiWidgetType =@@ -9147,6 +9153,8 @@ export interface ExperimentsListWidgetCatalogEntryOpenApiApi {readonly config_schema: ExperimentsListWidgetConfigApi/** @nullable */required_product_access?: string | null+ /** Whether tiles of this type self-update in real time after load. Live tiles show a fixed real-time window and cannot apply test-account filtering to the stream, so their config takes neither dateRange nor filterTestAccounts. */+ live: boolean}export type ExperimentResultsWidgetCatalogEntryOpenApiApiWidgetType =@@ -9166,6 +9174,8 @@ export interface ExperimentResultsWidgetCatalogEntryOpenApiApi {readonly config_schema: ExperimentResultsWidgetConfigApi/** @nullable */required_product_access?: string | null+ /** Whether tiles of this type self-update in real time after load. Live tiles show a fixed real-time window and cannot apply test-account filtering to the stream, so their config takes neither dateRange nor filterTestAccounts. */+ live: boolean}export type SurveyResultsWidgetCatalogEntryOpenApiApiWidgetType =@@ -9185,6 +9195,8 @@ export interface SurveyResultsWidgetCatalogEntryOpenApiApi {readonly config_schema: SurveyResultsWidgetConfigApi/** @nullable */required_product_access?: string | null+ /** Whether tiles of this type self-update in real time after load. Live tiles show a fixed real-time window and cannot apply test-account filtering to the stream, so their config takes neither dateRange nor filterTestAccounts. */+ live: boolean}export type LogsListWidgetCatalogEntryOpenApiApiWidgetType =@@ -9204,6 +9216,8 @@ export interface LogsListWidgetCatalogEntryOpenApiApi {readonly config_schema: LogsListWidgetConfigApi/** @nullable */required_product_access?: string | null+ /** Whether tiles of this type self-update in real time after load. Live tiles show a fixed real-time window and cannot apply test-account filtering to the stream, so their config takes neither dateRange nor filterTestAccounts. */+ live: boolean}export type WidgetCatalogEntryApi =diff --git a/products/dashboards/frontend/generated/widget-form-fields.json b/products/dashboards/frontend/generated/widget-form-fields.jsonindex 94f43bfbcb2a..8c9dbf889d55 100644--- a/products/dashboards/frontend/generated/widget-form-fields.json+++ b/products/dashboards/frontend/generated/widget-form-fields.json@@ -4,43 +4,50 @@"configSchemaExport": "activityEventsWidgetConfigSchema","configTypeExport": "ActivityEventsWidgetConfig","formSchemaExport": "activityEventsWidgetFormSchema",- "formFields": ["limit", "dateRange", "filterTestAccounts"]+ "formFields": ["limit", "dateRange", "filterTestAccounts"],+ "live": false},"error_tracking_list": {"configSchemaExport": "errorTrackingWidgetConfigSchema","configTypeExport": "ErrorTrackingWidgetConfig","formSchemaExport": "errorTrackingWidgetFormSchema",- "formFields": ["limit", "orderBy", "orderDirection", "dateRange", "filterTestAccounts", "status"]+ "formFields": ["limit", "orderBy", "orderDirection", "dateRange", "filterTestAccounts", "status"],+ "live": false},"experiment_results": {"configSchemaExport": "experimentResultsWidgetConfigSchema","configTypeExport": "ExperimentResultsWidgetConfig","formSchemaExport": "experimentResultsWidgetFormSchema",- "formFields": ["experimentId"]+ "formFields": ["experimentId"],+ "live": false},"experiments_list": {"configSchemaExport": "experimentsWidgetConfigSchema","configTypeExport": "ExperimentsWidgetConfig","formSchemaExport": "experimentsWidgetFormSchema",- "formFields": ["limit", "orderBy", "orderDirection", "status", "createdBy"]+ "formFields": ["limit", "orderBy", "orderDirection", "status", "createdBy"],+ "live": false},"logs_list": {"configSchemaExport": "logsWidgetConfigSchema","configTypeExport": "LogsWidgetConfig","formSchemaExport": "logsWidgetFormSchema",- "formFields": ["limit", "dateRange", "wrapLines", "timezone"]+ "formFields": ["limit", "dateRange", "wrapLines", "timezone"],+ "live": false},"session_replay_list": {"configSchemaExport": "sessionReplayWidgetConfigSchema","configTypeExport": "SessionReplayWidgetConfig","formSchemaExport": "sessionReplayWidgetFormSchema",- "formFields": ["limit", "orderBy", "orderDirection", "dateRange", "filterTestAccounts"]+ "formFields": ["limit", "orderBy", "orderDirection", "dateRange", "filterTestAccounts"],+ "live": false},"survey_results": {"configSchemaExport": "surveyResultsWidgetConfigSchema","configTypeExport": "SurveyResultsWidgetConfig","formSchemaExport": "surveyResultsWidgetFormSchema",- "formFields": ["surveyId", "limit", "dateRange"]+ "formFields": ["surveyId", "limit", "dateRange"],+ "live": false}}}diff --git a/products/dashboards/frontend/widget_types/catalog.ts b/products/dashboards/frontend/widget_types/catalog.tsindex 90da5365cb89..b974e5e2db8e 100644--- a/products/dashboards/frontend/widget_types/catalog.ts+++ b/products/dashboards/frontend/widget_types/catalog.ts@@ -17,6 +17,7 @@ import {surveyResultsWidgetConfigSchema,} from '../generated/widget-configs.zod'import type { DashboardWidgetProductAccess } from '../types'+import { isLiveDashboardWidgetType } from '../widgets/live/liveWidgetTypes'import { ActivityEventsWidgetPreview } from '../widgets/previews/ActivityEventsWidgetPreview'import { ErrorTrackingWidgetPreview } from '../widgets/previews/ErrorTrackingWidgetPreview'import {@@ -319,13 +320,25 @@ export const DASHBOARD_WIDGET_PREVIEWS: Record<DashboardWidgetCatalogKey, () =>export type ResolvedDashboardWidgetCatalogEntry = DashboardWidgetCatalogEntry & {headerLayout: DashboardWidgetHeaderLayoutheaderMeta: Required<DashboardWidgetHeaderMeta>+ /** `WidgetSpec.is_live` from the generated manifest — the tile self-updates in real time after load. */+ live: boolean}-function resolveDashboardWidgetCatalogEntry(entry: DashboardWidgetCatalogEntry): ResolvedDashboardWidgetCatalogEntry {+function resolveDashboardWidgetCatalogEntry(+ widgetType: string,+ entry: DashboardWidgetCatalogEntry+): ResolvedDashboardWidgetCatalogEntry {+ const live = isLiveDashboardWidgetType(widgetType)return {...entry,+ live,headerLayout: entry.headerLayout ?? DEFAULT_DASHBOARD_WIDGET_HEADER_LAYOUT,- headerMeta: { ...DEFAULT_DASHBOARD_WIDGET_HEADER_META, ...entry.headerMeta },+ headerMeta: {+ ...DEFAULT_DASHBOARD_WIDGET_HEADER_META,+ // Live tiles show a fixed real-time window; there is no configured date range to display.+ ...(live ? { showDateRange: false } : null),+ ...entry.headerMeta,+ },}}@@ -334,7 +347,10 @@ export function getDashboardWidgetCatalogEntry(widgetType: string): ResolvedDashthrow new Error(`Unknown dashboard widget type: ${widgetType}`)}- return resolveDashboardWidgetCatalogEntry(DASHBOARD_WIDGET_CATALOG[widgetType as DashboardWidgetCatalogKey])+ return resolveDashboardWidgetCatalogEntry(+ widgetType,+ DASHBOARD_WIDGET_CATALOG[widgetType as DashboardWidgetCatalogKey]+ )}export function tryGetDashboardWidgetCatalogEntry(widgetType: string): ResolvedDashboardWidgetCatalogEntry | undefined {@@ -342,7 +358,10 @@ export function tryGetDashboardWidgetCatalogEntry(widgetType: string): ResolvedDreturn undefined}- return resolveDashboardWidgetCatalogEntry(DASHBOARD_WIDGET_CATALOG[widgetType as DashboardWidgetCatalogKey])+ return resolveDashboardWidgetCatalogEntry(+ widgetType,+ DASHBOARD_WIDGET_CATALOG[widgetType as DashboardWidgetCatalogKey]+ )}export const DEFAULT_SHARED_DASHBOARD_WIDGET_PLACEHOLDER = {@@ -351,17 +370,15 @@ export const DEFAULT_SHARED_DASHBOARD_WIDGET_PLACEHOLDER = {} as constexport function getUnknownDashboardWidgetCatalogFallback(widgetType: string): ResolvedDashboardWidgetCatalogEntry {- return {+ return resolveDashboardWidgetCatalogEntry(widgetType, {groupId: widgetType,label: widgetType,description: '',defaultConfig: {},defaultLayout: { w: 6, h: 5, minW: 3 },headerTitle: widgetType,- headerLayout: DEFAULT_DASHBOARD_WIDGET_HEADER_LAYOUT,- headerMeta: DEFAULT_DASHBOARD_WIDGET_HEADER_META,sharedPlaceholder: DEFAULT_SHARED_DASHBOARD_WIDGET_PLACEHOLDER,- }+ })}export type DashboardWidgetCatalogGroup = {@@ -369,7 +386,7 @@ export type DashboardWidgetCatalogGroup = {groupLabel: stringwidgets: Array<{widgetType: DashboardWidgetCatalogKey- entry: DashboardWidgetCatalogEntry+ entry: ResolvedDashboardWidgetCatalogEntry}>}@@ -388,7 +405,10 @@ function getDashboardWidgetCatalogGroups(): DashboardWidgetCatalogGroup[] {groupsById.set(entry.groupId, group)}- group.widgets.push({ widgetType: widgetType as DashboardWidgetCatalogKey, entry })+ group.widgets.push({+ widgetType: widgetType as DashboardWidgetCatalogKey,+ entry: resolveDashboardWidgetCatalogEntry(widgetType, entry),+ })}const groupDisplayOrder = ['session_replay', 'error_tracking', 'activity', 'logs', 'experiments', 'surveys']diff --git a/products/dashboards/frontend/widgets/AddWidgetModal.tsx b/products/dashboards/frontend/widgets/AddWidgetModal.tsxindex f7c64408f1f4..8e4c1c2d057e 100644--- a/products/dashboards/frontend/widgets/AddWidgetModal.tsx+++ b/products/dashboards/frontend/widgets/AddWidgetModal.tsx@@ -17,7 +17,7 @@ import { ProductKey } from '~/queries/schema/schema-general'import {DASHBOARD_WIDGET_CATALOG_GROUPS,DASHBOARD_WIDGET_PREVIEWS,- type DashboardWidgetCatalogEntry,+ type ResolvedDashboardWidgetCatalogEntry,type DashboardWidgetCatalogKey,getDashboardWidgetGroupIcon,getDashboardWidgetGroupProductIntro,@@ -42,7 +42,7 @@ type AddWidgetModalProps = {type AddWidgetCatalogPickerProps = {widgetType: DashboardWidgetCatalogKey- entry: DashboardWidgetCatalogEntry+ entry: ResolvedDashboardWidgetCatalogEntryselected: booleanonToggleWidgetType: (widgetType: string) => void}@@ -65,6 +65,7 @@ function AddWidgetCatalogPicker({badge={entry.badge}description={entry.description}selected={selected}+ live={entry.live}preview={WidgetPreview ? <WidgetPreview /> : <div />}onSelect={handleSelect}/>diff --git a/products/dashboards/frontend/widgets/WidgetTypePickerCard.tsx b/products/dashboards/frontend/widgets/WidgetTypePickerCard.tsxindex 2c6cc272182a..60f192b3118d 100644--- a/products/dashboards/frontend/widgets/WidgetTypePickerCard.tsx+++ b/products/dashboards/frontend/widgets/WidgetTypePickerCard.tsx@@ -2,11 +2,15 @@ import clsx from 'clsx'import { IconCheck, IconStarFilled } from '@posthog/icons'+import { LemonTag } from 'lib/lemon-ui/LemonTag'+type WidgetTypePickerCardProps = {label: stringbadge?: stringdescription: stringselected: boolean+ /** Live (self-updating) widget type — tags the card so pickers know the tile updates in real time. */+ live?: booleanpreview: JSX.ElementonSelect: () => void}@@ -30,6 +34,7 @@ export function WidgetTypePickerCard({badge,description,selected,+ live,preview,onSelect,}: WidgetTypePickerCardProps): JSX.Element {@@ -60,7 +65,14 @@ export function WidgetTypePickerCard({) : null}<div className="p-3"><div className="flex items-center justify-between gap-2">- <span className="font-semibold">{label}</span>+ <span className="flex items-center gap-1.5 font-semibold">+ {label}+ {live ? (+ <LemonTag type="success" size="small">+ Live+ </LemonTag>+ ) : null}+ </span><WidgetTypePickerSelectionIndicator selected={selected} /></div><p className="text-xs text-muted m-0 mt-0.5 mb-2">{description}</p>diff --git a/products/dashboards/frontend/widgets/live/LiveWidgetSlidingWindow.test.ts b/products/dashboards/frontend/widgets/live/LiveWidgetSlidingWindow.test.tsnew file mode 100644index 000000000000..a6d754cc388d--- /dev/null+++ b/products/dashboards/frontend/widgets/live/LiveWidgetSlidingWindow.test.ts@@ -0,0 +1,181 @@+import type { LiveEvent } from '~/types'++import { LiveWidgetSlidingWindow } from './LiveWidgetSlidingWindow'++const WALL_CLOCK = '2026-01-16T16:30:00Z'+const WALL_CLOCK_MS = new Date(WALL_CLOCK).getTime()+const MINUTE = 60 * 1000++const relativeTime = (offsetMs: number): string => new Date(WALL_CLOCK_MS + offsetMs).toISOString()++const pageview = (timestamp: string, properties: Record<string, unknown> = {}): LiveEvent =>+ ({+ uuid: `uuid-${timestamp}-${JSON.stringify(properties)}`,+ event: '$pageview',+ timestamp,+ distinct_id: 'user-1',+ team_id: 1,+ created_at: timestamp,+ properties,+ }) as LiveEvent++// Mirrors the web analytics widgets: a skip-when-absent domain and a fallback-value domain.+const makeWindow = (): LiveWidgetSlidingWindow<'paths' | 'referrers'> =>+ new LiveWidgetSlidingWindow({+ windowMinutes: 30,+ breakdowns: {+ paths: (event) => {+ const pathname = event.properties?.$pathname+ return typeof pathname === 'string' && pathname !== '' ? pathname : null+ },+ referrers: (event) => {+ const referrer = event.properties?.$referring_domain+ return typeof referrer === 'string' && referrer !== '' ? referrer : '$direct'+ },+ },+ })++describe('LiveWidgetSlidingWindow', () => {+ it('drops streamed events at or before a domain seed generatedAt so re-seeds never double count', () => {+ const window = makeWindow()+ const generatedAt = relativeTime(-1 * MINUTE)+ window.mergeCountSeed([{ minute: relativeTime(-2 * MINUTE), count: 5 }], generatedAt)++ window.addEvent(pageview(relativeTime(-90 * 1000), { $pathname: '/before' })) // before generatedAt+ window.addEvent(pageview(generatedAt, { $pathname: '/at' })) // exactly at generatedAt+ window.addEvent(pageview(relativeTime(-30 * 1000), { $pathname: '/after' })) // after generatedAt++ expect(window.totalCount()).toBe(6)+ })++ it('never lets a lagging or empty re-seed wipe stream-accumulated counts', () => {+ const window = makeWindow()+ window.addEvent(pageview(relativeTime(-1 * MINUTE), { $pathname: '/live', $referring_domain: 'google.com' }))+ window.addEvent(pageview(relativeTime(-1 * MINUTE), { $pathname: '/live' }))++ // ClickHouse ingestion lags the stream: the re-seed comes back empty.+ window.mergeCountSeed([], relativeTime(0))+ window.mergeBreakdownSeed('paths', [], relativeTime(0))+ window.mergeBreakdownSeed('referrers', [], relativeTime(0))++ expect(window.totalCount()).toBe(2)+ expect(window.breakdownTotals('paths')).toEqual([{ value: '/live', views: 2 }])+ expect(window.breakdownTotals('referrers')).toEqual([+ { value: '$direct', views: 1 },+ { value: 'google.com', views: 1 },+ ])+ })++ it('does not double count when a caught-up re-seed includes events the stream already counted', () => {+ const window = makeWindow()+ window.addEvent(pageview(relativeTime(-1 * MINUTE), { $pathname: '/docs' }))+ window.addEvent(pageview(relativeTime(-1 * MINUTE), { $pathname: '/docs' }))++ // Server truth for that minute covers the streamed events plus one the stream missed.+ window.mergeCountSeed([{ minute: relativeTime(-1 * MINUTE), count: 3 }], relativeTime(0))+ window.mergeBreakdownSeed(+ 'paths',+ [{ minute: relativeTime(-1 * MINUTE), value: '/docs', views: 3 }],+ relativeTime(0)+ )++ expect(window.totalCount()).toBe(3)+ expect(window.breakdownTotals('paths')).toEqual([{ value: '/docs', views: 3 }])+ })++ it('does not let a stale out-of-order re-seed reopen the gate on events a newer seed covered', () => {+ const window = makeWindow()+ const staleGeneratedAt = relativeTime(-2 * MINUTE)++ window.mergeCountSeed([{ minute: relativeTime(-1 * MINUTE), count: 3 }], relativeTime(0))+ window.mergeBreakdownSeed(+ 'paths',+ [{ minute: relativeTime(-1 * MINUTE), value: '/docs', views: 3 }],+ relativeTime(0)+ )++ // An earlier run_widgets response lands after the newer one — it must not lower the watermark.+ window.mergeCountSeed([{ minute: relativeTime(-1 * MINUTE), count: 1 }], staleGeneratedAt)+ window.mergeBreakdownSeed(+ 'paths',+ [{ minute: relativeTime(-1 * MINUTE), value: '/docs', views: 1 }],+ staleGeneratedAt+ )++ // Already covered by the newer seed, so it must still be gated out.+ window.addEvent(pageview(relativeTime(-1 * MINUTE), { $pathname: '/docs' }))++ expect(window.totalCount()).toBe(3)+ expect(window.breakdownTotals('paths')).toEqual([{ value: '/docs', views: 3 }])+ })++ it('keeps domain seeds independent: seeding one domain does not clear counts or other domains', () => {+ const window = makeWindow()+ window.mergeCountSeed([{ minute: relativeTime(-2 * MINUTE), count: 3 }], relativeTime(0))+ window.addEvent(pageview(relativeTime(-5 * MINUTE), { $referring_domain: 'google.com' }))++ window.mergeBreakdownSeed(+ 'paths',+ [{ minute: relativeTime(-2 * MINUTE), value: '/docs', views: 7 }],+ relativeTime(0)+ )++ expect(window.totalCount()).toBe(3)+ expect(window.breakdownTotals('paths')).toEqual([{ value: '/docs', views: 7 }])+ expect(window.breakdownTotals('referrers')).toEqual([{ value: 'google.com', views: 1 }])+ })++ it.each([+ ['missing referrer', {}],+ ['empty referrer', { $referring_domain: '' }],+ ])('counts an extractor fallback value for %s while a null extractor skips the domain', (_name, properties) => {+ const window = makeWindow()+ window.addEvent(pageview(relativeTime(-1 * MINUTE), properties))++ // No $pathname → paths extractor returns null → the event is skipped for that domain only.+ expect(window.breakdownTotals('paths')).toEqual([])+ expect(window.breakdownTotals('referrers')).toEqual([{ value: '$direct', views: 1 }])+ })++ it('aggregates breakdown views across minutes and sorts by views descending', () => {+ const window = makeWindow()+ window.mergeBreakdownSeed(+ 'paths',+ [+ { minute: relativeTime(-3 * MINUTE), value: '/a', views: 1 },+ { minute: relativeTime(-2 * MINUTE), value: '/b', views: 2 },+ { minute: relativeTime(-1 * MINUTE), value: '/a', views: 2 },+ ],+ relativeTime(0)+ )++ expect(window.breakdownTotals('paths')).toEqual([+ { value: '/a', views: 3 },+ { value: '/b', views: 2 },+ ])+ })++ it('prunes minutes older than the window from every domain', () => {+ const window = makeWindow()+ window.mergeCountSeed(+ [+ { minute: relativeTime(-40 * MINUTE), count: 9 },+ { minute: relativeTime(-5 * MINUTE), count: 1 },+ ],+ relativeTime(0)+ )+ window.mergeBreakdownSeed(+ 'referrers',+ [+ { minute: relativeTime(-40 * MINUTE), value: 'old.com', views: 9 },+ { minute: relativeTime(-5 * MINUTE), value: 'new.com', views: 1 },+ ],+ relativeTime(0)+ )++ window.prune(WALL_CLOCK_MS / 1000)++ expect(window.totalCount()).toBe(1)+ expect(window.breakdownTotals('referrers')).toEqual([{ value: 'new.com', views: 1 }])+ })+})diff --git a/products/dashboards/frontend/widgets/live/LiveWidgetSlidingWindow.ts b/products/dashboards/frontend/widgets/live/LiveWidgetSlidingWindow.tsnew file mode 100644index 000000000000..dd01e771e74c--- /dev/null+++ b/products/dashboards/frontend/widgets/live/LiveWidgetSlidingWindow.ts@@ -0,0 +1,153 @@+import type { LiveEvent } from '~/types'++/** Maps a streamed event to a breakdown value; return null to skip the event for that domain. */+export type LiveWidgetEventExtractor = (event: LiveEvent) => string | null++export interface LiveWidgetSeedBucket {+ minute: string+ value: string+ views: number+}++const toEpochSeconds = (iso: string): number | null => {+ const ms = Date.parse(iso)+ return Number.isFinite(ms) ? ms / 1000 : null+}++const toMinuteBucket = (seconds: number): number => Math.floor(seconds / 60) * 60++/**+ * Minute-bucketed sliding window behind live dashboard widgets: an overall event count plus+ * named breakdown domains (each fed by a `LiveWidgetEventExtractor` over the streamed events).+ *+ * Each domain can be re-seeded independently because each widget's run_widgets result arrives+ * separately. A domain's seed carries a `generatedAt` server timestamp; streamed events at or+ * before it are dropped for that domain so a re-seed never double counts. That watermark only ever+ * advances, so seeds arriving out of order cannot reopen the gate on events a newer seed covered.+ *+ * Seeds arrive once per domain from the dashboard's initial run_widgets fetch (and again on manual+ * tile refresh), then the stream keeps the window moving. Seeds MERGE via per-bucket max rather+ * than replacing: the SSE stream reads Kafka directly while seeds read ClickHouse, which can lag+ * ingestion — a replace would wipe stream-accumulated counts with stale (or empty) server data.+ * Both sources count the same events, so max never double counts and converges to server truth.+ */+export class LiveWidgetSlidingWindow<D extends string = string> {+ private readonly windowMinutes: number+ private readonly domainEntries: [D, LiveWidgetEventExtractor][]+ private countsByMinute = new Map<number, number>()+ private breakdowns: Record<D, Map<number, Map<string, number>>>+ private newerThan: Record<string, number>++ constructor(options: { windowMinutes: number; breakdowns: Record<D, LiveWidgetEventExtractor> }) {+ this.windowMinutes = options.windowMinutes+ this.domainEntries = Object.entries(options.breakdowns) as [D, LiveWidgetEventExtractor][]+ this.breakdowns = Object.fromEntries(+ this.domainEntries.map(([domain]) => [domain, new Map<number, Map<string, number>>()])+ ) as Record<D, Map<number, Map<string, number>>>+ this.newerThan = Object.fromEntries(+ ['counts', ...this.domainEntries.map(([domain]) => domain)].map((key) => [key, 0])+ )+ }++ addEvent(event: LiveEvent): void {+ const seconds = toEpochSeconds(event.timestamp)+ if (seconds === null) {+ return+ }+ const minute = toMinuteBucket(seconds)++ if (seconds > this.newerThan.counts) {+ this.countsByMinute.set(minute, (this.countsByMinute.get(minute) ?? 0) + 1)+ }++ for (const [domain, extract] of this.domainEntries) {+ if (seconds > this.newerThan[domain]) {+ const value = extract(event)+ if (value !== null) {+ this.incrementBreakdown(domain, minute, value)+ }+ }+ }+ }++ mergeCountSeed(buckets: { minute: string; count: number }[], generatedAt: string): void {+ const merged = new Map<number, number>()+ for (const bucket of buckets) {+ const seconds = toEpochSeconds(bucket.minute)+ if (seconds !== null) {+ const minute = toMinuteBucket(seconds)+ merged.set(minute, (merged.get(minute) ?? 0) + bucket.count)+ }+ }+ for (const [minute, count] of this.countsByMinute) {+ merged.set(minute, Math.max(merged.get(minute) ?? 0, count))+ }+ this.countsByMinute = merged+ this.newerThan.counts = Math.max(this.newerThan.counts, toEpochSeconds(generatedAt) ?? 0)+ }++ mergeBreakdownSeed(domain: D, buckets: LiveWidgetSeedBucket[], generatedAt: string): void {+ const merged = new Map<number, Map<string, number>>()+ for (const bucket of buckets) {+ const seconds = toEpochSeconds(bucket.minute)+ if (seconds === null) {+ continue+ }+ const minute = toMinuteBucket(seconds)+ const byValue = merged.get(minute) ?? new Map<string, number>()+ byValue.set(bucket.value, (byValue.get(bucket.value) ?? 0) + bucket.views)+ merged.set(minute, byValue)+ }+ for (const [minute, byValue] of this.breakdowns[domain]) {+ const mergedByValue = merged.get(minute) ?? new Map<string, number>()+ for (const [value, views] of byValue) {+ mergedByValue.set(value, Math.max(mergedByValue.get(value) ?? 0, views))+ }+ merged.set(minute, mergedByValue)+ }+ this.breakdowns[domain] = merged+ this.newerThan[domain] = Math.max(this.newerThan[domain], toEpochSeconds(generatedAt) ?? 0)+ }++ prune(nowSeconds: number = Date.now() / 1000): void {+ const cutoff = toMinuteBucket(nowSeconds) - this.windowMinutes * 60+ for (const minute of this.countsByMinute.keys()) {+ if (minute < cutoff) {+ this.countsByMinute.delete(minute)+ }+ }+ for (const byMinute of Object.values<Map<number, Map<string, number>>>(this.breakdowns)) {+ for (const minute of byMinute.keys()) {+ if (minute < cutoff) {+ byMinute.delete(minute)+ }+ }+ }+ }++ totalCount(): number {+ let total = 0+ for (const count of this.countsByMinute.values()) {+ total += count+ }+ return total+ }++ breakdownTotals(domain: D): { value: string; views: number }[] {+ const totals = new Map<string, number>()+ for (const byValue of this.breakdowns[domain].values()) {+ for (const [value, views] of byValue) {+ totals.set(value, (totals.get(value) ?? 0) + views)+ }+ }+ return [...totals.entries()]+ .map(([value, views]) => ({ value, views }))+ .sort((a, b) => b.views - a.views || a.value.localeCompare(b.value))+ }++ private incrementBreakdown(domain: D, minute: number, value: string): void {+ const byValue = this.breakdowns[domain].get(minute) ?? new Map<string, number>()+ byValue.set(value, (byValue.get(value) ?? 0) + 1)+ this.breakdowns[domain].set(minute, byValue)+ }+}diff --git a/products/dashboards/frontend/widgets/live/components.tsx b/products/dashboards/frontend/widgets/live/components.tsxnew file mode 100644index 000000000000..92aad4f46005--- /dev/null+++ b/products/dashboards/frontend/widgets/live/components.tsx@@ -0,0 +1,53 @@+import { LemonButton } from 'lib/lemon-ui/LemonButton'++import { WidgetCardBodyMessage, WidgetCardContent } from '../../components/WidgetCard/WidgetCardBody'++/** Pulsing "Live" marker shown in a live widget tile's header top-heading row. */+export function LiveWidgetIndicator(): JSX.Element {+ return (+ <span className="flex items-center gap-1 font-medium text-success" data-attr="live-widget-indicator">+ <span className="relative flex size-2" aria-hidden>+ <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-success opacity-75" />+ <span className="relative inline-flex size-2 rounded-full bg-success" />+ </span>+ Live+ </span>+ )+}++export interface LiveWidgetEmptyStateProps {+ message: string+ cta?: {+ label: string+ to: string+ targetBlank?: boolean+ onClick?: () => void+ }+}++/** "No data in the real-time window yet" state for live widget tiles. */+export function LiveWidgetEmptyState({ message, cta }: LiveWidgetEmptyStateProps): JSX.Element {+ return (+ <WidgetCardContent>+ <WidgetCardBodyMessage>+ <div+ className="flex max-w-xs flex-col items-center gap-2 px-2 text-balance"+ data-attr="live-widget-empty-state"+ >+ <p className="m-0 text-sm text-muted">{message}</p>+ {cta ? (+ <LemonButton+ type="primary"+ size="small"+ to={cta.to}+ targetBlank={cta.targetBlank}+ onClick={cta.onClick}+ >+ {cta.label}+ </LemonButton>+ ) : null}+ </div>+ </WidgetCardBodyMessage>+ </WidgetCardContent>+ )+}diff --git a/products/dashboards/frontend/widgets/live/liveWidgetStream.ts b/products/dashboards/frontend/widgets/live/liveWidgetStream.tsnew file mode 100644index 000000000000..38c8d48ad192--- /dev/null+++ b/products/dashboards/frontend/widgets/live/liveWidgetStream.ts@@ -0,0 +1,130 @@+import { connect, events, listeners } from 'kea'+import type { Logic, LogicBuilder } from 'kea'++import { createStreamConnection } from 'lib/api-stream'+import { liveEventsHostOrigin } from 'lib/utils/apiHost'+import { teamLogic } from 'scenes/teamLogic'++import type { LiveEvent, TeamPublicType, TeamType } from '~/types'++const FLUSH_INTERVAL_MS = 300+const MINUTE_TICK_INTERVAL_MS = 60_000++export interface LiveWidgetStreamSpec {+ /** Livestream `eventType` query param, e.g. '$pageview'. Omit to stream all event types. */+ eventType?: string+ /** Livestream `columns` query param entries — the event properties the stream should include. */+ columns?: string[]+}++export interface LiveWidgetStreamOptions {+ /** Build the stream params from the current team; return null to skip connecting. */+ getStreamSpec: (team: TeamType | TeamPublicType) => LiveWidgetStreamSpec | null+ /**+ * Receives streamed events, batched on a flush interval while the tab is visible. Dispatch into+ * the consuming logic here via its wrapper (`myLogic.actions.x(...)`) — live widget logics are+ * unkeyed shared logics by contract, so one connection serves every tile of the family.+ */+ onEvents: (liveEvents: LiveEvent[]) => void+ /** Fires every 60s so time-windowed state can prune old minutes even without traffic. */+ onMinuteTick?: () => void+}++/**+ * Kea logic builder wiring a livestream SSE connection into a live widget's logic: one+ * `createStreamConnection` to `${liveEventsHostOrigin()}/events` authed with the team's+ * `live_events_token`, flush-batched `onEvents` delivery, and a minute tick for window pruning.+ *+ * All resources go through `cache.disposables`, so the stream tears down when the logic unmounts+ * and pauses while the tab is hidden (reconnecting on show). The dropped span is healed by the+ * next run_widgets re-seed — live seeds are idempotent by contract (see `LiveWidgetSeedPayload`).+ *+ * Connecting is re-evaluated on mount and whenever `currentTeam` resolves, because a tile can mount+ * before teamLogic has loaded the team (scenes render as soon as the user is known) — without that+ * the widget would sit on its seed forever. teamLogic also reloads the team on a poll, so the+ * connection is keyed by token + URL and only rebuilt when one of them actually changes.+ *+ * The builder only adds `connect`/`events` wiring — kea-typegen cannot see builder-injected+ * symbols, so the consuming logic declares its own actions/reducers/selectors and this builder+ * dispatches into them through the callbacks.+ */+export function liveWidgetStream<L extends Logic = Logic>(options: LiveWidgetStreamOptions): LogicBuilder<L> {+ return (logic) => {+ connect(() => ({+ actions: [teamLogic, ['loadCurrentTeamSuccess', 'updateCurrentTeamSuccess']],+ }))(logic)++ const syncConnection = (): void => {+ const { cache } = logic+ const team = teamLogic.values.currentTeam+ const token = team?.live_events_token+ const host = liveEventsHostOrigin()+ if (!team || !token || !host) {+ return+ }+ const spec = options.getStreamSpec(team)+ if (!spec) {+ return+ }++ const url = new URL(`${host}/events`)+ if (spec.eventType) {+ url.searchParams.append('eventType', spec.eventType)+ }+ if (spec.columns?.length) {+ url.searchParams.append('columns', spec.columns.join(','))+ }++ const connectionKey = `${token}::${url.toString()}`+ if (cache.liveWidgetStreamKey === connectionKey) {+ return+ }+ cache.liveWidgetStreamKey = connectionKey++ let batch: LiveEvent[] = []++ // pauseOnPageHidden (default) aborts the stream when the tab hides and reconnects on show.+ cache.disposables.add(() => {+ batch = []+ const connection = createStreamConnection({+ url,+ token,+ onMessage: (data) => {+ try {+ batch.push(JSON.parse(data) as LiveEvent)+ } catch (error) {+ console.error('Failed to parse live widget event:', error)+ }+ },+ onError: (error) => {+ console.error('Live widget stream error:', error)+ },+ })+ return () => connection.abort()+ }, 'liveWidgetStream.connection')++ cache.disposables.add(() => {+ const intervalId = setInterval(() => {+ if (batch.length) {+ options.onEvents(batch)+ batch = []+ }+ }, FLUSH_INTERVAL_MS)+ return () => clearInterval(intervalId)+ }, 'liveWidgetStream.flush')++ if (options.onMinuteTick) {+ cache.disposables.add(() => {+ const intervalId = setInterval(() => options.onMinuteTick?.(), MINUTE_TICK_INTERVAL_MS)+ return () => clearInterval(intervalId)+ }, 'liveWidgetStream.tick')+ }+ }++ events(() => ({ afterMount: syncConnection }))(logic)+ listeners(() => ({+ loadCurrentTeamSuccess: syncConnection,+ updateCurrentTeamSuccess: syncConnection,+ }))(logic)+ }+}diff --git a/products/dashboards/frontend/widgets/live/liveWidgetTypes.ts b/products/dashboards/frontend/widgets/live/liveWidgetTypes.tsnew file mode 100644index 000000000000..b6c14453cd33--- /dev/null+++ b/products/dashboards/frontend/widgets/live/liveWidgetTypes.ts@@ -0,0 +1,22 @@+import widgetFormFields from '../../generated/widget-form-fields.json'++const WIDGET_MANIFEST = widgetFormFields.widgets as Record<string, { live?: boolean }>++/** SSOT is `WidgetSpec.is_live` on the backend, flowed through `hogli build:widget-types`. */+export function isLiveDashboardWidgetType(widgetType: string): boolean {+ return WIDGET_MANIFEST[widgetType]?.live === true+}++/**+ * Contract for the run_widgets result of a live widget (`WidgetSpec.is_live` on the backend).+ *+ * The result is a one-shot SEED of the widget's real-time state, not the state itself: the tile+ * self-updates client-side afterwards. `generatedAt` is the server clock at seed-query time —+ * streamed events at or before it are already counted in the seed, so client merges use it to+ * avoid double counting. Any re-run of run_widgets (manual tile refresh, dashboard auto-refresh)+ * re-seeds, so seed merges must be idempotent.+ */+export interface LiveWidgetSeedPayload {+ /** Server clock at seed-query time (ISO-8601). */+ generatedAt: string+}diff --git a/products/dashboards/frontend/widgets/live/useLiveWidgetSeed.ts b/products/dashboards/frontend/widgets/live/useLiveWidgetSeed.tsnew file mode 100644index 000000000000..0e747d001040--- /dev/null+++ b/products/dashboards/frontend/widgets/live/useLiveWidgetSeed.ts@@ -0,0 +1,22 @@+import { useEffect } from 'react'++import type { LiveWidgetSeedPayload } from './liveWidgetTypes'++/**+ * Bridges a live widget's run_widgets `result` prop into its logic's seed action.+ *+ * This is the one accepted prop→action React bridge for live widgets: the seed arrives as a React+ * prop from the platform tile renderer, so the handoff has to happen in React. Seeding is safe to+ * repeat (seed merges are idempotent by contract), so re-renders and re-fetches need no guarding+ * beyond payload identity — pass `null` while the payload isn't ready.+ */+export function useLiveWidgetSeed<P extends LiveWidgetSeedPayload>(+ payload: P | null,+ seed: (payload: P) => void+): void {+ useEffect(() => {+ if (payload) {+ seed(payload)+ }+ }, [payload, seed])+}diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 1bdc711d0b77..60b10bff0aad 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -2230,6 +2230,8 @@ export namespace Schemas {readonly config_schema: ActivityEventsListWidgetConfig;/** @nullable */required_product_access?: string | null;+ /** Whether tiles of this type self-update in real time after load. Live tiles show a fixed real-time window and cannot apply test-account filtering to the stream, so their config takes neither dateRange nor filterTestAccounts. */+ live: boolean;}/**@@ -27020,6 +27022,8 @@ export namespace Schemas {readonly config_schema: ErrorTrackingListWidgetConfig;/** @nullable */required_product_access?: string | null;+ /** Whether tiles of this type self-update in real time after load. Live tiles show a fixed real-time window and cannot apply test-account filtering to the stream, so their config takes neither dateRange nor filterTestAccounts. */+ live: boolean;}/**@@ -29795,6 +29799,8 @@ export namespace Schemas {readonly config_schema: ExperimentResultsWidgetConfig;/** @nullable */required_product_access?: string | null;+ /** Whether tiles of this type self-update in real time after load. Live tiles show a fixed real-time window and cannot apply test-account filtering to the stream, so their config takes neither dateRange nor filterTestAccounts. */+ live: boolean;}/**@@ -30222,6 +30228,8 @@ export namespace Schemas {readonly config_schema: ExperimentsListWidgetConfig;/** @nullable */required_product_access?: string | null;+ /** Whether tiles of this type self-update in real time after load. Live tiles show a fixed real-time window and cannot apply test-account filtering to the stream, so their config takes neither dateRange nor filterTestAccounts. */+ live: boolean;}/**@@ -41414,6 +41422,8 @@ export namespace Schemas {readonly config_schema: LogsListWidgetConfig;/** @nullable */required_product_access?: string | null;+ /** Whether tiles of this type self-update in real time after load. Live tiles show a fixed real-time window and cannot apply test-account filtering to the stream, so their config takes neither dateRange nor filterTestAccounts. */+ live: boolean;}/**@@ -66927,6 +66937,8 @@ export namespace Schemas {readonly config_schema: SessionReplayListWidgetConfig;/** @nullable */required_product_access?: string | null;+ /** Whether tiles of this type self-update in real time after load. Live tiles show a fixed real-time window and cannot apply test-account filtering to the stream, so their config takes neither dateRange nor filterTestAccounts. */+ live: boolean;}/**@@ -72785,6 +72797,8 @@ export namespace Schemas {readonly config_schema: SurveyResultsWidgetConfig;/** @nullable */required_product_access?: string | null;+ /** Whether tiles of this type self-update in real time after load. Live tiles show a fixed real-time window and cannot apply test-account filtering to the stream, so their config takes neither dateRange nor filterTestAccounts. */+ live: boolean;}/**