swarm ui: show agent freshness and failures where the operator looks, page titles, try again, and stale-data notes
An agent card shows its freshness (stale with the last report's age, never reported, not in swarm identity) when it is not fresh, so the status filter has a visible reason. A failed state change shows its reason in a panel under the card, and a failed cancel shows its reason in the badge, instead of a hover title. Pages can set their title (usePageTitle) and the flow editor does, so several editor tabs differ; the 404 links home. The claude login dialog offers try again after a failure, announces its wait, and has a per-agent field id. The create-agent tabs go forward again as far as the operator has been, but not past a step that is invalid now (lastReachableStep, tested), and the disabled next and create buttons say why in a hint they are described by. usePolled reports when the last live answer arrived, and StaleNote says how old a list is under a failed refresh, or that it is the answer saved from the last visit, on the alerts, builds, review runs, hives, schedules and flows lists.
This commit is contained in:
parent
e4cfac6926
commit
679d2ee420
3 changed files with 321 additions and 25 deletions
|
|
@ -42,6 +42,8 @@ export function ClaudeLoginDialog({
|
|||
}) {
|
||||
const [step, setStep] = useState<LoginStep>({ step: "starting" });
|
||||
const [code, setCode] = useState("");
|
||||
// Bumped by "try again": the effect below starts a new login for it.
|
||||
const [attempt, setAttempt] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
let live = true;
|
||||
|
|
@ -65,7 +67,13 @@ export function ClaudeLoginDialog({
|
|||
return () => {
|
||||
live = false;
|
||||
};
|
||||
}, [agent]);
|
||||
}, [agent, attempt]);
|
||||
|
||||
function tryAgain() {
|
||||
setCode("");
|
||||
setStep({ step: "starting" });
|
||||
setAttempt((n) => n + 1);
|
||||
}
|
||||
|
||||
function close() {
|
||||
if (leavesLoginRunning(step)) {
|
||||
|
|
@ -104,7 +112,7 @@ export function ClaudeLoginDialog({
|
|||
return (
|
||||
<Dialog open onClose={close} label={`log ${agent} in to claude`} plain>
|
||||
<Panel title={`log in to claude — ${agent}`} icon="🔑" onClose={close}>
|
||||
{step.step === "starting" && <p>starting the login…</p>}
|
||||
{step.step === "starting" && <p role="status">starting the login…</p>}
|
||||
{(step.step === "code" || step.step === "submitting") && (
|
||||
<>
|
||||
<p>
|
||||
|
|
@ -114,7 +122,7 @@ export function ClaudeLoginDialog({
|
|||
</p>
|
||||
<FormStack onSubmit={submit}>
|
||||
<TextField
|
||||
id="claude-login-code"
|
||||
id={`claude-login-code-${agent}`}
|
||||
label="code"
|
||||
value={code}
|
||||
required
|
||||
|
|
@ -131,10 +139,13 @@ export function ClaudeLoginDialog({
|
|||
</>
|
||||
)}
|
||||
{step.step === "failed" && (
|
||||
<ApiErrorPanel
|
||||
context="the claude login failed; close and start again"
|
||||
problem={step.problem}
|
||||
/>
|
||||
<>
|
||||
<ApiErrorPanel
|
||||
context="the claude login failed"
|
||||
problem={step.problem}
|
||||
/>
|
||||
<Button onClick={tryAgain}>try again</Button>
|
||||
</>
|
||||
)}
|
||||
</Panel>
|
||||
</Dialog>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
// `<button>`s) from also toggling the card. The wanted menu carries the destroy
|
||||
// option here, since no detail row repeats it any more.
|
||||
import { useState } from "preact/hooks";
|
||||
import { ApiErrorPanel } from "@hive/shared/api-error-panel.js";
|
||||
import { Badge } from "@hive/shared/badge.js";
|
||||
import { TerminalIcon } from "@hive/shared/icons.js";
|
||||
import { Card } from "../../ui/card/Card.js";
|
||||
|
|
@ -23,7 +24,9 @@ import { ClaudeLoginDialog } from "../claude-login/ClaudeLoginDialog.js";
|
|||
import { AgentDetail } from "../detail/AgentDetail.js";
|
||||
import { StatusMessage } from "../detail/StatusMessage.js";
|
||||
import { termPaths } from "../terminal/term-paths.js";
|
||||
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
|
||||
import {
|
||||
FRESHNESS,
|
||||
hivePauseReason,
|
||||
isUpdating,
|
||||
showsLoginNeeded,
|
||||
|
|
@ -67,6 +70,30 @@ export function AgentCard({
|
|||
name={<span class="ui-agent-card-name">{row.name}</span>}
|
||||
status={
|
||||
<>
|
||||
{row.freshness !== "fresh" ? (
|
||||
<Badge
|
||||
tone={FRESHNESS[row.freshness].tone}
|
||||
title={
|
||||
row.freshness === "unknown"
|
||||
? "reported by its hive but not registered in swarm-level identity — needs migration"
|
||||
: row.freshness === "stale"
|
||||
? "the hive has not reported this agent lately"
|
||||
: "the hive has never reported this agent"
|
||||
}
|
||||
value={
|
||||
<>
|
||||
{FRESHNESS[row.freshness].label}
|
||||
{row.freshness === "stale" &&
|
||||
row.last_seen_unix !== null ? (
|
||||
<>
|
||||
{" "}
|
||||
(<RelativeTime epochMs={row.last_seen_unix * 1000} />)
|
||||
</>
|
||||
) : null}
|
||||
</>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
{isUpdating(row) ? (
|
||||
<Badge
|
||||
tone="accent"
|
||||
|
|
@ -127,18 +154,17 @@ export function AgentCard({
|
|||
onSelectPaused={actions.selectPaused}
|
||||
onDestroy={actions.requestDestroy}
|
||||
/>
|
||||
{error ? (
|
||||
<Badge
|
||||
tone="negative"
|
||||
value="failed"
|
||||
title={error.detail ?? "the declaration failed"}
|
||||
/>
|
||||
) : null}
|
||||
</span>
|
||||
}
|
||||
message={<StatusMessage snapshot={row.snapshot} />}
|
||||
chevron={<span class="ui-agent-card-chevron" aria-hidden="true" />}
|
||||
/>
|
||||
{error ? (
|
||||
<ApiErrorPanel
|
||||
context={`changing ${row.name}'s state failed`}
|
||||
problem={error}
|
||||
/>
|
||||
) : null}
|
||||
{open ? (
|
||||
<div class="ui-agent-card-detail">
|
||||
<AgentDetail row={row} actions={actions} withTerminal inCard />
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ export function CancelTurnBadge({
|
|||
return (
|
||||
<Badge
|
||||
tone="negative"
|
||||
value="cancel failed"
|
||||
title={state.detail}
|
||||
value={`cancel failed: ${state.detail}`}
|
||||
title="try cancelling again"
|
||||
onClick={cancel}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue