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: open AI settings from command palette when ai.enabled is false (#9937)

Shahmir Varqha3fd2c53ba84f
diff --git a/frontend/src/components/editor/actions/useNotebookActions.tsx b/frontend/src/components/editor/actions/useNotebookActions.tsx
index 54c4adf52c..e2c15420bf 100644
--- a/frontend/src/components/editor/actions/useNotebookActions.tsx
+++ b/frontend/src/components/editor/actions/useNotebookActions.tsx
@@ -41,7 +41,10 @@ import {
YoutubeIcon,
ZapIcon,
} from "lucide-react";
-import { settingDialogAtom } from "@/components/app-config/state";
+import {
+ settingDialogAtom,
+ useOpenSettingsToTab,
+} from "@/components/app-config/state";
import { MarkdownIcon } from "@/components/editor/cell/code/icons";
import { MarimoPlusIcon } from "@/components/icons/marimo-icons";
import { useImperativeModal } from "@/components/modal/ImperativeModal";
@@ -57,7 +60,8 @@ import {
useCellActions,
} from "@/core/cells/cells";
import { disabledCellIds } from "@/core/cells/utils";
-import { useResolvedMarimoConfig } from "@/core/config/config";
+import { capabilitiesAtom } from "@/core/config/capabilities";
+import { aiEnabledAtom, useResolvedMarimoConfig } from "@/core/config/config";
import { Constants } from "@/core/constants";
import {
updateCellOutputsWithScreenshots,
@@ -86,7 +90,7 @@ import { Strings } from "@/utils/strings";
import { newNotebookURL } from "@/utils/urls";
import { useRunAllCells } from "../cell/useRunCells";
import { useChromeActions, useChromeState } from "../chrome/state";
-import { PANELS } from "../chrome/types";
+import { isPanelHidden, PANELS } from "../chrome/types";
import { AddConnectionDialogContent } from "../connections/add-connection-dialog";
import { keyboardShortcutsAtom } from "../controls/keyboard-shortcuts";
import { commandPaletteAtom } from "../controls/state";
@@ -112,6 +116,8 @@ export function useNotebookActions() {
const kioskMode = useAtomValue(kioskModeAtom);
const hideAllMarkdownCode = useHideAllMarkdownCode();
const [resolvedConfig] = useResolvedMarimoConfig();
+ const capabilities = useAtomValue(capabilitiesAtom);
+ const aiEnabled = useAtomValue(aiEnabledAtom);
const {
updateCellConfig,
@@ -126,6 +132,7 @@ export function useNotebookActions() {
const copyNotebook = useCopyNotebook(filename);
const setCommandPaletteOpen = useSetAtom(commandPaletteAtom);
const setSettingsDialogOpen = useSetAtom(settingDialogAtom);
+ const { handleClick: openSettings } = useOpenSettingsToTab();
const setKeyboardShortcutsOpen = useSetAtom(keyboardShortcutsAtom);
const {
exportAsIPYNB,
@@ -407,20 +414,31 @@ export function useNotebookActions() {
label: "Helper panel",
redundant: true,
handle: NOOP_HANDLER,
- dropdown: PANELS.flatMap(
- ({ type: id, Icon, hidden, additionalKeywords }) => {
- if (hidden) {
- return [];
- }
- return {
- label: Strings.startCase(id),
- rightElement: renderCheckboxElement(selectedPanel === id),
- icon: <Icon size={14} strokeWidth={1.5} />,
- handle: () => toggleApplication(id),
- additionalKeywords,
- };
- },
- ),
+ dropdown: PANELS.flatMap((panel) => {
+ // Still show the AI panel in the command palette so users can try AI
+ // features. When AI is disabled, open settings instead of the panel.
+ const openAiSettingsWhenDisabled = panel.type === "ai" && !aiEnabled;
+ if (
+ isPanelHidden({ panel, capabilities, aiEnabled }) &&
+ !openAiSettingsWhenDisabled
+ ) {
+ return [];
+ }
+ const { type: id, Icon, additionalKeywords } = panel;
+ return {
+ label: Strings.startCase(id),
+ rightElement: renderCheckboxElement(selectedPanel === id),
+ icon: <Icon size={14} strokeWidth={1.5} />,
+ handle: () => {
+ if (openAiSettingsWhenDisabled) {
+ openSettings("ai", "ai-features");
+ return;
+ }
+ toggleApplication(id);
+ },
+ additionalKeywords,
+ };
+ }),
},
{