Commit 981b3e6
authored
## Summary
`CellManager` now wraps a `NotebookDocument` instead of holding its own
dict of `CellData`, and `Session.document` is a property that reads
through `cell_manager.document`. Removes a class of drift bugs where the
two were synced once at session startup and then diverged across save,
file-watch reload, and code-mode autosave.
## What changed
- **`CellManager` wraps the document.** Removed `_cell_data` dict is
gone; `get_cell_data` returns a fresh synthesized view each call.
- **`Session.document` is a `@property`** returning
`app.cell_manager.document`. No more manual rebinding when the manager
or app is swapped. Save-endpoint workaround removed.
- **Transitional helpers** preserve identity of `_document` and
`_compiled_cells` for callers that still rebuild the cell list as a
unit: `CellManager._replace_state_from` and
`NotebookDocument._replace_cells`. `InternalApp.with_data` uses the
former. A follow-up will route both through `Transaction.apply`.
- **File-watch reload bridge.** `AppFileManager.reload()` still swaps in
a fresh app, so the coordinator now snapshots `prev_document` before the
swap, builds the diff `Transaction`, and passes it to the strategy. A
follow-up will rework `reload()` to apply the diff in place.
## Tests
Invariants for the document property, `get_cell_data` view freshness,
`_replace_state_from` identity preservation, `_compiled_cells` lockstep
rekeying (with an **xfail** for the latent inner `Cell._cell.cell_id`
mismatch — separate follow-up), `_replace_cells` version bump, and
`InternalApp.with_data` identity + compiled-cell carryover.
1 parent 67d2781 commit 981b3e6
11 files changed
Lines changed: 614 additions & 173 deletions
File tree
- marimo
- _ast
- _messaging/notebook
- _server/api/endpoints
- _session
- tests
- _ast
- _messaging/notebook
- _session
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | | - | |
| 297 | + | |
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| |||
1014 | 1014 | | |
1015 | 1015 | | |
1016 | 1016 | | |
1017 | | - | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
1018 | 1031 | | |
1019 | 1032 | | |
1020 | 1033 | | |
1021 | | - | |
1022 | | - | |
1023 | | - | |
1024 | | - | |
1025 | | - | |
1026 | | - | |
| 1034 | + | |
1027 | 1035 | | |
1028 | 1036 | | |
1029 | 1037 | | |
1030 | 1038 | | |
1031 | | - | |
| 1039 | + | |
1032 | 1040 | | |
1033 | | - | |
| 1041 | + | |
1034 | 1042 | | |
1035 | 1043 | | |
1036 | 1044 | | |
| |||
1073 | 1081 | | |
1074 | 1082 | | |
1075 | 1083 | | |
1076 | | - | |
| 1084 | + | |
1077 | 1085 | | |
1078 | 1086 | | |
1079 | 1087 | | |
| |||
0 commit comments