Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-9248 feat(themes): first-class backdrop and glass, and agent-built themes (#10589)

Jiayuan Zhang634b083fd029
diff --git a/apps/desktop/src/renderer/src/components/desktop-layout.tsx b/apps/desktop/src/renderer/src/components/desktop-layout.tsx
index beb772923d..04ae7f4591 100644
--- a/apps/desktop/src/renderer/src/components/desktop-layout.tsx
+++ b/apps/desktop/src/renderer/src/components/desktop-layout.tsx
@@ -262,8 +262,10 @@ export function DesktopShell() {
IndexRedirect, not a route. */}
<WorkspaceSlugProvider slug={slug}>
<DesktopInboxBridge />
- <div className="flex h-screen bg-app-shell">
- {/* bg-app-shell is the wrapper's non-inset fill, so it also owns the
+ <div className="flex h-screen">
+ {/* The wrapper alone paints the frame: a second fill under it would
+ double the frame's glass over a theme's backdrop.
+ bg-app-shell is the wrapper's non-inset fill, so it also owns the
non-inset half of --sidebar-wrapper-fill. sidebar.tsx supplies the
inset half of both. Anything that has to paint an opaque layer
over this wrapper (the tab flares) reads the variable rather than
diff --git a/apps/docs/content/docs/developers/themes.fr.mdx b/apps/docs/content/docs/developers/themes.fr.mdx
index b3181806a7..3a4299160c 100644
--- a/apps/docs/content/docs/developers/themes.fr.mdx
+++ b/apps/docs/content/docs/developers/themes.fr.mdx
@@ -149,6 +149,27 @@ Les id d'option font 1 à 48 caractères parmi `a-z`, `0-9` et `-`, et commencen
[data-mc="content"] { max-width: var(--page-width); }
```
+## Arrière-plan et verre
+
+Un thème peut placer une image derrière l’application — un dégradé, une image ou un SVG animé — et transformer le cadre et la page en verre par-dessus. Définissez ces variables par mode :
+
+```css
+.theme-dark {
+ --backdrop: url(night.svg) center / cover no-repeat;
+ --backdrop-color: #1e1e4a;
+ --glass-opacity: 72%;
+ --glass-blur: 18px;
+ --frame-glass-opacity: 0%;
+ --frame-glass-blur: 0px;
+}
+```
+
+- `--backdrop` est une valeur CSS `background` peinte sous toute la fenêtre, sur le bureau comme sur le web. Les images doivent être dans le dossier du thème ; l’animation propre d’un SVG est jouée.
+- `--backdrop-color` est obligatoire avec un arrière-plan : la couleur unie affichée pendant le chargement, et celle sur laquelle `theme:check` mesure le verre.
+- `--glass-opacity` et `--glass-blur` fixent la part de la couleur de la page qui couvre l’arrière-plan et le flou de l’arrière-plan derrière elle. `--frame-glass-opacity` et `--frame-glass-blur` font de même pour le rail, la barre d’outils de la fenêtre, la barre d’onglets et la barre du bas.
+
+Utilisez-les plutôt qu’un `--app-shell` transparent ou un `background` sur `body` : l’application change alors d’arrière-plan sans faire clignoter la fenêtre. [`examples/themes/night-sky`](https://github.com/multica-ai/multica/tree/main/examples/themes/night-sky) en est un exemple complet.
+
## Sélecteurs
Ciblez les ancres, les slots et les attributs d'état — pas les noms de classes ni la structure du DOM, qui changent sans préavis. Ancres, slots et attributs d'état restent stables jusqu'au prochain `apiVersion`.
@@ -178,7 +199,7 @@ Tout ce qui charge une ressource est refusé, car le CSS peut lire le contenu de
- utilise une variable non publique, sauf si c'est un id d'option ou si le thème la lit lui-même avec `var()` ;
- définit des variables ailleurs que sur `.theme-light` et `.theme-dark` sans sélecteur descendant, ce qui empêche le sélecteur de thème de relire ses couleurs ;
- nomme une famille générique (`sans-serif`, `serif`, …) ou un mot-clé `ui-*` dans une pile de polices, ce qui écraserait la police CJK choisie ;
-- n'atteint pas le contraste WCAG AA dans un des modes : `--foreground` et `--muted-foreground` demandent 4,5:1 sur chaque surface, `--brand` 4,5:1 sur les surfaces de lecture, le libellé du bouton principal 4,5:1 sur le bouton, et `--faint-foreground` 3:1. Le texte des infobulles demande 4,5:1 sur `--tooltip`, et celui d'une puce d'affichage enfoncée 4,5:1 sur son fond. Les infobulles utilisent toujours le texte du mode sombre : définissez `--tooltip-foreground` pour le changer. Une puce enfoncée prend `--input` comme fond, sauf si vous définissez `--display-chip-pressed-background`.
+- n'atteint pas le contraste WCAG AA dans un des modes : `--foreground` et `--muted-foreground` demandent 4,5:1 sur chaque surface, `--brand` 4,5:1 sur les surfaces de lecture, le libellé du bouton principal 4,5:1 sur le bouton, et `--faint-foreground` 3:1. Le texte des infobulles demande 4,5:1 sur `--tooltip`, et celui d'une puce d'affichage enfoncée 4,5:1 sur son fond. Les infobulles utilisent toujours le texte du mode sombre : définissez `--tooltip-foreground` pour le changer. Une puce enfoncée prend `--input` comme fond, sauf si vous définissez `--display-chip-pressed-background`. Avec un arrière-plan, le cadre et la page sont mesurés comme du verre posé sur `--backdrop-color`.
## Vérifier et prévisualiser
@@ -196,6 +217,14 @@ pnpm theme:preview path/to/paper --out preview # preview/light.png et preview/
Si un thème masque ou casse une partie de l'interface pendant que vous travaillez dessus, ouvrez l'app avec `?theme=default`, ou maintenez **Maj** juste après le chargement ; voir [Quand un thème casse quelque chose](/themes#quand-un-thème-casse-quelque-chose).
+Le vérificateur fonctionne aussi sans installer le dépôt, depuis un clone partiel et Node 22.18 ou plus récent. Les agents reçoivent les mêmes commandes dans leur skill Multica intégré :
+
+```bash
+git clone --depth 1 --filter=blob:none --sparse https://github.com/multica-ai/multica.git multica-themes
+git -C multica-themes sparse-checkout set docs scripts packages/core packages/ui
+node multica-themes/scripts/theme-check.mjs path/to/paper
+```
+
## Publier dans la boutique
La boutique de thèmes liste les thèmes du registre [multica-ai/multica-themes](https://github.com/multica-ai/multica-themes). Son [guide de contribution](https://github.com/multica-ai/multica-themes/blob/main/CONTRIBUTING.md) donne les détails ; en bref :
diff --git a/apps/docs/content/docs/developers/themes.ja.mdx b/apps/docs/content/docs/developers/themes.ja.mdx
index 94dfeca0f6..f02c169ef9 100644
--- a/apps/docs/content/docs/developers/themes.ja.mdx
+++ b/apps/docs/content/docs/developers/themes.ja.mdx
@@ -149,6 +149,27 @@ paper/
[data-mc="content"] { max-width: var(--page-width); }
```
+## 背景とガラス
+
+テーマはアプリの背後に、グラデーション、画像、アニメーション SVG などの絵を置き、フレームとページをその上のガラスにできます。モードごとに設定します。
+
+```css
+.theme-dark {
+ --backdrop: url(night.svg) center / cover no-repeat;
+ --backdrop-color: #1e1e4a;
+ --glass-opacity: 72%;
+ --glass-blur: 18px;
+ --frame-glass-opacity: 0%;
+ --frame-glass-blur: 0px;
+}
+```
+
+- `--backdrop` はウィンドウ全体の下に描かれる CSS の `background` 値で、デスクトップでも Web でも表示されます。画像はテーマフォルダ内に置く必要があり、SVG 自体のアニメーションは再生されます。
+- 背景を使うときは `--backdrop-color` が必須です。読み込み中に表示される単色で、`theme:check` がガラスのコントラストを測る下地でもあります。
+- `--glass-opacity` と `--glass-blur` は、ページ自身の色が背景をどれだけ覆うかと、ページの後ろで背景をどれだけぼかすかを決めます。`--frame-glass-opacity` と `--frame-glass-blur` はレール、ウィンドウツールバー、タブバー、ボトムバーに同じことをします。
+
+`--app-shell` を透明にしたり `body` に `background` を設定したりする代わりに、これらを使ってください。そうすれば背景を変えてもウィンドウがちらつきません。[`examples/themes/night-sky`](https://github.com/multica-ai/multica/tree/main/examples/themes/night-sky) が完全な例です。
+
## セレクタ
クラス名や DOM 構造ではなく、アンカー、スロット、状態フックを対象にしてください。前者は予告なく変わります。アンカー、スロット、フックは次の `apiVersion` まで維持されます。
@@ -178,7 +199,7 @@ paper/
- 公開されていない変数を使っている(オプションの id か、テーマ自身が `var()` で読む変数を除く)。
- `.theme-light` と `.theme-dark` 以外の場所で、子孫セレクタなしに変数を設定している。テーマピッカーがテーマの色を読み取れなくなります。
- フォントスタックに汎用ファミリー(`sans-serif`、`serif` …)や `ui-*` キーワードがある。本人が選んだ CJK フォントが効かなくなります。
-- どちらかのモードで WCAG AA のコントラストを満たさない:`--foreground` と `--muted-foreground` はすべてのサーフェスで 4.5:1、`--brand` は読むためのサーフェスで 4.5:1、プライマリボタンのラベルはボタン上で 4.5:1、`--faint-foreground` は 3:1 が必要です。ツールチップの文字は `--tooltip` 上で 4.5:1、押された表示設定チップの文字はその塗りの上で 4.5:1 が必要です。ツールチップは常にダークモードの文字色を使うため、変えるには `--tooltip-foreground` を設定します。押されたチップは `--display-chip-pressed-background` を設定しない限り `--input` で塗られます。
+- どちらかのモードで WCAG AA のコントラストを満たさない:`--foreground` と `--muted-foreground` はすべてのサーフェスで 4.5:1、`--brand` は読むためのサーフェスで 4.5:1、プライマリボタンのラベルはボタン上で 4.5:1、`--faint-foreground` は 3:1 が必要です。ツールチップの文字は `--tooltip` 上で 4.5:1、押された表示設定チップの文字はその塗りの上で 4.5:1 が必要です。ツールチップは常にダークモードの文字色を使うため、変えるには `--tooltip-foreground` を設定します。押されたチップは `--display-chip-pressed-background` を設定しない限り `--input` で塗られます。 背景がある場合、フレームとページは `--backdrop-color` の上のガラスとして測定されます。
## チェックとプレビュー
@@ -196,6 +217,14 @@ pnpm theme:preview path/to/paper --out preview # preview/light.png と preview
作業中にテーマでインターフェースが隠れたり崩れたりしたら、`?theme=default` を付けてアプリを開くか、読み込み直後に **Shift** を押し続けます。[テーマで表示が崩れたとき](/themes#テーマで表示が崩れたとき)を参照してください。
+チェッカーはリポジトリをインストールしなくても、スパースクローンと Node 22.18 以降で実行できます。エージェントも、組み込みの Multica スキルで同じコマンドを使います。
+
+```bash
+git clone --depth 1 --filter=blob:none --sparse https://github.com/multica-ai/multica.git multica-themes
+git -C multica-themes sparse-checkout set docs scripts packages/core packages/ui
+node multica-themes/scripts/theme-check.mjs path/to/paper
+```
+
## テーマストアに公開する
テーマストアには [multica-ai/multica-themes](https://github.com/multica-ai/multica-themes) レジストリのテーマが並びます。詳しくはその[コントリビューションガイド](https://github.com/multica-ai/multica-themes/blob/main/CONTRIBUTING.md)を参照してください。要点は次のとおりです。
diff --git a/apps/docs/content/docs/developers/themes.ko.mdx b/apps/docs/content/docs/developers/themes.ko.mdx
index 6c974e9f79..4558fbc52b 100644
--- a/apps/docs/content/docs/developers/themes.ko.mdx
+++ b/apps/docs/content/docs/developers/themes.ko.mdx
@@ -149,6 +149,27 @@ paper/
[data-mc="content"] { max-width: var(--page-width); }
```
+## 배경과 유리
+
+테마는 앱 뒤에 그라데이션, 이미지, 애니메이션 SVG 같은 그림을 두고, 프레임과 페이지를 그 위의 유리로 바꿀 수 있습니다. 모드별로 설정합니다.
+
+```css
+.theme-dark {
+ --backdrop: url(night.svg) center / cover no-repeat;
+ --backdrop-color: #1e1e4a;
+ --glass-opacity: 72%;
+ --glass-blur: 18px;
+ --frame-glass-opacity: 0%;
+ --frame-glass-blur: 0px;
+}
+```
+
+- `--backdrop`은 창 전체 아래에 그려지는 CSS `background` 값으로, 데스크톱과 웹 모두에 표시됩니다. 이미지는 테마 폴더 안에 있어야 하며, SVG 자체의 애니메이션은 재생됩니다.
+- 배경을 쓸 때는 `--backdrop-color`가 필수입니다. 로딩 중에 보이는 단색이며, `theme:check`가 유리의 대비를 잴 때 쓰는 바탕색이기도 합니다.
+- `--glass-opacity`와 `--glass-blur`는 페이지 자체 색이 배경을 얼마나 덮는지, 페이지 뒤의 배경을 얼마나 흐리게 할지 정합니다. `--frame-glass-opacity`와 `--frame-glass-blur`는 레일, 창 도구 모음, 탭 바, 하단 바에 같은 역할을 합니다.
+
+`--app-shell`을 투명하게 하거나 `body`에 `background`를 지정하는 대신 이 변수들을 쓰세요. 그러면 배경을 바꿔도 창이 깜빡이지 않습니다. [`examples/themes/night-sky`](https://github.com/multica-ai/multica/tree/main/examples/themes/night-sky)가 완전한 예입니다.
+
## 선택자
클래스 이름이나 DOM 구조가 아니라 앵커, 슬롯, 상태 훅을 대상으로 하세요. 클래스 이름과 DOM 구조는 예고 없이 바뀝니다. 앵커, 슬롯, 훅은 다음 `apiVersion`까지 유지됩니다.
@@ -178,7 +199,7 @@ paper/
- 공개되지 않은 변수를 쓰는 경우. 옵션 id이거나 테마가 직접 `var()`로 읽는 변수는 예외입니다.
- `.theme-light`와 `.theme-dark`가 아닌 곳에 하위 선택자 없이 변수를 설정한 경우. 테마 선택기가 테마의 색을 읽어 올 수 없게 됩니다.
- 글꼴 스택에 일반 글꼴 계열(`sans-serif`, `serif`, …)이나 `ui-*` 키워드를 쓴 경우. 사용자가 고른 CJK 글꼴이 적용되지 않게 됩니다.
-- 어느 한 모드에서 WCAG AA 대비를 충족하지 못하는 경우: `--foreground`와 `--muted-foreground`는 모든 표면에서 4.5:1, `--brand`는 읽기 표면에서 4.5:1, 기본 버튼 라벨은 버튼 위에서 4.5:1, `--faint-foreground`는 3:1이 필요합니다. 툴팁 글자는 `--tooltip` 위에서 4.5:1, 눌린 표시 설정 칩의 글자는 칩 배경 위에서 4.5:1이 필요합니다. 툴팁은 항상 다크 모드 글자색을 쓰므로 바꾸려면 `--tooltip-foreground`를 설정하세요. 눌린 칩은 `--display-chip-pressed-background`를 설정하지 않으면 `--input`으로 채워집니다.
+- 어느 한 모드에서 WCAG AA 대비를 충족하지 못하는 경우: `--foreground`와 `--muted-foreground`는 모든 표면에서 4.5:1, `--brand`는 읽기 표면에서 4.5:1, 기본 버튼 라벨은 버튼 위에서 4.5:1, `--faint-foreground`는 3:1이 필요합니다. 툴팁 글자는 `--tooltip` 위에서 4.5:1, 눌린 표시 설정 칩의 글자는 칩 배경 위에서 4.5:1이 필요합니다. 툴팁은 항상 다크 모드 글자색을 쓰므로 바꾸려면 `--tooltip-foreground`를 설정하세요. 눌린 칩은 `--display-chip-pressed-background`를 설정하지 않으면 `--input`으로 채워집니다. 배경이 있으면 프레임과 페이지는 `--backdrop-color` 위의 유리로 측정됩니다.
## 검사와 미리보기
@@ -196,6 +217,14 @@ pnpm theme:preview path/to/paper --out preview # preview/light.png와 preview/
작업 중에 테마 때문에 인터페이스가 가려지거나 깨지면 `?theme=default`를 붙여 앱을 열거나, 로드 직후 **Shift**를 누르고 있으세요. [테마 때문에 화면이 깨졌을 때](/themes#테마-때문에-화면이-깨졌을-때)를 참고하세요.
+검사기는 저장소를 설치하지 않고도 스파스 클론과 Node 22.18 이상으로 실행할 수 있습니다. 에이전트도 기본 제공 Multica 스킬에서 같은 명령을 받습니다.
+
+```bash
+git clone --depth 1 --filter=blob:none --sparse https://github.com/multica-ai/multica.git multica-themes
+git -C multica-themes sparse-checkout set docs scripts packages/core packages/ui
+node multica-themes/scripts/theme-check.mjs path/to/paper
+```
+
## 테마 스토어에 게시하기
테마 스토어는 [multica-ai/multica-themes](https://github.com/multica-ai/multica-themes) 레지스트리의 테마를 보여 줍니다. 자세한 내용은 [기여 가이드](https://github.com/multica-ai/multica-themes/blob/main/CONTRIBUTING.md)에 있으며, 요약하면 다음과 같습니다.
diff --git a/apps/docs/content/docs/developers/themes.mdx b/apps/docs/content/docs/developers/themes.mdx
index b169ff7480..15966f7136 100644
--- a/apps/docs/content/docs/developers/themes.mdx
+++ b/apps/docs/content/docs/developers/themes.mdx
@@ -149,6 +149,27 @@ Option ids are 1–48 characters of `a-z`, `0-9`, and `-`, starting with a lette
[data-mc="content"] { max-width: var(--page-width); }
```
+## Backdrop and glass
+
+A theme can put a picture behind the app — a gradient, an image, or an animated SVG — and turn the frame and the page into glass over it. Set these per mode:
+
+```css
+.theme-dark {
+ --backdrop: url(night.svg) center / cover no-repeat;
+ --backdrop-color: #1e1e4a;
+ --glass-opacity: 72%;
+ --glass-blur: 18px;
+ --frame-glass-opacity: 0%;
+ --frame-glass-blur: 0px;
+}
+```
+
+- `--backdrop` is a CSS `background` value painted under the whole window, on desktop and on the web. Images must be in the theme folder; an SVG's own animation plays.
+- `--backdrop-color` is required with a backdrop: the solid color shown while it loads, and the color `theme:check` measures the glass on.
+- `--glass-opacity` and `--glass-blur` set how much of the page's own color covers the backdrop and how much the backdrop blurs behind it. `--frame-glass-opacity` and `--frame-glass-blur` do the same for the rail, window toolbar, tab bar, and bottom bar.
+
+Use these instead of a transparent `--app-shell` or a `background` on `body`: the app then changes backdrops without flashing the window. [`examples/themes/night-sky`](https://github.com/multica-ai/multica/tree/main/examples/themes/night-sky) is a complete example.
+
## Selectors
Target anchors, slots, and state hooks — not class names or DOM structure, which change without notice. Anchors, slots, and hooks stay until the next `apiVersion`.
@@ -178,7 +199,7 @@ Escapes, case, and comments don't get around the check; it reads the CSS the way
- uses a variable that isn't public, unless it is an option id or the theme reads it itself with `var()`;
- sets variables anywhere other than `.theme-light` and `.theme-dark` without a descendant selector, so the theme picker can't read the theme's colors back;
- names a generic family (`sans-serif`, `serif`, …) or a `ui-*` keyword in a font stack, which would override the person's CJK font;
-- misses WCAG AA contrast in either mode: `--foreground` and `--muted-foreground` need 4.5:1 on every surface, `--brand` 4.5:1 on reading surfaces, the primary button label 4.5:1 on the button, and `--faint-foreground` 3:1. Tooltip text needs 4.5:1 on `--tooltip`, and a pressed display chip's text 4.5:1 on its fill. Tooltips always use dark-mode text, so set `--tooltip-foreground` to change it; pressed chips fill with `--input` unless you set `--display-chip-pressed-background`.
+- misses WCAG AA contrast in either mode: `--foreground` and `--muted-foreground` need 4.5:1 on every surface, `--brand` 4.5:1 on reading surfaces, the primary button label 4.5:1 on the button, and `--faint-foreground` 3:1. Tooltip text needs 4.5:1 on `--tooltip`, and a pressed display chip's text 4.5:1 on its fill. Tooltips always use dark-mode text, so set `--tooltip-foreground` to change it; pressed chips fill with `--input` unless you set `--display-chip-pressed-background`. With a backdrop, the frame and the page are measured as glass over `--backdrop-color`.
## Check and preview
@@ -196,6 +217,14 @@ pnpm theme:preview path/to/paper --out preview # preview/light.png and preview
If a theme hides or breaks part of the interface while you work on it, open the app with `?theme=default`, or hold **Shift** right after it loads; see [When a theme breaks something](/themes#when-a-theme-breaks-something).
+The checker also runs without installing the repository, from a sparse clone and Node 22.18 or newer. Agents get the same commands from their built-in Multica skill:
+
+```bash
+git clone --depth 1 --filter=blob:none --sparse https://github.com/multica-ai/multica.git multica-themes
+git -C multica-themes sparse-checkout set docs scripts packages/core packages/ui
+node multica-themes/scripts/theme-check.mjs path/to/paper
+```
+
## Publish to the theme store
The theme store lists themes from the [multica-ai/multica-themes](https://github.com/multica-ai/multica-themes) registry. Its [contributing guide](https://github.com/multica-ai/multica-themes/blob/main/CONTRIBUTING.md) has the details; in short:
diff --git a/apps/docs/content/docs/developers/themes.zh-Hant.mdx b/apps/docs/content/docs/developers/themes.zh-Hant.mdx
index f204ab4272..d99fa8e1dc 100644
--- a/apps/docs/content/docs/developers/themes.zh-Hant.mdx
+++ b/apps/docs/content/docs/developers/themes.zh-Hant.mdx
@@ -149,6 +149,27 @@ paper/
[data-mc="content"] { max-width: var(--page-width); }
```
+## 背景與玻璃
+
+主題可以在應用程式後面放一張畫面——漸層、圖片或動畫 SVG——並讓框架和頁面變成覆蓋在它上面的玻璃。依模式設定:
+
+```css
+.theme-dark {
+ --backdrop: url(night.svg) center / cover no-repeat;
+ --backdrop-color: #1e1e4a;
+ --glass-opacity: 72%;
+ --glass-blur: 18px;
+ --frame-glass-opacity: 0%;
+ --frame-glass-blur: 0px;
+}
+```
+
+- `--backdrop` 是一個 CSS `background` 值,鋪在整個視窗下面,桌面應用程式和網頁版都會顯示。圖片必須放在主題資料夾裡;SVG 自帶的動畫會播放。
+- 設定背景時必須同時設定 `--backdrop-color`:載入期間顯示的純色,也是 `theme:check` 計算玻璃對比度時用的底色。
+- `--glass-opacity` 和 `--glass-blur` 決定頁面自身顏色蓋住背景的程度,以及背景在頁面後面的模糊程度。`--frame-glass-opacity` 和 `--frame-glass-blur` 對側欄、視窗工具列、分頁列和底列起同樣的作用。
+
+請用這些變數,而不是把 `--app-shell` 設成透明或給 `body` 設定 `background`:這樣切換背景時不會讓整個視窗閃爍。[`examples/themes/night-sky`](https://github.com/multica-ai/multica/tree/main/examples/themes/night-sky) 是一個完整範例。
+
## 選擇器
選擇錨點、slot 和狀態鉤子,不要選類名或 DOM 結構,後者隨時會變。錨點、slot 和鉤子會保持到下一個 `apiVersion`。
@@ -178,7 +199,7 @@ paper/
- 使用了非公開變數,除非它是選項 id,或者主題自己用 `var()` 讀取它;
- 在 `.theme-light` 和 `.theme-dark` 以外的地方設定變數而沒有後代選擇器,主題選擇器就讀不出主題的顏色;
- 在字型棧裡寫了通用字型族(`sans-serif`、`serif` …)或 `ui-*` 關鍵字,這會蓋掉使用者選的中文字型;
-- 任一模式下沒達到 WCAG AA 對比度:`--foreground` 和 `--muted-foreground` 在每個表面上需要 4.5:1,`--brand` 在閱讀表面上需要 4.5:1,主按鈕文字在按鈕上需要 4.5:1,`--faint-foreground` 需要 3:1。提示框文字在 `--tooltip` 上需要 4.5:1,按下狀態的顯示設定標籤,文字在其底色上需要 4.5:1。提示框始終使用深色模式的文字顏色,要修改請設定 `--tooltip-foreground`;按下的標籤預設用 `--input` 作底色,可以用 `--display-chip-pressed-background` 單獨設定。
+- 任一模式下沒達到 WCAG AA 對比度:`--foreground` 和 `--muted-foreground` 在每個表面上需要 4.5:1,`--brand` 在閱讀表面上需要 4.5:1,主按鈕文字在按鈕上需要 4.5:1,`--faint-foreground` 需要 3:1。提示框文字在 `--tooltip` 上需要 4.5:1,按下狀態的顯示設定標籤,文字在其底色上需要 4.5:1。提示框始終使用深色模式的文字顏色,要修改請設定 `--tooltip-foreground`;按下的標籤預設用 `--input` 作底色,可以用 `--display-chip-pressed-background` 單獨設定。 使用背景時,框架和頁面依覆蓋在 `--backdrop-color` 上的玻璃來計算。
## 檢查與預覽
@@ -196,6 +217,14 @@ pnpm theme:preview path/to/paper --out preview # preview/light.png 和 preview
開發過程中如果主題隱藏或弄亂了介面,在地址後加 `?theme=default` 開啟應用,或者載入後立刻按住 **Shift**;見[主題出問題時](/themes#主題出問題時)。
+檢查器也可以不安裝儲存庫,用稀疏複製和 Node 22.18 或更新版本直接執行。AI 代理內建的 Multica skill 裡也是這些指令:
+
+```bash
+git clone --depth 1 --filter=blob:none --sparse https://github.com/multica-ai/multica.git multica-themes
+git -C multica-themes sparse-checkout set docs scripts packages/core packages/ui
+node multica-themes/scripts/theme-check.mjs path/to/paper
+```
+
## 釋出到主題商店
主題商店列出 [multica-ai/multica-themes](https://github.com/multica-ai/multica-themes) 倉庫裡的主題。詳細說明見它的[貢獻指南](https://github.com/multica-ai/multica-themes/blob/main/CONTRIBUTING.md),簡單來說:
diff --git a/apps/docs/content/docs/developers/themes.zh.mdx b/apps/docs/content/docs/developers/themes.zh.mdx
index d2bec9be00..d8f1ab172b 100644
--- a/apps/docs/content/docs/developers/themes.zh.mdx
+++ b/apps/docs/content/docs/developers/themes.zh.mdx
@@ -149,6 +149,27 @@ paper/
[data-mc="content"] { max-width: var(--page-width); }
```
+## 背景与玻璃
+
+主题可以在应用后面放一张画面——渐变、图片或动画 SVG——并让框架和页面变成覆盖在它上面的玻璃。按模式设置:
+
+```css
+.theme-dark {
+ --backdrop: url(night.svg) center / cover no-repeat;
+ --backdrop-color: #1e1e4a;
+ --glass-opacity: 72%;
+ --glass-blur: 18px;
+ --frame-glass-opacity: 0%;
+ --frame-glass-blur: 0px;
+}
+```
+
+- `--backdrop` 是一个 CSS `background` 值,铺在整个窗口下面,桌面应用和网页版都会显示。图片必须放在主题文件夹里;SVG 自带的动画会播放。
+- 设置背景时必须同时设置 `--backdrop-color`:加载期间显示的纯色,也是 `theme:check` 计算玻璃对比度时用的底色。
+- `--glass-opacity` 和 `--glass-blur` 决定页面自身颜色盖住背景的程度,以及背景在页面后面的模糊程度。`--frame-glass-opacity` 和 `--frame-glass-blur` 对侧栏、窗口工具栏、标签栏和底栏起同样的作用。
+
+请用这些变量,而不是把 `--app-shell` 设成透明或给 `body` 设置 `background`:这样切换背景时不会让整个窗口闪烁。[`examples/themes/night-sky`](https://github.com/multica-ai/multica/tree/main/examples/themes/night-sky) 是一个完整示例。
+
## 选择器
选择锚点、slot 和状态钩子,不要选类名或 DOM 结构,后者随时会变。锚点、slot 和钩子会保持到下一个 `apiVersion`。
@@ -178,7 +199,7 @@ paper/
- 使用了非公开变量,除非它是选项 id,或者主题自己用 `var()` 读取它;
- 在 `.theme-light` 和 `.theme-dark` 以外的地方设置变量而没有后代选择器,主题选择器就读不出主题的颜色;
- 在字体栈里写了通用字体族(`sans-serif`、`serif` …)或 `ui-*` 关键字,这会盖掉用户选的中文字体;
-- 任一模式下没达到 WCAG AA 对比度:`--foreground` 和 `--muted-foreground` 在每个表面上需要 4.5:1,`--brand` 在阅读表面上需要 4.5:1,主按钮文字在按钮上需要 4.5:1,`--faint-foreground` 需要 3:1。提示框文字在 `--tooltip` 上需要 4.5:1,按下状态的显示设置标签,文字在其底色上需要 4.5:1。提示框始终使用深色模式的文字颜色,要修改请设置 `--tooltip-foreground`;按下的标签默认用 `--input` 作底色,可以用 `--display-chip-pressed-background` 单独设置。
+- 任一模式下没达到 WCAG AA 对比度:`--foreground` 和 `--muted-foreground` 在每个表面上需要 4.5:1,`--brand` 在阅读表面上需要 4.5:1,主按钮文字在按钮上需要 4.5:1,`--faint-foreground` 需要 3:1。提示框文字在 `--tooltip` 上需要 4.5:1,按下状态的显示设置标签,文字在其底色上需要 4.5:1。提示框始终使用深色模式的文字颜色,要修改请设置 `--tooltip-foreground`;按下的标签默认用 `--input` 作底色,可以用 `--display-chip-pressed-background` 单独设置。 使用背景时,框架和页面按覆盖在 `--backdrop-color` 上的玻璃来计算。
## 检查与预览
@@ -196,6 +217,14 @@ pnpm theme:preview path/to/paper --out preview # preview/light.png 和 preview
开发过程中如果主题隐藏或弄乱了界面,在地址后加 `?theme=default` 打开应用,或者加载后立刻按住 **Shift**;见[主题出问题时](/themes#主题出问题时)。
+检查器也可以不安装仓库,用稀疏克隆和 Node 22.18 或更高版本直接运行。智能体内置的 Multica skill 里也是这些命令:
+
+```bash
+git clone --depth 1 --filter=blob:none --sparse https://github.com/multica-ai/multica.git multica-themes
+git -C multica-themes sparse-checkout set docs scripts packages/core packages/ui
+node multica-themes/scripts/theme-check.mjs path/to/paper
+```
+
## 发布到主题商店
主题商店列出 [multica-ai/multica-themes](https://github.com/multica-ai/multica-themes) 仓库里的主题。详细说明见它的[贡献指南](https://github.com/multica-ai/multica-themes/blob/main/CONTRIBUTING.md),简单来说:
diff --git a/apps/docs/content/docs/themes.fr.mdx b/apps/docs/content/docs/themes.fr.mdx
index b0d0b4df65..28b278b467 100644
--- a/apps/docs/content/docs/themes.fr.mdx
+++ b/apps/docs/content/docs/themes.fr.mdx
@@ -83,6 +83,13 @@ Multica affiche le nom, l'auteur et la version du thème avant de l'installer. N
Pour créer votre propre thème, voir [Créer un thème](/developers/themes).
+## Demander à un agent d’en créer un
+
+N’importe quel agent peut créer un thème à partir d’une description. Demandez-le dans un chat, une tâche ou un commentaire, par exemple « fais-moi un thème sombre et calme avec un ciel nocturne qui défile lentement ». Les agents connaissent le format des thèmes et doivent passer les vérifications avant de livrer.
+
+- **Dans l’application de bureau**, un agent qui tourne sur le même ordinateur écrit le thème dans le dossier des thèmes. Dès qu’il passe les vérifications, il apparaît sous **Thème** : choisissez-le une fois, et chaque modification demandée ensuite s’affiche en une seconde environ.
+- **Sur le web, ou avec un agent sur une autre machine**, l’agent joint le thème sous forme de `.zip`. Cliquez sur **Installer le thème** sur la pièce jointe : Multica applique les mêmes vérifications et la même confirmation qu’avec **Importer un thème**.
+
## Quand un thème casse quelque chose
Un thème peut masquer ou casser une partie de l'interface. Pour revenir à Default :
diff --git a/apps/docs/content/docs/themes.ja.mdx b/apps/docs/content/docs/themes.ja.mdx
index d2969e04f1..d7740d5117 100644
--- a/apps/docs/content/docs/themes.ja.mdx
+++ b/apps/docs/content/docs/themes.ja.mdx
@@ -83,6 +83,13 @@ import { Step, Steps } from "fumadocs-ui/components/steps";
テーマを自作するには[テーマを作る](/developers/themes)を参照してください。
+## エージェントに作ってもらう
+
+どのエージェントでも、説明文からテーマを作れます。チャットやタスク、コメントで「ゆっくり流れる夜空の、落ち着いたダークテーマを作って」のように頼んでください。エージェントはテーマの形式を知っていて、納品前にテーマのチェックに合格する必要があります。
+
+- **デスクトップアプリでは**、同じコンピューターで動くエージェントがテーマをテーマフォルダに書き込みます。チェックに合格すると **テーマ** に表示されます。一度選べば、その後に頼んだ変更は 1 秒ほどで反映されます。
+- **Web 版、または別のマシンで動くエージェントの場合**、エージェントはテーマを `.zip` として添付します。添付ファイルの **テーマをインストール** をクリックすると、**テーマを読み込む** と同じチェックと確認画面が表示されます。
+
## テーマで表示が崩れたとき
テーマによってインターフェースの一部が隠れたり崩れたりすることがあります。Default に戻すには、次のどちらかを行います。
diff --git a/apps/docs/content/docs/themes.ko.mdx b/apps/docs/content/docs/themes.ko.mdx
index b61b02900d..c8c28adb1d 100644
--- a/apps/docs/content/docs/themes.ko.mdx
+++ b/apps/docs/content/docs/themes.ko.mdx
@@ -83,6 +83,13 @@ import { Step, Steps } from "fumadocs-ui/components/steps";
테마를 직접 만들려면 [테마 만들기](/developers/themes)를 참고하세요.
+## 에이전트에게 만들어 달라고 하기
+
+어떤 에이전트든 설명만으로 테마를 만들 수 있습니다. 채팅, 태스크, 댓글에서 "밤하늘이 천천히 흐르는 차분한 다크 테마를 만들어 줘"처럼 요청하세요. 에이전트는 테마 형식을 알고 있으며, 전달하기 전에 테마 검사를 통과해야 합니다.
+
+- **데스크톱 앱에서는** 같은 컴퓨터에서 실행되는 에이전트가 테마를 테마 폴더에 씁니다. 검사를 통과하면 **테마**에 나타납니다. 한 번 선택해 두면 이후에 요청하는 변경은 1초 안팎으로 반영됩니다.
+- **웹에서, 또는 다른 컴퓨터에서 실행되는 에이전트라면** 에이전트가 테마를 `.zip`으로 첨부합니다. 첨부 파일의 **테마 설치**를 클릭하면 **테마 가져오기**와 같은 검사와 확인 창이 표시됩니다.
+
## 테마 때문에 화면이 깨졌을 때
테마 때문에 인터페이스 일부가 가려지거나 깨질 수 있습니다. Default로 돌아가려면 다음 중 하나를 하세요.
diff --git a/apps/docs/content/docs/themes.mdx b/apps/docs/content/docs/themes.mdx
index ebd5c385c8..8d7121298a 100644
--- a/apps/docs/content/docs/themes.mdx
+++ b/apps/docs/content/docs/themes.mdx
@@ -83,6 +83,13 @@ Multica shows the theme's name, author, and version before installing it. Only i
To start a theme of your own, see [Make a theme](/developers/themes).
+## Ask an agent to make one
+
+Any agent can build a theme from a description. Ask it in a chat, an issue, or a comment, for example "make me a calm dark theme with a slowly drifting night sky". Agents know the theme format and must pass the theme checks before they deliver.
+
+- **In the desktop app**, an agent running on the same computer writes the theme into the themes folder. Once it passes the checks it appears under **Theme**: pick it there once, and each change you ask for after that shows up within a second.
+- **On the web, or with an agent on another machine**, the agent attaches the theme as a `.zip`. Click **Install theme** on the attachment: Multica runs the same checks and shows the same confirmation as **Import theme**.
+
## When a theme breaks something
A theme can hide or break part of the interface. To get back to Default, either:
diff --git a/apps/docs/content/docs/themes.zh-Hant.mdx b/apps/docs/content/docs/themes.zh-Hant.mdx
index ab1fa12f36..71fef30b0a 100644
--- a/apps/docs/content/docs/themes.zh-Hant.mdx
+++ b/apps/docs/content/docs/themes.zh-Hant.mdx
@@ -83,6 +83,13 @@ import { Step, Steps } from "fumadocs-ui/components/steps";
想從頭做一個主題,見[製作主題](/developers/themes)。
+## 讓 AI 代理幫你做一個
+
+任何 AI 代理都能根據一段描述製作主題。在對話、任務或留言裡告訴它,例如「幫我做一個夜空緩緩流動的沉靜深色主題」。AI 代理了解主題格式,交付前必須通過主題檢查。
+
+- **在桌面應用程式中**,執行在同一台電腦上的 AI 代理會把主題寫進主題資料夾。主題通過檢查後會出現在 **主題** 清單裡,選用一次即可;之後你提出的每次修改,一秒左右就會生效。
+- **在網頁版中,或 AI 代理執行在另一台機器上時**,AI 代理會把主題作為 `.zip` 附在回覆裡。點擊附件上的 **安裝主題**,Multica 會做與 **匯入主題** 相同的檢查並顯示相同的確認視窗。
+
## 主題出問題時
主題可能隱藏或弄亂介面的一部分。回到 Default 有兩種方法:
diff --git a/apps/docs/content/docs/themes.zh.mdx b/apps/docs/content/docs/themes.zh.mdx
index a7c0c732e7..8dedd86e2c 100644
--- a/apps/docs/content/docs/themes.zh.mdx
+++ b/apps/docs/content/docs/themes.zh.mdx
@@ -83,6 +83,13 @@ import { Step, Steps } from "fumadocs-ui/components/steps";
想从头做一个主题,见[制作主题](/developers/themes)。
+## 让智能体帮你做一个
+
+任何智能体都能根据一段描述制作主题。在对话、任务或评论里告诉它,比如“帮我做一个夜空缓缓流动的沉静深色主题”。智能体了解主题格式,交付前必须通过主题检查。
+
+- **在桌面应用中**,运行在同一台电脑上的智能体会把主题写进主题文件夹。主题通过检查后会出现在 **主题** 列表里,选用一次即可;之后你提出的每次修改,一秒左右就会生效。
+- **在网页版中,或智能体运行在另一台机器上时**,智能体会把主题作为 `.zip` 附在回复里。点击附件上的 **安装主题**,Multica 会做与 **导入主题** 相同的检查并显示相同的确认窗口。
+
## 主题出问题时
主题可能隐藏或弄乱界面的一部分。回到 Default 有两种方法:
diff --git a/docs/theming.md b/docs/theming.md
index 611ceb3d41..35162e9e88 100644
--- a/docs/theming.md
+++ b/docs/theming.md
@@ -13,7 +13,8 @@ Appearance → Theme options**. Themes never run JavaScript.
**Settings → Appearance → Manage** lists the themes installed on the device
and the community theme store; the built-in themes are in the theme picker. Install a theme from the
store there, or with **Import theme**, from a `.zip` of the folder or from the
-folder itself. Themes are saved on the device, like every other Appearance
+folder itself; a theme `.zip` attached to a chat or comment installs with
+**Install theme** on the attachment. Themes are saved on the device, like every other Appearance
setting; **Remove** on a theme's card deletes it, and goes back to Default
when it was in use. **Check for updates** looks for new releases of the
themes installed from the store.
@@ -192,6 +193,54 @@ and choice labels are a string or an object keyed by locale (`en`,
[data-mc="content"] { max-width: var(--page-width); }
```
+## Backdrop and glass
+
+A theme can put a picture behind the app: a gradient, an image, or an
+animated SVG. Set `--backdrop` per mode to a CSS `background` value, and
+the app paints it on a layer under the whole window, on Desktop and on the
+web. While a mode has a backdrop, the frame (rail, window toolbar, tab bar
+and bottom bar) and the page turn to glass: each keeps its own colour,
+`--app-shell` for the frame and `--page-canvas` for the page, at the
+opacity the theme sets, over the backdrop.
+
+```css
+.theme-dark {
+ --backdrop: url(night.svg) center / cover no-repeat;
+ --backdrop-color: #1e1e4a;
+ --glass-opacity: 72%;
+ --glass-blur: 18px;
+ --frame-glass-opacity: 0%;
+ --frame-glass-blur: 0px;
+}
+```
+
+| Variable | What it does |
+| --- | --- |
+| `--backdrop` | The layers behind the window, as `background` takes them. Images must be in the theme folder. An SVG's own CSS animation plays. |
+| `--backdrop-color` | Required with a backdrop. The solid colour under it: shown while the images load, and what `theme:check` measures the glass on. Use the colour the backdrop averages to. |
+| `--glass-opacity` | How much of `--page-canvas` (and `--background`) covers the backdrop in the page: `100%` is solid. |
+| `--glass-blur` | How much the backdrop is blurred behind the page. |
+| `--frame-glass-opacity`, `--frame-glass-blur` | The same for the frame. They default to the page's values; `0%` and `0px` leave the backdrop clear around the page. |
+
+Use these variables instead of making `--app-shell` transparent or setting a
+`background` on `body`: the app then knows there is a backdrop, keeps the
+frame and the page distinct, and decodes a new backdrop before it replaces the old one, so switching
+themes or saving `theme.css` never flashes the window. Option sliders can
+set the glass directly: an option with the id `glass-opacity` sets
+`--glass-opacity`.
+
+`theme:check` measures text over glass: the frame's text on `--app-shell` at
+`--frame-glass-opacity` over `--backdrop-color`, and the page's on
+`--page-canvas` at `--glass-opacity` over it. A variable that reads one of
+these colours, such as `--surface: var(--page-canvas)`, keeps the opaque
+colour, as it does in the app, and so does everything in dialogs, menus and
+tooltips, which sit outside the frame. A backdrop without a solid
+`--backdrop-color` is an error. The colour is a stand-in for the picture,
+so look at the brightest and darkest parts of the backdrop too, and raise
+the glass opacity or blur where the text gets hard to read.
+`examples/themes/night-sky` in the repository is a complete example: an
+animated sky in each mode and the glass on two sliders.
+
## Selectors
Target anchors, slots and state hooks, not class names or DOM structure:
@@ -318,7 +367,9 @@ that breaks them:
`--muted-foreground` need 4.5:1 on every surface, `--brand` 4.5:1 on the
reading surfaces, the primary button label 4.5:1 on the button, and
`--faint-foreground` 3:1. A frame (rules on the rail, window toolbar,
- tab bar or bottom bar) is checked against its own colours. The check follows `:root`,
+ tab bar or bottom bar) is checked against its own colours. With a
+ backdrop, the frame and the page are checked as glass over
+ `--backdrop-color`; see [Backdrop and glass](#backdrop-and-glass). The check follows `:root`,
`html`, the mode classes and option attributes the way the browser does,
with every option at its default; when a colour it measures is also set
somewhere else, such as inside `@media` or on `body`, it says so instead
@@ -391,6 +442,34 @@ Duplicating downloads a `.zip`. Unzip it, edit, and import the folder
again: the same `id` replaces the installed copy, and option values are
kept. If a check fails, the import dialog lists every problem.
+### Ask an agent
+
+Any agent can build a theme: ask for one in a chat, an issue or a comment.
+The theme reference in Multica's built-in platform skill tells the agent to
+read this guide, to pass `theme:check` with 0 errors before it delivers, and
+to attach `theme:preview` screenshots when it can run them. It is a reference
+inside the existing skill rather than a skill of its own, so it adds a line
+to the skill's routing table instead of an entry to every agent's skill list.
+
+- **Desktop on the agent's computer.** The agent writes the theme into the
+ themes folder. Once it passes the checks it is listed under **Theme**,
+ where you pick it once: a new theme never replaces the one in use by
+ itself. Every later save to the theme in use applies within a second, so
+ ask for changes and watch them land.
+- **On the web, or with an agent on another machine.** The agent attaches
+ the theme as a `.zip`. **Install theme** on the attachment reads it with
+ the same checks and confirmation as **Import theme**; a newer version of
+ the same id replaces the old one.
+
+The checker runs without installing the repository, from a sparse clone
+and Node 22.18 or newer:
+
+```sh
+git clone --depth 1 --filter=blob:none --sparse https://github.com/multica-ai/multica.git multica-themes
+git -C multica-themes sparse-checkout set docs scripts packages/core packages/ui
+node multica-themes/scripts/theme-check.mjs path/to/paper
+```
+
### Checking a theme
Before importing or sharing a theme, run the same checks from the repository:
@@ -695,6 +774,17 @@ and dark differ, both defaults are given.
| `--nav-item-active-background` | `var(--surface-selected)` | The current row. |
| `--nav-item-active-color` | `var(--surface-selected-foreground)` | Text of the current row. |
+### Backdrop and glass
+
+| Variable | Default (light / dark) | Use |
+| --- | --- | --- |
+| `--backdrop` | `none` | What the window shows behind the frame and the page, as `background` layers: colours, gradients and images in the theme folder, such as `url(sky.svg) center / cover no-repeat`. An SVG's own CSS animation plays. It shows through the glass below. |
+| `--backdrop-color` | `var(--app-shell)` | Solid colour under the backdrop: shown while it loads, and the colour `theme:check` measures the glass on. Required with a backdrop; use the colour the backdrop averages to. |
+| `--glass-opacity` | `100%` | How much of the page's own colour covers the backdrop: `100%` is solid, lower lets the backdrop through. Only applies with a backdrop. |
+| `--glass-blur` | `0px` | Blur of the backdrop seen through the page. |
+| `--frame-glass-opacity` | `var(--glass-opacity, 100%)` | How much of `app-shell` covers the backdrop in the frame: rail, toolbar, tab bar and bottom bar. |
+| `--frame-glass-blur` | `var(--glass-blur, 0px)` | Blur of the backdrop seen through the frame. |
+
### Layout and spacing
| Variable | Default (light / dark) | Use |
diff --git a/examples/themes/night-sky/dawn.svg b/examples/themes/night-sky/dawn.svg
new file mode 100644
index 0000000000..cace373b29
--- /dev/null
+++ b/examples/themes/night-sky/dawn.svg
@@ -0,0 +1,22 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 1000" preserveAspectRatio="xMidYMid slice">
+<style>
+.t0{animation:tw 4s ease-in-out infinite}
+.t1{animation:tw 6s ease-in-out -2s infinite}
+.t2{animation:tw 9s ease-in-out -5s infinite}
+.ga{animation:drift 90s ease-in-out infinite alternate}
+.gb{animation:drift 120s ease-in-out -40s infinite alternate-reverse}
+@keyframes tw{0%,100%{opacity:1}50%{opacity:.25}}
+@keyframes drift{from{transform:translate(-120px,-40px)}to{transform:translate(140px,60px)}}
+@media (prefers-reduced-motion: reduce){*{animation:none!important}}
+</style>
+<defs>
+<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#cfe0ff"/><stop offset="1" stop-color="#fde6d8"/></linearGradient>
+<radialGradient id="ga"><stop offset="0" stop-color="#ffb38a" stop-opacity=".55"/><stop offset="1" stop-color="#ffb38a" stop-opacity="0"/></radialGradient>
+<radialGradient id="gb"><stop offset="0" stop-color="#8fb6ff" stop-opacity=".45"/><stop offset="1" stop-color="#8fb6ff" stop-opacity="0"/></radialGradient>
+</defs>
+<rect width="1600" height="1000" fill="url(#sky)"/>
+<circle class="ga" cx="320" cy="260" r="520" fill="url(#ga)"/>
+<circle class="gb" cx="1280" cy="380" r="560" fill="url(#gb)"/>
+<circle class="t0" cx="1064" cy="481" r="1.62" fill="#ffffff"/><circle class="t1" cx="1415" cy="642" r="1.98" fill="#ffffff"/><circle class="t2" cx="701" cy="370" r="1.94" fill="#ffffff"/><circle class="t0" cx="1560" cy="272" r="0.71" fill="#ffffff"/><circle class="t1" cx="548" cy="671" r="1.59" fill="#ffffff"/><circle class="t2" cx="1181" cy="726" r="1.70" fill="#ffffff"/><circle class="t0" cx="331" cy="181" r="1.72" fill="#ffffff"/><circle class="t1" cx="167" cy="696" r="1.72" fill="#ffffff"/><circle class="t2" cx="1016" cy="541" r="1.35" fill="#ffffff"/><circle class="t0" cx="709" cy="663" r="1.39" fill="#ffffff"/><circle class="t1" cx="1398" cy="206" r="1.56" fill="#ffffff"/><circle class="t2" cx="694" cy="300" r="0.86" fill="#ffffff"/><circle class="t0" cx="942" cy="176" r="1.86" fill="#ffffff"/><circle class="t1" cx="1315" cy="257" r="1.56" fill="#ffffff"/><circle class="t2" cx="1404" cy="88" r="1.03" fill="#ffffff"/><circle class="t0" cx="1473" cy="1" r="0.78" fill="#ffffff"/><circle class="t1" cx="636" cy="16" r="1.57" fill="#ffffff"/><circle class="t2" cx="1437" cy="131" r="0.90" fill="#ffffff"/><circle class="t0" cx="1516" cy="532" r="0.85" fill="#ffffff"/><circle class="t1" cx="187" cy="476" r="0.62" fill="#ffffff"/><circle class="t2" cx="1299" cy="450" r="1.65" fill="#ffffff"/><circle class="t0" cx="205" cy="252" r="1.60" fill="#ffffff"/><circle class="t1" cx="1528" cy="416" r="1.42" fill="#ffffff"/><circle class="t2" cx="1244" cy="534" r="1.63" fill="#ffffff"/><circle class="t0" cx="956" cy="76" r="0.66" fill="#ffffff"/><circle class="t1" cx="981" cy="171" r="1.41" fill="#ffffff"/><circle class="t2" cx="401" cy="170" r="1.47" fill="#ffffff"/><circle class="t0" cx="1007" cy="618" r="0.94" fill="#ffffff"/><circle class="t1" cx="1449" cy="40" r="1.57" fill="#ffffff"/><circle class="t2" cx="651" cy="602" r="1.52" fill="#ffffff"/>
+<path d="M0 860 L180 800 L360 840 L560 760 L760 830 L980 770 L1180 840 L1400 790 L1600 830 L1600 1000 L0 1000 Z" fill="#b9c4dc"/>
+</svg>
diff --git a/examples/themes/night-sky/manifest.json b/examples/themes/night-sky/manifest.json
new file mode 100644
index 0000000000..f864ecd78e
--- /dev/null
+++ b/examples/themes/night-sky/manifest.json
@@ -0,0 +1,13 @@
+{
+ "apiVersion": 1,
+ "id": "night-sky",
+ "name": "Night Sky",
+ "version": "1.0.0",
+ "author": "Multica",
+ "description": "A slowly drifting sky behind a frosted page: night in dark mode, dawn in light mode.",
+ "options": [
+ { "id": "glass", "type": "heading", "label": "Glass" },
+ { "id": "glass-blur", "type": "slider", "label": "Blur", "default": 18, "min": 0, "max": 40, "step": 2, "unit": "px" },
+ { "id": "glass-opacity", "type": "slider", "label": "Page opacity", "default": 72, "min": 40, "max": 100, "step": 4, "unit": "%" }
+ ]
+}
diff --git a/examples/themes/night-sky/night.svg b/examples/themes/night-sky/night.svg
new file mode 100644
index 0000000000..bce7d68545
--- /dev/null
+++ b/examples/themes/night-sky/night.svg
@@ -0,0 +1,22 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 1000" preserveAspectRatio="xMidYMid slice">
+<style>
+.t0{animation:tw 4s ease-in-out infinite}
+.t1{animation:tw 6s ease-in-out -2s infinite}
+.t2{animation:tw 9s ease-in-out -5s infinite}
+.ga{animation:drift 90s ease-in-out infinite alternate}
+.gb{animation:drift 120s ease-in-out -40s infinite alternate-reverse}
+@keyframes tw{0%,100%{opacity:1}50%{opacity:.25}}
+@keyframes drift{from{transform:translate(-120px,-40px)}to{transform:translate(140px,60px)}}
+@media (prefers-reduced-motion: reduce){*{animation:none!important}}
+</style>
+<defs>
+<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#070b1d"/><stop offset="1" stop-color="#1b1f45"/></linearGradient>
+<radialGradient id="ga"><stop offset="0" stop-color="#4f6bff" stop-opacity=".55"/><stop offset="1" stop-color="#4f6bff" stop-opacity="0"/></radialGradient>
+<radialGradient id="gb"><stop offset="0" stop-color="#9b5cff" stop-opacity=".45"/><stop offset="1" stop-color="#9b5cff" stop-opacity="0"/></radialGradient>
+</defs>
+<rect width="1600" height="1000" fill="url(#sky)"/>
+<circle class="ga" cx="320" cy="260" r="520" fill="url(#ga)"/>
+<circle class="gb" cx="1280" cy="380" r="560" fill="url(#gb)"/>
+<circle class="t0" cx="0" cy="700" r="1.00" fill="#e8ecff"/><circle class="t1" cx="337" cy="554" r="1.35" fill="#e8ecff"/><circle class="t2" cx="527" cy="572" r="1.66" fill="#e8ecff"/><circle class="t0" cx="869" cy="520" r="1.49" fill="#e8ecff"/><circle class="t1" cx="1307" cy="184" r="1.12" fill="#e8ecff"/><circle class="t2" cx="1133" cy="531" r="0.68" fill="#e8ecff"/><circle class="t0" cx="1094" cy="356" r="1.89" fill="#e8ecff"/><circle class="t1" cx="1292" cy="93" r="1.32" fill="#e8ecff"/><circle class="t2" cx="1477" cy="523" r="1.50" fill="#e8ecff"/><circle class="t0" cx="924" cy="693" r="1.87" fill="#e8ecff"/><circle class="t1" cx="596" cy="255" r="1.77" fill="#e8ecff"/><circle class="t2" cx="532" cy="116" r="1.02" fill="#e8ecff"/><circle class="t0" cx="686" cy="224" r="1.91" fill="#e8ecff"/><circle class="t1" cx="892" cy="554" r="1.83" fill="#e8ecff"/><circle class="t2" cx="94" cy="208" r="1.38" fill="#e8ecff"/><circle class="t0" cx="814" cy="320" r="0.87" fill="#e8ecff"/><circle class="t1" cx="1454" cy="42" r="1.11" fill="#e8ecff"/><circle class="t2" cx="551" cy="505" r="1.89" fill="#e8ecff"/><circle class="t0" cx="824" cy="126" r="1.17" fill="#e8ecff"/><circle class="t1" cx="454" cy="277" r="1.19" fill="#e8ecff"/><circle class="t2" cx="532" cy="404" r="1.46" fill="#e8ecff"/><circle class="t0" cx="373" cy="689" r="1.24" fill="#e8ecff"/><circle class="t1" cx="1381" cy="483" r="1.49" fill="#e8ecff"/><circle class="t2" cx="826" cy="384" r="1.56" fill="#e8ecff"/><circle class="t0" cx="1503" cy="302" r="1.59" fill="#e8ecff"/><circle class="t1" cx="402" cy="446" r="1.09" fill="#e8ecff"/><circle class="t2" cx="529" cy="297" r="1.71" fill="#e8ecff"/><circle class="t0" cx="1404" cy="84" r="1.75" fill="#e8ecff"/><circle class="t1" cx="124" cy="309" r="0.82" fill="#e8ecff"/><circle class="t2" cx="125" cy="757" r="0.91" fill="#e8ecff"/><circle class="t0" cx="1012" cy="110" r="1.24" fill="#e8ecff"/><circle class="t1" cx="949" cy="105" r="1.89" fill="#e8ecff"/><circle class="t2" cx="1415" cy="677" r="1.84" fill="#e8ecff"/><circle class="t0" cx="1452" cy="578" r="0.99" fill="#e8ecff"/><circle class="t1" cx="17" cy="189" r="0.71" fill="#e8ecff"/><circle class="t2" cx="3" cy="469" r="0.92" fill="#e8ecff"/><circle class="t0" cx="1186" cy="372" r="1.56" fill="#e8ecff"/><circle class="t1" cx="381" cy="670" r="0.93" fill="#e8ecff"/><circle class="t2" cx="598" cy="680" r="0.77" fill="#e8ecff"/><circle class="t0" cx="783" cy="2" r="1.88" fill="#e8ecff"/><circle class="t1" cx="1019" cy="701" r="0.63" fill="#e8ecff"/><circle class="t2" cx="1440" cy="143" r="1.96" fill="#e8ecff"/><circle class="t0" cx="904" cy="516" r="0.97" fill="#e8ecff"/><circle class="t1" cx="356" cy="159" r="1.39" fill="#e8ecff"/><circle class="t2" cx="84" cy="585" r="1.58" fill="#e8ecff"/><circle class="t0" cx="1143" cy="379" r="0.65" fill="#e8ecff"/><circle class="t1" cx="176" cy="698" r="0.78" fill="#e8ecff"/><circle class="t2" cx="1101" cy="679" r="0.65" fill="#e8ecff"/><circle class="t0" cx="1413" cy="655" r="1.99" fill="#e8ecff"/><circle class="t1" cx="1527" cy="581" r="1.19" fill="#e8ecff"/><circle class="t2" cx="397" cy="553" r="1.84" fill="#e8ecff"/><circle class="t0" cx="637" cy="178" r="1.17" fill="#e8ecff"/><circle class="t1" cx="1419" cy="425" r="1.09" fill="#e8ecff"/><circle class="t2" cx="994" cy="559" r="1.07" fill="#e8ecff"/><circle class="t0" cx="1160" cy="321" r="0.88" fill="#e8ecff"/><circle class="t1" cx="499" cy="749" r="1.99" fill="#e8ecff"/><circle class="t2" cx="1012" cy="663" r="1.89" fill="#e8ecff"/><circle class="t0" cx="319" cy="490" r="0.79" fill="#e8ecff"/><circle class="t1" cx="796" cy="424" r="1.68" fill="#e8ecff"/><circle class="t2" cx="1513" cy="366" r="0.86" fill="#e8ecff"/><circle class="t0" cx="715" cy="126" r="1.53" fill="#e8ecff"/><circle class="t1" cx="835" cy="427" r="1.31" fill="#e8ecff"/><circle class="t2" cx="1211" cy="275" r="1.65" fill="#e8ecff"/><circle class="t0" cx="42" cy="227" r="1.36" fill="#e8ecff"/><circle class="t1" cx="324" cy="549" r="1.01" fill="#e8ecff"/><circle class="t2" cx="377" cy="501" r="1.20" fill="#e8ecff"/><circle class="t0" cx="120" cy="587" r="1.75" fill="#e8ecff"/><circle class="t1" cx="1465" cy="692" r="1.55" fill="#e8ecff"/><circle class="t2" cx="1534" cy="19" r="1.67" fill="#e8ecff"/><circle class="t0" cx="962" cy="550" r="1.86" fill="#e8ecff"/><circle class="t1" cx="59" cy="103" r="0.71" fill="#e8ecff"/><circle class="t2" cx="173" cy="64" r="0.61" fill="#e8ecff"/><circle class="t0" cx="968" cy="719" r="0.87" fill="#e8ecff"/><circle class="t1" cx="214" cy="154" r="1.54" fill="#e8ecff"/><circle class="t2" cx="389" cy="347" r="1.99" fill="#e8ecff"/><circle class="t0" cx="676" cy="512" r="1.68" fill="#e8ecff"/><circle class="t1" cx="635" cy="316" r="0.69" fill="#e8ecff"/><circle class="t2" cx="368" cy="614" r="1.96" fill="#e8ecff"/><circle class="t0" cx="244" cy="703" r="1.31" fill="#e8ecff"/><circle class="t1" cx="195" cy="160" r="1.44" fill="#e8ecff"/><circle class="t2" cx="273" cy="59" r="0.98" fill="#e8ecff"/><circle class="t0" cx="1034" cy="423" r="1.27" fill="#e8ecff"/><circle class="t1" cx="1590" cy="57" r="1.18" fill="#e8ecff"/><circle class="t2" cx="503" cy="3" r="0.61" fill="#e8ecff"/><circle class="t0" cx="662" cy="69" r="0.93" fill="#e8ecff"/><circle class="t1" cx="1479" cy="591" r="1.67" fill="#e8ecff"/><circle class="t2" cx="699" cy="650" r="1.95" fill="#e8ecff"/><circle class="t0" cx="1282" cy="503" r="1.40" fill="#e8ecff"/><circle class="t1" cx="557" cy="309" r="1.30" fill="#e8ecff"/><circle class="t2" cx="792" cy="431" r="1.61" fill="#e8ecff"/>
+<path d="M0 860 L180 800 L360 840 L560 760 L760 830 L980 770 L1180 840 L1400 790 L1600 830 L1600 1000 L0 1000 Z" fill="#05070f"/>
+</svg>
diff --git a/examples/themes/night-sky/theme.css b/examples/themes/night-sky/theme.css
new file mode 100644
index 0000000000..82cde65d69
--- /dev/null
+++ b/examples/themes/night-sky/theme.css
@@ -0,0 +1,23 @@
+/* The sliders in manifest.json set --glass-blur and --glass-opacity. The
+ frame stays clear (0%, no blur) so the sky reads sharply around the page. */
+
+.theme-light {
+ --backdrop: url(dawn.svg) center / cover no-repeat;
+ --backdrop-color: #d6d5e4;
+ --frame-glass-opacity: 0%;
+ --frame-glass-blur: 0px;
+ --page-canvas: oklch(0.99 0.006 250);
+ --rail-item-color: oklch(0.32 0.03 260);
+ --muted-foreground: oklch(0.45 0.03 270);
+ --faint-foreground: oklch(0.53 0.03 270);
+ --brand: oklch(0.52 0.19 262);
+}
+
+.theme-dark {
+ --backdrop: url(night.svg) center / cover no-repeat;
+ --backdrop-color: #1e1e4a;
+ --frame-glass-opacity: 0%;
+ --frame-glass-blur: 0px;
+ --page-canvas: oklch(0.17 0.02 275);
+ --rail-item-color: oklch(0.86 0.02 270);
+}
diff --git a/packages/core/appearance/theme-check.test.ts b/packages/core/appearance/theme-check.test.ts
index 43473e93c7..3a9a768ac9 100644
--- a/packages/core/appearance/theme-check.test.ts
+++ b/packages/core/appearance/theme-check.test.ts
@@ -447,6 +447,104 @@ describe("theme check", () => {
});
});
+describe("theme check with a backdrop", () => {
+ const assets = { "sky.svg": "data:image/svg+xml;base64,PHN2Zy8+" };
+ const checkBackdrop = (css: string, extra: Record<string, unknown> = {}) =>
+ checkThemePackage({ manifest: { ...manifest, ...extra }, css, assets }, base);
+ const pair = (report: ReturnType<typeof checkBackdrop>, mode: string, foreground: string, background: string) =>
+ report.contrast.find((c) => c.mode === mode && c.foreground === foreground && c.background === background && !c.variant);
+
+ it("requires --backdrop-color, so the glass is never left unmeasured", () => {
+ const report = checkBackdrop(".theme-dark { --backdrop: url(sky.svg) center / cover; --glass-opacity: 70%; }");
+ expect(report.ok).toBe(false);
+ expect(report.issues).toContainEqual({
+ level: "error",
+ message: expect.stringMatching(/^Backdrop, dark mode: --backdrop is set without --backdrop-color\./),
+ });
+ expect(
+ checkBackdrop(".theme-dark { --backdrop: url(sky.svg); --backdrop-color: color-mix(in oklab, red, blue); }").issues,
+ ).toContainEqual({ level: "error", message: expect.stringMatching(/--backdrop-color must be an opaque colour/) });
+ });
+
+ it("measures the frame and the page as glass over --backdrop-color", () => {
+ const report = checkBackdrop(
+ ".theme-light { --backdrop: url(sky.svg); --backdrop-color: #000000; --app-shell: #ffffff; --page-canvas: #ffffff; --glass-opacity: 50%; }",
+ );
+ const frame = { r: 128, g: 128, b: 128, a: 1 };
+ const page = { r: 192, g: 192, b: 192, a: 1 };
+ const foreground = resolveColor(base.light, "--foreground");
+ if (!("color" in foreground)) throw new Error("tokens.css has no light --foreground");
+ expect(pair(report, "light", "--foreground", "--app-shell")).toMatchObject({
+ glass: true,
+ ratio: Math.round(contrastRatio(foreground.color, frame) * 100) / 100,
+ });
+ expect(pair(report, "light", "--foreground", "--page-canvas")).toMatchObject({
+ glass: true,
+ ratio: Math.round(contrastRatio(foreground.color, page) * 100) / 100,
+ });
+ expect(pair(report, "light", "--foreground", "--surface")?.glass).toBeUndefined();
+ expect(report.issues.filter((i) => i.message.startsWith("Contrast not checked"))).toEqual([]);
+ });
+
+ it("keeps the opaque colour for variables on <html> that read a glass surface", () => {
+ const report = checkBackdrop(`.theme-light {
+ --backdrop: #ffffff;
+ --backdrop-color: #ffffff;
+ --app-shell: #000000;
+ --frame-glass-opacity: 0%;
+ --glass-opacity: 90%;
+ --button-primary: #000000;
+ --button-primary-foreground: var(--app-shell);
+}`);
+ expect(report.ok).toBe(false);
+ expect(pair(report, "light", "--button-primary-foreground", "--button-primary")).toMatchObject({ ratio: 1 });
+ expect(report.issues).toEqual([
+ { level: "error", message: "Contrast, light mode: --button-primary-foreground is below 4.5:1 on --button-primary (1.00:1)." },
+ ]);
+ });
+
+ it("measures an alias of a glass surface, and portals, on the opaque colour", () => {
+ const report = checkBackdrop(
+ ".theme-light { --backdrop: url(sky.svg); --backdrop-color: #000000; --page-canvas: #ffffff; --background: #ffffff; --surface: var(--page-canvas); --tooltip: var(--background); --tooltip-foreground: #000000; --glass-opacity: 50%; }",
+ );
+ const foreground = resolveColor(base.light, "--foreground");
+ if (!("color" in foreground)) throw new Error("tokens.css has no light --foreground");
+ const white = { r: 255, g: 255, b: 255, a: 1 };
+ const opaque = Math.round(contrastRatio(foreground.color, white) * 100) / 100;
+ expect(pair(report, "light", "--foreground", "--surface")).toMatchObject({ ratio: opaque });
+ expect(pair(report, "light", "--foreground", "--surface")?.glass).toBeUndefined();
+ expect(pair(report, "light", "--foreground", "--page-canvas")?.ratio).toBeLessThan(opaque);
+ const tooltip = report.contrast.find((c) => c.mode === "light" && c.area === "tooltip" && !c.variant);
+ expect(tooltip?.glass).toBeUndefined();
+ expect(tooltip).toMatchObject({ foreground: "--tooltip-foreground", ratio: 21 });
+ });
+
+ it("names the glass when text fails on it", () => {
+ const found = checkBackdrop(".theme-light { --backdrop: url(sky.svg); --backdrop-color: #101010; --frame-glass-opacity: 0%; }")
+ .issues.filter((i) => i.level === "error")
+ .map((i) => i.message);
+ expect(found).toContainEqual(
+ expect.stringMatching(/^Contrast, light mode: --foreground is below 4\.5:1 on --app-shell \(1\.\d\d:1\)\. With the backdrop, it is measured as glass/),
+ );
+ });
+
+ it("reads the glass opacity from an option", () => {
+ const report = checkBackdrop(
+ ".theme-dark { --backdrop: url(sky.svg) center / cover; --backdrop-color: #070b1d; --glass-opacity: var(--page-opacity); --frame-glass-opacity: 0%; }",
+ { options: [{ id: "page-opacity", type: "slider", label: "Page opacity", default: 80, min: 40, max: 100, unit: "%" }] },
+ );
+ expect(report.issues).toEqual([]);
+ expect(pair(report, "dark", "--foreground", "--page-canvas")?.glass).toBe(true);
+ });
+
+ it("warns when solid glass hides the backdrop", () => {
+ const report = checkBackdrop(".theme-dark { --backdrop: url(sky.svg); --backdrop-color: #070b1d; }");
+ expect(report.issues).toEqual([
+ { level: "warning", message: expect.stringMatching(/^Backdrop, dark mode: .* cover the backdrop completely\.$/) },
+ ]);
+ });
+});
+
describe("colour parsing", () => {
it("reads the colour syntaxes themes use", () => {
expect(parseColor("#fff")).toEqual({ r: 255, g: 255, b: 255, a: 1 });
diff --git a/packages/core/appearance/theme-check.ts b/packages/core/appearance/theme-check.ts
index e1dd69ec99..0ad6867846 100644
--- a/packages/core/appearance/theme-check.ts
+++ b/packages/core/appearance/theme-check.ts
@@ -20,7 +20,9 @@ import {
* do: set variables that are not public, name generic families in Latin
* font stacks, or paint text without enough contrast. Contrast is measured
* with the options at their defaults, then once per other value of each
- * `select` and `toggle` with the rest at their defaults.
+ * `select` and `toggle` with the rest at their defaults. With a backdrop,
+ * the frame and the page are measured as the glass the app paints over
+ * `--backdrop-color`.
*/
export interface ThemeCheckIssue {
@@ -53,6 +55,8 @@ export interface ContrastCheck {
variant?: ContrastVariant;
/** Set when the foreground is the app's default, not a variable the theme set. */
defaulted?: boolean;
+ /** Set when the background is glass: its colour at the glass opacity over the backdrop. */
+ glass?: boolean;
}
export interface ThemeCheckReport {
@@ -106,7 +110,10 @@ type Slot = "tooltip-content" | "popover-content";
const SLOTS: readonly Slot[] = ["tooltip-content", "popover-content"];
/** How to fix a pair the theme reaches only through a default. */
-function contrastHint({ area, foreground, background, defaulted }: ContrastCheck): string {
+function contrastHint({ area, foreground, background, defaulted, glass }: ContrastCheck): string {
+ if (glass) {
+ return " With the backdrop, it is measured as glass: the colour at --glass-opacity (--frame-glass-opacity for --app-shell) over --backdrop-color.";
+ }
if (area === "tooltip" && foreground === "--foreground") {
return " Tooltip text is the app's dark-mode --foreground in both modes; set --tooltip-foreground to choose it.";
}
@@ -282,6 +289,74 @@ class ScopePalette extends ReadTracker {
}
}
+/** A percentage, following var() chains, as 0–1; null when it is not one. */
+function resolveShare(palette: Map<string, string>, name: string, fallback: string): number | null {
+ let value = palette.get(name) ?? fallback;
+ for (let hops = 0; hops < 12; hops += 1) {
+ const reference = /^var\(\s*(--[\w-]+)\s*(?:,\s*(.+))?\)$/s.exec(value.trim());
+ if (!reference) {
+ const share = /^(\d+(?:\.\d+)?|\.\d+)%$/.exec(value.trim());
+ return share ? Math.min(1, Number(share[1]) / 100) : null;
+ }
+ const next = palette.get(reference[1]!) ?? reference[2];
+ if (next === undefined) return null;
+ value = next;
+ }
+ return null;
+}
+
+/** Surfaces the app paints as glass when a theme has a backdrop. */
+const GLASS_SURFACES = ["--app-shell", "--page-canvas", "--background"] as const;
+
+type GlassResult =
+ | { fills: Map<string, Rgba>; solid: boolean }
+ | { error: string }
+ | { unresolved: string }
+ | null;
+
+/**
+ * With a backdrop the frame and the page are glass, the way appearance.css
+ * paints them: the frame is --app-shell at --frame-glass-opacity over
+ * --backdrop-color, and the page's colours sit at --glass-opacity over the
+ * frame. Returns those mixes by surface. They replace the three variables
+ * only inside the frame: a variable on <html> that reads one of them, and
+ * everything in a portal, still sees the opaque value, so the palette keeps
+ * it. Null without a backdrop.
+ */
+function glassFills(palette: Map<string, string>): GlassResult {
+ const backdrop = palette.get("--backdrop")?.trim();
+ if (!backdrop || backdrop === "none") return null;
+ if (!palette.has("--backdrop-color")) {
+ return {
+ error:
+ "--backdrop is set without --backdrop-color. Set it to the colour the backdrop averages to: the glass is measured on it, and it shows while the backdrop loads.",
+ };
+ }
+ const under = resolveColor(palette, "--backdrop-color");
+ if (!("color" in under) || under.color.a < 1) {
+ return { error: "--backdrop-color must be an opaque colour this check can read: hex, rgb(), hsl(), oklab() or oklch()." };
+ }
+ const frameShare = resolveShare(palette, "--frame-glass-opacity", "var(--glass-opacity, 100%)");
+ const pageShare = resolveShare(palette, "--glass-opacity", "100%");
+ if (frameShare === null || pageShare === null) {
+ return { unresolved: `${frameShare === null ? "--frame-glass-opacity" : "--glass-opacity"} is not a percentage this check can read` };
+ }
+ const colors = new Map<string, Rgba>();
+ for (const name of GLASS_SURFACES) {
+ const color = resolveColor(palette, name);
+ if (!("color" in color)) return { unresolved: color.unresolved };
+ colors.set(name, color.color);
+ }
+ const glassOver = (color: Rgba, share: number, bottom: Rgba) => paintOver({ ...color, a: color.a * share }, bottom);
+ const frame = glassOver(colors.get("--app-shell")!, frameShare, under.color);
+ const fills = new Map<string, Rgba>([
+ ["--app-shell", frame],
+ ["--page-canvas", glassOver(colors.get("--page-canvas")!, pageShare, frame)],
+ ["--background", glassOver(colors.get("--background")!, pageShare, frame)],
+ ]);
+ return { fills, solid: frameShare === 1 && pageShare === 1 };
+}
+
/** Declarations by name, the most specific winning and, at equal specificity, the later one. */
type Cascade = Map<string, { value: string; specificity: number }>;
@@ -425,7 +500,7 @@ function measureContrast(
chosen: ThemeOptionValues | undefined,
base: BasePalette,
variant: ContrastVariant | undefined,
-): { results: ContrastCheck[]; unresolved: Set<string> } {
+): { results: ContrastCheck[]; unresolved: Set<string>; backdrop: Map<string, ThemeCheckIssue["level"]> } {
// The cascade on <html>, per mode: the base tokens (`:root` and `.dark`),
// then the theme's root and mode rules by specificity and order.
const cascade = {
@@ -478,19 +553,43 @@ function measureContrast(
const options = theme ? themeOptionVariables(theme, chosen) : { light: {}, dark: {} };
const results: ContrastCheck[] = [];
const unresolved = new Set<string>();
+ const backdrop = new Map<string, ThemeCheckIssue["level"]>();
const read = new Set<string>();
for (const m of ["light", "dark"] as const) {
// Option values are written after the theme as `:root.theme-<mode>`, so they win.
const palette = new ReadTracker(read, [...cascadeValues(cascade[m]), ...Object.entries(options[m])]);
+ const glassed = glassFills(palette);
+ const fills = glassed && "fills" in glassed ? glassed.fills : new Map<string, Rgba>();
+ /** A surface as painted: the glass mix when it is a glass surface in the frame, holding the theme's own colour. */
+ const paint = (surface: Map<string, string>, name: string, inFrame: boolean): ReturnType<typeof resolveColor> => {
+ const fill = inFrame ? fills.get(name) : undefined;
+ return fill && surface.get(name) === palette.get(name) ? { color: fill } : resolveColor(surface, name);
+ };
+ if (glassed && "error" in glassed) backdrop.set(`Backdrop, ${m} mode: ${glassed.error}`, "error");
+ if (glassed && "unresolved" in glassed) unresolved.add(`${m}: the backdrop's glass, because ${glassed.unresolved}`);
+ if (glassed && "solid" in glassed && glassed.solid) {
+ backdrop.set(
+ `Backdrop, ${m} mode: --glass-opacity and --frame-glass-opacity are 100%, so the frame and the page cover the backdrop completely.`,
+ "warning",
+ );
+ }
const measure = (
area: ContrastCheck["area"],
p: Map<string, string>,
foreground: string,
backgrounds: readonly string[],
required: number,
- /** Where the backgrounds are resolved, when not where the text is; and what a translucent one sits on. */
- { surface = p, under, defaulted }: { surface?: Map<string, string>; under?: string; defaulted?: boolean } = {},
+ /**
+ * Where the backgrounds are resolved, when not where the text is; what a
+ * translucent one sits on; and whether it is outside the frame, in a portal.
+ */
+ {
+ surface = p,
+ under,
+ defaulted,
+ portal = false,
+ }: { surface?: Map<string, string>; under?: string; defaulted?: boolean; portal?: boolean } = {},
) => {
const fg = resolveColor(p, foreground);
if ("unresolved" in fg) {
@@ -498,14 +597,14 @@ function measureContrast(
return;
}
for (const background of backgrounds) {
- const bg = resolveColor(surface, background);
+ const bg = paint(surface, background, !portal);
if ("unresolved" in bg) {
unresolved.add(`${m}: ${bg.unresolved}`);
continue;
}
let fill: Rgba = bg.color;
if (fill.a < 1 && under) {
- const floor = resolveColor(surface, under);
+ const floor = paint(surface, under, !portal);
if ("color" in floor && floor.color.a === 1) fill = paintOver(fill, floor.color);
}
if (fill.a < 1) {
@@ -522,6 +621,7 @@ function measureContrast(
required,
...(variant ? { variant } : {}),
...(defaulted ? { defaulted } : {}),
+ ...(!portal && fills.has(background) && surface.get(background) === palette.get(background) ? { glass: true } : {}),
});
}
};
@@ -535,7 +635,7 @@ function measureContrast(
else {
// The default hover is --sidebar-accent at 60% over the shell.
const accent = resolveColor(p, "--sidebar-accent");
- const shell = resolveColor(p, "--app-shell");
+ const shell = paint(p, "--app-shell", true);
if ("color" in accent && "color" in shell && shell.color.a === 1) {
const { r, g, b } = paintOver({ ...accent.color, a: accent.color.a * 0.6 }, shell.color);
p.set("--rail-item-hover-background", `rgb(${r} ${g} ${b})`);
@@ -582,7 +682,7 @@ function measureContrast(
// --tooltip-foreground. Its fill is resolved outside, in the page's mode.
const tooltip = new ScopePalette(read, palette, cascadeValues(slots["tooltip-content"][m]));
const tipText = tooltip.has("--tooltip-foreground") ? "--tooltip-foreground" : "--foreground";
- measure("tooltip", tooltip, tipText, ["--tooltip"], TEXT, { surface: palette });
+ measure("tooltip", tooltip, tipText, ["--tooltip"], TEXT, { surface: palette, portal: true });
// Display chips sit in popovers; pressed, they fill with
// --display-chip-pressed-background, which defaults to --input (translucent
@@ -590,7 +690,7 @@ function measureContrast(
const popover = new ScopePalette(read, palette, cascadeValues(slots["popover-content"][m]));
const chipText = popover.has("--display-chip-pressed-color") ? "--display-chip-pressed-color" : "--foreground";
const chipFill = popover.has("--display-chip-pressed-background") ? "--display-chip-pressed-background" : "--input";
- measure("display chip", popover, chipText, [chipFill], TEXT, { under: "--surface-raised" });
+ measure("display chip", popover, chipText, [chipFill], TEXT, { under: "--surface-raised", portal: true });
// A label paints its slot's colour behind --label-chip-color. When that is
// unset the app picks dark or light text by the colour as picked, and every
@@ -616,7 +716,7 @@ function measureContrast(
for (const [name, where] of unmodelled) {
if (read.has(name)) unresolved.add(`${where}, which the check does not follow`);
}
- return { results, unresolved };
+ return { results, unresolved, backdrop };
}
const pairKey = (c: ContrastCheck) => `${c.mode} ${c.area} ${c.foreground} ${c.background}`;
@@ -636,7 +736,7 @@ function reportFailing(checks: readonly ContrastCheck[], issues: ThemeCheckIssue
const where = [...(area === "page" ? [] : [area]), ...(variant ? [variant.label] : [])];
issues.push({
level: "error",
- message: `Contrast, ${m} mode${where.length > 0 ? ` (${where.join(", ")})` : ""}: ${foreground} is below ${required}:1 on ${list}.${contrastHint(group[0]!)}`,
+ message: `Contrast, ${m} mode${where.length > 0 ? ` (${where.join(", ")})` : ""}: ${foreground} is below ${required}:1 on ${list}.${contrastHint({ ...group[0]!, glass: group.some((c) => c.glass) })}`,
});
}
}
@@ -655,6 +755,7 @@ function checkContrast(
const parsed = rules(clean);
const defaults = measureContrast(clean, parsed, theme, undefined, base, undefined);
reportFailing(defaults.results, issues);
+ for (const [message, level] of defaults.backdrop) issues.push({ level, message });
const failingByDefault = new Set(defaults.results.filter((c) => c.ratio < c.required).map(pairKey));
const results = [...defaults.results];
const unresolvedWith = new Map<string, string[]>();
@@ -662,6 +763,9 @@ function checkContrast(
const run = measureContrast(clean, parsed, theme, chosen, base, variant);
results.push(...run.results);
reportFailing(run.results.filter((c) => !failingByDefault.has(pairKey(c))), issues);
+ for (const [message, level] of run.backdrop) {
+ if (!defaults.backdrop.has(message)) issues.push({ level, message: `${message} (${variant.label})` });
+ }
for (const reason of run.unresolved) {
if (!defaults.unresolved.has(reason)) unresolvedWith.set(reason, [...(unresolvedWith.get(reason) ?? []), variant.label]);
}
diff --git a/packages/core/appearance/theme-variables.ts b/packages/core/appearance/theme-variables.ts
index c2a4fe6517..efbb09a1e7 100644
--- a/packages/core/appearance/theme-variables.ts
+++ b/packages/core/appearance/theme-variables.ts
@@ -24,6 +24,7 @@ export type ThemeVariableSection =
| "typography"
| "controls"
| "navigation"
+ | "backdrop"
| "layout"
| "issues"
| "editor"
@@ -50,6 +51,7 @@ export const THEME_VARIABLE_SECTIONS: Record<ThemeVariableSection, string> = {
typography: "Typography",
controls: "Controls and overlays",
navigation: "Navigation and page",
+ backdrop: "Backdrop and glass",
layout: "Layout and spacing",
issues: "Issues",
editor: "Editor content",
@@ -69,6 +71,7 @@ const DEFAULT_TEXT: Record<string, string> = {
"button-primary-border": "`--button-primary`",
...Object.fromEntries(PALETTE_SLOTS.map((slot) => [`palette-${slot}`, "the colour as picked"])),
"label-chip-color": "dark or light, whichever reads on the picked colour",
+ backdrop: "`none`",
};
function section(name: ThemeVariableSection, entries: readonly Entry[]): ThemeVariable[] {
@@ -264,6 +267,15 @@ const NAVIGATION: Entry[] = [
["nav-item-active-color", "Text of the current row.", "var(--surface-selected-foreground)"],
];
+const BACKDROP: Entry[] = [
+ ["backdrop", "What the window shows behind the frame and the page, as `background` layers: colours, gradients and images in the theme folder, such as `url(sky.svg) center / cover no-repeat`. An SVG's own CSS animation plays. It shows through the glass below."],
+ ["backdrop-color", "Solid colour under the backdrop: shown while it loads, and the colour `theme:check` measures the glass on. Required with a backdrop; use the colour the backdrop averages to.", "var(--app-shell)"],
+ ["glass-opacity", "How much of the page's own colour covers the backdrop: `100%` is solid, lower lets the backdrop through. Only applies with a backdrop.", "100%"],
+ ["glass-blur", "Blur of the backdrop seen through the page.", "0px"],
+ ["frame-glass-opacity", "How much of `app-shell` covers the backdrop in the frame: rail, toolbar, tab bar and bottom bar.", "var(--glass-opacity, 100%)"],
+ ["frame-glass-blur", "Blur of the backdrop seen through the frame.", "var(--glass-blur, 0px)"],
+];
+
const LAYOUT: Entry[] = [
["space-xs", "Spacing step: the gap between board cards.", "0.5rem"],
["space-sm", "Spacing step: board card padding, the issue page's side padding on phones.", "0.75rem"],
@@ -399,6 +411,7 @@ export const THEME_VARIABLES: readonly ThemeVariable[] = [
...section("typography", TYPOGRAPHY),
...section("controls", CONTROLS),
...section("navigation", NAVIGATION),
+ ...section("backdrop", BACKDROP),
...section("layout", LAYOUT),
...section("issues", ISSUES),
...section("editor", EDITOR),
diff --git a/packages/ui/styles/appearance.css b/packages/ui/styles/appearance.css
index 14bd99bd7d..24267572e4 100644
--- a/packages/ui/styles/appearance.css
+++ b/packages/ui/styles/appearance.css
@@ -78,3 +78,54 @@ html[lang="zh-TW"] {
:root[data-theme] [data-slot="button"][data-variant="default"]:not(:disabled):hover {
background-color: color-mix(in oklab, var(--button-primary, var(--primary)) 90%, var(--foreground));
}
+
+/* ── Backdrop and glass ─────────────────────────────────────────────────────
+ * A theme that sets --backdrop gets a layer under the whole window,
+ * #multica-backdrop, which AppearanceSync paints and keeps; it also marks
+ * <html> with data-backdrop while the mode in use has one. The frame and the
+ * page then turn to glass: their own colours at the glass opacity, mixed here
+ * on <html> from the theme's opaque values, with the backdrop blurred behind
+ * them. theme-check.ts measures contrast on the same mixes. */
+
+#multica-backdrop {
+ position: fixed;
+ inset: 0;
+ z-index: -1;
+ overflow: hidden;
+ pointer-events: none;
+ background-color: var(--backdrop-color, var(--app-shell));
+}
+
+#multica-backdrop > div {
+ position: absolute;
+ inset: calc(-2 * var(--frame-glass-blur, var(--glass-blur, 0px)));
+ filter: blur(var(--frame-glass-blur, var(--glass-blur, 0px)));
+}
+
+:root[data-backdrop] {
+ --backdrop-frame-fill: color-mix(in oklab, var(--app-shell) var(--frame-glass-opacity, var(--glass-opacity, 100%)), transparent);
+ --backdrop-page-fill: color-mix(in oklab, var(--page-canvas) var(--glass-opacity, 100%), transparent);
+ --backdrop-background-fill: color-mix(in oklab, var(--background) var(--glass-opacity, 100%), transparent);
+}
+
+:root[data-backdrop] [data-slot="sidebar-wrapper"] {
+ --app-shell: var(--backdrop-frame-fill);
+ --page-canvas: var(--backdrop-page-fill);
+ --background: var(--backdrop-background-fill);
+}
+
+/* The blur sits on a layer under the page's content rather than on the page,
+ so the page does not become the containing block of fixed descendants. */
+:root[data-backdrop] [data-mc="page"] {
+ isolation: isolate;
+}
+
+:root[data-backdrop] [data-mc="page"]::before {
+ content: "";
+ position: absolute;
+ inset: 0;
+ z-index: -1;
+ pointer-events: none;
+ -webkit-backdrop-filter: blur(var(--glass-blur, 0px));
+ backdrop-filter: blur(var(--glass-blur, 0px));
+}
diff --git a/packages/views/common/appearance-sync.test.tsx b/packages/views/common/appearance-sync.test.tsx
index 7c76849deb..de7885d242 100644
--- a/packages/views/common/appearance-sync.test.tsx
+++ b/packages/views/common/appearance-sync.test.tsx
@@ -159,8 +159,8 @@ describe("AppearanceSync", () => {
describe("on Desktop", () => {
const encode = (text: string) => new TextEncoder().encode(text);
- const folder = (css: string) => [
- { path: "manifest.json", data: encode(JSON.stringify({ apiVersion: 1, id: "paper", name: "Paper" })) },
+ const folder = (css: string, id = "paper") => [
+ { path: "manifest.json", data: encode(JSON.stringify({ apiVersion: 1, id, name: id })) },
{ path: "theme.css", data: encode(css) },
];
let onChange: () => void = () => {};
@@ -212,5 +212,25 @@ describe("AppearanceSync", () => {
await act(async () => onChange());
await vi.waitFor(() => expect(html().hasAttribute("data-theme")).toBe(false));
});
+
+ it("lists a new folder theme without switching to it, and applies saves to the theme in use", async () => {
+ const paper = (canvas: string) => ({ folder: "paper", files: folder(`.theme-light { --page-canvas: ${canvas}; }`) });
+ const dusk = { folder: "dusk", files: folder(".theme-light { --page-canvas: #2a2438; }", "dusk") };
+ desktop.readThemeFolder.mockResolvedValue({ path: "/data/themes", entries: [paper("#fffdf8")] });
+ useAppearanceStore.setState({ theme: "paper" });
+ render(<AppearanceSync />);
+ await vi.waitFor(() => expect(themeCss()?.textContent).toContain("#fffdf8"));
+
+ desktop.readThemeFolder.mockResolvedValue({ path: "/data/themes", entries: [paper("#fffdf8"), dusk] });
+ await act(async () => onChange());
+ await vi.waitFor(() => expect(useInstalledThemesStore.getState().folders).toHaveProperty("dusk"));
+ expect(useAppearanceStore.getState().theme).toBe("paper");
+ expect(html().getAttribute("data-theme")).toBe("paper");
+
+ desktop.readThemeFolder.mockResolvedValue({ path: "/data/themes", entries: [paper("#f0f0ff"), dusk] });
+ await act(async () => onChange());
+ await vi.waitFor(() => expect(themeCss()?.textContent).toContain("#f0f0ff"));
+ expect(html().getAttribute("data-theme")).toBe("paper");
+ });
});
});
diff --git a/packages/views/common/appearance-sync.tsx b/packages/views/common/appearance-sync.tsx
index 4228b4f498..07f018a16f 100644
--- a/packages/views/common/appearance-sync.tsx
+++ b/packages/views/common/appearance-sync.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useEffect, useLayoutEffect } from "react";
+import { useCallback, useEffect, useLayoutEffect, useRef } from "react";
import { useShallow } from "zustand/react/shallow";
import {
APPEARANCE_STORAGE_KEY,
@@ -22,6 +22,7 @@ import {
} from "@multica/core/appearance";
import { getShortcutPlatform, getShortcutRuntime } from "@multica/core/shortcuts";
import { themeFolderAPI } from "../platform/theme-folder";
+import { removeBackdrop, syncBackdrop, type BackdropState } from "./backdrop-layer";
const STYLE_ELEMENT_ID = "multica-appearance";
const THEME_CSS_ELEMENT_ID = "multica-theme-css";
@@ -145,6 +146,29 @@ function useThemeFolderSync() {
}, []);
}
+/**
+ * Keeps the backdrop layer in step with the computed `--backdrop`. Returns
+ * the sync to call once the theme's CSS is written; mode changes call it
+ * themselves. The layer outlives each style rewrite and goes on unmount.
+ */
+function useBackdrop() {
+ const state = useRef<BackdropState>({ request: 0 });
+ const sync = useCallback(() => {
+ const styles = getComputedStyle(document.documentElement);
+ syncBackdrop(state.current, (name) => styles.getPropertyValue(name));
+ }, []);
+ useLayoutEffect(() => {
+ const observer = new MutationObserver(sync);
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] });
+ const current = state.current;
+ return () => {
+ observer.disconnect();
+ removeBackdrop(current);
+ };
+ }, [sync]);
+ return sync;
+}
+
function clearThemeAttributes(root: HTMLElement) {
root.removeAttribute(APPEARANCE_THEME_ATTR);
for (const name of root.getAttributeNames()) {
@@ -169,6 +193,7 @@ export function AppearanceSync() {
useModeClasses();
useStateClasses();
useThemeFolderSync();
+ const syncBackdropLayer = useBackdrop();
useLayoutEffect(() => {
const root = document.documentElement;
@@ -188,6 +213,7 @@ export function AppearanceSync() {
writeStyle(THEME_CSS_ELEMENT_ID, appearanceThemeCss(theme));
writeStyle(STYLE_ELEMENT_ID, appearanceStylesheet(theme, prefs));
orderStyles();
+ syncBackdropLayer();
return () => {
clearThemeAttributes(root);
@@ -195,7 +221,7 @@ export function AppearanceSync() {
document.getElementById(STYLE_ELEMENT_ID)?.remove();
document.getElementById(THEME_CSS_ELEMENT_ID)?.remove();
};
- }, [prefs, installed, safeMode]);
+ }, [prefs, installed, safeMode, syncBackdropLayer]);
useEffect(() => {
const onStorage = (event: StorageEvent) => {
diff --git a/packages/views/common/backdrop-layer.test.ts b/packages/views/common/backdrop-layer.test.ts
new file mode 100644
index 0000000000..14901257e0
--- /dev/null
+++ b/packages/views/common/backdrop-layer.test.ts
@@ -0,0 +1,88 @@
+import { afterEach, beforeEach, describe, expect, it } from "vitest";
+import {
+ BACKDROP_ATTR,
+ BACKDROP_ELEMENT_ID,
+ backdropImages,
+ removeBackdrop,
+ syncBackdrop,
+ type BackdropState,
+} from "./backdrop-layer";
+
+const NIGHT = 'url("data:image/svg+xml;base64,bmlnaHQ=") center / cover no-repeat';
+const DAWN = 'url("data:image/svg+xml;base64,ZGF3bg==") center / cover no-repeat';
+
+/** Image decodes that finish only when the test says so. */
+const decodes = new Map<string, () => void>();
+
+function variables(values: Record<string, string>) {
+ return (name: string) => values[name] ?? "";
+}
+
+const image = () => document.getElementById(BACKDROP_ELEMENT_ID)?.firstElementChild as HTMLElement | null;
+const settle = () => new Promise((resolve) => setTimeout(resolve, 0));
+const finishDecode = async (value: string) => {
+ for (const url of backdropImages(value)) decodes.get(url)?.();
+ await settle();
+};
+
+describe("backdrop layer", () => {
+ let state: BackdropState;
+
+ beforeEach(() => {
+ state = { request: 0 };
+ decodes.clear();
+ // jsdom has no HTMLImageElement.decode.
+ Object.defineProperty(HTMLImageElement.prototype, "decode", {
+ configurable: true,
+ value(this: HTMLImageElement) {
+ return new Promise<void>((resolve) => decodes.set(this.src, resolve));
+ },
+ });
+ });
+
+ afterEach(() => {
+ removeBackdrop(state);
+ delete (HTMLImageElement.prototype as { decode?: unknown }).decode;
+ });
+
+ it("finds the images in a background value", () => {
+ expect(backdropImages(`${NIGHT}, linear-gradient(#000, #111), url(a.png)`)).toEqual([
+ "data:image/svg+xml;base64,bmlnaHQ=",
+ "a.png",
+ ]);
+ });
+
+ it("paints the backdrop once it has decoded and marks <html>", async () => {
+ syncBackdrop(state, variables({ "--backdrop": NIGHT }));
+ expect(document.documentElement.hasAttribute(BACKDROP_ATTR)).toBe(true);
+ expect(document.body.firstElementChild?.id).toBe(BACKDROP_ELEMENT_ID);
+ expect(image()?.style.background).toBe("");
+ await finishDecode(NIGHT);
+ expect(image()?.style.background).toContain("bmlnaHQ=");
+ });
+
+ it("keeps the old backdrop on screen until the new one has decoded", async () => {
+ syncBackdrop(state, variables({ "--backdrop": NIGHT }));
+ await finishDecode(NIGHT);
+ syncBackdrop(state, variables({ "--backdrop": DAWN }));
+ await settle();
+ expect(image()?.style.background).toContain("bmlnaHQ=");
+ await finishDecode(DAWN);
+ expect(image()?.style.background).toContain("ZGF3bg==");
+ });
+
+ it("drops a decode that a later change overtook", async () => {
+ syncBackdrop(state, variables({ "--backdrop": NIGHT }));
+ syncBackdrop(state, variables({ "--backdrop": DAWN }));
+ await finishDecode(DAWN);
+ await finishDecode(NIGHT);
+ expect(image()?.style.background).toContain("ZGF3bg==");
+ });
+
+ it("removes the layer when the mode has no backdrop", () => {
+ syncBackdrop(state, variables({ "--backdrop": NIGHT }));
+ syncBackdrop(state, variables({ "--backdrop": " none" }));
+ expect(document.getElementById(BACKDROP_ELEMENT_ID)).toBeNull();
+ expect(document.documentElement.hasAttribute(BACKDROP_ATTR)).toBe(false);
+ });
+});
diff --git a/packages/views/common/backdrop-layer.ts b/packages/views/common/backdrop-layer.ts
new file mode 100644
index 0000000000..dec8cb5bb2
--- /dev/null
+++ b/packages/views/common/backdrop-layer.ts
@@ -0,0 +1,71 @@
+/**
+ * The layer a theme's `--backdrop` is painted on: a fixed element at the
+ * start of <body>, under everything, styled in appearance.css. While the mode
+ * in use has a backdrop, <html> carries `data-backdrop`, which turns the frame
+ * and the page to glass.
+ *
+ * The image is set inline from the computed value, not through `var()`, so a
+ * new one can be decoded before it replaces the old: switching themes or
+ * saving a theme file never clears the window to repaint it.
+ */
+
+export const BACKDROP_ELEMENT_ID = "multica-backdrop";
+export const BACKDROP_ATTR = "data-backdrop";
+
+export interface BackdropState {
+ /** The background the layer shows, or is about to once its images decode. */
+ wanted?: string;
+ request: number;
+}
+
+const isSet = (value: string) => value !== "" && value !== "none";
+
+/** The url()s in a `background` value. */
+export function backdropImages(value: string): string[] {
+ return [...value.matchAll(/url\(\s*(["']?)(.*?)\1\s*\)/g)].map((m) => m[2]!).filter(Boolean);
+}
+
+function decode(url: string): Promise<void> {
+ const image = new Image();
+ image.src = url;
+ return typeof image.decode === "function" ? image.decode().catch(() => undefined) : Promise.resolve();
+}
+
+/**
+ * Brings the layer and `data-backdrop` in line with the variables `read`
+ * returns, as computed on <html>.
+ */
+export function syncBackdrop(state: BackdropState, read: (name: string) => string): void {
+ const value = read("--backdrop").trim();
+ if (!isSet(value)) {
+ removeBackdrop(state);
+ return;
+ }
+ document.documentElement.setAttribute(BACKDROP_ATTR, "");
+
+ let layer = document.getElementById(BACKDROP_ELEMENT_ID);
+ if (!layer) {
+ layer = document.createElement("div");
+ layer.id = BACKDROP_ELEMENT_ID;
+ layer.setAttribute("aria-hidden", "true");
+ layer.appendChild(document.createElement("div"));
+ document.body.prepend(layer);
+ state.wanted = undefined;
+ }
+ if (state.wanted === value) return;
+ state.wanted = value;
+ const request = ++state.request;
+ const image = layer.firstElementChild as HTMLElement;
+ void Promise.all(backdropImages(value).map(decode)).then(() => {
+ if (state.request !== request || !image.isConnected) return;
+ image.style.background = value;
+ });
+}
+
+/** Removes the layer and `data-backdrop`. */
+export function removeBackdrop(state: BackdropState): void {
+ document.documentElement.removeAttribute(BACKDROP_ATTR);
+ document.getElementById(BACKDROP_ELEMENT_ID)?.remove();
+ state.wanted = undefined;
+ state.request += 1;
+}
diff --git a/packages/views/common/theme-install-dialog.tsx b/packages/views/common/theme-install-dialog.tsx
new file mode 100644
index 0000000000..17aaeb38b9
--- /dev/null
+++ b/packages/views/common/theme-install-dialog.tsx
@@ -0,0 +1,148 @@
+"use client";
+
+import { useState } from "react";
+import { Badge } from "@multica/ui/components/ui/badge";
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+} from "@multica/ui/components/ui/alert-dialog";
+import {
+ useAppearanceStore,
+ useInstalledThemesStore,
+ type Theme,
+ type ThemePackageResult,
+} from "@multica/core/appearance";
+import { useT } from "../i18n";
+
+export interface ThemeInstallDialog {
+ /** Shows a theme that was read for confirmation, or the problems that stop it installing. */
+ offer: (result: ThemePackageResult) => void;
+ /** The confirm and error dialogs; render it once. */
+ element: React.ReactNode;
+}
+
+/**
+ * Confirms installing a theme read from a file — Import theme, or a .zip an
+ * agent attached — showing what it is and that it can restyle every page,
+ * and switches to it on confirmation. Problems are listed as the checks
+ * report them, which is what someone writing a theme needs.
+ */
+export function useThemeInstallDialog(): ThemeInstallDialog {
+ const { t } = useT("settings");
+ const [pending, setPending] = useState<Theme | null>(null);
+ const [errors, setErrors] = useState<string[] | null>(null);
+ const installed = useInstalledThemesStore((s) => s.themes);
+ const install = useInstalledThemesStore((s) => s.install);
+ const uninstall = useInstalledThemesStore((s) => s.uninstall);
+ const set = useAppearanceStore((s) => s.set);
+ const previous = pending ? installed.find((theme) => theme.id === pending.id) : undefined;
+
+ const offer = (result: ThemePackageResult) => {
+ if (result.ok) setPending(result.theme);
+ else setErrors(result.errors);
+ };
+
+ const confirm = () => {
+ if (!pending) return;
+ const replaced = previous;
+ try {
+ install(pending);
+ set({ theme: pending.id });
+ } catch {
+ if (replaced) install(replaced);
+ else uninstall(pending.id);
+ setErrors([t(($) => $.appearance.import.storage_full)]);
+ }
+ setPending(null);
+ };
+
+ const element = (
+ <>
+ <AlertDialog open={pending !== null} onOpenChange={(open) => !open && setPending(null)}>
+ <AlertDialogContent>
+ {pending ? <ConfirmContent theme={pending} previous={previous} onConfirm={confirm} /> : null}
+ </AlertDialogContent>
+ </AlertDialog>
+ <AlertDialog open={errors !== null} onOpenChange={(open) => !open && setErrors(null)}>
+ <AlertDialogContent>{errors ? <ErrorsContent errors={errors} /> : null}</AlertDialogContent>
+ </AlertDialog>
+ </>
+ );
+ return { offer, element };
+}
+
+function ConfirmContent({ theme, previous, onConfirm }: { theme: Theme; previous?: Theme; onConfirm: () => void }) {
+ const { t } = useT("settings");
+ const assetCount = Object.keys(theme.assets ?? {}).length;
+ const optionCount = theme.options?.filter((option) => option.type !== "heading").length ?? 0;
+ return (
+ <>
+ <AlertDialogHeader>
+ <AlertDialogTitle className="flex items-center gap-2">
+ <span className="min-w-0 truncate">{t(($) => $.appearance.import.confirm_title, { name: theme.name })}</span>
+ <Badge variant="secondary">{t(($) => $.appearance.import.beta)}</Badge>
+ </AlertDialogTitle>
+ <AlertDialogDescription>{t(($) => $.appearance.import.warning)}</AlertDialogDescription>
+ </AlertDialogHeader>
+ <dl className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 rounded-md bg-muted px-3 py-2.5 text-caption">
+ {theme.author ? (
+ <>
+ <dt className="text-muted-foreground">{t(($) => $.appearance.import.author)}</dt>
+ <dd className="min-w-0 truncate">{theme.author}</dd>
+ </>
+ ) : null}
+ {theme.version ? (
+ <>
+ <dt className="text-muted-foreground">{t(($) => $.appearance.import.version)}</dt>
+ <dd>
+ {previous?.version
+ ? t(($) => $.appearance.import.replaces, { from: previous.version, to: theme.version })
+ : theme.version}
+ </dd>
+ </>
+ ) : null}
+ <dt className="text-muted-foreground">{t(($) => $.appearance.import.includes)}</dt>
+ <dd>
+ {[
+ "theme.css",
+ assetCount > 0 ? t(($) => $.appearance.import.has_assets, { count: assetCount }) : null,
+ optionCount > 0 ? t(($) => $.appearance.import.has_options, { count: optionCount }) : null,
+ ]
+ .filter(Boolean)
+ .join(" · ")}
+ </dd>
+ </dl>
+ <p className="text-caption text-muted-foreground">{t(($) => $.appearance.import.beta_note)}</p>
+ <AlertDialogFooter>
+ <AlertDialogCancel>{t(($) => $.appearance.import.cancel)}</AlertDialogCancel>
+ <AlertDialogAction onClick={onConfirm}>{t(($) => $.appearance.import.confirm)}</AlertDialogAction>
+ </AlertDialogFooter>
+ </>
+ );
+}
+
+function ErrorsContent({ errors }: { errors: readonly string[] }) {
+ const { t } = useT("settings");
+ return (
+ <>
+ <AlertDialogHeader>
+ <AlertDialogTitle>{t(($) => $.appearance.import.error_title)}</AlertDialogTitle>
+ <AlertDialogDescription>{t(($) => $.appearance.import.error_description)}</AlertDialogDescription>
+ </AlertDialogHeader>
+ <ul className="max-h-60 list-disc space-y-1 overflow-y-auto rounded-md bg-muted py-2.5 pr-3 pl-7 font-mono text-caption">
+ {errors.map((error, i) => (
+ <li key={i}>{error}</li>
+ ))}
+ </ul>
+ <AlertDialogFooter>
+ <AlertDialogCancel>{t(($) => $.appearance.import.close)}</AlertDialogCancel>
+ </AlertDialogFooter>
+ </>
+ );
+}
diff --git a/packages/views/editor/attachment-card.tsx b/packages/views/editor/attachment-card.tsx
index 554b7957e3..c8f4ecb034 100644
--- a/packages/views/editor/attachment-card.tsx
+++ b/packages/views/editor/attachment-card.tsx
@@ -27,6 +27,7 @@ interface AttachmentCardChromeProps {
canPreview: boolean;
canDownload: boolean;
canDelete?: boolean;
+ action?: ReactNode;
onPreview: () => void;
onDownload: () => void | Promise<unknown>;
onDelete?: () => void;
@@ -38,6 +39,7 @@ function AttachmentCardChrome({
canPreview,
canDownload,
canDelete,
+ action,
onPreview,
onDownload,
onDelete,
@@ -61,6 +63,7 @@ function AttachmentCardChrome({
: filename}
</p>
</div>
+ {!uploading && action}
{!uploading && canPreview && (
<DeferredTooltip
content={t(($) => $.attachment.preview)}
@@ -149,6 +152,8 @@ export interface AttachmentCardProps {
onDownload: () => void | Promise<unknown>;
/** Optional remove button, used by editable comment/file-card surfaces. */
onDelete?: () => void;
+ /** A labelled button shown before the icons, such as Install theme. */
+ action?: ReactNode;
/** Registers the card with the right-click menu. */
scopeRef?: (element: HTMLElement | null) => void;
}
@@ -162,6 +167,7 @@ export function AttachmentCard({
onPreview,
onDownload,
onDelete,
+ action,
scopeRef,
}: AttachmentCardProps) {
const kind = filename ? getPreviewKind(contentType, filename) : null;
@@ -177,6 +183,7 @@ export function AttachmentCard({
canPreview={canPreview}
canDownload={!!href}
canDelete={!!onDelete}
+ action={action}
onPreview={onPreview}
onDownload={onDownload}
onDelete={onDelete}
@@ -198,6 +205,8 @@ export interface AttachmentFileCardProps {
onPreview: () => void;
onDownload: () => void | Promise<unknown>;
onDelete?: () => void;
+ /** A labelled button that stays visible, such as Install theme. */
+ action?: ReactNode;
/** Registers the card with the right-click menu. */
scopeRef?: (element: HTMLElement | null) => void;
}
@@ -218,6 +227,7 @@ export function AttachmentFileCard({
onPreview,
onDownload,
onDelete,
+ action,
scopeRef,
}: AttachmentFileCardProps) {
const { t } = useT("editor");
@@ -263,6 +273,7 @@ export function AttachmentFileCard({
</span>
)}
</span>
+ {!uploading && action}
{!uploading && (canDownload || onDelete) && (
<span className={cn(
"relative flex shrink-0 items-center gap-0.5 transition-opacity group-hover/file-card:opacity-100 group-focus-within/file-card:opacity-100 [@media(hover:none)]:opacity-100",
diff --git a/packages/views/editor/attachment.tsx b/packages/views/editor/attachment.tsx
index a1029c678b..147e291292 100644
--- a/packages/views/editor/attachment.tsx
+++ b/packages/views/editor/attachment.tsx
@@ -60,6 +60,7 @@ import {
} from "./hooks/use-inline-media-url";
import { useDownloadAttachment } from "./use-download-attachment";
import { AttachmentCard, AttachmentFileCard } from "./attachment-card";
+import { InstallThemeButton, canBeThemeZip } from "./install-theme-button";
import { useAttachmentDownloadState } from "./hooks/use-attachment-download-state";
import { canOpenPreview, getPreviewKind, type PreviewKind } from "./utils/preview";
import { imageDimensions } from "./utils/image-metadata";
@@ -439,6 +440,11 @@ export function Attachment({
);
}
+ const themeAction =
+ !editable && !state.uploading && state.attachmentId && canBeThemeZip(state.filename, state.record?.size_bytes) ? (
+ <InstallThemeButton attachmentId={state.attachmentId} filename={state.filename} />
+ ) : undefined;
+
if (layout === "card") {
return (
<>
@@ -455,6 +461,7 @@ export function Attachment({
onPreview={openPreview}
onDownload={handleDownload}
onDelete={editable ? onDelete : undefined}
+ action={themeAction}
/>
{preview.modal}
</>
@@ -472,6 +479,7 @@ export function Attachment({
onPreview={openPreview}
onDownload={handleDownload}
onDelete={editable ? onDelete : undefined}
+ action={themeAction}
scopeRef={scopeRef}
/>
{preview.modal}
diff --git a/packages/views/editor/install-theme-button.test.tsx b/packages/views/editor/install-theme-button.test.tsx
new file mode 100644
index 0000000000..88bc6559b7
--- /dev/null
+++ b/packages/views/editor/install-theme-button.test.tsx
@@ -0,0 +1,76 @@
+import type { ReactNode } from "react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { cleanup, render, screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { I18nProvider } from "@multica/core/i18n/react";
+import {
+ DEFAULT_APPEARANCE,
+ THEME_PACKAGE_MAX_BYTES,
+ useAppearanceStore,
+ useInstalledThemesStore,
+ writeZip,
+} from "@multica/core/appearance";
+import enEditor from "../locales/en/editor.json";
+import enSettings from "../locales/en/settings.json";
+
+const getAttachmentBlob = vi.hoisted(() => vi.fn());
+vi.mock("@multica/core/api", () => ({ api: { getAttachmentBlob } }));
+
+import { InstallThemeButton, canBeThemeZip } from "./install-theme-button";
+
+const RESOURCES = { en: { editor: enEditor, settings: enSettings } };
+const Wrapper = ({ children }: { children: ReactNode }) => (
+ <I18nProvider locale="en" resources={RESOURCES}>
+ {children}
+ </I18nProvider>
+);
+
+const encode = (text: string) => new TextEncoder().encode(text);
+const zip = (files: Record<string, string>) =>
+ new Blob([writeZip(Object.entries(files).map(([path, text]) => ({ path, data: encode(text) })))]);
+
+describe("InstallThemeButton", () => {
+ beforeEach(() => {
+ localStorage.clear();
+ useAppearanceStore.setState(DEFAULT_APPEARANCE);
+ useInstalledThemesStore.setState({ themes: [], folders: {}, fromStore: {} });
+ getAttachmentBlob.mockReset();
+ });
+ afterEach(cleanup);
+
+ it("is offered on a .zip that is not larger than a theme may be", () => {
+ expect(canBeThemeZip("night-sky.zip", 40_000)).toBe(true);
+ expect(canBeThemeZip("NIGHT-SKY.ZIP", undefined)).toBe(true);
+ expect(canBeThemeZip("backup.zip", THEME_PACKAGE_MAX_BYTES + 1)).toBe(false);
+ expect(canBeThemeZip("notes.pdf", 100)).toBe(false);
+ });
+
+ it("installs the attachment as a theme after confirmation and switches to it", async () => {
+ getAttachmentBlob.mockResolvedValue(
+ zip({
+ "manifest.json": JSON.stringify({ apiVersion: 1, id: "night-sky", name: "Night Sky", version: "1.0.0" }),
+ "theme.css": ".theme-dark { --page-canvas: #101426; }",
+ }),
+ );
+ const user = userEvent.setup();
+ render(<InstallThemeButton attachmentId="att-1" filename="night-sky.zip" />, { wrapper: Wrapper });
+
+ await user.click(screen.getByRole("button", { name: "Install theme" }));
+ expect(getAttachmentBlob).toHaveBeenCalledWith("att-1");
+ expect(await screen.findByText(/Night Sky/)).toBeInTheDocument();
+ await user.click(screen.getByRole("button", { name: "Install and use" }));
+
+ expect(useInstalledThemesStore.getState().themes.map((theme) => theme.id)).toEqual(["night-sky"]);
+ expect(useAppearanceStore.getState().theme).toBe("night-sky");
+ });
+
+ it("lists what stops a zip from installing", async () => {
+ getAttachmentBlob.mockResolvedValue(zip({ "README.md": "not a theme" }));
+ const user = userEvent.setup();
+ render(<InstallThemeButton attachmentId="att-2" filename="code.zip" />, { wrapper: Wrapper });
+
+ await user.click(screen.getByRole("button", { name: "Install theme" }));
+ expect(await screen.findByText(enSettings.appearance.import.error_title)).toBeInTheDocument();
+ expect(useInstalledThemesStore.getState().themes).toEqual([]);
+ });
+});
diff --git a/packages/views/editor/install-theme-button.tsx b/packages/views/editor/install-theme-button.tsx
new file mode 100644
index 0000000000..42617785d8
--- /dev/null
+++ b/packages/views/editor/install-theme-button.tsx
@@ -0,0 +1,62 @@
+"use client";
+
+import { useState } from "react";
+import { toast } from "sonner";
+import { Loader2, Palette } from "@multica/ui/icons";
+import { Button } from "@multica/ui/components/ui/button";
+import { api } from "@multica/core/api";
+import { THEME_PACKAGE_MAX_BYTES, readThemePackage } from "@multica/core/appearance";
+import { useThemeInstallDialog } from "../common/theme-install-dialog";
+import { useT } from "../i18n";
+
+/**
+ * Whether an attachment could be a theme: a .zip no larger than a theme may
+ * be, which Import theme would refuse anyway. Its contents are read on click.
+ */
+export function canBeThemeZip(filename: string, sizeBytes: number | undefined): boolean {
+ return /\.zip$/i.test(filename) && (sizeBytes === undefined || sizeBytes <= THEME_PACKAGE_MAX_BYTES);
+}
+
+/**
+ * Installs a .zip attachment as a theme, through the same checks and confirm
+ * dialog as Settings → Appearance → Import theme. This is how a theme an
+ * agent built reaches someone on web or on another machine.
+ */
+export function InstallThemeButton({ attachmentId, filename }: { attachmentId: string; filename: string }) {
+ const { t } = useT("editor");
+ const dialog = useThemeInstallDialog();
+ const [reading, setReading] = useState(false);
+
+ const install = async () => {
+ setReading(true);
+ try {
+ const blob = await api.getAttachmentBlob(attachmentId);
+ dialog.offer(await readThemePackage([new File([blob], filename)]));
+ } catch {
+ toast.error(t(($) => $.attachment.install_theme_failed));
+ } finally {
+ setReading(false);
+ }
+ };
+
+ return (
+ <>
+ <Button
+ variant="outline"
+ size="xs"
+ className="relative shrink-0"
+ disabled={reading}
+ aria-busy={reading}
+ onMouseDown={(event) => event.stopPropagation()}
+ onClick={(event) => {
+ event.stopPropagation();
+ void install();
+ }}
+ >
+ {reading ? <Loader2 data-icon="inline-start" className="animate-spin" /> : <Palette data-icon="inline-start" />}
+ {t(($) => $.attachment.install_theme)}
+ </Button>
+ {dialog.element}
+ </>
+ );
+}
diff --git a/packages/views/locales/en/editor.json b/packages/views/locales/en/editor.json
index 0b43b8dbca..805b97465a 100644
--- a/packages/views/locales/en/editor.json
+++ b/packages/views/locales/en/editor.json
@@ -53,6 +53,8 @@
"zoom_actual": "Actual size"
},
"attachment": {
+ "install_theme": "Install theme",
+ "install_theme_failed": "Couldn't read the attachment. Try again in a moment.",
"download_failed": "Couldn't fetch a download link. Try again in a moment.",
"preview": "Preview",
"preview_loading": "Loading preview…",
diff --git a/packages/views/locales/en/settings.json b/packages/views/locales/en/settings.json
index 18de3a4529..1d3ffeaf95 100644
--- a/packages/views/locales/en/settings.json
+++ b/packages/views/locales/en/settings.json
@@ -277,7 +277,7 @@
},
"own": {
"title": "Make your own",
- "description": "Import a theme as a .zip or folder, or start from a copy of the current one."
+ "description": "Ask any agent to build one in a chat or an issue, import a theme as a .zip or folder, or start from a copy of the current one."
},
"tools": {
"duplicate": "Duplicate “{{name}}” as a new theme",
diff --git a/packages/views/locales/es/editor.json b/packages/views/locales/es/editor.json
index 8573928166..c5f823a747 100644
--- a/packages/views/locales/es/editor.json
+++ b/packages/views/locales/es/editor.json
@@ -53,6 +53,8 @@
"zoom_actual": "Tamaño real"
},
"attachment": {
+ "install_theme": "Instalar tema",
+ "install_theme_failed": "No se pudo leer el adjunto. Inténtalo de nuevo en un momento.",
"download_failed": "No se ha podido obtener un enlace de descarga. Inténtalo de nuevo en un momento.",
"preview": "Vista previa",
"preview_loading": "Cargando vista previa…",
diff --git a/packages/views/locales/es/settings.json b/packages/views/locales/es/settings.json
index 52b496a7b9..6ae857143f 100644
--- a/packages/views/locales/es/settings.json
+++ b/packages/views/locales/es/settings.json
@@ -277,7 +277,7 @@
},
"own": {
"title": "Crea el tuyo",
- "description": "Importa un tema como .zip o carpeta, o empieza con una copia del actual."
+ "description": "Pide a cualquier agente que cree uno en un chat o una tarea, importa un tema como .zip o carpeta, o empieza con una copia del actual."
},
"tools": {
"duplicate": "Duplicar «{{name}}» como tema nuevo",
diff --git a/packages/views/locales/fr/editor.json b/packages/views/locales/fr/editor.json
index 3af2dd6975..34f328abac 100644
--- a/packages/views/locales/fr/editor.json
+++ b/packages/views/locales/fr/editor.json
@@ -53,6 +53,8 @@
"zoom_actual": "Taille réelle"
},
"attachment": {
+ "install_theme": "Installer le thème",
+ "install_theme_failed": "Impossible de lire la pièce jointe. Réessayez dans un instant.",
"download_failed": "Impossible d'obtenir un lien de téléchargement. Réessayez dans un instant.",
"preview": "Aperçu",
"preview_loading": "Chargement de l'aperçu…",
diff --git a/packages/views/locales/fr/settings.json b/packages/views/locales/fr/settings.json
index 8367cd13ce..b9c6a95a4e 100644
--- a/packages/views/locales/fr/settings.json
+++ b/packages/views/locales/fr/settings.json
@@ -277,7 +277,7 @@
},
"own": {
"title": "Créer le vôtre",
- "description": "Importez un thème au format .zip ou depuis un dossier, ou partez d’une copie du thème actuel."
+ "description": "Demandez à n’importe quel agent d’en créer un dans un chat ou une tâche, importez un thème au format .zip ou depuis un dossier, ou partez d’une copie du thème actuel."
},
"tools": {
"duplicate": "Dupliquer « {{name}} » en nouveau thème",
diff --git a/packages/views/locales/ja/editor.json b/packages/views/locales/ja/editor.json
index 227b70248b..def05b53e2 100644
--- a/packages/views/locales/ja/editor.json
+++ b/packages/views/locales/ja/editor.json
@@ -53,6 +53,8 @@
"zoom_actual": "実際のサイズ"
},
"attachment": {
+ "install_theme": "テーマをインストール",
+ "install_theme_failed": "添付ファイルを読み込めませんでした。しばらくしてからもう一度お試しください。",
"download_failed": "ダウンロードリンクを取得できませんでした。しばらくしてからもう一度お試しください。",
"preview": "プレビュー",
"preview_loading": "プレビューを読み込み中…",
diff --git a/packages/views/locales/ja/settings.json b/packages/views/locales/ja/settings.json
index 55e490a71b..dfa92ec9ae 100644
--- a/packages/views/locales/ja/settings.json
+++ b/packages/views/locales/ja/settings.json
@@ -271,7 +271,7 @@
},
"own": {
"title": "自分で作る",
- "description": ".zip またはフォルダからテーマを読み込むか、現在のテーマのコピーから始めます。"
+ "description": "チャットやタスクで任意のエージェントに作ってもらうか、.zip またはフォルダからテーマを読み込むか、現在のテーマのコピーから始めます。"
},
"tools": {
"duplicate": "「{{name}}」を複製して新しいテーマにする",
diff --git a/packages/views/locales/ko/editor.json b/packages/views/locales/ko/editor.json
index 2f6e9ac210..4281e706bb 100644
--- a/packages/views/locales/ko/editor.json
+++ b/packages/views/locales/ko/editor.json
@@ -53,6 +53,8 @@
"zoom_actual": "실제 크기"
},
"attachment": {
+ "install_theme": "테마 설치",
+ "install_theme_failed": "첨부 파일을 읽을 수 없습니다. 잠시 후 다시 시도하세요.",
"download_failed": "다운로드 링크를 가져오지 못했습니다. 잠시 후 다시 시도하세요.",
"preview": "미리보기",
"preview_loading": "미리보기 불러오는 중...",
diff --git a/packages/views/locales/ko/settings.json b/packages/views/locales/ko/settings.json
index 6caa1038c4..258b75c8dd 100644
--- a/packages/views/locales/ko/settings.json
+++ b/packages/views/locales/ko/settings.json
@@ -271,7 +271,7 @@
},
"own": {
"title": "직접 만들기",
- "description": ".zip 파일이나 폴더로 테마를 가져오거나, 현재 테마의 사본으로 시작하세요."
+ "description": "채팅이나 태스크에서 아무 에이전트에게 만들어 달라고 하거나, .zip 파일이나 폴더로 테마를 가져오거나, 현재 테마의 사본으로 시작하세요."
},
"tools": {
"duplicate": "“{{name}}” 복제해서 새 테마 만들기",
diff --git a/packages/views/locales/ru/editor.json b/packages/views/locales/ru/editor.json
index aae93109d1..7a62ee7599 100644
--- a/packages/views/locales/ru/editor.json
+++ b/packages/views/locales/ru/editor.json
@@ -53,6 +53,8 @@
"zoom_actual": "Реальный размер"
},
"attachment": {
+ "install_theme": "Установить тему",
+ "install_theme_failed": "Не удалось прочитать вложение. Попробуйте ещё раз чуть позже.",
"download_failed": "Не удалось получить ссылку для скачивания. Повторите попытку через некоторое время.",
"preview": "Предпросмотр",
"preview_loading": "Загрузка предпросмотра…",
diff --git a/packages/views/locales/ru/settings.json b/packages/views/locales/ru/settings.json
index 89b6103910..d0551a58fb 100644
--- a/packages/views/locales/ru/settings.json
+++ b/packages/views/locales/ru/settings.json
@@ -288,7 +288,7 @@
},
"own": {
"title": "Создайте свою",
- "description": "Импортируйте тему из .zip или папки либо начните с копии текущей."
+ "description": "Попросите любого агента сделать тему в чате или задаче, импортируйте тему из .zip или папки либо начните с копии текущей."
},
"tools": {
"duplicate": "Дублировать «{{name}}» как новую тему",
diff --git a/packages/views/locales/zh-Hans/editor.json b/packages/views/locales/zh-Hans/editor.json
index 4cc0e04447..fe7df4868f 100644
--- a/packages/views/locales/zh-Hans/editor.json
+++ b/packages/views/locales/zh-Hans/editor.json
@@ -53,6 +53,8 @@
"zoom_actual": "实际大小"
},
"attachment": {
+ "install_theme": "安装主题",
+ "install_theme_failed": "无法读取附件,请稍后重试。",
"download_failed": "下载链接获取失败,请稍后重试。",
"preview": "预览",
"preview_loading": "加载预览中…",
diff --git a/packages/views/locales/zh-Hans/settings.json b/packages/views/locales/zh-Hans/settings.json
index dcc48bc3ed..533e9a1350 100644
--- a/packages/views/locales/zh-Hans/settings.json
+++ b/packages/views/locales/zh-Hans/settings.json
@@ -271,7 +271,7 @@
},
"own": {
"title": "制作自己的主题",
- "description": "从 .zip 或文件夹导入主题,或从当前主题的副本开始。"
+ "description": "在对话或任务里让任意智能体帮你做一个,从 .zip 或文件夹导入主题,或从当前主题的副本开始。"
},
"tools": {
"duplicate": "复制「{{name}}」为新主题",
diff --git a/packages/views/locales/zh-Hant/editor.json b/packages/views/locales/zh-Hant/editor.json
index b74419d23a..bf01d5019b 100644
--- a/packages/views/locales/zh-Hant/editor.json
+++ b/packages/views/locales/zh-Hant/editor.json
@@ -53,6 +53,8 @@
"zoom_actual": "實際大小"
},
"attachment": {
+ "install_theme": "安裝主題",
+ "install_theme_failed": "無法讀取附件,請稍後再試。",
"download_failed": "下載連結獲取失敗,請稍後重試。",
"preview": "預覽",
"preview_loading": "載入預覽中…",
diff --git a/packages/views/locales/zh-Hant/settings.json b/packages/views/locales/zh-Hant/settings.json
index f6d36e35e8..d02eaeb5e4 100644
--- a/packages/views/locales/zh-Hant/settings.json
+++ b/packages/views/locales/zh-Hant/settings.json
@@ -271,7 +271,7 @@
},
"own": {
"title": "製作自己的主題",
- "description": "從 .zip 或資料夾匯入主題,或從目前主題的副本開始。"
+ "description": "在對話或任務裡請任意 AI 代理幫你做一個,從 .zip 或資料夾匯入主題,或從目前主題的副本開始。"
},
"tools": {
"duplicate": "複製「{{name}}」為新主題",
diff --git a/packages/views/settings/components/appearance-tab.tsx b/packages/views/settings/components/appearance-tab.tsx
index 75939ef9a6..a3d6251220 100644
--- a/packages/views/settings/components/appearance-tab.tsx
+++ b/packages/views/settings/components/appearance-tab.tsx
@@ -20,16 +20,6 @@ import {
import { cn } from "@multica/ui/lib/utils";
import { Badge } from "@multica/ui/components/ui/badge";
import { Button } from "@multica/ui/components/ui/button";
-import {
- AlertDialog,
- AlertDialogAction,
- AlertDialogCancel,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogHeader,
- AlertDialogTitle,
-} from "@multica/ui/components/ui/alert-dialog";
import {
DropdownMenu,
DropdownMenuContent,
@@ -102,6 +92,7 @@ import { SegmentedToggle } from "../../common/segmented-toggle";
import { docsLocalePrefix } from "../../common/docs-locale";
import { openExternal } from "../../platform/open-external";
import { themeFolderAPI } from "../../platform/theme-folder";
+import { useThemeInstallDialog } from "../../common/theme-install-dialog";
import { ThemesButton, useStoreThemeInstall } from "./themes-dialog";
import { ThemeSwatch, useAppliedMode, useColorThemes, useThemeLabel, type PreviewMode } from "./theme-swatch";
import {
@@ -316,22 +307,12 @@ interface ThemeImport {
element: React.ReactNode;
}
-/**
- * Reads a theme from a .zip or a folder, shows what it is and that it can
- * restyle every page, and installs it on confirmation. Problems are listed
- * as the checks report them, which is what someone writing a theme needs.
- */
+/** Reads a theme from a .zip or a folder and offers it to install. */
function useThemeImport(): ThemeImport {
const { t } = useT("settings");
const zipRef = useRef<HTMLInputElement>(null);
const folderRef = useRef<HTMLInputElement>(null);
- const [pending, setPending] = useState<Theme | null>(null);
- const [errors, setErrors] = useState<string[] | null>(null);
- const installed = useInstalledThemesStore((s) => s.themes);
- const install = useInstalledThemesStore((s) => s.install);
- const uninstall = useInstalledThemesStore((s) => s.uninstall);
- const set = useAppearanceStore((s) => s.set);
- const previous = pending ? installed.find((theme) => theme.id === pending.id) : undefined;
+ const dialog = useThemeInstallDialog();
useEffect(() => {
// Not in React's input props; it makes the picker choose a folder.
@@ -340,23 +321,7 @@ function useThemeImport(): ThemeImport {
const read = async (files: File[]) => {
if (files.length === 0) return;
- const result = await readThemePackage(files);
- if (result.ok) setPending(result.theme);
- else setErrors(result.errors);
- };
-
- const confirm = () => {
- if (!pending) return;
- const replaced = previous;
- try {
- install(pending);
- set({ theme: pending.id });
- } catch {
- if (replaced) install(replaced);
- else uninstall(pending.id);
- setErrors([t(($) => $.appearance.import.storage_full)]);
- }
- setPending(null);
+ dialog.offer(await readThemePackage(files));
};
const picker = (ref: React.RefObject<HTMLInputElement | null>, props: React.ComponentProps<"input">) => (
@@ -372,75 +337,12 @@ function useThemeImport(): ThemeImport {
{...props}
/>
);
- const assetCount = pending ? Object.keys(pending.assets ?? {}).length : 0;
- const optionCount = pending?.options?.filter((option) => option.type !== "heading").length ?? 0;
const element = (
<>
{picker(zipRef, { accept: ".zip,application/zip", "aria-label": t(($) => $.appearance.import.from_zip) })}
{picker(folderRef, { multiple: true, "aria-label": t(($) => $.appearance.import.from_folder) })}
- <AlertDialog open={pending !== null} onOpenChange={(open) => !open && setPending(null)}>
- <AlertDialogContent>
- <AlertDialogHeader>
- <AlertDialogTitle className="flex items-center gap-2">
- <span className="min-w-0 truncate">
- {t(($) => $.appearance.import.confirm_title, { name: pending?.name ?? "" })}
- </span>
- <Badge variant="secondary">{t(($) => $.appearance.import.beta)}</Badge>
- </AlertDialogTitle>
- <AlertDialogDescription>{t(($) => $.appearance.import.warning)}</AlertDialogDescription>
- </AlertDialogHeader>
- {pending ? (
- <dl className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 rounded-md bg-muted px-3 py-2.5 text-caption">
- {pending.author ? (
- <>
- <dt className="text-muted-foreground">{t(($) => $.appearance.import.author)}</dt>
- <dd className="min-w-0 truncate">{pending.author}</dd>
- </>
- ) : null}
- {pending.version ? (
- <>
- <dt className="text-muted-foreground">{t(($) => $.appearance.import.version)}</dt>
- <dd>
- {previous?.version
- ? t(($) => $.appearance.import.replaces, { from: previous.version, to: pending.version })
- : pending.version}
- </dd>
- </>
- ) : null}
- <dt className="text-muted-foreground">{t(($) => $.appearance.import.includes)}</dt>
- <dd>
- {[
- "theme.css",
- assetCount > 0 ? t(($) => $.appearance.import.has_assets, { count: assetCount }) : null,
- optionCount > 0 ? t(($) => $.appearance.import.has_options, { count: optionCount }) : null,
- ]
- .filter(Boolean)
- .join(" · ")}
- </dd>
- </dl>
- ) : null}
- <p className="text-caption text-muted-foreground">{t(($) => $.appearance.import.beta_note)}</p>
- <AlertDialogFooter>
- <AlertDialogCancel>{t(($) => $.appearance.import.cancel)}</AlertDialogCancel>
- <AlertDialogAction onClick={confirm}>{t(($) => $.appearance.import.confirm)}</AlertDialogAction>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
- <AlertDialog open={errors !== null} onOpenChange={(open) => !open && setErrors(null)}>
- <AlertDialogContent>
- <AlertDialogHeader>
- <AlertDialogTitle>{t(($) => $.appearance.import.error_title)}</AlertDialogTitle>
- <AlertDialogDescription>{t(($) => $.appearance.import.error_description)}</AlertDialogDescription>
- </AlertDialogHeader>
- <ul className="max-h-60 list-disc space-y-1 overflow-y-auto rounded-md bg-muted py-2.5 pr-3 pl-7 font-mono text-caption">
- {errors?.map((error, i) => <li key={i}>{error}</li>)}
- </ul>
- <AlertDialogFooter>
- <AlertDialogCancel>{t(($) => $.appearance.import.close)}</AlertDialogCancel>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
+ {dialog.element}
</>
);
return { chooseZip: () => zipRef.current?.click(), chooseFolder: () => folderRef.current?.click(), element };
diff --git a/scripts/theme-check.test.mjs b/scripts/theme-check.test.mjs
index 6bc9f8f69c..34e1eb8ce0 100644
--- a/scripts/theme-check.test.mjs
+++ b/scripts/theme-check.test.mjs
@@ -89,6 +89,16 @@ test("writes a --json report larger than a pipe buffer in full", (t) => {
assert.equal(report.ok, true);
});
+test("checks the Night Sky example's glass over its backdrop colour, with nothing left unchecked", () => {
+ const result = run(resolve(import.meta.dirname, "../examples/themes/night-sky"), "--json");
+ assert.equal(result.status, 0, result.stdout + result.stderr);
+ const [report] = JSON.parse(result.stdout);
+ assert.equal(report.ok, true);
+ assert.deepEqual(report.issues, []);
+ assert.ok(report.contrast.some((c) => c.glass && c.background === "--page-canvas"));
+ assert.ok(report.contrast.some((c) => c.glass && c.background === "--app-shell"));
+});
+
test("explains a path that is not a theme", () => {
const result = run(join(tmpdir(), "no-such-theme-folder"));
assert.equal(result.status, 1);
diff --git a/scripts/theme-preview.mjs b/scripts/theme-preview.mjs
index 5ea5ba963f..5945b23bca 100644
--- a/scripts/theme-preview.mjs
+++ b/scripts/theme-preview.mjs
@@ -78,6 +78,32 @@ function page(theme, mode, appCss) {
return `<!doctype html><html lang="en" class="${mode} theme-${mode} is-web is-focused"${attrs}><head><meta charset="utf-8">${style(appCss)}${style(themeCss(theme))}${style(adjustments)}</head><body>${fixture}</body></html>`;
}
+/**
+ * Paints the mode's `--backdrop` as the app does (packages/views/common/backdrop-layer.ts),
+ * from the browser side because the page runs no script of its own.
+ */
+async function paintBackdrop(tab) {
+ await tab.evaluate(async () => {
+ const root = document.documentElement;
+ const value = getComputedStyle(root).getPropertyValue("--backdrop").trim();
+ if (value === "" || value === "none") return;
+ root.setAttribute("data-backdrop", "");
+ const layer = document.createElement("div");
+ layer.id = "multica-backdrop";
+ const image = layer.appendChild(document.createElement("div"));
+ document.body.prepend(layer);
+ const urls = [...value.matchAll(/url\(\s*(["']?)(.*?)\1\s*\)/g)].map((m) => m[2]).filter(Boolean);
+ await Promise.all(
+ urls.map((url) => {
+ const img = new Image();
+ img.src = url;
+ return img.decode().catch(() => undefined);
+ }),
+ );
+ image.style.background = value;
+ });
+}
+
const args = parseArgs(process.argv.slice(2));
if (args.targets.length !== 1 || args.modes.length === 0) {
console.error("Usage: pnpm theme:preview <theme folder or .zip> [--out <dir>] [--modes light,dark]");
@@ -108,6 +134,7 @@ try {
for (const mode of args.modes) {
const tab = await context.newPage();
await tab.setContent(page(result.theme, mode, appCss), { waitUntil: "load" });
+ await paintBackdrop(tab);
const file = join(out, `${mode}.png`);
writeFileSync(file, await tab.screenshot({ animations: "disabled" }));
await tab.close();
diff --git a/scripts/theme-preview.test.mjs b/scripts/theme-preview.test.mjs
index 003ea7225f..d7f85b45e5 100644
--- a/scripts/theme-preview.test.mjs
+++ b/scripts/theme-preview.test.mjs
@@ -95,6 +95,12 @@ const EXPECTED = [
classes: ["rounded-nav-item", "text-nav-item"],
source: "packages/views/layout/panel-nav.tsx",
},
+ {
+ what: "the frame",
+ find: (els) => els.filter((el) => el.attrs["data-slot"] === "sidebar-wrapper"),
+ classes: ["bg-app-shell"],
+ source: "packages/views/layout/dashboard-layout.tsx",
+ },
{
what: "the page",
find: (els) => anchors(els, "page"),
diff --git a/scripts/theme-preview/fixture.html b/scripts/theme-preview/fixture.html
index 941504e00c..448cf3a71e 100644
--- a/scripts/theme-preview/fixture.html
+++ b/scripts/theme-preview/fixture.html
@@ -14,7 +14,7 @@
packages/ui/styles/theme-variables.css. Class names here are only for the
fixture; themes must not rely on them.
-->
-<div class="flex h-screen bg-app-shell font-sans text-body text-foreground antialiased" style="--sidebar-width: 240px">
+<div data-slot="sidebar-wrapper" class="flex h-screen bg-app-shell font-sans text-body text-foreground antialiased" style="--sidebar-width: 240px">
<nav data-slot="app-rail" data-mc="app-rail" class="flex h-full w-14 shrink-0 flex-col items-center overflow-hidden pt-[15px] pb-2.5">
<span class="inline-flex size-[34px] shrink-0 items-center justify-center rounded-lg border border-surface-border bg-surface-raised text-body font-semibold text-foreground shadow-[var(--surface-shadow)]">A</span>
<div class="my-2 flex flex-col items-center gap-1">
diff --git a/server/internal/service/builtin_skills/multica-platform/SKILL.md b/server/internal/service/builtin_skills/multica-platform/SKILL.md
index b6fde83915..54ba5d5c55 100644
--- a/server/internal/service/builtin_skills/multica-platform/SKILL.md
+++ b/server/internal/service/builtin_skills/multica-platform/SKILL.md
@@ -1,6 +1,6 @@
---
name: multica-platform
-description: "Use for Multica platform actions the runtime brief does not fully cover: issue and PR contracts, sub-issues, saved views, charts and files in comments, mentions, agents, squads, autopilots, projects, runtimes, local environments, skill import. Not for the product code you are working on."
+description: "Use for Multica platform actions the runtime brief does not fully cover: issue and PR contracts, sub-issues, saved views, charts and files in comments, mentions, agents, squads, autopilots, projects, runtimes, local environments, skill import, themes. Not for the product code you are working on."
user-invocable: false
allowed-tools: Bash(multica *), Bash(git *), Bash(gh *)
---
@@ -29,13 +29,14 @@ Read the invariants below, then open the reference(s) your task actually needs
| `references/runtimes.md` | Runtimes, daemons, `repo checkout`, and the task CLI boundary |
| `references/environments.md` | Local environments in the issue sidebar: writing `.multica/environments.toml`, `multica env start` / `stop` / `list`, detected servers |
| `references/skill-import.md` | Importing a skill into this workspace from a URL or a local archive |
+| `references/themes.md` | Building or changing a Multica app theme: the format, the checker, delivering to Desktop's themes folder or as a `.zip` |
Open what the task needs. A single-domain task usually needs one; a task that
crosses domains needs each domain it touches — creating a squad, assigning it an
issue, then writing a mention needs `squads.md`, `issues.md` and `mentions.md`,
and skipping one of those means acting on a contract you have not read.
-What is never right is reading all ten because you are not sure. Each
+What is never right is reading all eleven because you are not sure. Each
reference states its own contracts in full and none depends on another, so
pick by domain and skip the rest.
diff --git a/server/internal/service/builtin_skills/multica-platform/references/themes.md b/server/internal/service/builtin_skills/multica-platform/references/themes.md
new file mode 100644
index 0000000000..28a7c4a5ff
--- /dev/null
+++ b/server/internal/service/builtin_skills/multica-platform/references/themes.md
@@ -0,0 +1,82 @@
+# Themes
+
+A Multica theme restyles the Multica app, on Desktop and on the web, through
+public CSS variables. A user can ask for one anywhere: a chat, an issue, a
+comment. This is the contract for building one and handing it over.
+
+## What a theme is
+
+A folder, or a `.zip` of it, holding:
+
+- `manifest.json`: `apiVersion` (1), `id`, `name`, `version`, and optionally
+ `author`, `description` and `options` (sliders, toggles and choices the user
+ can change in Settings).
+- `theme.css`: variables set on `.theme-light` and `.theme-dark`.
+- The images and fonts `theme.css` reaches with a relative `url()`.
+
+What the checker enforces, so design within it from the start:
+
+- **No code, no network.** Every `url()` points at a file inside the theme.
+- **Public variables only**, as listed in the guide; a variable of the theme's
+ own is fine when the theme reads it with `var()`.
+- **The id** is 1–40 characters of a-z, 0-9 and `-`, and not a built-in
+ theme's id. Keep it once chosen: installing the same id again replaces the
+ old version, while a new id adds a second theme.
+- **Contrast.** Text must reach WCAG AA on the surfaces it sits on, in both
+ modes. A backdrop is measured as glass over `--backdrop-color`.
+
+Style both light and dark unless the user asks for a single mode.
+
+## Get the guide and the checker
+
+The guide and the checker live in the public repository. A sparse clone
+needs only git and Node 22.18 or newer:
+
+```sh
+git clone --depth 1 --filter=blob:none --sparse https://github.com/multica-ai/multica.git multica-themes
+git -C multica-themes sparse-checkout set docs scripts packages/core packages/ui
+```
+
+Read `multica-themes/docs/theming.md` before writing anything: variables,
+selectors, options, backdrop and glass, and the contrast rules all live
+there, and they change between releases. Keep the clone for follow-ups and
+`git -C multica-themes pull` before reusing it.
+
+## Check before you deliver
+
+```sh
+node multica-themes/scripts/theme-check.mjs <theme folder or zip>
+```
+
+Deliver only when it reports **0 errors**. Fix the warnings you can, and tell
+the user why you kept any that remain. When you have a full clone with
+`pnpm install` done, `pnpm theme:preview <theme folder>` renders `light.png`
+and `dark.png`; look at them, and attach them to your reply.
+
+## Deliver
+
+Desktop watches a themes folder in its user data:
+
+| System | Themes folder |
+|---|---|
+| macOS | `~/Library/Application Support/Multica/themes` |
+| Windows | `%APPDATA%\Multica\themes` |
+| Linux | `$XDG_CONFIG_HOME/Multica/themes` (default `~/.config/Multica/themes`) |
+
+- **Desktop on this computer** (the `Multica` folder above exists): write the
+ theme into `<themes folder>/<id>/`, creating `themes` if needed. Desktop
+ lists it once it passes the checks but does not switch to it: tell the user
+ to pick it once under Settings → Appearance → Theme. From then on every
+ save to the theme in use applies within about a second, so make follow-up
+ changes in those files.
+- **Anywhere else**, or when the user is on the web or another computer: zip
+ the theme with `manifest.json` at the top of the zip as `<id>.zip`, and
+ attach it to your reply (`multica attachment upload <path>` in a chat,
+ `--attachment <path>` on `multica issue comment add`). The attachment shows
+ **Install theme**, which runs the same checks and asks before installing.
+ For a follow-up, raise `version` and attach a new zip; installing it
+ replaces the previous one.
+
+In the reply, say where the theme went (the folder, or the attachment) and,
+for the folder, that it needs picking once; what the checker reported; and
+include the previews when you have them.
diff --git a/server/internal/service/builtin_skills_test.go b/server/internal/service/builtin_skills_test.go
index 3347c21bc9..71b0e60aff 100644
--- a/server/internal/service/builtin_skills_test.go
+++ b/server/internal/service/builtin_skills_test.go
@@ -362,6 +362,7 @@ func TestPlatformSkillDescriptionNamesEveryDomain(t *testing.T) {
"references/runtimes.md": "runtime",
"references/environments.md": "local environment",
"references/skill-import.md": "skill import",
+ "references/themes.md": "theme",
}
skill, ok := findSkill(t, PlatformSkillName)
@@ -436,6 +437,7 @@ func TestPlatformSkillCoversPlatformContracts(t *testing.T) {
"references/runtimes.md",
"references/environments.md",
"references/skill-import.md",
+ "references/themes.md",
// Invariants deduplicated out of the eight merged bodies. Each
// was repeated in most of them; the router is now their only
// home, so losing one here loses it everywhere.
@@ -713,6 +715,25 @@ func TestPlatformSkillCoversPlatformContracts(t *testing.T) {
"resource_ref.ref",
},
},
+ {
+ // MUL-9248: theme knowledge ships here instead of riding in a
+ // per-request prompt, so any agent can build one from any chat
+ // or issue. The checker gate and the two delivery paths are what
+ // make a delivered theme installable; losing either strands it.
+ file: "references/themes.md",
+ want: []string{
+ "docs/theming.md",
+ "scripts/theme-check.mjs",
+ "Deliver only when it reports **0 errors**",
+ "~/Library/Application Support/Multica/themes",
+ "%APPDATA%\\Multica\\themes",
+ "~/.config/Multica/themes",
+ "does not switch to it",
+ "every save to the theme in use applies",
+ "**Install theme**",
+ "multica attachment upload <path>",
+ },
+ },
{
file: "references/skill-import.md",
want: []string{