oficina / base Public

Draw the Assistant's jobs as pills with their cards

A job card is now a pill in the chat, never a generic card: its state's
mark (the working one turns, and holds still with reduced motion), the
title and its status, and a link once there is something to see (ready,
done). The job's own page link is not drawn; the job view stub is where
it will go. Go-ahead and Publish cards that belong to a job hang under
its pill, on the server and in ask.js, and stay there when the pill is
redrawn (ruling P6j). team_update turns are quiet (D9): no status line,
activity or Stop. Pending copy rows for how the pill joins title and
status.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 92ff352a95ab24201bca613804092270e76b5628 parent 4a9ffe2
8 files changed, +573 −19
  • docs/copy-pending.md +7 −0
  • internal/browsertest/cards_test.go +140 −0
  • internal/equipo/chat.go +5 −0
  • internal/look/static/app.css +75 −2
  • internal/look/static/ask.js +109 −2
  • internal/web/ask.go +53 −13
  • internal/web/templates/partials/chat.html +12 −2
  • internal/webtest/ask_test.go +172 −0
diff --git a/docs/copy-pending.md b/docs/copy-pending.md
index b3cd483..752a620 100644
--- a/docs/copy-pending.md
+++ b/docs/copy-pending.md
@@ -370,3 +370,10 @@ Pending review (not part of Review 8): D12's reuse of the chat's lead on the set
| home.html | PENDING (D18): the header's Base button, which opens the docked chat; its name, now also its tooltip, is the approved label of the Ask icon it replaces | Ask Base |
| home.html | PENDING (D18): the field under the greeting that opens the chat, with its "/" hint; the approved placeholder, now on a button | Ask Base anything |
| home.html | REMOVED (D18): with Ask off Home has no field, so the disabled field and its tooltip go | ~~Asking Base arrives in a later slice~~ |
+
+Pending review (Task 18, job pills): a job shows as a pill in the chat. Its title, status and link label come from the Assistant (Equipo's copy); Base adds only how they are joined.
+
+| File | Context | Text |
+|---|---|---|
+| partials/chat.html, ask.js | PENDING: a job's pill, between the job's title and its status (drawn by the stylesheet, app.css) | {title} · {status} |
+| partials/chat.html, ask.js | PENDING: the pill's name for screen readers, which also says the status when a narrow chat hides it beside the link | {title}, {status} |
diff --git a/internal/browsertest/cards_test.go b/internal/browsertest/cards_test.go
index c4844e8..0078b20 100644
--- a/internal/browsertest/cards_test.go
+++ b/internal/browsertest/cards_test.go
@@ -3,6 +3,7 @@
package browsertest
import (
+ "fmt"
"strconv"
"strings"
"testing"
@@ -76,3 +77,142 @@ func TestAskCardsInPanel(t *testing.T) {
}
rig.Screen("#ask-panel", "the panel with the Assistant's cards")
}
+
+// jobJS is a summary of the job with id in the panel: how many li.job
+// there are, then the job's state, status, link and the ids of the cards
+// under it, or "none".
+func jobJS(id string) string {
+ return `(() => { const all = document.querySelectorAll("#ask-panel li.job"), j = document.querySelector('#ask-panel li.job[data-job="` + id + `"]');
+ if (!j) return all.length + " none";
+ const link = j.querySelector(".pill-link");
+ return all.length + " " + j.dataset.state + " " + j.querySelector(".pill-stage").textContent + " [" + (link ? link.textContent : "") + "] " +
+ [...j.querySelectorAll("ol.job-cards > li")].map(c => c.dataset.card).join(","); })()`
+}
+
+// A job is one pill, updated in place as it moves: one li.job throughout,
+// its state, status and name following each revision. A team_update turn
+// is quiet: its activity sets no status line and it shows no Stop.
+func TestAskJobPillInPanel(t *testing.T) {
+ rig, f := askBase(t)
+ openPanel(t, rig)
+ wait := func(js string) {
+ t.Helper()
+ drive(t, rig, chromedp.Poll[chromedp.Void](js, chromedp.WithPollingTimeout(10*time.Second)))
+ }
+ f.Say("On it.")
+ id := f.AskJob("Building your website")
+ is := func(want string) {
+ t.Helper()
+ wait(jobJS(id) + ` === ` + strconv.Quote(want))
+ }
+ is("1 working Getting started [] ")
+ if got := harness.Evaluate[string](rig, `(() => { const j = document.querySelector("#ask-panel li.job"), p = [];
+ if (j.querySelector(".card, .card-link")) p.push("drawn as a card");
+ if (j.querySelector(".pill-title").textContent !== "Building your website") p.push("title " + j.querySelector(".pill-title").textContent);
+ if (j.querySelector("summary.pill-main").getAttribute("aria-label") !== "Building your website, Getting started") p.push("name " + j.querySelector("summary").getAttribute("aria-label"));
+ if (j.querySelector(".state-mark svg")) p.push("working has an icon");
+ if (!getComputedStyle(j.querySelector(".state-mark"), "::after").animationName.includes("turn")) p.push("working mark still");
+ if (/equipo/i.test(document.querySelector("#ask-panel").innerText) || document.querySelector('#ask-panel a[href*="/jobs/"]')) p.push("names Equipo or links its page");
+ return p.join("; "); })()`); got != "" {
+ t.Errorf("the working pill: %s", got)
+ }
+ rig.Screen("#ask-panel", "a job's pill, working")
+ // With reduced motion the working mark holds still.
+ drive(t, rig, reducedMotion("dark", true))
+ if got := harness.Evaluate[string](rig, `(() => { const m = document.querySelector("#ask-panel li.job .state-mark");
+ return getComputedStyle(m, "::after").animationName + " " + getComputedStyle(m, "::before").animationName; })()`); got != "none none" {
+ t.Errorf("the working mark with reduced motion: %s", got)
+ }
+ drive(t, rig, reducedMotion("dark", false))
+ f.SetJob(id, "working", "Building it", "Writing the pages.")
+ is("1 working Building it [] ")
+ // A link shows only once there is something to see.
+ try := equipo.Link{Label: "Try it", URL: "https://preview.example.test/"}
+ f.SetJob(id, "asking", "One question for you", "Waiting for your answer.", try)
+ is("1 asking One question for you [] ")
+ f.SetJob(id, "ready", "Ready to try", "Have a look.", try)
+ is("1 ready Ready to try [Try it] ")
+ if got := harness.Evaluate[string](rig, `(() => { const j = document.querySelector("#ask-panel li.job"), a = j.querySelector(".pill-link");
+ return j.dataset.revision + " " + j.querySelector("summary").getAttribute("aria-label") + " " + a.href + " " + a.target + " " + a.rel + " " + !!j.querySelector(".state-mark svg"); })()`); got != "4 Building your website, Ready to try https://preview.example.test/ _blank noopener true" {
+ t.Errorf("the ready pill: %s", got)
+ }
+ rig.Screen("#ask-panel", "a job's pill, ready")
+
+ // A quiet turn: running, with an activity line, and neither shows.
+ turn := f.EmitTurn("team_update", "running")
+ f.Emit("activity", map[string]string{"turn_id": turn, "label": "Looking at the job"})
+ f.Say("Have a look.")
+ wait(`[...document.querySelectorAll("#ask-panel .msg.coordinator")].some(m => m.textContent === "Have a look.")`)
+ drive(t, rig, chromedp.Sleep(200*time.Millisecond))
+ if got := harness.Evaluate[string](rig, `JSON.stringify(document.querySelector("#ask-panel .ask-status").textContent) + " " +
+ document.querySelector("#ask-panel form.composer button.stop").hidden + " " + document.querySelector("#ask-panel form.cancel").getAttribute("action")`); got != `"" true /ask` {
+ t.Errorf("with a team_update turn running: status, Stop hidden, cancel %s", got)
+ }
+}
+
+// Ruling P6j: the go-ahead under a ready pill stays under it as the job is
+// redrawn, still ready and then working again; answering it posts its
+// value; a Publish card that arrives after the redraw lands under the same
+// pill. A card that comes before its job is drawn joins it when it is.
+func TestAskJobKeepsItsCards(t *testing.T) {
+ rig, f := askBase(t)
+ // The docked chat at its widest, where a ready pill has room for its
+ // status beside its link.
+ drive(t, rig, chromedp.EmulateViewport(1500, 900))
+ openPanel(t, rig)
+ wait := func(js string) {
+ t.Helper()
+ drive(t, rig, chromedp.Poll[chromedp.Void](js, chromedp.WithPollingTimeout(10*time.Second)))
+ }
+ options := []equipo.Option{{Value: "go", Label: "Go ahead"}, {Value: "later", Label: "Not yet"}}
+ try := equipo.Link{Label: "Try it", URL: "https://preview.example.test/"}
+ id := f.AskJob("Building your website")
+ f.SetJob(id, "ready", "Ready to try", "Have a look.", try)
+ goAhead := f.AskOutcomeFor(id, "This is ready. Go ahead?", options, nil)
+ wait(jobJS(id) + ` === ` + strconv.Quote("1 ready Ready to try [Try it] "+goAhead))
+ rig.Screen("#ask-panel", "a ready pill with its go-ahead")
+ // Legible in the dark and in the light.
+ for _, scheme := range []string{"dark", "light"} {
+ drive(t, rig, prefersScheme(scheme), chromedp.Sleep(300*time.Millisecond))
+ mobileShot(t, rig, "job-ready-"+scheme)
+ checkContrast(t, rig, "a ready pill, "+scheme, "#ask-panel .pill-title", "#ask-panel .pill-stage", "#ask-panel .pill-link")
+ }
+ drive(t, rig, prefersScheme("dark"))
+ f.SetJob(id, "ready", "Ready to try", "Still ready.", try)
+ wait(`document.querySelector('#ask-panel li.job').dataset.revision === "3" && ` + jobJS(id) + ` === ` + strconv.Quote("1 ready Ready to try [Try it] "+goAhead))
+ f.SetJob(id, "working", "Almost ready", "Putting the finishing touches on it.")
+ wait(jobJS(id) + ` === ` + strconv.Quote("1 working Almost ready [] "+goAhead))
+ if n := harness.Evaluate[int](rig, `document.querySelectorAll('#ask-panel [data-card="`+goAhead+`"]').length`); n != 1 {
+ t.Fatalf("the go-ahead is drawn %d times", n)
+ }
+
+ card := `#ask-panel li.job ol.job-cards [data-card="` + goAhead + `"]`
+ drive(t, rig, chromedp.Click(chromedp.CSS(card+` button[value="go"]`)))
+ wait(`document.querySelector(` + strconv.Quote(card+` .card-state`) + `)?.textContent === "Go ahead"`)
+ if c := f.Calls("/api/v1/assistant/cards/" + goAhead + "/answer"); len(c) != 1 || strings.TrimSpace(c[0].Body) != `{"choice":"go","revision":1}` {
+ t.Fatalf("answers: %+v", c)
+ }
+ f.SetJob(id, "ready", "Ready to publish", "Publish it when you're happy.", try)
+ publish := f.AskOutcomeFor(id, "Your site is ready. Publish it?", options, nil)
+ wait(jobJS(id) + ` === ` + strconv.Quote("1 ready Ready to publish [Try it] "+goAhead+","+publish))
+
+ // A card of a job not yet drawn is loose, and moves under it when the
+ // job arrives. (The fake numbers its cards in turn: the next job is
+ // the card after this one.)
+ early := f.AskOutcomeFor("", "Go ahead with the other one?", options, nil)
+ n, err := strconv.Atoi(strings.TrimPrefix(early, "c_"))
+ if err != nil {
+ t.Fatalf("card id %q", early)
+ }
+ later := f.AskOutcomeFor(fmt.Sprintf("c_%04d", n+2), "And this one?", options, nil)
+ wait(`!!document.querySelector('#ask-panel .thread > [data-card="` + later + `"]')`)
+ other := f.AskJob("Fixing the login")
+ if other != fmt.Sprintf("c_%04d", n+2) {
+ t.Fatalf("the next job is %s", other)
+ }
+ wait(jobJS(other) + ` === ` + strconv.Quote("2 working Getting started [] "+later))
+ rig.Screen("#ask-panel", "two pills with their cards")
+ if got := harness.Evaluate[string](rig, `[...document.querySelectorAll("#ask-panel .thread > li")].map(l => l.dataset.job ? "job" : l.dataset.card ? "card" : "msg").join(",")`); got != "job,card,job" {
+ t.Errorf("the thread: %s", got)
+ }
+}
diff --git a/internal/equipo/chat.go b/internal/equipo/chat.go
index 958a0be..8e4331a 100644
--- a/internal/equipo/chat.go
+++ b/internal/equipo/chat.go
@@ -18,6 +18,11 @@ const (
TurnCancelled = "cancelled"
)
+// TurnTeamUpdate is the kind of turn the Assistant takes by itself when a
+// job it handed on changes. It is quiet: Base shows no status, activity or
+// Stop for it.
+const TurnTeamUpdate = "team_update"
+
// InFlight reports whether a turn in state has not ended.
func InFlight(state string) bool {
return state == TurnQueued || state == TurnRunning || state == TurnWaiting
diff --git a/internal/look/static/app.css b/internal/look/static/app.css
index 30223b5..c76e981 100644
--- a/internal/look/static/app.css
+++ b/internal/look/static/app.css
@@ -112,6 +112,16 @@
--theirs-edge: rgba(238,242,248,.16);
--card: rgba(139,92,246,.16);
--card-edge: rgba(139,92,246,.45);
+ /* A job's pill, and the colours of its states: working, ready and done
+ are the accent; asking is warm; stopped is rose. --st-wash is how much
+ of the state's colour is washed in behind the pill. */
+ --pill: rgba(238,242,248,.11);
+ --pill-edge: rgba(238,242,248,.26);
+ --pill-shine: rgba(255,255,255,.2);
+ --pill-lift: rgba(6,8,22,.55);
+ --st-ask: #FFB066;
+ --st-stop: #F9A8D4;
+ --st-wash: .2;
}
:root[data-theme="light"] {
color-scheme: light; --sky-stop: 55%; --glass-lift: -22px;
@@ -140,7 +150,9 @@
--sheet-1: rgba(255,255,255,.82); --sheet-2: rgba(255,255,255,.72); --sheet-base: rgba(244,245,252,.6);
--scrim: rgba(30,36,64,.18); --mine: rgba(15,168,156,.14); --mine-edge: rgba(15,168,156,.38);
--theirs: rgba(255,255,255,.88); --theirs-edge: rgba(30,36,64,.1); --card: rgba(139,92,246,.1);
- --card-edge: rgba(124,77,232,.35);
+ --card-edge: rgba(124,77,232,.35); --pill: rgba(255,255,255,.94); --pill-edge: rgba(30,36,64,.16);
+ --pill-shine: rgba(255,255,255,1); --pill-lift: rgba(40,46,90,.28); --st-ask: #C0651A;
+ --st-stop: #C2366F; --st-wash: .13;
}
:root[data-theme="dark"] { color-scheme: dark; }
@supports (color: light-dark(white, black)) {
@@ -219,11 +231,17 @@
--theirs-edge: light-dark(rgba(30,36,64,.1), rgba(238,242,248,.16));
--card: light-dark(rgba(139,92,246,.1), rgba(139,92,246,.16));
--card-edge: light-dark(rgba(124,77,232,.35), rgba(139,92,246,.45));
+ --pill: light-dark(rgba(255,255,255,.94), rgba(238,242,248,.11));
+ --pill-edge: light-dark(rgba(30,36,64,.16), rgba(238,242,248,.26));
+ --pill-shine: light-dark(rgba(255,255,255,1), rgba(255,255,255,.2));
+ --pill-lift: light-dark(rgba(40,46,90,.28), rgba(6,8,22,.55));
+ --st-ask: light-dark(#C0651A, #FFB066);
+ --st-stop: light-dark(#C2366F, #F9A8D4);
}
/* The few values that are not colours follow the device too. */
@media (prefers-color-scheme: light) {
:root:not([data-theme="dark"]) { --sky-stop: 55%; --glass-lift: -22px;
- --fog-1-a: .28; --fog-2-a: .26; --fog-3-a: .2; --fog-4-a: .55; }
+ --fog-1-a: .28; --fog-2-a: .26; --fog-3-a: .2; --fog-4-a: .55; --st-wash: .13; }
}
}
* { box-sizing: border-box; }
@@ -498,6 +516,58 @@ aside.ask-panel { position: absolute; top: 16px; right: 16px; bottom: 16px; widt
.card-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 500; }
.msg.card .card-state { margin: 0; color: var(--haze); font-size: 14px; }
.msg.card .choices + .card-state { margin-top: 10px; }
+/* A job: a compact pill in the conversation, updated in place. A capsule,
+ not a bubble: its own surface and edge, a lift, a state mark on the left
+ and the state's colour washed in behind it. One line: when space runs
+ short the status gives way first (down to a few letters), then the
+ title; the link beside it never does. */
+.job { align-self: flex-start; max-width: 100%; display: flex; flex-direction: column; gap: 6px; }
+.job[data-state="working"], .job[data-state="ready"], .job[data-state="done"] { --st: var(--signal); }
+.job[data-state="asking"] { --st: var(--st-ask); }
+.job[data-state="stopped"] { --st: var(--st-stop); }
+.pill { position: relative; display: flex; align-items: center; max-width: 100%; min-height: 44px; border-radius: 999px;
+ background: linear-gradient(90deg, color-mix(in srgb, var(--st) calc(var(--st-wash) * 100%), transparent), transparent 70%), var(--pill);
+ box-shadow: inset 0 0 0 1px var(--pill-edge), inset 0 1px 0 var(--pill-shine), 0 8px 18px -10px var(--pill-lift); transition: box-shadow .2s; }
+.pill:has(.pill-main:hover) { box-shadow: inset 0 0 0 1px var(--accent-edge), inset 0 1px 0 var(--pill-shine), 0 8px 18px -10px var(--pill-lift); }
+.job-toggle { flex: 0 1 auto; min-width: 0; }
+.pill-main { min-width: 0; min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 14px 0 8px; border-radius: 999px;
+ list-style: none; cursor: pointer; font-size: 13.5px; line-height: 20px; white-space: nowrap; }
+.pill-main::-webkit-details-marker { display: none; }
+.pill-main:focus-visible { outline-offset: 2px; }
+.pill-title { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
+.pill-stage { flex: 0 1000 auto; min-width: 4.5em; overflow: hidden; text-overflow: ellipsis; color: var(--haze); font-size: 13px; }
+.pill-stage::before { content: "·"; margin: 0 6px 0 0; }
+.pill-link { flex: none; align-self: stretch; display: flex; align-items: center; margin-left: -5px; padding: 0 14px 0 10px; border-radius: 0 999px 999px 0;
+ font-size: 13.5px; font-weight: 600; color: var(--focus); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap;
+ box-shadow: inset 1px 0 0 var(--pill-edge); }
+/* A narrow chat (the docked chat at its narrowest, small phones): when the
+ pill carries a link, the link says the status ("Try it"), so the status
+ steps out. It stays in the pill's accessible name. */
+.thread { container-type: inline-size; }
+@container (max-width: 364px) { .pill:has(.pill-link) .pill-stage { display: none; } }
+/* The state mark: a disc. Working is a slow arc round a breathing dot; the
+ rest are still icons on the state's colour. */
+.state-mark { flex: none; position: relative; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--on-signal); }
+.state-mark svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
+.job[data-state="working"] .state-mark { background: color-mix(in srgb, var(--st) 14%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--st) 26%, transparent); }
+.job[data-state="working"] .state-mark::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--st);
+ animation: turn 1.6s cubic-bezier(.5,.15,.5,.85) infinite; }
+.job[data-state="working"] .state-mark::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--st); animation: glow 1.6s ease-in-out infinite alternate; }
+.job:not([data-state="working"]) .state-mark { background: var(--st); }
+@keyframes turn { to { transform: rotate(1turn); } }
+@keyframes glow { from { opacity: .45; } }
+/* The job view, opened from the pill, for now its status line, just below
+ it. */
+.job-toggle > .jobview { position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; min-width: 200px; max-width: 100%; padding: 10px 16px; border-radius: 14px;
+ background: var(--menu-base); box-shadow: inset 0 0 0 1px var(--pill-edge), 0 22px 48px -14px var(--menu-shadow); }
+.jv-stage { margin: 0; font-size: 14px; }
+/* The person's decisions for a job (its go-ahead, Publish) hang under its
+ pill, joined to it by a thread line. */
+.job-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
+.job-cards:empty { display: none; }
+.job-cards > .msg.card { position: relative; margin-left: 22px; max-width: 340px; }
+.job-cards > .msg.card::before { content: ""; position: absolute; left: -10px; top: -6px; bottom: 50%; width: 8px;
+ border-left: 2px solid var(--pill-edge); border-bottom: 2px solid var(--pill-edge); border-bottom-left-radius: 10px; }
.ask-empty, .ask-problem { margin: 0; padding: 0 20px 12px; color: var(--haze); font-size: 14px; }
.ask-foot { display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.ask-status { flex: 1; margin: 0; min-height: 1.5em; color: var(--haze); font-size: 14px; }
@@ -604,6 +674,9 @@ main { min-height: 100dvh; }
.base-btn, .ask-slot, .chat-col, aside.ask-panel, .shell > .home, .shell > .topbar { transition: none !important; }
.phone-open .shell > .home, .phone-open .shell > .topbar { transform: none; filter: none; }
.composer .actions button { animation: none; }
+ /* A working job's mark holds still: a quarter arc and a steady dot. */
+ .job[data-state="working"] .state-mark::after, .job[data-state="working"] .state-mark::before { animation: none; }
+ .job[data-state="working"] .state-mark::after { transform: rotate(45deg); }
}
/* Scratchpad's shared note: a field that grows past one control height. */
diff --git a/internal/look/static/ask.js b/internal/look/static/ask.js
index bab33bb..ff995d8 100644
--- a/internal/look/static/ask.js
+++ b/internal/look/static/ask.js
@@ -230,6 +230,8 @@ function start(root) {
// (its label, posting its value) while it is open, and the line saying
// how it ended. A newer revision redraws it; a card that has ended with
// nothing to say goes, and so does one of a kind Base does not draw.
+ // A card that belongs to a job (c.job: a go-ahead or Publish) hangs under
+ // the job's pill once the job is drawn, and is loose until then.
const kinds = ["question", "confirm", "outcome", "connect"];
function addCard(c) {
if (!c || !c.id) return;
@@ -244,6 +246,7 @@ function start(root) {
li.className = "msg card card-" + c.kind;
li.dataset.card = c.id;
li.dataset.revision = String(c.revision);
+ if (c.job) li.dataset.for = c.job;
const q = document.createElement("p");
q.textContent = c.question || "";
li.append(q);
@@ -284,10 +287,95 @@ function start(root) {
p.textContent = c.result;
li.append(p);
}
+ const list = c.job && item("data-job", c.job)?.querySelector("ol.job-cards");
+ if (old && (!list || old.parentElement === list)) old.replaceWith(li);
+ else {
+ if (old) old.remove();
+ (list || thread).append(li);
+ }
+ scroll();
+ }
+
+ // A job, a pill, drawn as the server draws it (the ask-job template): its
+ // state's mark, the title and its status, and once there is something to
+ // see (ready, done) the link to it. Its job page's link (rel) is never
+ // drawn here. A newer revision redraws it in place, never a second; the
+ // cards under it move to the new pill (ruling P6j), and so do loose cards
+ // of the job, drawn before it was; an open job view stays open.
+ const jobStates = ["working", "asking", "ready", "done", "stopped"];
+ const marks = {
+ asking: "M9.2 9.2a2.9 2.9 0 0 1 5.6 1c0 2-2.8 2.4-2.8 4.3M12 18.2h.01",
+ ready: "M8 16L16 8M9.5 8H16v6.5",
+ done: "M6 12.5l4 4 8-9",
+ stopped: "M9.5 7.5v9M14.5 7.5v9",
+ };
+ const svgNS = "http://www.w3.org/2000/svg";
+ function span(cls, text) {
+ const el = document.createElement("span");
+ el.className = cls;
+ if (text !== undefined) el.textContent = text;
+ return el;
+ }
+ function addJob(c) {
+ if (!c || !c.id || !jobStates.includes(c.state)) return;
+ const old = item("data-job", c.id);
+ if (old && Number(old.dataset.revision) > c.revision) return;
+ const li = document.createElement("li");
+ li.className = "job";
+ li.dataset.job = c.id;
+ li.dataset.revision = String(c.revision);
+ li.dataset.state = c.state;
+ const title = c.question || "", stage = c.result || "";
+ const pill = document.createElement("div");
+ pill.className = "pill";
+ const details = document.createElement("details");
+ details.className = "job-toggle";
+ details.open = !!old && !!old.querySelector("details.job-toggle")?.open;
+ const summary = document.createElement("summary");
+ summary.className = "pill-main";
+ summary.setAttribute("aria-label", title + ", " + stage);
+ const mark = span("state-mark");
+ mark.setAttribute("aria-hidden", "true");
+ if (marks[c.state]) {
+ const svg = document.createElementNS(svgNS, "svg");
+ svg.setAttribute("viewBox", "0 0 24 24");
+ const path = document.createElementNS(svgNS, "path");
+ path.setAttribute("d", marks[c.state]);
+ svg.append(path);
+ mark.append(svg);
+ }
+ summary.append(mark, span("pill-title", title), span("pill-stage", stage));
+ details.append(summary, jobView(c));
+ pill.append(details);
+ const go = (c.links || []).find((l) => l && !l.rel);
+ const href = go && typeof go.url === "string" && webURL(go.url);
+ if ((c.state === "ready" || c.state === "done") && href) {
+ const a = link(href, go.label || href);
+ a.className = "pill-link";
+ pill.append(a);
+ }
+ const list = document.createElement("ol");
+ list.className = "job-cards";
+ if (old) list.append(...old.querySelectorAll(":scope > ol.job-cards > li"));
+ list.append(...thread.querySelectorAll(`:scope > [data-for="${CSS.escape(c.id)}"]`));
+ li.append(pill, list);
if (old) old.replaceWith(li);
else thread.append(li);
scroll();
}
+ // The job view, opened from the pill: for now, its status line (the
+ // ask-jobview template). Its title, linked to the job's own page, goes
+ // here: the only place that link is drawn.
+ function jobView(c) {
+ const view = document.createElement("section");
+ view.className = "jobview";
+ view.setAttribute("aria-label", c.question || "");
+ const p = document.createElement("p");
+ p.className = "jv-stage";
+ p.textContent = c.result || "";
+ view.append(p);
+ return view;
+ }
const ended = (s) => s === "replied" || s === "failed" || s === "cancelled";
@@ -303,8 +391,18 @@ function start(root) {
field.addEventListener("input", paint);
paint();
+ // A team_update turn is the Assistant taking a job's news by itself, and
+ // is quiet (plan decision D9): no status line, no activity, no Stop, and
+ // never the turn in flight. Each turn's kind is kept for its activity.
+ const quietTurns = new Set();
+ const isQuiet = (id) => quietTurns.has(id);
function setTurn(t, line) {
if (t && !t.id) return;
+ if (t && t.kind === "team_update") {
+ quietTurns.add(t.id);
+ if (ended(t.state)) settle(t);
+ return;
+ }
if (t && !ended(t.state)) {
turn = t;
cancel.action = `/ask/turns/${encodeURIComponent(t.id)}/cancel`;
@@ -318,6 +416,11 @@ function start(root) {
turn = null;
paint();
status.textContent = t && t.state === "failed" ? "That didn't get an answer. Try again." : "";
+ 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.
+ 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();
@@ -335,10 +438,10 @@ function start(root) {
});
on("message", (e) => addMessage(e.data));
on("delta", (e) => delta(e.data));
- on("card", (e) => addCard(e.data));
+ on("card", (e) => (e.data && e.data.kind === "job" ? addJob(e.data) : addCard(e.data)));
on("turn", (e) => setTurn(e.data));
on("activity", (e) => {
- if (turn && e.data.turn_id === turn.id && e.data.label) status.textContent = e.data.label;
+ if (turn && e.data.turn_id === turn.id && !isQuiet(e.data.turn_id) && e.data.label) status.textContent = e.data.label;
});
on("state", (e) => {
quiet();
@@ -375,6 +478,10 @@ function start(root) {
thread.replaceChildren();
pinned = true;
s.messages.forEach(addMessage);
+ for (const j of s.jobs || []) {
+ addJob(j);
+ (j.cards || []).forEach(addCard);
+ }
s.cards.forEach(addCard);
setTurn(s.turn, s.status);
toBottom();
diff --git a/internal/web/ask.go b/internal/web/ask.go
index fcb3f3b..e31d568 100644
--- a/internal/web/ask.go
+++ b/internal/web/ask.go
@@ -165,16 +165,35 @@ type askView struct {
// Equipo is the "Open Equipo" link.
Equipo string
Messages []equipo.Message
- Cards []equipo.Card
- Turn *equipo.Turn
- Status string
- Key string
- Problem string
+ // Jobs are the job cards, each with the cards that belong to it;
+ // Cards every other card shown.
+ Jobs []jobView
+ Cards []equipo.Card
+ Turn *equipo.Turn
+ Status string
+ Key string
+ Problem string
// Text is what the person wrote and Equipo did not take, kept in the
// field.
Text string
}
+// jobView is a job card as the chat draws it, a pill, with the go-ahead
+// and Publish cards that belong to it (Card.Job) under it.
+type jobView struct {
+ equipo.Card
+ Cards []equipo.Card `json:"cards"`
+}
+
+// Go is where to see the job's work, for templates: its link beside the
+// pill, or nil.
+func (j jobView) Go() *equipo.Link {
+ if l, ok := j.Card.Go(); ok {
+ return &l
+ }
+ return nil
+}
+
// Shows reports whether the block for states (space-separated) shows now.
func (v askView) Shows(states string) bool {
for _, s := range strings.Fields(states) {
@@ -198,10 +217,11 @@ func (a *app) newAskView(state, next string) askView {
return askView{State: state, Next: next, Equipo: a.ask.client.Origin() + "/", Key: equipo.NewKey()}
}
-// turnStatus is the line under the conversation while a turn runs.
+// turnStatus is the line under the conversation while a turn runs. A
+// team_update turn is quiet (plan decision D9): it has none.
func turnStatus(t *equipo.Turn) string {
switch {
- case t == nil:
+ case t == nil || t.Kind == equipo.TurnTeamUpdate:
return ""
case t.State == equipo.TurnWaiting:
return "Ask Base can't answer right now. It will as soon as it can."
@@ -209,17 +229,36 @@ func turnStatus(t *equipo.Turn) string {
return "Thinking…"
}
-// fill puts a snapshot in the view: the messages, the cards to show and
-// the newest turn that has not ended.
+// fill puts a snapshot in the view: the messages, the jobs in the
+// snapshot's order with the cards that belong to each under it, every
+// other card to show, and the newest turn that has not ended, of those the
+// person sees running (never a quiet team_update turn, plan decision D9).
func (v *askView) fill(s equipo.Snapshot) {
v.Messages = s.Messages
+ var shown []equipo.Card
+ jobs := map[string]int{}
for _, c := range s.Cards {
- if p, ok := c.Clean(); ok && p.Shown() {
- v.Cards = append(v.Cards, p)
+ p, ok := c.Clean()
+ switch {
+ case !ok || !p.Shown():
+ case p.Kind == equipo.CardJob:
+ if _, dup := jobs[p.ID]; !dup {
+ jobs[p.ID] = len(v.Jobs)
+ v.Jobs = append(v.Jobs, jobView{Card: p, Cards: []equipo.Card{}})
+ }
+ default:
+ shown = append(shown, p)
+ }
+ }
+ for _, c := range shown {
+ if i, ok := jobs[c.Job]; ok && c.Job != "" {
+ v.Jobs[i].Cards = append(v.Jobs[i].Cards, c)
+ } else {
+ v.Cards = append(v.Cards, c)
}
}
for i := len(s.Turns) - 1; i >= 0; i-- {
- if equipo.InFlight(s.Turns[i].State) {
+ if equipo.InFlight(s.Turns[i].State) && s.Turns[i].Kind != equipo.TurnTeamUpdate {
t := s.Turns[i]
v.Turn = &t
break
@@ -325,11 +364,12 @@ func (a *app) askStateJSON(w http.ResponseWriter, r *http.Request) {
out := struct {
State string `json:"state"`
Messages []equipo.Message `json:"messages"`
+ Jobs []jobView `json:"jobs"`
Cards []equipo.Card `json:"cards"`
Turn *equipo.Turn `json:"turn"`
Status string `json:"status"`
Cursor int64 `json:"cursor"`
- }{v.State, append([]equipo.Message{}, v.Messages...), append([]equipo.Card{}, v.Cards...), v.Turn, v.Status, cursor}
+ }{v.State, append([]equipo.Message{}, v.Messages...), append([]jobView{}, v.Jobs...), append([]equipo.Card{}, v.Cards...), v.Turn, v.Status, cursor}
writeJSON(w, http.StatusOK, out)
}
diff --git a/internal/web/templates/partials/chat.html b/internal/web/templates/partials/chat.html
index 9356c7b..1ae1eef 100644
--- a/internal/web/templates/partials/chat.html
+++ b/internal/web/templates/partials/chat.html
@@ -4,10 +4,19 @@
<div class="ask-head"><h2 id="ask-title"><span class="mark" aria-hidden="true"></span>Ask Base</h2><form class="dock-close" method="post" action="/ask/dock"><input type="hidden" name="open" value="0"><button class="round close" type="submit" data-ask-close aria-label="Close"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg></button></form></div>
{{template "ask-body" .}}</aside>{{end}}
{{/* A card, drawn from its fields alone: the question, a link per link, a button per option (its label, posting its value) while it is open, and the line saying how it ended. The panel's script draws the same (ask.js, addCard). */}}
-{{define "ask-card"}}<li class="msg card card-{{.Kind}}" data-card="{{.ID}}" data-revision="{{.Revision}}"><p>{{.Question}}</p>
+{{define "ask-card"}}<li class="msg card card-{{.Kind}}" data-card="{{.ID}}" data-revision="{{.Revision}}"{{with .Job}} data-for="{{.}}"{{end}}><p>{{.Question}}</p>
{{- range .Links}}<p><a class="card-link" href="{{.URL}}" target="_blank" rel="noopener">{{.Label}}</a></p>{{end}}
{{- if and .Open .Options}}<form class="choices" method="post" action="/ask/cards/{{.ID}}/answer"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="key" value="{{newKey}}">{{range .Options}}<button class="btn ghost" type="submit" name="choice" value="{{.Value}}">{{.Label}}</button>{{end}}</form>{{end}}
{{- with .Result}}<p class="card-state">{{.}}</p>{{end}}</li>{{end}}
+{{/* A job, a pill: its state's mark, the title and its status, and once there is something to see (ready, done) the link to it. The summary opens the job view (without scripts, in place). The go-ahead and Publish cards that belong to the job hang under it. The panel's script draws the same (ask.js, addJob). */}}
+{{define "ask-job"}}<li class="job" data-job="{{.ID}}" data-revision="{{.Revision}}" data-state="{{.State}}">
+<div class="pill"><details class="job-toggle"><summary class="pill-main" aria-label="{{.Question}}, {{.Result}}"><span class="state-mark" aria-hidden="true">{{template "ask-mark" .State}}</span><span class="pill-title">{{.Question}}</span><span class="pill-stage">{{.Result}}</span></summary>{{template "ask-jobview" .}}</details>
+{{- if or (eq .State "ready") (eq .State "done")}}{{with .Go}}<a class="pill-link" href="{{.URL}}" target="_blank" rel="noopener">{{.Label}}</a>{{end}}{{end}}</div>
+<ol class="job-cards">{{range .Cards}}{{template "ask-card" .}}{{end}}</ol></li>{{end}}
+{{/* A job state's mark: working has none (the mark turns, in CSS); the rest are still icons. ask.js has the same paths (marks). */}}
+{{define "ask-mark"}}{{if eq . "asking"}}<svg viewBox="0 0 24 24"><path d="M9.2 9.2a2.9 2.9 0 0 1 5.6 1c0 2-2.8 2.4-2.8 4.3M12 18.2h.01"/></svg>{{else if eq . "ready"}}<svg viewBox="0 0 24 24"><path d="M8 16L16 8M9.5 8H16v6.5"/></svg>{{else if eq . "done"}}<svg viewBox="0 0 24 24"><path d="M6 12.5l4 4 8-9"/></svg>{{else if eq . "stopped"}}<svg viewBox="0 0 24 24"><path d="M9.5 7.5v9M14.5 7.5v9"/></svg>{{end}}{{end}}
+{{/* The job view, opened from the pill: for now, its status line. Its title, linked to the job's own page (Card.Equipo), goes here: the only place that link is drawn. */}}
+{{define "ask-jobview"}}<section class="jobview" aria-label="{{.Question}}"><p class="jv-stage">{{.Result}}</p></section>{{end}}
{{define "ask-body"}}<div class="ask-note" data-when="connect"{{if not (.Shows "connect")}} hidden{{end}}>
<p>Set up Ask Base to start asking.</p>
<form method="post" action="/ask/connect"><input type="hidden" name="next" value="{{.Next}}"><button class="btn" type="submit">Set up Ask Base</button></form>
@@ -26,10 +35,11 @@
<div class="ask-chat" data-when="ready norunner oldrunner"{{if not (.Shows "ready norunner oldrunner")}} hidden{{end}}>
<div class="log"><ol class="thread" role="log" aria-label="Conversation">
{{range .Messages}}{{if eq .Role "person"}}<li class="msg person" data-id="{{.ID}}">{{.Text}}</li>{{else}}<li class="msg coordinator" data-id="{{.ID}}">{{$.Rich .Text}}</li>{{end}}
+{{end}}{{range .Jobs}}{{template "ask-job" .}}
{{end}}{{range .Cards}}{{template "ask-card" .}}
{{end}}</ol>
<button class="jump" type="button" hidden>Jump to latest</button></div>
-<p class="ask-empty" data-empty{{if or .Messages .Cards}} hidden{{end}}>Ask about your work, or ask Base to get something done.</p>
+<p class="ask-empty" data-empty{{if or .Messages .Jobs .Cards}} hidden{{end}}>Ask about your work, or ask Base to get something done.</p>
{{with .Problem}}<p class="ask-problem" role="alert">{{.}}</p>{{end}}
{{/* Without a runner that can answer, the conversation shows and says so; what the person wrote stays in the field. */}}<p class="ask-problem ask-runner" data-when="norunner"{{if not (.Shows "norunner")}} hidden{{end}} role="alert">Ask Base isn't set up for you yet. <a href="{{.Equipo}}" target="_blank" rel="noopener">Finish setting it up</a>, then try again.</p>
<p class="ask-problem ask-runner" data-when="oldrunner"{{if not (.Shows "oldrunner")}} hidden{{end}} role="alert">Ask Base needs an update first. <a href="{{.Equipo}}" target="_blank" rel="noopener">Update it</a>, then try again.</p>
diff --git a/internal/webtest/ask_test.go b/internal/webtest/ask_test.go
index 2a327c4..3ec9857 100644
--- a/internal/webtest/ask_test.go
+++ b/internal/webtest/ask_test.go
@@ -1426,3 +1426,175 @@ func TestReconnectFailureDropsHostToken(t *testing.T) {
t.Fatalf("Settings shows a revoked connection as connected:\n%s", s)
}
}
+
+// jobItem is the job with id as /ask draws it: its li, pill and cards.
+func jobItem(t *testing.T, page, id string) string {
+ t.Helper()
+ m := regexp.MustCompile(`(?s)<li class="job" data-job="` + regexp.QuoteMeta(id) + `"[^>]*>.*?<ol class="job-cards">.*?</ol></li>`).FindString(page)
+ if m == "" {
+ t.Fatalf("no job %s in:\n%s", id, page)
+ }
+ return m
+}
+
+// A job is a pill in the conversation, never a card: the title, its status
+// beside it, and a summary named by both. Nothing in the chat names
+// Equipo, or links to the job's page there (only the job view's title
+// will, Task 19).
+func TestAskJobPill(t *testing.T) {
+ a, f := newAskApp(t)
+ a.connectEquipo(f)
+ id := f.AskJob("Building your website")
+ page := a.get("/ask").Body
+ if n := strings.Count(page, `<li class="job" `); n != 1 {
+ t.Fatalf("%d jobs drawn:\n%s", n, page)
+ }
+ job := jobItem(t, page, id)
+ if !strings.Contains(job, `data-state="working"`) || !strings.Contains(job, `data-revision="1"`) {
+ t.Errorf("job's attributes:\n%s", job)
+ }
+ expect(t, "title", job, `<span class="pill-title">(.*?)</span>`, "Building your website")
+ expect(t, "stage", job, `<span class="pill-stage">(.*?)</span>`, "Getting started")
+ if !strings.Contains(job, `<summary class="pill-main" aria-label="Building your website, Getting started">`) {
+ t.Errorf("summary's name:\n%s", job)
+ }
+ if strings.Contains(page, `data-card="`+id+`"`) || strings.Contains(job, "pill-link") {
+ t.Errorf("the job is drawn as a card, or links somewhere while working:\n%s", job)
+ }
+ if strings.Contains(strings.ToLower(textOf(page)), "equipo") || strings.Contains(page, f.URL+"/jobs/") {
+ t.Errorf("the chat names Equipo or links to the job's page there:\n%s", textOf(page))
+ }
+ if !strings.Contains(page, `data-empty hidden`) {
+ t.Errorf("the empty line shows beside a job")
+ }
+ var st struct {
+ Cards []struct{ ID string }
+ Jobs []struct {
+ ID, State, Result string
+ Cards []struct{ ID string }
+ }
+ }
+ if r := a.get("/ask/state"); json.Unmarshal([]byte(r.Body), &st) != nil || len(st.Cards) != 0 || len(st.Jobs) != 1 ||
+ st.Jobs[0].ID != id || st.Jobs[0].State != "working" || st.Jobs[0].Result != "Getting started" ||
+ st.Jobs[0].Cards == nil || !strings.Contains(r.Body, `"cards":[]`) {
+ t.Fatalf("state: %s", r.Body)
+ }
+}
+
+// The pill shows the status in every state, and a link beside it only
+// once there is something to see: ready (the preview) and done (the site).
+func TestAskJobStates(t *testing.T) {
+ preview := equipo.Link{Label: "Try it", URL: "https://preview.example.test/"}
+ site := equipo.Link{Label: "Open your site", URL: "https://site.example.test/"}
+ for _, tc := range []struct {
+ state, result string
+ links []equipo.Link
+ link, href string
+ }{
+ {"asking", "One question for you", nil, "", ""},
+ {"asking", "One question for you", []equipo.Link{preview}, "", ""},
+ {"ready", "Ready to try", []equipo.Link{preview}, "Try it", preview.URL},
+ {"done", "Done", []equipo.Link{site}, "Open your site", site.URL},
+ {"stopped", "Stopped", nil, "", ""},
+ } {
+ a, f := newAskApp(t)
+ a.connectEquipo(f)
+ id := f.AskJob("Building your website")
+ f.SetJob(id, tc.state, tc.result, "One sentence more.", tc.links...)
+ job := jobItem(t, a.get("/ask").Body, id)
+ where := tc.state + " " + strconv.Itoa(len(tc.links))
+ if !strings.Contains(job, `data-state="`+tc.state+`"`) || !strings.Contains(job, `data-revision="2"`) {
+ t.Errorf("%s: attributes:\n%s", where, job)
+ }
+ expect(t, where, job, `<span class="pill-stage">(.*?)</span>`, tc.result)
+ if !strings.Contains(job, `aria-label="Building your website, `+tc.result+`"`) {
+ t.Errorf("%s: summary's name:\n%s", where, job)
+ }
+ got := regexp.MustCompile(`<a class="pill-link" href="([^"]*)" target="_blank" rel="noopener">(.*?)</a>`).FindStringSubmatch(job)
+ switch {
+ case tc.link == "" && got != nil:
+ t.Errorf("%s: a pill link %q", where, got[0])
+ case tc.link != "" && (got == nil || got[1] != tc.href || got[2] != tc.link):
+ t.Errorf("%s: pill link %q, want %s to %s:\n%s", where, got, tc.link, tc.href, job)
+ }
+ if n := strings.Count(job, `class="state-mark" aria-hidden="true"`); n < 1 {
+ t.Errorf("%s: no state mark", where)
+ }
+ if hasSVG := strings.Contains(regexp.MustCompile(`(?s)<span class="state-mark"[^>]*>(.*?)</span>`).FindStringSubmatch(job)[1], "<svg"); hasSVG == (tc.state == "working") {
+ t.Errorf("%s: state mark's icon %v", where, hasSVG)
+ }
+ }
+}
+
+// A go-ahead or Publish card that belongs to a job is drawn under its
+// pill, and answers as any card does; one whose job is not drawn is loose.
+// A redrawn job (a new revision) keeps the cards under it.
+func TestAskJobAttachesItsCards(t *testing.T) {
+ a, f := newAskApp(t)
+ a.connectEquipo(f)
+ id := f.AskJob("Building your website")
+ f.SetJob(id, "ready", "Ready to try", "Have a look.", equipo.Link{Label: "Try it", URL: "https://preview.example.test/"})
+ goAhead := f.AskOutcomeFor(id, "This is ready. Go ahead?", goOptions, nil)
+ loose := f.AskOutcomeFor("c_9999", "Publish it?", goOptions, nil)
+ f.SetJob(id, "ready", "Ready to try", "Still ready.", equipo.Link{Label: "Try it", URL: "https://preview.example.test/"})
+ page := a.get("/ask").Body
+ job := jobItem(t, page, id)
+ if !strings.Contains(job, `data-revision="3"`) || !strings.Contains(job, `data-card="`+goAhead+`"`) || strings.Contains(job, `data-card="`+loose+`"`) {
+ t.Fatalf("the job's cards:\n%s", job)
+ }
+ if card := cardItem(t, job, goAhead); !strings.Contains(card, `data-for="`+id+`"`) {
+ t.Errorf("the attached card does not say whose it is:\n%s", card)
+ }
+ rest := strings.Replace(page, job, "", 1)
+ if !strings.Contains(rest, `data-card="`+loose+`"`) {
+ t.Errorf("the card of no drawn job is not loose:\n%s", page)
+ }
+ if strings.Index(page, job) > strings.Index(page, `data-card="`+loose+`"`) {
+ t.Errorf("a loose card is drawn before the job")
+ }
+ answer := formFields(t, page, "/ask/cards/"+goAhead+"/answer")
+ answer.Set("choice", "go")
+ if r := a.post("/ask/cards/"+goAhead+"/answer", answer); r.Code != 303 || r.Location() != "/ask" {
+ t.Fatalf("answer: %d %q", r.Code, r.Location())
+ }
+ if c := f.Calls("/api/v1/assistant/cards/" + goAhead + "/answer"); len(c) != 1 || strings.TrimSpace(c[0].Body) != `{"choice":"go","revision":1}` {
+ t.Fatalf("relayed: %+v", c)
+ }
+ if card := cardItem(t, jobItem(t, a.get("/ask").Body, id), goAhead); !strings.Contains(card, `<p class="card-state">Go ahead</p>`) {
+ t.Errorf("answered card under the job:\n%s", card)
+ }
+ var st struct {
+ Cards []struct{ ID string }
+ Jobs []struct {
+ ID string
+ Cards []struct{ ID, Job string }
+ }
+ }
+ if r := a.get("/ask/state"); json.Unmarshal([]byte(r.Body), &st) != nil || len(st.Cards) != 1 || st.Cards[0].ID != loose ||
+ len(st.Jobs) != 1 || len(st.Jobs[0].Cards) != 1 || st.Jobs[0].Cards[0].ID != goAhead || st.Jobs[0].Cards[0].Job != id {
+ t.Fatalf("state: %s", r.Body)
+ }
+}
+
+// A team_update turn is the Assistant thinking about a job by itself: no
+// status line, no Stop, and not the turn the cancel form stops.
+func TestAskTeamUpdateTurnIsQuiet(t *testing.T) {
+ a, f := newAskApp(t)
+ a.connectEquipo(f)
+ f.AskJob("Building your website")
+ f.EmitTurn("team_update", "running")
+ page := a.get("/ask").Body
+ expect(t, "/ask", page, `<p class="ask-status" role="status">(.*?)</p>`, "")
+ if !regexp.MustCompile(`<button class="stop"[^>]* hidden>`).MatchString(page) || strings.Contains(page, "/cancel") ||
+ strings.Contains(page, `http-equiv="refresh"`) {
+ t.Errorf("a team_update turn shows Stop or counts as the turn in flight:\n%s", page)
+ }
+ if r := a.get("/ask/state"); !strings.Contains(r.Body, `"turn":null`) || !strings.Contains(r.Body, `"status":""`) {
+ t.Errorf("state: %s", r.Body)
+ }
+ // The person's own turn still shows beside it.
+ f.Hold = true
+ a.post("/ask/messages", url.Values{"text": {"How is it going?"}})
+ page = a.get("/ask").Body
+ expect(t, "/ask with the person's turn", page, `<p class="ask-status" role="status">(.*?)</p>`, "Thinking…")
+}