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
21 changed files with 321 additions and 25 deletions

View file

@ -43,7 +43,10 @@ Everything it shows comes from [`swarm-controller`](../../../swarm-controller/RE
Pages that refresh on a timer share one polling rule: the page sends no new
request while the last one is still running, so an older answer never overtakes
a slow one, and a failed refresh keeps the rows already on screen under an
error. While a page is fetching, its refresh picker shows a spinner in place of
error. A list that isn't live says so: under a failed refresh it reads "showing the
last answer, from" and the time, and a page opened on the answer saved from the last
visit says that until a fresh one arrives (the alerts, builds, review runs, hives,
schedules and flows lists). While a page is fetching, its refresh picker shows a spinner in place of
the clock, for at least 0.4 seconds so a quick answer still reads as a refresh.
On a folded card (jobs, builds, hives) the picker sits in the card's header, left of the
chevron, and shows once the card is open; selecting it doesn't fold the card.
@ -72,7 +75,8 @@ An agent created here or with `swarmctl agent create` starts `paused`; set it
`up` from its card. A card shows **login needed** when the agent's own
turn-state header says its claude has no session, and a **log in** button
that runs the claude login from a dialog: open the URL it shows, then paste
the code back. When the secret store has the login, the dialog closes and a
the code back. A failed login offers **try again** in the same dialog. When the
secret store has the login, the dialog closes and a
short toast in the top-right corner says so. The credentials go to the agent through the secret store
([`claude-login.md`](../../2-handbook/swarm/claude-login.md)). The agent's own web UI login still
works too. The settings section of an opened card has a **claude login** row: when
@ -80,6 +84,11 @@ the swarm stored the agent's login, or that none is, with a **log in** button
(**log in again** when the swarm holds one) that opens the same dialog, and a **delete
login** action that asks first.
A card shows its freshness when the agent isn't **fresh**: **stale** with how long ago the hive last
reported it, **never reported**, or **not in swarm identity**. A fresh agent shows nothing, so the
badge is the reason a card matched the status filter. A failed state change shows its reason in a panel
under the card's header, not in a hover title.
A card shows **updating** when the agent's status snapshot has `updating` set.
The hive sets it when an update stops a running container and clears it when
the tail reconcile or start settles the agent, whether the container came back
@ -537,7 +546,7 @@ error and the agent gets nothing.
While the agent is in a turn, a **cancel turn** badge appears among the state
badges over the terminal, in its own tab. It asks the agent's harness to stop
the turn, then shows whether one was running ("turn cancelled" or "nothing was
running"); a failure shows "cancel failed" with the reason on hover, and a click
running"); a failure shows "cancel failed: " and the reason in the badge, and a click
tries again. Subagents have no message box and no cancel badge.
The message doesn't go through the agent's hive, so the hive dashboard's

View file

@ -1,6 +1,13 @@
// Root shell component — routing only. Each route's content is its own
// page component under `./pages/`; this file just maps paths to them.
import { Redirect, Route, Router, Switch, useSearch } from "wouter-preact";
import {
Link,
Redirect,
Route,
Router,
Switch,
useSearch,
} from "wouter-preact";
import { MOVED_ROUTES, movedHref } from "./shell/routes.js";
import { Shell } from "./shell/Shell.js";
import { useGuardedLocation } from "./shell/useGuardedLocation.js";
@ -28,6 +35,9 @@ function NotFound() {
return (
<Panel title="404" icon="🧭">
<p>no route here.</p>
<p>
<Link href="/">back to the start page</Link>
</p>
</Panel>
);
}

View file

@ -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>

View file

@ -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 />

View file

@ -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}
/>
);

View file

@ -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}

View file

@ -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>

View file

@ -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;

View file

@ -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

View file

@ -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".

View file

@ -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"

View file

@ -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}

View file

@ -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"

View file

@ -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}

View file

@ -29,6 +29,7 @@
import { useEffect, useRef, useState } from "preact/hooks";
import type { ComponentChildren } from "preact";
import { Link, useLocation } from "wouter-preact";
import { usePageTitleValue } from "./page-title.js";
import { LinksMenu } from "./LinksMenu.js";
import { UserMenu } from "./UserMenu.js";
import { useHideDebug } from "./useHideDebug.js";
@ -408,7 +409,9 @@ export function Shell({ children }: { children: ComponentChildren }) {
// top-level route takes its nav label, a terminal route takes the
// label its page registered as a dynamic tab. An unmatched path gets
// the bare brand.
const pageTitle = usePageTitleValue();
const pageLabel =
pageTitle ??
navItems.find((item) => item.href === location)?.label ??
tabs.find((tab) => tab.href === location)?.label;
useEffect(() => {

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;
}

View file

@ -16,12 +16,15 @@ export function Hint({
tone = "muted",
as: Tag = "p",
role,
id,
class: extraClass,
children,
}: {
tone?: HintTone;
as?: "p" | "span" | "div";
role?: "status" | "alert";
/** For a control's `aria-describedby`: the hint says why it is off. */
id?: string;
class?: string;
children: ComponentChildren;
}) {
@ -30,6 +33,7 @@ export function Hint({
.join(" ");
return (
<Tag
id={id}
class={classes}
role={role ?? (tone === "error" ? "alert" : undefined)}
>

View file

@ -0,0 +1,36 @@
// <StaleNote> — says how old a polled list is when it is not live: under a failed
// refresh it shows the last good answer, and with a `cacheKey` the first paint is
// the answer saved on the last visit. Neither says so by itself, so a list such as
// "nothing is alerting" could be days old without a mark. Renders nothing for a
// list that is current.
import { Hint } from "../hint/Hint.js";
import { RelativeTime } from "../relative-time/RelativeTime.js";
export function StaleNote({
updatedAt,
failed,
hasData,
}: {
/** When the last live answer arrived (`usePolled`), or null if none has. */
updatedAt: number | null;
/** The latest refresh failed. */
failed: boolean;
/** The page has a list to show at all. */
hasData: boolean;
}) {
if (!hasData) return null;
if (updatedAt === null) {
return (
<Hint role="status">
showing the answer saved from your last visit, until a fresh one
arrives.
</Hint>
);
}
if (!failed) return null;
return (
<Hint role="status">
showing the last answer, from <RelativeTime epochMs={updatedAt} />.
</Hint>
);
}

View file

@ -1,4 +1,6 @@
// A resource refetched on a timer: `{ data, error, refreshing, refresh, setData }`.
// `updatedAt` is when the last live answer arrived, for saying how old a list
// is under a failed refresh (`StaleNote`).
// `data` is `null` until the first answer (or, with a `cacheKey`, the saved one
// of the last visit, which is shown at once and replaced by the fresh answer;
// see `answer-cache.ts`); a failed fetch sets `error` and
@ -53,6 +55,9 @@ export function usePolled<T>(
): {
data: T | null;
error: ProblemDetails | null;
/** When the last live answer arrived; null until one has (a saved answer
* from the last visit is not one). */
updatedAt: number | null;
refreshing: boolean;
refresh: () => void;
setData: (update: (prev: T | null) => T | null) => void;
@ -64,6 +69,7 @@ export function usePolled<T>(
cacheKey === undefined ? null : readAnswer<T>(cacheKey),
);
const [error, setError] = useState<ProblemDetails | null>(null);
const [updatedAt, setUpdatedAt] = useState<number | null>(null);
const [refreshing, setRefreshing] = useState(false);
const fetcherRef = useRef(fetcher);
@ -83,6 +89,7 @@ export function usePolled<T>(
}
setData(next);
setError(null);
setUpdatedAt(Date.now());
},
onError: (e) => setError(toProblem(e)),
onBusy: (busy) => hold.busy(busy),
@ -99,5 +106,12 @@ export function usePolled<T>(
);
useRefreshInterval(intervalMs, () => poller.tick());
return { data, error, refreshing, refresh: () => poller.refetch(), setData };
return {
data,
error,
updatedAt,
refreshing,
refresh: () => poller.refetch(),
setData,
};
}

View file

@ -3,6 +3,7 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import {
lastReachableStep,
nameProblem,
nextStep,
previousStep,
@ -99,3 +100,16 @@ test("the summary lists what is sent and what stays at its default", () => {
assert.equal(rows({ permissions: [] }).permissions, "none");
assert.equal(rows({ agentsMd: "x" }).instructions, "AGENTS.md, 1 word");
});
test("the tabs go forward as far as the operator has been, not past a bad step", () => {
// On the summary (4) having been there: every step is open.
assert.equal(lastReachableStep(4, -1, 4), 4);
// Back on the identity step (0) after reaching the summary: still open to 4.
assert.equal(lastReachableStep(4, -1, 0), 4);
// The name went bad (step 0): only the current step is open.
assert.equal(lastReachableStep(4, 0, 0), 0);
// A bad permissions step (2) stops the tabs there.
assert.equal(lastReachableStep(4, 2, 0), 2);
// Never behind the current step.
assert.equal(lastReachableStep(1, 0, 3), 3);
});

Some files were not shown because too many files have changed in this diff Show more