Watch
0
0
Fork
You've already forked hyperhive
0

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:
iris 2026-11-19 18:59:20 +01:00 • committed by mara
commit 679d2ee420

View file

@ -0,0 +1,44 @@
// The title a page gives itself, for the browser tab and the page's heading: for
// a route the shell cannot name from its nav items or open tabs, such as the
// flow editor, where several tabs would otherwise all read as the bare brand.
// A page calls `usePageTitle("flow fan-out")`; the shell reads it with
// `usePageTitleValue()` and falls back to its own label when none is set.
import { useEffect, useState } from "preact/hooks";
let current: string | undefined;
const listeners = new Set<() => void>();
/** Set the page's title (or clear it with `undefined`). */
export function setPageTitle(title: string | undefined): void {
if (current === title) return;
current = title;
listeners.forEach((fn) => fn());
}
export function getPageTitle(): string | undefined {
return current;
}
/** Subscribe to changes; returns the way to stop. */
export function subscribePageTitle(fn: () => void): () => void {
listeners.add(fn);
return () => listeners.delete(fn);
}
/** Give the page this title while it is mounted. */
export function usePageTitle(title: string | undefined): void {
useEffect(() => {
setPageTitle(title);
return () => setPageTitle(undefined);
}, [title]);
}
/** The title a page has set, if any, following changes. */
export function usePageTitleValue(): string | undefined {
const [title, setTitle] = useState(getPageTitle());
useEffect(() => {
setTitle(getPageTitle());
return subscribePageTitle(() => setTitle(getPageTitle()));
}, []);
return title;
}