A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Pick the more readable ink for text on the accent
Fei24112fee2ede4c85
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 31543929..9a9558d8 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -1321,6 +1321,8 @@ var THEMES = {dark: { bg: "#0b1020", sidebar: "#10172a", bubble: "#1a2340", card: "#141c33", text: "#e8edf7", user: "#3b6fd8", userText: "#ffffff", accent: "#4f9dff" }}};+var DARK_INK = "#141414";+var accentInk = (accent) => (luminance(accent) + 0.05) ** 2 > 1.05 * (luminance(DARK_INK) + 0.05) ? DARK_INK : "#ffffff";var rgba = (hex, alpha) => `rgba(${[1, 3, 5].map((index) => parseInt(hex.slice(index, index + 2), 16)).join(",")},${alpha})`;function themeVars(mode, dark, accent = mode.accent) {return {@@ -1336,7 +1338,7 @@ function themeVars(mode, dark, accent = mode.accent) {"--bt-hover": dark ? "rgba(160,160,160,.12)" : "rgba(119,119,119,.09)","--bt-active": dark ? "rgba(160,160,160,.2)" : "rgba(119,119,119,.17)","--bt-accent": accent,- "--bt-accent-ink": luminance(accent) > 0.45 ? "#141414" : "#ffffff",+ "--bt-accent-ink": accentInk(accent),"--bt-user": mode.user,"--bt-user-ink": mode.userText,"--bt-tag-bg": rgba(mode.text, dark ? 0.09 : 0.06),diff --git a/ds-bot/src/client/themes.js b/ds-bot/src/client/themes.jsindex 077c24d3..5b33e959 100644--- a/ds-bot/src/client/themes.js+++ b/ds-bot/src/client/themes.js@@ -29,6 +29,10 @@ const THEMES = {dark: { bg: '#0b1020', sidebar: '#10172a', bubble: '#1a2340', card: '#141c33', text: '#e8edf7', user: '#3b6fd8', userText: '#ffffff', accent: '#4f9dff' },},}+// Text on the accent: near-black or white, whichever has the higher WCAG contrast.+// (L + .05)² > 1.05 × (L(#141414) + .05) is "dark ink reads better".+const DARK_INK = '#141414'+const accentInk = accent => ((luminance(accent) + 0.05) ** 2 > 1.05 * (luminance(DARK_INK) + 0.05) ? DARK_INK : '#ffffff')const rgba = (hex, alpha) => `rgba(${[1, 3, 5].map(index => parseInt(hex.slice(index, index + 2), 16)).join(',')},${alpha})`function themeVars(mode, dark, accent = mode.accent) {return {@@ -37,7 +41,7 @@ function themeVars(mode, dark, accent = mode.accent) {'--bt-line': rgba(mode.text, 0.08), '--bt-line-2': rgba(mode.text, 0.15),'--bt-hover': dark ? 'rgba(160,160,160,.12)' : 'rgba(119,119,119,.09)','--bt-active': dark ? 'rgba(160,160,160,.2)' : 'rgba(119,119,119,.17)',- '--bt-accent': accent, '--bt-accent-ink': luminance(accent) > 0.45 ? '#141414' : '#ffffff',+ '--bt-accent': accent, '--bt-accent-ink': accentInk(accent),'--bt-user': mode.user, '--bt-user-ink': mode.userText,'--bt-tag-bg': rgba(mode.text, dark ? 0.09 : 0.06), '--bt-tag-ink': rgba(mode.text, 0.58),}diff --git a/ds-bot/test/user-bubble.test.js b/ds-bot/test/user-bubble.test.jsindex 5eae8d58..13a8f6c1 100644--- a/ds-bot/test/user-bubble.test.js+++ b/ds-bot/test/user-bubble.test.js@@ -1,7 +1,7 @@import assert from 'node:assert/strict'import { readFileSync } from 'node:fs'import { test } from 'node:test'-import { luminance } from '../src/client/inks.js'+import { ACCENT_INKS, INKS, luminance } from '../src/client/inks.js'import { allThemes, shellTokens, themeCss } from '../src/client/themes.js'// The browser bundle holds every style sheet ds-bot installs; the bundle test@@ -80,6 +80,28 @@ 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.+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])+ }+ for (const ink of ACCENT_INKS) {+ 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 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 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' }