Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions scripts/test_nebula_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
14 changes: 8 additions & 6 deletions src/ask_question_mcp/assets/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down