Skip to content

WorkBuddy、CodeBuddy 桌面端增强助手:签到猫猫旅行成长计划查询、多账号独立备份、点切即用;免打扰模式让 AI 无人值守跑长任务;跨账号会话迁移、异常中断自动续接;暂存/快捷提示词;毛玻璃主题与更多实用功能。

fix: respect CodeBuddy light panel badge contrast in dark hosts

[email protected]6cd03eaad8bb
diff --git a/scripts/inject.js b/scripts/inject.js
index f21d6a7..cce60d2 100644
--- a/scripts/inject.js
+++ b/scripts/inject.js
@@ -17388,7 +17388,9 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
// Keep the theme hue, but lift dark fills above the empty gray vessel.
'@supports (color:oklch(from black l c h)){.wbs-daily-rings{--wbs-liquid-fill:oklch(from var(--wb-button-primary-bg) max(l,.62) c h / 1)}}',
'html:not(.cb-dark):not([data-theme="dark"]):is([data-wbs-theme-id="default"],:not([data-wbs-theme-id])) body:not([data-vscode-theme-name*="dark" i]) .wbs-daily-rings{--wbs-liquid-fill:var(--wbs-credit-theme-color,var(--wbs-primary))}',
- ':is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-daily-rings,:is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-checkin-tag.ok{--wbs-badge-bg:rgba(255,255,255,.085);--wbs-badge-fg:var(--wb-color-text-primary,#f6f5ff);background:var(--wbs-badge-bg);border:1px solid rgba(255,255,255,.12);color:var(--wbs-badge-fg);box-shadow:inset 0 1px 0 rgba(255,255,255,.08);backdrop-filter:blur(12px) saturate(1.08);-webkit-backdrop-filter:blur(12px) saturate(1.08)}:is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-daily-rings{--wbs-liquid-bg:rgba(255,255,255,.12);--wbs-liquid-ink:#f6f5ff}:is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-daily-rings:hover,:is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-daily-rings[aria-expanded="true"]{background:rgba(255,255,255,.14);box-shadow:inset 0 1px 0 rgba(255,255,255,.1),0 3px 10px rgba(0,0,0,.12)}',
+ // CodeBuddy's light panel must not inherit the host renderer's dark badge palette.
+ '.wbs-panel-light .wbs-daily-rings,[data-wbs-appearance="light"] .wbs-daily-rings{--wbs-liquid-fill:var(--wbs-credit-theme-color,var(--wbs-primary))}',
+ ':is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-daily-rings:not(:where([data-wbs-appearance="light"] *,.wbs-panel-light *)),:is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-checkin-tag.ok:not(:where([data-wbs-appearance="light"] *,.wbs-panel-light *)){--wbs-badge-bg:rgba(255,255,255,.085);--wbs-badge-fg:var(--wb-color-text-primary,#f6f5ff);background:var(--wbs-badge-bg);border:1px solid rgba(255,255,255,.12);color:var(--wbs-badge-fg);box-shadow:inset 0 1px 0 rgba(255,255,255,.08);backdrop-filter:blur(12px) saturate(1.08);-webkit-backdrop-filter:blur(12px) saturate(1.08)}:is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-daily-rings:not(:where([data-wbs-appearance="light"] *,.wbs-panel-light *)){--wbs-liquid-bg:rgba(255,255,255,.12);--wbs-liquid-ink:#f6f5ff}:is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-daily-rings:not(:where([data-wbs-appearance="light"] *,.wbs-panel-light *)):hover,:is(html.cb-dark,html[data-theme="dark"],html[data-wbs-theme-id="dark"],html[data-wbs-theme-id="cyber-purple"],html[data-wbs-theme-id="nebula"],body[data-vscode-theme-name*="dark" i]) .wbs-daily-rings:not(:where([data-wbs-appearance="light"] *,.wbs-panel-light *))[aria-expanded="true"]{background:rgba(255,255,255,.14);box-shadow:inset 0 1px 0 rgba(255,255,255,.1),0 3px 10px rgba(0,0,0,.12)}',
'.wbs-checkin-tag.fail{background:rgba(239,68,68,.1);color:#dc2626}',
'.wbs-model-rate-limit-slot{display:inline-flex;align-items:center;min-width:0}.wbs-model-rate-limit{appearance:none;-webkit-appearance:none;font:inherit;cursor:pointer;transition:background-color .15s,box-shadow .15s,color .15s}.wbs-model-rate-limit:hover,.wbs-model-rate-limit[aria-expanded="true"]{background:color-mix(in srgb,var(--wbs-badge-bg) 84%,white);box-shadow:0 2px 8px rgba(0,0,0,.14)}.wbs-model-rate-limit:focus-visible{outline:2px solid color-mix(in srgb,var(--wbs-badge-bg) 45%,transparent);outline-offset:2px}',
'.wbs-status-popover.is-rate-limit{width:500px;max-width:calc(100vw - 16px);overflow-x:auto}.wbs-status-popover.is-rate-limit-summary{width:360px;max-width:calc(100vw - 16px);overflow-x:auto}.wbs-model-rate-limit-detail{grid-template-columns:8px auto minmax(0,1fr) auto auto;gap:7px}.wbs-model-rate-limit-detail b{white-space:nowrap;overflow-wrap:normal}.wbs-model-rate-limit-detail .wbs-model-rate-limit-model{text-align:left}.wbs-model-rate-limit-detail i.rate-limit{color:var(--wb-color-text-primary,#1f1f1f)}.wbs-model-rate-limit-account-group{padding:7px 0 2px;border-top:1px solid var(--wb-border-subtle,rgba(20,24,32,.1))}.wbs-model-rate-limit-account-group:first-of-type{padding-top:0;border-top:0}.wbs-model-rate-limit-account-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 2px 2px}.wbs-model-rate-limit-account-head strong{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px}.wbs-model-rate-limit-account-head span{flex:0 0 auto;color:var(--wb-icon-tertiary,#7c818b);font-size:10px;white-space:nowrap}.wbs-model-rate-limit-summary-row{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,auto);align-items:center;gap:7px;min-height:28px;margin-top:4px;padding:0 8px;border:1px solid var(--wb-border-subtle,rgba(20,24,32,.1));border-radius:8px;background:color-mix(in srgb,var(--wb-bg-secondary,#f6f7f8) 72%,transparent)}.wbs-model-rate-limit-summary-row>span{color:var(--wb-color-text-secondary,#5f6368);white-space:nowrap}.wbs-model-rate-limit-summary-row>b{min-width:0;font-size:11px;font-weight:650;white-space:nowrap;overflow-wrap:normal}.wbs-model-rate-limit-summary-row .wbs-model-rate-limit-model{text-align:left}.wbs-model-rate-limit-summary-row .wbs-model-rate-limit-reset{text-align:right}',
@@ -17409,7 +17411,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
'.wbs-icon-btn:disabled{opacity:.5;cursor:not-allowed}',
/* 版本标签(昵称旁:个人版 / 企业名称):低饱和浅灰,信息次要不抢眼;深色主题单独适配 */
'.wbs-badge{display:inline-flex;align-items:center;font-size:10px;line-height:1;padding:2px 7px;border-radius:999px;flex-shrink:1;min-width:0;max-width:112px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500;background:var(--wb-bg-tertiary,#eef0f3);color:var(--wb-color-text-secondary,#5f6368);border:1px solid transparent}',
- 'html.cb-dark .wbs-badge,html[data-theme="dark"] .wbs-badge{background:rgba(255,255,255,.07);color:rgba(235,236,240,.68);border-color:rgba(255,255,255,.08)}',
+ 'html.cb-dark .wbs-badge:not(:where([data-wbs-appearance="light"] *,.wbs-panel-light *)),html[data-theme="dark"] .wbs-badge:not(:where([data-wbs-appearance="light"] *,.wbs-panel-light *)){background:rgba(255,255,255,.07);color:rgba(235,236,240,.68);border-color:rgba(255,255,255,.08)}',
/* 当前使用中角标:无底图形,颜色跟随昵称(text-primary),深色随变量自动适配 */
'.wbs-empty{text-align:center;color:var(--wb-icon-tertiary,#999);padding:28px 12px;font-size:13px;line-height:1.8}',
/* 底部 */
diff --git a/test/codebuddy-badge-contrast.test.js b/test/codebuddy-badge-contrast.test.js
new file mode 100644
index 0000000..b10ea3b
--- /dev/null
+++ b/test/codebuddy-badge-contrast.test.js
@@ -0,0 +1,35 @@
+'use strict';
+const test = require('node:test');
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const path = require('node:path');
+const vm = require('node:vm');
+const source = fs.readFileSync(path.join(__dirname, '../scripts/inject.js'), 'utf8');
+const start = source.indexOf(' css.textContent = [');
+const end = source.indexOf(" ].join('');", start);
+const css = vm.runInNewContext(source.slice(start, end + " ].join('');".length), { css: {} });
+const lightExclusion = ':not(:where([data-wbs-appearance="light"] *,.wbs-panel-light *))';
+
+// CodeBuddy keeps a light panel even when the official renderer uses a dark theme.
+// Every dark override must exclude both ways of marking that light surface.
+test('host dark edition and growth badge overrides respect the panel appearance', () => {
+ const rules = [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)].filter(([, selector]) =>
+ /html\.cb-dark|html\[data-theme="dark"\]|body\[data-vscode-theme-name/.test(selector) &&
+ /\.wbs-badge\b|\.wbs-daily-rings\b|\.wbs-checkin-tag\.ok/.test(selector));
+ assert.ok(rules.length >= 4, 'checks edition, growth ink, badge surface and hover rules');
+ for (const [, selector] of rules) {
+ for (const match of selector.matchAll(/\.wbs-badge\b|\.wbs-daily-rings\b|\.wbs-checkin-tag\.ok/g)) {
+ assert.ok(selector.slice(match.index + match[0].length).startsWith(lightExclusion), selector);
+ }
+ }
+});
+
+test('forced light growth badges retain the light credit color in any host theme', () => {
+ const fill = '--wbs-liquid-fill:var(--wbs-credit-theme-color,var(--wbs-primary))';
+ const rule = [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)].find(([, selector, body]) =>
+ selector.includes('[data-wbs-appearance="light"] .wbs-daily-rings') && body.includes(fill));
+ assert.ok(rule, 'explicit light appearance gets the same liquid highlight as the default light theme');
+ assert.ok(rule[1].includes('.wbs-panel-light .wbs-daily-rings'));
+ assert.match(css, /\.wbs-badge\{[^}]*color:var\(--wb-color-text-secondary/);
+ assert.match(css, /\.wbs-daily-cat-mark\{[^}]*background:var\(--wbs-liquid-ink\)/);
+});
diff --git a/test/growth-rings-ui.test.js b/test/growth-rings-ui.test.js
index 36b3ceb..89ebd51 100644
--- a/test/growth-rings-ui.test.js
+++ b/test/growth-rings-ui.test.js
@@ -176,7 +176,7 @@ test('growth primary is green in light and blue-purple in dark, cyber, and glass
assert.doesNotMatch(inject, /html\[data-wbs-theme-id="eye-care"\][^']*--wbs-primary:#7f77dd/);
assert.match(inject, /\.wbs-daily-rings,\.wbs-checkin-tag\.ok\{[^}]*color:var\(--wbs-badge-fg\)/);
assert.doesNotMatch(inject, /\.wbs-ck\.ok\{color:inherit\}/);
- assert.match(inject, /html\[data-wbs-theme-id="nebula"\][^']*\.wbs-checkin-tag\.ok\{[^}]*backdrop-filter:blur/);
+ assert.match(inject, /html\[data-wbs-theme-id="nebula"\][^']*\.wbs-checkin-tag\.ok:not\(:where\([^}]+\{[^}]*backdrop-filter:blur/);
assert.match(inject, /\.wbs-growth-rewards-head em\{[^}]*color:var\(--wb-icon-tertiary/);
assert.match(inject, /\.wbs-growth-tier b\{[^}]*color:var\(--wb-color-text-secondary/);
});