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
9 changed files with 321 additions and 25 deletions
|
|
@ -15,6 +15,7 @@ import {
|
|||
type RefreshIntervalMs,
|
||||
} from "../ui/refresh-interval/RefreshInterval.js";
|
||||
import { fetchJson, usePolled } from "../ui/polled/usePolled.js";
|
||||
import { StaleNote } from "../ui/polled/StaleNote.js";
|
||||
import { Table, type TableColumn } from "../ui/table/Table.js";
|
||||
import { TableSkeleton } from "../ui/table/TableSkeleton.js";
|
||||
import { Toolbar } from "../ui/toolbar/Toolbar.js";
|
||||
|
|
@ -81,6 +82,7 @@ function AlertsBody() {
|
|||
const {
|
||||
data: alerts,
|
||||
error,
|
||||
updatedAt,
|
||||
refreshing,
|
||||
} = usePolled(
|
||||
intervalMs,
|
||||
|
|
@ -114,6 +116,11 @@ function AlertsBody() {
|
|||
problem={error}
|
||||
/>
|
||||
) : null}
|
||||
<StaleNote
|
||||
updatedAt={updatedAt}
|
||||
failed={error !== null}
|
||||
hasData={alerts !== null}
|
||||
/>
|
||||
{!error && alerts === null ? (
|
||||
<TableSkeleton columns={COLUMNS} label="the alerts" />
|
||||
) : null}
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ import {
|
|||
} from "./CreateAgentAgentsMd.js";
|
||||
import {
|
||||
NAME_PATTERN,
|
||||
lastReachableStep,
|
||||
nextStep,
|
||||
previousStep,
|
||||
STEP_TITLES,
|
||||
|
|
@ -285,6 +286,32 @@ export function CreateAgentForm({
|
|||
});
|
||||
const done = result.status === "done";
|
||||
const at = STEPS.indexOf(step);
|
||||
// The tabs go forward again as far as the operator has been, as long as the
|
||||
// steps before are still valid.
|
||||
const [reached, setReached] = useState(0);
|
||||
useEffect(() => {
|
||||
setReached((r) => Math.max(r, at));
|
||||
}, [at]);
|
||||
const firstBad = STEPS.findIndex(
|
||||
(s) =>
|
||||
stepProblem(s, {
|
||||
name,
|
||||
hive,
|
||||
permissionsReady: catalogue !== null,
|
||||
inferenceProblem,
|
||||
}) !== null,
|
||||
);
|
||||
const lastTab = lastReachableStep(reached, firstBad, at);
|
||||
// Why the primary button is off, said in words.
|
||||
const createProblem =
|
||||
step === "summary" && result.status !== "submitting"
|
||||
? !hivesReady
|
||||
? "the hive list has not loaded"
|
||||
: !catalogue
|
||||
? "the permission list has not loaded"
|
||||
: null
|
||||
: null;
|
||||
const shownProblem = problem ?? createProblem;
|
||||
|
||||
// Enter goes on to the next step, and creates only from the summary.
|
||||
function onSubmit(e: Event) {
|
||||
|
|
@ -314,7 +341,7 @@ export function CreateAgentForm({
|
|||
type="button"
|
||||
class={`create-agent-step-tab${s === step ? " create-agent-step-current" : ""}`}
|
||||
aria-current={s === step ? "step" : undefined}
|
||||
disabled={i > at || done}
|
||||
disabled={i > lastTab || done}
|
||||
onClick={() => setStep(s)}
|
||||
>
|
||||
{i + 1}. {STEP_TITLES[s]}
|
||||
|
|
@ -555,9 +582,14 @@ export function CreateAgentForm({
|
|||
>
|
||||
back
|
||||
</Button>
|
||||
{problem !== null && (step !== "identity" || name !== "") && (
|
||||
<Hint as="span" role="status" class="create-agent-hint">
|
||||
{problem}
|
||||
{shownProblem !== null && (
|
||||
<Hint
|
||||
as="span"
|
||||
role="status"
|
||||
class="create-agent-hint"
|
||||
id="create-agent-hint"
|
||||
>
|
||||
{shownProblem}
|
||||
</Hint>
|
||||
)}
|
||||
{step === "summary" ? (
|
||||
|
|
@ -567,6 +599,9 @@ export function CreateAgentForm({
|
|||
disabled={
|
||||
result.status === "submitting" || !hivesReady || !catalogue
|
||||
}
|
||||
describedBy={
|
||||
createProblem !== null ? "create-agent-hint" : undefined
|
||||
}
|
||||
>
|
||||
{result.status === "submitting" ? "creating…" : "create"}
|
||||
</Button>
|
||||
|
|
@ -575,6 +610,9 @@ export function CreateAgentForm({
|
|||
variant="primary"
|
||||
type="submit"
|
||||
disabled={problem !== null}
|
||||
describedBy={
|
||||
problem !== null ? "create-agent-hint" : undefined
|
||||
}
|
||||
>
|
||||
next
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -73,6 +73,21 @@ export function stepProblem(step: Step, input: StepInputs): string | null {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The last step a tab can go to. The tabs reach as far as the operator has
|
||||
* got (`reached`, an index into `STEPS`), but not past a step whose inputs are
|
||||
* not valid now (`firstBad`, its index, or -1 for none), and never behind the
|
||||
* current step (`at`).
|
||||
*/
|
||||
export function lastReachableStep(
|
||||
reached: number,
|
||||
firstBad: number,
|
||||
at: number,
|
||||
): number {
|
||||
const limit = firstBad === -1 ? reached : Math.min(reached, firstBad);
|
||||
return Math.max(limit, at);
|
||||
}
|
||||
|
||||
/** One line of the summary: a setting and what will be sent for it. */
|
||||
export interface SummaryRow {
|
||||
label: string;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import {
|
|||
type RefreshIntervalMs,
|
||||
} from "../../ui/refresh-interval/RefreshInterval.js";
|
||||
import { fetchJson, usePolled } from "../../ui/polled/usePolled.js";
|
||||
import { StaleNote } from "../../ui/polled/StaleNote.js";
|
||||
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
|
||||
import { durationLabel } from "../../util.js";
|
||||
import {
|
||||
|
|
@ -100,6 +101,7 @@ function BuildsBody() {
|
|||
const {
|
||||
data: runs,
|
||||
error,
|
||||
updatedAt,
|
||||
refreshing,
|
||||
} = usePolled(intervalMs, (signal) => fetchJson<BuildRun[]>(RUNS, signal), {
|
||||
cacheKey: "builds",
|
||||
|
|
@ -153,6 +155,11 @@ function BuildsBody() {
|
|||
problem={error}
|
||||
/>
|
||||
) : null}
|
||||
<StaleNote
|
||||
updatedAt={updatedAt}
|
||||
failed={error !== null}
|
||||
hasData={runs !== null}
|
||||
/>
|
||||
{missing ? (
|
||||
<Hint role="status">
|
||||
the build in this link is no longer listed: the builder keeps only its
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
// were changed elsewhere, and the editor offers to reload or to keep the draft
|
||||
// on top of the latest.
|
||||
import { useCallback, useEffect, useState } from "preact/hooks";
|
||||
import { usePageTitle } from "../../shell/page-title.js";
|
||||
import {
|
||||
Link,
|
||||
useLocation,
|
||||
|
|
@ -76,6 +77,7 @@ export function FlowEditorPage({
|
|||
// With `from` an archetype flow: the one agent this copy is for.
|
||||
const agent = search.get("agent");
|
||||
const [, navigate] = useLocation();
|
||||
usePageTitle(isNew ? "new flow" : `flow ${flowId}`);
|
||||
const [view, setView] = useState<FlowsView | null>(null);
|
||||
const [draft, setDraft] = useState<Flow | null>(null);
|
||||
// What a new draft started as, so leaving it untouched is not "unsaved".
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import {
|
|||
type RefreshIntervalMs,
|
||||
} from "../../ui/refresh-interval/RefreshInterval.js";
|
||||
import { fetchJson, usePolled } from "../../ui/polled/usePolled.js";
|
||||
import { StaleNote } from "../../ui/polled/StaleNote.js";
|
||||
import { Deliveries, DeliveriesSkeleton } from "./Deliveries.js";
|
||||
import { FlowListSkeleton } from "./FlowListSkeleton.js";
|
||||
import { NEW_FLOW_PATH, withMembersAs } from "./FlowDraft.js";
|
||||
|
|
@ -45,6 +46,7 @@ export function NotificationRouter() {
|
|||
const {
|
||||
data: view,
|
||||
error,
|
||||
updatedAt,
|
||||
refreshing: flowsRefreshing,
|
||||
refresh,
|
||||
} = usePolled(intervalMs, (signal) =>
|
||||
|
|
@ -126,6 +128,11 @@ export function NotificationRouter() {
|
|||
{error ? (
|
||||
<ApiErrorPanel context="failed to load the flows" problem={error} />
|
||||
) : null}
|
||||
<StaleNote
|
||||
updatedAt={updatedAt}
|
||||
failed={error !== null}
|
||||
hasData={view !== null}
|
||||
/>
|
||||
{actionError ? (
|
||||
<ApiErrorPanel
|
||||
context="the flows were not changed"
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import {
|
|||
type RefreshIntervalMs,
|
||||
} from "../../ui/refresh-interval/RefreshInterval.js";
|
||||
import { fetchJson, usePolled } from "../../ui/polled/usePolled.js";
|
||||
import { StaleNote } from "../../ui/polled/StaleNote.js";
|
||||
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
|
||||
import { TryOutResult } from "../review-common/TryOutResult.js";
|
||||
import { durationLabel } from "../../util.js";
|
||||
|
|
@ -97,6 +98,7 @@ export function ReviewRuns() {
|
|||
const {
|
||||
data: runs,
|
||||
error,
|
||||
updatedAt,
|
||||
refreshing,
|
||||
} = usePolled(
|
||||
intervalMs,
|
||||
|
|
@ -136,6 +138,11 @@ export function ReviewRuns() {
|
|||
{error ? (
|
||||
<ApiErrorPanel context="the runs could not be loaded" problem={error} />
|
||||
) : null}
|
||||
<StaleNote
|
||||
updatedAt={updatedAt}
|
||||
failed={error !== null}
|
||||
hasData={runs !== null}
|
||||
/>
|
||||
{runs !== null && runs.length === 0 && !error ? (
|
||||
<EmptyState>No runs yet.</EmptyState>
|
||||
) : null}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import {
|
|||
type RefreshIntervalMs,
|
||||
} from "../../ui/refresh-interval/RefreshInterval.js";
|
||||
import { fetchJson, usePolled } from "../../ui/polled/usePolled.js";
|
||||
import { StaleNote } from "../../ui/polled/StaleNote.js";
|
||||
import type { TableColumn } from "../../ui/table/Table.js";
|
||||
import type { AgentRow } from "../../agent/AgentTypes.js";
|
||||
import { ScheduleCard, ScheduleListSkeleton } from "./ScheduleCard.js";
|
||||
|
|
@ -64,6 +65,7 @@ function SchedulesBody() {
|
|||
const {
|
||||
data: schedules,
|
||||
error,
|
||||
updatedAt,
|
||||
refreshing: schedulesRefreshing,
|
||||
refresh,
|
||||
} = usePolled(intervalMs, (signal) =>
|
||||
|
|
@ -180,6 +182,11 @@ function SchedulesBody() {
|
|||
{error ? (
|
||||
<ApiErrorPanel context="failed to load the schedules" problem={error} />
|
||||
) : null}
|
||||
<StaleNote
|
||||
updatedAt={updatedAt}
|
||||
failed={error !== null}
|
||||
hasData={schedules !== null}
|
||||
/>
|
||||
{actionError ? (
|
||||
<ApiErrorPanel
|
||||
context="the schedule was not changed"
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import {
|
|||
type RefreshIntervalMs,
|
||||
} from "../../ui/refresh-interval/RefreshInterval.js";
|
||||
import { fetchJson, usePolled } from "../../ui/polled/usePolled.js";
|
||||
import { StaleNote } from "../../ui/polled/StaleNote.js";
|
||||
import { Table, type TableColumn } from "../../ui/table/Table.js";
|
||||
import { TableSkeleton } from "../../ui/table/TableSkeleton.js";
|
||||
import { domainCell } from "../hive-domain.js";
|
||||
|
|
@ -116,6 +117,7 @@ function HiveRoster() {
|
|||
const {
|
||||
data: hives,
|
||||
error,
|
||||
updatedAt,
|
||||
refreshing,
|
||||
} = usePolled(
|
||||
intervalMs,
|
||||
|
|
@ -136,6 +138,11 @@ function HiveRoster() {
|
|||
{error ? (
|
||||
<ApiErrorPanel context="failed to load the hives" problem={error} />
|
||||
) : null}
|
||||
<StaleNote
|
||||
updatedAt={updatedAt}
|
||||
failed={error !== null}
|
||||
hasData={hives !== null}
|
||||
/>
|
||||
{!error && hives === null ? (
|
||||
<TableSkeleton columns={COLUMNS} label="the hives" />
|
||||
) : null}
|
||||
|
|
|
|||
Loading…
Reference in a new issue