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.

Hide snippets panel by default (#7460)

Trevor Manz8719895b5b5a
diff --git a/frontend/src/components/editor/chrome/state.ts b/frontend/src/components/editor/chrome/state.ts
index 936bbc6096..156d606792 100644
--- a/frontend/src/components/editor/chrome/state.ts
+++ b/frontend/src/components/editor/chrome/state.ts
@@ -123,7 +123,9 @@ export const exportedForTesting = {
// TODO: probably merge this with the chrome state
export const sidebarOrderAtom = atomWithStorage<PanelType[]>(
"marimo:sidebar-order",
- PANELS.filter((p) => !p.hidden && p.position === "sidebar").map((p) => p.id),
+ PANELS.filter(
+ (p) => !p.hidden && !p.defaultHidden && p.position === "sidebar",
+ ).map((p) => p.id),
jotaiJsonStorage,
{ getOnInit: true },
);
diff --git a/frontend/src/components/editor/chrome/types.ts b/frontend/src/components/editor/chrome/types.ts
index c5f3aedbff..86c75024d3 100644
--- a/frontend/src/components/editor/chrome/types.ts
+++ b/frontend/src/components/editor/chrome/types.ts
@@ -35,7 +35,10 @@ export type PanelType =
export interface PanelDescriptor {
id: PanelType;
Icon: LucideIcon;
+ /** If true, the panel is completely unavailable */
hidden?: boolean;
+ /** If true, the panel is available but not shown by default */
+ defaultHidden?: boolean;
tooltip: string;
position: "sidebar" | "footer";
}
@@ -87,12 +90,11 @@ export const PANELS: PanelDescriptor[] = [
position: "sidebar",
},
{
- // TODO(akshayka): Consider making snippets default
- // off, user configuration to enable.
id: "snippets",
Icon: SquareDashedBottomCodeIcon,
tooltip: "Snippets",
position: "sidebar",
+ defaultHidden: true,
},
// 3. Nice-to-have observability panels.
//
diff --git a/frontend/src/components/editor/chrome/wrapper/sidebar.tsx b/frontend/src/components/editor/chrome/wrapper/sidebar.tsx
index b21641eaf7..c6dedc75e0 100644
--- a/frontend/src/components/editor/chrome/wrapper/sidebar.tsx
+++ b/frontend/src/components/editor/chrome/wrapper/sidebar.tsx
@@ -8,6 +8,7 @@ import { useMemo } from "react";
import { ReorderableList } from "@/components/ui/reorderable-list";
import { Tooltip } from "@/components/ui/tooltip";
import { notebookQueuedOrRunningCountAtom } from "@/core/cells/cells";
+import { snippetsEnabledAtom } from "@/core/config/config";
import { cn } from "@/utils/cn";
import { FeedbackButton } from "../components/feedback-button";
import { sidebarOrderAtom, useChromeActions, useChromeState } from "../state";
@@ -17,15 +18,27 @@ export const Sidebar: React.FC = () => {
const { selectedPanel } = useChromeState();
const { toggleApplication } = useChromeActions();
const [sidebarOrder, setSidebarOrder] = useAtom(sidebarOrderAtom);
+ const snippetsEnabled = useAtomValue(snippetsEnabledAtom);
const renderIcon = ({ Icon }: PanelDescriptor, className?: string) => {
return <Icon className={cn("h-5 w-5", className)} />;
};
// Get all available sidebar panels
+ // Panels with defaultHidden are only available if explicitly enabled (e.g., snippets)
const availableSidebarPanels = useMemo(
- () => PANELS.filter((p) => !p.hidden && p.position === "sidebar"),
- [],
+ () =>
+ PANELS.filter((p) => {
+ if (p.hidden || p.position !== "sidebar") {
+ return false;
+ }
+ // Show defaultHidden panels only if enabled via config
+ if (p.defaultHidden && p.id === "snippets" && !snippetsEnabled) {
+ return false;
+ }
+ return true;
+ }),
+ [snippetsEnabled],
);
const currentItems = sidebarOrder
diff --git a/frontend/src/core/config/config.ts b/frontend/src/core/config/config.ts
index f794a15e34..61a585755a 100644
--- a/frontend/src/core/config/config.ts
+++ b/frontend/src/core/config/config.ts
@@ -115,3 +115,13 @@ export function getAppConfig() {
}
export const appWidthAtom = atom((get) => get(appConfigAtom).width);
+
+/**
+ * Snippets panel is available when user has custom paths or default snippets enabled.
+ */
+export const snippetsEnabledAtom = atom<boolean>((get) => {
+ const config = get(resolvedMarimoConfigAtom);
+ const customPaths = config.snippets?.custom_paths ?? [];
+ const includeDefaultSnippets = config.snippets?.include_default_snippets;
+ return customPaths.length > 0 || includeDefaultSnippets === true;
+});