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
fix: show 'Clear Output' cell action when console has output (#3650)
Shahmir Varqha59625f03a966
diff --git a/frontend/src/components/editor/Cell.tsx b/frontend/src/components/editor/Cell.tsxindex d9996f3b8b..2444bcc2c8 100644--- a/frontend/src/components/editor/Cell.tsx+++ b/frontend/src/components/editor/Cell.tsx@@ -373,6 +373,7 @@ const CellComponent = (};const hasOutput = !isOutputEmpty(output);+ const hasConsoleOutput = consoleOutputs.length > 0;const cellOutput = userConfig.display.cell_output;const hasOutputAbove = hasOutput && cellOutput === "above";@@ -588,6 +589,7 @@ const CellComponent = (status={status}getEditorView={getEditorView}hasOutput={hasOutput}+ hasConsoleOutput={hasConsoleOutput}name={name}><SortableCell@@ -617,6 +619,7 @@ const CellComponent = (cellConfig={cellConfig}needsRun={needsRun}hasOutput={hasOutput}+ hasConsoleOutput={hasConsoleOutput}cellActionDropdownRef={cellActionDropdownRef}cellId={cellId}name={name}@@ -733,6 +736,7 @@ interface CellToolbarProps {cellConfig: CellConfig;needsRun: boolean;hasOutput: boolean;+ hasConsoleOutput: boolean;cellActionDropdownRef: React.RefObject<CellActionsDropdownHandle>;cellId: CellId;name: string;@@ -747,6 +751,7 @@ const CellToolbar = ({cellConfig,needsRun,hasOutput,+ hasConsoleOutput,onRun,cellActionDropdownRef,cellId,@@ -777,6 +782,7 @@ const CellToolbar = ({name={name}config={cellConfig}hasOutput={hasOutput}+ hasConsoleOutput={hasConsoleOutput}><ToolbarItemvariant={"green"}diff --git a/frontend/src/components/editor/actions/useCellActionButton.tsx b/frontend/src/components/editor/actions/useCellActionButton.tsxindex 96357108dc..5ada9a1cb6 100644--- a/frontend/src/components/editor/actions/useCellActionButton.tsx+++ b/frontend/src/components/editor/actions/useCellActionButton.tsx@@ -62,6 +62,7 @@ export interface CellActionButtonPropscellId: CellId;status: RuntimeState;hasOutput: boolean;+ hasConsoleOutput: boolean;getEditorView: () => EditorView | null;}@@ -97,7 +98,15 @@ export function useCellActionButtons({ cell }: Props) {return [];}- const { cellId, config, getEditorView, name, hasOutput, status } = cell;+ const {+ cellId,+ config,+ getEditorView,+ name,+ hasOutput,+ hasConsoleOutput,+ status,+ } = cell;const toggleDisabled = async () => {const newConfig = { disabled: !config.disabled };@@ -242,7 +251,7 @@ export function useCellActionButtons({ cell }: Props) {{icon: <XCircleIcon size={13} strokeWidth={1.5} />,label: "Clear output",- hidden: !hasOutput,+ hidden: !(hasOutput || hasConsoleOutput),handle: () => {clearCellOutput({ cellId });},diff --git a/frontend/src/core/cells/focus.ts b/frontend/src/core/cells/focus.tsindex c83071fe56..b76b1371aa 100644--- a/frontend/src/core/cells/focus.ts+++ b/frontend/src/core/cells/focus.ts@@ -30,6 +30,7 @@ export const lastFocusedCellAtom = atom<{status: RuntimeState;getEditorView: () => EditorView | null;hasOutput: boolean;+ hasConsoleOutput: boolean;} | null>((get) => {const cellId = get(lastFocusedCellIdAtom);if (!cellId) {@@ -66,5 +67,6 @@ function cellFocusDetails(cellId: CellId, notebookState: NotebookState) {status: runtime ? runtime.status : "idle",getEditorView: getEditorView,hasOutput: runtime?.output != null,+ hasConsoleOutput: runtime?.consoleOutputs != null,};}