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.

fix: Sticky hourglass loading indicator (#5052)

Wasim51b9d6ad1603
diff --git a/frontend/src/components/editor/header/status.tsx b/frontend/src/components/editor/header/status.tsx
index 650c8bb270..19b2fba518 100644
--- a/frontend/src/components/editor/header/status.tsx
+++ b/frontend/src/components/editor/header/status.tsx
@@ -1,7 +1,10 @@
/* Copyright 2024 Marimo. All rights reserved. */
import { Tooltip } from "@/components/ui/tooltip";
import { notebookScrollToRunning } from "@/core/cells/actions";
+import { viewStateAtom } from "@/core/mode";
import { type ConnectionStatus, WebSocketState } from "@/core/websocket/types";
+import { cn } from "@/utils/cn";
+import { useAtomValue } from "jotai";
import { UnlinkIcon, HourglassIcon, LockIcon } from "lucide-react";
import React from "react";
@@ -9,22 +12,28 @@ export const StatusOverlay: React.FC<{
connection: ConnectionStatus;
isRunning: boolean;
}> = ({ connection, isRunning }) => {
+ const { mode } = useAtomValue(viewStateAtom);
+ const isClosed = connection.state === WebSocketState.CLOSED;
+ const isOpen = connection.state === WebSocketState.OPEN;
+
return (
<>
- {connection.state === WebSocketState.OPEN && isRunning && <RunningIcon />}
- {connection.state === WebSocketState.CLOSED &&
- !connection.canTakeover && <NoiseBackground />}
- {connection.state === WebSocketState.CLOSED &&
- !connection.canTakeover && <DisconnectedIcon />}
- {connection.state === WebSocketState.CLOSED && connection.canTakeover && (
- <LockedIcon />
- )}
+ {isClosed && !connection.canTakeover && <NoiseBackground />}
+ <div
+ className={cn(
+ "z-50 top-4 left-4",
+ mode === "read" ? "fixed" : "absolute",
+ )}
+ >
+ {isOpen && isRunning && <RunningIcon />}
+ {isClosed && !connection.canTakeover && <DisconnectedIcon />}
+ {isClosed && connection.canTakeover && <LockedIcon />}
+ </div>
</>
);
};
-const topLeftStatus =
- "absolute top-4 left-4 m-0 flex items-center space-x-3 min-h-[28px] no-print pointer-events-auto z-50 hover:cursor-pointer";
+const topLeftStatus = "no-print pointer-events-auto hover:cursor-pointer";
const DisconnectedIcon = () => (
<Tooltip content="App disconnected">
@@ -43,7 +52,7 @@ const LockedIcon = () => (
);
const RunningIcon = () => (
- <Tooltip content={"Jump to running cell"} side="right">
+ <Tooltip content="Jump to running cell" side="right">
<div
className={topLeftStatus}
data-testid="loading-indicator"
diff --git a/marimo/_smoke_tests/issues/4744-fixed-loading-indicator.py b/marimo/_smoke_tests/issues/4744-fixed-loading-indicator.py
new file mode 100644
index 0000000000..fad7a8d693
--- /dev/null
+++ b/marimo/_smoke_tests/issues/4744-fixed-loading-indicator.py
@@ -0,0 +1,34 @@
+import marimo
+
+__generated_with = "0.13.11"
+app = marimo.App()
+
+
+def _():
+ import marimo as mo
+ return (mo,)
+
+
[email protected](hide_code=True)
+def _(mo):
+ mo.md(r"""When viewing this notebook in run mode, the hourglass loading indicator should be stickied to the top left even when scrolling down.""")
+ return
+
+
+def _(mo):
+ mo.md("hello world" * 10000)
+ return
+
+
+def _():
+ import time
+
+ time.sleep(100)
+ return
+
+
+if __name__ == "__main__":
+ app.run()