Switching from columns view to another view loses column metadata
Describe the bug
- Create a notebook with a two columns, and arrange cells across the columns
- Switch to a compact view and save.
Expected behavior:
- Column metadata is still persisted in the notebook file.
Actual behavior:
- Column metadata is erased from the file.
Environment
{
"marimo": "0.10.16",
"OS": "Darwin",
"OS Version": "22.5.0",
"Processor": "arm",
"Python Version": "3.12.4",
"Binaries": {
"Browser": "131.0.6778.265",
"Node": "v21.5.0"
},
"Dependencies": {
"click": "8.1.8",
"docutils": "0.21.2",
"itsdangerous": "2.2.0",
"jedi": "0.19.2",
"markdown": "3.7",
"narwhals": "1.23.0",
"packaging": "24.2",
"psutil": "6.1.1",
"pygments": "2.19.1",
"pymdown-extensions": "10.14.1",
"pyyaml": "6.0.2",
"ruff": "0.9.2",
"starlette": "0.45.2",
"tomlkit": "0.13.2",
"typing-extensions": "4.12.2",
"uvicorn": "0.34.0",
"websockets": "14.2"
},
"Optional Dependencies": {}
}
Code to reproduce
import marimo
__generated_with = "0.10.16"
app = marimo.App(width="columns")
@app.cell(column=0)
def _():
"1"
return
@app.cell(column=1)
def _():
"2"
return
if __name__ == "__main__":
app.run()
Hi I would like to work on this but I'm unable to recreate the issue. I wasn't able to figure out how to create a notebook with columns instead of vertical rows.
@BhavanaK223 - glad to hear you want to work on this! here are the docs: https://docs.marimo.io/guides/editor_features/overview/#editor-widths
The toggle is in the top-right settings menu. Changing the "width" to columns
Hi @mscolnick, I was able to switch to columns and replicate the steps but the metadata isn't lost when I switch to compact after running. Any cells made/ created revert to the same column when switched into compact mode.
Can you try saving and see if the metadata is lost?
Yep, I tried saving before I switched to the compact width, and the data was still saved. I tried again saving after switching to compact mode and it had the same result
I think after you switch to "compact", then save, then look at the file, you'll see the column config missing.
to clarify, the intended behavior is that @app.cell(column=1) is still part of the meta data in the saved file, even if saved in compact layout again?
@jo-soft yep exactly
I was able to reproduce this bug and it looks like a good first issue. I have been using marimo for awhile and looking to support/contribute.
$ diff copy_repro.mo.py orig_repro.mo.py
4c4
< app = marimo.App()
---
> app = marimo.App(width="columns")
7c7
< @app.cell
---
> @app.cell(column=0)
13c13
< @app.cell
---
> @app.cell(column=1)
let me know if you'd still like help on this issue
hey @mwynn1, its still open and unclaimed at the moment, feel free to take it! happy to support you as needed
thanks @mscolnick sgtm!
just to clarify we should be retaining @app.cell(column=<index>) if we toggle width from columns to any of the other 3 width choices (not just compact)?
yep correct
@mscolnick I have a feature branch with a proposed fix -- is marimo following a fork and pull model for contributors? I could not push/make PR
@mwynn1 can you link tot his repo?
Re: this issue I have draft PR up -- adding some tests now.
I noticed another issue with columns that seems unrelated to the metadata issue in this ticket:
If you change to column width in edit mode you get/see columns. If you toggle to app view, no cols are displayed (just vertical cells). If you refresh the browser, the columns will display in app view and will continue to do so going forward. Seems like something is not getting set when rendering the app view with columns. happy to make an issue for this. I didn't see a quick fix for it but there may be something obvious I missed
@mwynn1, thanks for finding that additional issue. Filing it on GH would be great. I'm not sure how much the "columns" view is used in app mode (I also thought it wasn't supported), but if we have an issue for it, it can help track / up-vote if people want it supported.
I’d like to take this on, if maintainers are still comfortable with the fix.
I reproduced the current behavior on main at df8dbed0. When the width leaves columns, EditApp dispatches mergeAllColumns; the document-change mapper then emits set-config changes with column: 0 for the former later columns. The regular save path also derives configs from the now-single-column tree, so this needs to preserve metadata across both the transaction and explicit-save boundaries (not just change the rendering).
I confirmed that both earlier attempts, #6752 and #10461, are closed and that there is currently no open PR. My proposed scope is a focused owner-boundary fix plus a regression that proves the persisted column configs survive the width-driven merge while the rendered cell order is still flattened. I’ll also include before/after UI evidence.
Would you be comfortable assigning this to me / marking it ready?
Hi @mscolnick — just following up now that about a week has passed. I’m still happy to implement the focused fix and regression coverage described above, and I’ll continue to wait for maintainer confirmation before starting. If the team would prefer not to pursue this issue or considers it covered elsewhere, no problem — please let me know and I’ll step back.
Hi @akshayka, I'd like to work on this one. I've traced the root cause: it's
in the frontend, not codegen getCellConfigs() in
frontend/src/core/cells/cells.ts force-overwrites column to null in its
single-column branch whenever the notebook isn't currently in multi-column
view, even though the value is still intact in cell config at that point
(nothing upstream, e.g. mergeAllColumns, actually clears it). The backend
round-trip is faithful, so this is a one-line fix plus regression tests in
utils.test.ts.
I'll open a PR shortly.