Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: raise port-warning/on-warning AA contrast in day themes (#2626)

Adam Eivy6e6b0cdfd127
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index c60089c8fa..fdd6ddf6fe 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -83,4 +83,5 @@
- **[issue-2553] Size four viewport-height surfaces with `100dvh` (vh fallback) so iOS Safari chrome no longer clips them.** MediaLightbox's fullscreen image (`max-h-[100vh]`), the CollectionPicker popover (`min(360px, calc(100vh - 16px))`), the Layout sidebar flyout (`calc(100vh - 16px)`), and the ChiefOfStaff avatar panel/canvas caps (`min(460px|620px, calc(100vh - 1rem))`) all measured against `100vh`, which iOS Safari inflates by the retractable browser-chrome height — so each spilled under the chrome. New parametrized `max-h-dvh-cap`/`min-h-dvh-cap`/`h-dvh-cap` `@utility` classes in `index.css` size to `100dvh` (the visible dynamic viewport) with a `100vh` fallback gated behind `@supports (height: 1dvh)` — the two-declaration idiom `.h-dvh-screen` uses does not work once the value is wrapped in `var()`/`min()`/`calc()` (both declarations become valid-at-parse-time, so the `dvh` one wins the cascade then computes to invalid rather than restoring the `vh` line), so the `vh` value is the unconditional base and the `dvh` value overrides only where supported. A `--dvh-cap` upper bound and `--dvh-inset` subtracted margin (set per-surface, and per-breakpoint via arbitrary-property utilities for the responsive CoS caps) let one utility serve the plain, capped, and inset variants; the CoS panel keeps its fixed `min-h-[180px]`/`190px` at base/sm/md and only switches to the dvh cap at `lg:`/`xl:`, where the original used a viewport unit. Behavior is byte-identical on engines that predate `dvh`; on iOS Safari the surfaces now stay within the visible viewport.
- **[issue-2548] Replace the vacuous agentLifecycle spawn/completion replica tests with imports of real guard helpers.** `agentLifecycle.test.js` re-implemented production logic — local `unfixedSpawn`/`fixedSpawn` copies of the `spawningTasks` dedup flow and a `runCompletion`/`makeCompletionHarness` copy of the completion try/finally — and never imported `spawnAgentForTask`/`handleAgentCompletion`, so they stayed green when production regressed. The two concurrency contracts those replicas modelled are now extracted into `server/services/agentGuards.js`: `withSpawnDedupGuard(spawningTasks, taskId, fn)` (acquire-before-first-await, hold across the whole spawn body incl. the runner-enqueue handoff, release in `finally`, `SPAWN_DEDUP_SKIP` on a concurrent duplicate) and `withMapEntryCleanup(map, key, fn)` (delete the `runnerAgents` entry in `finally` even when a completion step throws). `spawnAgentForTask` now wraps `runAgentSpawn` in the former (dropping six inline `spawningTasks.delete` sites), and `handleAgentCompletion` wraps its body in the latter — so the tests drive the exact code production runs. The late-delete race that spawned a second agent for the same task id is now a behavioral test against the real guard, not a hand-copied one; the remaining source-scan tests were trimmed to non-negotiable orderings (the handedOff pre-spawn/post-handoff split, the #1563 claim/register ordering, the #989 marker release, the #2243 runner env merge) plus two wiring guards that pin the delegation. `cos.test.js` already drove the real `createDequeueCapacity`/`isMissionTierEligible`/`isIdleTierEligible` exports after #2530, so it was left as-is. New `agentGuards.test.js` unit-tests both helpers in isolation.
- **[issue-2554] Align CoS chrome and scrollbar colors with port design tokens.** The Chief of Staff panel chrome hardcoded `bg-slate-900/60`, `hover:bg-slate-800/80`, the `from-slate-900/80 to-slate-900/40` gradients, and `text-slate-400` — a `slate` surface that ignored the active theme. Those now map to `bg-port-card`/`hover:bg-port-border`/`text-port-text-muted` (the collapse button's `text-gray-500 hover:text-white` also became `text-port-text-muted hover:text-port-text` so its icon stays legible in light themes), so the panel restyles with the selected theme. The global `::-webkit-scrollbar-thumb` (and its `:hover`) dropped their hardcoded `#3a3a3a`/`#4a4a4a` for the opaque, theme-derived `rgb(var(--port-text-muted))` and `rgb(var(--port-text))` — colors that stay high-contrast against the already-tokenized `rgb(var(--port-card))` track in both dark and light themes (an alpha-over-track blend would wash out on light cards, so the opaque muted-text token is used). The unread-count badges in `Layout.jsx` (four sites) and `NotificationDropdown.jsx` swapped `bg-yellow-500 text-black` for `bg-port-warning text-port-on-warning`; the Dashboard server-health glow's `shadow-[0_0_8px_#22c55e]`/`#ef4444` now reference `rgb(var(--port-success))`/`rgb(var(--port-error))`. The Ambient full-screen idle display is intentionally left on its fixed deep-black `bg-[#050505]` (with `text-white` content) — it is a theme-independent ambient/OLED surface, and making the backdrop theme-following would strand its non-tokenized white clock and translucent panels invisibly on light themes. Visual-only token swaps — no logic or layout change; the retokenized surfaces now follow the active theme instead of a fixed palette.
+- **[issue-2626] Raise `bg-port-warning` / `text-port-on-warning` contrast to WCAG AA in day themes.** Two `mode: 'day'` themes paired an amber `--port-warning` with white `--port-on-warning`, dropping the ~180 warning surfaces (buttons, chips, unread-count badges) below the 4.5:1 AA threshold for small text — `lumen-glass-day` (#ca8a04 on white ≈ 2.94:1) and `black-ice-terminal-day` (#aa6e00 on white ≈ 4.25:1). Both now use black `--port-on-warning` at the theme-token layer (`0 0 0`), lifting them to ~7.15:1 and ~4.94:1 respectively; the other two amber day themes (`classic-noon`, `blueprint-ops-day`) already cleared AA at ~5.02:1 on white and were left unchanged. A new `client/src/themes/portosThemes.test.js` computes the WCAG contrast ratio for the warning pair of every theme and asserts ≥4.5:1, so a future theme can't regress the pairing.
diff --git a/client/src/themes/portosThemes.js b/client/src/themes/portosThemes.js
index 08de11f388..33404bc3e7 100644
--- a/client/src/themes/portosThemes.js
+++ b/client/src/themes/portosThemes.js
@@ -271,7 +271,8 @@ export const THEMES = {
'--port-error': '225 29 72',
'--port-on-accent': '255 255 255',
'--port-on-success': '5 46 22',
- '--port-on-warning': '255 255 255',
+ // Black on #ca8a04 is ~7.15:1 (AA) vs white's ~2.94:1 (fails). See #2626.
+ '--port-on-warning': '0 0 0',
'--port-on-error': '255 255 255',
// violet-700 — darkened for AA contrast on the cream/white glass panels.
'--port-accent-2': '126 34 206',
@@ -423,7 +424,8 @@ export const THEMES = {
'--port-error': '185 29 106',
'--port-on-accent': '255 255 255',
'--port-on-success': '255 255 255',
- '--port-on-warning': '255 255 255',
+ // Black on #aa6e00 is ~4.94:1 (AA) vs white's ~4.25:1 (fails small text). See #2626.
+ '--port-on-warning': '0 0 0',
'--port-on-error': '255 255 255',
// Plum ink — readable on cream paper, distinct from the rose error ink.
'--port-accent-2': '106 27 154',
diff --git a/client/src/themes/portosThemes.test.js b/client/src/themes/portosThemes.test.js
new file mode 100644
index 0000000000..f38eb92cae
--- /dev/null
+++ b/client/src/themes/portosThemes.test.js
@@ -0,0 +1,41 @@
+import { describe, it, expect } from 'vitest';
+import { THEMES } from './portosThemes.js';
+
+// WCAG 2.x relative luminance + contrast ratio, computed straight from the
+// stored "R G B" token strings so the assertion proves the on-disk theme
+// values themselves clear AA — see #2626 (bg-port-warning / text-port-on-warning
+// fell to ~2.94:1 on white in several day themes).
+const parseRgb = (value) => value.trim().split(/\s+/).map(Number);
+
+const relativeLuminance = ([r, g, b]) => {
+ const channel = (v) => {
+ const c = v / 255;
+ return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
+ };
+ return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
+};
+
+const contrastRatio = (a, b) => {
+ const [l1, l2] = [relativeLuminance(a), relativeLuminance(b)].sort((x, y) => y - x);
+ return (l1 + 0.05) / (l2 + 0.05);
+};
+
+const AA_SMALL_TEXT = 4.5;
+
+describe('portosThemes warning token contrast', () => {
+ const entries = Object.values(THEMES);
+
+ it('has at least one day theme (guards the loop below from vacuously passing)', () => {
+ expect(entries.some((t) => t.mode === 'day')).toBe(true);
+ });
+
+ it.each(entries.map((t) => [t.id, t]))(
+ '%s: bg-port-warning / text-port-on-warning meets WCAG AA (>=4.5:1)',
+ (_id, theme) => {
+ const warning = parseRgb(theme.colors['--port-warning']);
+ const onWarning = parseRgb(theme.colors['--port-on-warning']);
+ const ratio = contrastRatio(warning, onWarning);
+ expect(ratio).toBeGreaterThanOrEqual(AA_SMALL_TEXT);
+ },
+ );
+});