diff --git a/training/dashboard/static/dashboard.js b/training/dashboard/static/dashboard.js index 2a1e81d..1a5768b 100644 --- a/training/dashboard/static/dashboard.js +++ b/training/dashboard/static/dashboard.js @@ -1760,24 +1760,42 @@ def train_nn(*, model, X_train, y_train, X_val, y_val, root.innerHTML = ''; root.appendChild(awaitingNote('awaiting model_metric events · turn demo on for examples')); } + // Derive a gradient deterministically from the model name. Any + // string the producer publishes (mlp / mlp_realistic / cnn_oracle + // / knn_semi / something we never anticipated) maps to a stable + // hue, so the bar always paints. Beats hardcoding CSS rules per + // known name and missing whatever the producer adds tomorrow. + function modelHue(s) { + // FNV-1a 32-bit, cheap and deterministic across browsers. + let h = 2166136261; + for (let i = 0; i < s.length; i++) { + h ^= s.charCodeAt(i); + h = (h * 16777619) >>> 0; + } + return h % 360; + } + function gradientFor(model) { + const hue = modelHue(String(model)); + return `linear-gradient(90deg, oklch(72% 0.18 ${hue}), oklch(46% 0.20 ${hue}))`; + } function ensureRow(model) { if (rows.has(model)) return rows.get(model); if (root.querySelector('.awaiting')) root.innerHTML = ''; const row = document.createElement('div'); row.className = 'model-row'; row.innerHTML = `