Skip to content

Fix hide_code not taking effect on kernel-created cells#8926

Merged
manzt merged 2 commits intomainfrom
push-lkptpysrvyxo
Mar 30, 2026
Merged

Fix hide_code not taking effect on kernel-created cells#8926
manzt merged 2 commits intomainfrom
push-lkptpysrvyxo

Conversation

@manzt
Copy link
Copy Markdown
Collaborator

@manzt manzt commented Mar 30, 2026

Cells created via code_mode with hide_code=True and non-empty code showed their editor anyway because they were marked "untouched," which overrides hide_code in the render logic. That override only makes sense for empty cells the user just created, so gate it on !code as well.

Cells created via code_mode with `hide_code=True` and non-empty code
showed their editor anyway because they were marked "untouched," which
overrides `hide_code` in the render logic. That override only makes
sense for empty cells the user just created, so gate it on `!code` as
well.
@manzt manzt requested a review from Light2Dark as a code owner March 30, 2026 17:18
Copilot AI review requested due to automatic review settings March 30, 2026 17:18
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Mar 30, 2026 5:21pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a frontend state/rendering edge case where kernel-created cells (via code_mode) with hide_code=true and non-empty initial code were incorrectly treated as “untouched,” causing the editor to be shown despite hide_code.

Changes:

  • Gate untouchedNewCells enrollment on both hideCode and empty initial code (hideCode && !code).
  • Ensures hide_code takes effect immediately for kernel-created cells with non-empty code.

Comment on lines +250 to +252
untouchedNewCells:
hideCode && !code
? new Set([...state.untouchedNewCells, newCellId])
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change introduces new behavior (cells created with hideCode=true and non-empty initial code should no longer be treated as "untouched"), but there isn't a unit test covering this case. Add a test that creates a new cell with hideCode: true and a non-empty code string, and asserts it is NOT added to untouchedNewCells and that isCellCodeHidden(...) returns true.

Copilot uses AI. Check for mistakes.
@@ -247,9 +247,10 @@ const {
[newCellId]: createRef(),
},
scrollKey: autoFocus ? newCellId : null,
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CreateNewCellAction docs for hideCode currently say code will be "initially shown until blur" when hideCode is true, but with this new gating it will be hidden immediately for non-empty initial code. Update the hideCode field comment to reflect the conditional behavior (only initially shown for empty initial code).

Suggested change
scrollKey: autoFocus ? newCellId : null,
scrollKey: autoFocus ? newCellId : null,
// If hideCode is true, we only treat the cell as an "untouched" new cell
// when it has no initial code. In that case the editor is initially shown
// until blur. For cells with non-empty initial code, the code is hidden
// immediately instead of being initially shown.

Copilot uses AI. Check for mistakes.
@manzt manzt merged commit 2ed144a into main Mar 30, 2026
30 of 31 checks passed
@manzt manzt deleted the push-lkptpysrvyxo branch March 30, 2026 19:16
@github-actions
Copy link
Copy Markdown

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.21.2-dev90

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.

3 participants