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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: derive the Learning tile's critical tone locally and keep the hover border affordance (#4129)
Adam Eivyb5fa86791535
diff --git a/client/src/components/cos/StatCard.jsx b/client/src/components/cos/StatCard.jsxindex 2cbfa735bf..425a1bf98f 100644--- a/client/src/components/cos/StatCard.jsx+++ b/client/src/components/cos/StatCard.jsx@@ -13,8 +13,10 @@ const TONE_CLASSES = {// The `mini` and `default` variants share one stacked layout and differ only by// scale, so they live in a size table instead of two near-identical returns.+// `compact` keeps its own row layout but reads its shell classes from here too.const SIZES = {default: {+ bg: 'bg-port-card',root: 'rounded-lg p-2 sm:p-3 lg:p-4',activeBorder: 'border-port-accent shadow-lg shadow-port-accent/20',header: 'mb-0.5 sm:mb-1 lg:mb-2',@@ -23,6 +25,7 @@ const SIZES = {activeLabel: 'text-xs mt-0.5 sm:mt-1 animate-pulse',},mini: {+ bg: 'bg-port-card',root: 'rounded p-1.5 sm:p-2 lg:p-3',activeBorder: 'border-port-accent shadow-md shadow-port-accent/20',header: 'mb-0.5',@@ -30,10 +33,14 @@ const SIZES = {value: 'text-sm sm:text-base lg:text-xl',activeLabel: 'text-[9px] mt-0.5',},+ compact: {+ bg: 'bg-port-card/80',+ root: 'rounded px-2 py-1.5 flex items-center gap-2',+ activeBorder: 'border-port-accent shadow-md shadow-port-accent/20',+ activeLabel: 'text-[9px]',+ },};-const COMPACT_ACTIVE_BORDER = 'border-port-accent shadow-md shadow-port-accent/20';-export default function StatCard({ label, value, icon, active, activeLabel, compact, mini, tone, onClick, title }) {const ariaLabel = `${label}: ${value}${active && activeLabel ? `, ${activeLabel}` : ''}`;// Only tint the icon when a tone was asked for — tone-less callers pass a@@ -42,22 +49,27 @@ export default function StatCard({ label, value, icon, active, activeLabel, compconst iconClass = ['shrink-0', active ? 'animate-pulse' : '', toneStyles?.icon ?? ''].filter(Boolean).join(' ');const subLabelClass = toneStyles?.label ?? 'text-port-accent';const showActiveLabel = Boolean(active && activeLabel);- const borderClass = (activeBorder) => toneStyles?.border ?? (active ? activeBorder : 'border-port-border');++ const size = compact ? SIZES.compact : (mini ? SIZES.mini : SIZES.default);+ const borderClass = toneStyles?.border ?? (active ? size.activeBorder : 'border-port-border');// `onClick` promotes the card to a real <button> so it's keyboard- and- // screen-reader-reachable; without it the card stays a labelled group.+ // screen-reader-reachable; without it the card stays a labelled group. A card+ // already wearing a tone or active border keeps that color on hover — the+ // border-hover affordance only applies where the border is still neutral.const Wrapper = onClick ? 'button' : 'div';const wrapperProps = onClick? { type: 'button', onClick, title, 'aria-label': ariaLabel }: { role: 'group', title, 'aria-label': ariaLabel };- const interactiveClass = onClick ? 'text-left hover:bg-port-card/60' : '';+ const hasNeutralBorder = !toneStyles?.border && !active;+ const interactiveClass = onClick+ ? `text-left hover:bg-port-card/60${hasNeutralBorder ? ' hover:border-port-accent-2/50' : ''}`+ : '';+ const shellClass = `${size.bg} border transition-all ${size.root} ${borderClass} ${interactiveClass}`;if (compact) {return (- <Wrapper- {...wrapperProps}- className={`bg-port-card/80 border rounded px-2 py-1.5 flex items-center gap-2 transition-all ${borderClass(COMPACT_ACTIVE_BORDER)} ${interactiveClass}`}- >+ <Wrapper {...wrapperProps} className={shellClass}><div className={iconClass} aria-hidden="true">{icon}</div>@@ -71,7 +83,7 @@ export default function StatCard({ label, value, icon, active, activeLabel, comp<div className="text-[10px] text-gray-500 truncate">{label}</div><div className="text-sm font-bold text-white">{value}</div>{showActiveLabel && (- <div className={`text-[9px] truncate ${subLabelClass}`} aria-live="polite">+ <div className={`${size.activeLabel} truncate ${subLabelClass}`} aria-live="polite">{activeLabel}</div>)}@@ -80,13 +92,8 @@ export default function StatCard({ label, value, icon, active, activeLabel, comp);}- const size = mini ? SIZES.mini : SIZES.default;-return (- <Wrapper- {...wrapperProps}- className={`bg-port-card border transition-all ${size.root} ${borderClass(size.activeBorder)} ${interactiveClass}`}- >+ <Wrapper {...wrapperProps} className={shellClass}><div className={`flex items-center justify-between ${size.header}`}><span className={`${size.label} text-gray-500 truncate`}>{label}</span><div className={iconClass} aria-hidden="true">diff --git a/client/src/components/cos/StatCard.test.jsx b/client/src/components/cos/StatCard.test.jsxindex ecc664323c..26715f5e06 100644--- a/client/src/components/cos/StatCard.test.jsx+++ b/client/src/components/cos/StatCard.test.jsx@@ -57,6 +57,21 @@ describe('StatCard onClick', () => {expect(onClick).toHaveBeenCalledTimes(1);});+ it('offers a border-hover affordance while the border is still neutral', () => {+ const { container } = render(<StatCard label="Learning" value="84%" onClick={() => {}} mini />);+ expect(root(container).className).toContain('hover:border-port-accent-2/50');+ });++ it('does not hover-recolor a border already carrying a tone or the active accent', () => {+ // Hovering a red "critical" card must not flash it accent-2 — the health+ // color is the signal, and Tailwind's hover: variant would win over it.+ const { container: toned } = render(<StatCard label="Learning" value="12%" onClick={() => {}} tone="critical" mini />);+ expect(root(toned).className).not.toContain('hover:border-');++ const { container: activeCard } = render(<StatCard label="Active" value={2} onClick={() => {}} active mini />);+ expect(root(activeCard).className).not.toContain('hover:border-');+ });+it('passes title through for the hover hint', () => {render(<StatCard label="Learning" value="84%" title="2 need attention" onClick={() => {}} mini />);expect(screen.getByRole('button', { name: 'Learning: 84%' }).getAttribute('title')).toBe('2 need attention');diff --git a/client/src/pages/ChiefOfStaff.jsx b/client/src/pages/ChiefOfStaff.jsxindex d3a50091c5..d85f136162 100644--- a/client/src/pages/ChiefOfStaff.jsx+++ b/client/src/pages/ChiefOfStaff.jsx@@ -518,13 +518,16 @@ export default function ChiefOfStaff() {// Learning tile behaviour shared by the compact (sidebar/mobile) and mini// (ascii stats bar) renderings — only the icon scale and the empty-state- // value differ between them. `skipped > 0` is exactly the server's `critical`- // status (taskLearning/insights.js), so the sub-label lands red via the tone.+ // value differ between them. A skipped task type is critical on its own+ // terms: derive that here rather than trusting the server's status chain to+ // keep classifying `skipped > 0` as `critical`, or a reorder there would+ // silently drop the red signal while the tile still reads "N skipped".+ const learningSkipped = learningSummary?.skipped ?? 0;const learningStatProps = {label: 'Learning',- tone: learningSummary?.status || 'default',- active: (learningSummary?.skipped ?? 0) > 0,- activeLabel: learningSummary?.skipped ? `${learningSummary.skipped} skipped` : null,+ tone: learningSkipped > 0 ? 'critical' : (learningSummary?.status || 'default'),+ active: learningSkipped > 0,+ activeLabel: learningSkipped > 0 ? `${learningSkipped} skipped` : null,title: learningSummary?.statusMessage || 'View learning analytics',onClick: () => navigate('/cos/learning'),};diff --git a/client/src/pages/ChiefOfStaff.test.jsx b/client/src/pages/ChiefOfStaff.test.jsxindex 46ebc553d1..13e0cb924f 100644--- a/client/src/pages/ChiefOfStaff.test.jsx+++ b/client/src/pages/ChiefOfStaff.test.jsx@@ -275,6 +275,19 @@ describe('ChiefOfStaff Learning card skipped label', () => {}});+ it('paints a skipped tile as critical even if the server status disagrees', async () => {+ // The tile derives `critical` from `skipped > 0` itself instead of trusting+ // the server's status chain to keep classifying it that way — this fixture+ // is deliberately the mismatched combination (skipped 3 / status 'warning').+ api.getCosLearningSummary.mockResolvedValue(summaryWithSkipped);+ renderAt('config');++ for (const card of await learningCards()) {+ expect(within(card).getByText(/skipped/).className).toContain('text-port-error');+ expect(card.className).toContain('border-port-error');+ }+ });+it('omits the skipped label entirely when nothing was skipped', async () => {api.getCosLearningSummary.mockResolvedValue({ ...summaryWithSkipped, skipped: 0, status: 'good' });renderAt('config');