From 53c8adbe90811e1103921c30e4fc11a04e7f0dc0 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Mon, 28 Sep 2026 23:16:36 +0200 Subject: [PATCH] fix(dashboard): adding demo targets selects them by key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Demo-Prüfobjekte hinzufügen" answered "agent returned 400 Bad Request for demo-seed" for every selection: the dashboard sent the targets' display names ("Demo · PLC pump station …"), and the agent selects by manifest key ("plc-pump-station"), so it rejected them as unknown. The dashboard now reads the key the agent lists and selects by it; the display name is only shown. The test's manifest now has the agent's real shape (key and name), which is why it did not catch this. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p --- compliance-dashboard/src/components/demo_targets.rs | 13 +++++++------ .../src/infrastructure/onboarding.rs | 13 ++++++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/compliance-dashboard/src/components/demo_targets.rs b/compliance-dashboard/src/components/demo_targets.rs index 3924174..a15dd4f 100644 --- a/compliance-dashboard/src/components/demo_targets.rs +++ b/compliance-dashboard/src/components/demo_targets.rs @@ -107,14 +107,14 @@ pub fn DemoTargetsButton( for t in targets { DemoTargetRow { target: t.clone(), - checked: selected().contains(&t.name), + checked: selected().contains(&t.key), disabled: source_only && !t.source_only, - on_toggle: move |name: String| { + on_toggle: move |key: String| { let mut v = selected(); - if let Some(p) = v.iter().position(|n| n == &name) { + if let Some(p) = v.iter().position(|k| k == &key) { v.remove(p); } else { - v.push(name); + v.push(key); } selected.set(v); }, @@ -177,7 +177,8 @@ fn DemoTargetRow( on_toggle: EventHandler, ) -> Element { let lang = use_lang()(); - let name = target.name.clone(); + // Selected by manifest key; the display name is only shown. + let key = target.key.clone(); let note = common::NOT_AVAILABLE_HERE.get(lang); let style = if disabled { "display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); opacity: 0.55;" @@ -190,7 +191,7 @@ fn DemoTargetRow( r#type: "checkbox", checked: checked && !disabled, disabled: disabled, - onchange: move |_| on_toggle.call(name.clone()), + onchange: move |_| on_toggle.call(key.clone()), } div { style: "flex: 1; min-width: 0;", div { style: "display: flex; gap: 8px; align-items: center; flex-wrap: wrap;", diff --git a/compliance-dashboard/src/infrastructure/onboarding.rs b/compliance-dashboard/src/infrastructure/onboarding.rs index 919afcb..32a303a 100644 --- a/compliance-dashboard/src/infrastructure/onboarding.rs +++ b/compliance-dashboard/src/infrastructure/onboarding.rs @@ -147,6 +147,10 @@ pub struct ApplicableScansResponse { /// One entry of the demo-target manifest (`GET /api/v1/targets/demo-seed`). #[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)] pub struct DemoSeedTarget { + /// The manifest key: what a seed request selects by. + pub key: String, + /// The display name, prefix included (what the target is called once + /// seeded). pub name: String, #[serde(default)] pub kind: String, @@ -217,7 +221,7 @@ pub fn demo_seed_default_selection(targets: &[DemoSeedTarget], source_only: bool targets .iter() .filter(|t| !source_only || t.source_only) - .map(|t| t.name.clone()) + .map(|t| t.key.clone()) .collect() } @@ -661,8 +665,11 @@ mod tests { fn manifest_parses_and_default_selection_respects_source_only() { let body = serde_json::json!({ "targets": [ - {"name": "plc-pump-station", "kind": "plc_sps", "description": "x", "source_only": true}, - {"name": "web-juice-shop", "kind": "web_app", "description": "y", "source_only": false} + // The agent's shape: a key to select by, and a display name. + {"key": "plc-pump-station", "name": "Demo · PLC pump station", + "kind": "plc_sps", "description": "x", "source_only": true}, + {"key": "web-juice-shop", "name": "Demo · Juice Shop", + "kind": "web_app", "description": "y", "source_only": false} ] }); let list: DemoSeedListResponse = serde_json::from_value(body).unwrap();