feat(today): surface degraded fleet projects in SummaryBar

getFleetSummary now also reads sessionHealth from DB and counts projects
whose health is degraded or critical. A new amber pill appears in SummaryBar
when any exist, linking to /control — so the user sees unhealthy agents
from Today without opening the Control panel.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
g-butandClaude Sonnet 4.6 committed 2026-05-11 11:15:58 +02:00
1 parent a4549b2d88
commit ea8db50194
2 files changed
+12 -3

No files matched your search

+4 -1
View File
@@ -1,4 +1,4 @@
import { Target, Bell, Inbox, AlertCircle, Clock, Calendar, Users, Repeat2, Bot } from "lucide-react";
import { Target, Bell, Inbox, AlertCircle, Clock, Calendar, Users, Repeat2, Bot, Activity } from "lucide-react";
import Link from "next/link";
import { getTodaySummary, getFleetSummary } from "@/db/queries/today";
import { getCurrentUserId } from "@/lib/session";
@@ -41,6 +41,9 @@ export async function SummaryBar() {
{s.urgentAlerts > 0 && (
<Pill icon={Bell} value={`${s.urgentAlerts} urgent`} variant="red" href="#alerts" />
)}
{fleet.degraded > 0 && (
<Pill icon={Activity} value={`${fleet.degraded} degraded`} variant="amber" href="/control" />
)}
{fleet.running > 0 && (
<Pill icon={Bot} value={`${fleet.running} running`} variant="accent" href="/control" />
)}
+8 -2
View File
@@ -10,7 +10,7 @@ import { commitments, subscriptions, goals, alerts, actions, events, projectStat
import { eq, and, lte, isNotNull, sql } from "drizzle-orm";
import { HEALTH_FADING_DAYS } from "@/lib/constants/people";
import { GOAL_STATUS, SUB_STATUS, COMMITMENT_STATUS, ACTION_STATUS, ALERT_SEVERITY, EVENT_STATUS } from "@/lib/constants/statuses";
import { READY_WINDOW_S, PROMPT_RUNNING_WINDOW_S } from "@/lib/constants/control";
import { READY_WINDOW_S, PROMPT_RUNNING_WINDOW_S, getHealthShort } from "@/lib/constants/control";
import { z } from "zod";
export const CreateCommitmentBody = z.object({
@@ -239,18 +239,24 @@ export async function getFleetSummary(userId: string) {
.select({
currentPromptStartedAt: projectStates.currentPromptStartedAt,
readyAt: projectStates.readyAt,
sessionHealth: projectStates.sessionHealth,
})
.from(projectStates)
.where(eq(projectStates.userId, userId));
let running = 0;
let waiting = 0;
let degraded = 0;
for (const r of rows) {
if (r.currentPromptStartedAt && r.currentPromptStartedAt > cutoffRunning) {
running++;
} else if (r.readyAt && r.readyAt > cutoffWaiting) {
waiting++;
}
if (r.sessionHealth) {
const short = getHealthShort(r.sessionHealth);
if (short === "degraded" || short === "critical") degraded++;
}
}
return { running, waiting };
return { running, waiting, degraded };
}