From b6ca9a71d554be5ccf62941558195f474eb2d1f3 Mon Sep 17 00:00:00 2001 From: dylan Date: Thu, 16 Oct 2025 16:23:09 -0700 Subject: [PATCH 1/4] fix: hide invalid options on setup cell context menu --- .../editor/actions/useCellActionButton.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/editor/actions/useCellActionButton.tsx b/frontend/src/components/editor/actions/useCellActionButton.tsx index 4a5ba0626e8..f9c34ea3b5b 100644 --- a/frontend/src/components/editor/actions/useCellActionButton.tsx +++ b/frontend/src/components/editor/actions/useCellActionButton.tsx @@ -136,6 +136,8 @@ export function useCellActionButtons({ cell, closePopover }: Props) { } }; + const isSetupCell = cellId === "setup"; + // Actions const actions: ActionButton[][] = [ [ @@ -181,6 +183,7 @@ export function useCellActionButtons({ cell, closePopover }: Props) { onEnterKey={() => closePopover?.()} /> ), + hidden: isSetupCell, }, { icon: , @@ -254,6 +257,7 @@ export function useCellActionButtons({ cell, closePopover }: Props) { /> ), handle: toggleDisabled, + hidden: isSetupCell, }, { icon: , @@ -282,6 +286,7 @@ export function useCellActionButtons({ cell, closePopover }: Props) { keepCodeAsIs: false, }); }, + hidden: isSetupCell, }, { icon: , @@ -297,6 +302,7 @@ export function useCellActionButtons({ cell, closePopover }: Props) { keepCodeAsIs: false, }); }, + hidden: isSetupCell, }, { icon: , @@ -309,6 +315,7 @@ export function useCellActionButtons({ cell, closePopover }: Props) { maybeAddMarimoImport({ autoInstantiate, createNewCell: createCell }); toggleToLanguage(editorView, "python", { force: true }); }, + hidden: isSetupCell, }, ], @@ -324,6 +331,7 @@ export function useCellActionButtons({ cell, closePopover }: Props) { label: "Create cell above", hotkey: "cell.createAbove", handle: () => createCell({ cellId, before: true }), + hidden: isSetupCell, }, { icon: ( @@ -341,26 +349,28 @@ export function useCellActionButtons({ cell, closePopover }: Props) { label: "Move cell up", hotkey: "cell.moveUp", handle: () => moveCell({ cellId, before: true }), + hidden: isSetupCell, }, { icon: , label: "Move cell down", hotkey: "cell.moveDown", handle: () => moveCell({ cellId, before: false }), + hidden: isSetupCell, }, { icon: , label: "Move cell left", hotkey: "cell.moveLeft", handle: () => moveCell({ cellId, direction: "left" }), - hidden: appWidth !== "columns", + hidden: appWidth !== "columns" || isSetupCell, }, { icon: , label: "Move cell right", hotkey: "cell.moveRight", handle: () => moveCell({ cellId, direction: "right" }), - hidden: appWidth !== "columns", + hidden: appWidth !== "columns" || isSetupCell, }, { icon: , @@ -369,6 +379,7 @@ export function useCellActionButtons({ cell, closePopover }: Props) { // When using the cell menu, likely the user doesn't want to scroll // and instead just wants to get the cell out of the way handle: () => sendToTop({ cellId, scroll: false }), + hidden: isSetupCell, }, { icon: , @@ -377,6 +388,7 @@ export function useCellActionButtons({ cell, closePopover }: Props) { // When using the cell menu, likely the user doesn't want to scroll // and instead just wants to get the cell out of the way handle: () => sendToBottom({ cellId, scroll: false }), + hidden: isSetupCell, }, { icon: , @@ -384,6 +396,7 @@ export function useCellActionButtons({ cell, closePopover }: Props) { hotkey: "cell.addColumnBreakpoint", hidden: appWidth !== "columns", handle: () => addColumnBreakpoint({ cellId }), + hidden: isSetupCell, }, ], From 2bfefe330504dcecb5fa6ece58ee774c23c7fb27 Mon Sep 17 00:00:00 2001 From: dylan Date: Thu, 16 Oct 2025 18:32:44 -0700 Subject: [PATCH 2/4] comments: use const --- .../src/components/editor/actions/useCellActionButton.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/editor/actions/useCellActionButton.tsx b/frontend/src/components/editor/actions/useCellActionButton.tsx index f9c34ea3b5b..d16c474022d 100644 --- a/frontend/src/components/editor/actions/useCellActionButton.tsx +++ b/frontend/src/components/editor/actions/useCellActionButton.tsx @@ -39,7 +39,7 @@ import { Switch } from "@/components/ui/switch"; import { toast } from "@/components/ui/use-toast"; import { aiCompletionCellAtom } from "@/core/ai/state"; import { maybeAddMarimoImport } from "@/core/cells/add-missing-import"; -import { hasOnlyOneCellAtom, useCellActions } from "@/core/cells/cells"; +import { hasOnlyOneCellAtom, useCellActions, SETUP_CELL_ID } from "@/core/cells/cells"; import type { CellId } from "@/core/cells/ids"; import type { CellData } from "@/core/cells/types"; import { formatEditorViews } from "@/core/codemirror/format"; @@ -136,7 +136,7 @@ export function useCellActionButtons({ cell, closePopover }: Props) { } }; - const isSetupCell = cellId === "setup"; + const isSetupCell = cellId === SETUP_CELL_ID; // Actions const actions: ActionButton[][] = [ From a1c50e15f2e17bf93c17b32236e4020453f394de Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Oct 2025 01:34:41 +0000 Subject: [PATCH 3/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../src/components/editor/actions/useCellActionButton.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/editor/actions/useCellActionButton.tsx b/frontend/src/components/editor/actions/useCellActionButton.tsx index d16c474022d..64b551b38e3 100644 --- a/frontend/src/components/editor/actions/useCellActionButton.tsx +++ b/frontend/src/components/editor/actions/useCellActionButton.tsx @@ -39,7 +39,11 @@ import { Switch } from "@/components/ui/switch"; import { toast } from "@/components/ui/use-toast"; import { aiCompletionCellAtom } from "@/core/ai/state"; import { maybeAddMarimoImport } from "@/core/cells/add-missing-import"; -import { hasOnlyOneCellAtom, useCellActions, SETUP_CELL_ID } from "@/core/cells/cells"; +import { + hasOnlyOneCellAtom, + SETUP_CELL_ID, + useCellActions, +} from "@/core/cells/cells"; import type { CellId } from "@/core/cells/ids"; import type { CellData } from "@/core/cells/types"; import { formatEditorViews } from "@/core/codemirror/format"; From 71168cac3eeb2ae45b286406e514cfec60cc4bf6 Mon Sep 17 00:00:00 2001 From: dylan Date: Fri, 17 Oct 2025 09:02:19 -0700 Subject: [PATCH 4/4] fix: double hidden --- frontend/src/components/editor/actions/useCellActionButton.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/components/editor/actions/useCellActionButton.tsx b/frontend/src/components/editor/actions/useCellActionButton.tsx index 64b551b38e3..c5f6e5154de 100644 --- a/frontend/src/components/editor/actions/useCellActionButton.tsx +++ b/frontend/src/components/editor/actions/useCellActionButton.tsx @@ -398,9 +398,8 @@ export function useCellActionButtons({ cell, closePopover }: Props) { icon: , label: "Break into new column", hotkey: "cell.addColumnBreakpoint", - hidden: appWidth !== "columns", handle: () => addColumnBreakpoint({ cellId }), - hidden: isSetupCell, + hidden: appWidth !== "columns" || isSetupCell, }, ],