Skip to content

Commit f865c00

Browse files
tlongwell-blocknpub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d
andauthored
feat(desktop): show saved Run on settings when editing an agent (#4539)
## What When editing an agent, show where it runs. The edit dialog previously showed nothing about the backend; the "Where to run" section only existed in the create flow. This adds a read-only **Run on** section to `AgentInstanceEditDialog`: - **Local agents:** "This computer". - **Provider agents (e.g. Kubernetes):** the provider id plus its saved config rows — context, namespace, image, resources, etc. — with labels humanized from the stored keys and rows in provider-schema order (locators first, request/limit pairs adjacent, alphabetical spillover for unknown providers). - Copy states these are the settings **saved at creation** and that the run location can't be changed afterwards (a new agent is required). ## Design decisions (from thread review with @wren + @sami) - **No provider probe on edit.** `info` is executable work, and its schema reflects the plugin *today* (including a freshly generated random namespace default) — not what this agent was deployed with. The stored record is the only honest source. - **Saved settings, not effective settings.** Optional fields a record omits (e.g. `service_account`) are defaulted by the provider at deploy time; we render only what was persisted and never synthesize today's defaults. - **Safe rendering of opaque provider config.** Values render as safe scalars only; arrays/objects degrade to a summary row (React throws on object children — a hand-edited record must not crash the dialog). Falsy-but-present values (`0`, `false`) render honestly. Secret-shaped keys are redacted using the same word-split heuristic as the create-time `validate_provider_config` gate — one definition of "looks like a secret". The gate already blocks such keys on every app write path; display-side redaction is screenshot hygiene and covers hand-edited records. - **`backendAgentId` intentionally excluded:** deploy-time runtime state written on start, not saved creation intent. - **Read-only, no form state.** The backend is immutable post-create (`UpdateManagedAgentRequest` has no backend field), so the section renders straight from `agent.backend` with no reset effect. - `ADVANCED_FIELDS_MOTION_TRANSITION` was duplicated in both agent dialogs; hoisted to `agentConfigOptions` (also keeps the edit dialog inside the file-size ratchet). ## Testing - Unit contract for `summarizeRunOn` (9 tests): scalar honesty incl. `0`/`false`, structured-value fallback, secret redaction fail-safe, preferred ordering with spillover, key humanization. - Playwright spec (4 tests, registered in the smoke project): kubernetes agent with the exact eight-key record a real create flow persisted, local agent, blox agent (`workstation_name`), and redacted secret-shaped keys from a hypothetical future provider. - `pnpm typecheck`, `pnpm check`, full `pnpm test` (3937 pass) green at this head. - Live screenshots posted in the originating Buzz thread. --------- Signed-off-by: Tyler <[email protected]> Co-authored-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz>
1 parent 5e0efb0 commit f865c00

8 files changed

Lines changed: 624 additions & 10 deletions

‎desktop/playwright.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export default defineConfig({
126126
"**/agent-provider-dropdowns.spec.ts",
127127
"**/agent-lifecycle-feedback.spec.ts",
128128
"**/agent-access-warning.spec.ts",
129+
"**/edit-agent-run-on.spec.ts",
129130
"**/inbox-live-update.spec.ts",
130131
"**/mesh-compute.spec.ts",
131132
"**/observer-archive-policy.spec.ts",

‎desktop/src/features/agents/ui/AgentDefinitionDialog.tsx‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
personaBehaviorDraftValid,
3333
} from "./personaBehaviorDraft";
3434
import {
35+
ADVANCED_FIELDS_MOTION_TRANSITION,
3536
AUTO_MODEL_DROPDOWN_VALUE,
3637
AUTO_PROVIDER_DROPDOWN_VALUE,
3738
BLOCK_BUILD_HIDDEN_PROVIDER_IDS,
@@ -118,11 +119,6 @@ export type AgentDefinitionSubmitOptions = {
118119
publishCatalogUpdates: boolean;
119120
};
120121

121-
const ADVANCED_FIELDS_MOTION_TRANSITION = {
122-
duration: 0.18,
123-
ease: [0.23, 1, 0.32, 1],
124-
} as const;
125-
126122
export function AgentDefinitionDialog({
127123
open,
128124
title,

‎desktop/src/features/agents/ui/AgentInstanceEditDialog.tsx‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { Input } from "@/shared/ui/input";
2626
import { setManagedAgentAutoRestart } from "@/shared/api/tauriManagedAgents";
2727
import { EditAgentAdvancedFields } from "./EditAgentAdvancedFields";
2828
import {
29+
ADVANCED_FIELDS_MOTION_TRANSITION,
2930
AUTO_PROVIDER_DROPDOWN_VALUE,
3031
BLOCK_BUILD_HIDDEN_PROVIDER_IDS,
3132
CUSTOM_PROVIDER_DROPDOWN_VALUE,
@@ -65,6 +66,7 @@ import { AgentCreationPreview } from "./AgentCreationPreview";
6566
import type { EnvVarsValue } from "./EnvVarsEditor";
6667
import { useRequiredCredentialState } from "./useRequiredCredentialState";
6768
import { CreateAgentRespondToField } from "./RespondToField";
69+
import { RunOnSummarySection } from "./RunOnSummarySection";
6870
import { PersonaDropdownField } from "./PersonaDropdownField";
6971
import {
7072
MODEL_DISCOVERY_LOADING_VALUE,
@@ -93,11 +95,6 @@ import {
9395
usePendingHarnessSelection,
9496
} from "./addCustomHarness";
9597

96-
const ADVANCED_FIELDS_MOTION_TRANSITION = {
97-
duration: 0.18,
98-
ease: [0.23, 1, 0.32, 1],
99-
} as const;
100-
10198
export function AgentInstanceEditDialog({
10299
agent,
103100
initialFocus,
@@ -949,6 +946,8 @@ export function AgentInstanceEditDialog({
949946
variant="persona"
950947
/>
951948

949+
<RunOnSummarySection backend={agent.backend} />
950+
952951
{/* Provider (runtime) */}
953952
<div className="space-y-1.5">
954953
<label
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import type { ManagedAgentBackend } from "@/shared/api/types";
2+
3+
import { summarizeRunOn } from "./runOnSummary";
4+
5+
/**
6+
* Read-only "Run on" summary for the edit-agent dialog.
7+
*
8+
* Read-only on purpose: `UpdateManagedAgentRequest` has no backend field —
9+
* where an agent runs is fixed at creation (a provider-backed agent's
10+
* deployment holds its private key; there is no migrate operation). This
11+
* section shows the *saved* provider config from the record, without probing
12+
* the provider binary: an edit dialog must not do executable work as a side
13+
* effect, and a live probe would show today's schema defaults instead of
14+
* what this agent actually deployed with.
15+
*
16+
* Named "Run on" (matching the create flow) rather than "Provider" because
17+
* this dialog already uses "Provider" for the ACP harness selector.
18+
*/
19+
export function RunOnSummarySection({
20+
backend,
21+
}: {
22+
backend: ManagedAgentBackend;
23+
}) {
24+
const summary = summarizeRunOn(backend);
25+
26+
return (
27+
<div className="space-y-1.5" data-testid="edit-agent-run-on">
28+
<span className="text-sm font-medium text-foreground">Run on</span>
29+
{summary.location === "local" ? (
30+
<p
31+
className="text-sm text-muted-foreground"
32+
data-testid="edit-agent-run-on-location"
33+
>
34+
This computer
35+
</p>
36+
) : (
37+
<div className="space-y-2 rounded-2xl border border-border bg-muted/30 px-4 py-3">
38+
<p
39+
className="text-sm font-medium"
40+
data-testid="edit-agent-run-on-location"
41+
>
42+
{summary.providerId}
43+
</p>
44+
{summary.rows.length > 0 ? (
45+
<dl className="space-y-1">
46+
{summary.rows.map((row) => (
47+
<div
48+
className="flex flex-wrap items-baseline gap-x-3 gap-y-0.5"
49+
data-testid={`edit-agent-run-on-${row.key}`}
50+
key={row.key}
51+
>
52+
<dt className="text-xs text-muted-foreground">{row.label}</dt>
53+
<dd className="min-w-0 break-all font-mono text-xs text-foreground">
54+
{row.value}
55+
</dd>
56+
</div>
57+
))}
58+
</dl>
59+
) : (
60+
<p className="text-xs text-muted-foreground">
61+
No saved settings — the provider applies its defaults.
62+
</p>
63+
)}
64+
</div>
65+
)}
66+
<p className="text-xs text-muted-foreground">
67+
These are the settings saved when the agent was created. Where an agent
68+
runs can&apos;t be changed afterwards — create a new agent to run
69+
somewhere else.
70+
</p>
71+
</div>
72+
);
73+
}

‎desktop/src/features/agents/ui/agentConfigOptions.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ export const PERSONA_FIELD_CONTROL_CLASS =
3030
export const PERSONA_LABEL_OPTIONAL_CLASS =
3131
"ml-1 text-xs font-normal text-muted-foreground/50";
3232

33+
/** Shared advanced-fields expand/collapse easing for the agent dialogs. */
34+
export const ADVANCED_FIELDS_MOTION_TRANSITION = {
35+
duration: 0.18,
36+
ease: [0.23, 1, 0.32, 1],
37+
} as const;
38+
3339
export const AUTO_MODEL_DROPDOWN_VALUE = "__auto_model__";
3440
export const CUSTOM_MODEL_DROPDOWN_VALUE = "__custom_model__";
3541
export const AUTO_PROVIDER_DROPDOWN_VALUE = "__auto_provider__";
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
import assert from "node:assert/strict";
2+
import test from "node:test";
3+
4+
import { humanizeConfigKey, summarizeRunOn } from "./runOnSummary.ts";
5+
6+
test("local backend summarizes to the local location with no rows", () => {
7+
assert.deepEqual(summarizeRunOn({ type: "local" }), { location: "local" });
8+
});
9+
10+
test("provider backend carries the provider id", () => {
11+
const summary = summarizeRunOn({
12+
type: "provider",
13+
id: "kubernetes",
14+
config: {},
15+
});
16+
assert.equal(summary.location, "provider");
17+
assert.equal(summary.providerId, "kubernetes");
18+
assert.deepEqual(summary.rows, []);
19+
});
20+
21+
test("a saved kubernetes config renders labeled scalar rows", () => {
22+
const summary = summarizeRunOn({
23+
type: "provider",
24+
id: "kubernetes",
25+
config: {
26+
namespace: "buzz-agents-x7k2mp",
27+
image: "ghcr.io/block/buzz-sprig@sha256:17facfc7",
28+
cpu_request: "1",
29+
inactivity_seconds: 7200,
30+
},
31+
});
32+
assert.equal(summary.location, "provider");
33+
const byKey = Object.fromEntries(summary.rows.map((r) => [r.key, r]));
34+
assert.equal(byKey.namespace.label, "Namespace");
35+
assert.equal(byKey.namespace.value, "buzz-agents-x7k2mp");
36+
assert.equal(byKey.cpu_request.label, "CPU request");
37+
assert.equal(byKey.cpu_request.value, "1");
38+
assert.equal(byKey.inactivity_seconds.label, "Inactivity seconds");
39+
assert.equal(byKey.inactivity_seconds.value, "7200");
40+
assert.equal(byKey.image.value, "ghcr.io/block/buzz-sprig@sha256:17facfc7");
41+
assert.ok(summary.rows.every((r) => r.redacted === false));
42+
});
43+
44+
test("rows follow the provider-schema preferred order, spillover alphabetical", () => {
45+
const summary = summarizeRunOn({
46+
type: "provider",
47+
id: "kubernetes",
48+
config: {
49+
// Deliberately shuffled persisted order.
50+
memory_limit: "1Gi",
51+
zeta_extra: "z",
52+
namespace: "n",
53+
cpu_limit: "1",
54+
alpha_extra: "a",
55+
image: "i",
56+
inactivity_seconds: 7200,
57+
cpu_request: "1",
58+
context: "c",
59+
memory_request: "1Gi",
60+
},
61+
});
62+
assert.deepEqual(
63+
summary.rows.map((r) => r.key),
64+
[
65+
"context",
66+
"namespace",
67+
"image",
68+
"cpu_request",
69+
"memory_request",
70+
"cpu_limit",
71+
"memory_limit",
72+
"inactivity_seconds",
73+
"alpha_extra",
74+
"zeta_extra",
75+
],
76+
);
77+
});
78+
79+
test("null, empty-string, boolean, and number values all display honestly", () => {
80+
const summary = summarizeRunOn({
81+
type: "provider",
82+
id: "p",
83+
config: { a_null: null, b_empty: "", c_flag: true, d_num: 0, e_off: false },
84+
});
85+
const values = Object.fromEntries(summary.rows.map((r) => [r.key, r.value]));
86+
assert.equal(values.a_null, "Not set");
87+
assert.equal(values.b_empty, "Not set");
88+
assert.equal(values.c_flag, "true");
89+
// Falsy-but-present values must never read as missing: coerceConfigValues
90+
// emits real numbers/booleans, so `value || fallback` would lie about 0/false.
91+
assert.equal(values.d_num, "0");
92+
assert.equal(values.e_off, "false");
93+
});
94+
95+
test("every row value is a string — objects must never reach React children", () => {
96+
// React throws on an object child, taking down the whole edit dialog.
97+
// A hand-edited managed-agents.json with nested config is exactly the
98+
// record the create-time scalar gate never saw.
99+
const summary = summarizeRunOn({
100+
type: "provider",
101+
id: "p",
102+
config: {
103+
resources: { limits: { cpu: "2" } },
104+
flag: true,
105+
count: 3,
106+
name: "x",
107+
missing: null,
108+
},
109+
});
110+
for (const row of summary.rows) {
111+
assert.equal(typeof row.value, "string", `${row.key} is not a string`);
112+
}
113+
});
114+
115+
test("arrays and objects are summarized, never serialized", () => {
116+
const summary = summarizeRunOn({
117+
type: "provider",
118+
id: "p",
119+
config: {
120+
tolerations: [{ key: "gpu" }, { key: "spot" }],
121+
node_selector: { disktype: "ssd" },
122+
},
123+
});
124+
const values = Object.fromEntries(summary.rows.map((r) => [r.key, r.value]));
125+
assert.equal(values.tolerations, "List (2 items)");
126+
assert.equal(values.node_selector, "Structured value");
127+
// The nested content must not leak through.
128+
assert.ok(!JSON.stringify(values).includes("ssd"));
129+
});
130+
131+
test("secret-shaped keys are redacted, fail-safe for unknown providers", () => {
132+
const summary = summarizeRunOn({
133+
type: "provider",
134+
id: "future-provider",
135+
config: {
136+
api_token: "abc123",
137+
registry_password: "hunter2",
138+
clientSecret: "s3cr3t",
139+
authHeader: "Bearer xyz",
140+
privateKey: "nsec1...",
141+
namespace: "safe-to-show",
142+
},
143+
});
144+
const byKey = Object.fromEntries(summary.rows.map((r) => [r.key, r]));
145+
for (const key of [
146+
"api_token",
147+
"registry_password",
148+
"clientSecret",
149+
"authHeader",
150+
"privateKey",
151+
]) {
152+
assert.equal(byKey[key].redacted, true, `${key} must be redacted`);
153+
assert.equal(byKey[key].value, "••••••••");
154+
}
155+
assert.equal(byKey.namespace.redacted, false);
156+
assert.equal(byKey.namespace.value, "safe-to-show");
157+
// Raw secret bytes must be absent from the whole summary.
158+
const dump = JSON.stringify(summary);
159+
for (const secret of ["abc123", "hunter2", "s3cr3t", "Bearer xyz", "nsec1"]) {
160+
assert.ok(!dump.includes(secret), `${secret} leaked`);
161+
}
162+
});
163+
164+
test("humanizeConfigKey handles snake_case, camelCase, and acronyms", () => {
165+
assert.equal(humanizeConfigKey("cpu_request"), "CPU request");
166+
assert.equal(humanizeConfigKey("memory_limit"), "Memory limit");
167+
assert.equal(humanizeConfigKey("serviceAccount"), "Service account");
168+
assert.equal(humanizeConfigKey("image"), "Image");
169+
assert.equal(humanizeConfigKey("api_url"), "API URL");
170+
assert.equal(humanizeConfigKey(""), "");
171+
});

0 commit comments

Comments
 (0)