:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(notebooks): make widget dashboard picker searchable (#106475)
Marius Andraff21c3adb018
diff --git a/docs/internal/generated-notebook-widgets.md b/docs/internal/generated-notebook-widgets.mdindex afb5c1edb090..344404f5a52f 100644--- a/docs/internal/generated-notebook-widgets.md+++ b/docs/internal/generated-notebook-widgets.md@@ -18,6 +18,9 @@ Choose **Add to dashboard** from a generated widget's notebook menu to save itsBoth generated notebook widgets and dashboard widgets must be enabled.The selected widget version must have an available preview before the menu offers **Add to dashboard**.Notebook widgets are added from the notebook, rather than the dashboard's generic widget picker.+Search the dashboard picker by name, description, or creator to find a destination.+Each option shows its description and creator, and marks pinned dashboards.+Dashboards without edit access cannot be selected.Each snapshot holds up to 5,000 rows per dataframe and 8 MiB in total. Adding a widget fails if any required result has expired or cannot be fully captured within these limits.Opening a dashboard reads these saved rows without starting notebook compute. Each viewer still needs access to the source notebook, queries, and connected data sources, and must consent to the exact generated build before it reads data.Public dashboards show a placeholder instead of notebook results.diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 23cf6288510a..fe03eb89603c 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6520,10 +6520,14 @@ snapshots:hash: v1.k794b7964.f93f5836e1334a281785def757008dc8ffa21aa628abdad3699de6be7dfc57da.7iLBmN3IxFb-xnmud9sGvyawwuRnGQQ9NcMP5NXo6Osproducts-notebooks-dashboard-widget--access-denied--light:hash: v1.k794b7964.f12c96e51ba15ba72a9e624e28c236e2117b2b1702aa983d7a0ad522c3d1e75e.YItBs3XBt1hkittNdQn6r9NQeXD--YdOXRkOMzg8qs0- products-notebooks-dashboard-widget--add-to-dashboard--dark:- hash: v1.k794b7964.844a153c1d7d1b06b48367d4adf6668d3e8ef3e56ed5568b5952381efc64a184._CUmLNH3L2iQ0i8D4aztJBWbZ1t2RZz1wGseuQg-1Fs- products-notebooks-dashboard-widget--add-to-dashboard--light:- hash: v1.k794b7964.3024152d6b954ce8d4f622b473bfbdd097cf33879c41f92089237c0c612e90f6.Sqi5WDWpiccNT_xzbnlo4DfcaWH0KIER6kjG5MjsP38+ products-notebooks-dashboard-widget--add-to-dashboard--narrow--dark:+ hash: v1.k794b7964.a80eb1d7284bde24a4a20565922f4e5ac4bd42dfba55086285bafa3016c1afc8.2Ft47t3JRKvUjm7o443Jv-Xlisw2BbNFesRMwbDkUkU+ products-notebooks-dashboard-widget--add-to-dashboard--narrow--light:+ hash: v1.k794b7964.94e4251d13dbedbf92e27243c4172322f5c684a5eec872f90cbe89fa85b956d0.-9FZjB6zgp4onoGHJP2cb-3KBljALv24T6uCrKuwho8+ products-notebooks-dashboard-widget--add-to-dashboard--wide--dark:+ hash: v1.k794b7964.ecf78a656f57121c94296ee22cb5c062093a980c770f68bd381093cf0ea93866.lo1l0HsrWqhLhB8q2pEpeQTDWPkhmZY5cRhMwJ8Xa5g+ products-notebooks-dashboard-widget--add-to-dashboard--wide--light:+ hash: v1.k794b7964.1b9f1573942ee86fe2acc9a6c4fbd65b1c6faa258db22d25a2f033e0a10cc6c0.YIf8xyNsfLNq1bS_Vn-NtURdKU_Jr6oM3g54UxGZ7Isproducts-notebooks-dashboard-widget--empty--dark:hash: v1.k794b7964.0dea0b55f93423d05eadf5d965f98c95171d4cd5b6ba6be4cd0d265d853d1aa7.i7496pxyxpeOzZ8QDSw1qmagFet5LEI8LDAi9WN6Jngproducts-notebooks-dashboard-widget--empty--light:@@ -6536,6 +6540,14 @@ snapshots:hash: v1.k794b7964.f93f5836e1334a281785def757008dc8ffa21aa628abdad3699de6be7dfc57da.3fn8SNwLnaHNnbN_MopoEAmij74NXlwTFqZ_0EvbX5Iproducts-notebooks-dashboard-widget--saved-results--light:hash: v1.k794b7964.f12c96e51ba15ba72a9e624e28c236e2117b2b1702aa983d7a0ad522c3d1e75e.ZrLMAxC9Z4gZ5qqJz7qFUUC7ykih0WvLmTJxitYD9Mg+ products-notebooks-dashboard-widget--search-dashboard-by-creator--narrow--dark:+ hash: v1.k794b7964.420b88ad149d19152ff8f1239ea9d8d35319e0b1bf4c1aae14cb773d958a1ae2.b7tEuMNcWeYGsqZkDKNZCz7H-xg8-d3H11AK-HWJzOY+ products-notebooks-dashboard-widget--search-dashboard-by-creator--narrow--light:+ hash: v1.k794b7964.c461f66b8a15203df372652f6322e407dc9f5fa6cf45156480bdc88822a30ce6.zx8iNjt1xP_kfZ3uydSe4Nj_F171G4DgizV_-l8lcBA+ products-notebooks-dashboard-widget--search-dashboard-by-creator--wide--dark:+ hash: v1.k794b7964.123382b87f95f9b8839032c88505de0eaf4eceed9092e1f25c24e87af669720c.Cg1vVScDMXtN7SDdxobEI3LqaI3-78O9-Xi8rRwWk54+ products-notebooks-dashboard-widget--search-dashboard-by-creator--wide--light:+ hash: v1.k794b7964.1a1fd60764b15bdd8ab1072705aae80fe0ac8e20846d7b0d3dddf0cbbf320f89.qBmud_ddtUDMuW4A3gkMxRN2UbQRoJ-0SgT4QmEJHn8products-notebooks-notebook-widget-trust-controls--gate--dark:hash: v1.k794b7964.97a5e7b5f92071f677d09773a3dea88ead3c9a71e85dbd6f6de8875ffc7a3036.9u2VOZ-O_aSU002VK8iAydGcjIYBXzRIacAelaDLJ6Yproducts-notebooks-notebook-widget-trust-controls--gate--light:diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 8bee00590b1e..65cf93a98468 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -4224,6 +4224,10 @@ importers:specifier: 'catalog:'version: 0.2.4([email protected](patch_hash=139b8d1f1304f9d9da452a9a1244c94ea679dbcb85687d8999563146879fb6f5)([email protected]))+ storybook:+ specifier: 'catalog:'+ version: 10.4.6(@testing-library/[email protected])(@types/[email protected])([email protected])([email protected]([email protected]))([email protected])+products/notifications:dependencies:kea:diff --git a/products/notebooks/frontend/NotebookDashboardWidget/NotebookDashboardWidget.stories.tsx b/products/notebooks/frontend/NotebookDashboardWidget/NotebookDashboardWidget.stories.tsxindex 6b99b28b7c75..7c30c21453fa 100644--- a/products/notebooks/frontend/NotebookDashboardWidget/NotebookDashboardWidget.stories.tsx+++ b/products/notebooks/frontend/NotebookDashboardWidget/NotebookDashboardWidget.stories.tsx@@ -4,10 +4,12 @@ import { useActions } from 'kea'import { LemonButton } from '@posthog/lemon-ui'import { mswDecorator } from '~/mocks/browser'-import { DashboardPlacement, DashboardTile } from '~/types'+import { AccessControlLevel, DashboardBasicType, DashboardPlacement, DashboardTile } from '~/types'import { DashboardWidgetItem } from 'products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem'+import { expect, userEvent, waitFor, within } from 'storybook/test'+import { notebookWidgetDashboardLogic } from '../NotebookNodeGeneratedWidget/notebookWidgetDashboardLogic'import { NotebookWidgetDashboardModal } from '../NotebookNodeGeneratedWidget/NotebookWidgetDashboardModal'import { NotebookDashboardWidget } from './NotebookDashboardWidget'@@ -159,10 +161,80 @@ export const AddToDashboard: Story = {mocks: {get: {'/api/environments/:team_id/dashboards/': {- results: [{ id: 1, name: 'Revenue overview', user_access_level: 'editor', deleted: false }],+ results: Array.from(+ { length: 250 },+ (_, index): DashboardBasicType => ({+ id: index + 1,+ name:+ index === 0+ ? 'Activation overview'+ : index === 1+ ? 'Board review'+ : index === 249+ ? 'Revenue overview'+ : `Metrics report ${index + 1}`,+ description:+ index === 0+ ? 'Signups, onboarding, and activation across the product.'+ : index === 249+ ? 'Conversion from trial to paid plans.'+ : '',+ created_by: {+ id: index + 1,+ uuid: `example-creator-${index + 1}`,+ distinct_id: `example-creator-${index + 1}`,+ first_name: index === 0 ? 'Avery' : index === 249 ? 'Jules' : 'Morgan',+ last_name: index === 0 ? 'Stone' : index === 249 ? 'Parker' : 'Reed',+ email:+ index === 0+ ? '[email protected]'+ : index === 249+ ? '[email protected]'+ : '[email protected]',+ },+ created_at: '2026-01-01T00:00:00Z',+ pinned: index === 0,+ deleted: false,+ is_shared: false,+ last_accessed_at: null,+ creation_mode: 'default',+ user_access_level: index === 1 ? AccessControlLevel.Viewer : AccessControlLevel.Editor,+ })+ ),+ next: null,+ count: 250,},},},},+ testOptions: { snapshotTargetSelector: 'body', viewportWidths: ['narrow', 'wide'] },+ },+ play: async () => {+ const screen = within(document.body)+ await userEvent.click(screen.getByRole('button', { name: 'Add to dashboard' }))+ await waitFor(() => {+ expect(screen.getByRole('button', { name: 'Choose a dashboard' })).not.toHaveClass('LemonButton--loading')+ })+ await userEvent.click(screen.getByRole('button', { name: 'Choose a dashboard' }))+ await screen.findByText('Activation overview')+ },+}++export const SearchDashboardByCreator: Story = {+ ...AddToDashboard,+ play: async (context) => {+ await AddToDashboard.play?.(context)+ const screen = within(document.body)+ for (const searchTerm of ['Parker', 'Jules Parker', '[email protected]', 'Jules']) {+ await userEvent.clear(screen.getByPlaceholderText('Search by name, description, or creator'))+ await userEvent.type(screen.getByPlaceholderText('Search by name, description, or creator'), searchTerm)+ await waitFor(() => {+ expect(screen.getByText('Revenue overview')).toBeVisible()+ expect(screen.getByText('Created by Jules Parker')).toBeVisible()+ expect(screen.queryByText('Activation overview')).not.toBeInTheDocument()+ expect(screen.queryByText('Board review')).not.toBeInTheDocument()+ expect(screen.queryByText('Metrics report 3')).not.toBeInTheDocument()+ })+ }},}diff --git a/products/notebooks/frontend/NotebookNodeGeneratedWidget/NotebookWidgetDashboardModal.tsx b/products/notebooks/frontend/NotebookNodeGeneratedWidget/NotebookWidgetDashboardModal.tsxindex eeb2b3c41110..a691d57ee959 100644--- a/products/notebooks/frontend/NotebookNodeGeneratedWidget/NotebookWidgetDashboardModal.tsx+++ b/products/notebooks/frontend/NotebookNodeGeneratedWidget/NotebookWidgetDashboardModal.tsx@@ -1,6 +1,9 @@import { useActions, useValues } from 'kea'-import { LemonBanner, LemonButton, LemonModal, LemonSelect } from '@posthog/lemon-ui'+import { IconPinFilled } from '@posthog/icons'+import { LemonBanner, LemonButton, LemonModal, LemonSearchableSelect, Tooltip } from '@posthog/lemon-ui'++import { fullName, fullNameOrEmail } from 'lib/utils/strings'import { dashboardsModel } from '~/models/dashboardsModel'import { AccessControlLevel } from '~/types'@@ -39,18 +42,51 @@ export function NotebookWidgetDashboardModal(props: NotebookWidgetDashboardPropsSave this widget and its current dataframe results on a dashboard. Opening the dashboard will notrun notebook code.</p>- <LemonSelect+ <LemonSearchableSelectvalue={dashboardId}onChange={selectDashboard}loading={dashboardsLoading}disabledReason={saving ? 'Saving results…' : undefined}fullWidthplaceholder="Choose a dashboard"+ searchPlaceholder="Search by name, description, or creator"+ searchKeys={['label', 'description', 'creator']}+ searchInputDataAttr="notebook-widget-dashboard-search"+ noResultsMessage="No dashboards match your search"+ data-attr="notebook-widget-dashboard-select"options={nameSortedDashboards.filter((dashboard) => !dashboard.deleted).map((dashboard) => ({value: dashboard.id,label: dashboard.name || 'Untitled',+ description: dashboard.description,+ creator: dashboard.created_by+ ? `${fullName(dashboard.created_by)} ${dashboard.created_by.email}`+ : '',+ labelInMenu: (+ <span className="flex min-w-0 flex-1 flex-col gap-1 text-left">+ <span className="flex min-w-0 items-center gap-2">+ <span className="truncate">{dashboard.name || 'Untitled'}</span>+ {dashboard.pinned && (+ <Tooltip title="Pinned dashboard">+ <span className="flex shrink-0">+ <IconPinFilled className="text-secondary" />+ </span>+ </Tooltip>+ )}+ </span>+ {dashboard.description && (+ <span className="line-clamp-2 text-xs font-normal text-secondary">+ {dashboard.description}+ </span>+ )}+ <span className="truncate text-xs font-normal text-secondary">+ {dashboard.created_by+ ? `Created by ${fullNameOrEmail(dashboard.created_by)}`+ : 'Creator unavailable'}+ </span>+ </span>+ ),disabledReason:dashboard.user_access_level === AccessControlLevel.Viewer? 'You need edit access to this dashboard'diff --git a/products/notebooks/package.json b/products/notebooks/package.jsonindex f250a58656a3..19a68b1cc8f9 100644--- a/products/notebooks/package.json+++ b/products/notebooks/package.json@@ -11,7 +11,8 @@},"devDependencies": {"@testing-library/react": "^14.3.1",- "kea-test-utils": "catalog:"+ "kea-test-utils": "catalog:",+ "storybook": "catalog:"},"peerDependencies": {"@posthog/brand": "catalog:",