Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: mount the create-agent form only while its dialog is open, and list the internet setting

The dialog rendered its form even when closed, so every visit to the agents page
or the start page fetched the hive, permission and archetype lists, a half-filled
form was kept, and the hint to reopen the form for a fresh archetype list was
wrong. It now mounts per open. The summary lists the unrestricted internet box
like every other setting, and create another clears it with the rest. The
swarm-ui doc says both.
This commit is contained in:
iris 2026-11-25 19:21:13 +01:00 • committed by mara
commit 5de0ff59f4
6 changed files with 28 additions and 10 deletions

View file

@ -1096,8 +1096,10 @@ when the controller is old or unreachable.
### Creating an agent
The **+ agent** button opens a dialog of five steps, which you go through in
order with **next** and can step back through with **back** or the step tabs:
The **+ agent** button opens a dialog whose form mounts each time, so it reads
the hive, permission and archetype lists then, and a closed dialog costs no
requests. The dialog has five steps, which you go through in order with
**next** and can step back through with **back** or the step tabs:
1. **identity**: the name, the hive, and optionally an
[archetype](../../2-handbook/swarm/archetypes.md) that fills in the settings of the steps after it.
@ -1115,8 +1117,9 @@ order with **next** and can step back through with **back** or the step tabs:
default. Ticking it adds `unrestricted_internet` to the request.
4. **resources and inference**: the optional resource caps and inference
settings.
5. **summary**: every setting the request will carry, and what stays at its
default, then **what this creates**. **create** is on this step only.
5. **summary**: every setting the request will carry (including the internet
setting), and what stays at its default, then **what this creates**.
**create** is on this step only.
The header, the step tabs and the buttons stay in place and only the step's own
fields scroll, so a long step never pushes **next** out of view. After

View file

@ -270,6 +270,7 @@ export function CreateAgentForm({
setName("");
setAgentsMd("");
pickArchetype("");
setInternet(false);
},
// The text's own refusal shows beside its box, so go back to it.
onError: (problem) => {
@ -535,6 +536,7 @@ export function CreateAgentForm({
caps: capsBody(cpu, memory),
inference: draftBody(inference),
agentsMd,
internet,
}).map((row) => (
<div class="create-agent-summary-row" key={row.label}>
<dt>{row.label}</dt>

View file

@ -112,6 +112,8 @@ export interface SummaryInput {
caps: object;
inference: object;
agentsMd: string;
// The "unrestricted internet" box: a security setting, so it is listed.
internet: boolean;
}
function settings(values: object): string {
@ -142,6 +144,10 @@ export function summaryRows(s: SummaryInput): SummaryRow[] {
? "none"
: s.permissions.join(", "),
},
{
label: "internet",
value: s.internet ? "unrestricted" : "only the allowed domains",
},
{ label: "resource caps", value: settings(s.caps) },
{ label: "inference", value: settings(s.inference) },
{

View file

@ -71,11 +71,13 @@ export function SetupAssistant() {
label="create agent"
plain
>
<CreateAgentForm
initialName="ruth"
initialArchetype={RUTH_ARCHETYPE}
onClose={() => setOpen(false)}
/>
{open ? (
<CreateAgentForm
initialName="ruth"
initialArchetype={RUTH_ARCHETYPE}
onClose={() => setOpen(false)}
/>
) : null}
</Dialog>
</>
);

View file

@ -247,7 +247,9 @@ export function AgentsPage() {
label="create agent"
plain
>
<CreateAgentForm onClose={() => setCreateOpen(false)} />
{createOpen ? (
<CreateAgentForm onClose={() => setCreateOpen(false)} />
) : null}
</Dialog>
{broadcasting ? (
<BroadcastDialog

View file

@ -78,6 +78,7 @@ test("the summary lists what is sent and what stays at its default", () => {
caps: {},
inference: {},
agentsMd: "",
internet: false,
...over,
}).map((r) => [r.label, r.value]),
);
@ -85,6 +86,8 @@ test("the summary lists what is sent and what stays at its default", () => {
assert.equal(plain.name, "ruth");
assert.equal(plain.archetype, "none: a custom agent");
assert.equal(plain.permissions, "the default set");
assert.equal(plain.internet, "only the allowed domains");
assert.equal(rows({ internet: true }).internet, "unrestricted");
assert.equal(plain["resource caps"], "none set");
assert.equal(plain.inference, "none set");
assert.equal(plain.instructions, "none");