[bug]: Notebook marked as stale when saved after kernel restart in watch mode
Describe the bug
I described this behavior in #7098, where it seemed like it was related to a VS Code extension, however, I have noticed that it happens even outside of VS Code. It is still possible the behavior for the #7098 is still related to the old extension, so I am making a new issue.
When running a Marimo notebook in watch mode, the first time the user saves the notebook after a kernel restart marks all the cells as stale. I don't think it should do this.
Example:
https://github.com/user-attachments/assets/8b5d7699-cfbe-412b-a642-bd995ff12615
Will you submit a PR?
- [ ] Yes
Environment
{
"marimo": "0.17.7",
"editable": false,
"location": "C:/Users/avg170002/AppData/Local/uv/cache/archive-v0/y6F1X84CPUXxWLfYY4ewn/Lib/site-packages/marimo",
"OS": "Windows",
"OS Version": "11",
"Processor": "Intel64 Family 6 Model 198 Stepping 2, GenuineIntel",
"Python Version": "3.13.9",
"Locale": "en_US",
"Binaries": {
"Browser": "--",
"Node": "v22.21.1"
},
"Dependencies": {
"click": "8.3.0",
"docutils": "0.22.3",
"itsdangerous": "2.2.0",
"jedi": "0.19.2",
"markdown": "3.10",
"narwhals": "2.11.0",
"packaging": "25.0",
"psutil": "7.1.3",
"pygments": "2.19.2",
"pymdown-extensions": "10.16.1",
"pyyaml": "6.0.3",
"starlette": "0.50.0",
"tomlkit": "0.13.3",
"typing-extensions": "missing",
"uvicorn": "0.38.0",
"websockets": "15.0.1"
},
"Optional Dependencies": {
"loro": "1.8.2"
},
"Experimental Flags": {}
}
Code to reproduce
import marimo
__generated_with = "0.17.7"
app = marimo.App(width="medium")
@app.cell
def _():
import marimo as mo
return
@app.cell
def _():
print("Hello")
return
if __name__ == "__main__":
app.run()
I don't think this is related to #7098 but it is weird (the markdown actively changed- meaning that the cell is stale because the contents were different). Thanks for reporting
@Antyos im having trouble even reproducing this simple example. can you verify in the top right hamburger menu that you are running on 0.17.7
EDIT: I can reproduce this with watcher_on_save = "lazy" set
EDIT-2: I do think this is fixed on latest though. I will keep testing around if I can reproduce this otherwise.