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

refactor([issue-708]): extract shared scoreToColor across digital-twin test panels

[._.]/ Adam Eivy7f1b6258390d
diff --git a/client/src/components/digital-twin/constants.js b/client/src/components/digital-twin/constants.js
index 7d272c04dc..04ee420938 100644
--- a/client/src/components/digital-twin/constants.js
+++ b/client/src/components/digital-twin/constants.js
@@ -340,3 +340,12 @@ export function getHealthLabel(score) {
return 'Needs Work';
}
+// Shared 0–1 test-run score → Tailwind text color, used by the values-alignment,
+// adversarial-boundary, and multi-turn test panels so their score readouts stay
+// visually consistent (green ≥80%, yellow ≥50%, red below).
+export function scoreToColor(score) {
+ if (score >= 0.8) return 'text-green-400';
+ if (score >= 0.5) return 'text-yellow-400';
+ return 'text-red-400';
+}
+
diff --git a/client/src/components/digital-twin/tabs/AdversarialBoundaryPanel.jsx b/client/src/components/digital-twin/tabs/AdversarialBoundaryPanel.jsx
index 9974c06a76..ac06764182 100644
--- a/client/src/components/digital-twin/tabs/AdversarialBoundaryPanel.jsx
+++ b/client/src/components/digital-twin/tabs/AdversarialBoundaryPanel.jsx
@@ -15,7 +15,7 @@ import * as api from '../../../services/api';
import toast from '../../ui/Toast';
import PersonaBadge from '../PersonaBadge';
-import { ADVERSARIAL_STATUS } from '../constants';
+import { ADVERSARIAL_STATUS, scoreToColor } from '../constants';
import { timeAgo } from '../../../utils/formatters';
/**
@@ -91,9 +91,6 @@ export default function AdversarialBoundaryPanel({ selectedProviders = [], perso
onRefresh?.();
};
- const scoreColor = (score) =>
- score >= 0.8 ? 'text-green-400' : score >= 0.5 ? 'text-yellow-400' : 'text-red-400';
-
const getResultIcon = (result) => {
switch (result) {
case 'held':
@@ -210,7 +207,7 @@ export default function AdversarialBoundaryPanel({ selectedProviders = [], perso
<span className="text-sm text-red-400">{r.error}</span>
) : (
<>
- <span className={`text-lg font-bold ${scoreColor(r.score || 0)}`}>
+ <span className={`text-lg font-bold ${scoreToColor(r.score || 0)}`}>
{Math.round((r.score || 0) * 100)}%
</span>
<span className="text-sm text-gray-500 ml-2">
@@ -294,7 +291,7 @@ export default function AdversarialBoundaryPanel({ selectedProviders = [], perso
{history.map(run => (
<div key={run.runId} className="flex items-center justify-between p-3 rounded bg-port-bg">
<div className="flex items-center gap-4">
- <span className={`text-xl font-bold ${scoreColor(run.score)}`}>
+ <span className={`text-xl font-bold ${scoreToColor(run.score)}`}>
{Math.round(run.score * 100)}%
</span>
<div>
diff --git a/client/src/components/digital-twin/tabs/MultiTurnPanel.jsx b/client/src/components/digital-twin/tabs/MultiTurnPanel.jsx
index 45dbe086a0..82b11e4cd4 100644
--- a/client/src/components/digital-twin/tabs/MultiTurnPanel.jsx
+++ b/client/src/components/digital-twin/tabs/MultiTurnPanel.jsx
@@ -15,7 +15,7 @@ import * as api from '../../../services/api';
import toast from '../../ui/Toast';
import PersonaBadge from '../PersonaBadge';
-import { MULTI_TURN_STATUS } from '../constants';
+import { MULTI_TURN_STATUS, scoreToColor } from '../constants';
import { timeAgo } from '../../../utils/formatters';
/**
@@ -92,9 +92,6 @@ export default function MultiTurnPanel({ selectedProviders = [], personaId = '',
onRefresh?.();
};
- const scoreColor = (score) =>
- score >= 0.8 ? 'text-green-400' : score >= 0.5 ? 'text-yellow-400' : 'text-red-400';
-
const getResultIcon = (result) => {
switch (result) {
case 'consistent':
@@ -211,7 +208,7 @@ export default function MultiTurnPanel({ selectedProviders = [], personaId = '',
<span className="text-sm text-red-400">{r.error}</span>
) : (
<>
- <span className={`text-lg font-bold ${scoreColor(r.score || 0)}`}>
+ <span className={`text-lg font-bold ${scoreToColor(r.score || 0)}`}>
{Math.round((r.score || 0) * 100)}%
</span>
<span className="text-sm text-gray-500 ml-2">
@@ -297,7 +294,7 @@ export default function MultiTurnPanel({ selectedProviders = [], personaId = '',
{history.map(run => (
<div key={run.runId} className="flex items-center justify-between p-3 rounded bg-port-bg">
<div className="flex items-center gap-4">
- <span className={`text-xl font-bold ${scoreColor(run.score)}`}>
+ <span className={`text-xl font-bold ${scoreToColor(run.score)}`}>
{Math.round(run.score * 100)}%
</span>
<div>
diff --git a/client/src/components/digital-twin/tabs/ValuesAlignmentPanel.jsx b/client/src/components/digital-twin/tabs/ValuesAlignmentPanel.jsx
index f07933ac11..ed88406a21 100644
--- a/client/src/components/digital-twin/tabs/ValuesAlignmentPanel.jsx
+++ b/client/src/components/digital-twin/tabs/ValuesAlignmentPanel.jsx
@@ -15,7 +15,7 @@ import * as api from '../../../services/api';
import toast from '../../ui/Toast';
import PersonaBadge from '../PersonaBadge';
-import { VALUES_STATUS } from '../constants';
+import { VALUES_STATUS, scoreToColor } from '../constants';
import { timeAgo } from '../../../utils/formatters';
/**
@@ -89,9 +89,6 @@ export default function ValuesAlignmentPanel({ selectedProviders = [], personaId
onRefresh?.();
};
- const scoreColor = (score) =>
- score >= 0.8 ? 'text-green-400' : score >= 0.5 ? 'text-yellow-400' : 'text-red-400';
-
const getResultIcon = (result) => {
switch (result) {
case 'aligned':
@@ -208,7 +205,7 @@ export default function ValuesAlignmentPanel({ selectedProviders = [], personaId
<span className="text-sm text-red-400">{r.error}</span>
) : (
<>
- <span className={`text-lg font-bold ${scoreColor(r.score || 0)}`}>
+ <span className={`text-lg font-bold ${scoreToColor(r.score || 0)}`}>
{Math.round((r.score || 0) * 100)}%
</span>
<span className="text-sm text-gray-500 ml-2">
@@ -292,7 +289,7 @@ export default function ValuesAlignmentPanel({ selectedProviders = [], personaId
{history.map(run => (
<div key={run.runId} className="flex items-center justify-between p-3 rounded bg-port-bg">
<div className="flex items-center gap-4">
- <span className={`text-xl font-bold ${scoreColor(run.score)}`}>
+ <span className={`text-xl font-bold ${scoreToColor(run.score)}`}>
{Math.round(run.score * 100)}%
</span>
<div>