Skip to content

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.

Handle running indicator when only scratchpad is active (#8750)

Trevor Manz15306cad7071
diff --git a/frontend/src/components/editor/header/status.tsx b/frontend/src/components/editor/header/status.tsx
index 8c0c678e46..28d91ea24d 100644
--- a/frontend/src/components/editor/header/status.tsx
+++ b/frontend/src/components/editor/header/status.tsx
@@ -5,6 +5,7 @@ import { HourglassIcon, LockIcon, UnlinkIcon } from "lucide-react";
import React from "react";
import { Tooltip } from "@/components/ui/tooltip";
import { notebookScrollToRunning } from "@/core/cells/actions";
+import { onlyScratchpadIsRunningAtom } from "@/core/cells/cells";
import { viewStateAtom } from "@/core/mode";
import { type ConnectionStatus, WebSocketState } from "@/core/websocket/types";
import { cn } from "@/utils/cn";
@@ -52,17 +53,24 @@ const LockedIcon = () => (
</Tooltip>
);
-const RunningIcon = () => (
- <Tooltip content="Jump to running cell" side="right">
- <div
- className={topLeftStatus}
- data-testid="loading-indicator"
- onClick={notebookScrollToRunning}
- >
- <HourglassIcon className="running-app-icon" size={30} strokeWidth={1} />
- </div>
- </Tooltip>
-);
+const RunningIcon = () => {
+ const scratchpadOnly = useAtomValue(onlyScratchpadIsRunningAtom);
+ const tooltip = scratchpadOnly
+ ? "Scratchpad is running"
+ : "Jump to running cell";
+
+ return (
+ <Tooltip content={tooltip} side="right">
+ <div
+ className={topLeftStatus}
+ data-testid="loading-indicator"
+ onClick={scratchpadOnly ? undefined : notebookScrollToRunning}
+ >
+ <HourglassIcon className="running-app-icon" size={30} strokeWidth={1} />
+ </div>
+ </Tooltip>
+ );
+};
const NoiseBackground = () => (
<>
diff --git a/frontend/src/core/cells/cells.ts b/frontend/src/core/cells/cells.ts
index fd21b531e1..4919f10052 100644
--- a/frontend/src/core/cells/cells.ts
+++ b/frontend/src/core/cells/cells.ts
@@ -1640,6 +1640,12 @@ export const cellsRuntimeAtom = atom((get) => get(notebookAtom).cellRuntime);
export const notebookIsRunningAtom = atom((get) =>
notebookIsRunning(get(notebookAtom)),
);
+export const onlyScratchpadIsRunningAtom = atom((get) => {
+ const { cellRuntime } = get(notebookAtom);
+ return Object.entries(cellRuntime).every(
+ ([id, rt]) => rt.status !== "running" || id === SCRATCH_CELL_ID,
+ );
+});
export const notebookQueuedOrRunningCountAtom = atom((get) =>
notebookQueueOrRunningCount(get(notebookAtom)),
);
diff --git a/frontend/src/core/cells/utils.ts b/frontend/src/core/cells/utils.ts
index 8e7d7988aa..b2eaad1961 100644
--- a/frontend/src/core/cells/utils.ts
+++ b/frontend/src/core/cells/utils.ts
@@ -11,6 +11,7 @@ export function notebookIsRunning(state: NotebookState) {
(cell) => cell.status === "running",
);
}
+
export function notebookQueueOrRunningCount(state: NotebookState) {
return Object.values(state.cellRuntime).filter(
(cell) => cell.status === "running" || cell.status === "queued",