Skip to content

show code config for each slide#9776

Open
Light2Dark wants to merge 4 commits into
mainfrom
sham/add-show-code-config
Open

show code config for each slide#9776
Light2Dark wants to merge 4 commits into
mainfrom
sham/add-show-code-config

Conversation

@Light2Dark
Copy link
Copy Markdown
Collaborator

@Light2Dark Light2Dark commented Jun 3, 2026

📝 Summary

  • Previously, pressing C toggles 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.
  • Also adds a way that a user can set a slide to showCode, so something is persisted. When set to true, you cannot hide the code with C. I think this is the clearest experience for users.
Screen.Recording.2026-06-03.at.10.07.51.PM.mov

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

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

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jun 3, 2026 3:22pm

Request Review

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

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
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread frontend/src/components/slides/reveal-component.tsx
@Light2Dark Light2Dark requested a review from dmadisetti June 3, 2026 15:21
@Light2Dark Light2Dark added the enhancement New feature or request label Jun 3, 2026
@Light2Dark Light2Dark marked this pull request as ready for review June 3, 2026 15:48
Copilot AI review requested due to automatic review settings June 3, 2026 15:48
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

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 showCode boolean to the slides layout schema and ensure it round-trips through validation + (de)serialization.
  • Update the slides sidebar UI to let users persist showCode on 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);
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.

2 participants