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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Add additionalKeywords to action types and command palette for enhanced search functionality (#8600)
Myles Scolnick0530a5c256c7
diff --git a/frontend/src/components/editor/actions/types.ts b/frontend/src/components/editor/actions/types.tsindex c4e38df349..74725b5773 100644--- a/frontend/src/components/editor/actions/types.ts+++ b/frontend/src/components/editor/actions/types.ts@@ -27,6 +27,7 @@ export interface ActionButton {handleHeadless?: (event?: Event) => void;divider?: boolean;dropdown?: ActionButton[];+ additionalKeywords?: string[];}export function isParentAction(@@ -51,6 +52,10 @@ export function flattenActions(if (isParentAction(action)) {return flattenActions(action.dropdown, `${prevLabel + action.label} > `);}- return { ...action, label: prevLabel + action.label };+ return {+ ...action,+ label: prevLabel + action.label,+ additionalKeywords: action.additionalKeywords,+ };});}diff --git a/frontend/src/components/editor/actions/useNotebookActions.tsx b/frontend/src/components/editor/actions/useNotebookActions.tsxindex e307ef4ea6..26c3f245eb 100644--- a/frontend/src/components/editor/actions/useNotebookActions.tsx+++ b/frontend/src/components/editor/actions/useNotebookActions.tsx@@ -379,17 +379,20 @@ export function useNotebookActions() {label: "Helper panel",redundant: true,handle: NOOP_HANDLER,- dropdown: PANELS.flatMap(({ type: id, Icon, hidden }) => {- if (hidden) {- return [];- }- return {- label: startCase(id),- rightElement: renderCheckboxElement(selectedPanel === id),- icon: <Icon size={14} strokeWidth={1.5} />,- handle: () => toggleApplication(id),- };- }),+ dropdown: PANELS.flatMap(+ ({ type: id, Icon, hidden, additionalKeywords }) => {+ if (hidden) {+ return [];+ }+ return {+ label: startCase(id),+ rightElement: renderCheckboxElement(selectedPanel === id),+ icon: <Icon size={14} strokeWidth={1.5} />,+ handle: () => toggleApplication(id),+ additionalKeywords,+ };+ },+ ),},{@@ -510,6 +513,7 @@ export function useNotebookActions() {label: "Restart kernel",variant: "danger",handle: restartKernel,+ additionalKeywords: ["reset", "reload", "restart"],},{icon: <FastForwardIcon size={14} strokeWidth={1.5} />,@@ -567,6 +571,7 @@ export function useNotebookActions() {label: "User settings",handle: () => setSettingsDialogOpen((open) => !open),redundant: true,+ additionalKeywords: ["preferences", "options", "configuration"],},{icon: <ExternalLinkIcon size={14} strokeWidth={1.5} />,diff --git a/frontend/src/components/editor/chrome/types.ts b/frontend/src/components/editor/chrome/types.tsindex 678cc0d7da..2092ba4694 100644--- a/frontend/src/components/editor/chrome/types.ts+++ b/frontend/src/components/editor/chrome/types.ts@@ -59,6 +59,8 @@ export interface PanelDescriptor {defaultSection: PanelSection;/** Capability required for this panel to be visible. If the capability is false, the panel is hidden. */requiredCapability?: keyof Capabilities;+ /** Additional search keywords for the command palette */+ additionalKeywords?: string[];}/**@@ -73,6 +75,7 @@ export const PANELS: PanelDescriptor[] = [label: "Files",tooltip: "View files",defaultSection: "sidebar",+ additionalKeywords: ["explorer", "browser", "directory"],},{type: "variables",@@ -80,6 +83,7 @@ export const PANELS: PanelDescriptor[] = [label: "Variables",tooltip: "Explore variables and data sources",defaultSection: "sidebar",+ additionalKeywords: ["state", "scope", "inspector"],},{type: "packages",@@ -87,6 +91,7 @@ export const PANELS: PanelDescriptor[] = [label: "Packages",tooltip: "Manage packages",defaultSection: "sidebar",+ additionalKeywords: ["dependencies", "pip", "install"],},{type: "ai",@@ -94,6 +99,7 @@ export const PANELS: PanelDescriptor[] = [label: "AI",tooltip: "Chat & Agents",defaultSection: "sidebar",+ additionalKeywords: ["chat", "copilot", "assistant"],},{type: "outline",@@ -101,6 +107,7 @@ export const PANELS: PanelDescriptor[] = [label: "Outline",tooltip: "View outline",defaultSection: "sidebar",+ additionalKeywords: ["toc", "structure", "headings"],},{type: "documentation",@@ -108,6 +115,7 @@ export const PANELS: PanelDescriptor[] = [label: "Docs",tooltip: "View live docs",defaultSection: "sidebar",+ additionalKeywords: ["reference", "api"],},{type: "dependencies",@@ -115,6 +123,7 @@ export const PANELS: PanelDescriptor[] = [label: "Dependencies",tooltip: "Explore dependencies",defaultSection: "sidebar",+ additionalKeywords: ["graph", "imports"],},// Developer panel defaults{@@ -123,6 +132,7 @@ export const PANELS: PanelDescriptor[] = [label: "Errors",tooltip: "View errors",defaultSection: "developer-panel",+ additionalKeywords: ["exceptions", "problems", "diagnostics"],},{type: "scratchpad",@@ -130,6 +140,7 @@ export const PANELS: PanelDescriptor[] = [label: "Scratchpad",tooltip: "Scratchpad",defaultSection: "developer-panel",+ additionalKeywords: ["scratch", "draft", "playground"],},{type: "tracing",@@ -137,6 +148,7 @@ export const PANELS: PanelDescriptor[] = [label: "Tracing",tooltip: "View tracing",defaultSection: "developer-panel",+ additionalKeywords: ["profiling", "performance"],},{type: "secrets",@@ -145,6 +157,7 @@ export const PANELS: PanelDescriptor[] = [tooltip: "Manage secrets",defaultSection: "developer-panel",hidden: isWasm(),+ additionalKeywords: ["env", "environment", "keys", "credentials"],},{type: "logs",@@ -152,6 +165,7 @@ export const PANELS: PanelDescriptor[] = [label: "Logs",tooltip: "View logs",defaultSection: "developer-panel",+ additionalKeywords: ["console", "stdout"],},{type: "terminal",@@ -161,6 +175,7 @@ export const PANELS: PanelDescriptor[] = [hidden: isWasm(),defaultSection: "developer-panel",requiredCapability: "terminal",+ additionalKeywords: ["shell", "console", "bash", "command"],},{type: "snippets",@@ -168,6 +183,7 @@ export const PANELS: PanelDescriptor[] = [label: "Snippets",tooltip: "Snippets",defaultSection: "developer-panel",+ additionalKeywords: ["templates", "examples"],},{type: "cache",@@ -176,6 +192,7 @@ export const PANELS: PanelDescriptor[] = [tooltip: "View cache",defaultSection: "developer-panel",hidden: !getFeatureFlag("cache_panel"),+ additionalKeywords: ["memory", "memoize"],},];diff --git a/frontend/src/components/editor/controls/command-palette.tsx b/frontend/src/components/editor/controls/command-palette.tsxindex 69e855d4b9..d68ebcf1bb 100644--- a/frontend/src/components/editor/controls/command-palette.tsx+++ b/frontend/src/components/editor/controls/command-palette.tsx@@ -78,6 +78,7 @@ const CommandPalette = () => {return (<CommandItemdisabled={props.disabled}+ keywords={hotkey.additionalKeywords}onSelect={() => {addRecentCommand(shortcut);// Close first and then run the action, so the dialog doesn't steal focus@@ -105,15 +106,18 @@ const CommandPalette = () => {handle,props = {},hotkey,+ additionalKeywords,}: {label: string;handle: () => void;props?: { disabled?: boolean; tooltip?: React.ReactNode };hotkey?: HotkeyAction;+ additionalKeywords?: string[];}) => {return (<CommandItemdisabled={props.disabled}+ keywords={additionalKeywords}onSelect={() => {addRecentCommand(label);setOpen(false);@@ -163,6 +167,7 @@ const CommandPalette = () => {disabled: action.disabled,tooltip: action.tooltip,},+ additionalKeywords: action.additionalKeywords,});}return null;@@ -190,6 +195,7 @@ const CommandPalette = () => {label: action.label,handle: action.handleHeadless || action.handle,props: { disabled: action.disabled, tooltip: action.tooltip },+ additionalKeywords: action.additionalKeywords,});})}{cellActions.map((action) => {@@ -200,6 +206,7 @@ const CommandPalette = () => {label: `Cell > ${action.label}`,handle: action.handleHeadless || action.handle,props: { disabled: action.disabled, tooltip: action.tooltip },+ additionalKeywords: action.additionalKeywords,});})}</CommandGroup>diff --git a/frontend/src/components/ui/command.tsx b/frontend/src/components/ui/command.tsxindex 85125fa6eb..9984ba6cbb 100644--- a/frontend/src/components/ui/command.tsx+++ b/frontend/src/components/ui/command.tsx@@ -7,6 +7,7 @@ import { Search } from "lucide-react";import * as React from "react";import { Dialog, DialogContent } from "@/components/ui/dialog";import { cn } from "@/utils/cn";+import { smartMatchFilter } from "@/utils/smartMatch";import { Strings } from "@/utils/strings";import {MENU_ITEM_DISABLED,@@ -21,6 +22,7 @@ const Command = React.forwardRef<>(({ className, ...props }, ref) => (<CommandPrimitiveref={ref}+ filter={smartMatchFilter}className={cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",className,diff --git a/frontend/src/core/hotkeys/hotkeys.ts b/frontend/src/core/hotkeys/hotkeys.tsindex 0d2b2ba853..fb167959d6 100644--- a/frontend/src/core/hotkeys/hotkeys.ts+++ b/frontend/src/core/hotkeys/hotkeys.ts@@ -27,11 +27,13 @@ export interface Hotkey {* @default true*/editable?: boolean;+ additionalKeywords?: string[];}interface ResolvedHotkey {name: string;key: string;+ additionalKeywords?: string[];}type ModKey = "Cmd" | "Ctrl";@@ -110,6 +112,7 @@ const DEFAULT_HOT_KEY = {name: "Run",group: "Running Cells",key: "Mod-Enter",+ additionalKeywords: ["execute", "submit"],},"cell.runAndNewBelow": {name: "Run and new below",@@ -132,6 +135,7 @@ const DEFAULT_HOT_KEY = {name: "Format cell",group: "Editing",key: "Mod-b",+ additionalKeywords: ["lint"],},"cell.viewAsMarkdown": {name: "View as Markdown",@@ -201,6 +205,7 @@ const DEFAULT_HOT_KEY = {name: "Delete cell",group: "Editing",key: "Shift-Backspace",+ additionalKeywords: ["remove"],},"cell.hideCode": {name: "Hide cell code",@@ -320,6 +325,7 @@ const DEFAULT_HOT_KEY = {name: "Save file",group: "Other",key: "Mod-s",+ additionalKeywords: ["write", "persist"],},"global.commandPalette": {name: "Show command palette",@@ -485,23 +491,26 @@ export class HotkeyProvider implements IHotkeyProvider {}getHotkey(action: HotkeyAction): ResolvedHotkey {- const { name, key } = this.hotkeys[action];+ const { name, key, additionalKeywords } = this.hotkeys[action];if (typeof key === "string") {return {name,key: key.replace("Mod", this.mod),+ additionalKeywords,};}if (key === NOT_SET) {return {name,key: "",+ additionalKeywords,};}const platformKey = key[this.platform] || key.main;return {name,key: platformKey.replace("Mod", this.mod),+ additionalKeywords,};}@@ -539,6 +548,7 @@ export class OverridingHotkeyProvider extends HotkeyProvider {return {name: base.name,key: override ? normalizeKeyString(override) : base.key,+ additionalKeywords: base.additionalKeywords,};}}diff --git a/frontend/src/utils/__tests__/smartMatch.test.ts b/frontend/src/utils/__tests__/smartMatch.test.tsnew file mode 100644index 0000000000..ea56d6e7b4--- /dev/null+++ b/frontend/src/utils/__tests__/smartMatch.test.ts@@ -0,0 +1,61 @@+/* Copyright 2026 Marimo. All rights reserved. */+import { describe, expect, it } from "vitest";+import { smartMatch, smartMatchFilter } from "../smartMatch";++describe("smartMatch", () => {+ it("matches exact word", () => {+ expect(smartMatch("run", "Run cell")).toBe(true);+ });++ it("matches word prefix", () => {+ expect(smartMatch("exe", "execute start")).toBe(true);+ });++ it("matches across array of haystacks", () => {+ expect(smartMatch("exe", ["Run", "execute start"])).toBe(true);+ });++ it("does not match unrelated terms", () => {+ expect(smartMatch("xyz", "Run cell")).toBe(false);+ });++ it("empty search matches everything", () => {+ expect(smartMatch("", "anything")).toBe(true);+ });++ it("multi-word needle requires all words to match", () => {+ expect(smartMatch("run cell", "Run cell")).toBe(true);+ expect(smartMatch("run xyz", "Run cell")).toBe(false);+ });++ it("is case-insensitive", () => {+ expect(smartMatch("RUN", "run cell")).toBe(true);+ });++ it("skips null/undefined haystacks", () => {+ expect(smartMatch("run", [null, undefined, "Run cell"])).toBe(true);+ expect(smartMatch("run", [null, undefined])).toBe(false);+ });+});++describe("smartMatchFilter", () => {+ it("returns 1 for value match", () => {+ expect(smartMatchFilter("Run cell", "run")).toBe(1);+ });++ it("returns 0 for no match", () => {+ expect(smartMatchFilter("Run cell", "xyz")).toBe(0);+ });++ it("returns 0.8 for keyword-only match", () => {+ expect(smartMatchFilter("Run", "execute", ["execute", "start"])).toBe(0.8);+ });++ it("returns 1 when value matches even if keywords also match", () => {+ expect(smartMatchFilter("Run", "run", ["execute", "start"])).toBe(1);+ });++ it("does not match without relevant keywords", () => {+ expect(smartMatchFilter("Run", "preferences", ["execute"])).toBe(0);+ });+});diff --git a/frontend/src/utils/smartMatch.ts b/frontend/src/utils/smartMatch.tsnew file mode 100644index 0000000000..270d6d7c9f--- /dev/null+++ b/frontend/src/utils/smartMatch.ts@@ -0,0 +1,62 @@+/* Copyright 2026 Marimo. All rights reserved. */++/**+ * Split a string into lowercase words (letters/digits only).+ */+function words(s: string): string[] {+ return s.toLowerCase().match(/[\da-z]+/g) || [];+}++/**+ * Returns true when every word in `needle` is a prefix of at least one word+ * in one of the `haystacks`.+ *+ * Examples:+ * smartMatch("run", "Run cell") // true – "run" prefixes "run"+ * smartMatch("exe", ["Run", "execute start"]) // true – "exe" prefixes "execute"+ * smartMatch("xyz", "Run cell") // false+ */+export function smartMatch(+ needle: string,+ haystackOrHaystacks: string | (string | null | undefined)[],+): boolean {+ const needleWords = words(needle);+ if (needleWords.length === 0) {+ return true; // empty search matches everything+ }++ const haystacks = Array.isArray(haystackOrHaystacks)+ ? haystackOrHaystacks+ : [haystackOrHaystacks];++ // Collect all words from all haystacks+ const haystackWords: string[] = [];+ for (const h of haystacks) {+ if (h) {+ haystackWords.push(...words(h));+ }+ }++ // Every needle word must be a prefix of at least one haystack word+ return needleWords.every((nw) => {+ return haystackWords.some((hw) => hw.startsWith(nw));+ });+}++/**+ * cmdk-compatible filter function.+ * Returns 1 for a value match, 0.8 for a keyword-only match, 0 for no match.+ */+export function smartMatchFilter(+ value: string,+ search: string,+ keywords?: string[],+): number {+ if (smartMatch(search, value)) {+ return 1;+ }+ if (keywords && smartMatch(search, keywords)) {+ return 0.8;+ }+ return 0;+}