Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
dash keys its theme off data-theme, like the other three apps (#449)
nyblnet8d93af5301e4
diff --git a/dash/CHANGELOG.md b/dash/CHANGELOG.mdindex 761582f3..93f7e8fd 100644--- a/dash/CHANGELOG.md+++ b/dash/CHANGELOG.md@@ -155,6 +155,14 @@ The release that came out of watching somebody use 0.2.0.and take unsaved edits with it; a `?` shortcut card generated from the key mapitself; and ⇧Space selects the row, which had never worked.+- **Dark theme works the way it does in every other Bento app.** Dash was+ themed through a mechanism of its own — the only one of the four apps that+ was — and it meant a stylesheet shared across the suite could not have+ themed dash at all. The palette is unchanged, light and dark, value for+ value; the switch underneath it is now the shared one. An existing theme+ preference carries over. Controls (buttons, inputs, chips) take the shared+ 10px radius rather than dash's 7px, so a button looks the same here as in+ slides, spaces and type.- **A value too wide for its column can be read by hovering it.** Cells clipwith an ellipsis, and until now the rest of the value was simply gone — theonly way to recover it was to click the cell and read the formula bar, oncediff --git a/dash/src/comments.css b/dash/src/comments.cssindex d4f3164a..87f3d8ef 100644--- a/dash/src/comments.css+++ b/dash/src/comments.css@@ -21,8 +21,13 @@cell. Violet is the only hue in dash that is not already spoken for.These two lines belong in styles.css :root beside --err-ink; they are hereonly because this file may not edit that one. */- --cmt: light-dark(#7c3aed, #a78bfa);- --cmt-wash: light-dark(#f5f0ff, #2a2140);+ --cmt: #7c3aed;+ --cmt-wash: #f5f0ff;+}++:root[data-theme="dark"] {+ --cmt: #a78bfa;+ --cmt-wash: #2a2140;}/* ————— the marker —————diff --git a/dash/src/find.css b/dash/src/find.cssindex 970bbf4e..90306dcc 100644--- a/dash/src/find.css+++ b/dash/src/find.css@@ -21,14 +21,20 @@chip", and a find hit is a different kind of thing. Green reads as "hereit is" against both the blue selection fill (--sel) and the amber accent,and stays distinguishable from the red error cells. */- --find-hit: light-dark(#d9f2e3, #17402c);+ --find-hit: #d9f2e3;/* The CURRENT match is a fill the document did not choose, so its ink is--ink-on-fill (#1e2a3a) in BOTH themes — the same rule the conditionalformatting section states. That fixes the dark value: #2f9e68 measured4.29:1 against that ink, under AA on the one cell the whole feature existsto point at. #3aad74 is 5.12:1 and reads as the same green. */- --find-cur: light-dark(#7ddaa6, #3aad74);- --find-ring: light-dark(#0f8f57, #4fd18d);+ --find-cur: #7ddaa6;+ --find-ring: #0f8f57;+}++:root[data-theme="dark"] {+ --find-hit: #17402c;+ --find-cur: #3aad74;+ --find-ring: #4fd18d;}/* ————— the bar ————— */diff --git a/dash/src/main.ts b/dash/src/main.tsindex 2e7d75bc..5415cc4d 100644--- a/dash/src/main.ts+++ b/dash/src/main.ts@@ -28,6 +28,7 @@ import {canWriteInPlace, downloadFile, suggestedFileName, openedFileName, registerPreview,currentFileName,} from '../../kernel/src/save.ts'+import { startTheme } from '../../kernel/src/theme.ts'import { putRecovery, pruneOld } from '../../kernel/src/autosave.ts'import { FileWriteBack } from './writeback.ts'import { APP_VERSION } from '../../kernel/src/update.ts'@@ -164,6 +165,15 @@ configureApp({capturePristine()+// Theme: AFTER capturePristine, BEFORE the first paint — slides' two lines,+// for slides' two reasons. capturePristine clones the LIVE document and every+// save re-serializes that clone, so `data-theme` on <html> must not exist yet+// or a viewer's preference travels inside every file they save (dash measured+// exactly that once, which is why it used to theme through a transient <style>+// instead — see settings.ts). And before the paint, because applying it later+// renders the workspace light and then flips it, which reads as a bug.+startTheme()+// The file-manager thumbnail. Registered BEFORE any save can happen: a save// that ran first would write a shell with no preview in it, and the next// thumbnail request would show the boot splash again.diff --git a/dash/src/panels.css b/dash/src/panels.cssindex 9d3dc100..06e7a014 100644--- a/dash/src/panels.css+++ b/dash/src/panels.css@@ -226,8 +226,9 @@ body.dp-resizing { cursor: col-resize; user-select: none; }display: flex;align-items: center;justify-content: center;- box-shadow: 0 1px 4px light-dark(rgb(20 30 45 / 0.12), rgb(0 0 0 / 0.45));+ box-shadow: 0 1px 4px rgb(20 30 45 / 0.12);}+:root[data-theme="dark"] .dp-toggle { box-shadow: 0 1px 4px rgb(0 0 0 / 0.45); }.dp-toggle:hover { color: var(--ink); border-color: var(--line-strong); }/* shut: the chevron pins fully on-screen, docked to the edge like a drawer pull */.dp-resizer:has(+ .dp-panel.dp-shut) .dp-toggle {diff --git a/dash/src/settings.ts b/dash/src/settings.tsindex 939db56f..c249e691 100644--- a/dash/src/settings.ts+++ b/dash/src/settings.ts@@ -30,6 +30,7 @@ import {import { disconnectOnline, joinFromDoc } from './sync/online.ts'import type { SyncSession } from './sync/session.ts'import { openDialog } from './dialog.ts'+import { themeChoice, setTheme, type ThemeChoice } from '../../kernel/src/theme.ts'import { t, locale, localeChoices, setLocale } from './i18n.ts'import type { Store } from './store.ts'@@ -128,85 +129,33 @@ export const updateWaiting = (): boolean => launchCheck?.status === 'update'// --- theme: a VIEWER preference, never the document's --------------------------//// The same shape as story.ts's reduced-motion switch and the interface-// language: this is ONE PERSON's preference about their own screen, so it-// lives in localStorage and never enters the format (PLATFORM §8).+// language: ONE PERSON's preference about their own screen, in localStorage,+// never in the format (PLATFORM §8). `doc.theme` in model.ts is a DIFFERENT+// thing — the document's own palette, which travels in the file and colours+// the charts and the static preview. Nothing here touches it.//-// `doc.theme` in model.ts is a DIFFERENT thing and must not be confused with-// this: that is the document's own palette, it travels in the file, and it-// colours the charts and the static preview. Nothing here reads or writes it.+// THE MECHANISM IS kernel/src/theme.ts, shared with slides, spaces and type:+// `data-theme` on <html>, which styles.css keys off, plus `color-scheme` for+// the browser's own furniture. Dash had its own store here until 2026-09-12 —+// a transient <style> pinning `color-scheme`, with the palette written as+// light-dark() pairs — and the reason it gave was a real, measured bug: with+// the attribute set at module load, `bento.serialize()` came back with+// `<html data-theme="light">`, because capturePristine() clones the live+// document and every save re-serializes that clone.//-// THE MECHANISM IS A TRANSIENT <style>, AND IT HAD TO BE. The obvious-// implementation — `data-theme` on <html>, matched by `:root[data-theme=…]` in-// styles.css — QUIETLY WRITES THE PREFERENCE INTO EVERY SAVED FILE.-// `capturePristine()` (kernel/src/save.ts) clones the LIVE document at boot, so-// anything sitting on the root element by then is in the shell every ⌘S-// produces: measured, `bento.serialize()` came back with-// `<html lang="en" data-theme="light">`, and that file would then force one-// reader's choice on everyone who opened it. Exactly the bug this whole design-// exists to avoid, arriving through the back door.+// THE ANSWER TO THAT IS ORDER, NOT A DIFFERENT MECHANISM. startTheme() is+// called from main.ts AFTER capturePristine() and before the first paint, so+// the pristine copy never carries the attribute and nothing is painted in the+// wrong theme first. slides documents the same two constraints at its own call+// site. The rig proves the saved-file half by serializing under a dark theme+// and grepping the result.//-// A node carrying `data-bento-transient` is stripped from every serialized-// shell (kernel save.ts TRANSIENT_SELECTOR) — the same mechanism the-// compressed shell uses for its inflated stylesheet. So the override is a-// <style> element carrying that attribute, and it declares `color-scheme`-// rather than any colour: styles.css writes the palette as `light-dark()`-// pairs, which resolve against the used `color-scheme`, so pinning that one-// property flips every token at once. 'auto' REMOVES the element — the absence-// of an override is what "follow the OS" means.-//-// `:root:root` for specificity (0,2,0), not `!important` and not a reliance on-// document order: this <style> is appended at module load, while the app's own-// stylesheet arrives from the deflate loader in the built shell and from Vite's-// injector in dev, and those two orders are not the same.-//-// --bar-opacity rides along because `light-dark()` is colour-only; see the-// note beside it in styles.css.--export type ThemePref = 'auto' | 'light' | 'dark'--const THEME_KEY = 'bento-theme'-const THEME_STYLE_ID = 'dx-theme'--/** The dark ground's data-bar opacity, kept in step with styles.css. */-const BAR_OPACITY: Record<'light' | 'dark', string> = { light: '0.55', dark: '0.45' }--export function readThemePref(): ThemePref {- try {- const v = localStorage.getItem(THEME_KEY)- return v === 'light' || v === 'dark' ? v : 'auto'- } catch { return 'auto' }-}--export function applyTheme(pref: ThemePref = readThemePref()): void {- const existing = document.getElementById(THEME_STYLE_ID)- if (pref === 'auto') { existing?.remove(); return }- const style = existing ?? document.createElement('style')- style.id = THEME_STYLE_ID- // Never let this reach a saved file (see above). Set before the node is in- // the document, so there is no window in which an unmarked style exists.- style.setAttribute('data-bento-transient', '')- style.textContent =- `:root:root{color-scheme:${pref};--bar-opacity:${BAR_OPACITY[pref]}}`- if (!existing) document.head.append(style)-}--export function setThemePref(pref: ThemePref): void {- try {- if (pref === 'auto') localStorage.removeItem(THEME_KEY)- else localStorage.setItem(THEME_KEY, pref)- } catch { /* private mode — the choice still holds for this session */ }- applyTheme(pref)-}+// What decided the switch: measured in a browser, `data-theme="dark"` on dash+// did nothing, so a shared kernel stylesheet keyed off the attribute — the only+// key slides can use, since it pins `color-scheme: only light` — could not have+// themed dash at all. The same localStorage key ('bento-theme') was already in+// use here, so an existing preference carries over untouched.-// AT MODULE LOAD, and deliberately not from a hook: main.ts imports about.ts-// (which imports this) while it is booting and mounts its dialogs near the END-// of that boot, so waiting for a hook would paint the whole workspace in the-// wrong theme first. Here the rule lands before the app is built and while the-// splash is still covering the screen — which is also what lets the splash-// itself follow an explicit choice (index.html gives it `light-dark()` colours-// and nothing else). Guarded because the rigs import this module in Node, where-// there is no document to touch.-if (typeof document !== 'undefined') applyTheme()// --- the dialog ---------------------------------------------------------------@@ -259,13 +208,13 @@ export function openSettings(hooks: SettingsHooks): void {// rebuild, and unlike the language picker this one does not have to close and// reopen the dialog.card.append(d.h(t('Appearance')))- const themes: Array<[ThemePref, string]> = [+ const themes: Array<[ThemeChoice, string]> = [['auto', t('Match my system')],['light', t('Light')],['dark', t('Dark')],]const themeSel = document.createElement('select')- const current = readThemePref()+ const current = themeChoice()for (const [v, label] of themes) {const o = document.createElement('option')o.value = v@@ -273,7 +222,7 @@ export function openSettings(hooks: SettingsHooks): void {if (v === current) o.selected = truethemeSel.append(o)}- themeSel.addEventListener('change', () => setThemePref(themeSel.value as ThemePref))+ themeSel.addEventListener('change', () => setTheme(themeSel.value as ThemeChoice))card.append(d.row(t('Theme'), themeSel))// --- updates --------------------------------------------------------------diff --git a/dash/src/styles.css b/dash/src/styles.cssindex 8aeb76de..b77e8e29 100644--- a/dash/src/styles.css+++ b/dash/src/styles.css@@ -17,22 +17,42 @@charts and the static preview. Do not conflate them; nothing here is everread from or written to the document.- HOW THE SWITCH WORKS. `light-dark()` resolves against the element's used- `color-scheme`, so a token's two values sit on ONE line where they can be- compared — and there is no second copy of the palette inside a- `prefers-color-scheme` block to fall out of step with the first. The default- `light dark` follows the OS; an explicit choice pins `color-scheme` through- a single rule about.ts injects, and it wins in BOTH directions (a reader on- a dark desktop who wants a light sheet is as real a case as the reverse).-- `color-scheme` is also what turns the scrollbars, the caret, the native- selects and the resize grippers dark, and it is declared HERE rather than in- index.html's <meta name="color-scheme"> because a CSS declaration on the- root element beats that meta — verified in the browser, both directions.-- WHICH TOKENS VARY: exactly the ones written as a `light-dark()` pair. The+ HOW THE SWITCH WORKS — and how it used to, because the old way was reasoned+ and someone will otherwise put it back. :root holds the LIGHT palette; the+ `:root[data-theme="dark"]` block right after it redefines the tokens that+ vary. kernel/src/theme.ts puts `data-theme` on <html> — resolving 'auto'+ against the OS itself, and re-resolving when the OS flips — and also sets+ `color-scheme`, which is what turns the scrollbars, the caret, the native+ selects and the resize grippers dark. Stylesheets key off the attribute;+ `color-scheme` is for the browser's own furniture. That is the division+ theme.ts states, and it is the one slides, spaces and type already follow.++ Dash used `light-dark()` pairs until 2026-09-12, for two reasons this file+ gave at the time. One: a token's two values sat on ONE line, with no second+ copy of the palette to drift from the first. That was a real advantage and+ is the cost of this change; the dark block keeps the same order and the same+ section markers to make side-by-side reading as cheap as it can be, and the+ rig fails on any dark token with no light twin. Two: "an attribute on <html>+ is cloned into every saved file by capturePristine()". True — and answered+ by ORDER, not by avoiding the attribute: main.ts calls startTheme() AFTER+ capturePristine() and before the first paint, so the pristine copy every+ save re-serializes never carries it. slides documents the same two lines.+ The comment also said slides "has none to copy"; it has had a dark block+ since #285. What actually decided it: measured in a browser, setting+ `data-theme="dark"` on dash did NOTHING, so a shared kernel stylesheet keyed+ off the attribute — which is the only key slides can use, since it pins+ `color-scheme: only light` — could not have themed dash at all. Three apps+ on one mechanism and one on another is the divergence, whatever the values.++ `color-scheme: light dark` stays on :root below, for two things that run+ BEFORE theme.ts does: index.html's splash, which is painted from+ `light-dark()` colours before any script runs and so can only follow the OS,+ and the browser furniture in that same window. theme.ts overrides both the+ moment it runs.++ WHICH TOKENS VARY: exactly the ones that appear in the dark block. Theplain values — the brand amber, the radii, the type scale, the row height —- are the same object on both grounds and are deliberately NOT paired. The+ are the same object on both grounds and are deliberately NOT themed. Theamber is the interesting one: it reads ON the dark ground at 9.25:1, so theaccent does not change when the lights go out. It is 2.02:1 on white, whichis why it is only ever a border, a badge or a mark there and never body@@ -51,32 +71,32 @@The name on the left is dash's; slides' name for the same thing is givenin the comment, and is aliased at the foot of this block so a rule portedfrom slides resolves without being rewritten. */- --bg: light-dark(#ffffff, #0e1319); /* the page, and the sheet itself */+ --bg: #ffffff; /* the page, and the sheet itself *//* chrome bands: top bar, status bar. slides: --chrome */- --panel: light-dark(#f5f7fa, #161c24);+ --panel: #f5f7fa;/* Raised opaque surfaces — menus, dialogs, popovers, inputs, buttons, theside panels. On white it IS the page colour; on dark it has to lift offthe page or a menu floating over the grid has no edge but its shadow, andshadows barely read on a dark ground. */- --surface: light-dark(#ffffff, #1b222c);+ --surface: #ffffff;/* menu rows, buttons, list items. slides: --chrome-2 */- --hover: light-dark(#eceff4, #26303d);+ --hover: #eceff4;/* A wash for hover states drawn OVER unknown content (a chart band, a tablerow that may already be tinted). Alpha, not a colour, for that reason. */- --wash: light-dark(rgb(0 0 0 / 0.04), rgb(255 255 255 / 0.07));- --line: light-dark(#e3e8ef, #1f2731);- --line-strong: light-dark(#cbd5e1, #2f3a49);- --ink: light-dark(#1e2a3a, #d6dee9);+ --wash: rgb(0 0 0 / 0.04);+ --line: #e3e8ef;+ --line-strong: #cbd5e1;+ --ink: #1e2a3a;/* Secondary ink — control labels, panel rows. slides: --ink-2. dash had nosuch token and reached for --muted, which is a CAPTION grey and a step toolight for a word somebody is meant to act on. */- --ink-2: light-dark(#31445c, #b9c5d4);+ --ink-2: #31445c;/* MEASURED, and the reason this is slides' #5b6472 rather than the #64748bdash had: --muted carries 11–11.5px captions, and at #64748b it was4.34:1 on --hover and 4.22:1 on --accent-wash — under AA on the twogrounds a caption most often lands on. slides' grey is 5.19:1 and 5.30:1on those same two, 5.57:1 on --panel, and it is the same hue family. */- --muted: light-dark(#5b6472, #93a0b2);+ --muted: #5b6472;--accent: #f7a600;/* Ink for a word that MEANS amber — a partial total, a "+ add" invitation —where the amber itself is 2.02:1 on white and cannot be the text. slides:@@ -85,13 +105,13 @@value is the amber ink --warn-ink already uses, so the app carries oneamber-on-dark and not two. MEASURED: 6.92:1 on white, 9.22:1 on the darkheader band. */- --accent-ink: light-dark(#7a5200, #f0b357);+ --accent-ink: #7a5200;--slash: #ff9e8a; /* the wordmark's peach *//* Focus, and the selection ring, are ONE colour — see the focus note below.slides calls it --blue and uses it for the same job. */--blue: var(--sel-ring);/* slides' scrim and its two shadow tiers (popover, dialog), verbatim. */- --scrim: light-dark(rgb(15 23 36 / 0.38), rgb(2 5 9 / 0.66));+ --scrim: rgb(15 23 36 / 0.38);/* ————— THE SHADOWS HAVE TO BE BUILT THIS WAY, and it is not a style choice —————`light-dark()` is a <color> function. A CUSTOM property holds any tokenstream, so `--shadow-pop: light-dark(0 12px 32px …, …)` is a perfectly@@ -113,28 +133,28 @@Light on a dark desktop would get light surfaces wearing dark-tunedshadows. `scripts/test-dash-theme.ts` now fails on any light-dark() whoselight half is not a colour. */- --shadow-pop-color: light-dark(rgb(15 23 36 / 0.18), rgb(0 0 0 / 0.55));- --shadow-dialog-color: light-dark(rgb(15 23 36 / 0.3), rgb(0 0 0 / 0.7));+ --shadow-pop-color: rgb(15 23 36 / 0.18);+ --shadow-dialog-color: rgb(15 23 36 / 0.3);--shadow-pop: 0 12px 32px var(--shadow-pop-color);--shadow-dialog: 0 18px 50px var(--shadow-dialog-color);/* ————— semantic ————— */- --warn-bg: light-dark(#fffbeb, #221b0d); /* the findings strip */- --warn-ink: light-dark(#b45309, #f0b357);- --warn-chip: light-dark(#fef3c7, #3a2e10);- --err-ink: light-dark(#b91c1c, #ff9b8f);- --err-bg: light-dark(#fef2f2, #2b1618);- --up-ink: light-dark(#1f8a5b, #4fbf8b);- --down-ink: light-dark(#c0503c, #f08a78);+ --warn-bg: #fffbeb; /* the findings strip */+ --warn-ink: #b45309;+ --warn-chip: #fef3c7;+ --err-ink: #b91c1c;+ --err-bg: #fef2f2;+ --up-ink: #1f8a5b;+ --down-ink: #c0503c;/* The toast inverts against the app on light and merely lifts on dark:a white slab on a dark sheet is a flashbulb, not a status line. */- --toast-bg: light-dark(#1e2a3a, #2b3543);- --toast-ink: light-dark(#ffffff, #e8edf5);+ --toast-bg: #1e2a3a;+ --toast-ink: #ffffff;/* Accent-tinted surfaces — the active sheet, a filter chip. Distinct from--sel: this one means "this is the chosen one", not "this is selecteddata", and the two stopped being the same colour when selection wentblue. */- --accent-wash: light-dark(#fdf0d6, #38290c);+ --accent-wash: #fdf0d6;/* The bar under the ACTIVE worksheet tab — a non-text indicator, so it has a3:1 floor to clear rather than a decorative one. MEASURED against the tabit sits on: the brand amber is 9.25:1 on the dark sheet and 2.02:1 on the@@ -166,7 +186,7 @@ground the labels came out at 3.6:1 and the axis was unreadable. The lightvalue here IS the kernel's default, so light-theme charts are untouched;see the rule near .dx-chart-body for why CSS can reach them at all. */- --chart-ink: light-dark(#6b7280, #a7b3c4);+ --chart-ink: #6b7280;/* COUPLED TO grid.ts `ROW_H`, and there is no mechanism keeping them honest.The body is virtualised: JS positions every row at `top: i * ROW_H` as an@@ -230,12 +250,12 @@Text on it: --muted is 5.28:1 (light) and 5.97:1 (dark), --ink 12.81:1 and11.69:1 — the empty-state note is the only thing that ever lands here. */- --desk: light-dark(#eef1f6, #1b232d);+ --desk: #eef1f6;- --grid-line: light-dark(#edf0f4, #212a35);- --grid-head: light-dark(#fbfcfd, #151c25); /* the header/gutter band */- --grid-head-ink: light-dark(#4a5568, #a9b6c7);- --grid-head-on: light-dark(#dbe7fb, #1d3050); /* a selected row/column header */+ --grid-line: #edf0f4;+ --grid-head: #fbfcfd; /* the header/gutter band */+ --grid-head-ink: #4a5568;+ --grid-head-on: #dbe7fb; /* a selected row/column header *//* ————— selection —————Cool, and deliberately NOT the brand amber. The amber tint used to sit on@@ -243,15 +263,23 @@the document had coloured were the same warm smear; the two things areunrelated and now cannot be confused. --sel-ring is the cursor cell's ringand the range outline; --sel is the range fill. */- --sel: light-dark(#eef4ff, #16243c);- --sel-ring: light-dark(#2563eb, #3b82f6);+ --sel: #eef4ff;+ --sel-ring: #2563eb;/* ————— one scale, five surfaces —————The pivot, the dashboard, the story editor, the save menu and the Aboutdialog were each written separately and each picked its own radii, shadowsand caption size. These are the agreed values; every one of those filesnow reads them rather than restating a number. */- --radius: 7px; /* controls: buttons, inputs, chips */+ /* 10px, NOT 7px, and the 7px was a real choice, not drift: dash split the+ radius into a three-step scale (control / floating surface / dialog) and+ 7px was the control step, recorded as a deliberate divergence in+ test-dash-theme.ts. It goes because `--radius` is about to be a SHARED+ token in kernel's stylesheet with one value across four apps, and a dash+ that redefined it would be the one app whose buttons differ from the+ other three. --radius-lg and --radius-xl are dash's own and keep the scale+ where dash still needs it; `--radius` and `--radius-lg` now coincide. */+ --radius: 10px; /* controls: buttons, inputs, chips — the shared value */--radius-lg: 10px; /* floating surfaces: menus, popovers, cards */--radius-xl: 14px; /* dialogs *//* the two shadows are theme-varying and live in the palette block above */@@ -278,20 +306,65 @@--chrome-2: var(--hover);}-/* THE EXPLICIT OVERRIDE IS NOT IN THIS FILE, and that is not an oversight.- It is a `:root:root{color-scheme:…}` rule injected at boot by about.ts- inside a `data-bento-transient` <style>, because the natural version — an- attribute on <html> plus `:root[data-theme=…]` rules here — is CLONED INTO- EVERY SAVED FILE by capturePristine() and would force one reader's- preference on everyone who opened the workbook afterwards. The whole story- is in about.ts; what matters here is that flipping `color-scheme` is all an- override does, and every `light-dark()` pair above follows it.+/* THE DARK PALETTE, keyed off `data-theme` — see the note above :root for why+ this is a block and no longer a light-dark() pair per token. Same names, same+ ORDER, same section markers as :root, so the two can be read side by side;+ a token that appears here and not in :root is a bug the rig catches. */+:root[data-theme="dark"] {++ /* ————— ground and chrome ————— */+ --bg: #0e1319;+ --panel: #161c24;+ --surface: #1b222c;+ --hover: #26303d;+ --wash: rgb(255 255 255 / 0.07);+ --line: #1f2731;+ --line-strong: #2f3a49;+ --ink: #d6dee9;+ --ink-2: #b9c5d4;+ --muted: #93a0b2;+ --accent-ink: #f0b357;+ --scrim: rgb(2 5 9 / 0.66);++ /* ————— THE SHADOWS HAVE TO BE BUILT THIS WAY, and it is not a style choice ————— */+ --shadow-pop-color: rgb(0 0 0 / 0.55);+ --shadow-dialog-color: rgb(0 0 0 / 0.7);- What DOES belong here is the OS default for the one token light-dark()- cannot carry. */-@media (prefers-color-scheme: dark) {- :root { --bar-opacity: 0.45; }-}+ /* ————— semantic ————— */+ --warn-bg: #221b0d;+ --warn-ink: #f0b357;+ --warn-chip: #3a2e10;+ --err-ink: #ff9b8f;+ --err-bg: #2b1618;+ --up-ink: #4fbf8b;+ --down-ink: #f08a78;+ --toast-bg: #2b3543;+ --toast-ink: #e8edf5;+ --accent-wash: #38290c;+ --chart-ink: #a7b3c4;++ /* ————— THE DESK: the ground a DATASET sits on ————— */+ --desk: #1b232d;+ --grid-line: #212a35;+ --grid-head: #151c25;+ --grid-head-ink: #a9b6c7;+ --grid-head-on: #1d3050;++ /* ————— selection ————— */+ --sel: #16243c;+ --sel-ring: #3b82f6;++ /* the one themed token that is not a colour; was a media query */+ --bar-opacity: 0.45;+}++/* NO OS MEDIA QUERY, deliberately. `data-theme` is always EXPLICIT on <html>:+ kernel/src/theme.ts resolves 'auto' against prefers-color-scheme itself,+ sets the attribute, and re-sets it when the OS flips. A media block here+ would be a second opinion about the same fact, and the two would disagree+ the first time a reader chose the opposite of their OS. --bar-opacity, the+ one themed token that is not a colour, therefore lives in the dark block+ above with everything else. */* { box-sizing: border-box; }@@ -1617,8 +1690,13 @@ html, body {about the same cell. Declared here rather than in comments.css so the themeowns both halves of the pair. */:root {- --cmt: light-dark(#7c5cff, #a48bff);- --cmt-wash: light-dark(#f2efff, #241f3d);+ --cmt: #7c5cff;+ --cmt-wash: #f2efff;+}++:root[data-theme="dark"] {+ --cmt: #a48bff;+ --cmt-wash: #241f3d;}/* ————— the spreadsheet kind (grid.ts, `kind: 'canvas'`) —————diff --git a/docs/DECISIONS.md b/docs/DECISIONS.mdindex ac8e4a5a..ac014511 100644--- a/docs/DECISIONS.md+++ b/docs/DECISIONS.md@@ -6695,6 +6695,55 @@ chance to run and it is cheap. Reconciliation for this cycle: 41 commits, 40mapped, 1 correctly absent, run by bento-team-slides.+## 2026-09-12 — bento/dash keys its theme off `data-theme`, like the other three apps++**The divergence the maintainer asked dash to fix was a MECHANISM, not a+palette.** Ten token names are shared across all four apps; dash differed on+nine of their values. That was the symptom. Measured in a browser with one+gesture per app: slides, spaces and type all theme off `:root[data-theme="dark"]`+and none respond to `color-scheme` alone; dash themed off `light-dark()` — which+resolves against `color-scheme` — and setting `data-theme="dark"` on it did+NOTHING. Three apps on one switch and one on another.++**Why it matters more than a palette difference:** kernel's shared stylesheet+(UI primitives, tier 4) can only key off `data-theme`, because slides pins+`color-scheme: only light` for a documented reason (dark-mode phones render+native form controls dark against dark ink — blank dropdowns). A shared sheet+built that way could not have themed dash at all. So dash conforms; keeping its+dark palette, which is good, as a mechanical transform into a dark block.++**Dash's `light-dark()` was a reasoned choice, and this entry exists so nobody+reverts it from the old reasoning.** Its stylesheet gave two arguments. One: a+token's two values on ONE line, with no second copy to drift — a real advantage+and the honest cost of this change, mitigated by giving the dark block the+same order and section markers as `:root`, and a rig check that fails on any+dark token without a light twin. Two: "`data-theme` on `<html>` is cloned into+every saved file by `capturePristine()`" — a bug dash had MEASURED+(`bento.serialize()` returned `<html data-theme="light">`). That is answered by+ORDER, not by a different mechanism: `startTheme()` runs after+`capturePristine()` and before the first paint, which slides already documents+at its call site. Re-measured after this change: live root `data-theme="dark"`,+serialized `<html lang="en">`. The old comment also said slides "has none to+copy"; it has had a dark block since #285.++**`--radius` was NOT drift, and the record should say so.** It was reported to+the lead as "7px, no reasoning anywhere". Wrong: dash's rig listed it as a+deliberate three-step scale (control / floating surface / dialog) with 7px as+the control step. It takes the shared 10px anyway, because a shared token+should mean one thing across four apps and kernel's sheet is about to own it;+`--radius-lg` and `--radius-xl` are dash's own and keep the scale where dash+still needs it. A documented choice was overridden for a stated reason, not+undone by mistake — and the rig's DIVERGENCES loop now fails on any exemption+for a token that has come back into line, so a stale allowance cannot outlive+its reason again.++**What this entry does NOT decide:** whether the sheet itself inverts. Dash's+`--bg` is themed and its comment reads "the page, and the sheet itself" — so on+a grid the paper goes dark, where bento/type keeps its page white because a+contract will be printed. That is defensible for a grid and undecided for the+platform. `--bg` is left exactly as it was, themed and commented, so the+question stays visible until the maintainer rules on it.+## 2026-09-10 — spaces view filters: a FLAT condition list, and unknown operators show MORE## 2026-09-09 — PAGE → DECK emits a DOCUMENT, not a file, and says what it droppeddiff --git a/scripts/test-dash-surface.ts b/scripts/test-dash-surface.tsindex 83a38e67..b70ad998 100644--- a/scripts/test-dash-surface.ts+++ b/scripts/test-dash-surface.ts@@ -90,21 +90,33 @@ function rule(selector: string): string | null {return null}-/** Every `--name: value;` declared anywhere in a :root block. */-function tokens(): Map<string, string> {+/**+ * Every `--name: value;` in the :root blocks of ONE theme.+ *+ * Since 2026-09-12 the palette is a light :root plus a `:root[data-theme="dark"]`+ * block, not light-dark() pairs — so reading "all :root blocks" into one map,+ * as this used to, let the dark block overwrite the light values and handed+ * every "light:" check below a dark number. Comments are stripped first: the+ * selector capture sweeps up the comment above a block, and one that mentions+ * `data-theme="dark"` would otherwise make the light block look dark.+ */+function tokens(theme: 'light' | 'dark' = 'light'): Map<string, string> {const out = new Map<string, string>()- for (const block of code.matchAll(/(^|\})\s*([^{}]*:root[^{}]*)\{([\s\S]*?)\n\}/gm)) {+ const clean = code.replace(/\/\*[\s\S]*?\*\//g, '')+ for (const block of clean.matchAll(/(^|\})\s*([^{}]*:root[^{}]*)\{([\s\S]*?)\n\}/gm)) {+ const isDark = /\[data-theme\s*=\s*["']?dark/.test(block[2])+ if (isDark !== (theme === 'dark')) continuefor (const m of block[3].matchAll(/(--[a-z0-9-]+)\s*:\s*([^;]+);/g)) out.set(m[1], m[2].trim())}return out}-/** Both halves of a `light-dark(a, b)` token, as hex. */+/** Both halves of a themed token — light from bare :root, dark from the dark block. */function pair(name: string): [string, string] {- const v = tokens().get(name)- if (!v) throw new Error(`${name} is not declared`)- const m = /^light-dark\(\s*([^,]+),\s*([^)]+)\)/.exec(v)- return m ? [m[1].trim(), m[2].trim()] : [v.trim(), v.trim()]+ const l = tokens('light').get(name)+ if (!l) throw new Error(`${name} is not declared`)+ const d = tokens('dark').get(name) ?? l+ return [l.trim(), d.trim()]}function luminance(hex: string): number {@@ -129,9 +141,9 @@ console.log('\nthe dataset lies on a ground that is not its own paper')ok(scroll && /background:\s*var\(--desk\)/.test(scroll),'the scroller — everything around and below the sheet — is painted with --desk')- const t = tokens()+ const t = tokens('light')ok(t.has('--desk'), '--desk is declared in the palette, with both of its halves')- ok(/^light-dark\(/.test(t.get('--desk') ?? ''),+ ok(tokens('dark').has('--desk'),'and it varies by theme, so the desk is not a light-mode-only idea')// The measurement is the check. "A different token" is satisfied by a tokendiff --git a/scripts/test-dash-surfaces.ts b/scripts/test-dash-surfaces.tsindex 37bf00ea..d5b41a10 100644--- a/scripts/test-dash-surfaces.ts+++ b/scripts/test-dash-surfaces.ts@@ -344,22 +344,38 @@ closeAll()closeAll()}-// ============================================================ the theme is transient+// ============================================================ the theme stays out of the file//-// A `data-theme` attribute on <html> would be cloned into every saved file by-// capturePristine() and force one reader's choice on everyone who opens it.-// The override is a <style> carrying `data-bento-transient`, which the kernel-// strips from every serialized shell.+// A `data-theme` attribute on <html> is cloned into every saved file by+// capturePristine() and would force one reader's choice on everyone who opens+// it — dash MEASURED that once (`bento.serialize()` came back with+// `<html data-theme="light">`), which is why it used to theme through a+// transient <style> instead. It now uses kernel/src/theme.ts like the other+// three apps, and the guarantee comes from ORDER: main.ts must call+// startTheme() AFTER capturePristine(). That order is the whole invariant, so+// it is asserted on the source, where reordering two lines would silently+// reintroduce the leak. The outcome itself — a dark-themed session serializing+// a shell with no data-theme in it — is layout-free and is checked in the+// built shell in a browser, because this DOM stub cannot clone or serialize.{- settings.setThemePref('dark')- const style = doc.getElementById('dx-theme')- ok(style !== null && style.hasAttribute('data-bento-transient'),- 'the theme override is a transient <style> — an untagged one is saved into the file and changes everybody’s screen')- ok(doc.documentElement.getAttribute('data-theme') === null,- 'and nothing is written onto <html>, which is the shape that caused that')- settings.setThemePref('auto')- ok(doc.getElementById('dx-theme') === null,- 'and "Match my system" REMOVES it — the absence of an override is what following the OS means')+ const main = src('main.ts')+ const cap = main.indexOf('capturePristine()')+ const start = main.indexOf('startTheme()')+ ok(cap > 0 && start > 0, 'main.ts calls both capturePristine() and startTheme()')+ ok(cap < start,+ 'and capturePristine() comes FIRST — the pristine copy every save re-serializes must never carry data-theme')+ ok(!/applyTheme\(|setThemePref\(|dx-theme/.test(src('settings.ts')),+ 'the private theme store is gone from settings.ts — one mechanism, kernel/src/theme.ts, across four apps')+ // and the shared mechanism actually reaches the root element+ const kernel = await import('../kernel/src/theme.ts')+ // `dataset.theme`, not getAttribute: that is what theme.ts writes, and this+ // stub's dataset is one-way (setAttribute fills it; assignment does not+ // reflect back). A real DOM reflects both ways, which the browser check sees.+ kernel.setTheme('dark')+ ok(doc.documentElement.dataset.theme === 'dark',+ 'setTheme writes data-theme onto <html> — the attribute the stylesheet keys off')+ kernel.setTheme('light')+ ok(doc.documentElement.dataset.theme === 'light', 'and back')}// ============================================================ the sizediff --git a/scripts/test-dash-theme.ts b/scripts/test-dash-theme.tsindex b6dd3150..df0f2de0 100644--- a/scripts/test-dash-theme.ts+++ b/scripts/test-dash-theme.ts@@ -137,11 +137,19 @@ console.log('every var() a dash stylesheet reads is declared by one of them')*/function rootVars(text: string): Map<string, string> {const out = new Map<string, string>()+ // COMMENTS COME OUT FIRST, before any block is matched. The selector capture+ // below runs from the previous `}` to the next `{`, which sweeps up any+ // comment sitting above the block — and a comment that so much as MENTIONS+ // `[data-theme="dark"]` then makes the light block look like the dark one and+ // vanish. That happened: the header note above styles.css's :root gained the+ // phrase while explaining the switch, and this rig reported eight "dash+ // declares --ink" failures against a palette that was fully present.+ const clean = text.replace(/\/\*[\s\S]*?\*\//g, '')// every light :root block in the file, not just the first — find.css adds two.- for (const block of text.matchAll(/(^|\})\s*([^{}]*:root[^{}]*)\{([\s\S]*?)\n\}/gm)) {+ for (const block of clean.matchAll(/(^|\})\s*([^{}]*:root[^{}]*)\{([\s\S]*?)\n\}/gm)) {const selector = block[2]if (/\[data-theme\s*=\s*["']?dark/.test(selector)) continue- const body = block[3].replace(/\/\*[\s\S]*?\*\//g, '')+ const body = block[3]for (const m of body.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;]+);/g)) out.set(m[1], m[2].trim())}return out@@ -167,6 +175,10 @@ const SHARED: Record<string, string> = {'--accent-ink': '--accent-ink','--panel': '--chrome','--hover': '--chrome-2',+ // Since 2026-09-12. It was in DIVERGENCES below as dash's deliberate 7px+ // control radius; it is a shared token now because kernel's stylesheet is+ // about to own it with ONE value across four apps. See DECISIONS.md.+ '--radius': '--radius',}/**@@ -175,9 +187,6 @@ const SHARED: Record<string, string> = {* point of the list is the reason and not the exemption.*/const DIVERGENCES: Record<string, string> = {- '--radius': 'slides has one radius (10px, its floating surfaces); dash splits the '- + 'scale into --radius / --radius-lg / --radius-xl, and --radius is the CONTROL '- + 'radius. Same numbers, different partition of them.','--blue': 'dash declares it as an alias of --sel-ring (#2563eb, 5.17:1 on white) '+ 'rather than slides\' #5b8def (3.23:1). Same job — focus and selection — and '+ 'dash\'s value clears 4.5:1 where slides\' only clears 3:1.',@@ -196,8 +205,18 @@ console.log('\nthe light palette is bento/slides\' palette')ok(lightValue(a) === lightValue(b),`${ours} is slides' ${theirs} — ${lightValue(a)} vs ${lightValue(b)}`)}+ // AN ALLOWANCE HAS TO EARN ITS PLACE. This loop used to check only that the+ // reason was long enough, so an entry for a token that had quietly come back+ // into line stayed forever — the same rot as a NOT_RUN list of rigs that are+ // in fact run, which cost #323 a day. --radius was exactly that after it took+ // the shared value. Now: a listed token must (a) still exist on both sides+ // and (b) still DIFFER, or the entry is a lie and the rig says so.for (const [name, why] of Object.entries(DIVERGENCES)) {ok(why.length > 40, `${name} diverges from slides for a written-down reason`)+ const a = dash.get(name), b = slides.get(name)+ if (a === undefined || b === undefined) continue // an alias with no slides twin; the alias loop below covers it+ ok(lightValue(a) !== lightValue(b),+ `${name} actually still diverges (${lightValue(a)} vs ${lightValue(b)}) — if it has come back into line, delete its DIVERGENCES entry rather than keep an exemption nothing needs`)}// the aliases have to actually point at something, or a rule ported from// slides resolves to nothing and silently does nothing (failure 1 again)@@ -303,25 +322,57 @@ console.log('\nfocus is indicated with one colour, and it is not the amber')'and every one of them is a file already on the known list')}-// ============================================================ 5 · light-dark() is a colour+// ============================================================ 5 · the dark block-console.log('\nlight-dark() is only asked for colours')+/** Every `[data-theme="dark"]` block, name → raw value. The mirror of rootVars. */+function darkVars(text: string): Map<string, string> {+ const out = new Map<string, string>()+ const clean = text.replace(/\/\*[\s\S]*?\*\//g, '') // same reason as rootVars+ for (const block of clean.matchAll(/(^|\})\s*([^{}]*:root[^{}]*)\{([\s\S]*?)\n\}/gm)) {+ if (!/\[data-theme\s*=\s*["']?dark/.test(block[2])) continue+ const body = block[3]+ for (const m of body.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;]+);/g)) out.set(m[1], m[2].trim())+ }+ return out+}++console.log('\nthe dark palette is a block keyed off data-theme, and it mirrors the light one'){- const vars = rootVars(allCss)- for (const [name, value] of vars) {- if (!value.startsWith('light-dark(')) continue- const [light] = pair(vars, name)- const looksLikeColour = /^(#|rgba?\(|hsla?\(|color-mix\(|var\(|oklch\(|transparent$|currentcolor$)/.test(light)- ok(looksLikeColour,- `${name} varies by theme and must therefore be a <color> — light-dark() cannot `- + `carry "${light}". It is a legal thing to WRITE in a custom property and an `- + `invalid thing to substitute anywhere, so the property silently takes its `- + `initial value. This is how every shadow in dash was "none". Vary the colour `- + `and keep the rest outside, as --shadow-pop does.`)+ // Dash themed through light-dark() pairs until 2026-09-12. The switch to a+ // [data-theme="dark"] block was a TRANSFORM of 37 tokens across four files, plus one inline shadow,+ // and a transform is exactly where one gets dropped: a token missing from the+ // dark block does not error, it just stays light on a dark ground, and on a+ // token like --line that reads as "the dark theme looks a bit off" for a+ // long time. So the tokens that would be worst to lose are named.+ const light = rootVars(allCss)+ const dark = darkVars(allCss)+ ok(dark.size >= 35, `the dark block carries the palette, not a fragment of it (${dark.size} tokens)`)+ for (const name of ['--bg', '--panel', '--surface', '--hover', '--line', '--line-strong',+ '--ink', '--ink-2', '--muted', '--sel', '--sel-ring', '--accent-ink', '--bar-opacity',+ '--find-hit', '--find-cur', '--cmt', '--cmt-wash']) {+ ok(dark.has(name), `${name} has a dark value — a themed token that fell out of the transform stays light on a dark ground`)}- // the one token that DOES vary and is not a colour has to do it the long way- ok(/@media\s*\(prefers-color-scheme:\s*dark\)[^}]*--bar-opacity/s.test(css['styles.css']),- '--bar-opacity, a number, varies through a media query and not through light-dark()')+ // The reverse: a token that exists ONLY in the dark block has no light value+ // to fall back to, so in the light theme the property is simply unset. Every+ // dark token must have a light twin on bare :root.+ const orphans = [...dark.keys()].filter((n) => !light.has(n))+ ok(orphans.length === 0, `every dark token has a light twin on :root${orphans.length ? ` — orphans: ${orphans.join(', ')}` : ''}`)+ // And a dark twin that is byte-identical to its light value is a token that+ // did not need theming — or a paste error. --accent is deliberately NOT in+ // the dark block for exactly this reason.+ const same = [...dark].filter(([n, v]) => light.get(n) === v).map(([n]) => n)+ ok(same.length === 0, `no dark value merely repeats its light value${same.length ? ` — ${same.join(', ')}` : ''}`)++ // The mechanism is the ATTRIBUTE, and only the attribute. A light-dark()+ // declaration would resolve off color-scheme instead and split the palette+ // across two switches; a prefers-color-scheme block would be a second opinion+ // about the OS that theme.ts already resolves. Comments may mention both.+ const decls = allCss.replace(/\/\*[\s\S]*?\*\//g, '')+ ok(!/light-dark\(/.test(decls), 'no declaration uses light-dark() — the palette keys off data-theme alone')+ ok(!/@media[^{]*prefers-color-scheme[^{]*\{[^}]*--/.test(decls),+ 'no custom property is set inside a prefers-color-scheme query — resolving the OS is theme.ts\'s job, and two resolvers disagree')+ ok(/^\s*color-scheme:\s*light dark;/m.test(css['styles.css']),+ 'bare :root still declares `color-scheme: light dark` — for the splash and the browser furniture in the window before theme.ts runs')}// ============================================================ 6 · no colour hides in a query