Skip to content

Conversation

@dmadisetti
Copy link
Collaborator

@dmadisetti dmadisetti commented Jan 6, 2026

📝 Summary

Adds --sandbox to marimo edit --sandbox directory/. Leveraging pep-723 where ever it can.

closes #2598 rebases and supercedes #7640

  • removes dangerous sandbox
  • spawns ipc process only for marimo edit --sandbox (home mode)
  • uses lazy front end

UX changes on kernel launch failure:

image

@dmadisetti dmadisetti requested a review from akshayka as a code owner January 6, 2026 23:53
@vercel
Copy link

vercel bot commented Jan 6, 2026

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

Project Deployment Review Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jan 7, 2026 4:56pm

@dmadisetti dmadisetti changed the title Dm/sandbox home feat: sandboxed home Jan 6, 2026
@dmadisetti dmadisetti requested a review from mscolnick January 6, 2026 23:57
Copy link
Contributor

@akshayka akshayka left a comment

Choose a reason for hiding this comment

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

Before releasing this feature, we should make sure the UX issues you alluded to in the PR description, in particular when the frontend handles the case in which sandbox notebooks fail to start (e.g., uv sync fails):

  • the error should be communicated to the user;
  • we should either fail fast (show the error and stop trying to connect to the kernel), or provide a way for the user to fix the error and try again (edit script metadata, then click a button to try creating the venv again)

If you prefer to work in multiple PRs, sandbox home could be feature flagged until the FE handles the failure case

Copy link
Contributor

@akshayka akshayka left a comment

Choose a reason for hiding this comment

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

Shutting down the server on the frontend should also shutdown running notebooks, but that does not appear to be happening right now

Co-authored-by: Akshay Agrawal <akshay@marimo.io>
case "interrupted":
return;

case "kernel-startup-error":
Copy link
Contributor

Choose a reason for hiding this comment

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

should we just re-use the generic "banner" notification? less code and more consistent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I do think it needs to be more visually - "this will not work"

# Check for pyzmq dependency
from marimo._dependencies.dependencies import DependencyManager

if not DependencyManager.has("zmq"):
Copy link
Contributor

Choose a reason for hiding this comment

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

DependencyManager.zmq.has()?

action: Optional[Literal["restart"]] = None


class KernelStartupErrorNotification(Notification, tag="kernel-startup-error"):
Copy link
Contributor

Choose a reason for hiding this comment

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

we have StartupLog and Banner (which can be used for errors). i wonder if that might be better to piggy back off

KernelStartupErrorNotification(error=error_message)
)
text = f'{{"op": "kernel-startup-error", "data": {msg.decode("utf-8")}}}'
await self.websocket.send_text(text)
Copy link
Contributor

Choose a reason for hiding this comment

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

self.session.notify( KernelStartupErrorNotification(error=error_message))

Copy link
Contributor

Choose a reason for hiding this comment

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

oh maybe you don't have the session? this bit feels fragile

Copy link
Collaborator Author

@dmadisetti dmadisetti Jan 7, 2026

Choose a reason for hiding this comment

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

Good point. Changing this up, an advantage to having a session is that we could potentially stream the errors/ startup before closing. Will keep that for a future PR because this is quiet long, but will do the non-blocking kernel launch

asset_url=asset_url,
timeout=timeout,
sandbox_mode=sandbox_mode,
home_sandbox_mode=home_sandbox,
Copy link
Contributor

@mscolnick mscolnick Jan 7, 2026

Choose a reason for hiding this comment

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

  1. are these mutually exclusive? should we combine into a single flag?
  2. home_sandbox_mode feels like it may become a misnomer quite soon. should it be sandbox_mode: "none" | "single" | "multi"?

Copy link
Contributor

@akshayka akshayka left a comment

Choose a reason for hiding this comment

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

Might not be related to this change, but I created a new notebook and marimo was not added to its script metadata:

# /// script 
# requires-python = ">=3.13"
# dependencies = [
#     "matplotlib==3.10.8",
# ]
# ///

Additionally, I am finding a bad interaction with format on save, see video:

ruff-install.mp4

Comment on lines +64 to +65
The kernel failed to start. This usually happens when there's an
issue with the sandbox environment or missing dependencies.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The kernel failed to start. This usually happens when there's an
issue with the sandbox environment or missing dependencies.
The kernel failed to start. This usually happens when the package manager
can't install your notebook's dependencies.

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 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make sandbox compatible with edit server (multiple notebooks)

4 participants