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.

feature: queue stack on the left side-bar (#2069)

Myles Scolnickd1437c09c161
diff --git a/frontend/src/components/editor/chrome/wrapper/sidebar.tsx b/frontend/src/components/editor/chrome/wrapper/sidebar.tsx
index a5ee786f8d..215cc33d63 100644
--- a/frontend/src/components/editor/chrome/wrapper/sidebar.tsx
+++ b/frontend/src/components/editor/chrome/wrapper/sidebar.tsx
@@ -7,6 +7,8 @@ import { useChromeActions, useChromeState } from "../state";
import { Tooltip } from "@/components/ui/tooltip";
import { FeedbackButton } from "../components/feedback-button";
import { type PanelDescriptor, PANELS } from "../types";
+import { notebookQueuedOrRunningCountAtom } from "@/core/cells/cells";
+import { useAtomValue } from "jotai";
export const Sidebar: React.FC = () => {
const { selectedPanel } = useChromeState();
@@ -21,7 +23,7 @@ export const Sidebar: React.FC = () => {
);
return (
- <div className="h-full py-4 px-1 flex flex-col items-start text-muted-foreground text-md select-none no-print text-sm z-50 dark:bg-background print:hidden">
+ <div className="h-full pt-4 pb-1 px-1 flex flex-col items-start text-muted-foreground text-md select-none no-print text-sm z-50 dark:bg-background print:hidden">
{sidebarItems.map((p) => (
<SidebarItem
key={p.type}
@@ -32,12 +34,27 @@ export const Sidebar: React.FC = () => {
{renderIcon(p)}
</SidebarItem>
))}
-
<FeedbackButton>
<SidebarItem tooltip="Send feedback!" selected={false}>
<MessageCircleQuestionIcon className="h-5 w-5" />
</SidebarItem>
</FeedbackButton>
+ <div className="flex-1" />
+ <QueuedOrRunningStack />
+ </div>
+ );
+};
+
+const QueuedOrRunningStack = () => {
+ const count = useAtomValue(notebookQueuedOrRunningCountAtom);
+ return (
+ <div className="flex flex-col-reverse gap-[1px] overflow-hidden">
+ {Array.from({ length: count }).map((_, index) => (
+ <div
+ key={index.toString()}
+ className="flex-shrink-0 h-1 w-2 bg-[var(--grass-6)] border border-[var(--grass-7)]"
+ />
+ ))}
</div>
);
};
diff --git a/frontend/src/core/cells/cells.ts b/frontend/src/core/cells/cells.ts
index 6d9900211a..4e1f0a26b8 100644
--- a/frontend/src/core/cells/cells.ts
+++ b/frontend/src/core/cells/cells.ts
@@ -29,7 +29,7 @@ import { deserializeBase64, deserializeJson } from "@/utils/json/base64";
import { historyField } from "@codemirror/commands";
import { clamp } from "@/utils/math";
import type { LayoutState } from "../layout/layout";
-import { notebookIsRunning } from "./utils";
+import { notebookIsRunning, notebookQueueOrRunningCount } from "./utils";
import {
splitEditor,
updateEditorCodeFromPython,
@@ -1015,6 +1015,9 @@ export const useCellDataAtoms = () => useAtom(cellDataAtoms);
export const notebookIsRunningAtom = atom((get) =>
notebookIsRunning(get(notebookAtom)),
);
+export const notebookQueuedOrRunningCountAtom = atom((get) =>
+ notebookQueueOrRunningCount(get(notebookAtom)),
+);
/**
* Get the editor views for all cells.
diff --git a/frontend/src/core/cells/utils.ts b/frontend/src/core/cells/utils.ts
index b1d4c5acc3..727c1894e4 100644
--- a/frontend/src/core/cells/utils.ts
+++ b/frontend/src/core/cells/utils.ts
@@ -16,6 +16,11 @@ 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",
+ ).length;
+}
export function notebookNeedsSave(
state: NotebookState,