From 9587a4b3e3b1bd3f34e73f3ea21b85217f3f16a1 Mon Sep 17 00:00:00 2001 From: Alex J Lennon Date: Mon, 10 Aug 2026 09:31:09 +0100 Subject: [PATCH] fix MCQ banner: stop repeating the question under Policy chrome Dangerous/action-class strips showed prefix + full question while #question already rendered the ask, so Policy MCQs looked doubled. Co-authored-by: Cursor --- scripts/test_nebula_layout.py | 15 +++++++++++++++ src/ask_question_mcp/assets/dialog/dialog.js | 14 ++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/scripts/test_nebula_layout.py b/scripts/test_nebula_layout.py index 2a958bd..d25533c 100644 --- a/scripts/test_nebula_layout.py +++ b/scripts/test_nebula_layout.py @@ -44,6 +44,21 @@ def test_freeform_inside_main_body() -> None: assert 'id="listen-btn"' in html +def test_banner_does_not_repeat_question() -> None: + """Dangerous chrome strip must not paste the full question (looks doubled).""" + js = ( + ROOT / "src" / "ask_question_mcp" / "assets" / "dialog" / "dialog.js" + ).read_text(encoding="utf-8") + assert 'banner-copy").textContent' in js or "$(\"#banner-copy\")" in js + # Old bug: `${prefix}${payload.question || ""}` + assert "${prefix}${payload.question" not in js, ( + "REGRESSION: banner-copy must not append payload.question " + "(question already shown in #question)" + ) + assert "prefix}${payload.question" not in js + + if __name__ == "__main__": test_freeform_inside_main_body() + test_banner_does_not_repeat_question() print("test_nebula_layout: ok") diff --git a/src/ask_question_mcp/assets/dialog/dialog.js b/src/ask_question_mcp/assets/dialog/dialog.js index b776cb1..fbf977e 100644 --- a/src/ask_question_mcp/assets/dialog/dialog.js +++ b/src/ask_question_mcp/assets/dialog/dialog.js @@ -697,12 +697,14 @@ for (const b of BANDS) banner.classList.remove(`is-${b}`); if (bandClass) banner.classList.add(bandClass); else if (dangerous) banner.classList.add("is-danger"); - const prefix = - payload.banner_prefix || - (dangerous ? "⛔ Confirm — " : ""); - $("#banner-copy").textContent = dangerous - ? `${prefix}${payload.question || ""}` - : ""; + // Band strip only — never paste the question here (eyebrow + #question + // already carry the ask; repeating it made dangerous MCQs look doubled). + const prefix = String( + payload.banner_prefix || (dangerous ? "⛔ Confirm" : ""), + ) + .replace(/\s*[—\-–:]\s*$/, "") + .trim(); + $("#banner-copy").textContent = dangerous ? prefix : ""; const ok = $("#ok-btn"); for (const b of BANDS) ok.classList.remove(`is-${b}`);