Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Give preset accents their dark value in dark mode

Fei2411a5a710ae813c
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 7913e16b..137da9c0 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -1357,8 +1357,12 @@ function themeVars(mode, dark, accent = mode.accent) {
};
}
var declarations = (vars) => Object.entries(vars).map(([name, value]) => `${name}:${value}`).join(";");
+var darkAccent = (accent) => {
+ const ink = ACCENT_INKS.find((id) => INKS[id][0] === accent);
+ return ink === void 0 ? accent : INKS[ink][1];
+};
var themeCss = (theme, accent) => `html body{${declarations(themeVars(theme.light, false, accent ?? theme.light.accent))}}
-html body[data-ds-dark-theme]{${declarations(themeVars(theme.dark, true, accent ?? theme.dark.accent))}}
+html body[data-ds-dark-theme]{${declarations(themeVars(theme.dark, true, darkAccent(accent) ?? theme.dark.accent))}}
${theme.css ?? ""}`;
var shellTokens = ({ light, dark }) => ({
"--dsw-alias-bg-base": { light: light.bg, dark: dark.bg },
diff --git a/ds-bot/src/client/themes.js b/ds-bot/src/client/themes.js
index 5b33e959..f4153e82 100644
--- a/ds-bot/src/client/themes.js
+++ b/ds-bot/src/client/themes.js
@@ -1,4 +1,4 @@
-import { isHex, luminance } from './inks.js'
+import { ACCENT_INKS, INKS, isHex, luminance } from './inks.js'
import { SHAPES, markupCache, maskCache } from './characters.js'
import { createSource } from './sources.js'
@@ -47,9 +47,16 @@ function themeVars(mode, dark, accent = mode.accent) {
}
}
const declarations = vars => Object.entries(vars).map(([name, value]) => `${name}:${value}`).join(';')
+// A preset accent is saved as its light value; in dark mode it takes the preset's dark
+// value, as Bot names do, so Charcoal does not vanish on a dark background. A custom
+// accent is the same in both modes. A preset is matched the way Settings marks it.
+const darkAccent = (accent) => {
+ const ink = ACCENT_INKS.find(id => INKS[id][0] === accent)
+ return ink === undefined ? accent : INKS[ink][1]
+}
// `html body` outranks the base sheet's `body` rules without !important.
export const themeCss = (theme, accent) => `html body{${declarations(themeVars(theme.light, false, accent ?? theme.light.accent))}}
-html body[data-ds-dark-theme]{${declarations(themeVars(theme.dark, true, accent ?? theme.dark.accent))}}
+html body[data-ds-dark-theme]{${declarations(themeVars(theme.dark, true, darkAccent(accent) ?? theme.dark.accent))}}
${theme.css ?? ''}`
export const shellTokens = ({ light, dark }) => ({
'--dsw-alias-bg-base': { light: light.bg, dark: dark.bg },
diff --git a/ds-bot/test/user-bubble.test.js b/ds-bot/test/user-bubble.test.js
index 13a8f6c1..20be9f85 100644
--- a/ds-bot/test/user-bubble.test.js
+++ b/ds-bot/test/user-bubble.test.js
@@ -82,11 +82,13 @@ test('the user ink reads on the user surface in every built-in theme and mode',
// Text on the accent (send key, new-message pill, primary buttons) takes whichever
// of the two inks reads better: white on Tangerine was 2.89:1, near-black is 6.38:1.
+// The variables themeCss sets for one mode.
+const varsOf = (theme, accent, dark) => {
+ const block = themeCss(theme, accent).split('\n').find(line => line.startsWith(dark ? 'html body[data-ds-dark-theme]{' : 'html body{'))
+ return Object.fromEntries(block.slice(block.indexOf('{') + 1, -1).split(';').map(item => item.split(':')))
+}
+
test('the accent ink is the more readable of the two inks for every accent', () => {
- const inkOf = (theme, accent, dark) => {
- const block = themeCss(theme, accent).split('\n').find(line => line.startsWith(dark ? 'html body[data-ds-dark-theme]{' : 'html body{'))
- return Object.fromEntries(block.slice(block.indexOf('{') + 1, -1).split(';').map(item => item.split(':')))
- }
const cases = []
for (const id of ['deepseek', 'mono', 'paper', 'moonlight']) {
for (const dark of [false, true]) cases.push([`${id} ${dark ? 'dark' : 'light'}`, allThemes()[id], undefined, dark])
@@ -95,13 +97,32 @@ test('the accent ink is the more readable of the two inks for every accent', ()
for (const dark of [false, true]) cases.push([`${ink} ${dark ? 'dark' : 'light'}`, allThemes().deepseek, INKS[ink][0], dark])
}
for (const [name, theme, accent, dark] of cases) {
- const vars = inkOf(theme, accent, dark)
+ const vars = varsOf(theme, accent, dark)
const paper = vars['--bt-accent'], ink = vars['--bt-accent-ink']
const other = ink === '#ffffff' ? '#141414' : '#ffffff'
assert.ok(contrast(ink, paper) >= contrast(other, paper), `${name}: ${ink} on ${paper} is ${contrast(ink, paper).toFixed(2)}:1, ${other} would be ${contrast(other, paper).toFixed(2)}:1`)
}
})
+// A preset accent is saved as its light value. Dark mode used it too, so Charcoal
+// (#141416) was 1.00:1 on the dark background, Graphite 1.34:1 and Cobalt 2.48:1.
+test('a preset accent takes its dark value in dark mode; a custom accent stays the same', () => {
+ for (const [id, theme] of Object.entries(allThemes())) {
+ for (const ink of ACCENT_INKS) {
+ const [light, dark] = INKS[ink]
+ assert.equal(varsOf(theme, light, false)['--bt-accent'], light)
+ assert.equal(varsOf(theme, light, true)['--bt-accent'], dark, `${id} ${ink}`)
+ const ratio = contrast(dark, theme.dark.bg)
+ assert.ok(ratio >= 3, `${id} ${ink}: ${dark} on ${theme.dark.bg} is ${ratio.toFixed(2)}:1`)
+ }
+ // A color picked by hand is not a preset, even when it spells one in lower case.
+ for (const custom of ['#123456', INKS.deepseek[0].toLowerCase()]) {
+ assert.equal(varsOf(theme, custom, true)['--bt-accent'], custom)
+ }
+ assert.equal(varsOf(theme, undefined, true)['--bt-accent'], theme.dark.accent)
+ }
+})
+
// A dark skin repaints the host bubble surface (dsh-dream-skin's underwater theme
// sets this value) and leaves ds-bot's colors alone.
const DARK_SKIN = { '--dsw-specific-bubble': 'rgba(31,33,38,.92)', '--dsw-alias-label-primary': '#ffffff' }