Skip to content

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

Paint the user bubble's surface and text from one theme pair

Fei24115948e69fa284
diff --git a/CHANGELOG.md b/CHANGELOG.md
index be0739b5..d4924e37 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@ All notable changes to DS Bot are listed here. The format follows [Keep a Change
## [Unreleased]
+### Fixed
+
+- Your own messages in a Bot chat stay readable under dark skins that recolor message bubbles.
+
## [0.1.4] - 2026-10-13
### Added
diff --git a/ds-bot/client.js b/ds-bot/client.js
index ea2b7877..db654611 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -1322,9 +1322,6 @@ var shellTokens = ({ light, dark }) => ({
"--dsw-alias-label-secondary": { light: rgba(light.text, 0.74), dark: rgba(dark.text, 0.74) },
"--dsw-alias-label-tertiary": { light: rgba(light.text, 0.6), dark: rgba(dark.text, 0.6) }
});
-var conversationTokens = ({ light, dark }) => ({
- "--dsw-specific-bubble": { light: light.user, dark: dark.user }
-});
var customThemes = {};
var registry = createSource(0);
var isPoint = (point) => Array.isArray(point) && point.length === 2 && point.every(Number.isFinite);
@@ -2693,9 +2690,10 @@ body[data-bt-room] [data-composer-card]:has(button[class*="_primary"]:disabled)
[data-chain-overlay-fallback="conversation.composer"]:has(~ .bt-q){display:block!important;order:2}
.bt-q{order:1}
div:has(> nav [class*="_marks"]){display:none!important}
-/* The theme paints --dsw-specific-bubble in the user color, and that token backs every
- user-side bubble: sent, steering mid-turn, not yet admitted, question replies. */
-[class*="_userRow"] [class*="_bubble"],[data-chat-flow-kind=question-reply] [class*="_bubble"],[data-chat-flow-kind=command-input] [class*="_bubble"]{color:var(--bt-user-ink)!important;border-radius:18px!important;padding:7px 12px!important;font-size:var(--dsh-content-font-size,14px)!important;line-height:calc(var(--dsh-content-font-size,14px) + 8px)!important}
+/* Every user-side bubble (sent, steering mid-turn, not yet admitted, question replies)
+ takes its surface and its text from the one --bt-user pair: a skin that repaints
+ the host's bubble surface alone would otherwise leave the text unreadable. */
+[class*="_userRow"] [class*="_bubble"],[data-chat-flow-kind=question-reply] [class*="_bubble"],[data-chat-flow-kind=command-input] [class*="_bubble"]{background:var(--bt-user)!important;color:var(--bt-user-ink)!important;border-radius:18px!important;padding:7px 12px!important;font-size:var(--dsh-content-font-size,14px)!important;line-height:calc(var(--dsh-content-font-size,14px) + 8px)!important}
[class*="_userRow"] [class*="_bubble"] [class*="_markdown"],[class*="_userRow"] [class*="_bubble"] a{color:inherit}
/* Sent messages get the hover toolbar below; steering and unsent bubbles keep none. */
[class*="_userRow"] [class*="_actions"]{display:none!important}
@@ -12906,7 +12904,7 @@ function UserMessageCell({ node, sessionId, useRoster, actions, renderMessageIma
var USER_MESSAGE_CSS = `
.bt-umsg{display:flex;flex-direction:row-reverse;align-items:center;justify-content:flex-start;gap:4px}
.bt-ustack{min-width:0;max-width:min(calc(var(--dsh-chat-content-width,748px) * .702),82%);display:flex;flex-direction:column;align-items:flex-end;gap:8px}
-.bt-ubody{max-width:100%;box-sizing:border-box;background:var(--dsw-specific-bubble,var(--bt-user));color:var(--bt-user-ink);border-radius:18px;padding:7px 12px;font-size:var(--dsh-content-font-size,14px);line-height:calc(var(--dsh-content-font-size,14px) + 8px);white-space:pre-wrap;word-break:break-word}
+.bt-ubody{max-width:100%;box-sizing:border-box;background:var(--bt-user);color:var(--bt-user-ink);border-radius:18px;padding:7px 12px;font-size:var(--dsh-content-font-size,14px);line-height:calc(var(--dsh-content-font-size,14px) + 8px);white-space:pre-wrap;word-break:break-word}
.bt-ubody a{color:inherit}
.bt-umention{display:inline-flex;align-items:center;gap:3px;vertical-align:-3px;max-width:100%;padding:0 1px;border:0;background:none;color:inherit;font:inherit;font-weight:600;line-height:inherit;cursor:pointer;border-radius:6px;white-space:nowrap}
.bt-umention:hover{text-decoration:underline;text-underline-offset:2px}
@@ -13251,30 +13249,6 @@ function apply(ctx) {
style.remove();
};
};
- const installBubbleTokens = () => {
- let release = null;
- let key = "";
- const render = () => {
- const snapshot = roster.getSnapshot();
- const prefs = snapshot.ready ? snapshot.prefs ?? {} : savedPrefs;
- const themes = allThemes();
- const id = themes[prefs.theme] ? prefs.theme : "deepseek";
- const next = `${id}|${registry.getSnapshot()}`;
- if (next === key) return;
- key = next;
- const drop = release;
- release = ctx.theme.overrideTokens("ds-bot: conversation", conversationTokens(themes[id]));
- if (typeof drop === "function") drop();
- };
- render();
- const offRoster = roster.subscribe(render);
- const offRegistry = registry.subscribe(render);
- return () => {
- offRoster();
- offRegistry();
- if (typeof release === "function") release();
- };
- };
ctx.effect(() => {
const hub = { registerShape, registerTheme, themes: () => Object.keys(allThemes()), shapes: () => Object.keys(SHAPES) };
const queued = Array.isArray(window.dshBotQueue) ? window.dshBotQueue : [];
@@ -13766,7 +13740,6 @@ function apply(ctx) {
];
const installConversation = () => [
installCompiledStyles(CONVERSATION_CSS, "conversation"),
- installBubbleTokens(),
installMentions(),
installAtMenu(),
// Bot conversations are always flat, so the work-details mode is not a choice:
diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.js
index e14e7191..f6468dfa 100644
--- a/ds-bot/src/client/index.js
+++ b/ds-bot/src/client/index.js
@@ -2,7 +2,7 @@ import { call } from './api.js'
import { isHex, inkText, paintCss } from './inks.js'
import { DEFAULT_MASK, SHAPES, markupCache, maskOf } from './characters.js'
import { createSource, EMPTY_ROSTER, indexRoster, isAgentSession } from './sources.js'
-import { themeCss, shellTokens, conversationTokens, registry, registerShape, registerTheme, allThemes } from './themes.js'
+import { themeCss, shellTokens, registry, registerShape, registerTheme, allThemes } from './themes.js'
import { MENTION_ORIGIN, currentPart } from './text.js'
import { SHELL_CSS, CONVERSATION_CSS, installStyles, installCompiledStyles } from './styles.js'
import { lookOf } from './mark.js'
@@ -305,29 +305,6 @@ export function apply(ctx) {
}
}
- // The user-bubble token rides with the conversation group, so a plain Session
- // keeps dsh's own bubble colors while the Bot shell stays themed.
- const installBubbleTokens = () => {
- let release = null
- let key = ''
- const render = () => {
- const snapshot = roster.getSnapshot()
- const prefs = snapshot.ready ? snapshot.prefs ?? {} : savedPrefs
- const themes = allThemes()
- const id = themes[prefs.theme] ? prefs.theme : 'deepseek'
- const next = `${id}|${registry.getSnapshot()}`
- if (next === key) return
- key = next
- const drop = release
- release = ctx.theme.overrideTokens('ds-bot: conversation', conversationTokens(themes[id]))
- if (typeof drop === 'function') drop()
- }
- render()
- const offRoster = roster.subscribe(render)
- const offRegistry = registry.subscribe(render)
- return () => { offRoster(); offRegistry(); if (typeof release === 'function') release() }
- }
-
ctx.effect(() => {
const hub = { registerShape, registerTheme, themes: () => Object.keys(allThemes()), shapes: () => Object.keys(SHAPES) }
const queued = Array.isArray(window.dshBotQueue) ? window.dshBotQueue : []
@@ -789,7 +766,6 @@ export function apply(ctx) {
]
const installConversation = () => [
installCompiledStyles(CONVERSATION_CSS, 'conversation'),
- installBubbleTokens(),
installMentions(),
installAtMenu(),
// Bot conversations are always flat, so the work-details mode is not a choice:
diff --git a/ds-bot/src/client/styles.js b/ds-bot/src/client/styles.js
index 5b87ae7f..247b53d8 100644
--- a/ds-bot/src/client/styles.js
+++ b/ds-bot/src/client/styles.js
@@ -904,9 +904,10 @@ body[data-bt-room] [data-composer-card]:has(button[class*="_primary"]:disabled)
[data-chain-overlay-fallback="conversation.composer"]:has(~ .bt-q){display:block!important;order:2}
.bt-q{order:1}
div:has(> nav [class*="_marks"]){display:none!important}
-/* The theme paints --dsw-specific-bubble in the user color, and that token backs every
- user-side bubble: sent, steering mid-turn, not yet admitted, question replies. */
-[class*="_userRow"] [class*="_bubble"],[data-chat-flow-kind=question-reply] [class*="_bubble"],[data-chat-flow-kind=command-input] [class*="_bubble"]{color:var(--bt-user-ink)!important;border-radius:18px!important;padding:7px 12px!important;font-size:var(--dsh-content-font-size,14px)!important;line-height:calc(var(--dsh-content-font-size,14px) + 8px)!important}
+/* Every user-side bubble (sent, steering mid-turn, not yet admitted, question replies)
+ takes its surface and its text from the one --bt-user pair: a skin that repaints
+ the host's bubble surface alone would otherwise leave the text unreadable. */
+[class*="_userRow"] [class*="_bubble"],[data-chat-flow-kind=question-reply] [class*="_bubble"],[data-chat-flow-kind=command-input] [class*="_bubble"]{background:var(--bt-user)!important;color:var(--bt-user-ink)!important;border-radius:18px!important;padding:7px 12px!important;font-size:var(--dsh-content-font-size,14px)!important;line-height:calc(var(--dsh-content-font-size,14px) + 8px)!important}
[class*="_userRow"] [class*="_bubble"] [class*="_markdown"],[class*="_userRow"] [class*="_bubble"] a{color:inherit}
/* Sent messages get the hover toolbar below; steering and unsent bubbles keep none. */
[class*="_userRow"] [class*="_actions"]{display:none!important}
diff --git a/ds-bot/src/client/themes.js b/ds-bot/src/client/themes.js
index 59168e38..077c24d3 100644
--- a/ds-bot/src/client/themes.js
+++ b/ds-bot/src/client/themes.js
@@ -55,11 +55,6 @@ export const shellTokens = ({ light, dark }) => ({
'--dsw-alias-label-secondary': { light: rgba(light.text, 0.74), dark: rgba(dark.text, 0.74) },
'--dsw-alias-label-tertiary': { light: rgba(light.text, 0.6), dark: rgba(dark.text, 0.6) },
})
-// The user bubble belongs to the conversation group: on a plain Session the shell
-// stays mounted but dsh's own colors paint the bubbles.
-export const conversationTokens = ({ light, dark }) => ({
- '--dsw-specific-bubble': { light: light.user, dark: dark.user },
-})
// Other plugins add character shapes and themes through `window.dshBot`, or queue
// calls on `window.dshBotQueue` before this plugin loads. A shape draws only its
diff --git a/ds-bot/src/client/user-message.js b/ds-bot/src/client/user-message.js
index 8ccc06e2..54aa8ac5 100644
--- a/ds-bot/src/client/user-message.js
+++ b/ds-bot/src/client/user-message.js
@@ -100,7 +100,7 @@ export function UserMessageCell({ node, sessionId, useRoster, actions, renderMes
export const USER_MESSAGE_CSS = `
.bt-umsg{display:flex;flex-direction:row-reverse;align-items:center;justify-content:flex-start;gap:4px}
.bt-ustack{min-width:0;max-width:min(calc(var(--dsh-chat-content-width,748px) * .702),82%);display:flex;flex-direction:column;align-items:flex-end;gap:8px}
-.bt-ubody{max-width:100%;box-sizing:border-box;background:var(--dsw-specific-bubble,var(--bt-user));color:var(--bt-user-ink);border-radius:18px;padding:7px 12px;font-size:var(--dsh-content-font-size,14px);line-height:calc(var(--dsh-content-font-size,14px) + 8px);white-space:pre-wrap;word-break:break-word}
+.bt-ubody{max-width:100%;box-sizing:border-box;background:var(--bt-user);color:var(--bt-user-ink);border-radius:18px;padding:7px 12px;font-size:var(--dsh-content-font-size,14px);line-height:calc(var(--dsh-content-font-size,14px) + 8px);white-space:pre-wrap;word-break:break-word}
.bt-ubody a{color:inherit}
.bt-umention{display:inline-flex;align-items:center;gap:3px;vertical-align:-3px;max-width:100%;padding:0 1px;border:0;background:none;color:inherit;font:inherit;font-weight:600;line-height:inherit;cursor:pointer;border-radius:6px;white-space:nowrap}
.bt-umention:hover{text-decoration:underline;text-underline-offset:2px}
diff --git a/ds-bot/test/user-bubble.test.js b/ds-bot/test/user-bubble.test.js
new file mode 100644
index 00000000..5eae8d58
--- /dev/null
+++ b/ds-bot/test/user-bubble.test.js
@@ -0,0 +1,112 @@
+import assert from 'node:assert/strict'
+import { readFileSync } from 'node:fs'
+import { test } from 'node:test'
+import { 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
+// keeps it in step with src/client.
+const bundle = readFileSync(new URL('../client.js', import.meta.url), 'utf8')
+
+// CSS declaration blocks hold no braces, so a declaration's rule runs from the
+// nearest `{` before it to the nearest `}` after it.
+function rulesWith(pattern) {
+ const rules = []
+ for (const match of bundle.matchAll(pattern)) {
+ const open = bundle.lastIndexOf('{', match.index)
+ const close = bundle.indexOf('}', match.index)
+ const start = Math.max(bundle.lastIndexOf('}', open), bundle.lastIndexOf('\n', open), bundle.lastIndexOf('`', open)) + 1
+ rules.push({ selector: bundle.slice(start, open).trim(), body: bundle.slice(open + 1, close) })
+ }
+ return rules
+}
+const declared = (body, property) => body.split(';').map(item => item.trim()).find(item => item.startsWith(`${property}:`))?.slice(property.length + 1)
+const surface = body => declared(body, 'background') ?? declared(body, 'background-color')
+const ruleFor = selector => {
+ const rule = rulesWith(/color:var\(--bt-user-ink\)/g).find(item => item.selector.startsWith(selector))
+ assert.ok(rule, `no rule for ${selector}`)
+ return rule
+}
+
+test('every rule that writes in the user ink paints the user surface under it', () => {
+ const rules = rulesWith(/(?<=[{;])color:var\(--bt-user-ink\)/g)
+ assert.ok(rules.length >= 3)
+ for (const { selector, body } of rules) {
+ assert.match(surface(body) ?? '', /^var\(--bt-user\)(!important)?$/, selector)
+ }
+})
+
+test('no ds-bot text color sits on a surface that a skin owns', () => {
+ for (const { selector, body } of rulesWith(/(?<=[{;])color:var\(--bt-/g)) {
+ assert.doesNotMatch(surface(body) ?? '', /--dsw-/, selector)
+ }
+})
+
+test('ds-bot leaves the host bubble variables to the host and its skins', () => {
+ assert.doesNotMatch(bundle, /--dsw-specific-bubble/)
+ assert.doesNotMatch(bundle, /conversationTokens|installBubbleTokens/)
+ for (const [id, theme] of Object.entries(allThemes())) {
+ assert.deepEqual(Object.keys(shellTokens(theme)).filter(name => name.includes('bubble')), [], id)
+ }
+})
+
+const themeVars = (theme, dark) => {
+ const block = themeCss(theme).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 parse = color => {
+ if (/^#[0-9a-f]{6}$/i.test(color)) return { hex: color.toLowerCase(), alpha: 1 }
+ const parts = color.match(/^rgba?\(([^)]+)\)$/)[1].split(',').map(Number)
+ return { hex: `#${parts.slice(0, 3).map(part => part.toString(16).padStart(2, '0')).join('')}`, alpha: parts[3] ?? 1 }
+}
+const over = (top, under) => {
+ const { hex, alpha } = parse(top)
+ if (alpha === 1) return hex
+ const channel = (color, index) => parseInt(color.slice(index, index + 2), 16)
+ return `#${[1, 3, 5].map(index => Math.round(channel(hex, index) * alpha + channel(under, index) * (1 - alpha)).toString(16).padStart(2, '0')).join('')}`
+}
+const contrast = (ink, paper) => {
+ const [a, b] = [luminance(ink), luminance(paper)].sort((x, y) => y - x)
+ return (a + 0.05) / (b + 0.05)
+}
+
+test('the user ink reads on the user surface in every built-in theme and mode', () => {
+ for (const id of ['deepseek', 'mono', 'paper', 'moonlight']) {
+ for (const dark of [false, true]) {
+ const vars = themeVars(allThemes()[id], dark)
+ const ratio = contrast(over(vars['--bt-user-ink'], vars['--bt-user']), over(vars['--bt-user'], vars['--bt-main']))
+ assert.ok(ratio >= 4.5, `${id} ${dark ? 'dark' : 'light'}: ${ratio.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' }
+const resolve = (value, vars) => {
+ const plain = value.replace(/!important$/, '')
+ const match = plain.match(/^var\((--[\w-]+)(?:,(.+))?\)$/)
+ if (!match) return plain
+ if (vars[match[1]] !== undefined) return resolve(vars[match[1]], vars)
+ assert.ok(match[2] !== undefined, `${match[1]} is unset`)
+ return resolve(match[2], vars)
+}
+
+test('a user message stays readable when a dark skin repaints the host bubble', () => {
+ for (const id of ['deepseek', 'mono', 'paper', 'moonlight']) {
+ const vars = { ...themeVars(allThemes()[id], true), ...DARK_SKIN }
+ const page = vars['--bt-main']
+ for (const selector of ['.bt-ubody', '[class*="_userRow"] [class*="_bubble"]']) {
+ const { body } = ruleFor(selector)
+ const paper = over(resolve(surface(body), vars), page)
+ const ink = over(resolve(declared(body, 'color'), vars), paper)
+ assert.ok(contrast(ink, paper) >= 4.5, `${id} ${selector}: ${contrast(ink, paper).toFixed(2)}:1`)
+ }
+ }
+})
+
+test('the surface wins over the host bubble rule that reads the skin variable', () => {
+ const { body } = ruleFor('[class*="_userRow"] [class*="_bubble"]')
+ assert.equal(surface(body), 'var(--bt-user)!important')
+ assert.equal(declared(body, 'color'), 'var(--bt-user-ink)!important')
+})