From 2c3cfdbedcb41089764853c1501b8983aa5a6cd5 Mon Sep 17 00:00:00 2001 From: Ken Date: Tue, 26 May 2026 20:54:58 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20resolve=20code=20review=20issues=20?= =?UTF-8?q?=E2=80=94=20schema=20mismatch,=20test=20fixes,=20pop-out=20rend?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix a2ui-format.md schema to match renderer: rename 'options' → 'filters' in filters block, replace 'active: boolean' with 'value: string' in filter options, update form select options from string[] to {label, value}[] objects (Critical #1) - Fix 3 failing tests in test_researcher_agent.sh to use @mention paths without .md extension (Important #2) - Complete pop-out feature in VisualBlock.handlePopOut() by posting render message to popup window after 500ms initialization delay (Important #3) - Update test_context_files.sh to match new a2ui-format.md schema (filters array key check, value field check) --- bundle/context/a2ui-format.md | 24 ++++++++++++++---------- frontend/src/components/ChatPanel.tsx | 11 +++++++++++ tests/test_context_files.sh | 4 ++-- tests/test_researcher_agent.sh | 6 +++--- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/bundle/context/a2ui-format.md b/bundle/context/a2ui-format.md index f723710..55c6cff 100644 --- a/bundle/context/a2ui-format.md +++ b/bundle/context/a2ui-format.md @@ -28,20 +28,20 @@ Renders a row of toggle chips. Use for quick category or attribute filtering. ```a2ui { "type": "filters", - "options": [ - { "label": "Toyota", "active": true }, - { "label": "Honda", "active": false }, - { "label": "Hyundai", "active": false }, - { "label": "Under $5K", "active": false } + "filters": [ + { "label": "Toyota", "value": "toyota" }, + { "label": "Honda", "value": "honda" }, + { "label": "Hyundai", "value": "hyundai" }, + { "label": "Under $5K", "value": "under_5k" } ] } ``` | Field | Type | Description | |-------|------|-------------| -| `options` | array | List of filter chips | -| `options[].label` | string | Display text for the chip | -| `options[].active` | boolean | Whether the chip is pre-selected | +| `filters` | array | List of filter chips | +| `filters[].label` | string | Display text for the chip | +| `filters[].value` | string | Machine-readable identifier for the chip | --- @@ -113,7 +113,11 @@ configure a follow-up action. "name": "fuel_type", "type": "select", "label": "Fuel Type", - "options": ["hybrid", "electric", "any"] + "options": [ + { "label": "Hybrid", "value": "hybrid" }, + { "label": "Electric", "value": "electric" }, + { "label": "Any", "value": "any" } + ] } ], "submitLabel": "Search" @@ -127,7 +131,7 @@ configure a follow-up action. | `fields[].type` | string | `"number"`, `"text"`, `"select"` | | `fields[].label` | string | Human-readable label | | `fields[].value` | any | Default value (for `number`/`text` fields) | -| `fields[].options` | string[] | Choice list (for `select` fields) | +| `fields[].options` | `{label, value}[]` | Choice list (for `select` fields); each item has a display `label` and machine-readable `value` | | `submitLabel` | string | Text on the submit button | --- diff --git a/frontend/src/components/ChatPanel.tsx b/frontend/src/components/ChatPanel.tsx index 37d23c7..4063d6d 100644 --- a/frontend/src/components/ChatPanel.tsx +++ b/frontend/src/components/ChatPanel.tsx @@ -76,6 +76,17 @@ function VisualBlock({ w.document.open() w.document.write(html) w.document.close() + // Give the iframe time to initialize, then send the render message + setTimeout(() => { + w.postMessage( + { + jsonrpc: '2.0', + method: 'render', + params: { code: payload.code, data: payload.data ?? {} }, + }, + '*' + ) + }, 500) }) .catch(() => { w.close() diff --git a/tests/test_context_files.sh b/tests/test_context_files.sh index 56ff51e..b1a84c7 100755 --- a/tests/test_context_files.sh +++ b/tests/test_context_files.sh @@ -60,12 +60,12 @@ check_contains "$A2UI" "a2ui fenced code block" '```a2ui' echo "" echo "=== Checking a2ui-format.md: block type 'filters' ===" check_contains "$A2UI" "filters type" '"type": "filters"' -check_contains "$A2UI" "filters options array" '"options"' +check_contains "$A2UI" "filters array key" '"filters"' check_contains "$A2UI" "Toyota option" '"Toyota"' check_contains "$A2UI" "Honda option" '"Honda"' check_contains "$A2UI" "Hyundai option" '"Hyundai"' check_contains "$A2UI" "Under \$5K option" '"Under $5K"' -check_contains "$A2UI" "active field" '"active"' +check_contains "$A2UI" "value field" '"value"' echo "" echo "=== Checking a2ui-format.md: block type 'table' ===" diff --git a/tests/test_researcher_agent.sh b/tests/test_researcher_agent.sh index 156aad4..122b33e 100755 --- a/tests/test_researcher_agent.sh +++ b/tests/test_researcher_agent.sh @@ -128,17 +128,17 @@ check_regex "user can take over via VNC" "VNC|vnc" echo "" echo "=== Checking body: A2UI section ===" check_contains "A2UI section header" "A2UI" -check_contains "a2ui-format.md @mention" "bundle/context/a2ui-format.md" +check_contains "a2ui-format @mention" "bundle/context/a2ui-format" echo "" echo "=== Checking body: Artifacts section ===" check_contains "Artifacts section header" "Artifacts" -check_contains "artifact-conventions.md @mention" "bundle/context/artifact-conventions.md" +check_contains "artifact-conventions @mention" "bundle/context/artifact-conventions" echo "" echo "=== Checking body: Inline Visuals section ===" check_contains "Inline Visuals section header" "Inline Visuals" -check_contains "visual-artifacts.md @mention" "bundle/context/visual-artifacts.md" +check_contains "visual-artifacts @mention" "bundle/context/visual-artifacts" check_regex "proactive visual generation mention" "proactive|visual.*generation|comparison.*table|chart" echo ""