oficina / base Public

Paused work review fixes: zone off the page's path, Carry on now errors in the view

Human

Prompt

Fable's review of feat/paused-jobs, with the controller's rulings: S1 time-zone call in the background with a short timeout, remember definitive answers, back off on 5xx/timeouts/429; S2 send only_if_unset: true; S3 show a failed Carry on now inside the job view on web and native; S4 record Change the limit as deferred; nits N1 404 final, N2 null card redraws, N4 pin ask.js strings, N5 fake replay as Equipo's.

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 runs PUT assistant/time-zone {time_zone, only_if_unset: true} on its own goroutine (5 s bound), outside the member lock; a 2xx or 4xx but 429 settles it, a 5xx/429/timeout waits an hour; a new connection mid-call sends again. Carry on now: Equipo's 404 is 409 ready (final); a 200 with no card reloads; a retryable failure shows 'That didn't send. Try again.' inside the job view (ask.js .jv-error with role=alert; native AskModel.carryOnErrors under the note). The fake replays by card and key with the card as it is now, takes only_if_unset, and can hold or refuse time-zone and fail carry_on. docs/superpowers/specs/2026-11-24-paused-work-base.md records what Base does and what is deferred (Change the limit, the view's longer time, the person's own zone, older clients).
Agent notes
Matches Equipo feat/paused-work 31cdb35d: only_if_unset keeps a zone the person's own browser or device set, and replaces one Base set before (the fake tracks the source the same way); carry_on's 409s are only card_stale, not_paused and carry_on_unavailable.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 6ce1ff9d8b6d40ba3c38192c7207b58fcf11a018 parent 64742a1
23 files changed, +444 −72
  • docs/api/base-native-v1.md +6 −2
  • docs/superpowers/specs/2026-11-24-paused-work-base.md +55 −0
  • internal/browsertest/cards_test.go +12 −4
  • internal/equipo/chat.go +5 −2
  • internal/equipo/equipo_test.go +20 −3
  • internal/equipo/equipotest/chat.go +72 −13
  • internal/look/static/app.css +1 −0
  • internal/look/static/ask.js +19 −6
  • internal/web/ask.go +8 −5
  • internal/web/ask_connect.go +56 −15
  • internal/web/ask_relay.go +9 −3
  • internal/webtest/ask_test.go +106 −9
  • native/apple/Sources/BaseKit/Ask/AskModel.swift +22 −3
  • native/apple/Sources/BaseKit/Ask/Pill.swift +16 −6
  • native/apple/Sources/BaseKit/Ask/Thread.swift +2 −1
  • native/apple/Tests/BaseKitTests/AskModelTests.swift +30 −0
  • native/apple/Tests/BaseSnapshots/AskSnapshots.swift +5 −0
  • native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-dark-ax3.png binary
  • native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-dark-default.png binary
  • native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-light-ax3.png binary
  • native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-light-default.png binary
  • native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-failed-dark-default.png binary
  • native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-failed-light-default.png binary

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 ===
1:55PM INF Unknown SCM platform. Use --platform to include links in findings. host=amadan.net
1:55PM INF 1 commits scanned.
1:55PM INF scanned ~2373618 bytes (2.37 MB) in 210ms
1:55PM INF no leaks found
=== 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 6.795s 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 5.776s amadan.net/oficina/base/internal/webtest
receipt: slow package 800ms amadan.net/oficina/base/internal/issuer
receipt: slow package 582ms amadan.net/oficina/base/internal/operations
receipt: slow package 194ms amadan.net/oficina/base/internal/consumer
receipt: slow package 117ms amadan.net/oficina/base/internal/equipo
receipt: slow test 1.52s amadan.net/oficina/base/internal/webtest TestHomeDoesNotWaitOnAStalledSnapshot
receipt: slow test 1.07s amadan.net/oficina/base/internal/webtest TestAskZoneIsToldOnce
receipt: slow test 570ms amadan.net/oficina/base/internal/issuer TestAuthorizeSignsForInstalledApp
receipt: slow test 510ms amadan.net/oficina/base/internal/operations TestOperationsRefusals
receipt: slow test 210ms amadan.net/oficina/base/internal/issuer TestAuthorizeRefusals
=== 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/api/base-native-v1.md b/docs/api/base-native-v1.md
index 5717240..24fdf29 100644
--- a/docs/api/base-native-v1.md
+++ b/docs/api/base-native-v1.md
@@ -213,9 +213,13 @@ and `key`, a fresh idempotency key kept until an answer settles the
outcome (a resend after a network error or a `502` reuses it).
- `200 {"card": Card}`: the job card as it is now (working again).
+ `{"card": null}` (a card Base does not draw): reload `/ask/state`.
- `409 {"state":"ready"}`: the job moved on (a newer revision), is no longer
- paused, or no longer offers it (Equipo's `card_stale`, `not_paused`,
- `carry_on_unavailable`). Reload `/ask/state` to redraw it; never resend.
+ paused, no longer offers it, or is not one of the person's jobs at all
+ (Equipo's `card_stale`, `not_paused`, `carry_on_unavailable`, `404`).
+ Reload `/ask/state` to redraw it; never resend.
+- A failure to try again (`502`, no answer) belongs next to the button,
+ inside the job view, not only on the status line.
- Without scripts, the form answers `303 /ask`.
### Every write's other answers
diff --git a/docs/superpowers/specs/2026-11-24-paused-work-base.md b/docs/superpowers/specs/2026-11-24-paused-work-base.md
new file mode 100644
index 0000000..4394e44
--- /dev/null
+++ b/docs/superpowers/specs/2026-11-24-paused-work-base.md
@@ -0,0 +1,55 @@
+# Paused work: Base's half
+
+Paul approved "clearer paused work" on 2026-11-24 (mockups
+`polish-audit/paused-work/b/`, copy `copy-review/strings-final.json`).
+Equipo owns the contract: `oficina/equipo` `feat/paused-work`,
+`docs/api/equipo-v1.md` ("Talk to the Assistant") and its spec
+`docs/superpowers/specs/2026-11-24-paused-work-design.md`.
+
+## What Base does
+
+- **Opts in.** Every snapshot and event stream asks for
+ `job_states=paused`. Without it Equipo sends a paused job as `working`
+ with the same words.
+- **Draws a paused job.** The pill has a still clock mark on `--st-pause`
+ (`#4B55C9` light, `#AEB8FF` dark; its icon is 6.1:1 and 7.9:1) and
+ Equipo's `result` as its status. The job view shows `detail`, and
+ "Carry on now" (`assistant.job.carry_on`) with
+ `assistant.job.carry_on_note` under it when the card has `carry_on`.
+ Base shows Equipo's words as given: they are already in the person's
+ time zone.
+- **Draws stopped as a square.** It used to be two pause bars. Paused and
+ stopped have to look different.
+- **Relays Carry on now.** `POST /ask/cards/{id}/carry_on` (see
+ `docs/api/base-native-v1.md`). The key is kept until an answer settles
+ 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.
+- **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.
+- **Default zone.** `BASE_TIMEZONE` defaults to `Europe/Dublin` (Paul's
+ ruling).
+
+## Not in this change (deferred)
+
+- **"Change the limit"** (`assistant.job.change_limit`, approved in
+ `paused-budget-view.html`, copy reviewed). Equipo's job card has no link
+ for it yet. When Equipo sends one (a card link with its own `rel`), Base
+ draws it in the job view of a spending-limit pause.
+- **"Paused until 21:00 tonight" in the view**
+ (`assistant.job.paused_view`). The contract has a single `result`, so
+ the view repeats the pill's "Paused until 21:00".
+- **The person's own zone from Base's clients.** Base sends the team's
+ zone only when the person has none. Relaying the browser's or the app's
+ own zone is for later.
+- **Older clients of Base.** Base opts in for all of its clients. A tab
+ still running the old `ask.js` ignores a paused job until it reloads,
+ and a native build from before this change would drop it. No native
+ build has shipped yet.
diff --git a/internal/browsertest/cards_test.go b/internal/browsertest/cards_test.go
index 6a22e9b..297b49d 100644
--- a/internal/browsertest/cards_test.go
+++ b/internal/browsertest/cards_test.go
@@ -814,6 +814,14 @@ func TestAskJobPausedCarriesOn(t *testing.T) {
drive(t, rig, prefersScheme("dark"))
rig.Screen("#ask-panel", "a paused job's view, with Carry on now")
+ // Equipo not answering: the view says so under the button (Fable's
+ // review S3: on a phone the sheet hides the status line), and the
+ // 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." &&
+ !document.querySelector(` + strconv.Quote(view+` .jv-act button`) + `).disabled`)
+ f.FailCarryOn(0)
drive(t, rig, chromedp.Click(chromedp.CSS(view+` .jv-act button`)))
wait(`document.querySelector(` + strconv.Quote(job) + `)?.dataset.state === "working"`)
settle()
@@ -821,11 +829,11 @@ func TestAskJobPausedCarriesOn(t *testing.T) {
t.Errorf("Carry on now still shows on a working job")
}
calls := f.Calls("/api/v1/assistant/cards/" + id + "/carry_on")
- if len(calls) != 1 {
- t.Fatalf("Carry on now went %d times", len(calls))
+ if len(calls) != 2 {
+ t.Fatalf("Carry on now went %d times, want the failure and its retry", len(calls))
}
key := calls[0].Header.Get("Idempotency-Key")
- if want := `{"idempotency_key":"` + key + `","revision":3}`; key == "" || strings.TrimSpace(calls[0].Body) != want {
- t.Errorf("sent %s with key %q, want %s", calls[0].Body, key, want)
+ if want := `{"idempotency_key":"` + key + `","revision":3}`; key == "" || strings.TrimSpace(calls[0].Body) != want || calls[1].Body != calls[0].Body {
+ t.Errorf("sent %s then %s with key %q, want %s twice", calls[0].Body, calls[1].Body, key, want)
}
}
diff --git a/internal/equipo/chat.go b/internal/equipo/chat.go
index 9c119ff..162e727 100644
--- a/internal/equipo/chat.go
+++ b/internal/equipo/chat.go
@@ -281,9 +281,12 @@ func (c *Client) Snapshot(ctx context.Context, token string) (Snapshot, error) {
// SetTimeZone tells Equipo the person's IANA time zone, which the times in
// the copy it writes for them are in (a paused job's "Paused until
-// 21:00"). Equipo answers 422 invalid_input to a zone it does not know.
+// 21:00"), only if they have none yet (only_if_unset): a zone one of the
+// person's own devices reported wins over Base's. Equipo answers 422
+// invalid_input to a zone it does not know.
func (c *Client) SetTimeZone(ctx context.Context, token, zone string) error {
- _, err := c.call(ctx, http.MethodPut, assistant+"/time-zone", token, NewKey(), nil, map[string]string{"time_zone": zone}, nil)
+ in := map[string]any{"time_zone": zone, "only_if_unset": true}
+ _, err := c.call(ctx, http.MethodPut, assistant+"/time-zone", token, NewKey(), nil, in, nil)
return err
}
diff --git a/internal/equipo/equipo_test.go b/internal/equipo/equipo_test.go
index 49a542a..d2b2e26 100644
--- a/internal/equipo/equipo_test.go
+++ b/internal/equipo/equipo_test.go
@@ -526,11 +526,19 @@ func TestCarryOnNow(t *testing.T) {
if again, err := c.CarryOnNow(ctx, cred.Token, job, 3, "k-2"); err != nil || again.Revision != 4 || again.State != equipo.JobWorking {
t.Errorf("replayed: %+v %v", again, err)
}
- if _, err := c.CarryOnNow(ctx, cred.Token, job, 4, "k-3"); !errors.As(err, &e) || e.Code != "not_paused" {
+ // Equipo replays a key with the card as it is now, not as it was.
+ f.SetJob(job, equipo.JobReady, "Ready to try", "Have a look.")
+ if again, err := c.CarryOnNow(ctx, cred.Token, job, 3, "k-2"); err != nil || again.Revision != 5 || again.State != equipo.JobReady {
+ t.Errorf("replayed after a move: %+v %v", again, err)
+ }
+ if _, err := c.CarryOnNow(ctx, cred.Token, "c_nothing", 1, "k-2"); !errors.As(err, &e) || e.Status != 404 {
+ t.Errorf("no such card, with a key seen before: %v", err)
+ }
+ if _, err := c.CarryOnNow(ctx, cred.Token, job, 5, "k-3"); !errors.As(err, &e) || e.Code != "not_paused" {
t.Errorf("not paused: %v", err)
}
f.PauseJob(job, "Paused until 22:00", "", false)
- if _, err := c.CarryOnNow(ctx, cred.Token, job, 5, "k-4"); !errors.As(err, &e) || e.Code != "carry_on_unavailable" {
+ if _, err := c.CarryOnNow(ctx, cred.Token, job, 6, "k-4"); !errors.As(err, &e) || e.Code != "carry_on_unavailable" {
t.Errorf("unavailable: %v", err)
}
}
@@ -588,9 +596,18 @@ func TestSetTimeZone(t *testing.T) {
t.Fatalf("set: %v, zone %q", err, f.TimeZone())
}
if calls := f.Calls("/api/v1/assistant/time-zone"); len(calls) != 1 || calls[0].Method != http.MethodPut ||
- strings.TrimSpace(calls[0].Body) != `{"time_zone":"Europe/Dublin"}` || calls[0].Header.Get("Idempotency-Key") == "" {
+ strings.TrimSpace(calls[0].Body) != `{"only_if_unset":true,"time_zone":"Europe/Dublin"}` || calls[0].Header.Get("Idempotency-Key") == "" {
t.Errorf("sent: %+v", calls)
}
+ // Base's zone replaces the one Base set before (BASE_TIMEZONE changed),
+ // never one the person's own device set.
+ if err := c.SetTimeZone(ctx, cred.Token, "Europe/Madrid"); err != nil || f.TimeZone() != "Europe/Madrid" {
+ t.Errorf("Base's new zone: %v, zone %q", err, f.TimeZone())
+ }
+ f.SetTimeZone("Europe/Berlin")
+ if err := c.SetTimeZone(ctx, cred.Token, dublin); err != nil || f.TimeZone() != "Europe/Berlin" {
+ t.Errorf("over the person's own: %v, zone %q", err, f.TimeZone())
+ }
var e *equipo.Error
if err := c.SetTimeZone(ctx, cred.Token, "Mars/Olympus"); !errors.As(err, &e) || e.Status != 422 || e.Code != "invalid_input" {
t.Errorf("unknown zone: %v", err)
diff --git a/internal/equipo/equipotest/chat.go b/internal/equipo/equipotest/chat.go
index 16e4eea..6b65223 100644
--- a/internal/equipo/equipotest/chat.go
+++ b/internal/equipo/equipotest/chat.go
@@ -84,15 +84,24 @@ type chat struct {
events []event // in order; a live event (a glance) has cursor 0
cursor int64 // the newest event's cursor, from 40
sent map[string]string // idempotency key to message id
- carried map[string]card // carry_on's idempotency key to the card it answered
+ carried map[string]bool // carry_on's card id and idempotency key, once carried on
wake chan struct{} // closed at each new event
// runner is why the person's runner cannot answer: "no_runner",
// "runner_too_old", or "" when it can.
runner string
// address is who the bearer speaks for (the snapshot's me.address).
address string
- // zone is the person's time zone, as PUT time-zone set it.
- zone string
+ // zone is the person's time zone; zoneOwn says their own browser or
+ // device set it (SetTimeZone), not Base (PUT assistant/time-zone).
+ zone string
+ zoneOwn bool
+ // zoneStatus and zoneCode, when set, are what every PUT time-zone
+ // gets; zoneHold, when set, holds each one until it closes.
+ zoneStatus int
+ zoneCode string
+ zoneHold chan struct{}
+ // carryStatus, when set, is what every carry_on gets (a 5xx).
+ carryStatus int
// hostStatus and hostCode, when set, are what every PUT host gets.
hostStatus int
hostCode string
@@ -105,7 +114,7 @@ type chat struct {
}
func (c *chat) init() {
- c.turns, c.sent, c.carried, c.wake = map[string]*turn{}, map[string]string{}, map[string]card{}, make(chan struct{})
+ c.turns, c.sent, c.carried, c.wake = map[string]*turn{}, map[string]string{}, map[string]bool{}, make(chan struct{})
c.cursor = 40
c.address = "paul@tito.io"
}
@@ -685,7 +694,8 @@ func (f *Fake) answer(w http.ResponseWriter, r *http.Request, id string) {
// carryOn is POST cards/{id}/carry_on {revision, idempotency_key}, as
// Equipo's docs/api/equipo-v1.md says: a paused job that offers it
// (carry_on) starts again now, working, and the answer is 200 {"card"}.
-// A key seen before gets the answer it got then. 409 card_stale at another
+// A key that already carried this card on gets 200 with the card as it is
+// now, as Equipo's job_paused.go does. 409 card_stale at another
// revision, not_paused when it is not paused, carry_on_unavailable when it
// does not offer it, each {code, copy_key, request_id, card}; 404 for
// anything but a job card.
@@ -700,8 +710,8 @@ func (f *Fake) carryOn(w http.ResponseWriter, r *http.Request, id string) {
}
f.cmu.Lock()
defer f.cmu.Unlock()
- if done, ok := f.carried[in.IdempotencyKey]; ok {
- writeJSON(w, 200, map[string]any{"card": done})
+ if f.carryStatus != 0 {
+ writeError(w, r, f.carryStatus, "unavailable")
return
}
var c *card
@@ -720,6 +730,8 @@ func (f *Fake) carryOn(w http.ResponseWriter, r *http.Request, id string) {
switch {
case c == nil:
writeError(w, r, 404, "not_found")
+ case f.carried[c.ID+"\x00"+in.IdempotencyKey]:
+ writeJSON(w, 200, map[string]any{"card": *c})
case c.Revision != in.Revision:
conflict("card_stale")
case c.State != equipo.JobPaused:
@@ -729,7 +741,7 @@ func (f *Fake) carryOn(w http.ResponseWriter, r *http.Request, id string) {
default:
c.State, c.Result, c.Detail, c.CarryOn, c.Revision = equipo.JobWorking, "Carrying on", "Picking up where it left off.", false, c.Revision+1
f.emit("card", "card", c.ID, c.Revision, "", *c)
- f.carried[in.IdempotencyKey] = *c
+ f.carried[c.ID+"\x00"+in.IdempotencyKey] = true
writeJSON(w, 200, map[string]any{"card": *c})
}
}
@@ -756,11 +768,31 @@ func asSeen(c card, paused bool) card {
return c
}
-// timeZone is PUT time-zone {time_zone}: 200 {time_zone} for a zone Go
-// knows (an IANA name), else 422 invalid_input.
+// timeZone is PUT assistant/time-zone {time_zone, only_if_unset}, as
+// Equipo's zone.go (31cdb35d): 200 {time_zone: the zone in effect} for a
+// zone Go knows (an IANA name), else 422 invalid_input. With only_if_unset
+// a zone the person's own browser or device set stays; one Base set
+// before is replaced.
func (f *Fake) timeZone(w http.ResponseWriter, r *http.Request) {
var in struct {
- TimeZone string `json:"time_zone"`
+ TimeZone string `json:"time_zone"`
+ OnlyIfUnset bool `json:"only_if_unset"`
+ }
+ f.cmu.Lock()
+ status, code, hold := f.zoneStatus, f.zoneCode, f.zoneHold
+ f.cmu.Unlock()
+ if hold != nil {
+ select {
+ case <-hold:
+ case <-r.Context().Done():
+ return
+ case <-f.closing:
+ return
+ }
+ }
+ if status != 0 {
+ writeError(w, r, status, code)
+ return
}
if strict(r, &in) != nil || in.TimeZone == "" || in.TimeZone == "Local" {
writeError(w, r, 422, "invalid_input")
@@ -771,9 +803,36 @@ func (f *Fake) timeZone(w http.ResponseWriter, r *http.Request) {
return
}
f.cmu.Lock()
- f.zone = in.TimeZone
+ if !in.OnlyIfUnset || !f.zoneOwn {
+ f.zone, f.zoneOwn = in.TimeZone, false
+ }
+ zone := f.zone
+ f.cmu.Unlock()
+ writeJSON(w, 200, map[string]string{"time_zone": zone})
+}
+
+// FailCarryOn makes every carry_on answer status (a 5xx; 0 stops).
+func (f *Fake) FailCarryOn(status int) { f.cmu.Lock(); f.carryStatus = status; f.cmu.Unlock() }
+
+// SetTimeZone sets the person's zone, as one of their own devices does.
+func (f *Fake) SetTimeZone(zone string) { f.cmu.Lock(); f.zone, f.zoneOwn = zone, true; f.cmu.Unlock() }
+
+// RefuseTimeZone makes every PUT time-zone answer status with code (0
+// accepts them again).
+func (f *Fake) RefuseTimeZone(status int, code string) {
+ f.cmu.Lock()
+ f.zoneStatus, f.zoneCode = status, code
+ 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{} {
+ hold := make(chan struct{})
+ f.cmu.Lock()
+ f.zoneHold = hold
f.cmu.Unlock()
- writeJSON(w, 200, map[string]string{"time_zone": in.TimeZone})
+ return 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 a5c9579..6d011ca 100644
--- a/internal/look/static/app.css
+++ b/internal/look/static/app.css
@@ -660,6 +660,7 @@ aside.ask-panel { position: absolute; top: 16px; right: 16px; bottom: 16px; widt
saying what it uses. */
.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); }
/* 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 0401c87..8d646e5 100644
--- a/internal/look/static/ask.js
+++ b/internal/look/static/ask.js
@@ -757,7 +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.
+ // 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.
function carryOn(c) {
const form = document.createElement("form");
form.className = "jv-act";
@@ -1669,19 +1671,30 @@ function start(root) {
// Carry on now: once, with post's kept key (a retry after a lost answer
// is the same request). The answer is the job card, redrawn in place;
- // a 409 (the card moved on, or no longer offers it) reads the
- // conversation afresh. Never resent by itself.
+ // 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.
async function carryOnNow(form) {
const b = form.querySelector("button");
if (b.disabled) return;
b.disabled = true;
+ form.querySelector(".jv-error")?.remove();
const out = await post(form);
- if (!out && lastStatus === 409 && lastState === "ready") {
+ if ((!out && lastStatus === 409 && lastState === "ready") || (out && !out.card)) {
await load();
return;
}
- if (out && out.card) addJob(out.card);
- else b.disabled = false;
+ if (out) {
+ addJob(out.card);
+ return;
+ }
+ 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);
+ }
}
// On a wide screen the field is ready when the page opens: only with the
diff --git a/internal/web/ask.go b/internal/web/ask.go
index f80ba8e..462e586 100644
--- a/internal/web/ask.go
+++ b/internal/web/ask.go
@@ -32,10 +32,12 @@ type asker struct {
// with Oficina ID for them (askOficinaLock).
oficina sync.Map
// zone is the team's IANA time zone (BASE_TIMEZONE), which Equipo
- // writes the Assistant's times in; zoned holds the zone told to Equipo
- // for each member id since Base started (zoneFor).
- zone string
- zoned sync.Map
+ // writes the Assistant's times in unless the person has one of their
+ // own; zones holds, per member id, where telling Equipo has got to
+ // (zoneFor).
+ zone string
+ zoneMu sync.Mutex
+ zones map[string]*zoneTold
}
// askRoutes mounts the chat, behind the member gate and Base's CSRF check.
@@ -87,7 +89,8 @@ func (a *app) askDock(w http.ResponseWriter, r *http.Request) {
// newAsker is the chat with the Equipo at origin, for the team at zone
// (BASE_TIMEZONE), which Base tells Equipo for each member (zoneFor).
func newAsker(origin, instanceKey, name string, zone *time.Location) *asker {
- a := &asker{client: equipo.New(origin), seal: equipo.NewSealer(instanceKey), label: "Base (" + name + ")"}
+ a := &asker{client: equipo.New(origin), seal: equipo.NewSealer(instanceKey), label: "Base (" + name + ")",
+ zones: map[string]*zoneTold{}}
if zone != nil {
a.zone = zone.String()
}
diff --git a/internal/web/ask_connect.go b/internal/web/ask_connect.go
index 3da30f7..3ec73e7 100644
--- a/internal/web/ask_connect.go
+++ b/internal/web/ask_connect.go
@@ -333,8 +333,8 @@ func (a *app) registerHost(ctx context.Context, me store.Member, dev, token stri
func (a *app) hostFor(ctx context.Context, me store.Member, dev, token string, fresh bool) {
ctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), storeTimeout)
defer cancel()
+ a.zoneFor(me, token, fresh)
defer a.lockMember(me.ID)()
- a.zoneFor(ctx, me, token, fresh)
if !fresh {
done, err := store.HostRegistered(ctx, a.db, me.ID)
if err != nil {
@@ -350,27 +350,68 @@ func (a *app) hostFor(ctx context.Context, me store.Member, dev, token string, f
}
}
+// zoneWait bounds one time-zone call; zoneRetry is how long Base waits
+// after one that failed (5xx, 429, no answer in time) before trying again.
+const (
+ zoneWait = 5 * time.Second
+ zoneRetry = time.Hour
+)
+
+// 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.
+type zoneTold struct {
+ busy, again, settled bool
+ retryAt time.Time
+}
+
// zoneFor tells Equipo the member's time zone, the team's (BASE_TIMEZONE),
-// so the times the Assistant writes for them ("Paused until 21:00") are in
-// it: on each new connection (fresh), and otherwise once for each member
-// since Base started, which is when BASE_TIMEZONE can change. A failure is
-// logged and tried again on the next read; an Equipo that has no such
-// route (404) is not asked again until Base restarts. The caller holds the
-// member's lock.
-func (a *app) zoneFor(ctx context.Context, me store.Member, token string, fresh bool) {
+// for the times the Assistant writes for them ("Paused until 21:00"),
+// only if they have none of their own yet (SetTimeZone): once each time
+// 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.
+func (a *app) zoneFor(me store.Member, token string, fresh bool) {
if a.ask.zone == "" {
return
}
- if told, ok := a.ask.zoned.Load(me.ID); ok && told == a.ask.zone && !fresh {
- return
+ a.ask.zoneMu.Lock()
+ z := a.ask.zones[me.ID]
+ if z == nil {
+ z = &zoneTold{}
+ a.ask.zones[me.ID] = z
}
- err := a.ask.client.SetTimeZone(ctx, token, a.ask.zone)
- var e *equipo.Error
- if err != nil && !(errors.As(err, &e) && e.Status == http.StatusNotFound) {
- a.logger.Warn("ask: time zone", "err", err)
+ switch {
+ case fresh && z.busy:
+ z.again = true
+ case fresh:
+ z.settled, z.retryAt = false, time.Time{}
+ }
+ if z.busy || z.settled || time.Now().Before(z.retryAt) {
+ a.ask.zoneMu.Unlock()
return
}
- a.ask.zoned.Store(me.ID, a.ask.zone)
+ z.busy = true
+ a.ask.zoneMu.Unlock()
+ go func() {
+ ctx, cancel := context.WithTimeout(context.Background(), zoneWait)
+ 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 {
+ a.logger.Warn("ask: time zone", "err", err, "settled", settled)
+ }
+ a.ask.zoneMu.Lock()
+ defer a.ask.zoneMu.Unlock()
+ z.busy, z.settled = false, settled && !z.again
+ z.again = false
+ if !settled {
+ z.retryAt = time.Now().Add(zoneRetry)
+ }
+ }()
}
// memberConn is a member's lock, held while their connection changes or
diff --git a/internal/web/ask_relay.go b/internal/web/ask_relay.go
index 9499880..cd184aa 100644
--- a/internal/web/ask_relay.go
+++ b/internal/web/ask_relay.go
@@ -172,9 +172,12 @@ func (a *app) askAnswer(w http.ResponseWriter, r *http.Request) {
// askCarryOn is POST /ask/cards/{id}/carry_on: a paused job's "Carry on
// now", at the revision the person saw, relayed as card answers are. The
-// answer is {"card": the job card as it is now}. A 409 (card_stale,
-// not_paused, carry_on_unavailable) is stale: the conversation is read
-// afresh, and nothing is resent.
+// answer is {"card": the job card as it is now}, or {"card": null} when
+// Base does not draw the card Equipo gave (the clients then read the
+// conversation afresh). A 409 (card_stale, not_paused,
+// carry_on_unavailable) is stale: the conversation is read afresh, and
+// nothing is resent. So is a 404, which is final: Equipo has no such job
+// card for the person.
func (a *app) askCarryOn(w http.ResponseWriter, r *http.Request) {
c, ok := a.askBearer(w, r)
if !ok {
@@ -182,6 +185,9 @@ func (a *app) askCarryOn(w http.ResponseWriter, r *http.Request) {
}
rev, _ := strconv.ParseInt(r.PostFormValue("revision"), 10, 64)
in, err := a.ask.client.CarryOnNow(r.Context(), c.token, chi.URLParam(r, "id"), rev, askKey(r.PostFormValue("key")))
+ if e := (*equipo.Error)(nil); errors.As(err, &e) && e.Status == http.StatusNotFound {
+ err = &equipo.Error{Status: http.StatusConflict, Code: e.Code}
+ }
var out struct {
Card *equipo.Card `json:"card"`
}
diff --git a/internal/webtest/ask_test.go b/internal/webtest/ask_test.go
index 40e3994..fe394b7 100644
--- a/internal/webtest/ask_test.go
+++ b/internal/webtest/ask_test.go
@@ -1649,7 +1649,13 @@ func TestAskJobPaused(t *testing.T) {
if !strings.Contains(job, square) || strings.Contains(job, clock) || strings.Contains(job, "M9.5 7.5v9M14.5 7.5v9") {
t.Errorf("stopped's mark:\n%s", job)
}
- // ask.js and the native app draw the same marks.
+ // ask.js draws the same words, and it and the native app the same marks.
+ js, _ := os.ReadFile("../look/static/ask.js")
+ for _, words := range []string{`"Carry on now"`, `"Uses your other plan, at no extra cost."`, `"That didn't send. Try again."`} {
+ if !strings.Contains(string(js), words) {
+ t.Errorf("ask.js has no %s", words)
+ }
+ }
for _, file := range []string{"../look/static/ask.js", "../../native/apple/Sources/BaseKit/Look/Marks.swift"} {
raw, _ := os.ReadFile(file)
for _, d := range []string{clock, square} {
@@ -1731,13 +1737,37 @@ func TestAskCarryOnNow(t *testing.T) {
if r := json409(fresh); r.Code != 409 || strings.TrimSpace(r.Body) != `{"state":"ready"}` {
t.Errorf("carry on unavailable: %d %s", r.Code, r.Body)
}
+ // No such job card for the person (Equipo's 404) is final, never "try
+ // again": stale for the panel, /ask without a problem for a form.
+ path = "/ask/cards/c_nothing/carry_on"
+ if r := json409(url.Values{"revision": {"1"}, "key": {"k-gone"}}); r.Code != 409 || strings.TrimSpace(r.Body) != `{"state":"ready"}` {
+ t.Errorf("no such card: %d %s", r.Code, r.Body)
+ }
+ if r := a.post(path, url.Values{"revision": {"1"}, "key": {"k-gone-2"}}); r.Code != 303 || r.Location() != "/ask" {
+ t.Errorf("no such card, without scripts: %d %q", r.Code, r.Location())
+ }
}
-// Base tells Equipo the team's time zone (BASE_TIMEZONE), so the
-// Assistant's times are in it: once a connection is made, not again on
-// every read. Base opts in to the paused job state on the snapshot and the
-// event stream (job_states=paused).
-func TestAskSendsTheTeamZoneAndOptsInToPaused(t *testing.T) {
+// zoneCalls waits up to two seconds for Equipo to have had n PUT
+// time-zone calls (Base makes them on their own, off the page's path), and
+// returns them; then it waits a little more and fails if any more came.
+func zoneCalls(t *testing.T, f *equipotest.Fake, n int) []equipotest.Call {
+ t.Helper()
+ const path = "/api/v1/assistant/time-zone"
+ for end := time.Now().Add(2 * time.Second); len(f.Calls(path)) < n && time.Now().Before(end); {
+ time.Sleep(10 * time.Millisecond)
+ }
+ time.Sleep(100 * time.Millisecond)
+ calls := f.Calls(path)
+ if len(calls) != n {
+ t.Fatalf("%d time-zone calls, want %d: %+v", len(calls), n, calls)
+ }
+ return calls
+}
+
+// newZonedAskApp is newAskApp with BASE_TIMEZONE at Europe/Madrid.
+func newZonedAskApp(t *testing.T) (*testApp, *equipotest.Fake) {
+ t.Helper()
madrid, err := time.LoadLocation("Europe/Madrid")
if err != nil {
t.Fatal(err)
@@ -1746,13 +1776,23 @@ func TestAskSendsTheTeamZoneAndOptsInToPaused(t *testing.T) {
a := newAppConfigured(t, func(*sql.DB, config.Config) web.Installer { return noInstaller{} }, madrid,
func(c *config.Config) { c.EquipoOrigin = f.URL })
a.signedInOwner()
+ return a, f
+}
+
+// Base tells Equipo the team's time zone (BASE_TIMEZONE), so the
+// Assistant's times are in it, only if the person has none of their own
+// (only_if_unset): once a connection is made, not again on every read.
+// Base opts in to the paused job state on the snapshot and the event
+// stream (job_states=paused).
+func TestAskSendsTheTeamZoneAndOptsInToPaused(t *testing.T) {
+ a, f := newZonedAskApp(t)
a.connectEquipo(f)
a.get("/ask")
a.get("/ask")
- zones := f.Calls("/api/v1/assistant/time-zone")
- if len(zones) != 1 || zones[0].Method != http.MethodPut || strings.TrimSpace(zones[0].Body) != `{"time_zone":"Europe/Madrid"}` ||
+ zones := zoneCalls(t, f, 1)
+ if zones[0].Method != http.MethodPut || strings.TrimSpace(zones[0].Body) != `{"only_if_unset":true,"time_zone":"Europe/Madrid"}` ||
f.TimeZone() != "Europe/Madrid" {
- t.Errorf("time zone told: %+v", zones)
+ t.Errorf("time zone told: %+v, Equipo has %q", zones, f.TimeZone())
}
snaps := f.Calls("/api/v1/assistant/snapshot")
if len(snaps) == 0 {
@@ -1781,6 +1821,63 @@ func TestAskSendsTheTeamZoneAndOptsInToPaused(t *testing.T) {
}
}
+// 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) {
+ a, f := newZonedAskApp(t)
+ f.SetTimeZone("Europe/Berlin")
+ a.connectEquipo(f)
+ a.get("/ask")
+ zoneCalls(t, f, 1)
+ if f.TimeZone() != "Europe/Berlin" {
+ t.Errorf("Base replaced the person's zone: %q", f.TimeZone())
+ }
+}
+
+// Fable's review S1: the time-zone call never holds up a page. With it
+// hanging, /ask, Home and /ask/state each answer at once, and it is one
+// call, not one per read.
+func TestAskZoneNeverHoldsThePage(t *testing.T) {
+ a, f := newZonedAskApp(t)
+ hold := f.HoldTimeZone()
+ defer close(hold)
+ a.connectEquipo(f)
+ for _, page := range []string{"/ask", "/", "/ask/state", "/ask"} {
+ start := time.Now()
+ if r := a.get(page); r.Code != 200 {
+ t.Fatalf("%s: %d", page, r.Code)
+ }
+ if took := time.Since(start); took > time.Second {
+ t.Errorf("%s took %v with the time-zone call hanging", page, took)
+ }
+ }
+ zoneCalls(t, f, 1)
+}
+
+// An answer that settles it (a 2xx, or a 4xx other than 429: Fable's 422
+// for a zone Equipo refuses, and an older Equipo's 404) is never sent
+// again; a failure (a 5xx, a 429) is not tried again for a while: one call
+// over a connect and three reads, either way.
+func TestAskZoneIsToldOnce(t *testing.T) {
+ for _, tc := range []struct {
+ status int
+ code string
+ }{{422, "invalid_input"}, {404, "not_found"}, {500, "internal"}, {503, "unavailable"}, {429, "rate_limited"}} {
+ t.Run(strconv.Itoa(tc.status), func(t *testing.T) {
+ a, f := newZonedAskApp(t)
+ f.RefuseTimeZone(tc.status, tc.code)
+ a.connectEquipo(f)
+ zoneCalls(t, f, 1)
+ for _, page := range []string{"/ask", "/", "/ask/state"} {
+ if r := a.get(page); r.Code != 200 {
+ t.Fatalf("%s: %d", page, r.Code)
+ }
+ }
+ zoneCalls(t, f, 1)
+ })
+ }
+}
+
// A go-ahead or Publish card that belongs to a job is drawn under its
// 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
diff --git a/native/apple/Sources/BaseKit/Ask/AskModel.swift b/native/apple/Sources/BaseKit/Ask/AskModel.swift
index 86f15d4..f31bf55 100644
--- a/native/apple/Sources/BaseKit/Ask/AskModel.swift
+++ b/native/apple/Sources/BaseKit/Ask/AskModel.swift
@@ -94,6 +94,9 @@ import Observation
/// Cards with an answer on its way, or a paused job's Carry on now:
/// their buttons are disabled.
public private(set) var answering: Set<String> = []
+ /// Jobs whose Carry on now failed and can be tried again: the line
+ /// their view shows under the button (job id to text).
+ public private(set) var carryOnErrors: [String: String] = [:]
/// Jobs waiting on the person (asking or stopped): the sidebar's badge.
public var waitingJobs: Int {
@@ -334,19 +337,23 @@ import Observation
/// A paused job's "Carry on now", bound to the revision the person
/// saw (ask.js `carryOnNow`). Its key is kept until an answer settles
/// the outcome, so pressing it again after a lost answer is the same
- /// request. A 409 (the job moved on, is no longer paused, or no longer
- /// offers it) reads the conversation afresh; it is never resent.
+ /// request. A 409 (the job moved on, is no longer paused, no longer
+ /// offers it, or is gone) or an answer with no card reads the
+ /// conversation afresh; it is never resent. A failure that can be tried
+ /// again says so in the job's view (`carryOnErrors`), as well as on the
+ /// status line, which a sheet over the thread hides.
public func carryOn(_ job: AskCard) async {
guard job.offersCarryOn, !answering.contains(job.id) else { return }
let key = carryOnKeys[job.id]?.revision == job.revision ? carryOnKeys[job.id]!.key : BaseClient.newKey()
carryOnKeys[job.id] = (job.revision, key)
answering.insert(job.id)
+ carryOnErrors[job.id] = nil
defer { answering.remove(job.id) }
do {
let out = try await client.carryOn(card: job.id, revision: job.revision, key: key)
carryOnKeys[job.id] = nil
if phase != .ready { phase = .ready }
- if let c = out.card { add(c) }
+ if let c = out.card { add(c) } else { await load() }
} catch {
if case .server(409, _, let state) = error, state != "norunner", state != "oldrunner" {
carryOnKeys[job.id] = nil
@@ -354,6 +361,18 @@ import Observation
return
}
refusedWrite(error, keepsKey: { carryOnKeys[job.id] = nil })
+ if Self.tryAgain(error) { carryOnErrors[job.id] = BaseText.text("ask.not_sent") }
+ }
+ }
+
+ /// Whether refusedWrite says to try again (ask.not_sent): no answer,
+ /// an unreadable one, or a refusal that is not one of Ask's states.
+ static func tryAgain(_ error: BaseAPIError) -> Bool {
+ switch error {
+ case .unauthenticated: false
+ case .offline, .badResponse: true
+ case .server(let code, _, let state):
+ code != 409 && !(state.map { [.connect, .pending, .reconnect, .norunner, .oldrunner, .notLinked].contains(AskPhase(server: $0)) } ?? false)
}
}
diff --git a/native/apple/Sources/BaseKit/Ask/Pill.swift b/native/apple/Sources/BaseKit/Ask/Pill.swift
index 0a87e4c..230afa1 100644
--- a/native/apple/Sources/BaseKit/Ask/Pill.swift
+++ b/native/apple/Sources/BaseKit/Ask/Pill.swift
@@ -30,8 +30,10 @@ struct JobPill: View {
let job: AskModel.Job
let busy: Set<String>
let timeZone: TimeZone?
- /// A paused job's "Carry on now", from its view.
+ /// A paused job's "Carry on now", from its view, and why the last one
+ /// failed (job id to text).
var carryOn: (AskCard) -> Void = { _ in }
+ var carryOnErrors: [String: String] = [:]
let answer: (AskCard, AskCard.Option) -> Void
@State private var viewing = false
@Environment(\.colorScheme) private var scheme
@@ -99,7 +101,8 @@ struct JobPill: View {
.accessibilityLabel(Text(verbatim: label))
.accessibilityAddTraits(.isButton)
.modifier(JobViewPresentation(isPresented: $viewing, job: job, timeZone: timeZone,
- carrying: busy.contains(job.card.id), carryOn: { carryOn(job.card) }))
+ carrying: busy.contains(job.card.id), carryOnError: carryOnErrors[job.card.id],
+ carryOn: { carryOn(job.card) }))
let link = job.card.go.flatMap { go in go.url.map { (go.label, $0) } }.map { label, url in
Button { openURL(url) } label: {
@@ -168,17 +171,18 @@ struct JobViewPresentation: ViewModifier {
let job: AskModel.Job
let timeZone: TimeZone?
let carrying: Bool
+ let carryOnError: String?
let carryOn: () -> Void
func body(content: Content) -> some View {
#if os(macOS)
content.popover(isPresented: $isPresented, arrowEdge: .top) {
- JobView(job: job, timeZone: timeZone, close: { isPresented = false }, carrying: carrying, carryOn: carryOn)
+ JobView(job: job, timeZone: timeZone, close: { isPresented = false }, carrying: carrying, carryOnError: carryOnError, carryOn: carryOn)
.frame(width: 320)
.frame(maxHeight: 520)
}
#else
content.sheet(isPresented: $isPresented) {
- JobView(job: job, timeZone: timeZone, close: { isPresented = false }, carrying: carrying, carryOn: carryOn)
+ JobView(job: job, timeZone: timeZone, close: { isPresented = false }, carrying: carrying, carryOnError: carryOnError, carryOn: carryOn)
.presentationDetents([.medium, .large])
.presentationDragIndicator(.visible)
}
@@ -199,14 +203,16 @@ public struct JobView: View {
var now: Date = .now
/// Carry on now is on its way: its button is disabled.
let carrying: Bool
+ /// Why the last Carry on now failed, shown under it.
+ let carryOnError: String?
let carryOn: () -> Void
@Environment(\.colorScheme) private var scheme
@Environment(\.openURL) private var openURL
public init(job: AskModel.Job, timeZone: TimeZone?, close: @escaping () -> Void, now: Date = .now,
- carrying: Bool = false, carryOn: @escaping () -> Void = {}) {
+ carrying: Bool = false, carryOnError: String? = nil, carryOn: @escaping () -> Void = {}) {
self.job = job; self.timeZone = timeZone; self.close = close; self.now = now
- self.carrying = carrying; self.carryOn = carryOn
+ self.carrying = carrying; self.carryOnError = carryOnError; self.carryOn = carryOn
}
public var body: some View {
@@ -249,6 +255,10 @@ public struct JobView: View {
.disabled(carrying)
Text(BaseText.text("assistant.job.carry_on_note"))
.font(BaseFont.body(13, relativeTo: .footnote)).foregroundStyle(p[.haze])
+ if let carryOnError {
+ Text(verbatim: carryOnError)
+ .font(BaseFont.body(13, relativeTo: .footnote))
+ }
}
.padding(.top, 12)
}
diff --git a/native/apple/Sources/BaseKit/Ask/Thread.swift b/native/apple/Sources/BaseKit/Ask/Thread.swift
index 6c95294..0c6fcd3 100644
--- a/native/apple/Sources/BaseKit/Ask/Thread.swift
+++ b/native/apple/Sources/BaseKit/Ask/Thread.swift
@@ -106,7 +106,8 @@ struct AskThread: View {
case .job(let job) where layout == .panel && (job.state == .asking || job.state == .stopped):
EmptyView() // the panel shows them at its top (WaitingJobs)
case .job(let job):
- JobPill(job: job, busy: model.answering, timeZone: timeZone, carryOn: { card in Task { await model.carryOn(card) } }) { card, option in
+ JobPill(job: job, busy: model.answering, timeZone: timeZone, carryOn: { card in Task { await model.carryOn(card) } },
+ carryOnErrors: model.carryOnErrors) { card, option in
Task { await model.answer(card, option) }
}
case .card(let card):
diff --git a/native/apple/Tests/BaseKitTests/AskModelTests.swift b/native/apple/Tests/BaseKitTests/AskModelTests.swift
index f8d7eab..b779616 100644
--- a/native/apple/Tests/BaseKitTests/AskModelTests.swift
+++ b/native/apple/Tests/BaseKitTests/AskModelTests.swift
@@ -288,6 +288,36 @@ import XCTest
XCTAssertEqual(m.phase, .norunner)
}
+ /// Fable's review S3: a Carry on now that can be tried again says so in
+ /// the job's view (a sheet hides the status line), and the next press
+ /// 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)])
+ m.apply(.card(Self.pausedJob))
+ await m.carryOn(Self.pausedJob)
+ XCTAssertEqual(m.carryOnErrors["jp"], BaseText.text("ask.not_sent"))
+ await m.carryOn(Self.pausedJob)
+ XCTAssertNil(m.carryOnErrors["jp"])
+ XCTAssertEqual(fields(t.calls[0])["key"], fields(t.calls[1])["key"], "a 502 keeps the key")
+ let (n, _) = model([json(409, #"{"state":"norunner"}"#)])
+ n.apply(.card(Self.pausedJob))
+ await n.carryOn(Self.pausedJob)
+ XCTAssertTrue(n.carryOnErrors.isEmpty)
+ XCTAssertEqual(n.phase, .norunner)
+ }
+
+ /// Fable's review N2: an answer with no card Base draws reads the
+ /// conversation afresh.
+ func testACarryOnAnswerWithNoCardRedraws() async throws {
+ let (m, t) = model([json(200, #"{"card":null}"#), .respond(status: 200, body: Fixture.data("state-ready.json")), .hang])
+ m.apply(.card(Self.pausedJob))
+ await m.carryOn(Self.pausedJob)
+ XCTAssertEqual(t.calls[1].path, "/ask/state")
+ try await waitUntil { t.calls.count == 3 }
+ m.pause()
+ }
+
func testStopCancelsTheTurn() async {
let (m, t) = model([json(200, #"{"state":"ready"}"#)])
m.apply(.turn(AskTurn(id: "t8", kind: "chat", state: "running")))
diff --git a/native/apple/Tests/BaseSnapshots/AskSnapshots.swift b/native/apple/Tests/BaseSnapshots/AskSnapshots.swift
index cfddc74..cedbd47 100644
--- a/native/apple/Tests/BaseSnapshots/AskSnapshots.swift
+++ b/native/apple/Tests/BaseSnapshots/AskSnapshots.swift
@@ -42,6 +42,11 @@ final class AskSnapshots: XCTestCase {
SnapshotScreen("job-view-paused", mac: .width(320), iphone: .width(402)) {
JobView(job: AskFixtures.pausedJob, timeZone: AskFixtures.zone, close: {}, now: SnapshotSettings.now)
},
+ // Fable's review S3: a failed Carry on now says so in the view.
+ SnapshotScreen("job-view-paused-failed", mac: .width(320), iphone: .width(402)) {
+ JobView(job: AskFixtures.pausedJob, timeZone: AskFixtures.zone, close: {}, now: SnapshotSettings.now,
+ carryOnError: BaseText.text("ask.not_sent"))
+ },
SnapshotScreen("norunner", mac: .fixed(width: 640, height: 420), iphone: .fixed(width: 402, height: 520)) {
AskFrame { AskView(model: AskFixtures.model(state: "norunner", extra: AskFixtures.shortThread), layout: frameLayout, timeZone: AskFixtures.zone, actions: AskActions {}) }
},
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-dark-ax3.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-dark-ax3.png
new file mode 100644
index 0000000..355934e
Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-dark-ax3.png differ
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-dark-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-dark-default.png
new file mode 100644
index 0000000..06fd4cf
Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-dark-default.png differ
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-light-ax3.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-light-ax3.png
new file mode 100644
index 0000000..4f756ff
Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-light-ax3.png differ
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-light-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-light-default.png
new file mode 100644
index 0000000..0fb9ad8
Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-light-default.png differ
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-failed-dark-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-failed-dark-default.png
new file mode 100644
index 0000000..d4a65fa
Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-failed-dark-default.png differ
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-failed-light-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-failed-light-default.png
new file mode 100644
index 0000000..e2c483e
Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-failed-light-default.png differ