: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): simplify jupyter controls and dataframe labels (#118653)
Marius Andraecdd8510ff57
diff --git a/docs/internal/generated-notebook-widgets.md b/docs/internal/generated-notebook-widgets.mdindex 326345c1e338..40c12d219220 100644--- a/docs/internal/generated-notebook-widgets.md+++ b/docs/internal/generated-notebook-widgets.md@@ -129,7 +129,8 @@ New widgets default to Claude Sonnet 5. An explicitly selected model stays selecWidget IDs are saved when their settings, title, or panel visibility change, so editing a widget keeps its generation history attached.New SQL cells receive a unique name beginning with `sql_df_`; Python cells receive one beginning with `df_`.-You can rename a dataframe in its result panel.+You can rename a dataframe below its results while its edit, filters, or query panel is also open. Results-only views hide the name controls.+In Jupyter mode, dataframe names use smaller text. Code cells keep the name below their output alongside their visible source editor.The SQL and insight dataframe name rows are visible when either `revamped-py-notebooks` or `notebook-generated-widgets` is enabled.The widget flag enables HogQL dataframe preparation. Python, kernel-backed SQL, and direct connections require `revamped-py-notebooks`.Insights that expose SQL have the same dataframe name field below their results, starting with `insight_df` (with a numeric suffix when needed).diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex f0c6ee77567e..af2854f4c52a 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -13227,13 +13227,13 @@ snapshots:scenes-app-notebooks-generated-widgets--before-generation--light:hash: v1.k794b7964.f8eabbbe270e16f6db6253fac4ccc1298d6486f4fcc54d086f39b494e32276bb.byEVF2WvcVULWZ_b-qJMNkCK-hCMqS-EcQNFNyVUVd4scenes-app-notebooks-jupyter-mode--jupyter-mode--dark:- hash: v1.k794b7964.0348331cebb2cd718ba27d081121a42d855b62c191f86af19b66bc7d5d812ede.Uco9KJMqE3EAiMZg1x3rnZA6nGEQ5Z6iWPhr1s_9LJk+ hash: v1.k794b7964.b8692b352616bd450bd43d9e4a134c22be76a554d179e324a88c92f0809225df.DPVmn8UZZao9iJbQ6EKyNPJFPYSZIi2MBRe9xaqpposscenes-app-notebooks-jupyter-mode--jupyter-mode--light:- hash: v1.k794b7964.b2e5a41eeab0da940c38f236a768eb67f35000260b98b1df0fdbacf5e5f307b8.ogybvKdLXRRiMBqxzGenSF58ax8ATMn1drzEhmss2Pk+ hash: v1.k794b7964.d9a69aac59ff00d9bc74864896b05c2ea02be8a542c3e2eaa5978e488cd9d823.rVnDEXzXD4cxM0YlICewnJ6qtfINfo8JEga-QmaqWlYscenes-app-notebooks-jupyter-mode--jupyter-mode-off--dark:- hash: v1.k794b7964.8a933f9d3d913d27c9306f54490eff93629b2ae2c5a42c3a08c2165a7db72b68.ghNnjSunZ43NsgdxzN6tQlPHLUl6OFRy-vLszghAd7s+ hash: v1.k794b7964.30b1a561f2d25e4e2a8828b4ad81eb07b8cb48e6b924eea617bae2b7e026df1f.aUSXnCxnH2rdVJiAGQfh3DmmdDa01nJtrYSrM_-k9asscenes-app-notebooks-jupyter-mode--jupyter-mode-off--light:- hash: v1.k794b7964.e5f3696e8d1b266d63a8be0d38b0becbd75c7eb6e478d31909da8d030f60695c.9if2KQS4f4KII2N3_eJtTeKPjgOdXnkOGEOq3wTkCMo+ hash: v1.k794b7964.a8148a0bdf6dcb7477c159e50720365e3110419dfdc67644b7f9f489dbf9b0db.s40r7AlvjNNdAk8rCvrNk4BI8a-5EJdNDiNRDjN8qEQscenes-app-notebooks-kernel-info--free-compute--dark:hash: v1.k794b7964.e8e81cc18d66dcca3d1cd23cc5017833b040abcaa4a3be85c6161787fed0efcd.OiaNuBz69zbpOxiLQsFYOQuJn_226577RmjJ_GbOdyQscenes-app-notebooks-kernel-info--free-compute--light:@@ -13287,13 +13287,13 @@ snapshots:scenes-app-notebooks-run-all-banner--starting--light:hash: v1.k794b7964.6c7bd37efe1d58d68070782d7d1d0ce20be5abfebe1f829feb0376b584ad1158.CVBhfDqMZqLLuxmDgkiTAS9Vn2SANiX9cOWDF1Ui8hkscenes-app-notebooks-sql-cell-chart--bar-chart--dark:- hash: v1.k794b7964.4b9763fbf9a227bfd8011e77ffdebc555dd84159bc3555e64cbc772a3f577b97.rV9Q2LerkU-4gFGqjyuUtqJfa5Eg7IWIfxq5pTijeAs+ hash: v1.k794b7964.01d294260ab7f11c6ec5f12babb168e9b4be9b3ac5083437ce4ca08c26fdd307.NEYWZWqJjvheGvI6_V7nSZpr6G1CQXpQVv_LakiSmKkscenes-app-notebooks-sql-cell-chart--bar-chart--light:- hash: v1.k794b7964.75cb272b247dfe1d0d751ac76a9bbf602fc122a7dcdee14d1dc58fc0bf776664.C-l8o8t6DAWzgk0V3gjTaUXq8fh0oLfAKx41SpxmzQ0+ hash: v1.k794b7964.c8b9e39a378111733901720344706caa06054f71617c2f33d048c6bea82e52cb.A0knltu3Io9HZA-xdzQ6xCvsxicU8ZSjvOWWj-jT9bsscenes-app-notebooks-sql-cell-chart--line-chart--dark:- hash: v1.k794b7964.acd1ca0ffe9b2ca1b475f2ada98c2d852640f533cd8cee18adfbbb0d1a1271b0.EcUH90S95-XdsPZFEFml6IyvfJtJJotSgQsgmyMg5Pc+ hash: v1.k794b7964.81aa5c1de9525de5b841548cc8b8403451b89c6ab3701bd33fcdc27c2864458d.bbY5Nitk6h_sipbG-d3C7qhQl0xRobRMrq1vBsK9Bf8scenes-app-notebooks-sql-cell-chart--line-chart--light:- hash: v1.k794b7964.48a35e5d510ee5bb815299d814acc467016199b559833ecc66418f23cd1b0732.xiZOqKnalZ7mv20MlRJSPfRXI7WxZ9kLLvDxQ4KQBQA+ hash: v1.k794b7964.6ba65b542065dd2a89dce854230c8cd9fa88af21cda380d996a36e602947494f.uBxIB5cGUIDNUBP_HUc1ZKCKP8oVHeYqlyClmTDYDoQscenes-app-notebooks-widget-generation-cost--less-than-one-cent--dark:hash: v1.k794b7964.3d7ab4ed80e86dee207323ed0baf83d86a9c0b53c868f64769ddc708b4ab5881.RKwiZJnBL8K4kWfRM3MV6Aruoqr20twxVmepMy_SU6Yscenes-app-notebooks-widget-generation-cost--less-than-one-cent--light:@@ -13339,9 +13339,9 @@ snapshots:scenes-app-notebooks-widget-views--group-views--light:hash: v1.k794b7964.3844ddec20fcd7f37bffaca53a98740dfc150d5ec61c040435d9d5683b78c49f.ti5pquIH9vqC56HbmyWDpO9r23A4XSrzBN0zcHNo08Mscenes-app-notebooks-widget-views--insight-views--dark:- hash: v1.k794b7964.e25c1892d4ab208af5c14ddbd62850287baa0f564b2bcd67309e9357ebae2e9c.uP6ZYZ2y2epiADizyQmS0p921z8XYO4RssS_4Ns2228+ hash: v1.k794b7964.3cd6aee7228c98cf2f27bf0126200eaabd87e1cd4afe7123892b6532700b6b07.ybJ4tpHq-P3wNlOCEUspRZB7kLR1DdWC7SDx1QW_ohYscenes-app-notebooks-widget-views--insight-views--light:- hash: v1.k794b7964.5369699ec2675bd48c1df9f62bb8b5c8e95821ed26a4ed8a2d46cc07a547e8a5.Lx0HDMJJDnUu1yL_liJyEQ-rRlhY4p5a8bqTL2C6geg+ hash: v1.k794b7964.690e0db45d95915a66fb22e02f7ead173186a6cefae5ad6dbdeb5103b7bdfbd0.dzHPbHhENEt9YoK-EEMi88V_XmLPXJNhl9HulAWBKvoscenes-app-notebooks-widget-views--llm-trace-views--dark:hash: v1.k794b7964.4e1ab634bae8a93e4e3c6fed3c379cd10791a8cdfaa37c551ffc10cbb5c2d738.zBi7T4pmBEu1EV1ID04nuFxNs7iSFBMDc-tCKVEmy70scenes-app-notebooks-widget-views--llm-trace-views--light:diff --git a/frontend/src/scenes/notebooks/Nodes/components/NotebookCellOutputNameFooter.tsx b/frontend/src/scenes/notebooks/Nodes/components/NotebookCellOutputNameFooter.tsxindex 1807b241d912..2c866f7138fb 100644--- a/frontend/src/scenes/notebooks/Nodes/components/NotebookCellOutputNameFooter.tsx+++ b/frontend/src/scenes/notebooks/Nodes/components/NotebookCellOutputNameFooter.tsx@@ -1,7 +1,11 @@+import clsx from 'clsx'import { ReactNode } from 'react'import { IconCornerDownRight } from '@posthog/icons'+import { useComponentPanelState } from 'lib/components/MarkdownNotebook/componentPanelContext'+import { useNotebookJupyterCommands } from 'lib/components/MarkdownNotebook/jupyterMode'+/** The bar under a code cell's output that names the dataframe the cell binds. Shared by the SQL* and Python cells, which differ only in what they put after the input. */export function NotebookCellOutputNameFooter({@@ -16,12 +20,22 @@ export function NotebookCellOutputNameFooter({inputRef?: (element: HTMLInputElement | null) => void/** Drawn after the input: a validation error, usage links, a hint. */children?: ReactNode-}): JSX.Element {+}): JSX.Element | null {+ const componentPanelState = useComponentPanelState()+ const isJupyterMode = !!useNotebookJupyterCommands()++ if (componentPanelState && !componentPanelState.showEditPanel) {+ return null+ }+return (<div// Translucent overlay, not a surface token: the shell is surface-primary in light// mode but surface-tertiary in dark, so a fixed surface vanishes against one of them.- className="flex shrink-0 items-center gap-2 text-xs text-muted border-t border-primary bg-fill-highlight-50 p-2"+ className={clsx(+ 'flex shrink-0 flex-wrap items-center gap-2 text-muted border-t border-primary bg-fill-highlight-50',+ isJupyterMode ? 'px-2 py-1 text-xxs' : 'p-2 text-xs'+ )}onClick={(event) => event.stopPropagation()}onMouseDown={(event) => event.stopPropagation()}>@@ -33,13 +47,16 @@ export function NotebookCellOutputNameFooter({// The dataframe name this cell's result is exposed as to later cells. A SQL cell// references it as a table name (`from sql_df`), a Python cell as a variable.// Optional: left empty, the cell exports nothing and later cells can't read it.- // Wide enough for the placeholder to sit on one line without clipping. The name- // carries weight through size and a faintly warm near-black rather than a hue,- // because a saturated color here competes with the accent the app spends on links.- className="w-56 rounded border border-primary px-1.5 py-0.5 text-sm font-medium font-mono bg-surface-primary text-[oklch(0.27_0.022_345deg)] dark:text-[oklch(0.93_0.014_345deg)] focus:outline-none focus:ring-1 focus:ring-primary"+ className={clsx(+ 'max-w-full rounded border border-primary px-1.5 py-0.5 font-mono bg-surface-primary focus:outline-none focus:ring-1 focus:ring-primary',+ isJupyterMode+ ? 'w-44 text-xxs text-secondary'+ : 'w-56 text-sm font-medium text-[oklch(0.27_0.022_345deg)] dark:text-[oklch(0.93_0.014_345deg)]'+ )}value={returnVariable}onChange={(event) => onChange(event.target.value)}placeholder="Output dataframe name"+ aria-label="Output dataframe name"spellCheck={false}ref={inputRef}/>diff --git a/frontend/src/scenes/notebooks/Nodes/components/NotebookJupyterCellOutput.tsx b/frontend/src/scenes/notebooks/Nodes/components/NotebookJupyterCellOutput.tsxindex 8f644c0ca3b4..c083731cdf04 100644--- a/frontend/src/scenes/notebooks/Nodes/components/NotebookJupyterCellOutput.tsx+++ b/frontend/src/scenes/notebooks/Nodes/components/NotebookJupyterCellOutput.tsx@@ -106,12 +106,12 @@ export function NotebookJupyterCellOutput({</OutputRow>) : null}{dataframeResult && isEditable ? (- <OutputRow className="MarkdownNotebook__jupyter-output-area--muted flex items-center gap-3">- <label className="flex items-center gap-1.5 text-xs">+ <OutputRow className="MarkdownNotebook__jupyter-output-area--muted flex flex-wrap items-center gap-3">+ <label className="flex items-center gap-1.5 text-xxs"><span>Saved as</span><inputtype="text"- className="w-48 px-1 font-mono bg-transparent rounded border border-transparent hover:border-primary focus:border-primary focus:outline-none text-primary"+ className="w-44 px-1 text-xxs font-mono bg-transparent rounded border border-transparent hover:border-primary focus:border-primary focus:outline-none text-secondary"value={returnVariable}onChange={(event) => onReturnVariableChange(event.target.value)}placeholder="Output dataframe name"diff --git a/frontend/src/scenes/notebooks/Notebook/MarkdownNotebookV2Renderer.tsx b/frontend/src/scenes/notebooks/Notebook/MarkdownNotebookV2Renderer.tsxindex 4ce4591227d6..77226d397505 100644--- a/frontend/src/scenes/notebooks/Notebook/MarkdownNotebookV2Renderer.tsx+++ b/frontend/src/scenes/notebooks/Notebook/MarkdownNotebookV2Renderer.tsx@@ -86,11 +86,16 @@ const NOTEBOOK_AI_PRESENCE_DEPARTURE_IDLE_MS = 5_000const NOTEBOOK_AI_PRESENCE_FADE_OUT_MS = 300type MarkdownNotebookV2Props = {+ collapsedToolbarContainer?: HTMLElement | nulldebugOpen?: booleanonDebugOpenChange?: (isOpen: boolean) => void}-export function MarkdownNotebookV2({ debugOpen, onDebugOpenChange }: MarkdownNotebookV2Props): JSX.Element {+export function MarkdownNotebookV2({+ collapsedToolbarContainer,+ debugOpen,+ onDebugOpenChange,+}: MarkdownNotebookV2Props): JSX.Element {const mountedNotebookLogic = useMountedLogic(notebookLogic)const {isEditable,@@ -803,7 +808,9 @@ export function MarkdownNotebookV2({ debugOpen, onDebugOpenChange }: MarkdownNotcanvasHeader={jupyterMode ? (<>- {isEditable ? <NotebookJupyterToolbar /> : null}+ {isEditable ? (+ <NotebookJupyterToolbar collapsedContainer={collapsedToolbarContainer} />+ ) : null}<NotebookVariablesBar /></>) : (diff --git a/frontend/src/scenes/notebooks/Notebook/Notebook.tsx b/frontend/src/scenes/notebooks/Notebook/Notebook.tsxindex efc8b44bb39d..fe23f8ff6e18 100644--- a/frontend/src/scenes/notebooks/Notebook/Notebook.tsx+++ b/frontend/src/scenes/notebooks/Notebook/Notebook.tsx@@ -31,6 +31,7 @@ import { notebookSettingsLogic } from './notebookSettingsLogic'let markdownNotebookMountCount = 0export type NotebookProps = NotebookLogicProps & {+ collapsedToolbarContainer?: HTMLElement | nullinitialContent?: JSONContenteditable?: booleanclassName?: string@@ -47,6 +48,7 @@ export function Notebook({cachedInsightsByShortId,cachedInlineQueryResultsByNodeId,className,+ collapsedToolbarContainer,markdownSourceOpen,onMarkdownSourceOpenChange,}: NotebookProps): JSX.Element {@@ -184,6 +186,7 @@ export function Notebook({<NotebookColumnLeft /><ErrorBoundary><MarkdownNotebookV2+ collapsedToolbarContainer={collapsedToolbarContainer}debugOpen={markdownSourceOpen}onDebugOpenChange={onMarkdownSourceOpenChange}/>diff --git a/frontend/src/scenes/notebooks/Notebook/NotebookJupyterToolbar.tsx b/frontend/src/scenes/notebooks/Notebook/NotebookJupyterToolbar.tsxindex 921d0b6f078f..8b8e6eda3cf5 100644--- a/frontend/src/scenes/notebooks/Notebook/NotebookJupyterToolbar.tsx+++ b/frontend/src/scenes/notebooks/Notebook/NotebookJupyterToolbar.tsx@@ -1,7 +1,17 @@import clsx from 'clsx'import { useActions, useValues } from 'kea'+import { useState } from 'react'+import { createPortal } from 'react-dom'-import { IconFastForward, IconKeyboard, IconPlayFilled, IconPlus, IconRefresh, IconStopFilled } from '@posthog/icons'+import {+ IconChevronDown,+ IconFastForward,+ IconKeyboard,+ IconPlayFilled,+ IconPlus,+ IconRefresh,+ IconStopFilled,+} from '@posthog/icons'import { LemonButton, LemonDivider, LemonSelect } from '@posthog/lemon-ui'import { useNotebookJupyterCommands, useNotebookJupyterStoreValue } from 'lib/components/MarkdownNotebook/jupyterMode'@@ -14,7 +24,12 @@ import { notebookLogic } from './notebookLogic'import { notebookRunLogic } from './notebookRunLogic'import { notebookSettingsLogic } from './notebookSettingsLogic'-export function NotebookJupyterToolbar(): JSX.Element | null {+export function NotebookJupyterToolbar({+ collapsedContainer,+}: {+ collapsedContainer?: HTMLElement | null+}): JSX.Element | null {+ const [isExpanded, setIsExpanded] = useState(false)const jupyter = useNotebookJupyterCommands()const { shortId, isShared } = useValues(notebookLogic)const { statusInfo, isStarting } = useValues(notebookKernelInfoLogic({ shortId, isShared }))@@ -57,39 +72,18 @@ export function NotebookJupyterToolbar(): JSX.Element | null {handler?.interrupt?.()}- return (+ const toolbar = (<><div- className="NotebookJupyterToolbar sticky top-0 z-10 flex flex-wrap items-center gap-0.5 py-1 mb-2 border rounded-xs bg-(--jupyter-paper-background)"+ className={clsx(+ 'NotebookJupyterToolbar flex max-w-full items-center gap-0.5 border rounded-xs bg-surface-primary',+ isExpanded ? 'sticky top-0 z-10 flex-wrap py-1 mb-2' : 'w-fit flex-nowrap',+ !isExpanded && !collapsedContainer && 'ml-auto mb-2'+ )}// Keeps focus, and with it command mode, on the selected cell while a button is clicked.onMouseDown={(event) => event.preventDefault()}data-attr="notebook-jupyter-toolbar">- <LemonButton- size="small"- icon={<IconPlus />}- tooltip="Insert a cell below (B)"- aria-label="Insert a cell below"- onClick={() => jupyter.insertCell(activeCellId, 'below', { edit: true })}- data-attr="notebook-jupyter-insert-cell"- />- <LemonButton- size="small"- icon={<IconArrowUp />}- tooltip="Move the selected cell up"- aria-label="Move the selected cell up"- disabledReason={activeCellKind ? undefined : noCellReason}- onClick={() => jupyter.executeCommand('move-up', activeCellId)}- />- <LemonButton- size="small"- icon={<IconArrowDown />}- tooltip="Move the selected cell down"- aria-label="Move the selected cell down"- disabledReason={activeCellKind ? undefined : noCellReason}- onClick={() => jupyter.executeCommand('move-down', activeCellId)}- />- <LemonDivider vertical className="mx-1 h-5" /><LemonButtonsize="small"icon={<IconPlayFilled />}@@ -122,70 +116,116 @@ export function NotebookJupyterToolbar(): JSX.Element | null {disabledReason={isRestartingKernel ? 'The kernel is restarting' : undefined}onClick={() => requestKernelRestart()}/>+ {isExpanded && (+ <>+ <LemonDivider vertical className="mx-1 h-5" />+ <LemonButton+ size="small"+ icon={<IconPlus />}+ tooltip="Insert a cell below (B)"+ aria-label="Insert a cell below"+ onClick={() => jupyter.insertCell(activeCellId, 'below', { edit: true })}+ data-attr="notebook-jupyter-insert-cell"+ />+ <LemonButton+ size="small"+ icon={<IconArrowUp />}+ tooltip="Move the selected cell up"+ aria-label="Move the selected cell up"+ disabledReason={activeCellKind ? undefined : noCellReason}+ onClick={() => jupyter.executeCommand('move-up', activeCellId)}+ />+ <LemonButton+ size="small"+ icon={<IconArrowDown />}+ tooltip="Move the selected cell down"+ aria-label="Move the selected cell down"+ disabledReason={activeCellKind ? undefined : noCellReason}+ onClick={() => jupyter.executeCommand('move-down', activeCellId)}+ />+ <LemonDivider vertical className="mx-1 h-5" />+ <LemonButton+ size="small"+ icon={<IconFastForward />}+ tooltip="Restart the kernel and run all cells"+ aria-label="Restart the kernel and run all cells"+ disabledReason={+ isRestartingKernel+ ? 'The kernel is restarting'+ : isRunAllRunning+ ? 'All cells are already running'+ : undefined+ }+ onClick={() => requestKernelRestart(true)}+ />+ <LemonDivider vertical className="mx-1 h-5" />+ <LemonSelect+ size="small"+ value={+ activeCellKind === 'code' ? 'code' : activeCellKind === 'markdown' ? 'markdown' : null+ }+ placeholder="-"+ options={[+ { value: 'code', label: 'Code' },+ { value: 'markdown', label: 'Markdown' },+ ]}+ disabledReason={+ activeCellKind === 'code' || activeCellKind === 'markdown'+ ? undefined+ : 'Select a code or markdown cell to change its type'+ }+ onChange={(value) => {+ if (value && value !== activeCellKind) {+ jupyter.executeCommand(+ value === 'markdown' ? 'to-markdown' : 'to-code',+ activeCellId+ )+ }+ }}+ data-attr="notebook-jupyter-cell-type"+ />+ <div className="flex-1" />+ <LemonButton+ size="small"+ icon={<IconKeyboard />}+ tooltip="Keyboard shortcuts (H)"+ aria-label="Keyboard shortcuts"+ onClick={() => jupyter.store.setShortcutsOpen(true)}+ data-attr="notebook-jupyter-shortcuts"+ />+ <LemonButton+ size="small"+ tooltip={`Kernel status: ${kernelStatus}. Click to ${showKernelInfo ? 'hide' : 'show'} kernel details.`}+ active={showKernelInfo}+ onClick={() => setShowKernelInfo(!showKernelInfo)}+ data-attr="notebook-jupyter-kernel-status"+ >+ <span className="flex items-center gap-2 text-xs text-secondary font-normal whitespace-nowrap">+ <span>Python 3 (sandbox)</span>+ <span+ aria-label={`Kernel ${kernelStatus.toLowerCase()}`}+ className={clsx(+ 'inline-block size-3 rounded-full border-2 border-current',+ isBusy && 'bg-current'+ )}+ />+ </span>+ </LemonButton>+ </>+ )}<LemonButtonsize="small"- icon={<IconFastForward />}- tooltip="Restart the kernel and run all cells"- aria-label="Restart the kernel and run all cells"- disabledReason={- isRestartingKernel- ? 'The kernel is restarting'- : isRunAllRunning- ? 'All cells are already running'- : undefined- }- onClick={() => requestKernelRestart(true)}- />- <LemonDivider vertical className="mx-1 h-5" />- <LemonSelect- size="small"- value={activeCellKind === 'code' ? 'code' : activeCellKind === 'markdown' ? 'markdown' : null}- placeholder="-"- options={[- { value: 'code', label: 'Code' },- { value: 'markdown', label: 'Markdown' },- ]}- disabledReason={- activeCellKind === 'code' || activeCellKind === 'markdown'- ? undefined- : 'Select a code or markdown cell to change its type'- }- onChange={(value) => {- if (value && value !== activeCellKind) {- jupyter.executeCommand(value === 'markdown' ? 'to-markdown' : 'to-code', activeCellId)- }- }}- data-attr="notebook-jupyter-cell-type"- />- <div className="flex-1" />- <LemonButton- size="small"- icon={<IconKeyboard />}- tooltip="Keyboard shortcuts (H)"- aria-label="Keyboard shortcuts"- onClick={() => jupyter.store.setShortcutsOpen(true)}- data-attr="notebook-jupyter-shortcuts"+ icon={<IconChevronDown className={isExpanded ? 'rotate-180' : undefined} />}+ tooltip={isExpanded ? 'Show fewer notebook controls' : 'Show more notebook controls'}+ aria-label={isExpanded ? 'Show fewer notebook controls' : 'Show more notebook controls'}+ aria-expanded={isExpanded}+ onClick={() => setIsExpanded(!isExpanded)}+ data-attr="notebook-jupyter-toggle-toolbar"/>- <LemonButton- size="small"- tooltip={`Kernel status: ${kernelStatus}. Click to ${showKernelInfo ? 'hide' : 'show'} kernel details.`}- active={showKernelInfo}- onClick={() => setShowKernelInfo(!showKernelInfo)}- data-attr="notebook-jupyter-kernel-status"- >- <span className="flex items-center gap-2 text-xs text-secondary font-normal whitespace-nowrap">- <span>Python 3 (sandbox)</span>- <span- aria-label={`Kernel ${kernelStatus.toLowerCase()}`}- className={clsx(- 'inline-block size-3 rounded-full border-2 border-current',- isBusy && 'bg-current'- )}- />- </span>- </LemonButton></div><NotebookJupyterShortcutsModal /></>)++ return !isExpanded && collapsedContainer ? createPortal(toolbar, collapsedContainer) : toolbar}diff --git a/frontend/src/scenes/notebooks/NotebookPanel/NotebookPanel.tsx b/frontend/src/scenes/notebooks/NotebookPanel/NotebookPanel.tsxindex b60b3d7c31c8..9aa2362189b7 100644--- a/frontend/src/scenes/notebooks/NotebookPanel/NotebookPanel.tsx+++ b/frontend/src/scenes/notebooks/NotebookPanel/NotebookPanel.tsx@@ -1,6 +1,7 @@import './NotebookPanel.scss'import { useActions, useValues } from 'kea'+import { useState } from 'react'import { IconExpand45 } from '@posthog/icons'import { Link } from '@posthog/lemon-ui'@@ -22,6 +23,7 @@ import { NotebookPanelDropzone } from './NotebookPanelDropzone'import { notebookPanelLogic } from './notebookPanelLogic'export function NotebookPanel(): JSX.Element | null {+ const [collapsedToolbarContainer, setCollapsedToolbarContainer] = useState<HTMLDivElement | null>(null)const { selectedNotebook, droppedResource } = useValues(notebookPanelLogic)const { selectNotebook, closeSidePanel } = useActions(notebookPanelLogic)const { notebook } = useValues(notebookLogic({ shortId: selectedNotebook, target: NotebookTarget.Popover }))@@ -38,7 +40,7 @@ export function NotebookPanel(): JSX.Element | null {{!droppedResource ? (<><SidePanelContentContainer>- <SidePanelPaneHeader title="Notebooks">+ <SidePanelPaneHeader title="Notebooks" className="h-auto min-h-10 flex-wrap gap-y-1"><div className="flex gap-1 overflow-hidden"><NotebookListMiniselectedNotebookId={selectedNotebook}@@ -52,7 +54,8 @@ export function NotebookPanel(): JSX.Element | null {</div><div className="flex-1" />- <div className="flex items-center gap-1">+ <div className="flex flex-wrap items-center justify-end gap-1 ml-auto">+ <div ref={setCollapsedToolbarContainer} className="shrink-0 empty:hidden" />{selectedNotebook && <NotebookPresence shortId={selectedNotebook} />}<NotebookMenu shortId={selectedNotebook} inPanel />{contentWidthHasEffect && <NotebookExpandButton size="small" inPanel={true} />}@@ -70,7 +73,12 @@ export function NotebookPanel(): JSX.Element | null {</Link></div></SidePanelPaneHeader>- <Notebook key={selectedNotebook} shortId={selectedNotebook} editable={editable} />+ <Notebook+ key={selectedNotebook}+ shortId={selectedNotebook}+ editable={editable}+ collapsedToolbarContainer={collapsedToolbarContainer}+ /></SidePanelContentContainer></>) : null}diff --git a/frontend/src/scenes/notebooks/NotebookScene.tsx b/frontend/src/scenes/notebooks/NotebookScene.tsxindex 26e00e8d8a70..d3189f31cd9d 100644--- a/frontend/src/scenes/notebooks/NotebookScene.tsx+++ b/frontend/src/scenes/notebooks/NotebookScene.tsx@@ -52,6 +52,7 @@ export const scene: SceneExport<NotebookSceneLogicProps> = {}export function NotebookScene(): JSX.Element {+ const [collapsedToolbarContainer, setCollapsedToolbarContainer] = useState<HTMLDivElement | null>(null)const { notebookId, loading } = useValues(notebookSceneLogic)const { createNotebook } = useActions(notebookSceneLogic)const { notebook, accessDeniedToNotebook } = useValues(@@ -142,7 +143,7 @@ export function NotebookScene(): JSX.Element {resourceType={{ type: 'notebook' }}/>)}- <div className={cn('flex items-center justify-between', sceneMenuBarEnabled && 'mt-2')}>+ <div className={cn('flex flex-wrap gap-2 items-center justify-between', sceneMenuBarEnabled && 'mt-2')}><div className="flex gap-2 items-center">{!todayRailEnabled && <SceneBreadcrumbBackButton />}{isTemplate && <LemonTag type="highlight">TEMPLATE</LemonTag>}@@ -153,7 +154,8 @@ export function NotebookScene(): JSX.Element {</BindLogic></div>- <div className="flex gap-2 items-center">+ <div className="flex flex-wrap gap-2 items-center justify-end ml-auto">+ <div ref={setCollapsedToolbarContainer} className="shrink-0 empty:hidden" /><NotebookSyncInfo shortId={notebookId} /><NotebookPresence shortId={notebookId} />@@ -202,6 +204,7 @@ export function NotebookScene(): JSX.Element {</BindLogic><Notebook+ collapsedToolbarContainer={collapsedToolbarContainer}key={notebookId}shortId={notebookId}editable={!isTemplate}