Skip to content

fix: hide install-package button in read mode#9979

Merged
kirangadhave merged 1 commit into
mainfrom
kg/run-mode-install-package-error
Jun 24, 2026
Merged

fix: hide install-package button in read mode#9979
kirangadhave merged 1 commit into
mainfrom
kg/run-mode-install-package-error

Conversation

@kirangadhave

@kirangadhave kirangadhave commented Jun 24, 2026

Copy link
Copy Markdown
Member

📝 Summary

In a read-only marimo run session, opening the column explorer on a table whose chart preview needs Altair showed an "Install altair" button. Clicking it failed with an "Authorization header required" toast, since POST /api/packages/add is gated behind @requires("edit") and read-mode end users cannot mutate the environment.

Guard InstallPackageButton with useInstallAllowed() so it renders nothing where installs can't succeed. This covers the column-explorer path and any future caller in one place; MissingPackagePrompt already short-circuits to generic copy before reaching the button. In read mode the column explorer now shows just the error text with no dead button.

Closes MO-5918

Review in cubic

The column explorer rendered the "Install altair" button in a read-only `marimo run` session, where the install request is rejected with an authorization error. Guard InstallPackageButton with useInstallAllowed so it only renders where installs can succeed.
@vercel

vercel Bot commented Jun 24, 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, Comment Jun 24, 2026 6:15pm

Request Review

@kirangadhave kirangadhave changed the title fix(datasources): hide install-package button in read mode fix: hide install-package button in read mode Jun 24, 2026
@kirangadhave kirangadhave added the internal A refactor or improvement that is not user facing label Jun 24, 2026
@kirangadhave kirangadhave marked this pull request as ready for review June 24, 2026 18:14

Copilot AI 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.

Pull request overview

Prevents the “Install <package>” button from appearing in read-only (marimo run) sessions where package installation cannot succeed (backend route is edit-gated), avoiding a dead-end UI path and auth error toast.

Changes:

  • Gate InstallPackageButton rendering behind useInstallAllowed() (hide in read mode).
  • Extend the component test suite to cover the read-mode behavior.
  • Initialize viewStateAtom to edit in tests to keep existing render expectations stable.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
frontend/src/components/datasources/install-package-button.tsx Adds useInstallAllowed() guard so the install button does not render when installs can’t work (read mode).
frontend/src/components/datasources/tests/install-package-button.test.tsx Adds coverage for read-mode non-rendering and sets default mode to edit for the suite.

@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.

No issues found across 2 files

Architecture diagram
sequenceDiagram
    participant User as End User
    participant UI as Column Explorer
    participant InstallBtn as InstallPackageButton
    participant ModeHook as useInstallAllowed()
    participant CoreMode as Core Mode Module
    participant Backend as Backend API

    Note over User,Backend: Column Explorer Read Mode Flow

    User->>UI: Open column explorer on table
    UI->>UI: Detect missing Altair package
    UI->>InstallBtn: Render with packages=["altair"]

    alt Edit Mode
        ModeHook->>CoreMode: Check current mode
        CoreMode-->>ModeHook: mode="edit"
        ModeHook-->>InstallBtn: installAllowed=true
        InstallBtn->>User: Show "Install altair" button
        User->>InstallBtn: Click button
        InstallBtn->>Backend: POST /api/packages/add
        Backend-->>InstallBtn: 200 OK
        InstallBtn-->>User: Package installed
    else Read Mode (new behavior)
        ModeHook->>CoreMode: Check current mode
        CoreMode-->>ModeHook: mode="read"
        ModeHook-->>InstallBtn: installAllowed=false
        InstallBtn-->>UI: Return null (nothing rendered)
        UI-->>User: Show error text only
    end

    Note over InstallBtn,Backend: Previously: button always rendered in all modes
Loading

Re-trigger cubic

@kirangadhave kirangadhave enabled auto-merge (squash) June 24, 2026 18:23
@kirangadhave kirangadhave merged commit 3f853cd into main Jun 24, 2026
36 of 40 checks passed
@kirangadhave kirangadhave deleted the kg/run-mode-install-package-error branch June 24, 2026 18:51
@github-actions

Copy link
Copy Markdown

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.11-dev23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants