Skip to content

feat: make keyboard shortcuts extensible through entrypoints - #10589

Draft
peter-gy wants to merge 8 commits into
marimo-team:mainfrom
peter-gy:pgy/extensible-keyboard-shortcuts-poc
Draft

feat: make keyboard shortcuts extensible through entrypoints#10589
peter-gy wants to merge 8 commits into
marimo-team:mainfrom
peter-gy:pgy/extensible-keyboard-shortcuts-poc

Conversation

@peter-gy

@peter-gy peter-gy commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

📝 Summary

Adds a marimo.keyboard_shortcuts entry point so installed Python packages can contribute editor shortcuts with a plain dictionary.

marimo validates and namespaces contributed actions, then exposes them in the command palette and Shortcuts dialog with existing overrides and duplicate detection. Triggering an extension action dispatches marimo:keyboard-shortcut, which package widgets or panels can handle in the browser.

Invalid entries are skipped individually, and installed entry points are loaded once per process. Includes focused Python and frontend coverage for discovery, validation, caching, UI registration, and event dispatch.

Demo

  1. Developer of a 3rd-party package defines metadata and exposes it via entrypoint
# src/my_pkg_with_keyboard_shortcut/__init__.py
ACTION = "extension.my-pkg-with-keyboard-shortcut.show-message"

keyboard_shortcuts = {
    "show-message": {
        "name": "Show companion message",
        "key": "Mod-Shift-Y",
    }
}
[project.entry-points."marimo.keyboard_shortcuts"]
my-pkg-with-keyboard-shortcut = "my_pkg_with_keyboard_shortcut:keyboard_shortcuts"
image
  1. Marimo editor picks it up automatically and exposes it via command palette
Built-in.Retina.Display.Area.2026-08-19.09_47.AM.mp4

@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview Aug 19, 2026 8:12am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 25 files

Architecture diagram
sequenceDiagram
    participant Plugin as Extension Package
    participant EP as EntryPoint Registry
    participant Server as Marimo Server
    participant API as Assets API
    participant Template as HTML Template
    participant Client as Browser (Marimo App)
    participant Config as Jotai Store
    participant Hotkey as OverridingHotkeyProvider
    participant Bar as Shortcut Extension Handler
    participant Document as DOM/Window
    
    Note over Plugin,Server: Server-side: Extension Loading
    Plugin->>EP: Register "marimo.keyboard_shortcuts" entry point
    Server->>EP: Discover installed extensions
    EP-->>Server: Registry with extension metadata
    
    Note over Server,API: Request time: Serve index.html
    Client->>API: GET /
    API->>EP: load_keyboard_shortcuts()
    EP-->>API: Namespaced shortcut map (extension.<provider>.<id>)
    API->>Template: Render with keyboardShortcuts data
    Template-->>Client: HTML + inline mount config (keyboardShortcuts)
    
    Note over Client,Config: Client-side initialization
    Client->>Config: Parse mount options (zod validation)
    Config->>Config: Validate extension action keys (extension.*)
    Config->>Config: Store keyboardShortcutExtensionsAtom
    Client->>Hotkey: Create provider with built-in + extension hotkeys
    
    Note over Hotkey,Document: Runtime: Keyboard handling
    Document->>Hotkey: keydown event (e.g., Ctrl+Shift+Y)
    Hotkey->>Hotkey: Match against merged shortcut map
    Hotkey->>Bar: Trigger extension action callback
    Bar->>Document: Dispatch CustomEvent("marimo:keyboard-shortcut")
    Document->>Document: Listeners receive { action: "extension.x.y" }
    
    Note over Hotkey,Document: UI Integration
    Client->>Hotkey: Query hotkey info for command palette/settings
    Hotkey-->>Client: Display name, key binding, group
    
    alt Invalid extension metadata
        API->>API: Catch exception, log warning
        API-->>Template: Skip invalid extension
    end
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread marimo/_entrypoints/keyboard_shortcuts.py
Comment thread frontend/src/core/hotkeys/hotkeys.ts Outdated
Comment thread frontend/src/mount.tsx Outdated
Comment thread marimo/_server/api/endpoints/assets.py
Comment thread marimo/_server/api/endpoints/assets.py

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 6 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread marimo/_entrypoints/keyboard_shortcuts.py Outdated
Comment thread frontend/src/mount.tsx Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request team-draft

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant