fix(dashboard): adding demo targets selects them by key
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 7m0s
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 7m0s
"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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
1 parent
6fe7874ccd
commit
53c8adbe90
2 files changed
+17
-9
No files matched your search
@@ -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<String>,
|
||||
) -> 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;",
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user