chore: add utility scripts and additional test coverage

STORY:
Development requires supporting scripts and comprehensive test coverage.
This commit adds utility scripts and extends test suites.

COLLABORATION:
- scripts/capture-sessions.mjs: Screenshot capture for sessions hub
- scripts/capture-timeline.mjs: Timeline view capture utility
- sessions-header-logic.ts: Session header business logic
- Additional test files for sessions, hooks, and snapshot diffing
This commit is contained in:
zenchantlive 2026-02-15 21:19:31 -08:00
parent 812b6cf8c5
commit 173937c1f3
7 changed files with 729 additions and 0 deletions

View file

@ -0,0 +1,47 @@
import type { AgentRecord, AgentLiveness } from '../../lib/agent-registry';
export interface SwarmHealth {
status: 'active' | 'warning' | 'critical' | 'offline';
color: string;
}
export function getSwarmHealth(
members: AgentRecord[],
livenessMap: Record<string, AgentLiveness | string>
): SwarmHealth {
if (members.length === 0) {
return { status: 'offline', color: 'text-zinc-500' };
}
let hasStale = false;
let hasEvicted = false;
let allIdle = true;
for (const member of members) {
const liveness = livenessMap[member.agent_id] as AgentLiveness || 'active';
if (liveness !== 'idle') {
allIdle = false;
}
if (liveness === 'stale') {
hasStale = true;
} else if (liveness === 'evicted') {
hasEvicted = true;
}
}
if (allIdle) {
return { status: 'offline', color: 'text-zinc-500' };
}
if (hasEvicted) {
return { status: 'critical', color: 'text-rose-400' };
}
if (hasStale) {
return { status: 'warning', color: 'text-amber-400' };
}
return { status: 'active', color: 'text-emerald-400' };
}