Feedback section closes after collection and links back to the runbook list
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: sonnet Assistant-Process: 295952@bnt-lap001 Assistant-Session: e93f64ad-516c-46eb-9666-aad8d300c477
This commit is contained in:
parent
3938114747
commit
3fc279a6ed
2 changed files with 13 additions and 8 deletions
17
rtut/ui.py
17
rtut/ui.py
|
|
@ -154,20 +154,21 @@ class App:
|
|||
|
||||
def feedback_form(self, i: int, rid: str, r) -> str:
|
||||
fb = R.latest_feedback(r)
|
||||
thanks = ""
|
||||
if fb:
|
||||
face = next(f for k, f, _ in SMILEYS if k == fb["rating"])
|
||||
thanks = (f"<p><b>Thank you.</b> Recorded: {face} {e(fb['comment'] or '(no comment)')} "
|
||||
"<span class=note>You can change it below.</span></p>")
|
||||
btns = " ".join(f"<button name=rating value={k} title='{e(t)}' aria-label='{e(t)}'"
|
||||
f" style='font-size:1.6rem;padding:.1rem .6rem'>{face}</button>"
|
||||
for k, face, t in SMILEYS)
|
||||
return (f"<div id=feedback class=step><h2>How was this runbook?</h2>{thanks}"
|
||||
f"<form method=post action='/run/{i}/{e(rid)}/feedback'>{self.hidden()}"
|
||||
form = (f"<form method=post action='/run/{i}/{e(rid)}/feedback'>{self.hidden()}"
|
||||
"<p class=note>Practicable? Anything that felt strange or unclear, or an idea to make it better. "
|
||||
"Never include secrets.</p>"
|
||||
f"<p><textarea name=comment rows=3 style='width:100%' placeholder='optional comment'>"
|
||||
f"{e(fb['comment']) if fb else ''}</textarea></p><p class=row>{btns}</p></form></div>")
|
||||
f"{e(fb['comment']) if fb else ''}</textarea></p><p class=row>{btns}</p></form>")
|
||||
if fb: # collected: close the section, suggest the next step
|
||||
face = next(f for k, f, _ in SMILEYS if k == fb["rating"])
|
||||
return ("<div id=feedback class=step><p><b>Thank you.</b> Recorded: "
|
||||
f"{face} {e(fb['comment'] or '(no comment)')}</p>"
|
||||
"<p><a href='/'>← Back to the runbook list</a></p>"
|
||||
f"<details><summary class=note>Change my feedback</summary>{form}</details></div>")
|
||||
return f"<div id=feedback class=step><h2>How was this runbook?</h2>{form}</div>"
|
||||
|
||||
def run_page(self, i: int, rid: str, msg: str = "") -> bytes:
|
||||
p = self.packs[i]; r = R.load(p, rid); d = p.data
|
||||
|
|
|
|||
|
|
@ -215,6 +215,10 @@ def test_feedback_form_after_all_steps_done_and_recording(srv):
|
|||
assert st == 303 and loc2.endswith("#feedback")
|
||||
_, _, body = req(srv, "GET", base)
|
||||
assert "Thank you." in body and "step 3 was unclear" in body
|
||||
assert "How was this runbook?" not in body # the section closed once feedback was collected
|
||||
assert "<a href='/'>← Back to the runbook list</a>" in body # the probable next step
|
||||
assert "Change my feedback" in body # the form is still reachable, folded away
|
||||
assert req(srv, "GET", "/")[0] == 200
|
||||
|
||||
|
||||
def test_feedback_validation(srv):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue