Skip to content

feat(dashboards): add WidgetCard shell and dashboard widget UI glue (7/11)#60523

Merged
MattPua merged 14 commits into
masterfrom
05-28-feat_dashboards_add_widgetcard_shell
Jun 1, 2026
Merged

feat(dashboards): add WidgetCard shell and dashboard widget UI glue (7/11)#60523
MattPua merged 14 commits into
masterfrom
05-28-feat_dashboards_add_widgetcard_shell

Conversation

@MattPua
Copy link
Copy Markdown
Member

@MattPua MattPua commented May 28, 2026

Problem

Dashboard widgets need shared frontend shell components before any concrete widget type lands. This PR adds the WidgetCard compound component, add-widget modal, catalog/registry scaffolding, and dashboard scene glue with an empty widget catalog.

This PR is 7/11 in the dashboard widgets Graphite stack.

Depends on: PR 6 (#60494 — widget registry and run_widgets API)

Changes

  • WidgetCard compound components, DashboardWidgetItem, add-widget modal, widget type picker
  • Empty DASHBOARD_WIDGET_CATALOG and DASHBOARD_WIDGET_REGISTRY (concrete types in follow-up PRs)
  • Dashboard scene integration: dashboardLogic, DashboardItems, widgetFetchUtils, empty-dashboard UX
  • Shared card chrome: CardTopHeadingRow, DashboardTileRefreshDataButton
  • Widget availability guard and setup prompt infrastructure
  • Jest tests for shell components and registry scaffolding

How did you test this code?

  • Agent: ran Jest tests for WidgetCard, DashboardWidgetItem, registry scaffolding, and widget availability during development
  • Feature remains behind dashboard widgets feature flag

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Publish to changelog?

no — still feature flagged

Docs update

skip-inkeep-docs

🤖 Agent context

@MattPua MattPua changed the title feat(dashboards): add WidgetCard shell and dashboard widget UI glue feat(dashboards): add WidgetCard shell and dashboard widget UI glue (8/11) May 28, 2026
@MattPua MattPua changed the title feat(dashboards): add WidgetCard shell and dashboard widget UI glue (8/11) feat(dashboards): add WidgetCard shell and dashboard widget UI glue (7/11) May 28, 2026
@MattPua MattPua changed the title feat(dashboards): add WidgetCard shell and dashboard widget UI glue (7/11) feat(dashboards): add WidgetCard shell and dashboard widget UI glue (8/12) May 28, 2026
@MattPua MattPua changed the title feat(dashboards): add WidgetCard shell and dashboard widget UI glue (8/12) feat(dashboards): add WidgetCard shell and dashboard widget UI glue (7/11) May 28, 2026
@MattPua MattPua force-pushed the 05-28-feat_dashboards_add_widgetcard_shell branch from 07b7d6a to fa6e73b Compare May 28, 2026 20:20
@MattPua MattPua force-pushed the 05-28-feat_dashboards_add_widget_registry_run_widgets_and_dashboard_widget_api branch from 2049950 to 7b6c3c5 Compare May 28, 2026 20:20
@MattPua MattPua force-pushed the 05-28-feat_dashboards_add_widgetcard_shell branch 3 times, most recently from 58653c9 to 400ebc6 Compare May 28, 2026 20:43
@MattPua MattPua marked this pull request as ready for review May 28, 2026 20:49
@assign-reviewers-posthog assign-reviewers-posthog Bot requested review from a team May 28, 2026 20:50
@MattPua MattPua force-pushed the 05-28-feat_dashboards_add_widgetcard_shell branch from 400ebc6 to 067652e Compare May 28, 2026 20:51
@MattPua MattPua removed the request for review from a team May 28, 2026 20:53
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 28, 2026

Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 3
frontend/src/scenes/dashboard/dashboardLogic.tsx:1833-1837
**Public dashboard insights stop refreshing after this change**

Adding `DashboardPlacement.Public` to the exclusion in `handleDashboardLoadComplete` prevents `refreshDashboardItems` from ever being called on shared/public dashboards. `refreshDashboardItems` is the mechanism that fetches fresh data for stale insight tiles (it filters using `cache_target_age`). Skipping it entirely means insights on public dashboards will silently stall at whatever cached state they were in when the dashboard was loaded, even when their cache has expired.

The underlying motivation — avoiding `refreshDashboardWidgets` on public views — is already enforced: `refreshDashboardWidgets` returns early when `placement === DashboardPlacement.Public`. The `Public` guard here is redundant for widgets but harmful for insight tiles. Moving the `Public` exclusion to the widget-specific code block inside `refreshDashboardItems` (or simply removing it from `handleDashboardLoadComplete`) would preserve the original insight-refresh behaviour for public dashboards.

### Issue 2 of 3
products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.tsx:302-309
`userHasWidgetProductAccess` is missing an exhaustive `never` guard at the end of its switch, unlike the equivalent pattern used in `widgetAvailability.ts`. When `DashboardWidgetProductAccess` gains a new member (e.g. `'surveys'`), TypeScript will silently compile the function with an implicit `undefined` return instead of failing at compile time. Adding the guard aligns it with the existing safety pattern and catches omissions automatically.

```suggestion
    switch (productAccess) {
        // New gated widget types: add a case here — CONTRIBUTING.md
        case 'error_tracking':
            return userHasAccess(AccessControlResourceType.ErrorTracking, AccessControlLevel.Viewer)
        case 'session_recording':
            return userHasAccess(AccessControlResourceType.SessionRecording, AccessControlLevel.Viewer)
        default: {
            const _exhaustive: never = productAccess
            return _exhaustive
        }
    }
}
```

### Issue 3 of 3
products/dashboards/frontend/widget_types/widgetAvailability.test.ts:14-42
The `session_replay_enabled` requirement is declared alongside `exception_autocapture` but has no test coverage. A parameterised table would cover both requirements without repeating the setup, and would automatically catch any future addition to `WidgetAvailabilityRequirementId`.

```suggestion
    it.each([
        {
            requirement: 'exception_autocapture' as const,
            teamPropKey: 'autocapture_exceptions_opt_in' as const,
        },
        {
            requirement: 'session_replay_enabled' as const,
            teamPropKey: 'session_recording_opt_in' as const,
        },
    ])('evaluates $requirement requirement', ({ requirement, teamPropKey }) => {
        expect(
            isWidgetAvailabilityRequirementMet(requirement, {
                ...MOCK_DEFAULT_TEAM,
                [teamPropKey]: false,
            })
        ).toBe(false)

        expect(
            isWidgetAvailabilityRequirementMet(requirement, {
                ...MOCK_DEFAULT_TEAM,
                [teamPropKey]: true,
            })
        ).toBe(true)
    })
```

Reviews (1): Last reviewed commit: "feat(dashboards): add WidgetCard shell a..." | Re-trigger Greptile

Comment thread frontend/src/scenes/dashboard/dashboardLogic.tsx
Comment thread products/dashboards/frontend/widget_types/widgetAvailability.test.ts Outdated
MattPua and others added 3 commits June 1, 2026 15:43
Use satisfies Record for widget product access compile-time checks,
replace ProductIntroduction tailwind overrides with SCSS, simplify utils,
tighten date range schema validation, and remove unused modal sections file.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@MattPua MattPua force-pushed the 05-28-feat_dashboards_add_widgetcard_shell branch from bef55af to 73190dc Compare June 1, 2026 19:44
@MattPua MattPua removed the request for review from a team June 1, 2026 19:44
Use generated dashboardsPartialUpdate, fix project-scoped View href
expectation, and scope dashboardLogic test mocks with spies.

Co-authored-by: Cursor <cursoragent@cursor.com>
@assign-reviewers-posthog assign-reviewers-posthog Bot requested a review from a team June 1, 2026 20:17
MattPua and others added 2 commits June 1, 2026 16:42
Bump products/dashboards posthog-js to catalog 1.378.0 and dedupe
jest snapshot entries so frozen install and build:products pass CI.

Co-authored-by: Cursor <cursoragent@cursor.com>
@MattPua MattPua removed the request for review from a team June 1, 2026 20:44
Co-authored-by: Cursor <cursoragent@cursor.com>
@assign-reviewers-posthog assign-reviewers-posthog Bot requested a review from a team June 1, 2026 21:08
@MattPua MattPua removed the request for review from a team June 1, 2026 21:14
@assign-reviewers-posthog assign-reviewers-posthog Bot requested a review from a team June 1, 2026 21:25
@MattPua MattPua removed the request for review from a team June 1, 2026 21:35
@MattPua MattPua force-pushed the 05-28-feat_dashboards_add_widgetcard_shell branch from 3fa4158 to 69db79a Compare June 1, 2026 21:36
@assign-reviewers-posthog assign-reviewers-posthog Bot requested a review from a team June 1, 2026 21:36
@MattPua MattPua removed the request for review from a team June 1, 2026 21:53
16 updated
Run: 9cedf542-a10f-427d-9b3e-4c6b1f6fdae4

Co-authored-by: MattPua <3376526+MattPua@users.noreply.github.com>
@assign-reviewers-posthog assign-reviewers-posthog Bot requested a review from a team June 1, 2026 21:59
@MattPua MattPua removed the request for review from a team June 1, 2026 22:33
@MattPua MattPua merged commit 550ea3f into master Jun 1, 2026
201 of 209 checks passed
Copy link
Copy Markdown
Member Author

MattPua commented Jun 1, 2026

Merge activity

@MattPua MattPua deleted the 05-28-feat_dashboards_add_widgetcard_shell branch June 1, 2026 22:51
@deployment-status-posthog
Copy link
Copy Markdown

deployment-status-posthog Bot commented Jun 1, 2026

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-06-01 23:14 UTC Run
prod-us ✅ Deployed 2026-06-02 10:18 UTC Run
prod-eu ✅ Deployed 2026-06-02 10:20 UTC Run

MattPua added a commit that referenced this pull request Jun 3, 2026
## Problem

Dashboards need embeddable product widgets beyond insights. Error tracking issues are the first list-style widget: a ranked table of top issues that fits the WidgetCard shell and establishes patterns later widgets (session replay, etc.) reuse.

This PR is **8/11** in the dashboard widgets Graphite stack (WidgetCard shell #60523 is merged).

## Changes

- **`error_tracking_list`** **widget** — catalog/registry entry, backend runner, config schema, preview, and full frontend tile (component, edit modal, stories, tests)
- **`ErrorTrackingIssueList`** **extraction** — shared list component + skeleton for dashboard embedding without pulling in the full error tracking scene
- **Shared edit-modal infrastructure** — `editWidgetModalBuilders`, tile/filter section components, `buildWidgetTileMetadataPatch`, and kea patterns both widget types inherit
- **Shared dashboard tile orchestration** (used by all widget types on this branch):
    - Single PATCH save via `updateWidgetTile` / `updateDashboardWidgetTile` (config + name + description)
    - `useAsyncActions` so edit modals await save before closing
    - Refresh widget data after duplicate
    - Unknown widget types: header + ⋯ menu stay usable; body-only `ErrorBoundary` (no fetch-error refresh UI)
    - Catalog setup prompts use stacked vertical `WidgetCardProductIntroduction`
    - New widgets append to the bottom row of the layout (not lowest-segment gap fill)
    - Server analytics: `dashboard widget added` alongside existing `dashboard tile added`
- **Catalog header defaults** — `getDashboardWidgetCatalogEntry` / `tryGetDashboardWidgetCatalogEntry` resolve layout and header metadata
- **Review follow-ups** — validation wiring, table layout/sparkline fixes, kea typegen-safe modal logic, Storybook/VR baseline updates

## How did you test this code?

- Agent: Jest for error tracking widget, edit modal, registry, add-widget modal, config validation, `DashboardWidgetItem`, and `dashboardLogic` widget tile updates
- Agent: backend `test_dashboard_widgets`, `test_run_widgets`, and `test_widget_layouts`
- Feature remains behind the dashboard widgets feature flag

👉 _Stay up-to-date with_ [_PostHog coding conventions_](https://posthog.com/docs/contribute/coding-conventions) _for a smoother review._

## Automatic notifications

- [ ] Publish to changelog?
- [x] Alert Sales and Marketing teams?

## Docs update

Add the `skip-inkeep-docs` label — no user-facing docs yet (feature flagged). Agent skill/docs land in #60516.

## 🤖 Agent context

- Split from former monolithic PR #60495; WidgetCard glue merged in #60523; session replay lands in #60496
- Several shared dashboard fixes landed here because they touch `dashboardLogic`, `DashboardWidgetItem`, and backend tile create paths used by every widget type
- Cursor agent assisted on review fixes, CI resolution, and post-ship UX polish (save flow, error boundaries, layout placement)
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.

2 participants