show code config for each slide#9776
Open
Light2Dark wants to merge 4 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
1 issue found across 7 files
Architecture diagram
sequenceDiagram
participant User as User
participant SlideUI as Slides UI (RevealSlidesComponent)
participant SlideForm as Slide Config Form (SlideConfigForm)
participant Layout as Slides Layout State (jotai)
participant Plugin as Slide Layout Plugin (SlidesLayoutPlugin)
participant Storage as Layout File (JSON)
participant Cell as Slide Cell (RuntimeCell)
Note over User,Cell: Per-Slide Code Visibility Control
User->>SlideForm: Toggle "Show code" switch
SlideForm->>Layout: handleShowCodeChange(checked)
Layout->>Layout: Update showCode in cell config
Layout->>Plugin: Persist layout change
Plugin->>Storage: Write updated slides.json
User->>SlideUI: Navigate to slide
SlideUI->>Layout: Read cell configs
Layout-->>SlideUI: SlideConfig Map
SlideUI->>SlideUI: resolveShowCode(cellId, showCodeOverrides)
alt Code toggle enabled & cellId exists
SlideUI->>SlideUI: shouldShowCode()
alt Config has showCode=true
SlideUI->>SlideUI: Return true
else Override set (keypress C)
SlideUI->>SlideUI: Return true
else Neither
SlideUI->>SlideUI: Return false
end
else Code toggle disabled or no active cell
SlideUI->>SlideUI: Return false
end
User->>SlideUI: Press "C" key or toolbar button
SlideUI->>SlideUI: toggleShowCode()
SlideUI->>SlideUI: startTransition -> setShowCodeOverrides()
SlideUI->>SlideUI: Toggle cellId in showCodeOverrides set
SlideUI->>SlideUI: re-render slides with updated resolveShowCode
Note over SlideUI,Cell: Rendering Decision per Cell
alt resolveShowCode returns true
alt isEditable
SlideUI->>Cell: SlideCellView (editable code)
else Not editable
SlideUI->>Cell: SlideCellReadOnlyView (read-only code)
end
else resolveShowCode returns false
alt Has output
SlideUI->>Cell: CellOutputSlide (output only)
else No output & isEditable
SlideUI->>Cell: SlideCellView (editable code fallback)
else No output & showCode true
SlideUI->>Cell: SlideCellReadOnlyView (read-only code)
else No output & neither
SlideUI->>Cell: Empty/placeholder
end
end
Note over Layout,Plugin: Persistence & Round-Trip
SlideForm->>Layout: Set showCode config
Layout->>Plugin: serialize() includes showCode
Plugin->>Storage: Save JSON with showCode fields
Storage-->>Plugin: Load layout JSON
Plugin->>Plugin: validate() & deserialize() preserve showCode
Plugin-->>SlideUI: Restored SlideConfig Map with showCode
Note over Plugin,Storage: Backwards Compatibility
alt Layout file lacks showCode
Plugin->>Plugin: Deserialize with showCode undefined
Plugin-->>SlideUI: SlideConfig with showCode: undefined
SlideUI->>SlideUI: Default to false
else Layout file has showCode
Plugin->>Plugin: Deserialize with showCode preserved
Plugin-->>SlideUI: SlideConfig with showCode value
end
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the slides presentation experience so “show code” can be controlled per slide/cell (including persistence via layout config), rather than as a single global toggle across the entire deck.
Changes:
- Add a per-slide
showCodeboolean to the slides layout schema and ensure it round-trips through validation + (de)serialization. - Update the slides sidebar UI to let users persist
showCodeon a selected slide. - Rework the presentation code toggle to target the active slide cell (or active fragment cell) using per-cell override state, with unit tests for the resolver.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| marimo/_smoke_tests/slides_examples/nested_slides.py | Bumps the smoke test notebook’s __generated_with version. |
| marimo/_smoke_tests/slides_examples/layouts/nested_slides.slides.json | Adds showCode entries to exercise persisted per-slide behavior in smoke tests. |
| frontend/src/components/slides/slide-form.tsx | Adds a “Show code” switch to persist showCode onto the selected slide config. |
| frontend/src/components/slides/reveal-component.tsx | Implements per-cell code visibility resolution and per-cell keyboard toggle overrides in the Reveal.js deck. |
| frontend/src/components/slides/tests/reveal-component.test.ts | Adds unit tests for the shouldShowCode resolver logic. |
| frontend/src/components/editor/renderers/slides-layout/types.ts | Extends SlideConfig schema to include optional showCode. |
| frontend/src/components/editor/renderers/slides-layout/tests/plugin.test.ts | Adds backwards-compat snapshot coverage to ensure showCode survives validate + (de)serialize round-trips. |
Comment on lines
431
to
+435
| const toggleShowCode = useEvent(() => { | ||
| startTransition(() => setShowCode((value) => !value)); | ||
| if (cellIdToShowCode == null) { | ||
| return; | ||
| } | ||
| startTransition(() => |
Comment on lines
609
to
+612
| {codeToggleEnabled && ( | ||
| <Tooltip content={codeShown ? "Hide code (C)" : "Show code (C)"}> | ||
| <Tooltip | ||
| content={cellShowsCode ? "Hide code (C)" : "Show code (C)"} | ||
| > |
Comment on lines
+170
to
+175
| const { cells, cellId, showCodeOverrides, codeToggleEnabled } = options; | ||
| if (cellId == null || !codeToggleEnabled) { | ||
| return false; | ||
| } | ||
| const configured = cells.get(cellId)?.showCode ?? false; | ||
| return configured || showCodeOverrides.has(cellId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Summary
Ctoggles the code editor globally for all slides. This change only toggles it for the selected slide. Note that for fragments, this only shows the editor for current active fragment.C. I think this is the clearest experience for users.Screen.Recording.2026-06-03.at.10.07.51.PM.mov
📋 Pre-Review Checklist
✅ Merge Checklist