oficina / base Public

Move a job's answered cards from under its pill into the job view

Paul's live check (2026-11-16): an answered question and a given
go-ahead still sat under a job's pill.

- Under the pill: only the job's cards that are open (waiting on the
  person). Once answered or resolved, a card is listed in the job view,
  under the detail, as its question and its result line, with nothing
  to press (ask-jobcard; ask.js endedCard). Cards of no job keep today's
  behaviour; an ended card of a job not yet drawn joins its view when
  the job arrives, and a redrawn job keeps its view's list.
- /ask/state still carries every card of a job; the script places it.
- No new words.
- Browser: TestAskJobSettledCardsInView; TestAskJobKeepsItsCards now
  expects the answered go-ahead in the view. Webtest:
  TestAskJobSettledCardsInView, TestAskJobAttachesItsCards updated.
- make browser gets -timeout 20m: the browser package runs about 630 s
  on this shared machine under load, past go test's 10 minute default.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev fdea76a3481ac244e4c5ad9df2f81611561af149 parent f447db1
8 files changed, +246 −21
  • Makefile +1 −1
  • internal/browsertest/cards_test.go +96 −4
  • internal/equipo/equipotest/chat.go +7 −1
  • internal/look/static/app.css +9 −1
  • internal/look/static/ask.js +50 −4
  • internal/web/ask.go +28 −2
  • internal/web/templates/partials/chat.html +6 −4
  • internal/webtest/ask_test.go +49 −4
diff --git a/Makefile b/Makefile
index 58d2545..3552802 100644
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,7 @@ test:
# apps it installs. Set RASTRILLO_CHROME to a Chromium, and
# BASE_BROWSER_ARTIFACTS to a directory to keep the screenshots it takes.
browser:
- go test -tags browser -count=1 ./...
+ go test -tags browser -count=1 -timeout 20m ./...
vet:
go vet ./...
diff --git a/internal/browsertest/cards_test.go b/internal/browsertest/cards_test.go
index f504f94..e455736 100644
--- a/internal/browsertest/cards_test.go
+++ b/internal/browsertest/cards_test.go
@@ -156,8 +156,9 @@ func TestAskJobPillInPanel(t *testing.T) {
// 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.
+// value and moves it into the job view; 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
@@ -192,13 +193,14 @@ func TestAskJobKeepsItsCards(t *testing.T) {
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"`)
+ // Answered, it leaves the pill for the job view.
+ wait(jobJS(id) + ` === ` + strconv.Quote("1 working Almost ready [] ") + ` && ` + endedJS(id) + ` === "This is ready. Go ahead?|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))
+ wait(jobJS(id) + ` === ` + strconv.Quote("1 ready Ready to publish [Try it] "+publish) + ` && ` + endedJS(id) + ` === "This is ready. Go ahead?|Go ahead"`)
// 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
@@ -221,6 +223,96 @@ func TestAskJobKeepsItsCards(t *testing.T) {
}
}
+// endedJS lists the cards in job id's view, each as its question and
+// its result line ("question|result"), comma-separated; "none" without
+// the job.
+func endedJS(id string) string {
+ return `(() => { const j = document.querySelector('#ask-panel li.job[data-job="` + id + `"]');
+ if (!j) return "none";
+ return [...j.querySelectorAll(".jobview ol.jv-cards > li")].map(c => [...c.children].map(p => p.textContent).join("|")).join(","); })()`
+}
+
+// Paul's live check (2026-11-16): only a card that needs an answer hangs
+// under its job's pill. A question answered and a go-ahead given move
+// into the job view, under its detail, each as its question and how it
+// ended, with nothing to press; an open go-ahead still shows under the
+// pill, and moves into the view once answered. The view keeps them as
+// the job is redrawn, and an ended card of a job not yet drawn joins its
+// view when it is. A card of no job stays in the conversation.
+func TestAskJobSettledCardsInView(t *testing.T) {
+ rig, f := askBase(t)
+ 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"}}
+ id := f.AskLegacyJob("Can you make me a website?")
+ question := f.AskKindFor("question", id, "Which website?", []equipo.Option{{Value: "new", Label: "A new one"}}, nil)
+ goAhead := f.AskOutcomeFor(id, "This is ready. Go ahead?", options, nil)
+ f.SetCard(question, "answered", "A new one")
+ f.SetCard(goAhead, "answered", "Go ahead")
+ f.SetJob(id, "stopped", "Stopped", "It can't go on until something is sorted out.")
+ both := "Which website?|A new one,This is ready. Go ahead?|Go ahead"
+ wait(jobJS(id) + ` === "1 stopped Stopped [] " && ` + endedJS(id) + ` === ` + strconv.Quote(both))
+ job := `#ask-panel li.job[data-job="` + id + `"]`
+ if got := harness.Evaluate[string](rig, `(() => { const j = document.querySelector(`+strconv.Quote(job)+`), p = [];
+ if (document.querySelectorAll('#ask-panel .thread > [data-card]').length) p.push("a card loose in the conversation");
+ const list = j.querySelector(".jobview ol.jv-cards");
+ if (list.previousElementSibling !== j.querySelector(".jobview .jv-detail")) p.push("not under the detail");
+ if (list.querySelector("form, button, a")) p.push("something to press");
+ return p.join("; "); })()`); got != "" {
+ t.Errorf("the ended cards: %s", got)
+ }
+ drive(t, rig, chromedp.Click(chromedp.CSS(job+` summary`)), chromedp.Sleep(250*time.Millisecond))
+ if n := harness.Evaluate[int](rig, `[...document.querySelectorAll(`+strconv.Quote(job+` .jobview ol.jv-cards > li`)+`)].filter(c => c.checkVisibility()).length`); n != 2 {
+ t.Errorf("%d ended cards show in the open view", n)
+ }
+ rig.Screen("#ask-panel", "a stopped job's view with its ended cards")
+ for _, scheme := range []string{"dark", "light"} {
+ drive(t, rig, prefersScheme(scheme), chromedp.Sleep(300*time.Millisecond))
+ mobileShot(t, rig, "jobview-settled-"+scheme)
+ checkContrast(t, rig, "the ended cards, "+scheme, job+" .jv-cards .jv-q", job+" .jv-cards .jv-result")
+ }
+ drive(t, rig, prefersScheme("dark"), chromedp.KeyEvent(kb.Escape), chromedp.Sleep(200*time.Millisecond))
+
+ // An open go-ahead hangs under the pill; answered, it joins the view.
+ f.SetJob(id, "ready", "Ready to try", "Have a look.")
+ again := f.AskOutcomeFor(id, "Try it again?", options, nil)
+ wait(jobJS(id) + ` === ` + strconv.Quote("1 ready Ready to try [] "+again) + ` && ` + endedJS(id) + ` === ` + strconv.Quote(both))
+ drive(t, rig, chromedp.Click(chromedp.CSS(job+` ol.job-cards [data-card="`+again+`"] button[value="go"]`)))
+ wait(jobJS(id) + ` === "1 ready Ready to try [] " && ` + endedJS(id) + ` === ` + strconv.Quote(both+",Try it again?|Go ahead"))
+ // Redrawn, the job keeps them in its view.
+ f.SetJob(id, "working", "Almost ready", "Putting the finishing touches on it.")
+ wait(jobJS(id) + ` === "1 working Almost ready [] " && ` + endedJS(id) + ` === ` + strconv.Quote(both+",Try it again?|Go ahead"))
+
+ // An ended card of a job not yet drawn joins its view when it is; a
+ // card of no job stays where it is. (The fake numbers its cards in
+ // turn: the next job is the card after the next.)
+ loose := f.AskOutcome("Something else?", options, nil)
+ n, err := strconv.Atoi(strings.TrimPrefix(loose, "c_"))
+ if err != nil {
+ t.Fatalf("card id %q", loose)
+ }
+ early := f.AskOutcomeFor(fmt.Sprintf("c_%04d", n+2), "And this one?", options, nil)
+ f.SetCard(early, "resolved", "Not needed any more")
+ f.SetCard(loose, "answered", "Go ahead")
+ wait(`!!document.querySelector('#ask-panel .thread > [data-card="` + early + `"]')`)
+ if other := f.AskJob("Fixing the login"); other != fmt.Sprintf("c_%04d", n+2) {
+ t.Fatalf("the next job is %s", other)
+ }
+ wait(jobJS(fmt.Sprintf("c_%04d", n+2)) + ` === ` + `"2 working Getting started [] "` + ` && ` + endedJS(fmt.Sprintf("c_%04d", n+2)) + ` === "And this one?|Not needed any more"`)
+ 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)
+ }
+
+ // Read afresh, the same.
+ drive(t, rig, chromedp.Reload(), chromedp.Sleep(300*time.Millisecond))
+ openPanel(t, rig)
+ wait(jobJS(id) + ` === "2 working Almost ready [] " && ` + endedJS(id) + ` === ` + strconv.Quote(both+",Try it again?|Go ahead"))
+}
+
// statusShownJS checks the pill of job id: its status is drawn (a box with
// width, neither display:none nor visibility:hidden) and its title is cut
// short with an ellipsis before the status is; "" when both hold.
diff --git a/internal/equipo/equipotest/chat.go b/internal/equipo/equipotest/chat.go
index 0975d6c..131cddc 100644
--- a/internal/equipo/equipotest/chat.go
+++ b/internal/equipo/equipotest/chat.go
@@ -220,9 +220,15 @@ func (f *Fake) SetJobStarted(id string, at time.Time) {
// AskOutcomeFor puts an open outcome card in the conversation that
// belongs to job card job, as Equipo mirrors a job's go-ahead or Publish.
func (f *Fake) AskOutcomeFor(job, question string, options []equipo.Option, links []equipo.Link) string {
+ return f.AskKindFor(equipo.CardOutcome, job, question, options, links)
+}
+
+// AskKindFor puts an open card of kind in the conversation that belongs
+// to job card job, such as a question mirrored before job threads.
+func (f *Fake) AskKindFor(kind, job, question string, options []equipo.Option, links []equipo.Link) string {
f.cmu.Lock()
defer f.cmu.Unlock()
- c := &card{ID: f.next("c"), Revision: 1, Kind: equipo.CardOutcome, State: "open", Question: question, Job: job,
+ c := &card{ID: f.next("c"), Revision: 1, Kind: kind, State: "open", Question: question, Job: job,
Options: append([]equipo.Option{}, options...), Links: append([]equipo.Link{}, links...)}
f.cards = append(f.cards, c)
f.emit("card", "card", c.ID, c.Revision, "", *c)
diff --git a/internal/look/static/app.css b/internal/look/static/app.css
index 02c2f0a..667c21d 100644
--- a/internal/look/static/app.css
+++ b/internal/look/static/app.css
@@ -602,7 +602,8 @@ aside.ask-panel { position: absolute; top: 16px; right: 16px; bottom: 16px; widt
@keyframes turn { to { transform: rotate(1turn); } }
@keyframes glow { from { opacity: .45; } }
/* The job view, opened from the pill: its title, the status, one sentence
- more, when it started, and the link to the work. Without scripts it
+ more, the job's cards that have ended, when it started, and the link to
+ the work. Without scripts it
opens in place, just under the pill's row. With them (ask.js) it is a popover
in the top layer, anchored to the pill inside the chat, and on a phone a
sheet from the foot of the screen over the dimmed chat (the scrim). It
@@ -642,6 +643,13 @@ aside.ask-panel { position: absolute; top: 16px; right: 16px; bottom: 16px; widt
.jv-stage { font-weight: 500; }
.jobview > .jv-detail { margin-top: 2px; color: var(--haze); }
.jobview > .jv-started { margin-top: 8px; color: var(--haze); font-size: 13px; }
+/* Under the detail, the job's cards that have ended (Paul, 2026-11-16):
+ each its question, then how it ended, in the status's quieter ink; a
+ rule above the list keeps them apart from the status. */
+.jv-cards { list-style: none; margin: 10px 10px 0 36px; padding: 8px 0 0; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--rule); }
+.jv-cards:empty { display: none; }
+.jv-cards p { margin: 0; }
+.jv-cards .jv-result { color: var(--haze); font-size: 13px; }
.jv-go { display: inline-flex; align-items: center; height: 44px; margin: 14px 10px 0 0; padding: 0 18px; border-radius: 10px; font-weight: 600; font-size: 15px;
text-decoration: none; background: var(--btn); color: var(--btn-ink); }
.scrim { position: absolute; inset: 0; z-index: 4; background: var(--scrim); border-radius: inherit; }
diff --git a/internal/look/static/ask.js b/internal/look/static/ask.js
index 59a7dc7..ec12c3b 100644
--- a/internal/look/static/ask.js
+++ b/internal/look/static/ask.js
@@ -276,17 +276,34 @@ function start(root) {
// 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.
+ // the job's pill once the job is drawn while it waits on the person, and
+ // once ended is listed in the job view (endedCard); it is loose until its
+ // job is drawn.
const kinds = ["question", "confirm", "outcome", "connect"];
+ // The newest of each job's card, for its job to place when it is drawn.
+ const jobCards = new Map();
function addCard(c) {
if (!c || !c.id) return;
const old = item("data-card", c.id);
if (!kinds.includes(c.kind) || (c.state !== "open" && !c.result)) {
if (old) old.remove();
+ jobCards.delete(c.id);
scroll();
return;
}
if (old && Number(old.dataset.revision) > c.revision) return;
+ if (c.job) jobCards.set(c.id, c);
+ const view = c.state !== "open" && c.job && item("data-job", c.job)?.querySelector(".jobview ol.jv-cards");
+ if (view) {
+ const li = endedCard(c);
+ if (old && old.parentElement === view) old.replaceWith(li);
+ else {
+ if (old) old.remove();
+ view.append(li);
+ }
+ scroll();
+ return;
+ }
const li = document.createElement("li");
li.className = "msg card card-" + c.kind;
li.dataset.card = c.id;
@@ -341,11 +358,24 @@ function start(root) {
scroll();
}
+ // A job's card that has ended, in its view, as the server draws it (the
+ // ask-jobcard template): the question and how it ended.
+ function endedCard(c) {
+ const li = document.createElement("li");
+ li.className = "jv-card";
+ li.dataset.card = c.id;
+ li.dataset.revision = String(c.revision);
+ li.dataset.for = c.job;
+ li.append(para("jv-q", c.question || ""), para("jv-result", c.result || ""));
+ return li;
+ }
+
// 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. 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
+ // and so do loose cards of the job, drawn before it was (those that have
+ // ended to its view), and the ended cards in its view; an open job view
// stays open, and focus stays where it was.
const jobStates = ["working", "asking", "ready", "done", "stopped"];
const marks = {
@@ -426,8 +456,20 @@ function start(root) {
}
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)}"]`));
+ const ended = details.querySelector(".jobview ol.jv-cards");
+ if (old) {
+ list.append(...old.querySelectorAll(":scope > ol.job-cards > li"));
+ ended.append(...old.querySelectorAll(".jobview ol.jv-cards > li"));
+ }
+ const loose = [...thread.querySelectorAll(`:scope > [data-for="${CSS.escape(c.id)}"]`)];
+ for (const el of loose) {
+ const k = jobCards.get(el.dataset.card);
+ if (!k || k.state === "open") list.append(el);
+ else {
+ el.remove();
+ ended.append(endedCard(k));
+ }
+ }
li.append(pill, list);
if (popovers) {
summary.setAttribute("aria-expanded", "false");
@@ -483,6 +525,9 @@ function start(root) {
header.append(stateMark(c.state), h3, close);
view.append(header, para("jv-stage", c.result || ""));
if (c.detail) view.append(para("jv-detail", c.detail));
+ const ended = document.createElement("ol");
+ ended.className = "jv-cards";
+ view.append(ended);
const at = typeof c.started_at === "string" ? new Date(c.started_at) : null;
if (at && !isNaN(at)) {
const p = para("jv-started", startedText(at, Date.now()));
@@ -1253,6 +1298,7 @@ function start(root) {
const focused = viewing && item("data-job", viewing)?.querySelector(".jobview")?.contains(document.activeElement);
thread.replaceChildren();
bubbles.clear();
+ jobCards.clear();
glances.clear();
waits.clear();
pinned = true;
diff --git a/internal/web/ask.go b/internal/web/ask.go
index cd49074..a13e667 100644
--- a/internal/web/ask.go
+++ b/internal/web/ask.go
@@ -186,13 +186,39 @@ type askView struct {
Unread bool
}
-// 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.
+// jobView is a job card as the chat draws it, a pill, with the cards that
+// belong to it (Card.Job): under the pill while they wait on the person,
+// in its view once they have ended. Cards carries them all, for the
+// panel's script to place.
type jobView struct {
equipo.Card
Cards []equipo.Card `json:"cards"`
}
+// OpenCards are the job's cards that wait on the person, drawn under its
+// pill.
+func (j jobView) OpenCards() []equipo.Card {
+ var out []equipo.Card
+ for _, c := range j.Cards {
+ if c.Open() {
+ out = append(out, c)
+ }
+ }
+ return out
+}
+
+// EndedCards are the job's cards that have ended (answered, resolved),
+// listed in its view: each its question and how it ended.
+func (j jobView) EndedCards() []equipo.Card {
+ var out []equipo.Card
+ for _, c := range j.Cards {
+ if !c.Open() {
+ out = append(out, c)
+ }
+ }
+ return out
+}
+
// Go is where to see the job's work, for templates: its link beside the
// pill, or nil.
func (j jobView) Go() *equipo.Link {
diff --git a/internal/web/templates/partials/chat.html b/internal/web/templates/partials/chat.html
index c80038e..4b4decc 100644
--- a/internal/web/templates/partials/chat.html
+++ b/internal/web/templates/partials/chat.html
@@ -8,19 +8,21 @@
{{- 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). */}}
+{{/* 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 cards that belong to the job hang under it while they wait on the person; once ended they are listed in its view. 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}}
+<ol class="job-cards">{{range .OpenCards}}{{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: its title, the status, one sentence more, when it started, and once there is something to see the link to it. The title links to the job's own page in Equipo (Card.Equipo, "Open in Equipo" as its tooltip, an arrow on hover and focus): the only place the chat links there, never a step the person must take. Without scripts it opens in place under the pill; the panel's script makes it a popover beside the pill, or a sheet on a phone, and shows Close (ask.js, jobView). */}}
+{{/* The job view, opened from the pill: its title, the status, one sentence more, the job's cards that have ended (each its question and how it ended: ask-jobcard), when it started, and once there is something to see the link to it. The title links to the job's own page in Equipo (Card.Equipo, "Open in Equipo" as its tooltip, an arrow on hover and focus): the only place the chat links there, never a step the person must take. Without scripts it opens in place under the pill; the panel's script makes it a popover beside the pill, or a sheet on a phone, and shows Close (ask.js, jobView). */}}
{{define "ask-jobview"}}<section class="jobview" aria-label="{{.Question}}"><header><span class="state-mark" aria-hidden="true">{{template "ask-mark" .State}}</span>
<h3>{{with .Equipo}}<a class="jv-title" href="{{.URL}}" title="{{.Label}}" target="_blank" rel="noopener">{{$.Question}}<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 6h9v9M18 6L7 17"/></svg></a>{{else}}{{.Question}}{{end}}</h3>
<button class="round" type="button" data-job-close aria-label="Close" hidden><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg></button></header>
-<p class="jv-stage">{{.Result}}</p>{{with .Detail}}<p class="jv-detail">{{.}}</p>{{end}}{{with .StartedAt}}<p class="jv-started">{{startedText .}}</p>{{end}}
+<p class="jv-stage">{{.Result}}</p>{{with .Detail}}<p class="jv-detail">{{.}}</p>{{end}}<ol class="jv-cards">{{range .EndedCards}}{{template "ask-jobcard" .}}{{end}}</ol>{{with .StartedAt}}<p class="jv-started">{{startedText .}}</p>{{end}}
{{- if or (eq .State "ready") (eq .State "done")}}{{with .Go}}<a class="jv-go" href="{{.URL}}" target="_blank" rel="noopener">{{.Label}}</a>{{end}}{{end}}</section>{{end}}
+{{/* A job's card that has ended, in its view: the question and how it ended, nothing to press. The panel's script draws the same (ask.js, addCard). */}}
+{{define "ask-jobcard"}}<li class="jv-card" data-card="{{.ID}}" data-revision="{{.Revision}}" data-for="{{.Job}}"><p class="jv-q">{{.Question}}</p><p class="jv-result">{{.Result}}</p></li>{{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>
diff --git a/internal/webtest/ask_test.go b/internal/webtest/ask_test.go
index fadbbe6..f24f1a9 100644
--- a/internal/webtest/ask_test.go
+++ b/internal/webtest/ask_test.go
@@ -1593,8 +1593,9 @@ func TestAskJobStates(t *testing.T) {
}
// 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.
+// pill while open, and answers as any card does; answered, it is listed
+// in the job view. 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)
@@ -1626,8 +1627,9 @@ func TestAskJobAttachesItsCards(t *testing.T) {
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)
+ // Answered, it is the job view's, as its question and how it ended.
+ if view := jobViewOf(t, jobItem(t, a.get("/ask").Body, id)); !strings.Contains(view, `<li class="jv-card" data-card="`+goAhead+`" data-revision="2" data-for="`+id+`"><p class="jv-q">This is ready. Go ahead?</p><p class="jv-result">Go ahead</p></li>`) {
+ t.Errorf("answered card in the job view:\n%s", view)
}
var st struct {
Cards []struct{ ID string }
@@ -1642,6 +1644,49 @@ func TestAskJobAttachesItsCards(t *testing.T) {
}
}
+// Paul's live check (2026-11-16): only a card that needs an answer is
+// drawn under its job's pill. A job's answered question and go-ahead are
+// listed in its view, under the detail, each as its question and its
+// result line with nothing to press; an open go-ahead stays under the
+// pill; the state carries every card of the job, for the script to
+// place.
+func TestAskJobSettledCardsInView(t *testing.T) {
+ a, f := newAskApp(t)
+ a.connectEquipo(f)
+ id := f.AskLegacyJob("Can you make me a website?")
+ question := f.AskKindFor("question", id, "Which website?", []equipo.Option{{Value: "new", Label: "A new one"}}, nil)
+ goAhead := f.AskOutcomeFor(id, "This is ready. Go ahead?", goOptions, nil)
+ f.SetCard(question, "answered", "A new one")
+ f.SetCard(goAhead, "answered", "Go ahead")
+ f.SetJob(id, "stopped", "Stopped", "It can't go on until something is sorted out.")
+ page := a.get("/ask").Body
+ job := jobItem(t, page, id)
+ if !strings.HasSuffix(job, `<ol class="job-cards"></ol></li>`) || strings.Contains(page, `class="msg card`) {
+ t.Errorf("an ended card drawn as a card:\n%s", page)
+ }
+ view := jobViewOf(t, job)
+ want := `<p class="jv-detail">It can&#39;t go on until something is sorted out.</p><ol class="jv-cards">` +
+ `<li class="jv-card" data-card="` + question + `" data-revision="2" data-for="` + id + `"><p class="jv-q">Which website?</p><p class="jv-result">A new one</p></li>` +
+ `<li class="jv-card" data-card="` + goAhead + `" data-revision="2" data-for="` + id + `"><p class="jv-q">This is ready. Go ahead?</p><p class="jv-result">Go ahead</p></li></ol>`
+ if !strings.Contains(view, want) {
+ t.Errorf("the job view's ended cards, want %s in:\n%s", want, view)
+ }
+ again := f.AskOutcomeFor(id, "Try it again?", goOptions, nil)
+ job = jobItem(t, a.get("/ask").Body, id)
+ if card := cardItem(t, job, again); !strings.Contains(card, `action="/ask/cards/`+again+`/answer"`) || strings.Contains(jobViewOf(t, job), again) {
+ t.Errorf("the open go-ahead is not under the pill:\n%s", job)
+ }
+ var st struct {
+ Jobs []struct {
+ ID string
+ Cards []struct{ ID, State string }
+ }
+ }
+ if r := a.get("/ask/state"); json.Unmarshal([]byte(r.Body), &st) != nil || len(st.Jobs) != 1 || len(st.Jobs[0].Cards) != 3 {
+ 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) {