Skip to content

add config to disable AI#9739

Merged
Light2Dark merged 6 commits into
mainfrom
sham/disable-ai
Jun 2, 2026
Merged

add config to disable AI#9739
Light2Dark merged 6 commits into
mainfrom
sham/disable-ai

Conversation

@Light2Dark
Copy link
Copy Markdown
Collaborator

@Light2Dark Light2Dark commented Jun 1, 2026

📝 Summary

Fixes #4901. We've heard from a few folks in-person that they would like this.

Adds a config to disable AI which hides it all from the UI but leaves out code-completion & "Pair with an agent".

  • ai.enabled is the config, although notably, this is a UI impact, we don't disable the endpoints. I considered ai.show_ui but enabled is more generic
  • Kept code-completion & Pair with agent because they are not in-your-face touch points for interacting with AI.
Screen.Recording.2026-06-01.at.10.53.25.PM.mov

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

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

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jun 1, 2026 3:22pm

Request Review

@Light2Dark Light2Dark changed the title add config and UI handling for disabled AI add config to disable AI Jun 1, 2026
@Light2Dark Light2Dark requested a review from Copilot June 1, 2026 15:07
@github-actions github-actions Bot added documentation Improvements or additions to documentation bash-focus Area to focus on during release bug bash labels Jun 1, 2026
@Light2Dark Light2Dark marked this pull request as ready for review June 1, 2026 15:13
@Light2Dark Light2Dark requested a review from akshayka as a code owner June 1, 2026 15:13
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

4 issues found across 20 files

Architecture diagram
sequenceDiagram
    participant User as User (Browser)
    participant UI as React UI Components
    participant ConfigStore as Config State (Jotai)
    participant AppChrome as AppChrome / Sidebar / Footer
    participant CellEditor as Cell Editor / Actions
    participant ErrorHandler as Error / Traceback UI
    participant Nav as Cell Navigation

    Note over User,Nav: Runtime Flow for AI Feature Visibility

    User->>ConfigStore: Update config (ai.enabled = false)
    ConfigStore->>ConfigStore: Compute atoms: aiEnabledAtom, aiFeaturesEnabledAtom, aiModelConfiguredAtom

    alt ai.enabled = false
        ConfigStore-->>AppChrome: aiEnabled = false
        AppChrome->>AppChrome: isPanelHidden({panel: type "ai", aiEnabled: false})
        AppChrome->>AppChrome: Remove Chat panel from sidebar & dev panel
        AppChrome->>AppChrome: Remove AI status icon from footer
        AppChrome-->>UI: Renders without AI panels/icon

        ConfigStore-->>CellEditor: aiFeaturesEnabled = false
        CellEditor->>CellEditor: Hide "Generate with AI" button
        CellEditor->>CellEditor: Disable aiCellCompletion shortcut
        CellEditor-->>UI: No AI cell actions

        ConfigStore-->>ErrorHandler: aiFeaturesEnabled = false
        ErrorHandler->>ErrorHandler: Hide "Fix with AI" in traceback
        ErrorHandler-->>UI: No AI fix button

        ConfigStore-->>Nav: aiFeaturesEnabled = false
        Nav->>Nav: Disable cell AI completion shortcut
        Nav-->>UI: No AI navigation action
    else ai.enabled = true (default)
        ConfigStore-->>AppChrome: aiEnabled = true
        ConfigStore-->>AppChrome: aiModelConfigured = true/false
        alt aiModelConfigured = false
            AppChrome->>AppChrome: Show AI status icon with "Assist disabled" tooltip
            CellEditor->>CellEditor: Show "Generate with AI" button with tooltip "AI provider not found"
        else aiModelConfigured = true
            AppChrome->>AppChrome: Show AI status icon with model name
            AppChrome->>AppChrome: Show Chat panel in sidebar
            CellEditor->>CellEditor: Enable aiCellCompletion shortcut
            CellEditor->>CellEditor: Show "Generate with AI" button active
            ErrorHandler->>ErrorHandler: Show "Fix with AI" button
            Nav->>Nav: Enable cell AI completion shortcut
        end
    end

    Note over UI,CellEditor: Config UI Interaction (User toggles setting)

    User->>ConfigStore: Toggle checkbox for "Enable AI features"
    ConfigStore->>ConfigStore: Update config value
    ConfigStore-->>UI: Reactively hide AI Providers/Models/MCP tabs
    ConfigStore-->>UI: Show only "AI Features" tab with enabled toggle
Loading

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

Re-trigger cubic

Comment thread frontend/src/components/chat/chat-panel.tsx
Comment thread frontend/src/components/editor/navigation/navigation.ts
Comment thread frontend/src/components/editor/cell/code/cell-editor.tsx
Comment thread docs/guides/editor_features/ai_completion.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an ai.enabled user config flag to hide AI-related actions and panels throughout the editor UI (while leaving code-completion and “Pair with an agent” available), addressing issue #4901.

Changes:

  • Introduces ai.enabled in backend config typing/defaults and OpenAPI schema.
  • Updates the frontend config schema/state and gates AI UI surfaces (sidebar AI panel, footer icon, “Generate with AI”, refactor/fix affordances) behind ai.enabled.
  • Adds UI controls/docs/tests for the new setting.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/openapi/src/api.ts Adds enabled?: boolean to AiConfig and documents the new key in generated TS types.
packages/openapi/api.yaml Adds enabled to the OpenAPI AiConfig schema and description text.
marimo/_config/config.py Adds enabled to AiConfig TypedDict and includes it in default config.
frontend/src/core/config/config.ts Adds atoms/helpers for AI enabled/configured state used across UI.
frontend/src/core/config/config-schema.ts Extends UserConfigSchema.ai with enabled defaulting to true.
frontend/src/core/config/tests/config-schema.test.ts Updates snapshots to include ai.enabled: true by default.
frontend/src/components/editor/renderers/cell-array.tsx Hides “Generate with AI” button (and AI cell UI) when ai.enabled is false.
frontend/src/components/editor/output/MarimoTracebackOutput.tsx Gates AI fix affordance on the new AI feature-enabled state.
frontend/src/components/editor/navigation/navigation.ts Prevents toggling AI completion via shortcut when AI features aren’t enabled.
frontend/src/components/editor/navigation/tests/navigation.test.ts Sets up config so AI completion shortcut tests remain valid with new gating.
frontend/src/components/editor/errors/auto-fix.tsx Wires AI autofix availability to the new AI feature-enabled state.
frontend/src/components/editor/chrome/wrapper/sidebar.tsx Filters out the AI panel from sidebar/dev-panel lists when ai.enabled is false; adds type="button".
frontend/src/components/editor/chrome/wrapper/footer-items/ai-status.tsx Hides the footer AI status icon entirely when ai.enabled is false.
frontend/src/components/editor/chrome/wrapper/app-chrome.tsx Filters out the AI panel from dev panel lists when ai.enabled is false.
frontend/src/components/editor/chrome/types.ts Extends isPanelHidden to consider aiEnabled for the AI panel.
frontend/src/components/editor/cell/code/cell-editor.tsx Disables inline AI tooltip + AI completion toggling unless AI features are enabled.
frontend/src/components/editor/actions/useCellActionButton.tsx Hides “Refactor with AI” cell action unless AI features are enabled.
frontend/src/components/chat/chat-panel.tsx Uses a “model configured” signal to show empty state vs. chat body.
frontend/src/components/app-config/ai-config.tsx Adds a settings checkbox for ai.enabled and hides provider/model/MCP tabs when disabled.
docs/guides/editor_features/ai_completion.md Documents [ai].enabled = false to hide AI UI surfaces.
Comments suppressed due to low confidence (2)

packages/openapi/api.yaml:102

  • AiConfig.mode enum includes agent, but the schema description string only documents ask/manual. Please update the description to match the actual enum values (or regenerate this file after fixing the source description).
        \ the maximum number of tokens to use in AI completions\n    - `mode`: the\
        \ mode to use for AI completions. Can be one of: `\"ask\"` or `\"manual\"\
        `\n    - `inline_tooltip`: if `True`, enable inline AI tooltip suggestions\n\

frontend/src/core/config/config.ts:105

  • isAiModelConfigured only checks whether any model field is set, but it’s used to decide whether AI UI should be considered “configured” (chat panel empty state, footer status, Generate-with-AI gating). As-is, selecting a model without provider credentials will be treated as configured and lead to avoidable runtime errors, and the tooltip text about providers becomes inaccurate.
export function isAiModelConfigured(config: UserConfig) {
  return (
    Boolean(config.ai?.models?.chat_model) ||
    Boolean(config.ai?.models?.edit_model) ||
    Boolean(config.ai?.models?.autocomplete_model)

Comment thread marimo/_config/config.py
Comment thread packages/openapi/src/api.ts
Comment thread marimo/_config/config.py
Comment thread packages/openapi/src/api.ts
Comment thread packages/openapi/api.yaml
@Light2Dark Light2Dark merged commit f0c3a80 into main Jun 2, 2026
47 of 48 checks passed
@Light2Dark Light2Dark deleted the sham/disable-ai branch June 2, 2026 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bash-focus Area to focus on during release bug bash documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to hide AI in UI

3 participants