Take a failed turn's streamed words away with its bubble
A bubble that had started streaming had become a draft and left the bubbles map, so a failure could not remove it, and settle() removed only cancelled drafts: the half-written answer stayed under the failure notice. A failed turn's draft now goes as a cancelled one does, with any spark still on it. TestAskThinkingBubble streams words before failing the turn and checks that no bubble, draft, canvas or line with those words is left.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+20
−3
internal/browsertest/thinking_test.go+14 −0internal/look/static/ask.js+6 −3
diff --git a/internal/browsertest/thinking_test.go b/internal/browsertest/thinking_test.go| index bd524b2..0d520ed 100644 |
| --- a/internal/browsertest/thinking_test.go |
| +++ b/internal/browsertest/thinking_test.go |
| @@ -189,6 +189,20 @@ func TestAskThinkingBubble(t *testing.T) { |
| if n := th.eval(`document.querySelectorAll("#ask-panel canvas").length + ""`); n != "0" { |
| t.Errorf("failed, %s canvases", n) |
| } |
| + // Failing after some words have streamed in takes them away too. |
| + id = th.send("Try this again") |
| + f.Stream(id, "Half an answer that never") |
| + th.wait(`document.querySelector("#ask-panel .msg.draft")?.textContent === "Half an answer that never"`) |
| + f.FailTurn(id) |
| + th.wait(`document.querySelector("#ask-panel form.composer button.stop").hidden`) |
| + drive(t, rig, chromedp.Sleep(200*time.Millisecond)) |
| + if got := th.eval(`document.querySelectorAll("#ask-panel .thinking, #ask-panel .draft, #ask-panel canvas").length + " " + |
| + [...document.querySelectorAll("#ask-panel .msg.coordinator")].filter(m => m.textContent.includes("Half an answer")).length`); got != "0 0" { |
| + t.Errorf("failed while streaming: bubbles, drafts and canvases, then lines with its words %s, want 0 0", got) |
| + } |
| + if got := th.eval(statusJS); got != `"That didn't get an answer. Try again." shown` { |
| + t.Errorf("failed while streaming, the status line is %s", got) |
| + } |
| // A team_update turn is quiet: no bubble. |
| f.Hold = false |
diff --git a/internal/look/static/ask.js b/internal/look/static/ask.js| index 081fa3e..0c1f1ad 100644 |
| --- a/internal/look/static/ask.js |
| +++ b/internal/look/static/ask.js |
| @@ -1066,12 +1066,15 @@ function start(root) { |
| settle(t); |
| } |
| // settle ends the drafts of turn t (every draft when there is none): a |
| - // cancelled turn's goes, the rest stay as written. |
| + // cancelled or failed turn's goes, with any spark still on it (the |
| + // failure is said in the status line); the rest stay as written. |
| function settle(t) { |
| for (const d of thread.querySelectorAll("[data-draft]")) { |
| if (!t || d.dataset.draft === t.id) { |
| - if (t && t.state === "cancelled") d.remove(); |
| - else d.removeAttribute("aria-busy"); |
| + if (t && (t.state === "cancelled" || t.state === "failed")) { |
| + spark.stop(d, true); |
| + d.remove(); |
| + } else d.removeAttribute("aria-busy"); |
| } |
| } |
| } |