Paused work re-review: zone 404 backs off, resend tested, failure said once
Human
Prompt
Fable approved feat/paused-jobs at 6ce1ff9; follow-ups before merge, test-first, one commit: R1 a 404 from the zone route backs off like a 5xx (other 4xx stay settled); R2 a test for resending the zone on a new connection; R4 announce the Carry on failure line once (native accessibility announcement; web exactly one live region).
From this commit's own message. The prompt ledger has no entries for it — which is what a squashed, rebased or amended commit looks like, and what every commit looks like in a repo without a ledger.
Summary
zoneFor treats Equipo's 404 (no route yet) as a failure: an hour's back-off, logged at info, so deploy order never matters; other 4xx stay settled. Tests: TestZoneBacksOffOn404 and TestZoneAgainForAConnectionMidCall (internal), TestAskZoneAgainOnANewConnection (web). The Carry on failure is said once: the job view has one empty role=status region (template and ask.js) that takes the line, and post(…, quiet) leaves the status line alone; the native AskModel posts an accessibility announcement (injectable, tested). The fake's HoldTimeZone returns a release func.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 files changed,
+208
−36
docs/superpowers/specs/2026-11-24-paused-work-base.md+6 −3internal/browsertest/cards_test.go+7 −1internal/equipo/equipotest/chat.go+11 −4internal/look/static/app.css+1 −0internal/look/static/ask.js+18 −15internal/web/ask_connect.go+13 −5internal/web/ask_internal_test.go+107 −0internal/web/templates/partials/chat.html+1 −1internal/webtest/ask_test.go+19 −3native/apple/Sources/BaseKit/Ask/AskModel.swift+16 −2native/apple/Tests/BaseKitTests/AskModelTests.swift+9 −2
CI passed — run details
CI log
=== build === CGO_ENABLED=0 go build ./... === vet === go vet ./... === fmt-check === === staticcheck === go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 ./... === govulncheck === go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./... No vulnerabilities found. === gitleaks === [90m2:14PM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net [90m2:14PM[0m [32mINF[0m [1m1 commits scanned.[0m [90m2:14PM[0m [32mINF[0m [1mscanned ~2380355 bytes (2.38 MB) in 196ms[0m [90m2:14PM[0m [32mINF[0m [1mno leaks found[0m === budget === go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget size budget size: 22 directories within budget === script-test === scripts/prepare-apps_test.sh ok releases lookup failure stops before ship ok app owned elsewhere stops the script ok apps listing failure stops before create ok ambiguous release dir is refused ok explicit version resolves the ambiguity ok releases match is exact, not substring ok shipped version is only promoted, existing app not created ok fresh account creates, ships, promotes to edge, enables ok failing promote stops the script ok ship is retried while uploads are rate limited all passed hack/fonts_test.sh fonts_test: ok === test === go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -count=1 ./... receipt: test step 7.549s against a 60s target (the gate's other steps are not in this figure) receipt: 16 packages ran, 0 cached, 6 without tests, 0 failed receipt: slow package 6.599s amadan.net/oficina/base/internal/webtest receipt: slow package 854ms amadan.net/oficina/base/internal/issuer receipt: slow package 569ms amadan.net/oficina/base/internal/operations receipt: slow package 188ms amadan.net/oficina/base/internal/consumer receipt: slow package 160ms amadan.net/oficina/base/internal/web receipt: slow test 1.51s amadan.net/oficina/base/internal/webtest TestHomeDoesNotWaitOnAStalledSnapshot receipt: slow test 1.07s amadan.net/oficina/base/internal/webtest TestAskZoneIsToldOnce receipt: slow test 620ms amadan.net/oficina/base/internal/issuer TestAuthorizeSignsForInstalledApp receipt: slow test 510ms amadan.net/oficina/base/internal/operations TestOperationsRefusals receipt: slow test 220ms amadan.net/oficina/base/internal/webtest TestAskZoneAgainOnANewConnection === native === strings: copy review's strings.json is not here (git-ignored); its comparison skipped strings: 119 in the catalog, 116 used worktree-lib_test: ok
diff --git a/docs/superpowers/specs/2026-11-24-paused-work-base.md b/docs/superpowers/specs/2026-11-24-paused-work-base.md| index 4394e44..a5607db 100644 |
| --- a/docs/superpowers/specs/2026-11-24-paused-work-base.md |
| +++ b/docs/superpowers/specs/2026-11-24-paused-work-base.md |
| @@ -25,15 +25,18 @@ Equipo owns the contract: `oficina/equipo` `feat/paused-work`, |
| the outcome. A 409 (`card_stale`, `not_paused`, `carry_on_unavailable`) |
| or a 404 reads the conversation afresh and is never resent. A failure |
| the person can retry says so inside the job view, next to the button, |
| - because a phone's sheet covers the status line. |
| + because a phone's sheet covers the status line. A screen reader hears |
| + it once: on the web from the view's one live region (the status line |
| + stays quiet), and in the app as an accessibility announcement. |
| - **Tells Equipo the team's zone.** It sends `PUT |
| /api/v1/assistant/time-zone {"time_zone": BASE_TIMEZONE, |
| "only_if_unset": true}`, so a zone from the person's own device wins. It |
| sends it once per member each time Base starts and again on a new |
| connection. The call runs in the background with a 5 s bound, so it |
| never holds up a page or the member's lock. Base remembers any 2xx, and |
| - any 4xx except 429. After a 5xx, a 429 or a timeout it waits an hour |
| - before trying again. |
| + any 4xx except 404 and 429. After a 5xx, a 429, a 404 (an Equipo |
| + without the route yet, so the order of deploys doesn't matter) or a |
| + timeout, it waits an hour before trying again. |
| - **Default zone.** `BASE_TIMEZONE` defaults to `Europe/Dublin` (Paul's |
| ruling). |
diff --git a/internal/browsertest/cards_test.go b/internal/browsertest/cards_test.go| index 297b49d..d5d3fe7 100644 |
| --- a/internal/browsertest/cards_test.go |
| +++ b/internal/browsertest/cards_test.go |
| @@ -819,8 +819,14 @@ func TestAskJobPausedCarriesOn(t *testing.T) { |
| // button comes back. Pressing again sends the same key. |
| f.FailCarryOn(503) |
| drive(t, rig, chromedp.Click(chromedp.CSS(view+` .jv-act button`))) |
| - wait(`document.querySelector(` + strconv.Quote(view+` .jv-act .jv-error[role="alert"]`) + `)?.textContent === "That didn't send. Try again." && |
| + wait(`document.querySelector(` + strconv.Quote(view+` .jv-act .jv-error[role="status"]`) + `)?.textContent === "That didn't send. Try again." && |
| !document.querySelector(` + strconv.Quote(view+` .jv-act button`) + `).disabled`) |
| + // Said once (Fable's re-review R4): in the view's live region only, not |
| + // on the status line too. |
| + if got := harness.Evaluate[string](rig, `[...document.querySelectorAll("#ask-panel [role=status], #ask-panel [role=alert], #ask-panel [aria-live]")] |
| + .filter(el => el.textContent.includes("That didn't send")).map(el => el.className).join("|")`); got != "jv-error" { |
| + t.Errorf("the failure is said in %q, want once, in the view (jv-error)", got) |
| + } |
| f.FailCarryOn(0) |
| drive(t, rig, chromedp.Click(chromedp.CSS(view+` .jv-act button`))) |
| wait(`document.querySelector(` + strconv.Quote(job) + `)?.dataset.state === "working"`) |
diff --git a/internal/equipo/equipotest/chat.go b/internal/equipo/equipotest/chat.go| index 6b65223..9ff1a45 100644 |
| --- a/internal/equipo/equipotest/chat.go |
| +++ b/internal/equipo/equipotest/chat.go |
| @@ -825,14 +825,21 @@ func (f *Fake) RefuseTimeZone(status int, code string) { |
| f.cmu.Unlock() |
| } |
| -// HoldTimeZone holds every PUT time-zone until the channel it returns is |
| -// closed (or the request gives up). |
| -func (f *Fake) HoldTimeZone() chan struct{} { |
| +// HoldTimeZone holds every PUT time-zone (until the request gives up) |
| +// until release is called; calls after that answer at once. |
| +func (f *Fake) HoldTimeZone() (release func()) { |
| hold := make(chan struct{}) |
| f.cmu.Lock() |
| f.zoneHold = hold |
| f.cmu.Unlock() |
| - return hold |
| + return sync.OnceFunc(func() { |
| + f.cmu.Lock() |
| + if f.zoneHold == hold { |
| + f.zoneHold = nil |
| + } |
| + f.cmu.Unlock() |
| + close(hold) |
| + }) |
| } |
| // TimeZone is the zone the person set (PUT time-zone), "" before any. |
diff --git a/internal/look/static/app.css b/internal/look/static/app.css| index 6d011ca..0db5708 100644 |
| --- a/internal/look/static/app.css |
| +++ b/internal/look/static/app.css |
| @@ -661,6 +661,7 @@ aside.ask-panel { position: absolute; top: 16px; right: 16px; bottom: 16px; widt |
| .jv-act { margin: 12px 10px 0 36px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; } |
| .jv-act small { color: var(--haze); font-size: 13px; } |
| .jv-act .jv-error { margin: 0; font-size: 13px; color: var(--frost); } |
| +.jv-act .jv-error:empty { margin-top: -6px; } |
| /* 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. */ |
diff --git a/internal/look/static/ask.js b/internal/look/static/ask.js| index 8d646e5..12a2dae 100644 |
| --- a/internal/look/static/ask.js |
| +++ b/internal/look/static/ask.js |
| @@ -757,9 +757,9 @@ function start(root) { |
| // "Carry on now", as the server draws it (the ask-jobview template): a |
| // form posting the card's revision, and the line under it saying what |
| - // it uses. Its key is post's, kept until the outcome is known. A |
| - // failure says so under it (jv-error), inside the view, where a phone's |
| - // sheet shows it. |
| + // it uses, and an empty live region (jv-error, role="status") for a |
| + // failure to say so inside the view, where a phone's sheet shows it. |
| + // Its key is post's, kept until the outcome is known. |
| function carryOn(c) { |
| const form = document.createElement("form"); |
| form.className = "jv-act"; |
| @@ -775,7 +775,9 @@ function start(root) { |
| b.textContent = "Carry on now"; |
| const note = document.createElement("small"); |
| note.textContent = "Uses your other plan, at no extra cost."; |
| - form.append(rev, b, note); |
| + const error = para("jv-error", ""); |
| + error.setAttribute("role", "status"); |
| + form.append(rev, b, note, error); |
| return form; |
| } |
| @@ -1567,12 +1569,13 @@ function start(root) { |
| const sending = new WeakMap(); |
| // post sends a form by fetch and returns its JSON, or null when it was |
| - // already on its way or failed (and the panel says so). |
| + // already on its way or failed (and the panel says so; quiet: the caller |
| + // says a failure to try again itself, not the status line). |
| // lastStatus is the HTTP status of the latest post that got an answer, |
| // lastState the state it answered with. |
| let lastStatus = 0; |
| let lastState = ""; |
| - async function post(form, extra) { |
| + async function post(form, extra, quiet) { |
| lastStatus = 0; |
| lastState = ""; |
| const body = new URLSearchParams(new FormData(form)); |
| @@ -1603,9 +1606,9 @@ function start(root) { |
| // Otherwise the conversation stays, with a line to try again (a 409 |
| // is stale: the next events show how things are). |
| if (["connect", "pending", "reconnect", ...runnerless].includes(out.state)) show(out.state); |
| - else if (res.status !== 409) status.textContent = "That didn't send. Try again."; |
| + else if (res.status !== 409 && !quiet) status.textContent = "That didn't send. Try again."; |
| } catch { |
| - status.textContent = "That didn't send. Try again."; |
| + if (!quiet) status.textContent = "That didn't send. Try again."; |
| } finally { |
| req.busy = false; |
| if (known) sending.delete(form); |
| @@ -1673,14 +1676,16 @@ function start(root) { |
| // is the same request). The answer is the job card, redrawn in place; |
| // a 409 (the card moved on, or no longer offers it, or is gone) or an |
| // answer with no card reads the conversation afresh. Never resent by |
| - // itself. A failure to try again says so inside the view (jv-error), |
| - // as well as on the status line. |
| + // itself. A failure to try again says so once, in the view's live |
| + // region (jv-error), never also on the status line, so a screen reader |
| + // hears it once. |
| async function carryOnNow(form) { |
| const b = form.querySelector("button"); |
| + const error = form.querySelector(".jv-error"); |
| if (b.disabled) return; |
| b.disabled = true; |
| - form.querySelector(".jv-error")?.remove(); |
| - const out = await post(form); |
| + error.textContent = ""; |
| + const out = await post(form, {}, true); |
| if ((!out && lastStatus === 409 && lastState === "ready") || (out && !out.card)) { |
| await load(); |
| return; |
| @@ -1691,9 +1696,7 @@ function start(root) { |
| } |
| b.disabled = false; |
| if (!runnerless.includes(lastState) && !["connect", "pending", "reconnect"].includes(lastState)) { |
| - const p = para("jv-error", "That didn't send. Try again."); |
| - p.setAttribute("role", "alert"); |
| - form.append(p); |
| + error.textContent = "That didn't send. Try again."; |
| } |
| } |
diff --git a/internal/web/ask_connect.go b/internal/web/ask_connect.go| index 3ec73e7..daa6512 100644 |
| --- a/internal/web/ask_connect.go |
| +++ b/internal/web/ask_connect.go |
| @@ -359,8 +359,10 @@ const ( |
| // zoneTold is where telling Equipo a member's time zone has got to: a |
| // call in flight (busy; again if a new connection came meanwhile), an |
| -// answer that settles it (any 2xx, or a 4xx but 429: the same call would |
| -// get the same answer), or a failure, after which it waits until retryAt. |
| +// answer that settles it (any 2xx, or a 4xx but 404 and 429: the same call |
| +// would get the same answer), or a failure, after which it waits until |
| +// retryAt. A 404 is an Equipo without the route yet, which may get it |
| +// (deployed after Base), so it waits like a failure. |
| type zoneTold struct { |
| busy, again, settled bool |
| retryAt time.Time |
| @@ -372,7 +374,7 @@ type zoneTold struct { |
| // Base starts, which is when BASE_TIMEZONE can change, and again on a new |
| // connection (fresh). It never holds up the page or the member's lock: |
| // the call runs on its own, bounded by zoneWait. After a failure (5xx, |
| -// 429, no answer in time) it is tried again no sooner than zoneRetry. |
| +// 429, 404, no answer in time) it is tried again no sooner than zoneRetry. |
| func (a *app) zoneFor(me store.Member, token string, fresh bool) { |
| if a.ask.zone == "" { |
| return |
| @@ -400,8 +402,14 @@ func (a *app) zoneFor(me store.Member, token string, fresh bool) { |
| defer cancel() |
| err := a.ask.client.SetTimeZone(ctx, token, a.ask.zone) |
| var e *equipo.Error |
| - settled := err == nil || errors.As(err, &e) && e.Status >= 400 && e.Status < 500 && e.Status != http.StatusTooManyRequests |
| - if err != nil { |
| + refused := errors.As(err, &e) |
| + settled := err == nil || refused && e.Status >= 400 && e.Status < 500 && |
| + e.Status != http.StatusTooManyRequests && e.Status != http.StatusNotFound |
| + switch { |
| + case refused && e.Status == http.StatusNotFound: |
| + // An Equipo from before the route: expected, not a fault. |
| + a.logger.Info("ask: time zone: Equipo has no such route yet", "err", err) |
| + case err != nil: |
| a.logger.Warn("ask: time zone", "err", err, "settled", settled) |
| } |
| a.ask.zoneMu.Lock() |
diff --git a/internal/web/ask_internal_test.go b/internal/web/ask_internal_test.go| index 606c2cd..97d3bf0 100644 |
| --- a/internal/web/ask_internal_test.go |
| +++ b/internal/web/ask_internal_test.go |
| @@ -1,8 +1,16 @@ |
| package web |
| import ( |
| + "context" |
| + "crypto/ed25519" |
| + "crypto/rand" |
| + "log/slog" |
| "testing" |
| "time" |
| + |
| + "amadan.net/oficina/base/internal/equipo" |
| + "amadan.net/oficina/base/internal/equipo/equipotest" |
| + "amadan.net/oficina/base/internal/store" |
| ) |
| // "Started N minutes ago" (plan decision D19), at each boundary, and the |
| @@ -42,3 +50,102 @@ func TestStartedText(t *testing.T) { |
| t.Errorf("with no zone (as given): %q", got) |
| } |
| } |
| + |
| +// newZoneApp is just enough of Base to tell a fake Equipo a member's time |
| +// zone (zoneFor), with a bearer the fake knows. |
| +func newZoneApp(t *testing.T) (*app, *equipotest.Fake, string) { |
| + t.Helper() |
| + f := equipotest.New(t) |
| + madrid, err := time.LoadLocation("Europe/Madrid") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + a := &app{ask: newAsker(f.URL, "zone-test-instance-key", "Acme", madrid), logger: slog.New(slog.DiscardHandler)} |
| + ctx := context.Background() |
| + pub, key, _ := ed25519.GenerateKey(rand.Reader) |
| + ch, err := a.ask.client.BeginDevice(ctx, pub, "Base (Acme)") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + proof, err := equipo.Prove(key, ch, rand.Text()) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := f.Approve(ch.UserCode); err != nil { |
| + t.Fatal(err) |
| + } |
| + cred, err := a.ask.client.Exchange(ctx, proof) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return a, f, cred.Token |
| +} |
| + |
| +// told waits for the member's zone call to end and returns where it got to. |
| +func told(t *testing.T, a *app, id string) zoneTold { |
| + t.Helper() |
| + for end := time.Now().Add(3 * time.Second); time.Now().Before(end); time.Sleep(5 * time.Millisecond) { |
| + a.ask.zoneMu.Lock() |
| + z := *a.ask.zones[id] |
| + a.ask.zoneMu.Unlock() |
| + if !z.busy { |
| + return z |
| + } |
| + } |
| + t.Fatal("the time-zone call never ended") |
| + return zoneTold{} |
| +} |
| + |
| +// Fable's re-review R1: an Equipo without the route (404) may get it, so |
| +// Base waits and tries again, as after a 5xx or a 429, never settling it |
| +// until a restart; every other refusal (a 4xx) is settled. |
| +func TestZoneBacksOffOn404(t *testing.T) { |
| + for _, tc := range []struct { |
| + status int |
| + settled bool |
| + }{{404, false}, {500, false}, {429, false}, {422, true}, {403, true}, {0, true}} { |
| + a, f, token := newZoneApp(t) |
| + if tc.status != 0 { |
| + f.RefuseTimeZone(tc.status, "x") |
| + } |
| + me := store.Member{ID: "m1"} |
| + start := time.Now() |
| + a.zoneFor(me, token, false) |
| + z := told(t, a, me.ID) |
| + if z.settled != tc.settled || !tc.settled && z.retryAt.Before(start.Add(zoneRetry)) || tc.settled && !z.retryAt.IsZero() { |
| + t.Errorf("%d: settled %v, retry at %v (want settled %v)", tc.status, z.settled, z.retryAt, tc.settled) |
| + } |
| + a.zoneFor(me, token, false) |
| + if n := len(f.Calls("/api/v1/assistant/time-zone")); n != 1 { |
| + t.Errorf("%d: %d calls before the wait is up", tc.status, n) |
| + } |
| + } |
| +} |
| + |
| +// Fable's re-review R2: a new connection made while the call is in flight |
| +// tells Equipo again once it ends (the held call had the old bearer), and |
| +// then not again. |
| +func TestZoneAgainForAConnectionMidCall(t *testing.T) { |
| + a, f, token := newZoneApp(t) |
| + release := f.HoldTimeZone() |
| + me := store.Member{ID: "m1"} |
| + a.zoneFor(me, token, true) |
| + for len(f.Calls("/api/v1/assistant/time-zone")) == 0 { |
| + time.Sleep(5 * time.Millisecond) |
| + } |
| + a.zoneFor(me, token, true) // the new connection, mid-call: no second call yet |
| + if n := len(f.Calls("/api/v1/assistant/time-zone")); n != 1 { |
| + t.Fatalf("%d calls while one is in flight", n) |
| + } |
| + release() |
| + if z := told(t, a, me.ID); z.settled { |
| + t.Fatal("the call before the new connection settled it") |
| + } |
| + a.zoneFor(me, token, false) |
| + told(t, a, me.ID) |
| + a.zoneFor(me, token, false) |
| + told(t, a, me.ID) |
| + if n := len(f.Calls("/api/v1/assistant/time-zone")); n != 2 { |
| + t.Errorf("%d calls, want the held one and one for the new connection", n) |
| + } |
| +} |
diff --git a/internal/web/templates/partials/chat.html b/internal/web/templates/partials/chat.html| index 4c388e7..117c7b9 100644 |
| --- a/internal/web/templates/partials/chat.html |
| +++ b/internal/web/templates/partials/chat.html |
| @@ -22,7 +22,7 @@ |
| <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}} |
| -{{- if and (eq .State "paused") .CarryOn}}<form class="jv-act" method="post" action="/ask/cards/{{.ID}}/carry_on"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="key" value="{{newKey}}"><button class="btn ghost" type="submit">Carry on now</button><small>Uses your other plan, at no extra cost.</small></form>{{end}}<ol class="jv-cards">{{range .EndedCards}}{{template "ask-jobcard" .}}{{end}}</ol>{{with .StartedAt}}<p class="jv-started">{{startedText .}}</p>{{end}} |
| +{{- if and (eq .State "paused") .CarryOn}}<form class="jv-act" method="post" action="/ask/cards/{{.ID}}/carry_on"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="key" value="{{newKey}}"><button class="btn ghost" type="submit">Carry on now</button><small>Uses your other plan, at no extra cost.</small><p class="jv-error" role="status"></p></form>{{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}} |
diff --git a/internal/webtest/ask_test.go b/internal/webtest/ask_test.go| index fe394b7..4e77482 100644 |
| --- a/internal/webtest/ask_test.go |
| +++ b/internal/webtest/ask_test.go |
| @@ -1621,7 +1621,7 @@ func TestAskJobPaused(t *testing.T) { |
| expect(t, "status", view, `<p class="jv-stage">(.*?)</p>`, "Paused until 21:00") |
| expect(t, "detail", view, `<p class="jv-detail">(.*?)</p>`, "It has reached the limit on its plan for now. It will carry on by itself at 21:00 (in 9 hours).") |
| form := regexp.MustCompile(`(?s)<form class="jv-act" method="post" action="/ask/cards/` + id + `/carry_on">(.*?)</form>`).FindStringSubmatch(view) |
| - if form == nil || !strings.Contains(form[1], `<button class="btn ghost" type="submit">Carry on now</button><small>Uses your other plan, at no extra cost.</small>`) { |
| + if form == nil || !strings.Contains(form[1], `<button class="btn ghost" type="submit">Carry on now</button><small>Uses your other plan, at no extra cost.</small><p class="jv-error" role="status"></p>`) { |
| t.Fatalf("no Carry on now in the view:\n%s", view) |
| } |
| fields := formFields(t, page, "/ask/cards/"+id+"/carry_on") |
| @@ -1821,6 +1821,22 @@ func TestAskSendsTheTeamZoneAndOptsInToPaused(t *testing.T) { |
| } |
| } |
| +// Fable's re-review R2: a new connection tells Equipo again (its bearer is |
| +// new), once, and reads after it do not. |
| +func TestAskZoneAgainOnANewConnection(t *testing.T) { |
| + a, f := newZonedAskApp(t) |
| + a.connectEquipo(f) |
| + a.get("/ask") |
| + zoneCalls(t, f, 1) |
| + a.approveEquipo(f) |
| + a.get("/ask") |
| + a.get("/") |
| + calls := zoneCalls(t, f, 2) |
| + if calls[0].Header.Get("Authorization") == calls[1].Header.Get("Authorization") { |
| + t.Error("the second call did not use the new connection's bearer") |
| + } |
| +} |
| + |
| // A zone one of the person's own devices set wins: Base's is only for |
| // when they have none. |
| func TestAskZoneNeverOverridesThePersons(t *testing.T) { |
| @@ -1839,8 +1855,8 @@ func TestAskZoneNeverOverridesThePersons(t *testing.T) { |
| // call, not one per read. |
| func TestAskZoneNeverHoldsThePage(t *testing.T) { |
| a, f := newZonedAskApp(t) |
| - hold := f.HoldTimeZone() |
| - defer close(hold) |
| + release := f.HoldTimeZone() |
| + defer release() |
| a.connectEquipo(f) |
| for _, page := range []string{"/ask", "/", "/ask/state", "/ask"} { |
| start := time.Now() |
diff --git a/native/apple/Sources/BaseKit/Ask/AskModel.swift b/native/apple/Sources/BaseKit/Ask/AskModel.swift| index f31bf55..ef3f312 100644 |
| --- a/native/apple/Sources/BaseKit/Ask/AskModel.swift |
| +++ b/native/apple/Sources/BaseKit/Ask/AskModel.swift |
| @@ -1,5 +1,6 @@ |
| import Foundation |
| import Observation |
| +import SwiftUI |
| /// Ask Base: the conversation, its jobs and cards and the turn in flight, |
| /// kept as ask.js keeps them (internal/look/static/ask.js), so the apps |
| @@ -114,13 +115,21 @@ import Observation |
| let client: BaseClient |
| /// Runs `body` after `delay` (tests run it at once, or never). |
| let schedule: @MainActor (Duration, @escaping @MainActor () -> Void) -> Void |
| + /// Says a line to VoiceOver once (a failed Carry on now's; tests record |
| + /// them). |
| + let announce: @MainActor (String) -> Void |
| public init(client: BaseClient, |
| - schedule: @escaping @MainActor (Duration, @escaping @MainActor () -> Void) -> Void = AskModel.later) { |
| + schedule: @escaping @MainActor (Duration, @escaping @MainActor () -> Void) -> Void = AskModel.later, |
| + announce: @escaping @MainActor (String) -> Void = AskModel.announce) { |
| self.client = client |
| self.schedule = schedule |
| + self.announce = announce |
| } |
| + /// Posts `line` as an accessibility announcement. |
| + public static func announce(_ line: String) { AccessibilityNotification.Announcement(line).post() } |
| + |
| public static func later(_ delay: Duration, _ body: @escaping @MainActor () -> Void) { |
| Task { @MainActor in |
| try? await Task.sleep(for: delay) |
| @@ -361,7 +370,12 @@ import Observation |
| return |
| } |
| refusedWrite(error, keepsKey: { carryOnKeys[job.id] = nil }) |
| - if Self.tryAgain(error) { carryOnErrors[job.id] = BaseText.text("ask.not_sent") } |
| + if Self.tryAgain(error) { |
| + // Shown under the button and said once: the status line |
| + // is no live region, and a sheet may cover it. |
| + carryOnErrors[job.id] = BaseText.text("ask.not_sent") |
| + announce(BaseText.text("ask.not_sent")) |
| + } |
| } |
| } |
diff --git a/native/apple/Tests/BaseKitTests/AskModelTests.swift b/native/apple/Tests/BaseKitTests/AskModelTests.swift| index b779616..34ca188 100644 |
| --- a/native/apple/Tests/BaseKitTests/AskModelTests.swift |
| +++ b/native/apple/Tests/BaseKitTests/AskModelTests.swift |
| @@ -293,17 +293,24 @@ import XCTest |
| /// clears it. Ask's own states (no runner) are the chat's, not the view's. |
| func testAFailedCarryOnSaysSoInTheView() async { |
| let carried = #"{"card":{"id":"jp","revision":4,"kind":"job","state":"working","question":"Bakery website","result":"Carrying on","options":[],"links":[]}}"# |
| - let (m, t) = model([json(502, #"{"state":"unavailable"}"#), json(200, carried)]) |
| + var said: [String] = [] |
| + let t = ScriptedTransport([json(502, #"{"state":"unavailable"}"#), json(200, carried)]) |
| + let m = AskModel(client: BaseClient(transport: t) {}, schedule: { _, _ in }, announce: { said.append($0) }) |
| m.apply(.card(Self.pausedJob)) |
| await m.carryOn(Self.pausedJob) |
| XCTAssertEqual(m.carryOnErrors["jp"], BaseText.text("ask.not_sent")) |
| + XCTAssertEqual(said, [BaseText.text("ask.not_sent")], "said once (Fable's re-review R4)") |
| await m.carryOn(Self.pausedJob) |
| XCTAssertNil(m.carryOnErrors["jp"]) |
| + XCTAssertEqual(said.count, 1, "a success says nothing") |
| XCTAssertEqual(fields(t.calls[0])["key"], fields(t.calls[1])["key"], "a 502 keeps the key") |
| - let (n, _) = model([json(409, #"{"state":"norunner"}"#)]) |
| + var quiet: [String] = [] |
| + let n = AskModel(client: BaseClient(transport: ScriptedTransport([json(409, #"{"state":"norunner"}"#)])) {}, schedule: { _, _ in }, |
| + announce: { quiet.append($0) }) |
| n.apply(.card(Self.pausedJob)) |
| await n.carryOn(Self.pausedJob) |
| XCTAssertTrue(n.carryOnErrors.isEmpty) |
| + XCTAssertTrue(quiet.isEmpty) |
| XCTAssertEqual(n.phase, .norunner) |
| } |