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 9, 2026 5:37pm

@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

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

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 did try to refactor this such that we:

  • async attempted startup kernel
  • started session and the web socket loop
  • push notifications from kernel startup directly to the queue

This also has the advantage of being able to stream messages during startup
image

In theory. In practice the installation modal popped up after it was done (not sure what I was missing there), I had a couple race condition issues where kernel closed out before WS was ready.

There's also not really a clear mechanism to turn off the session from inside the kernel, and started going down the route of a process interrupt- I didn't want to rely on the FE for teardown since it was leaving orphaned sessions. Then remembered if we just fail before we set up our scaffolding, then we don't have to do all this- so I reverted and just cleaned up.

Maybe we can revisit, but it was looking to be like a fair amount of more work on an already long PR. Maybe there's a simpler way but seemed marginal for just a slight code smell

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

@dmadisetti
Copy link
Collaborator Author

marimo not being added a a bug particular to this (but we should fix). Opening the motebook again and it works as expected.

For the ruff error, I'm just going to throw an error and revisit if we need to. Ruff is installed in the sandbox, but the wrong sandbox! Installation path goes through the kernel

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