fix: hide install-package button in read mode#9979
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
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
InstallPackageButtonrendering behinduseInstallAllowed()(hide in read mode). - Extend the component test suite to cover the read-mode behavior.
- Initialize
viewStateAtomtoeditin 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. |
Contributor
There was a problem hiding this comment.
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
mscolnick
approved these changes
Jun 24, 2026
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.11-dev23 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Summary
In a read-only
marimo runsession, 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, sincePOST /api/packages/addis gated behind@requires("edit")and read-mode end users cannot mutate the environment.Guard
InstallPackageButtonwithuseInstallAllowed()so it renders nothing where installs can't succeed. This covers the column-explorer path and any future caller in one place;MissingPackagePromptalready 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