A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
improvement: add tooltips to some hide/show code, fix markdown when cell output is below (#3026)
Myles Scolnickc1f3512e20df
diff --git a/frontend/src/components/editor/Cell.tsx b/frontend/src/components/editor/Cell.tsxindex 6792a2abd2..a643054b53 100644--- a/frontend/src/components/editor/Cell.tsx+++ b/frontend/src/components/editor/Cell.tsx@@ -416,6 +416,7 @@ const CellComponent = (/>{isMarkdownCodeHidden && (<HideCodeButton+ tooltip="Edit markdown"className="z-20 relative -top-3"onClick={temporarilyShowCode}/>@@ -564,6 +565,8 @@ const CellComponent = (/>);+ const cellOutput = userConfig.display.cell_output;+return (<CellActionsContextMenucellId={cellId}@@ -584,8 +587,8 @@ const CellComponent = (title={cellTitle()}><div className={className} id={HTMLId} ref={cellContainerRef}>- {userConfig.display.cell_output === "above" && outputArea}- <div className={cn("tray", isMarkdownCodeHidden && "!border-t-0")}>+ {cellOutput === "above" && outputArea}+ <div className={cn("tray")} data-hidden={isMarkdownCodeHidden}><div className="absolute right-2 -top-4 z-10"><CellToolbaredited={edited}@@ -604,7 +607,8 @@ const CellComponent = (<divclassName={cn("absolute flex flex-col gap-[2px] justify-center h-full left-[-34px] z-20",- isMarkdownCodeHidden && "-top-7",+ isMarkdownCodeHidden && cellOutput === "above" && "-top-7",+ isMarkdownCodeHidden && cellOutput === "below" && "-bottom-10",isMarkdownCodeHidden && isCellButtonsInline && "-left-[3.8rem]",)}>@@ -667,7 +671,7 @@ const CellComponent = ()}</div></div>- {userConfig.display.cell_output === "below" && outputArea}+ {cellOutput === "below" && outputArea}<ConsoleOutputconsoleOutputs={consoleOutputs}stale={consoleOutputStale}diff --git a/frontend/src/components/editor/ai/ai-completion-editor.tsx b/frontend/src/components/editor/ai/ai-completion-editor.tsxindex 602ba8ec3d..128c2ba3ea 100644--- a/frontend/src/components/editor/ai/ai-completion-editor.tsx+++ b/frontend/src/components/editor/ai/ai-completion-editor.tsx@@ -30,6 +30,7 @@ const Original = CodeMirrorMerge.Original;const Modified = CodeMirrorMerge.Modified;interface Props {+ className?: string;currentCode: string;currentLanguageAdapter: LanguageAdapterType | undefined;initialPrompt: string | undefined;@@ -51,6 +52,7 @@ const baseExtensions = [customPythonLanguageSupport(), EditorView.lineWrapping];* This shows a left/right split with the original and modified code.*/export const AiCompletionEditor: React.FC<Props> = ({+ className,onChange,initialPrompt,currentLanguageAdapter,@@ -116,7 +118,12 @@ export const AiCompletionEditor: React.FC<Props> = ({const { theme } = useTheme();return (- <div className="flex flex-col w-full rounded-[inherit] overflow-hidden">+ <div+ className={cn(+ "flex flex-col w-full rounded-[inherit] overflow-hidden",+ className,+ )}+ ><divclassName={cn("flex items-center gap-2 border-b px-3 transition-all rounded-[inherit] rounded-b-none duration-300 overflow-hidden",diff --git a/frontend/src/components/editor/cell/code/cell-editor.tsx b/frontend/src/components/editor/cell/code/cell-editor.tsxindex 47954db1ea..6004e8df26 100644--- a/frontend/src/components/editor/cell/code/cell-editor.tsx+++ b/frontend/src/components/editor/cell/code/cell-editor.tsx@@ -375,6 +375,7 @@ const CellEditorInternal = ({{/* Completely hide the editor and icons when markdown is hidden. If just hidden, display. */}{!isMarkdown && hidden && (<HideCodeButton+ tooltip="Edit code"className="absolute inset-0 z-10"onClick={temporarilyShowCode}/>diff --git a/frontend/src/components/editor/code/readonly-python-code.tsx b/frontend/src/components/editor/code/readonly-python-code.tsxindex 11a416e01d..7a609506e5 100644--- a/frontend/src/components/editor/code/readonly-python-code.tsx+++ b/frontend/src/components/editor/code/readonly-python-code.tsx@@ -13,6 +13,7 @@ import { cn } from "@/utils/cn";import { customPythonLanguageSupport } from "@/core/codemirror/language/python";import { sql } from "@codemirror/lang-sql";import { copyToClipboard } from "@/utils/copy";+import { Tooltip } from "@/components/ui/tooltip";const pythonExtensions = [customPythonLanguageSupport(),@@ -46,10 +47,16 @@ export const ReadonlyCode = memo(className,)}>- {hideCode && <HideCodeButton onClick={() => setHideCode(false)} />}+ {hideCode && (+ <HideCodeButton+ tooltip="Show code"+ onClick={() => setHideCode(false)}+ />+ )}{!hideCode && (<div className="absolute top-0 right-0 my-1 mx-2 z-10 hover-action flex gap-2"><CopyButton text={code} />+<EyeCloseButton onClick={() => setHideCode(true)} /></div>)}@@ -76,32 +83,39 @@ const CopyButton = (props: { text: string }) => {});return (- <Button onClick={copy} size="xs" className="py-0" variant="secondary">- <CopyIcon size={14} strokeWidth={1.5} />- </Button>+ <Tooltip content="Copy code" usePortal={false}>+ <Button onClick={copy} size="xs" className="py-0" variant="secondary">+ <CopyIcon size={14} strokeWidth={1.5} />+ </Button>+ </Tooltip>);};const EyeCloseButton = (props: { onClick: () => void }) => {return (- <Button- onClick={props.onClick}- size="xs"- className="py-0"- variant="secondary"- >- <EyeOffIcon size={14} strokeWidth={1.5} />- </Button>+ <Tooltip content="Hide code" usePortal={false}>+ <Button+ onClick={props.onClick}+ size="xs"+ className="py-0"+ variant="secondary"+ >+ <EyeOffIcon size={14} strokeWidth={1.5} />+ </Button>+ </Tooltip>);};export const HideCodeButton = (props: {+ tooltip?: string;className?: string;onClick: () => void;}) => {return (<div className={props.className} onClick={props.onClick}>- <EyeIcon className="hover-action w-5 h-5 text-muted-foreground cursor-pointer absolute left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2 opacity-80 hover:opacity-100" />+ <Tooltip usePortal={false} content={props.tooltip}>+ <EyeIcon className="hover-action w-5 h-5 text-muted-foreground cursor-pointer absolute left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2 opacity-80 hover:opacity-100 z-20" />+ </Tooltip></div>);};diff --git a/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx b/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsxindex c6ab82981e..c0c98b7d45 100644--- a/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx+++ b/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx@@ -258,7 +258,7 @@ const VerticalCell = memo(// Kiosk and not presentingconst kioskFull = kiosk && mode !== "present";- const className = cn("Cell", "hover-actions-parent", {+ const className = cn("Cell", "hover-actions-parent empty:invisible", {published: !showCode && !kioskFull,interactive: mode === "edit","has-error": errored,diff --git a/frontend/src/css/app/Cell.css b/frontend/src/css/app/Cell.cssindex 064d4919e0..0935b4fcdc 100644--- a/frontend/src/css/app/Cell.css+++ b/frontend/src/css/app/Cell.css@@ -80,6 +80,14 @@}}+ > [data-hidden="true"] ~ * {+ border-top: none;+ }++ > * ~ [data-hidden="true"] {+ border-top: none;+ }+/* Stale styles for Cell */&.stale,&.disabled.stale {