Skip to content

refactor(desktop): push the transcript diagram theme through a Cmd - #1406

Draft
tonyfettes wants to merge 1 commit into
mainfrom
haoxiang/transcript-theme-cmd
Draft

refactor(desktop): push the transcript diagram theme through a Cmd#1406
tonyfettes wants to merge 1 commit into
mainfrom
haoxiang/transcript-theme-cmd

Conversation

@tonyfettes

Copy link
Copy Markdown
Contributor

Why

#1379 rendered the effective theme as data-transcript-theme on the transcript root and watched that attribute with the content MutationObserver so Mermaid diagrams could re-render on a theme switch. That is the DOM used as a message bus between the root and the component's subscription, the pattern the last few transcript PRs have been removing.

Rabbita never re-runs a component's subscriptions on an input-only change ("Changing the input alone does not send a message, run update, or refresh subscriptions"), so the theme cannot reach the diagram mount through Input or the subscription payload either.

What

  • Theme::apply batches @transcript_component.apply_theme(dark) next to the existing @fileeditor.apply_theme, the same Cmd-push shape the file editor already uses for an imperative widget outside Model.
  • The component package keeps a package-level transcript_theme: the current value plus a registry of live transcript mounts. A mount registers in its constructor and reads the current value there, unregisters on dispose, so the command and the first mount may run in either order. Only Mermaid is re-rendered; Diago SVGs follow the palette through CSS variables.
  • Removed: Input.dark_mode and its three call sites, the rendered data-transcript-theme attribute, the attribute_filter entry, the get_attribute read-back, and the per-diagram mut dark_mode.
  • The e2e now asserts the root data-theme projection written by the theme command instead of a component-rendered attribute.

Verification

  • moon check --target js
  • moon test --target js for frontend/transcript/component (21) and frontend (467)
  • transcript_diagrams.spec.js in Chromium: 6 passed, including the dark-mode re-render case
  • pkg.generated.mbti synced from the js _build artifact; the diff is exactly the removed dark_mode? and the added apply_theme

🤖 Generated with Claude Code

https://claude.ai/code/session_018f26rE1L4kzBf5ddeqn99i

#1379 rendered the effective theme as `data-transcript-theme` on the
transcript root and watched that attribute with the content
MutationObserver so Mermaid could re-render on a theme switch: the DOM
used as a message bus between the root and the component's subscription.

Rabbita never re-runs a component's `subscriptions` on an input-only
change, so the theme cannot reach the diagram mount through `Input` or
the subscription payload. Deliver it the way the file editor already
receives it instead: `Theme::apply` batches
`@transcript_component.apply_theme`, which updates a package-level
registry of live transcript mounts. A mount registers in its
constructor, reads the current value there, and unregisters on dispose,
so the command and the first mount may run in either order.

`Input` loses `dark_mode`, the view no longer renders the attribute, the
observer no longer filters on it, and the e2e asserts the root
`data-theme` projection the theme command writes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018f26rE1L4kzBf5ddeqn99i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant