Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: retrying a broadcast shows the agents that failed, even ones the filter hides

This commit is contained in:
iris 2026-10-18 02:34:42 +02:00 • committed by mara
commit f65364759f
4 changed files with 33 additions and 3 deletions

View file

@ -25,6 +25,7 @@ import {
import { TextAreaField } from "../../ui/text-area-field/TextAreaField.js";
import {
failedAgents,
filterShowing,
isRunning,
parseResults,
selectedVisible,
@ -130,7 +131,10 @@ export function BroadcastPage() {
}
function retryFailed(results: BroadcastResult[]) {
setTicked(failedAgents(results));
const failed = failedAgents(results);
// Only this page's view changes; the saved choice stays as it was.
setFilterState(filterShowing(filter, all, failed));
setTicked(failed);
setSend({ status: "idle" });
}

View file

@ -38,6 +38,20 @@ export function selectedVisible(
return ticked.filter((name) => shown.has(name));
}
/**
* The filter to show `names` under: `filter` itself when it shows them all,
* otherwise `all`. A resend to agents that failed must show them ticked, and
* the failures are often the agents the `running` filter hides.
*/
export function filterShowing(
filter: AgentFilter,
agents: BroadcastAgent[],
names: string[],
): AgentFilter {
const shown = new Set(visibleAgents(agents, filter).map((a) => a.name));
return names.every((n) => shown.has(n)) ? filter : "all";
}
/** `ticked` with `name` flipped. */
export function toggled(ticked: string[], name: string): string[] {
return ticked.includes(name)

View file

@ -5,6 +5,7 @@ import assert from "node:assert/strict";
import { test } from "node:test";
import {
failedAgents,
filterShowing,
MAX_BROADCAST,
isRunning,
parseResults,
@ -94,3 +95,14 @@ test("an answer that is not the agreed shape is null, not an empty list", () =>
test("one broadcast may name at most 64 agents", () => {
assert.equal(MAX_BROADCAST, 64);
});
test("a retry shows the failed agents even when the filter hides them", () => {
const agents = [
{ name: "a", snapshot: { running: true } },
{ name: "b", snapshot: { running: false } },
];
assert.equal(filterShowing("running", agents, ["a"]), "running");
assert.equal(filterShowing("running", agents, ["a", "b"]), "all");
assert.equal(filterShowing("running", agents, ["b"]), "all");
assert.equal(filterShowing("all", agents, ["b"]), "all");
});