Skip to content

feat: Flush notebook to disk on restart#10004

Open
mchav wants to merge 1 commit into
marimo-team:mainfrom
mchav:flush_save
Open

feat: Flush notebook to disk on restart#10004
mchav wants to merge 1 commit into
marimo-team:mainfrom
mchav:flush_save

Conversation

@mchav

@mchav mchav commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

📝 Summary

Mis-timed restarts don't save the notebook to disk properly and result in data loss. The PR flushes the notebook to disk before initiating a restart.

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

Review in cubic

Mis-timed restarts don't save the notebook to disk properly and result in data loss.
@vercel

vercel Bot commented Jun 26, 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 26, 2026 4:29pm

Request Review

@mscolnick mscolnick added the enhancement New feature or request label Jun 26, 2026

@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 User
    participant UI as useRestartKernel
    participant Save as useSaveNotebook
    participant Persist as Notebook Persistence
    participant WS as WebSocket
    participant Kernel as Kernel

    User->>UI: Click restart kernel
    UI->>UI: Open confirm dialog
    UI->>User: Show updated description
    User->>UI: Confirm restart
    UI->>Save: saveIfNotebookIsPersistent()
    Note right of Save: Checks if notebook is a persistent file

    alt Notebook is persistent file
        Save->>Persist: Save notebook to disk
        Persist-->>Save: Save result
    else Save fails (caught)
        Save-->>UI: Error thrown
        UI->>UI: Logger.warn() – non‑fatal
    end

    UI->>WS: setConnection(CLOSING)
    UI->>Kernel: sendRestart()
    Kernel-->>UI: Acknowledged
    UI->>UI: reloadSafe() → page reload
Loading

Re-trigger cubic

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants