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:
parent
975b43ce0e
commit
5de0ff59f4
5 changed files with 28 additions and 10 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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) },
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -247,7 +247,9 @@ export function AgentsPage() {
|
|||
label="create agent"
|
||||
plain
|
||||
>
|
||||
<CreateAgentForm onClose={() => setCreateOpen(false)} />
|
||||
{createOpen ? (
|
||||
<CreateAgentForm onClose={() => setCreateOpen(false)} />
|
||||
) : null}
|
||||
</Dialog>
|
||||
{broadcasting ? (
|
||||
<BroadcastDialog
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue