Skip to content

feat(viewer): report resolved theme id + mode to the host on theme change#194

Merged
benvinegar merged 1 commit into
mainfrom
feat/theme-change-meta
Jul 1, 2026
Merged

feat(viewer): report resolved theme id + mode to the host on theme change#194
benvinegar merged 1 commit into
mainfrom
feat/theme-change-meta

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Why

onThemeChange handed the embedding host only the resolved token values, not which theme/scheme produced them. That's enough for a host that paints its own chrome from the tokens, but not for a host that re-renders surfaces out-of-band.

Concretely: the sideshow cloud's feed preview cards are opaque-origin sandbox iframes served by /s/:id, which needs ?theme=&mode= to reproduce the viewer's exact look. Without the ids, the host can only pass mode (sniffed off the pinned color-scheme), so cross-workspace previews (the org activity feed) fall back to each source workspace's persisted theme instead of the viewer's — the previews render in the wrong palette.

What

Add a second meta: { theme, mode } argument to onThemeChange, carrying the resolved theme id and light/dark scheme the engine already computes (it builds its own surface URLs from exactly these).

  • Additive / non-breaking: the tokens argument is unchanged; the default self-hosted host omits onThemeChange entirely, so self-hosted parity is preserved.
  • Updated the hand-written viewer/embed.d.ts public declaration to match.
  • Extended e2e/embed-theme.spec.ts to assert the pushed meta on mount ({ theme: "github", mode: "light" }) and after a theme switch (gruvbox).

Test

  • npm run typecheck ✓ · npm run lint ✓ · npm test ✓ (412)
  • npm run build ✓ · npx playwright test embed-theme ✓ (chromium; webkit skipped — missing system deps in this env)

Changeset: minor.

…ange

`onThemeChange` handed the host only the resolved token VALUES, not which
theme/scheme produced them. That's enough for a host that paints its own
chrome from the tokens, but not for one that re-renders surfaces
out-of-band: the cloud's feed preview frames are opaque-origin sandboxes
served by `/s/:id`, which needs `?theme=&mode=` to reproduce the viewer's
exact look. Without the ids, cross-workspace previews (the org feed) fell
back to each source workspace's persisted theme instead of the viewer's.

Add a second `meta: { theme, mode }` argument carrying the resolved theme id
and light/dark scheme the engine already knows (it builds its own surface
URLs from them). Additive: the tokens argument is unchanged and the default
self-hosted host ignores it — parity preserved.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@benvinegar benvinegar merged commit ffe7099 into main Jul 1, 2026
9 checks passed
@benvinegar benvinegar deleted the feat/theme-change-meta branch July 1, 2026 02:59
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