diff --git a/state-hub/dashboard/src/index.md b/state-hub/dashboard/src/index.md index 6890b26..c180c28 100644 --- a/state-hub/dashboard/src/index.md +++ b/state-hub/dashboard/src/index.md @@ -188,7 +188,7 @@ function _timeCutoff(mode) { return null; } -const chartWs = ( +const _chartWsFiltered = ( _STATUS_MODES.has(_chartMode) ? wsAll.filter(w => w.status === _chartMode) : _chartMode === "accepted" @@ -217,7 +217,20 @@ const chartWs = ( new Date(w.updated_at) >= since || new Date(w.created_at) >= since ); })() -).sort((a, b) => a.domain.localeCompare(b.domain) || a.title.localeCompare(b.title)); +); + +// Sort domains top-to-bottom by most recent workstream update (most active domain first). +// Within a domain, most recently updated workstream comes first. +const _domainLatest = {}; +for (const w of _chartWsFiltered) { + const t = new Date(w.updated_at).getTime(); + if (!_domainLatest[w.domain] || t > _domainLatest[w.domain]) _domainLatest[w.domain] = t; +} +const chartWs = [..._chartWsFiltered].sort((a, b) => { + const dd = (_domainLatest[b.domain] ?? 0) - (_domainLatest[a.domain] ?? 0); + if (dd !== 0) return dd; + return new Date(b.updated_at) - new Date(a.updated_at); +}); // ── Status weight: bold for notable statuses in mixed-status modes ───────────── // Color is NOT used for status — avoids green-on-green when completed bars fill the row.