Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 105x 1127x | import React from "react";
/**
* Status pills, driven by a registry rather than a colour map per page.
*
* Ten files declared their own `Record<SomeStatus, string>` of Tailwind
* classes. The five `SimulationStatus` maps were byte-identical; the rest
* overlapped heavily. A colour is a *meaning* ("this failed", "this is still
* going"), so the meanings live here once and each domain says which of its
* statuses carries which meaning.
*
* Adding a status means adding one entry to a scale — never a new colour
* string, and never a new component.
*/
/** What a status means, independent of which resource it belongs to. */
export type StatusTone =
| "neutral" // nothing is happening yet, and nothing is wrong
| "muted" // deliberately set aside — archived, cancelled
| "progress" // in flight
| "success" // finished well, or live and healthy
| "done" // finished, without a judgement on the outcome
| "warning"
| "danger";
/** The single place a badge colour is spelled out. Values are whole class
* names because Tailwind scans source text and cannot see interpolation. */
export const STATUS_TONE_CLASSES: Record<StatusTone, string> = {
neutral:
"bg-gray-50 dark:bg-gray-800 text-gray-500 dark:text-gray-400 border-gray-200 dark:border-gray-600",
muted:
"bg-gray-50 dark:bg-gray-800 text-gray-400 dark:text-gray-500 border-gray-200 dark:border-gray-600",
progress:
"bg-blue-50 dark:bg-blue-950/40 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-800",
success:
"bg-green-50 dark:bg-green-950/40 text-green-700 dark:text-green-300 border-green-200 dark:border-green-800",
done: "bg-violet-50 dark:bg-violet-950/40 text-violet-700 dark:text-violet-300 border-violet-200 dark:border-violet-800",
warning:
"bg-amber-50 dark:bg-amber-950/40 text-amber-600 dark:text-amber-400 border-amber-200 dark:border-amber-800",
danger:
"bg-red-50 dark:bg-red-950/40 text-red-700 dark:text-red-300 border-red-200 dark:border-red-800",
};
/** The same meanings as a ring around a mark (a node on a map): its border
* only, so the mark's own fill stays its own. Whole class names, like the
* badges'. A 2px ring is a graphic, so each tone clears 3:1 on the card
* surfaces (white; gray-800 in dark), checked with the dataviz palette
* validator; success and warning sit in the colour-vision floor band, so
* whatever draws a ring names the status beside it or on hover, and marks
* a warning with a glyph — never colour alone. */
export const STATUS_TONE_RING: Record<StatusTone, string> = {
neutral: "border-gray-300 dark:border-gray-600",
muted: "border-gray-200 dark:border-gray-700",
progress: "border-blue-600 dark:border-blue-500",
success: "border-emerald-600",
done: "border-violet-600 dark:border-violet-500",
warning: "border-amber-600",
danger: "border-red-600 dark:border-red-500",
};
/** A named set of statuses and the tone each carries. */
export type StatusScale = Record<string, StatusTone>;
/**
* A resource's lifecycle: `SimulationStatus`, and anything else that is
* drafted, activated and eventually archived.
*
* `completed` is `done`, not `success` — a finished simulation is finished,
* which says nothing about whether it went well.
*/
export const LIFECYCLE_STATUS: StatusScale = {
draft: "neutral",
active: "success",
running: "progress",
completed: "done",
archived: "warning",
failed: "danger",
};
/**
* One execution of something: an evaluation run, a batch, a simulation run,
* a skill run.
*
* Here `completed` *is* `success` — the run did what it was asked to. That
* this word means different things in the two scales is exactly why they are
* two scales rather than one shared lookup.
*/
export const RUN_STATUS: StatusScale = {
queued: "neutral",
running: "progress",
completed: "success",
failed: "danger",
cancelled: "muted",
// A policy rule refused it — the same tone a block carries on Governance.
blocked: "danger",
// Paused for a person: it needs somebody, which is what warning means.
awaiting_input: "warning",
// A reviewer declined an approval gate — deliberately stopped, not failed.
rejected: "muted",
// A chat answer that failed (`ChatMessage.status`), as a run's `failed`.
error: "danger",
// Not run: its workspace's budget was used up (a website crawl). It runs
// again when the budget does — waiting on somebody's money, not broken.
held: "warning",
};
/**
* `SwarmEnum.RunStatus` — a swarm run (`objects/Swarm.ts`).
*
* `partial` is a warning, not a failure: it answered, from part of the work.
* Both waits on a person are warnings, as a paused skill run's is.
*/
export const SWARM_RUN_STATUS: StatusScale = {
planning: "progress",
awaiting_approval: "warning",
running: "progress",
awaiting_input: "warning",
wrapping_up: "progress",
completed: "success",
partial: "warning",
failed: "danger",
blocked: "danger",
cancelled: "muted",
};
/**
* `SwarmEnum.TaskStatus` — one task of a swarm run. `skipped` and
* `cancelled` are set aside on purpose (the run wrapped up, or a person
* dropped the piece), so muted; `interrupted` runs again, so it is waiting.
*/
export const SWARM_TASK_STATUS: StatusScale = {
queued: "neutral",
running: "progress",
awaiting_input: "warning",
done: "success",
failed: "danger",
blocked: "danger",
skipped: "muted",
cancelled: "muted",
interrupted: "neutral",
};
/**
* `ReviewStatus` — a flag raised by an audit rule, and what a person made of it.
*
* `pending` is `warning` rather than `neutral`: an unreviewed flag is work
* outstanding, and a queue that renders it as unremarkable is a queue nobody
* clears. `dismissed` is `muted` rather than `danger` — the flag was judged
* unwarranted, which is a normal outcome, not a failure.
*/
/**
* A rule: switched on, or stored and switched off. Off is `muted` — set aside
* on purpose — never a warning: an inactive rule is a choice, not a fault.
*/
export const RULE_STATE: StatusScale = {
active: "success",
off: "muted",
};
/** An organisation invite link. Only a pending one admits anybody. */
export const INVITE_STATUS: StatusScale = {
pending: "warning",
accepted: "success",
revoked: "muted",
expired: "muted",
};
export const REVIEW_STATUS: StatusScale = {
pending: "warning",
reviewed: "success",
dismissed: "muted",
};
/**
* A regression verdict — how one evaluation run compares to the one before it.
*
* `unchanged` is `success`, not `neutral`: for a regression check, "nothing got
* worse" is the good outcome, and rendering it as unremarkable would leave the
* only reassuring answer looking like no answer at all. The two "we could not
* tell" verdicts are `neutral` for the opposite reason — they are not a pass.
*/
export const REGRESSION_VERDICT: StatusScale = {
improved: "success",
unchanged: "success",
regressed: "danger",
no_baseline: "neutral",
incomparable: "neutral",
};
/**
* A promotion gate's verdict.
*
* `unmeasured` is `warning` rather than `neutral`: the promotion is allowed,
* but nothing checked it, and that is worth noticing rather than reading as
* approval.
*/
export const GATE_STATUS: StatusScale = {
clear: "success",
blocked: "danger",
unmeasured: "warning",
};
/**
* What came of one rule being evaluated against one invocation — the
* Governance → Rules → Activity log.
*
* `no_change` is `success`, not `neutral`: a redaction rule over a prompt
* with no PII in it has done its job, and that is the reassuring answer, not
* an absent one. `applied` is `done` — the rule acted, which is worth looking
* at without implying anything went wrong. `not_matched` is the only
* genuinely unremarkable outcome: the rule was evaluated and correctly stood
* aside.
*/
export const GOVERNANCE_OUTCOME: StatusScale = {
blocked: "danger",
applied: "done",
no_change: "success",
not_matched: "neutral",
};
/**
* `HitlOutcome` — how a pause for a person ended (see `objects/Hitl.ts`).
*
* `awaiting` is `warning` like `RUN_STATUS.awaiting_input`: somebody is
* needed. A skip is `neutral`, not a failure — the agent was told to proceed
* on its own reading, which is a legitimate answer. A rejection is `muted`
* as on skill runs; a policy block is `danger` as everywhere else.
*/
export const HITL_OUTCOME: StatusScale = {
awaiting: "warning",
answered: "success",
approved: "success",
skipped: "neutral",
rejected: "muted",
blocked: "danger",
abandoned: "muted",
};
/** `EvaluationStatus` — drafted, in use, or retired. */
export const EVALUATION_STATUS: StatusScale = {
draft: "neutral",
active: "success",
archived: "warning",
};
/** How well a document's evidence supports its conclusions (svc-ai
* `DocumentSpec.confidence`). Low is a caution, not a failure. */
export const EVIDENCE_CONFIDENCE: StatusScale = {
high: "success",
medium: "done",
low: "warning",
};
/** Whether an agent's version in force has evaluation evidence behind it
* (`AssuranceStatus`). Never evaluated is a warning, not a failure: it is a
* gap in evidence, where a regression is evidence of a problem. */
export const ASSURANCE_STATUS: StatusScale = {
current: "success",
failing: "danger",
unscored: "neutral",
outdated: "warning",
unrecorded: "neutral",
never: "warning",
regressed: "danger",
};
/** How far an agent's answers stray from its average (`RiskBand`): steady
* answers are the safe reading, erratic ones a caution, and answers that
* often fail outright a danger, whatever the average says. */
export const RISK_LEVEL: StatusScale = {
low: "success",
moderate: "warning",
high: "danger",
};
/** Whether a section of a decision record holds what its turn recorded
* (`DecisionSectionStatus`). Recorded and empty are both answers: a turn
* that called no tool has nothing to show, which is reassuring rather than
* missing. Not recorded is a gap in the evidence (a caution, as an agent
* never evaluated is); unavailable is a failure to read it. */
export const DECISION_SECTION: StatusScale = {
recorded: "done",
empty: "neutral",
not_recorded: "warning",
unavailable: "danger",
};
/** A person's verdict on an answer (`DecisionVerdict`). A correction is
* `done`, not a failure: the answer was close enough to fix, and the fix is
* now on record. */
export const DECISION_VERDICT: StatusScale = {
accepted: "success",
edited: "done",
rejected: "danger",
};
/** What became of an answer at the agent's quality check (svc-ai
* `QualityOutcome`). Revised is a success: the agent revised its own answer
* and the revision passed (the check no longer writes answers itself).
* Unavailable is a caution — nobody checked it, which is a gap rather than
* evidence of a problem. Skipped is neutral: the agent's cost profile chose
* not to check a simple request. Failed is a failure. */
export const QUALITY_CHECK: StatusScale = {
passed: "success",
revised: "success",
failed: "danger",
unavailable: "warning",
skipped: "neutral",
};
/** How a retrieval stage of a turn ran (svc-ai's `retrieval_report`): the
* query planner or relevance judge failed, or a search leg could not run.
* A caution — the pipeline went on with less (the judge fails open,
* keeping its passages unjudged) — not evidence the answer is wrong. */
export const RETRIEVAL_STAGE: StatusScale = {
degraded: "warning",
};
/** Where a budget stands (`BudgetStatus`). Reached is a failure — the next
* turn it governs is refused, or let through with a warning — and heading
* over or nearly used are cautions. A budget whose figures cannot be read
* is a caution too: a gap, not evidence of overspend. */
export const BUDGET_STATUS: StatusScale = {
ok: "success",
near: "warning",
projected_over: "warning",
reached: "danger",
unavailable: "neutral",
};
/** Where one of an agent's memories stands (svc-ai `agent_memories`): in
* force, in force until a date the person gave, replaced by a correction,
* or past its date. Replaced and expired ones are kept for the record and
* never recalled — set aside, not wrong. */
export const MEMORY_STATE: StatusScale = {
current: "success",
temporary: "neutral",
replaced: "muted",
expired: "muted",
};
export interface StatusBadgeProps {
/** The status value. Anything not in `scale` falls back to `neutral`. */
status: string;
/** Which vocabulary `status` belongs to. */
scale?: StatusScale;
/** Lucide icon shown before the label. */
icon?: React.ElementType;
/** Overrides the humanised status text. */
label?: React.ReactNode;
/** `xs` matches the dense badges on cards and rows. */
size?: "xs" | "sm";
className?: string;
}
const SIZES = {
xs: "text-[10px] px-1.5 py-0.5 gap-1",
sm: "text-xs px-2.5 py-1 gap-1.5",
} as const;
/**
* ```tsx
* <StatusBadge status={world.status} scale={LIFECYCLE_STATUS} />
* <StatusBadge status={run.status} scale={RUN_STATUS} icon={Play} size="sm" />
* ```
*/
export const StatusBadge: React.FC<StatusBadgeProps> = ({
status,
scale = LIFECYCLE_STATUS,
icon: Icon,
label,
size = "xs",
className = "",
}) => (
<span
className={`inline-flex items-center rounded-full border font-medium capitalize ${
SIZES[size]
} ${STATUS_TONE_CLASSES[scale[status] ?? "neutral"]} ${className}`.trim()}
>
{Icon && <Icon className="size-3 shrink-0" />}
{label ?? status.replace(/_/g, " ")}
</span>
);
export default StatusBadge;
|