You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(themer): sync themes across tabs, Studio-style footer actions, and review follow-ups to #2065 - #2066
Follow-up to #2065, now that it has landed on main (this PR was stacked on it and GitHub retargeted it to main when the branch went). Sixteen commits, each a delta main lacks.
What it does
Cross-tab sync actually runs.main ships sync.ts (BroadcastChannel + a Web Lock electing the one tab that persists) but nothing calls it: PersistActorSnapshot still writes on requestIdleCallback. It now runs syncThemer(actorRef, {persist: writePersistedSnapshot}), so themes picked, edited, added or removed in one tab show in the others, writes are idle-deferred and flushed on pagehide, and knip stops flagging sync.ts.
Sidebar footers follow the Studio's document footer (one main action, the rest behind a … menu — see screenshots):
Header: only the split preview toggle and the close button (the code button and the back arrow are gone).
List footer: Edit when the applied theme is one of the user's own, Duplicate & Edit for a preset or the configured theme; the menu holds Add theme, Add from image, Add from code and — for a listed applied theme — Show theme code (the snippet dialog, moved here from the header). The image picker's hidden input is now its own ImageFileInput, which the menu item clicks; the menu button shows loading while an image's palette is read.
Editor footer: Done, with Remove in the menu.
Removed themes: a Done footer back to the list, in place of the header's back arrow.
Buttons are the Studio's own size (padding: 2, gap: 2, font size 1, as DEFAULT_BUTTON_PROPS in sanity's Button), in ghost mode, and the main actions carry an icon: Edit a pencil, Duplicate & Edit a copy, Done a checkmark. The footer menus animate like the cards' do.
The list's two dialogs are states of the machine's list flow (idle / pasting / snippet; events dialog.paste, dialog.snippet — guarded on an applied listed theme, left when it goes away — and dialog.close), so leaving the list closes them, and the persisted-snapshot schema restores a dialog-open snapshot to the plain list.
The cards' own … menus are untouched. Labels are short on purpose: your BoundaryElementProvider confines the menu to the sidebar, which can be narrow.
Every element id (menus, dialogs, the paste dialog's error) comes from useId(); no hardcoded ids remain under src/.
Safari: the Studio scaled wrongly while it resized with the split copy. Safari (WebKit, as of Technology Preview 253) paints a view-transition snapshot that has a filter animating on it as raw layer contents, losing the object-fit stretch of resizeStudioRules — remove the blur and it animates like Chrome. The blur now sits on the ::view-transition-image-pair, which holds both snapshots and is a plain box, as one blur peaking at the cross-over (6px, what the two 12px blurs on the snapshots crossfaded into at that point), while the snapshots keep the stretch and only fade. Verified in Chromium and WebKit on the real Studio that the pair carries the blur and the snapshots keep their sizing rules. A reduced case for Safari (variant A = snapshots, variant B = image pair) is attached as an artifact: safari-snapshot-filter-repro.html.
Review comments on #2065 that still applied, fixed here:
Hidden list leaves picker busy (Bugbot) — useImagePalette guarded setBusy(false) with a mounted flag that goes false when the list's Activity hides on theme.add, so the image button stayed loading. The list's state survives being hidden; only the pick number guards the result now.
Wheel ignores reduced motion (Bugbot, Copilot) — the navbar renders the plain ColorWheelIcon under prefers-reduced-motion: reduce (usePrefersReducedMotion from @sanity/ui), so AnimatedColorWheelIcon and motion/react are not even loaded then.
Themer toggle inert on small viewports — per review, left to the toolbar's own breakpoints; ThemerProvider reads the sidebar threshold from MIN_MEDIA_INDEX_FOR_SIDEBAR (2).
Applied theme background is incomplete — reverted per review, for a follow-up PR.
Also: the commented-out crossfade experiment in ViewTransitions.css.ts (it refers to keyframes that are gone), docs for the layout (no more panel/split/moving tags or ThemerLayout.css.ts), the reducer and ThemerProps (minus images/view, which nothing picks), the README's title option in place of the removed config, a minor changeset, and the AGENTS.md note about Turbo's pnpm run re-resolving the lockfile locally.
Split types clash on sidebar toggle — opening the sidebar with the split on adds both open and split-screen:open, so the Studio gets the resize and the blur-fade together. Looks deliberate (the split copy needs its type to slide in); your call.
Lazy AnimatedColorWheelIcon imports motion/react at navbar mount (Copilot) — a startup-cost question, not a bug; the hover spin needs the icon ready.
Closing the sidebar keeps the split — you marked it intentional. Theme rebuilt on every render — React Compiler, as you said. Config card shows the stock theme — by design until config returns. Changeset should be major — minor, 0.x.
Verification
Manual, in the test studio (video below): footer buttons measured at 24.98px, the same as the document footer's Publish, with copy/checkmark icons; header buttons, both footers and their menus, Duplicate & Edit → editor → Remove → Show removed (1) → Delete → back in the list, Show theme code present for a preset and absent for the configured theme; no console errors.
Dialogs, on the built studio (Playwright): Add from code opens the paste dialog (clipboard unavailable), a bad code shows the error, Escape closes it; Show theme code opens the snippet dialog for a preset and does not return after a reload; the configured theme's menu has no snippet item.
Split transition probed in Chromium and WebKit (Playwright) on the built Studio: ::view-transition-image-pair gets the 6px blur, the snapshots our fades plus the stretch rules, the split copy its slide, all at 480ms.
cursorBot
changed the title
fix(themer): clear CI for the <ViewTransition> / <Activity> rework (stacked on #2065)
fix(themer): clear CI and simplify the machine for the <ViewTransition> / <Activity> rework (stacked on #2065)
Oct 1, 2026
The small-screen stacking described here is currently unreachable: plugin.tsx:117-121 forces the sidebar closed at media indexes ≤2 and only permits split at indexes >3. Either align those breakpoint gates so the mobile layout can render, or remove the claim that the split copy appears on top on small screens.
Your themes stay the same across the Studio's tabs: a theme picked, edited, added or removed in one tab shows in the others right away, while which tab has the sidebar open, or the split preview on, stays each tab's own. The tool picks up where you left off after a reload, and what it keeps in `localStorage` is validated as it is read back — what earlier versions stored is migrated — and written from one tab at a time.
The sidebar's footers follow the Studio's document footer: one primary action — `Edit` for your own applied theme, `Duplicate & Edit` for a preset or the configured theme, `Done` in the editor and among the removed themes — with the other actions (adding a theme, from an image or from a shared code, the applied theme's code, removing the theme being edited) behind the menu button next to it. The header keeps the split preview toggle and the close button.
`@sanity/themer/tool` adds a themer sidebar to the Studio for these themes. It lists the configured theme, the presets and your own themes, each previewed as a tiny Studio in both color schemes, and picking one applies it live to the whole Studio while you browse around — in the appearance the Studio is set to or, with the split-screen toggle in the sidebar header, twice: the Studio next to the sidebar keeps the appearance it is set to, and a copy in the opposite scheme slides in from off screen on the far side (or on top, on small screens, where the sidebar covers the Studio instead of standing next to it), through React's `ViewTransition` — which is why the tool requires React 19.3. The cards drag into any order (or move from their menu), which sticks between sessions, and a theme's menu copies it as a short code to share — paste a code into the list, or add it through the paste button, to get the theme in another Studio. Your own themes are edited scheme by scheme — a light mode and a dark mode card with accent/text/background pickers and a contrast slider each, the one the Studio is showing marked as active — add one from scratch, duplicate a preset to start from it, or take the colors from an image: its palette is read on device (the image is drawn onto a canvas and its vibrant and muted colors extracted right there, nothing is uploaded), the vibrant color becomes the accent (adjusted until a button label reads on it), the muted one the text color and the light and dark muted colors tint the backgrounds, and a row of variants previews the theme built around each swatch instead — with an "I'm feeling lucky" button that picks an interesting one. Themes can be removed and restored, and a dialog shows the `buildTheme` snippet that makes the applied theme permanent:
`@sanity/themer/tool` adds a themer sidebar to the Studio for these themes. It lists the configured theme, the presets and your own themes, each previewed as a tiny Studio in both color schemes, and picking one applies it live to the whole Studio while you browse around — in the appearance the Studio is set to or, with the split-screen toggle in the sidebar header, twice: the Studio next to the sidebar keeps the appearance it is set to, and a copy in the opposite scheme slides in from off screen on the far side, through React's `ViewTransition` — which is why the tool requires React 19.3. The cards drag into any order (or move from their menu), which sticks between sessions, and a theme's menu copies it as a short code to share — paste a code into the list, or add it through the paste button, to get the theme in another Studio. Your own themes are edited scheme by scheme — a light mode and a dark mode card with accent/text/background pickers and a contrast slider each, the one the Studio is showing marked as active — add one from scratch, duplicate a preset to start from it, or take the colors from an image: its palette is read on device (the image is drawn onto a canvas and its vibrant and muted colors extracted right there, nothing is uploaded), the vibrant color becomes the accent (adjusted until a button label reads on it), the muted one the text color and the light and dark muted colors tint the backgrounds, and a row of variants previews the theme built around each swatch instead — with an "I'm feeling lucky" button that picks an interesting one. Themes can be removed and restored, and a dialog shows the `buildTheme` snippet that makes the applied theme permanent:
`PersistActorSnapshot` runs `syncThemer` — the cross-tab sync over BroadcastChannel with the one persisting tab elected through a Web Lock — in place of its own idle-deferred write, which is what makes `sync.ts` run at all.
Co-authored-by: Cody Olsen <[email protected]>
…are, and the title option
The layout's doc no longer describes machine tags that are gone (`panel`, `split`, `moving`) or a stylesheet by another name; the reducer's state and `initialToolState` get their docs; `ThemerProps` loses `images` and `view`, which the sidebar and the editor select from the actor now; the README describes the `title` option in place of the removed `config`.
Co-authored-by: Cody Olsen <[email protected]>
Adding the theme from an image opens the editor, which hides the list in an `Activity`: its effects are torn down, the mounted flag went false, and the flag stayed set — the picker was still loading when the list showed again. The list's state survives being hidden, so only the pick number guards the result now.
Co-authored-by: Cody Olsen <[email protected]>
The spin is a transform the motion value drives, which `MotionConfig`'s reduced-motion setting does not reach — as the icon's own doc promised, only the colors come and go now.
Co-authored-by: Cody Olsen <[email protected]>
…resolve the layout's background
`ThemerProvider` keeps the sidebar closed below the media index the sidebar needs, so the toggle there span its icon and set `open` without anything showing — `ThemerNavbar` no longer registers it there, and both read the threshold from one constant. The layout's background is the applied theme's resolved one, so a theme that only sets an accent has one too.
Co-authored-by: Cody Olsen <[email protected]>
…u, like the Studio's document footer
The header keeps the split preview toggle and the close button. The list's footer takes the applied theme on to the editor — `Edit` for a custom theme, `Duplicate & Edit` for a preset or the configured theme — with adding a theme (plain, from an image, from a shared code) and the applied theme's code behind the menu button; the editor's footer is `Done` with `Remove` in its menu; the removed themes get a `Done` footer in place of the header's back arrow. The hidden image input moves out of `ImageFileButton` into `ImageFileInput`, which the menu item clicks.
Co-authored-by: Cody Olsen <[email protected]>
The Studio's own buttons are `padding: 2`, `gap: 2` at font size 1 — the sidebar footers were a size up. The primary actions carry an icon like the document footer's `Publish`: `Edit` a pencil, `Duplicate & Edit` a copy, `Done` a checkmark.
Co-authored-by: Cody Olsen <[email protected]>
resolveThemeOptions is not the final background used by the applied theme: buildTheme goes through buildPalette, which can darken or lighten user-entered backgrounds to satisfy contrast (see theme/theme.test.ts:169-188). For example, a dark #888888 option makes this layout #888888 while the Studio uses the adjusted palette.dark.black, so the wrong color can still show behind split/view transitions. Derive this value from the built palette (dark.black / light.white) instead.
The reason will be displayed to describe this comment to others. Learn more.
no, this is the wrong place to have this. Put this one level up as there is no point at all in rendering <AnimatedColorWheelIcon> if it should have zero motion, <ColorWheelIcon> can be used instead
Every element id — the menus of the cards and the footers, the two dialogs and the paste dialog's error the input is described by — comes from `useId()` instead of a hardcoded string, so two Studios on a page cannot share one. The footer menus animate like the cards' do.
Co-authored-by: Cody Olsen <[email protected]>
…motion
The check moves up to the navbar: there is nothing for `AnimatedColorWheelIcon` to do when nothing may move, so the plain `ColorWheelIcon` renders instead — and `motion/react` stays out of the navbar's chunk, as `usePrefersReducedMotion` comes from `@sanity/ui`.
Co-authored-by: Cody Olsen <[email protected]>
…for Safari
Safari (WebKit, as of Technology Preview 253) paints a filtered view-transition snapshot as raw layer contents and loses the `object-fit` stretch of `resizeStudioRules`, so the Studio scaled wrongly while it resized with the split copy; without the filter it animates as in Chrome. The blur now sits on the `::view-transition-image-pair`, which holds both snapshots and is a plain box, as one blur peaking at the cross-over — 6px, what the two 12px blurs on the snapshots crossfaded into at that point — while the snapshots keep the stretch and only fade.
Co-authored-by: Cody Olsen <[email protected]>
resolveThemeOptions returns the requested background, but buildTheme uses buildPalette, which can darken or lighten that value to enforce contrast (buildPalette.ts:106-114; covered by theme.test.ts:169-188). For example, a dark background of #888888 makes this outer layout #888888 while the themed Studio uses a darker palette.black, so the backdrop exposed during split/view transitions still has the wrong color. Derive this value from the same generated palette (the scheme's black/white) or a shared helper instead.
… were
Per review: the toolbar handles the responsive breakpoints itself, so the navbar does not reconstruct `__internal_actions` by media index; the sidebar threshold stays in `MIN_MEDIA_INDEX_FOR_SIDEBAR` (2, the largest index that is too small) for `ThemerProvider` alone; the resolved background comes back in a follow-up PR.
Co-authored-by: Cody Olsen <[email protected]>
The paste dialog and the applied theme's snippet dialog were `useState`s of the list. They are child states of the list flow now (`idle`, `pasting`, `snippet`), with `dialog.paste`, `dialog.snippet` — guarded on an applied listed theme, and left when it goes away — and `dialog.close`; leaving the list closes them. The persisted-snapshot schema accepts the nested value and restores to the plain list, so a dialog does not reopen after a reload.
Co-authored-by: Cody Olsen <[email protected]>
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
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.
Follow-up to #2065, now that it has landed on
main(this PR was stacked on it and GitHub retargeted it tomainwhen the branch went). Sixteen commits, each a deltamainlacks.What it does
Cross-tab sync actually runs.
mainshipssync.ts(BroadcastChannel + a Web Lock electing the one tab that persists) but nothing calls it:PersistActorSnapshotstill writes onrequestIdleCallback. It now runssyncThemer(actorRef, {persist: writePersistedSnapshot}), so themes picked, edited, added or removed in one tab show in the others, writes are idle-deferred and flushed onpagehide, and knip stops flaggingsync.ts.Sidebar footers follow the Studio's document footer (one main action, the rest behind a
…menu — see screenshots):Editwhen the applied theme is one of the user's own,Duplicate & Editfor a preset or the configured theme; the menu holdsAdd theme,Add from image,Add from codeand — for a listed applied theme —Show theme code(the snippet dialog, moved here from the header). The image picker's hidden input is now its ownImageFileInput, which the menu item clicks; the menu button showsloadingwhile an image's palette is read.Done, withRemovein the menu.Donefooter back to the list, in place of the header's back arrow.padding: 2,gap: 2, font size 1, asDEFAULT_BUTTON_PROPSin sanity'sButton), inghostmode, and the main actions carry an icon:Edita pencil,Duplicate & Edita copy,Donea checkmark. The footer menus animate like the cards' do.idle/pasting/snippet; eventsdialog.paste,dialog.snippet— guarded on an applied listed theme, left when it goes away — anddialog.close), so leaving the list closes them, and the persisted-snapshot schema restores a dialog-open snapshot to the plain list.…menus are untouched. Labels are short on purpose: yourBoundaryElementProviderconfines the menu to the sidebar, which can be narrow.useId(); no hardcoded ids remain undersrc/.The Studio document footer (Publish and the more menu) next to the themer footer (Duplicate & Edit and the more menu), the buttons the same height
Themer list footer: Duplicate & Edit plus the menu with Add theme, Add from image, Add from code, Show theme code
Themer editor footer: Done plus the menu with Remove
Safari: the Studio scaled wrongly while it resized with the split copy. Safari (WebKit, as of Technology Preview 253) paints a view-transition snapshot that has a
filteranimating on it as raw layer contents, losing theobject-fitstretch ofresizeStudioRules— remove the blur and it animates like Chrome. The blur now sits on the::view-transition-image-pair, which holds both snapshots and is a plain box, as one blur peaking at the cross-over (6px, what the two 12px blurs on the snapshots crossfaded into at that point), while the snapshots keep the stretch and only fade. Verified in Chromium and WebKit on the real Studio that the pair carries the blur and the snapshots keep their sizing rules. A reduced case for Safari (variant A = snapshots, variant B = image pair) is attached as an artifact:safari-snapshot-filter-repro.html.Review comments on #2065 that still applied, fixed here:
useImagePaletteguardedsetBusy(false)with a mounted flag that goes false when the list'sActivityhides ontheme.add, so the image button stayed loading. The list's state survives being hidden; only the pick number guards the result now.ColorWheelIconunderprefers-reduced-motion: reduce(usePrefersReducedMotionfrom@sanity/ui), soAnimatedColorWheelIconandmotion/reactare not even loaded then.ThemerProviderreads the sidebar threshold fromMIN_MEDIA_INDEX_FOR_SIDEBAR(2).Also: the commented-out crossfade experiment in
ViewTransitions.css.ts(it refers to keyframes that are gone), docs for the layout (no morepanel/split/movingtags orThemerLayout.css.ts), the reducer andThemerProps(minusimages/view, which nothing picks), the README'stitleoption in place of the removedconfig, aminorchangeset, and theAGENTS.mdnote about Turbo'spnpm runre-resolving the lockfile locally.Review comments on #2065 I did not act on
openandsplit-screen:open, so the Studio gets the resize and the blur-fade together. Looks deliberate (the split copy needs its type to slide in); your call.AnimatedColorWheelIconimportsmotion/reactat navbar mount (Copilot) — a startup-cost question, not a bug; the hover spin needs the icon ready.configreturns. Changeset should be major —minor, 0.x.Verification
Publish, withcopy/checkmarkicons; header buttons, both footers and their menus,Duplicate & Edit→ editor →Remove→Show removed (1)→Delete→ back in the list,Show theme codepresent for a preset and absent for the configured theme; no console errors.Add from codeopens the paste dialog (clipboard unavailable), a bad code shows the error, Escape closes it;Show theme codeopens the snippet dialog for a preset and does not return after a reload; the configured theme's menu has no snippet item.::view-transition-image-pairgets the 6px blur, the snapshots our fades plus the stretch rules, the split copy its slide, all at 480ms.oxfmt --checkclean;oxlint --disable-nested-config(whole repo, type-aware) 0 errors;CI=1 knipclean@sanity/themertsdown build (publint clean) and the Storybook static buildvitest run --project @sanity/themer: 13 files, 143 testspnpm install --frozen-lockfilepassesthemer-sidebar-footer-actions.mp4
To show artifacts inline, enable in settings.