Files
buzz/desktop/src/features/agents/ui/RunOnSummarySection.tsx
Tyler f865c0054b 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 <109685178+tlongwell-block@users.noreply.github.com>
Co-authored-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz>
2026-08-03 12:08:29 -04:00

74 lines
2.6 KiB
TypeScript

import type { ManagedAgentBackend } from "@/shared/api/types";
import { summarizeRunOn } from "./runOnSummary";
/**
* Read-only "Run on" summary for the edit-agent dialog.
*
* Read-only on purpose: `UpdateManagedAgentRequest` has no backend field —
* where an agent runs is fixed at creation (a provider-backed agent's
* deployment holds its private key; there is no migrate operation). This
* section shows the *saved* provider config from the record, without probing
* the provider binary: an edit dialog must not do executable work as a side
* effect, and a live probe would show today's schema defaults instead of
* what this agent actually deployed with.
*
* Named "Run on" (matching the create flow) rather than "Provider" because
* this dialog already uses "Provider" for the ACP harness selector.
*/
export function RunOnSummarySection({
backend,
}: {
backend: ManagedAgentBackend;
}) {
const summary = summarizeRunOn(backend);
return (
<div className="space-y-1.5" data-testid="edit-agent-run-on">
<span className="text-sm font-medium text-foreground">Run on</span>
{summary.location === "local" ? (
<p
className="text-sm text-muted-foreground"
data-testid="edit-agent-run-on-location"
>
This computer
</p>
) : (
<div className="space-y-2 rounded-2xl border border-border bg-muted/30 px-4 py-3">
<p
className="text-sm font-medium"
data-testid="edit-agent-run-on-location"
>
{summary.providerId}
</p>
{summary.rows.length > 0 ? (
<dl className="space-y-1">
{summary.rows.map((row) => (
<div
className="flex flex-wrap items-baseline gap-x-3 gap-y-0.5"
data-testid={`edit-agent-run-on-${row.key}`}
key={row.key}
>
<dt className="text-xs text-muted-foreground">{row.label}</dt>
<dd className="min-w-0 break-all font-mono text-xs text-foreground">
{row.value}
</dd>
</div>
))}
</dl>
) : (
<p className="text-xs text-muted-foreground">
No saved settings — the provider applies its defaults.
</p>
)}
</div>
)}
<p className="text-xs text-muted-foreground">
These are the settings saved when the agent was created. Where an agent
runs can&apos;t be changed afterwards — create a new agent to run
somewhere else.
</p>
</div>
);
}