Merge branch 'feat/paused-jobs' into main
Merge branch 'feat/paused-jobs' into main Base's half of the clearer paused-work design (Paul, 2026-11-24): a paused job state (opted into from Equipo with job_states=paused) with a clock mark and Equipo's words; Carry on now relayed to Equipo's carry_on (kept key, 409s redraw, failure shown and announced in the job view); the member's zone sent in the background with only_if_unset; stopped gets its own mark; BASE_TIMEZONE defaults to Europe/Dublin. "Change the limit" deferred. Copy accepted by delegation (Luna). Reviewed by Claude Fable 5.2 (approved at 6ce1ff9; nits in 598254e). Hub CI green.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 files changed,
+1,505
−49
.env.local.example+1 −1README.md+1 −1docs/api/base-native-v1.md+23 −3docs/superpowers/specs/2026-11-24-paused-work-base.md+58 −0internal/browsertest/cards_test.go+79 −0internal/config/config.go+1 −1internal/config/config_test.go+1 −1internal/equipo/chat.go+45 −6internal/equipo/equipo_test.go+138 −0internal/equipo/equipotest/chat.go+197 −2internal/look/static/app.css+12 −2internal/look/static/ask.js+70 −8internal/web/app.go+1 −1internal/web/ask.go+17 −2internal/web/ask_connect.go+73 −0internal/web/ask_internal_test.go+107 −0internal/web/ask_relay.go+27 −0internal/web/templates/partials/chat.html+5 −4internal/webtest/ask_native_contract_test.go+41 −0internal/webtest/ask_test.go+303 −1native/apple/Sources/BaseKit/API/Client.swift+5 −0native/apple/Sources/BaseKit/API/Models.swift+20 −3native/apple/Sources/BaseKit/Ask/AskModel.swift+63 −2native/apple/Sources/BaseKit/Ask/Pill.swift+36 −5native/apple/Sources/BaseKit/Ask/Thread.swift+2 −1native/apple/Sources/BaseKit/Look/Marks.swift+10 −4native/apple/Sources/BaseKit/Look/Palette.swift+3 −0native/apple/Sources/BaseKit/Resources/Localizable.xcstrings+24 −0native/apple/Tests/BaseKitTests/AskModelTests.swift+104 −0native/apple/Tests/BaseKitTests/LookTests.swift+7 −1native/apple/Tests/BaseSnapshots/AskSnapshots.swift+31 −0native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-dark-ax3.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-dark-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-dark-ax3.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-dark-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-light-ax3.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-failed-light-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-light-ax3.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-light-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-dark-ax3.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-dark-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-light-ax3.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-light-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-dark-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-failed-dark-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-failed-light-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-light-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/paused-dark-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/paused-light-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-look/iphone/marks-dark-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-look/iphone/marks-light-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-look/mac/marks-dark-default.pngbinarynative/apple/Tests/BaseSnapshots/__Snapshots__/base-look/mac/marks-light-default.pngbinary
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 === [90m9:48PM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net [90m9:48PM[0m [32mINF[0m [1m1 commits scanned.[0m [90m9:48PM[0m [32mINF[0m [1mscanned ~2380355 bytes (2.38 MB) in 260ms[0m [90m9:48PM[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.76s 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.432s amadan.net/oficina/base/internal/webtest receipt: slow package 600ms amadan.net/oficina/base/internal/operations receipt: slow package 548ms amadan.net/oficina/base/internal/issuer receipt: slow package 214ms amadan.net/oficina/base/internal/consumer receipt: slow package 162ms amadan.net/oficina/base/internal/web receipt: slow test 1.51s amadan.net/oficina/base/internal/webtest TestHomeDoesNotWaitOnAStalledSnapshot receipt: slow test 1.08s amadan.net/oficina/base/internal/webtest TestAskZoneIsToldOnce receipt: slow test 520ms amadan.net/oficina/base/internal/operations TestOperationsRefusals receipt: slow test 270ms amadan.net/oficina/base/internal/issuer TestAuthorizeSignsForInstalledApp receipt: slow test 240ms 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/.env.local.example b/.env.local.example| index f41012d..9ee7885 100644 |
| --- a/.env.local.example |
| +++ b/.env.local.example |
| @@ -9,7 +9,7 @@ BASE_OWNER=owner@example.com |
| # openssl rand -base64 32 |
| BASE_INSTANCE_KEY= |
| BASE_APPS_DOMAIN=apps.example.com |
| -BASE_TIMEZONE=Europe/London |
| +BASE_TIMEZONE=Europe/Dublin |
| BASE_PLATFORM_CONSOLE=https://console.example.com |
| BASE_PLATFORM_ACCOUNT=acme |
| BASE_PLATFORM_INSTANCE_TOKEN= |
diff --git a/README.md b/README.md| index 7b74326..edbf992 100644 |
| --- a/README.md |
| +++ b/README.md |
| @@ -40,7 +40,7 @@ Everything is an environment variable. `BASE_ORIGIN`, `BASE_OWNER` and |
| - `BASE_NAME` is what your team calls Base, such as "Acme" (default `Base`). |
| - `BASE_SLUG` names the apps' hostnames: `<slug>-<appid>.<BASE_APPS_DOMAIN>`. |
| Lowercase letters, digits and `-`, at most 19 characters (default `base`). |
| -- `BASE_TIMEZONE` is where dates are shown (default `Europe/London`). |
| +- `BASE_TIMEZONE` is where dates are shown, and the time zone Ask sends Equipo so the Assistant writes times in it ("Paused until 21:00"); default `Europe/Dublin`. |
| - `BASE_ASSERTION_KEY` is Base's signing key. `go run ./tools/keygen` prints |
| a fresh one. Without it, no one can open an installed app. Keep it stable |
| across restarts: apps check sign-ins against its public half. |
diff --git a/docs/api/base-native-v1.md b/docs/api/base-native-v1.md| index 620fa6d..24fdf29 100644 |
| --- a/docs/api/base-native-v1.md |
| +++ b/docs/api/base-native-v1.md |
| @@ -138,14 +138,18 @@ links to http(s) only, bold and italics). |
| **Turn** `{"id", "kind", "state": "queued"|"running"|"waiting"|"replied"|"failed"|"cancelled", "reason"}`. |
| -**Card** `{"id", "revision", "kind", "state", "question", "options": [{"value","label"}], "links": [{"label","url","rel"?}], "result", "job"?, "detail"?, "started_at"?, "turn_id"?}`. |
| +**Card** `{"id", "revision", "kind", "state", "question", "options": [{"value","label"}], "links": [{"label","url","rel"?}], "result", "job"?, "detail"?, "started_at"?, "carry_on"?, "turn_id"?}`. |
| - `kind` is `question`, `confirm`, `outcome`, `connect` or `job`; a card is |
| `open` while it waits for an answer. Every link is absolute http(s). |
| - `rel` is `equipo` (a job's page in Equipo) or `oficina_connect` (Base's |
| own `/ask/oficina/connect`, a browser flow). |
| - A job card has no options; its `state` is `working`, `asking`, `ready`, |
| - `done` or `stopped`; `result` is its short status, `detail` one sentence |
| - more and `started_at` when it began. |
| + `done`, `paused` or `stopped`; `result` is its short status, `detail` one sentence |
| + more and `started_at` when it began. A `paused` job carries on by itself |
| + (draw it with the clock mark); its `result` and `detail` are Equipo's, |
| + already in the team's time zone ("Paused until 21:00"): show them as |
| + given. `carry_on: true` (on a `paused` job card only, else absent) offers |
| + "Carry on now" (`POST /ask/cards/{id}/carry_on`). |
| - `job` names the job card a card belongs to; `turn_id`, on a connect card |
| from the stream, the turn that raised it. |
| @@ -202,6 +206,22 @@ Form: `choice` (an option's `value`), `revision` (the card's, as seen) and |
| - `409 {"state":"ready"}`: the card moved on (answered, or a newer |
| revision). Reload `/ask/state` to redraw it. |
| +### `POST /ask/cards/{id}/carry_on` |
| + |
| +A paused job's "Carry on now". Form: `revision` (the job card's, as seen) |
| +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, 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 |
| | status | body | meaning | |
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..a5607db |
| --- /dev/null |
| +++ b/docs/superpowers/specs/2026-11-24-paused-work-base.md |
| @@ -0,0 +1,58 @@ |
| +# 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. 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 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). |
| + |
| +## 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 d6cdff6..d5d3fe7 100644 |
| --- a/internal/browsertest/cards_test.go |
| +++ b/internal/browsertest/cards_test.go |
| @@ -764,3 +764,82 @@ func TestAskJobViewScriptsOffInPlace(t *testing.T) { |
| rig.Screen(".ask-page", "the job view opened in place, scripts off") |
| } |
| } |
| + |
| +// A paused job (clearer paused work, 2026-11-24): the pill's clock mark on |
| +// the calm indigo, its status as Equipo wrote it, and in its view the |
| +// sentence and "Carry on now" with the line under it, readable in both |
| +// themes. Carry on now posts once, the card's revision and a key (the |
| +// body's idempotency_key and the Idempotency-Key header), and the job |
| +// redraws in place, working, with no button. Stopped's mark is a square. |
| +func TestAskJobPausedCarriesOn(t *testing.T) { |
| + rig, f := askBase(t) |
| + openPanel(t, rig) |
| + wait := func(js string) { |
| + t.Helper() |
| + drive(t, rig, chromedp.Poll[chromedp.Void](js, chromedp.WithPollingTimeout(10*time.Second))) |
| + } |
| + settle := func() { drive(t, rig, chromedp.Sleep(250*time.Millisecond)) } |
| + stopped := f.AskJob("Invoice reminders") |
| + f.SetJob(stopped, "stopped", "Stopped: needs you", "It needs you.") |
| + id := f.AskJob("Bakery website") |
| + f.PauseJob(id, "Paused until 21:00", "It has reached the limit on its plan for now. It will carry on by itself at 21:00 (in 9 hours).", true) |
| + job := `#ask-panel li.job[data-job="` + id + `"]` |
| + wait(`document.querySelector(` + strconv.Quote(job) + `)?.dataset.state === "paused" && document.querySelector(` + strconv.Quote(job+` .jv-act`) + `) !== null`) |
| + drive(t, rig, prefersScheme("dark"), chromedp.Sleep(300*time.Millisecond)) |
| + if got := harness.Evaluate[string](rig, `[document.querySelector(`+strconv.Quote(job+` .pill-stage`)+`).textContent, |
| + document.querySelector(`+strconv.Quote(job+` .pill-main .state-mark path`)+`).getAttribute("d"), |
| + getComputedStyle(document.querySelector(`+strconv.Quote(job+` .pill-main .state-mark`)+`)).backgroundColor, |
| + document.querySelector('#ask-panel li.job[data-job="`+stopped+`"] .pill-main .state-mark path').getAttribute("d")].join("|")`); got != |
| + "Paused until 21:00|M19.2 12a7.2 7.2 0 1 1-14.4 0a7.2 7.2 0 1 1 14.4 0zM12 8.6V12l2.4 1.6|rgb(174, 184, 255)|M9 7.5h6a1.5 1.5 0 0 1 1.5 1.5v6a1.5 1.5 0 0 1-1.5 1.5H9a1.5 1.5 0 0 1-1.5-1.5V9A1.5 1.5 0 0 1 9 7.5z" { |
| + t.Errorf("paused pill (status|mark|colour|stopped's mark): %s", got) |
| + } |
| + drive(t, rig, chromedp.Click(chromedp.CSS(job+` summary`))) |
| + settle() |
| + view := job + ` .jobview` |
| + if got := harness.Evaluate[string](rig, `(() => { const v = document.querySelector(`+strconv.Quote(view)+`); |
| + return [v.checkVisibility(), v.querySelector(".jv-stage").textContent, v.querySelector(".jv-detail").textContent, |
| + v.querySelector(".jv-act button").textContent, v.querySelector(".jv-act small").textContent].join("|"); })()`); got != |
| + "true|Paused until 21:00|It has reached the limit on its plan for now. It will carry on by itself at 21:00 (in 9 hours).|Carry on now|Uses your other plan, at no extra cost." { |
| + t.Errorf("the paused job's view: %s", got) |
| + } |
| + for _, scheme := range []string{"dark", "light"} { |
| + drive(t, rig, prefersScheme(scheme), chromedp.Sleep(300*time.Millisecond)) |
| + mobileShot(t, rig, "jobview-paused-"+scheme) |
| + checkContrast(t, rig, "the paused job's view, "+scheme, view+" .jv-stage", view+" .jv-detail", view+" .jv-act button", view+" .jv-act small") |
| + iconContrast(t, rig, "the paused mark, "+scheme, job+" .pill-main .state-mark svg") |
| + } |
| + if got := harness.Evaluate[string](rig, `getComputedStyle(document.querySelector(`+strconv.Quote(job+` .pill-main .state-mark`)+`)).backgroundColor`); got != "rgb(75, 85, 201)" { |
| + t.Errorf("paused's colour in light: %s", got) |
| + } |
| + 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="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"`) |
| + settle() |
| + if n := harness.Evaluate[int](rig, `document.querySelectorAll(`+strconv.Quote(job+` .jv-act`)+`).length`); n != 0 { |
| + t.Errorf("Carry on now still shows on a working job") |
| + } |
| + calls := f.Calls("/api/v1/assistant/cards/" + id + "/carry_on") |
| + 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 || 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/config/config.go b/internal/config/config.go| index 7210701..82b4e39 100644 |
| --- a/internal/config/config.go |
| +++ b/internal/config/config.go |
| @@ -97,7 +97,7 @@ func Load(getenv func(string) string) (Config, error) { |
| } |
| tz := get("TIMEZONE") |
| if tz == "" { |
| - tz = "Europe/London" |
| + tz = "Europe/Dublin" |
| } |
| if cfg.Timezone, err = time.LoadLocation(tz); err != nil { |
| return Config{}, fmt.Errorf("BASE_TIMEZONE: %w", err) |
diff --git a/internal/config/config_test.go b/internal/config/config_test.go| index 48c8a51..ff98072 100644 |
| --- a/internal/config/config_test.go |
| +++ b/internal/config/config_test.go |
| @@ -29,7 +29,7 @@ func TestLoadRequiresOriginAndOwner(t *testing.T) { |
| if err != nil { |
| t.Fatal(err) |
| } |
| - if cfg.Owner != "owner@example.com" || cfg.Slug != "base" || cfg.Timezone.String() != "Europe/London" { |
| + if cfg.Owner != "owner@example.com" || cfg.Slug != "base" || cfg.Timezone.String() != "Europe/Dublin" { |
| t.Errorf("defaults wrong: %+v", cfg) |
| } |
| } |
diff --git a/internal/equipo/chat.go b/internal/equipo/chat.go| index 18332e3..162e727 100644 |
| --- a/internal/equipo/chat.go |
| +++ b/internal/equipo/chat.go |
| @@ -51,7 +51,9 @@ type Turn struct { |
| // ended (Result). Base knows no kind's words of its own. A job card's |
| // question is the job's title, Result its short status, Detail one |
| // sentence more and StartedAt when it began; Job is the job card a |
| -// go-ahead or Publish card belongs to. |
| +// go-ahead or Publish card belongs to. A paused job's Result and Detail |
| +// are already in the person's time zone ("Paused until 21:00"), and |
| +// CarryOn says the person may start it again now (CarryOnNow). |
| type Card struct { |
| ID string `json:"id"` |
| Revision int64 `json:"revision"` |
| @@ -64,6 +66,7 @@ type Card struct { |
| Job string `json:"job,omitempty"` |
| Detail string `json:"detail,omitempty"` |
| StartedAt *time.Time `json:"started_at,omitempty"` |
| + CarryOn bool `json:"carry_on,omitempty"` |
| // Turn is the turn that raised a connect card, as its event said |
| // (WithTurn); never read from the card's own fields. |
| Turn string `json:"turn_id,omitempty"` |
| @@ -101,6 +104,9 @@ const ( |
| JobReady = "ready" |
| JobDone = "done" |
| JobStopped = "stopped" |
| + // JobPaused is a job held for a while (its allowance or spending limit |
| + // reached, its runner offline) that carries on by itself. |
| + JobPaused = "paused" |
| ) |
| // LinkEquipo is the rel of a job card's link to the job's page in Equipo. |
| @@ -118,7 +124,7 @@ const OficinaConnectPath = "/ask/oficina/connect" |
| // options and links, and a link only if it is an http(s) URL (WebURL), |
| // with a rel only if it is LinkEquipo (or, for CleanAt, Base's own connect link). A job card has no options, and is |
| // kept only in a state Base knows; Detail and StartedAt are kept on a job |
| -// card only, and Job only when it looks like a card id (validJob). ok is |
| +// card only, CarryOn only on a paused one, and Job only when it looks like a card id (validJob). ok is |
| // false for every other kind of card. |
| func (c Card) Clean() (Card, bool) { return c.CleanAt("") } |
| @@ -130,7 +136,7 @@ func (c Card) CleanAt(base string) (Card, bool) { |
| case CardQuestion, CardConfirm, CardOutcome, CardConnect: |
| case CardJob: |
| switch c.State { |
| - case JobWorking, JobAsking, JobReady, JobDone, JobStopped: |
| + case JobWorking, JobAsking, JobReady, JobDone, JobStopped, JobPaused: |
| default: |
| return Card{}, false |
| } |
| @@ -141,6 +147,7 @@ func (c Card) CleanAt(base string) (Card, bool) { |
| Options: []Option{}, Links: []Link{}, Result: c.Result} |
| if c.Kind == CardJob { |
| out.Detail, out.StartedAt = c.Detail, c.StartedAt |
| + out.CarryOn = c.CarryOn && c.State == JobPaused |
| } else { |
| for _, o := range c.Options { |
| out.Options = append(out.Options, Option{Value: o.Value, Label: o.Label}) |
| @@ -259,13 +266,30 @@ type Answered struct { |
| Turn Turn `json:"turn"` |
| } |
| +// JobStates is the query that opts in to the job states Base draws |
| +// beyond the five every Equipo sends: without it, Equipo sends a paused |
| +// job as working (same result and detail, no carry_on), since an older |
| +// Base drops a state it does not know. |
| +const JobStates = "job_states=" + JobPaused |
| + |
| // Snapshot reads the person's conversation in one go. |
| func (c *Client) Snapshot(ctx context.Context, token string) (Snapshot, error) { |
| var out Snapshot |
| - _, err := c.call(ctx, http.MethodGet, assistant+"/snapshot", token, "", nil, nil, &out) |
| + _, err := c.call(ctx, http.MethodGet, assistant+"/snapshot?"+JobStates, token, "", nil, nil, &out) |
| return out, err |
| } |
| +// 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"), 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 { |
| + 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 |
| +} |
| + |
| // Send sends the person's message: ErrNoRunner or ErrRunnerTooOld when |
| // the person has no runner that can answer. key makes a retry safe: |
| // Equipo keeps one message per key. It goes as the body's |
| @@ -292,6 +316,21 @@ func (c *Client) Answer(ctx context.Context, token, id, choice string, revision |
| return out, err |
| } |
| +// CarryOnNow starts paused job card id again now, at the card's revision: |
| +// what "Carry on now" asks, offered while the card's CarryOn is set. The |
| +// answer is the card as it is now (200 {"card": …}); the same key again |
| +// gives the same answer. A 409 says why it cannot: card_stale (the card |
| +// moved on), not_paused or carry_on_unavailable. key goes as the body's |
| +// idempotency_key and the Idempotency-Key header. |
| +func (c *Client) CarryOnNow(ctx context.Context, token, id string, revision int64, key string) (Card, error) { |
| + var out struct { |
| + Card Card `json:"card"` |
| + } |
| + in := map[string]any{"revision": revision, "idempotency_key": key} |
| + _, err := c.call(ctx, http.MethodPost, assistant+"/cards/"+url.PathEscape(id)+"/carry_on", token, key, nil, in, &out) |
| + return out.Card, err |
| +} |
| + |
| // RegisterHost tells Equipo where the person's Base operations live |
| // (origin) and the token Base minted for them (hostToken), which the |
| // Assistant presents when it calls them. A second call replaces the |
| @@ -306,9 +345,9 @@ func (c *Client) RegisterHost(ctx context.Context, token, origin, hostToken stri |
| // now). It gives up when the headers take longer than StreamHeaderTimeout. |
| // The caller reads and closes the body; cancelling ctx ends the stream. |
| func (c *Client) Events(ctx context.Context, token, after string) (*http.Response, error) { |
| - u := c.origin + assistant + "/events" |
| + u := c.origin + assistant + "/events?" + JobStates |
| if after != "" { |
| - u += "?after=" + url.QueryEscape(after) |
| + u += "&after=" + url.QueryEscape(after) |
| } |
| ctx, cancel := context.WithCancel(ctx) |
| req, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil) |
diff --git a/internal/equipo/equipo_test.go b/internal/equipo/equipo_test.go| index e59e3f1..d2b2e26 100644 |
| --- a/internal/equipo/equipo_test.go |
| +++ b/internal/equipo/equipo_test.go |
| @@ -475,3 +475,141 @@ func TestFakeGlanceIsLiveOnly(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// A paused job is kept, with carry_on when Equipo offers it; carry_on on a |
| +// job in any other state, or on another kind of card, is dropped. A job |
| +// card from an Equipo that never sends carry_on cleans to the same JSON |
| +// as before (no carry_on key at all). |
| +func TestCardCleanPausedJob(t *testing.T) { |
| + got, ok := equipo.Card{ID: "c_1", Revision: 4, Kind: equipo.CardJob, State: equipo.JobPaused, Question: "Bakery website", |
| + Result: "Paused until 21:00", Detail: "It will carry on by itself at 21:00 (in 9 hours).", CarryOn: true}.Clean() |
| + raw, _ := json.Marshal(got) |
| + const want = `{"id":"c_1","revision":4,"kind":"job","state":"paused","question":"Bakery website","options":[],"links":[],"result":"Paused until 21:00","detail":"It will carry on by itself at 21:00 (in 9 hours).","carry_on":true}` |
| + if !ok || string(raw) != want { |
| + t.Errorf("paused: %v\n got %s\nwant %s", ok, raw, want) |
| + } |
| + for _, c := range []equipo.Card{ |
| + {ID: "c_2", Kind: equipo.CardJob, State: equipo.JobWorking, CarryOn: true}, |
| + {ID: "c_3", Kind: equipo.CardJob, State: equipo.JobStopped, CarryOn: true}, |
| + {ID: "c_4", Kind: equipo.CardOutcome, State: "open", CarryOn: true}, |
| + } { |
| + got, _ := c.Clean() |
| + if raw, _ := json.Marshal(got); got.CarryOn || strings.Contains(string(raw), "carry_on") { |
| + t.Errorf("%s %s kept carry_on: %s", c.Kind, c.State, raw) |
| + } |
| + } |
| +} |
| + |
| +// CarryOnNow posts {revision, idempotency_key} with the key as the |
| +// Idempotency-Key and reads the card back from {"card"}; the same key |
| +// replays the answer; Equipo's 409s come back as errors with their codes. |
| +func TestCarryOnNow(t *testing.T) { |
| + f := equipotest.New(t) |
| + c := equipo.New(f.URL) |
| + cred := signIn(t, f, c) |
| + ctx := context.Background() |
| + job := f.AskJob("Bakery website") |
| + f.PauseJob(job, "Paused until 21:00", "It will carry on by itself at 21:00.", true) |
| + var e *equipo.Error |
| + if _, err := c.CarryOnNow(ctx, cred.Token, job, 1, "k-1"); !errors.As(err, &e) || e.Status != 409 || e.Code != "card_stale" { |
| + t.Errorf("stale: %v", err) |
| + } |
| + card, err := c.CarryOnNow(ctx, cred.Token, job, 3, "k-2") |
| + if err != nil || card.ID != job || card.State != equipo.JobWorking || card.Revision != 4 { |
| + t.Fatalf("carry on: %+v %v", card, err) |
| + } |
| + calls := f.Calls("/api/v1/assistant/cards/" + job + "/carry_on") |
| + if last := calls[len(calls)-1]; strings.TrimSpace(last.Body) != `{"idempotency_key":"k-2","revision":3}` || |
| + last.Header.Get("Idempotency-Key") != "k-2" { |
| + t.Errorf("sent: %+v", last) |
| + } |
| + 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) |
| + } |
| + // 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, 6, "k-4"); !errors.As(err, &e) || e.Code != "carry_on_unavailable" { |
| + t.Errorf("unavailable: %v", err) |
| + } |
| +} |
| + |
| +// Base opts in to the paused state on the snapshot and the event stream |
| +// (job_states=paused). Without it, as for an older Base, Equipo sends a |
| +// paused job as working, with its result and detail and no carry_on. |
| +func TestPausedIsOptIn(t *testing.T) { |
| + f := equipotest.New(t) |
| + c := equipo.New(f.URL) |
| + cred := signIn(t, f, c) |
| + ctx := context.Background() |
| + job := f.AskJob("Bakery website") |
| + f.PauseJob(job, "Paused until 21:00", "It will carry on by itself at 21:00.", true) |
| + snap, err := c.Snapshot(ctx, cred.Token) |
| + if err != nil || len(snap.Cards) != 1 || snap.Cards[0].State != equipo.JobPaused || !snap.Cards[0].CarryOn { |
| + t.Fatalf("opted in: %+v %v", snap.Cards, err) |
| + } |
| + if calls := f.Calls("/api/v1/assistant/snapshot"); calls[len(calls)-1].Query != "job_states=paused" { |
| + t.Errorf("snapshot's query %q", calls[len(calls)-1].Query) |
| + } |
| + res, err := c.Events(ctx, cred.Token, "40") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + res.Body.Close() |
| + if calls := f.Calls("/api/v1/assistant/events"); calls[len(calls)-1].Query != "job_states=paused&after=40" { |
| + t.Errorf("events' query %q", calls[len(calls)-1].Query) |
| + } |
| + |
| + // An older Base, asking without it. |
| + req, _ := http.NewRequest(http.MethodGet, f.URL+"/api/v1/assistant/snapshot", nil) |
| + req.Header.Set("Authorization", "Bearer "+cred.Token) |
| + raw, err := http.DefaultClient.Do(req) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer raw.Body.Close() |
| + var old equipo.Snapshot |
| + if json.NewDecoder(raw.Body).Decode(&old) != nil || len(old.Cards) != 1 || old.Cards[0].State != equipo.JobWorking || |
| + old.Cards[0].CarryOn || old.Cards[0].Result != "Paused until 21:00" { |
| + t.Errorf("without the opt-in: %+v", old.Cards) |
| + } |
| +} |
| + |
| +// SetTimeZone is PUT time-zone {time_zone}; a zone Equipo does not know is |
| +// 422 invalid_input. |
| +func TestSetTimeZone(t *testing.T) { |
| + f := equipotest.New(t) |
| + c := equipo.New(f.URL) |
| + cred := signIn(t, f, c) |
| + ctx := context.Background() |
| + const dublin = "Europe/Dublin" |
| + if err := c.SetTimeZone(ctx, cred.Token, dublin); err != nil || f.TimeZone() != dublin { |
| + 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) != `{"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 34db54f..9ff1a45 100644 |
| --- a/internal/equipo/equipotest/chat.go |
| +++ b/internal/equipo/equipotest/chat.go |
| @@ -1,6 +1,7 @@ |
| package equipotest |
| import ( |
| + "crypto/rand" |
| "encoding/json" |
| "fmt" |
| "io" |
| @@ -58,6 +59,7 @@ type card struct { |
| Job string `json:"job,omitempty"` |
| Detail string `json:"detail,omitempty"` |
| StartedAt *time.Time `json:"started_at,omitempty"` |
| + CarryOn bool `json:"carry_on,omitempty"` |
| } |
| type event struct { |
| @@ -82,12 +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]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; 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 |
| @@ -100,7 +114,7 @@ type chat struct { |
| } |
| func (c *chat) init() { |
| - c.turns, c.sent, c.wake = map[string]*turn{}, map[string]string{}, 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" |
| } |
| @@ -222,6 +236,21 @@ func (f *Fake) SetJob(id, state, result, detail string, links ...equipo.Link) { |
| } |
| } |
| +// PauseJob moves job card id to paused, with result and detail as Equipo |
| +// writes them in the person's time zone, and carryOn saying whether the |
| +// person may carry on now: a new revision, announced. |
| +func (f *Fake) PauseJob(id, result, detail string, carryOn bool) { |
| + f.SetJob(id, equipo.JobPaused, result, detail) |
| + f.cmu.Lock() |
| + defer f.cmu.Unlock() |
| + for _, c := range f.cards { |
| + if c.ID == id && c.CarryOn != carryOn { |
| + c.CarryOn, c.Revision = carryOn, c.Revision+1 |
| + f.emit("card", "card", c.ID, c.Revision, "", *c) |
| + } |
| + } |
| +} |
| + |
| // SetJobStarted moves when job card id started to at: a new revision, |
| // announced. |
| func (f *Fake) SetJobStarted(id string, at time.Time) { |
| @@ -348,6 +377,8 @@ func (f *Fake) serveChat(w http.ResponseWriter, r *http.Request) { |
| writeError(w, r, 404, "not_found") |
| case r.Method == http.MethodPut && p == "/host": |
| f.host(w, r) |
| + case r.Method == http.MethodPut && p == "/time-zone": |
| + f.timeZone(w, r) |
| case r.Method == http.MethodGet && p == "/snapshot": |
| f.snapshot(w, r) |
| case r.Method == http.MethodGet && p == "/messages": |
| @@ -360,6 +391,8 @@ func (f *Fake) serveChat(w http.ResponseWriter, r *http.Request) { |
| f.cancel(w, r, strings.TrimSuffix(strings.TrimPrefix(p, "/turns/"), "/cancel")) |
| case r.Method == http.MethodPost && strings.HasPrefix(p, "/cards/") && strings.HasSuffix(p, "/answer"): |
| f.answer(w, r, strings.TrimSuffix(strings.TrimPrefix(p, "/cards/"), "/answer")) |
| + case r.Method == http.MethodPost && strings.HasPrefix(p, "/cards/") && strings.HasSuffix(p, "/carry_on"): |
| + f.carryOn(w, r, strings.TrimSuffix(strings.TrimPrefix(p, "/cards/"), "/carry_on")) |
| case r.Method == http.MethodPost && p == "/oficina/connect": |
| f.oficinaConnect(w, r) |
| case r.Method == http.MethodPost && p == "/oficina/connect/finish": |
| @@ -400,7 +433,7 @@ func (f *Fake) snapshot(w http.ResponseWriter, r *http.Request) { |
| } |
| cards := []card{} |
| for _, c := range f.cards { |
| - cards = append(cards, *c) |
| + cards = append(cards, asSeen(*c, pausedOK(r))) |
| } |
| writeJSON(w, 200, map[string]any{ |
| "me": map[string]any{"id": f.address, "address": f.address, "role": "owner", |
| @@ -658,6 +691,164 @@ func (f *Fake) answer(w http.ResponseWriter, r *http.Request, id string) { |
| go f.answerTurn(t.ID, in.Choice) |
| } |
| +// 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 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. |
| +func (f *Fake) carryOn(w http.ResponseWriter, r *http.Request, id string) { |
| + var in struct { |
| + Revision int64 `json:"revision"` |
| + IdempotencyKey string `json:"idempotency_key"` |
| + } |
| + if strict(r, &in) != nil || len(in.IdempotencyKey) < 1 || len(in.IdempotencyKey) > 128 { |
| + writeError(w, r, 422, "invalid_input") |
| + return |
| + } |
| + f.cmu.Lock() |
| + defer f.cmu.Unlock() |
| + if f.carryStatus != 0 { |
| + writeError(w, r, f.carryStatus, "unavailable") |
| + return |
| + } |
| + var c *card |
| + for _, x := range f.cards { |
| + if x.ID == id && x.Kind == equipo.CardJob { |
| + c = x |
| + } |
| + } |
| + conflict := func(code string) { |
| + request := r.Header.Get("Idempotency-Key") |
| + if request == "" || len(request) > 256 { |
| + request = rand.Text() |
| + } |
| + writeJSON(w, 409, map[string]any{"code": code, "copy_key": "api." + code, "request_id": request, "card": *c}) |
| + } |
| + 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: |
| + conflict("not_paused") |
| + case !c.CarryOn: |
| + conflict("carry_on_unavailable") |
| + 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[c.ID+"\x00"+in.IdempotencyKey] = true |
| + writeJSON(w, 200, map[string]any{"card": *c}) |
| + } |
| +} |
| + |
| +// pausedOK reports whether r opted in to the paused job state |
| +// (job_states=paused, a comma-separated list). |
| +func pausedOK(r *http.Request) bool { |
| + for _, v := range r.URL.Query()["job_states"] { |
| + for _, s := range strings.Split(v, ",") { |
| + if s == equipo.JobPaused { |
| + return true |
| + } |
| + } |
| + } |
| + return false |
| +} |
| + |
| +// asSeen is c as a client sees it: without the paused opt-in, a paused |
| +// job comes as working with the same result and detail and no carry_on. |
| +func asSeen(c card, paused bool) card { |
| + if !paused && c.Kind == equipo.CardJob && c.State == equipo.JobPaused { |
| + c.State, c.CarryOn = equipo.JobWorking, false |
| + } |
| + return c |
| +} |
| + |
| +// 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"` |
| + 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") |
| + return |
| + } |
| + if _, err := time.LoadLocation(in.TimeZone); err != nil { |
| + writeError(w, r, 422, "invalid_input") |
| + return |
| + } |
| + f.cmu.Lock() |
| + 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 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 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. |
| +func (f *Fake) TimeZone() string { |
| + f.cmu.Lock() |
| + defer f.cmu.Unlock() |
| + return f.zone |
| +} |
| + |
| // stream is GET events: Server-Sent Events after ?after= (or |
| // Last-Event-ID), as Equipo writes them: then, live events (cursor 0, no |
| // id line) that come while the stream is open. |
| @@ -678,6 +869,7 @@ func (f *Fake) stream(w http.ResponseWriter, r *http.Request) { |
| } |
| after = n |
| } |
| + paused := pausedOK(r) |
| rc := http.NewResponseController(w) |
| w.Header().Set("Content-Type", "text/event-stream") |
| w.WriteHeader(200) |
| @@ -696,6 +888,9 @@ func (f *Fake) stream(w http.ResponseWriter, r *http.Request) { |
| wake := f.wake |
| f.cmu.Unlock() |
| for _, e := range batch { |
| + if c, ok := e.Data.(card); ok { |
| + e.Data = asSeen(c, paused) |
| + } |
| raw, _ := json.Marshal(e) |
| id := "" |
| if e.Cursor != 0 { |
diff --git a/internal/look/static/app.css b/internal/look/static/app.css| index d2bdb3e..0db5708 100644 |
| --- a/internal/look/static/app.css |
| +++ b/internal/look/static/app.css |
| @@ -113,7 +113,8 @@ |
| --card: rgba(139,92,246,.16); |
| --card-edge: rgba(139,92,246,.45); |
| /* A job's pill, and the colours of its states: working, ready and done |
| - are the accent; asking is warm; stopped is rose. --st-wash is how much |
| + are the accent; asking is warm; paused is a calm indigo (white or |
| + the dark ink on it is over 6:1); stopped is rose. --st-wash is how much |
| of the state's colour is washed in behind the pill. */ |
| --pill: rgba(238,242,248,.11); |
| --pill-edge: rgba(238,242,248,.26); |
| @@ -121,6 +122,7 @@ |
| --pill-lift: rgba(6,8,22,.55); |
| --st-ask: #FFB066; |
| --st-stop: #F9A8D4; |
| + --st-pause: #AEB8FF; |
| --st-wash: .2; |
| /* The composer's focus edge, teal into violet (each 3:1 on the panel, |
| in both themes), the glow under it, and the thinking bubble's spark, |
| @@ -171,7 +173,7 @@ |
| --theirs: rgba(255,255,255,.88); --theirs-edge: rgba(30,36,64,.1); --card: rgba(139,92,246,.1); |
| --card-edge: rgba(124,77,232,.35); --pill: rgba(255,255,255,.94); --pill-edge: rgba(30,36,64,.16); |
| --pill-shine: rgba(255,255,255,1); --pill-lift: rgba(40,46,90,.28); --st-ask: #C0651A; |
| - --st-stop: #C2366F; --st-wash: .13; --edge-a: #0B7A72; --edge-b: #6A3CD6; --edge-hi: #2B58C8; |
| + --st-stop: #C2366F; --st-pause: #4B55C9; --st-wash: .13; --edge-a: #0B7A72; --edge-b: #6A3CD6; --edge-hi: #2B58C8; |
| --edge-glow-a: rgba(15,168,156,.36); --edge-glow-b: rgba(124,77,232,.32); --spk-rose: #C2366F; --spk-amber: #B8641C; |
| } |
| :root[data-theme="dark"] { color-scheme: dark; } |
| @@ -257,6 +259,7 @@ |
| --pill-lift: light-dark(rgba(40,46,90,.28), rgba(6,8,22,.55)); |
| --st-ask: light-dark(#C0651A, #FFB066); |
| --st-stop: light-dark(#C2366F, #F9A8D4); |
| + --st-pause: light-dark(#4B55C9, #AEB8FF); |
| --edge-a: light-dark(#0B7A72, #6EE7DC); |
| --edge-b: light-dark(#6A3CD6, #B49CFC); |
| --edge-hi: light-dark(#2B58C8, #E6FFFB); |
| @@ -577,6 +580,7 @@ aside.ask-panel { position: absolute; top: 16px; right: 16px; bottom: 16px; widt |
| .job { align-self: flex-start; max-width: 100%; display: flex; flex-direction: column; gap: 6px; } |
| .job[data-state="working"], .job[data-state="ready"], .job[data-state="done"] { --st: var(--signal); } |
| .job[data-state="asking"] { --st: var(--st-ask); } |
| +.job[data-state="paused"] { --st: var(--st-pause); } |
| .job[data-state="stopped"] { --st: var(--st-stop); } |
| .pill { position: relative; display: flex; align-items: center; max-width: 100%; min-height: 44px; border-radius: 999px; |
| background: linear-gradient(90deg, color-mix(in srgb, var(--st) calc(var(--st-wash) * 100%), transparent), transparent 70%), var(--pill); |
| @@ -652,6 +656,12 @@ 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; } |
| +/* A paused job's one action, "Carry on now", and the quiet line under it |
| + 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); } |
| +.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 8a06515..12a2dae 100644 |
| --- a/internal/look/static/ask.js |
| +++ b/internal/look/static/ask.js |
| @@ -586,12 +586,13 @@ function start(root) { |
| // 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 jobStates = ["working", "asking", "ready", "done", "paused", "stopped"]; |
| const marks = { |
| asking: "M9.2 9.2a2.9 2.9 0 0 1 5.6 1c0 2-2.8 2.4-2.8 4.3M12 18.2h.01", |
| ready: "M8 16L16 8M9.5 8H16v6.5", |
| done: "M6 12.5l4 4 8-9", |
| - stopped: "M9.5 7.5v9M14.5 7.5v9", |
| + paused: "M19.2 12a7.2 7.2 0 1 1-14.4 0a7.2 7.2 0 1 1 14.4 0zM12 8.6V12l2.4 1.6", |
| + stopped: "M9 7.5h6a1.5 1.5 0 0 1 1.5 1.5v6a1.5 1.5 0 0 1-1.5 1.5H9a1.5 1.5 0 0 1-1.5-1.5V9A1.5 1.5 0 0 1 9 7.5z", |
| }; |
| const svgNS = "http://www.w3.org/2000/svg"; |
| function span(cls, text) { |
| @@ -702,8 +703,9 @@ function start(root) { |
| // The job view, opened from the pill, drawn as the server draws it (the |
| // ask-jobview template): the title, linked to the job's own page (its |
| // link with rel equipo, the link's label as its tooltip): the only place |
| - // that link is drawn. Then the status, one sentence more, when it |
| - // started, and the link to the work once there is something to see. |
| + // that link is drawn. Then the status, one sentence more, for a paused |
| + // job that offers it "Carry on now" (carryOn), when it started, and the |
| + // link to the work once there is something to see. |
| function jobView(c) { |
| const view = document.createElement("section"); |
| view.className = "jobview"; |
| @@ -734,6 +736,7 @@ 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)); |
| + if (c.state === "paused" && c.carry_on === true) view.append(carryOn(c)); |
| const ended = document.createElement("ol"); |
| ended.className = "jv-cards"; |
| view.append(ended); |
| @@ -752,6 +755,32 @@ function start(root) { |
| return view; |
| } |
| + // "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, 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"; |
| + form.method = "post"; |
| + form.action = `/ask/cards/${encodeURIComponent(c.id)}/carry_on`; |
| + const rev = document.createElement("input"); |
| + rev.type = "hidden"; |
| + rev.name = "revision"; |
| + rev.value = String(c.revision); |
| + const b = document.createElement("button"); |
| + b.className = "btn ghost"; |
| + b.type = "submit"; |
| + b.textContent = "Carry on now"; |
| + const note = document.createElement("small"); |
| + note.textContent = "Uses your other plan, at no extra cost."; |
| + const error = para("jv-error", ""); |
| + error.setAttribute("role", "status"); |
| + form.append(rev, b, note, error); |
| + return form; |
| + } |
| + |
| // When a job started (plan decision D19), as the server says it |
| // (startedText in ask.go): how long ago in minutes or hours, then from a |
| // day on, the day in Base's time zone (the thread's data-zone; this |
| @@ -1540,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)); |
| @@ -1576,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); |
| @@ -1612,6 +1642,10 @@ function start(root) { |
| thread.addEventListener("submit", async (e) => { |
| e.preventDefault(); |
| const form = e.target; |
| + if (form.matches("form.jv-act")) { |
| + carryOnNow(form); |
| + return; |
| + } |
| const choice = e.submitter && e.submitter.value; |
| if (!choice) return; |
| for (const b of form.querySelectorAll("button")) b.disabled = true; |
| @@ -1638,6 +1672,34 @@ function start(root) { |
| if (out.turn) setTurn(out.turn); |
| }); |
| + // 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, or is gone) or an |
| + // answer with no card reads the conversation afresh. Never resent by |
| + // 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; |
| + error.textContent = ""; |
| + const out = await post(form, {}, true); |
| + if ((!out && lastStatus === 409 && lastState === "ready") || (out && !out.card)) { |
| + await load(); |
| + return; |
| + } |
| + if (out) { |
| + addJob(out.card); |
| + return; |
| + } |
| + b.disabled = false; |
| + if (!runnerless.includes(lastState) && !["connect", "pending", "reconnect"].includes(lastState)) { |
| + error.textContent = "That didn't send. Try again."; |
| + } |
| + } |
| + |
| // On a wide screen the field is ready when the page opens: only with the |
| // chat open and ready, never on a phone (it would raise the keyboard), and |
| // never over focus the person already has or a link's target (#...). |
diff --git a/internal/web/app.go b/internal/web/app.go| index 6f1c435..6df5782 100644 |
| --- a/internal/web/app.go |
| +++ b/internal/web/app.go |
| @@ -92,7 +92,7 @@ func App(d *db.DB, cfg config.Config, mailer mail.Sender, inst Installer, logger |
| } |
| a := &app{db: d.Writer(), cfg: cfg, inst: inst, logger: logger, pages: pages, mailer: mailer} |
| if cfg.EquipoOrigin != "" { |
| - a.ask = newAsker(cfg.EquipoOrigin, cfg.InstanceKey, cfg.Name) |
| + a.ask = newAsker(cfg.EquipoOrigin, cfg.InstanceKey, cfg.Name, cfg.Timezone) |
| } |
| guard, err := pow.New(pow.Config{InstanceKey: cfg.InstanceKey, Nonces: pow.SQLNonces(d.Writer()), Difficulty: pow.NoProof, MinAge: pow.DefaultMinAge}) |
| if err != nil { |
diff --git a/internal/web/ask.go b/internal/web/ask.go| index 5d2c6c2..462e586 100644 |
| --- a/internal/web/ask.go |
| +++ b/internal/web/ask.go |
| @@ -31,6 +31,13 @@ type asker struct { |
| // oficina holds a *sync.Mutex per member id, held while Ask is set up |
| // 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 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. |
| @@ -41,6 +48,7 @@ func (a *app) askRoutes(r chi.Router) { |
| r.Post("/ask/messages", a.askSend) |
| r.Post("/ask/turns/{id}/cancel", a.askCancel) |
| r.Post("/ask/cards/{id}/answer", a.askAnswer) |
| + r.Post("/ask/cards/{id}/carry_on", a.askCarryOn) |
| r.Post("/ask/connect", a.askConnectStart) |
| r.Get("/ask/connect", a.askConnectPage) |
| r.Post("/ask/connect/check", a.askConnectCheck) |
| @@ -78,8 +86,15 @@ func (a *app) askDock(w http.ResponseWriter, r *http.Request) { |
| http.Redirect(w, r, "/", http.StatusSeeOther) |
| } |
| -func newAsker(origin, instanceKey, name string) *asker { |
| - return &asker{client: equipo.New(origin), seal: equipo.NewSealer(instanceKey), label: "Base (" + name + ")"} |
| +// 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 + ")", |
| + zones: map[string]*zoneTold{}} |
| + if zone != nil { |
| + a.zone = zone.String() |
| + } |
| + return a |
| } |
| // The states of a member's chat. Connect: nothing connected; pending: a |
diff --git a/internal/web/ask_connect.go b/internal/web/ask_connect.go| index 2ed8942..daa6512 100644 |
| --- a/internal/web/ask_connect.go |
| +++ b/internal/web/ask_connect.go |
| @@ -333,6 +333,7 @@ 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)() |
| if !fresh { |
| done, err := store.HostRegistered(ctx, a.db, me.ID) |
| @@ -349,6 +350,78 @@ 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 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 |
| +} |
| + |
| +// zoneFor tells Equipo the member's time zone, the team's (BASE_TIMEZONE), |
| +// 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, 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 |
| + } |
| + a.ask.zoneMu.Lock() |
| + z := a.ask.zones[me.ID] |
| + if z == nil { |
| + z = &zoneTold{} |
| + a.ask.zones[me.ID] = z |
| + } |
| + 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 |
| + } |
| + 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 |
| + 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() |
| + 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 |
| // their host is registered, and their connection's generation, which every |
| // change to their link moves on (changeLink). The lock is not reentrant: |
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/ask_relay.go b/internal/web/ask_relay.go| index 9d520b9..cd184aa 100644 |
| --- a/internal/web/ask_relay.go |
| +++ b/internal/web/ask_relay.go |
| @@ -170,6 +170,33 @@ func (a *app) askAnswer(w http.ResponseWriter, r *http.Request) { |
| a.askDone(w, r, c, err, out) |
| } |
| +// 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}, 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 { |
| + return |
| + } |
| + 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"` |
| + } |
| + if card, ok := in.CleanAt(a.cfg.Origin); ok { |
| + out.Card = &card |
| + } |
| + a.askDone(w, r, c, err, out) |
| +} |
| + |
| // Stream bounds. Equipo pings every 20 seconds, so a minute of silence |
| // means it is gone; a stream lives at most streamLife, after which the |
| // browser reconnects with its cursor; one event is at most maxEventBytes |
diff --git a/internal/web/templates/partials/chat.html b/internal/web/templates/partials/chat.html| index 56be999..117c7b9 100644 |
| --- a/internal/web/templates/partials/chat.html |
| +++ b/internal/web/templates/partials/chat.html |
| @@ -15,13 +15,14 @@ |
| <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 .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, 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). */}} |
| +{{/* A job state's mark: working has none (the mark turns, in CSS); the rest are still icons: paused a clock (it carries on by itself), stopped a square (it waits for the person). ask.js has the same paths (marks), and so does the native app (BaseIcon). */}} |
| +{{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 . "paused"}}<svg viewBox="0 0 24 24"><path d="M19.2 12a7.2 7.2 0 1 1-14.4 0a7.2 7.2 0 1 1 14.4 0zM12 8.6V12l2.4 1.6"/></svg>{{else if eq . "stopped"}}<svg viewBox="0 0 24 24"><path d="M9 7.5h6a1.5 1.5 0 0 1 1.5 1.5v6a1.5 1.5 0 0 1-1.5 1.5H9a1.5 1.5 0 0 1-1.5-1.5V9A1.5 1.5 0 0 1 9 7.5z"/></svg>{{end}}{{end}} |
| +{{/* The job view, opened from the pill: its title, the status, one sentence more, for a paused job that offers it "Carry on now" (assistant.job.carry_on, with assistant.job.carry_on_note under it: copy review 2026-11-24) posting the card's revision, 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}}<ol class="jv-cards">{{range .EndedCards}}{{template "ask-jobcard" .}}{{end}}</ol>{{with .StartedAt}}<p class="jv-started">{{startedText .}}</p>{{end}} |
| +<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><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_native_contract_test.go b/internal/webtest/ask_native_contract_test.go| index 5c07fba..19a3fc3 100644 |
| --- a/internal/webtest/ask_native_contract_test.go |
| +++ b/internal/webtest/ask_native_contract_test.go |
| @@ -496,3 +496,44 @@ func (p *pipeWriter) Write(b []byte) (int, error) { |
| } |
| func (p *pipeWriter) Flush() {} |
| + |
| +// Carry on now (docs/api/base-native-v1.md): a paused job's card says |
| +// carry_on; the route answers {"card": the job as it is now}; a 409 from |
| +// Equipo (card_stale, not_paused, carry_on_unavailable) is Ask's stale |
| +// 409 {"state":"ready"}; before connecting it is the state's 409. |
| +func TestAskContractCarryOn(t *testing.T) { |
| + web, app, f := newNativeAskApp(t) |
| + wantBody(t, "not connected", app.nativeForm("/ask/cards/c_1/carry_on", url.Values{"revision": {"1"}, "key": {"k1"}}), 409, `{"state":"connect"}`) |
| + web.approveEquipo(f) |
| + job := f.AskJob("Bakery website") |
| + f.PauseJob(job, "Paused until 21:00", "It has reached the limit on its plan for now. It will carry on by itself at 21:00 (in 9 hours).", true) |
| + s, r := app.askState() |
| + if len(s.Jobs) != 1 { |
| + t.Fatalf("jobs: %s", r.Body) |
| + } |
| + wantKeys(t, "paused job", string(s.Jobs[0]), "id", "revision", "kind", "state", "question", "options", "links", "result", "detail", "started_at", "carry_on", "cards") |
| + var j struct { |
| + State, Result string |
| + Revision int64 |
| + CarryOn bool `json:"carry_on"` |
| + } |
| + if json.Unmarshal(s.Jobs[0], &j) != nil || j.State != "paused" || j.Result != "Paused until 21:00" || !j.CarryOn { |
| + t.Fatalf("paused job: %s", s.Jobs[0]) |
| + } |
| + rev := strconv.FormatInt(j.Revision, 10) |
| + wantBody(t, "stale", app.nativeForm("/ask/cards/"+job+"/carry_on", url.Values{"revision": {"1"}, "key": {"s-1"}}), 409, `{"state":"ready"}`) |
| + ok := app.nativeForm("/ask/cards/"+job+"/carry_on", url.Values{"revision": {rev}, "key": {"s-2"}}) |
| + wantKeys(t, "carry on", ok.Body, "card") |
| + var out struct{ Card struct{ ID, State string } } |
| + if ok.Code != 200 || json.Unmarshal([]byte(ok.Body), &out) != nil || out.Card.ID != job || out.Card.State != "working" { |
| + t.Errorf("carry on: %d %s", ok.Code, ok.Body) |
| + } |
| + // Sent again with its key (its answer was lost): the same answer. |
| + if again := app.nativeForm("/ask/cards/"+job+"/carry_on", url.Values{"revision": {rev}, "key": {"s-2"}}); again.Code != 200 || again.Body != ok.Body { |
| + t.Errorf("resent: %d %s, want %s", again.Code, again.Body, ok.Body) |
| + } |
| + // No longer paused. |
| + s, _ = app.askState() |
| + _ = json.Unmarshal(s.Jobs[0], &j) |
| + wantBody(t, "not paused", app.nativeForm("/ask/cards/"+job+"/carry_on", url.Values{"revision": {strconv.FormatInt(j.Revision, 10)}, "key": {"s-3"}}), 409, `{"state":"ready"}`) |
| +} |
diff --git a/internal/webtest/ask_test.go b/internal/webtest/ask_test.go| index 2a1bd15..4e77482 100644 |
| --- a/internal/webtest/ask_test.go |
| +++ b/internal/webtest/ask_test.go |
| @@ -603,7 +603,7 @@ func TestAskEventsRelay(t *testing.T) { |
| t.Fatal("the stream carried the bearer") |
| } |
| up := f.Calls("/api/v1/assistant/events") |
| - if len(up) == 0 || up[0].Header.Get("Authorization") != "Bearer "+token || up[0].Query != "after="+strconv64(st.Cursor) { |
| + if len(up) == 0 || up[0].Header.Get("Authorization") != "Bearer "+token || up[0].Query != "job_states=paused&after="+strconv64(st.Cursor) { |
| t.Fatalf("upstream: %+v", up) |
| } |
| } |
| @@ -1592,6 +1592,308 @@ func TestAskJobStates(t *testing.T) { |
| } |
| } |
| +// A paused job (Equipo's "paused", its status and sentence in the person's |
| +// time zone, as given): the pill's clock mark on the calm indigo, its |
| +// status, and in the view the sentence and, when the card offers it, |
| +// "Carry on now" with the line under it, posting the card's revision and |
| +// a key. Not offered, the view has no form. Stopped has a mark of its own |
| +// (a square), never paused's or the old pause bars. |
| +func TestAskJobPaused(t *testing.T) { |
| + const clock = `<path d="M19.2 12a7.2 7.2 0 1 1-14.4 0a7.2 7.2 0 1 1 14.4 0zM12 8.6V12l2.4 1.6"/>` |
| + const square = `<path d="M9 7.5h6a1.5 1.5 0 0 1 1.5 1.5v6a1.5 1.5 0 0 1-1.5 1.5H9a1.5 1.5 0 0 1-1.5-1.5V9A1.5 1.5 0 0 1 9 7.5z"/>` |
| + a, f := newAskApp(t) |
| + a.connectEquipo(f) |
| + id := f.AskJob("Bakery website") |
| + f.PauseJob(id, "Paused until 21:00", "It has reached the limit on its plan for now. It will carry on by itself at 21:00 (in 9 hours).", true) |
| + page := a.get("/ask").Body |
| + job := jobItem(t, page, id) |
| + if !strings.Contains(job, `data-state="paused"`) { |
| + t.Errorf("paused job's state:\n%s", job) |
| + } |
| + expect(t, "stage", job, `<span class="pill-stage">(.*?)</span>`, "Paused until 21:00") |
| + if !strings.Contains(job, `<summary class="pill-main" aria-label="Bakery website, Paused until 21:00">`) { |
| + t.Errorf("summary's name:\n%s", job) |
| + } |
| + if n := strings.Count(job, clock); n != 2 { |
| + t.Errorf("the clock mark is drawn %d times (pill and view):\n%s", n, job) |
| + } |
| + view := jobViewOf(t, job) |
| + 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><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") |
| + if fields.Get("revision") != "3" || fields.Get("key") == "" { |
| + t.Errorf("Carry on now posts %v", fields) |
| + } |
| + css, _ := os.ReadFile("../look/static/app.css") |
| + for _, rule := range []string{`.job[data-state="paused"] { --st: var(--st-pause); }`, `--st-pause: #AEB8FF;`, `--st-pause: #4B55C9;`, `--st-pause: light-dark(#4B55C9, #AEB8FF);`} { |
| + if !strings.Contains(string(css), rule) { |
| + t.Errorf("app.css has no %s", rule) |
| + } |
| + } |
| + |
| + // Not offered: no form, the rest as before. |
| + other := f.AskJob("Invoice reminders") |
| + f.PauseJob(other, "Paused until midnight", "It has reached today's spending limit. It will carry on by itself at midnight (in 3 hours).", false) |
| + view = jobViewOf(t, jobItem(t, a.get("/ask").Body, other)) |
| + if strings.Contains(view, "<form") || strings.Contains(view, "Carry on now") { |
| + t.Errorf("Carry on now without carry_on:\n%s", view) |
| + } |
| + |
| + // Stopped: a square, distinct from paused's clock. |
| + f.SetJob(other, "stopped", "Stopped", "It needs you.") |
| + job = jobItem(t, a.get("/ask").Body, other) |
| + 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 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} { |
| + if d = regexp.MustCompile(`d="([^"]*)"`).FindStringSubmatch(d)[1]; !strings.Contains(string(raw), `"`+d+`"`) { |
| + t.Errorf("%s has no %s", file, d) |
| + } |
| + } |
| + } |
| +} |
| + |
| +// Carry on now, without scripts: the form posts once to Equipo with its |
| +// key (the body's idempotency_key and the Idempotency-Key header) and the |
| +// revision shown, and /ask shows the job carrying on. The same form sent |
| +// again is the same request. At a stale revision Equipo's 409 is not |
| +// resent: /ask draws the card as it is now. A job that is no longer paused, |
| +// or no longer offers it, is a 409 too. Scripts on, the answer is the card. |
| +func TestAskCarryOnNow(t *testing.T) { |
| + a, f := newAskApp(t) |
| + a.connectEquipo(f) |
| + id := f.AskJob("Bakery website") |
| + f.PauseJob(id, "Paused until 21:00", "It will carry on by itself at 21:00 (in 9 hours).", true) |
| + path := "/ask/cards/" + id + "/carry_on" |
| + form := formFields(t, a.get("/ask").Body, path) |
| + for i := range 2 { |
| + if r := a.post(path, form); r.Code != 303 || r.Location() != "/ask" { |
| + t.Fatalf("carry on %d: %d %q", i, r.Code, r.Location()) |
| + } |
| + } |
| + calls := f.Calls("/api/v1/assistant" + path[len("/ask"):]) |
| + want := `{"idempotency_key":"` + form.Get("key") + `","revision":3}` |
| + if len(calls) != 2 || strings.TrimSpace(calls[0].Body) != want || calls[1].Body != calls[0].Body || |
| + calls[0].Header.Get("Idempotency-Key") != form.Get("key") { |
| + t.Fatalf("relayed: %+v, want twice %s", calls, want) |
| + } |
| + job := jobItem(t, a.get("/ask").Body, id) |
| + if !strings.Contains(job, `data-state="working"`) || strings.Contains(job, "Carry on now") { |
| + t.Errorf("after Carry on now:\n%s", job) |
| + } |
| + |
| + // Stale: the job moved on unseen. One call, a 409, and /ask draws it anew. |
| + other := f.AskJob("Invoice reminders") |
| + f.PauseJob(other, "Paused until 21:00", "It will carry on by itself at 21:00 (in 9 hours).", true) |
| + path = "/ask/cards/" + other + "/carry_on" |
| + stale := formFields(t, a.get("/ask").Body, path) |
| + f.PauseJob(other, "Paused until 22:00", "It will carry on by itself at 22:00 (in 10 hours).", true) |
| + if r := a.post(path, stale); r.Code != 303 || r.Location() != "/ask" { |
| + t.Fatalf("stale: %d %q", r.Code, r.Location()) |
| + } |
| + if n := len(f.Calls("/api/v1/assistant/cards/" + other + "/carry_on")); n != 1 { |
| + t.Errorf("a stale Carry on now went %d times", n) |
| + } |
| + fresh := formFields(t, a.get("/ask").Body, path) |
| + if fresh.Get("revision") != "4" { |
| + t.Errorf("after the 409 the job is at revision %q, want 4", fresh.Get("revision")) |
| + } |
| + |
| + // Scripts on: the card, at its new revision. |
| + json409 := func(form url.Values) Resp { |
| + req, _ := http.NewRequest(http.MethodPost, a.base+path, strings.NewReader(form.Encode())) |
| + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| + req.Header.Set("Origin", a.origin) |
| + req.Header.Set("Accept", "application/json") |
| + return a.do(req) |
| + } |
| + res := json409(fresh) |
| + var out struct{ Card struct{ ID, State string } } |
| + if res.Code != 200 || json.Unmarshal([]byte(res.Body), &out) != nil || out.Card.ID != other || out.Card.State != "working" { |
| + t.Fatalf("JSON carry on: %d %s", res.Code, res.Body) |
| + } |
| + // No longer paused, then paused without the offer: 409s, the panel reads afresh. |
| + fresh.Set("key", "k-again") |
| + fresh.Set("revision", "5") |
| + if r := json409(fresh); r.Code != 409 || strings.TrimSpace(r.Body) != `{"state":"ready"}` { |
| + t.Errorf("not paused: %d %s", r.Code, r.Body) |
| + } |
| + f.PauseJob(other, "Paused until 23:00", "It will carry on by itself at 23:00.", false) |
| + fresh.Set("key", "k-third") |
| + fresh.Set("revision", "6") |
| + 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()) |
| + } |
| +} |
| + |
| +// 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) |
| + } |
| + f := equipotest.New(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 := 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, Equipo has %q", zones, f.TimeZone()) |
| + } |
| + snaps := f.Calls("/api/v1/assistant/snapshot") |
| + if len(snaps) == 0 { |
| + t.Fatal("no snapshot read") |
| + } |
| + for _, c := range snaps { |
| + if c.Query != "job_states=paused" { |
| + t.Errorf("snapshot's query %q", c.Query) |
| + } |
| + } |
| + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) |
| + defer cancel() |
| + req, _ := http.NewRequestWithContext(ctx, http.MethodGet, a.base+"/ask/events?after=40", nil) |
| + res, err := a.client.Do(req) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + // Its first line comes once Equipo's stream has opened. |
| + if line, _ := bufio.NewReader(res.Body).ReadString('\n'); res.StatusCode != 200 || line == "" { |
| + t.Fatalf("events: %d %q", res.StatusCode, line) |
| + } |
| + res.Body.Close() |
| + events := f.Calls("/api/v1/assistant/events") |
| + if len(events) == 0 || events[0].Query != "job_states=paused&after=40" { |
| + t.Errorf("events: %+v", events) |
| + } |
| +} |
| + |
| +// 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) { |
| + 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) |
| + release := f.HoldTimeZone() |
| + defer release() |
| + 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/API/Client.swift b/native/apple/Sources/BaseKit/API/Client.swift| index f0b733d..777699a 100644 |
| --- a/native/apple/Sources/BaseKit/API/Client.swift |
| +++ b/native/apple/Sources/BaseKit/API/Client.swift |
| @@ -61,6 +61,11 @@ public struct BaseClient: Sendable { |
| try await post("/ask/cards/\(Self.segment(id))/answer", form: [("revision", String(revision)), ("choice", choice), ("key", key)]) |
| } |
| + /// A paused job's "Carry on now", at the revision the person saw. |
| + public func carryOn(card id: String, revision: Int64, key: String) async throws(BaseAPIError) -> AskCarriedOn { |
| + try await post("/ask/cards/\(Self.segment(id))/carry_on", form: [("revision", String(revision)), ("key", key)]) |
| + } |
| + |
| /// `POST /api/v1/ask/oficina` (Task 7): connects Ask with an Oficina ID |
| /// assertion addressed to Equipo. `auto`: the app set Ask up by itself |
| /// (at sign-in, a renewal, a reconnect), which Base refuses with |
diff --git a/native/apple/Sources/BaseKit/API/Models.swift b/native/apple/Sources/BaseKit/API/Models.swift| index 4592766..ce7cb20 100644 |
| --- a/native/apple/Sources/BaseKit/API/Models.swift |
| +++ b/native/apple/Sources/BaseKit/API/Models.swift |
| @@ -236,16 +236,20 @@ public struct AskCard: Decodable, Sendable, Equatable, Identifiable { |
| public var detail: String |
| public var startedAt: Date? |
| public var turnID: String |
| + /// A paused job offers "Carry on now" (`carry_on`; Base sends it on a |
| + /// paused job card only). |
| + public var carryOn: Bool |
| public init(id: String, revision: Int64 = 1, kind: String, state: String, question: String = "", options: [Option] = [], |
| - links: [Link] = [], result: String = "", job: String = "", detail: String = "", startedAt: Date? = nil, turnID: String = "") { |
| + links: [Link] = [], result: String = "", job: String = "", detail: String = "", startedAt: Date? = nil, turnID: String = "", |
| + carryOn: Bool = false) { |
| self.id = id; self.revision = revision; self.kind = kind; self.state = state; self.question = question |
| self.options = options; self.links = links; self.result = result; self.job = job; self.detail = detail |
| - self.startedAt = startedAt; self.turnID = turnID |
| + self.startedAt = startedAt; self.turnID = turnID; self.carryOn = carryOn |
| } |
| enum CodingKeys: String, CodingKey { |
| case id, revision, kind, state, question, options, links, result, job, detail |
| - case startedAt = "started_at", turnID = "turn_id" |
| + case startedAt = "started_at", turnID = "turn_id", carryOn = "carry_on" |
| } |
| public init(from decoder: Decoder) throws { |
| let c = try decoder.container(keyedBy: CodingKeys.self) |
| @@ -253,11 +257,14 @@ public struct AskCard: Decodable, Sendable, Equatable, Identifiable { |
| question = c.value(.question, ""); options = c.value(.options, []).filter { !$0.value.isEmpty } |
| links = c.value(.links, []).filter { $0.url != nil }; result = c.value(.result, "") |
| job = c.value(.job, ""); detail = c.value(.detail, ""); startedAt = c.date(.startedAt); turnID = c.value(.turnID, "") |
| + carryOn = c.value(.carryOn, false) |
| } |
| public var isOpen: Bool { state == "open" } |
| public var isJob: Bool { kind == "job" } |
| public var jobState: JobState? { isJob ? JobState(rawValue: state) : nil } |
| + /// A paused job that offers "Carry on now". |
| + public var offersCarryOn: Bool { jobState == .paused && carryOn } |
| /// The kinds drawn as cards (ask.js `kinds`). |
| public static let drawnKinds: Set<String> = ["question", "confirm", "outcome", "connect"] |
| /// Where to see a job's work once there is something to see (ready, |
| @@ -343,6 +350,16 @@ public struct AskAnswered: Decodable, Sendable, Equatable { |
| } |
| } |
| +/// `POST /ask/cards/{id}/carry_on`'s answer: the job card as it is now. |
| +public struct AskCarriedOn: Decodable, Sendable, Equatable { |
| + public var card: AskCard? |
| + enum CodingKeys: String, CodingKey { case card } |
| + public init(from decoder: Decoder) throws { |
| + let c = try decoder.container(keyedBy: CodingKeys.self) |
| + card = c.optional(.card).flatMap { (k: AskCard) in k.id.isEmpty ? nil : k } |
| + } |
| +} |
| + |
| /// `POST /api/v1/ask/oficina`'s answer (Task 7): `ready` with when to renew, |
| /// or `not_linked`. |
| public struct AskSetupAnswer: Decodable, Sendable, Equatable { |
diff --git a/native/apple/Sources/BaseKit/Ask/AskModel.swift b/native/apple/Sources/BaseKit/Ask/AskModel.swift| index a8658f5..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 |
| @@ -91,8 +92,12 @@ import Observation |
| /// The composer's text. |
| public var text = "" |
| public private(set) var sending = false |
| - /// Cards with an answer on its way: their buttons are disabled. |
| + /// 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 { |
| @@ -110,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) |
| @@ -133,6 +146,7 @@ import Observation |
| /// The message in flight or of unknown outcome, and its key. |
| private var pendingSend: (text: String, key: String)? |
| private var answerKeys: [String: (signature: String, key: String)] = [:] |
| + private var carryOnKeys: [String: (revision: Int64, key: String)] = [:] |
| private var cancelKey: (turn: String, key: String)? |
| private var stream: Task<Void, Never>? |
| private var generation = 0 |
| @@ -329,6 +343,53 @@ 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, 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) } else { await load() } |
| + } catch { |
| + if case .server(409, _, let state) = error, state != "norunner", state != "oldrunner" { |
| + carryOnKeys[job.id] = nil |
| + await load() |
| + return |
| + } |
| + refusedWrite(error, keepsKey: { carryOnKeys[job.id] = nil }) |
| + 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")) |
| + } |
| + } |
| + } |
| + |
| + /// 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) |
| + } |
| + } |
| + |
| /// What a refused write shows (ask.js `post`): Ask's own states stand in |
| /// for the conversation, or add their note; a 409 is stale (the next |
| /// events show how things are); anything else asks to try again. The |
diff --git a/native/apple/Sources/BaseKit/Ask/Pill.swift b/native/apple/Sources/BaseKit/Ask/Pill.swift| index 0fa3254..230afa1 100644 |
| --- a/native/apple/Sources/BaseKit/Ask/Pill.swift |
| +++ b/native/apple/Sources/BaseKit/Ask/Pill.swift |
| @@ -30,6 +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, 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 |
| @@ -96,7 +100,9 @@ struct JobPill: View { |
| .buttonStyle(.plain) |
| .accessibilityLabel(Text(verbatim: label)) |
| .accessibilityAddTraits(.isButton) |
| - .modifier(JobViewPresentation(isPresented: $viewing, job: job, timeZone: timeZone)) |
| + .modifier(JobViewPresentation(isPresented: $viewing, job: job, timeZone: timeZone, |
| + 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: { |
| @@ -164,16 +170,19 @@ struct JobViewPresentation: ViewModifier { |
| @Binding var isPresented: Bool |
| 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 }) |
| + 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 }) |
| + JobView(job: job, timeZone: timeZone, close: { isPresented = false }, carrying: carrying, carryOnError: carryOnError, carryOn: carryOn) |
| .presentationDetents([.medium, .large]) |
| .presentationDragIndicator(.visible) |
| } |
| @@ -182,7 +191,8 @@ struct JobViewPresentation: ViewModifier { |
| } |
| /// What the job view shows (chat.html `ask-jobview`): the title, linked to |
| -/// the job's own page in Equipo; the status; one sentence more; the cards |
| +/// the job's own page in Equipo; the status; one sentence more; for a |
| +/// paused job that offers it, "Carry on now" and the line under it; the cards |
| /// that have ended, each its question and how it ended; when it started; |
| /// and the link to the work once there is something to see. The jobs |
| /// design (11-20) adds its decisions here later. |
| @@ -191,11 +201,18 @@ public struct JobView: View { |
| let timeZone: TimeZone? |
| let close: () -> Void |
| 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) { |
| + public init(job: AskModel.Job, timeZone: TimeZone?, close: @escaping () -> Void, now: Date = .now, |
| + 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.carryOnError = carryOnError; self.carryOn = carryOn |
| } |
| public var body: some View { |
| @@ -231,6 +248,20 @@ public struct JobView: View { |
| VStack(alignment: .leading, spacing: 2) { |
| if !job.card.result.isEmpty { Text(verbatim: job.card.result).font(BaseFont.body(14, .medium)) } |
| if !job.card.detail.isEmpty { Text(verbatim: job.card.detail).font(BaseFont.body(14)).foregroundStyle(p[.haze]) } |
| + if job.card.offersCarryOn { |
| + VStack(alignment: .leading, spacing: 6) { |
| + Button(action: carryOn) { Text(BaseText.text("assistant.job.carry_on")) } |
| + .buttonStyle(BaseButtonStyle(.ghost)) |
| + .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) |
| + } |
| if !job.ended.isEmpty { |
| VStack(alignment: .leading, spacing: 6) { |
| ForEach(job.ended) { card in |
diff --git a/native/apple/Sources/BaseKit/Ask/Thread.swift b/native/apple/Sources/BaseKit/Ask/Thread.swift| index 42d5185..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) { 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/Sources/BaseKit/Look/Marks.swift b/native/apple/Sources/BaseKit/Look/Marks.swift| index ee50c28..f63e5f8 100644 |
| --- a/native/apple/Sources/BaseKit/Look/Marks.swift |
| +++ b/native/apple/Sources/BaseKit/Look/Marks.swift |
| @@ -21,20 +21,23 @@ public struct BaseMark: View { |
| /// A job's state, as the web names them (ask.js `jobStates`). |
| public enum JobState: String, Sendable, CaseIterable, Codable { |
| - case working, asking, ready, done, stopped |
| + case working, asking, ready, done, paused, stopped |
| } |
| /// The 24-unit drawings Base's web uses (ask.js `marks`, the templates' |
| /// `ask-mark`, and the job view's and composer's icons), as paths. |
| public enum BaseIcon: Sendable { |
| - case asking, ready, done, stopped, arrowOut, close, send |
| + case asking, ready, done, paused, stopped, arrowOut, close, send |
| var svg: String { |
| switch self { |
| case .asking: "M9.2 9.2a2.9 2.9 0 0 1 5.6 1c0 2-2.8 2.4-2.8 4.3M12 18.2h.01" |
| case .ready: "M8 16L16 8M9.5 8H16v6.5" |
| case .done: "M6 12.5l4 4 8-9" |
| - case .stopped: "M9.5 7.5v9M14.5 7.5v9" |
| + // A clock: it carries on by itself. |
| + case .paused: "M19.2 12a7.2 7.2 0 1 1-14.4 0a7.2 7.2 0 1 1 14.4 0zM12 8.6V12l2.4 1.6" |
| + // A square: stopped until the person acts (never paused's clock). |
| + case .stopped: "M9 7.5h6a1.5 1.5 0 0 1 1.5 1.5v6a1.5 1.5 0 0 1-1.5 1.5H9a1.5 1.5 0 0 1-1.5-1.5V9A1.5 1.5 0 0 1 9 7.5z" |
| case .arrowOut: "M9 6h9v9M18 6L7 17" |
| case .close: "M6 6l12 12M18 6L6 18" |
| case .send: "M12 19V5M6 11l6-6 6 6" |
| @@ -73,7 +76,8 @@ public struct Icon: View { |
| /// A job state's mark (`.state-mark`): a disc. Working is a slow arc |
| /// turning round a breathing dot, on the accent's tint; the rest are |
| /// still icons on the state's colour (working, ready and done the accent, |
| -/// asking warm, stopped rose). With Reduce Motion, working holds still: a |
| +/// asking warm, paused a calm indigo with a clock, stopped rose with a |
| +/// square). With Reduce Motion, working holds still: a |
| /// quarter arc and a steady dot. |
| public struct StateMark: View { |
| let state: JobState |
| @@ -88,6 +92,7 @@ public struct StateMark: View { |
| switch state { |
| case .working, .ready, .done: p[.signal] |
| case .asking: p[.stAsk] |
| + case .paused: p[.stPause] |
| case .stopped: p[.stStop] |
| } |
| } |
| @@ -131,6 +136,7 @@ public struct StateMark: View { |
| case .asking: .asking |
| case .ready: .ready |
| case .done: .done |
| + case .paused: .paused |
| case .stopped, .working: .stopped |
| } |
| } |
diff --git a/native/apple/Sources/BaseKit/Look/Palette.swift b/native/apple/Sources/BaseKit/Look/Palette.swift| index 51f6bb3..53b5155 100644 |
| --- a/native/apple/Sources/BaseKit/Look/Palette.swift |
| +++ b/native/apple/Sources/BaseKit/Look/Palette.swift |
| @@ -123,6 +123,7 @@ public struct Palette: Sendable { |
| case pillLift = "pill-lift" |
| case stAsk = "st-ask" |
| case stStop = "st-stop" |
| + case stPause = "st-pause" |
| case edgeA = "edge-a" |
| case edgeB = "edge-b" |
| case edgeHi = "edge-hi" |
| @@ -227,6 +228,7 @@ public struct Palette: Sendable { |
| .pillLift: RGBA(6, 8, 22, 0.55), |
| .stAsk: RGBA(255, 176, 102, 1), |
| .stStop: RGBA(249, 168, 212, 1), |
| + .stPause: RGBA(174, 184, 255, 1), |
| .edgeA: RGBA(110, 231, 220, 1), |
| .edgeB: RGBA(180, 156, 252, 1), |
| .edgeHi: RGBA(230, 255, 251, 1), |
| @@ -331,6 +333,7 @@ public struct Palette: Sendable { |
| .pillLift: RGBA(40, 46, 90, 0.28), |
| .stAsk: RGBA(192, 101, 26, 1), |
| .stStop: RGBA(194, 54, 111, 1), |
| + .stPause: RGBA(75, 85, 201, 1), |
| .edgeA: RGBA(11, 122, 114, 1), |
| .edgeB: RGBA(106, 60, 214, 1), |
| .edgeHi: RGBA(43, 88, 200, 1), |
diff --git a/native/apple/Sources/BaseKit/Resources/Localizable.xcstrings b/native/apple/Sources/BaseKit/Resources/Localizable.xcstrings| index f605b65..1292fa6 100644 |
| --- a/native/apple/Sources/BaseKit/Resources/Localizable.xcstrings |
| +++ b/native/apple/Sources/BaseKit/Resources/Localizable.xcstrings |
| @@ -373,6 +373,30 @@ |
| } |
| } |
| }, |
| + "assistant.job.carry_on": { |
| + "comment": "Copy review 2026-11-24 (paused work), COPY ACCEPTED BY DELEGATION (Luna). Button in the paused job view, when another plan has room at no extra cost (chat.html ask-jobview).", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Carry on now" |
| + } |
| + } |
| + } |
| + }, |
| + "assistant.job.carry_on_note": { |
| + "comment": "Copy review 2026-11-24 (paused work), COPY ACCEPTED BY DELEGATION (Luna). Small line under 'Carry on now' (chat.html ask-jobview).", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Uses your other plan, at no extra cost." |
| + } |
| + } |
| + } |
| + }, |
| "chat.paste.command": { |
| "comment": "Equipo's approved label (EquipoKit, 00d09aa7) over a shell code block in a reply.", |
| "extractionState": "manual", |
diff --git a/native/apple/Tests/BaseKitTests/AskModelTests.swift b/native/apple/Tests/BaseKitTests/AskModelTests.swift| index 6097552..34ca188 100644 |
| --- a/native/apple/Tests/BaseKitTests/AskModelTests.swift |
| +++ b/native/apple/Tests/BaseKitTests/AskModelTests.swift |
| @@ -221,6 +221,110 @@ import XCTest |
| XCTAssertTrue(m.answering.isEmpty) |
| } |
| + // MARK: Paused jobs (clearer paused work, 2026-11-24) |
| + |
| + static let pausedJob = AskCard(id: "jp", revision: 3, kind: "job", state: "paused", question: "Bakery website", |
| + result: "Paused until 21:00", detail: "It will carry on by itself at 21:00 (in 9 hours).", carryOn: true) |
| + |
| + /// A paused job's card decodes with carry_on; Equipo's paused job is |
| + /// not waiting on the person. An older Equipo's job (no carry_on) never |
| + /// offers it. |
| + func testAPausedJobDrawsAndOffersCarryOnOnlyWhenPaused() throws { |
| + let raw = #"{"id":"jp","revision":3,"kind":"job","state":"paused","question":"Bakery website","result":"Paused until 21:00","detail":"It will carry on.","carry_on":true}"# |
| + let card = try JSONDecoder().decode(AskCard.self, from: Data(raw.utf8)) |
| + XCTAssertEqual(card.jobState, .paused) |
| + XCTAssertTrue(card.offersCarryOn) |
| + let old = try JSONDecoder().decode(AskCard.self, from: Data(raw.replacingOccurrences(of: #","carry_on":true"#, with: "").utf8)) |
| + XCTAssertFalse(old.offersCarryOn) |
| + let working = try JSONDecoder().decode(AskCard.self, from: Data(raw.replacingOccurrences(of: "paused", with: "working").utf8)) |
| + XCTAssertFalse(working.offersCarryOn, "carry_on means nothing outside paused") |
| + let (m, _) = model() |
| + m.apply(.card(card)) |
| + guard case .job(let j) = m.entries.last else { return XCTFail() } |
| + XCTAssertEqual(j.state, .paused) |
| + XCTAssertEqual(m.waitingJobs, 0, "a paused job carries on by itself: nothing waits on the person") |
| + } |
| + |
| + /// Carry on now posts the revision seen, once, and keeps its key until |
| + /// an answer settles it: after a lost answer the same key goes again. |
| + /// The answer's card redraws the job in place. |
| + func testCarryOnPostsOnceWithAKeptKey() async { |
| + let carried = #"{"card":{"id":"jp","revision":4,"kind":"job","state":"working","question":"Bakery website","result":"Carrying on","options":[],"links":[]}}"# |
| + let (m, t) = model([.offline(), .commitThenLoseResponse(), json(200, carried)]) |
| + m.apply(.card(Self.pausedJob)) |
| + await m.carryOn(Self.pausedJob) |
| + XCTAssertEqual(m.status, BaseText.text("ask.not_sent")) |
| + await m.carryOn(Self.pausedJob) |
| + await m.carryOn(Self.pausedJob) |
| + XCTAssertEqual(t.calls.count, 3) |
| + XCTAssertEqual(t.calls[0].path, "/ask/cards/jp/carry_on") |
| + XCTAssertEqual(fields(t.calls[0])["revision"], "3") |
| + XCTAssertEqual(Set(t.calls.map { fields($0)["key"]! }).count, 1, "one Carry on now, one key") |
| + guard case .job(let j) = m.entries.last else { return XCTFail() } |
| + XCTAssertEqual(j.state, .working) |
| + XCTAssertEqual(j.card.revision, 4) |
| + XCTAssertTrue(m.answering.isEmpty) |
| + // It no longer offers it: pressing again sends nothing. |
| + await m.carryOn(j.card) |
| + XCTAssertEqual(t.calls.count, 3) |
| + } |
| + |
| + /// A 409 (the job moved on, is no longer paused, or no longer offers |
| + /// it) reads the conversation afresh and never resends; the next press |
| + /// is a new request with a new key. Without a runner nothing happened, |
| + /// and the job stays offering it. |
| + func testCarryOnStaleRedrawsAndNeverResends() async throws { |
| + let (m, t) = model([json(409, #"{"state":"ready"}"#), .respond(status: 200, body: Fixture.data("state-ready.json")), .hang, |
| + json(409, #"{"state":"norunner"}"#)]) |
| + m.apply(.card(Self.pausedJob)) |
| + await m.carryOn(Self.pausedJob) |
| + XCTAssertEqual(t.calls[1].path, "/ask/state", "a stale job reads the conversation afresh") |
| + try await waitUntil { t.calls.count == 3 } |
| + m.pause() |
| + XCTAssertFalse(m.entries.contains { $0.id == "j:jp" }, "drawn from the fresh state") |
| + await m.carryOn(Self.pausedJob) |
| + XCTAssertEqual(t.calls[3].path, "/ask/cards/jp/carry_on") |
| + XCTAssertNotEqual(fields(t.calls[3])["key"], fields(t.calls[0])["key"]) |
| + 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":[]}}"# |
| + 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") |
| + 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) |
| + } |
| + |
| + /// 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/BaseKitTests/LookTests.swift b/native/apple/Tests/BaseKitTests/LookTests.swift| index 10e0272..6d4df7a 100644 |
| --- a/native/apple/Tests/BaseKitTests/LookTests.swift |
| +++ b/native/apple/Tests/BaseKitTests/LookTests.swift |
| @@ -42,7 +42,7 @@ final class LookTests: XCTestCase { |
| } |
| func testIconsParse() { |
| - for icon in [BaseIcon.asking, .ready, .done, .stopped, .arrowOut, .close, .send] { |
| + for icon in [BaseIcon.asking, .ready, .done, .paused, .stopped, .arrowOut, .close, .send] { |
| let bounds = icon.path(in: CGRect(x: 0, y: 0, width: 24, height: 24)).boundingRect |
| XCTAssertFalse(bounds.isEmpty && bounds.width == 0 && bounds.height == 0, "\(icon) drew nothing") |
| XCTAssertTrue(CGRect(x: 0, y: 0, width: 24, height: 24).insetBy(dx: -1, dy: -1).contains(bounds), "\(icon) leaves its box: \(bounds)") |
| @@ -51,6 +51,12 @@ final class LookTests: XCTestCase { |
| let asking = BaseIcon.asking.path(in: CGRect(x: 0, y: 0, width: 24, height: 24)).boundingRect |
| XCTAssertEqual(asking.minX, 9.2, accuracy: 0.05) |
| XCTAssertEqual(asking.maxX, 14.8, accuracy: 0.6) |
| + // Paused's clock is a whole circle of radius 7.2 round the middle. |
| + let paused = BaseIcon.paused.path(in: CGRect(x: 0, y: 0, width: 24, height: 24)).boundingRect |
| + XCTAssertEqual(paused.minX, 4.8, accuracy: 0.05) |
| + XCTAssertEqual(paused.maxX, 19.2, accuracy: 0.05) |
| + XCTAssertEqual(paused.minY, 4.8, accuracy: 0.05) |
| + XCTAssertEqual(paused.maxY, 19.2, accuracy: 0.05) |
| } |
| func testAppearanceFromTheServer() { |
diff --git a/native/apple/Tests/BaseSnapshots/AskSnapshots.swift b/native/apple/Tests/BaseSnapshots/AskSnapshots.swift| index 5ce7eea..cedbd47 100644 |
| --- a/native/apple/Tests/BaseSnapshots/AskSnapshots.swift |
| +++ b/native/apple/Tests/BaseSnapshots/AskSnapshots.swift |
| @@ -32,6 +32,21 @@ final class AskSnapshots: XCTestCase { |
| SnapshotScreen("job-view-long", mac: .fixed(width: 320, height: 520), iphone: .fixed(width: 402, height: 437)) { |
| JobView(job: AskFixtures.longJob, timeZone: AskFixtures.zone, close: {}, now: SnapshotSettings.now) |
| }, |
| + // Clearer paused work (2026-11-24): a paused job's pill (the |
| + // clock on indigo, "Paused until 21:00") beside a stopped one |
| + // (its square) and one working; and the paused job's view with |
| + // its sentence and Carry on now. |
| + SnapshotScreen("paused", mac: .fixed(width: 640, height: 360), iphone: .fixed(width: 402, height: 420)) { |
| + AskFrame { AskView(model: AskFixtures.paused(), layout: frameLayout, timeZone: AskFixtures.zone, actions: AskActions {}) } |
| + }, |
| + 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 {}) } |
| }, |
| @@ -134,6 +149,22 @@ struct AskFrame<Content: View>: View { |
| return m |
| } |
| + /// A paused job that offers Carry on now, a stopped one and one working. |
| + static func paused() -> AskModel { |
| + let m = model(state: "ready", extra: #"{"id":"m1","role":"person","text":"Can you put together a simple website for the bakery?","turn_id":"t1"}"#) |
| + m.apply(.card(pausedJob.card)) |
| + m.apply(.card(AskCard(id: "j5", revision: 2, kind: "job", state: "stopped", question: "Invoice reminders", result: "Stopped: needs you"))) |
| + m.apply(.card(AskCard(id: "j6", revision: 1, kind: "job", state: "working", question: "Christmas menu", result: "Building a first look"))) |
| + return m |
| + } |
| + |
| + static let pausedJob = AskModel.Job( |
| + card: AskCard(id: "j4", revision: 3, kind: "job", state: "paused", question: "Bakery website", |
| + links: [.init(label: "Open in Equipo", url: URL(string: "https://equipo.fennel.example/tasks/tk4"), rel: "equipo")], |
| + result: "Paused until 21:00", |
| + detail: "It has reached the limit on its plan for now. It will carry on by itself at 21:00 (in 9 hours).", |
| + startedAt: SnapshotSettings.now.addingTimeInterval(-2 * 3600), carryOn: true)) |
| + |
| static let longJob = AskModel.Job(card: job.card, open: [], ended: (1...6).map { n in |
| AskCard(id: "e\(n)", kind: "confirm", state: "answered", question: "Decision \(n): use the autumn menu's prices for the Christmas boxes?", |
| result: n % 2 == 0 ? "You said yes" : "You said no", job: "j2") |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-dark-ax3.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-dark-ax3.png| new file mode 100644 |
| index 0000000..c971fbc |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-dark-ax3.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-dark-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-dark-default.png| new file mode 100644 |
| index 0000000..7ca7240 |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-dark-default.png differ |
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/iphone/job-view-paused-light-ax3.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-light-ax3.png| new file mode 100644 |
| index 0000000..ec2ae7c |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-light-ax3.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-light-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-light-default.png| new file mode 100644 |
| index 0000000..2917ae9 |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/job-view-paused-light-default.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-dark-ax3.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-dark-ax3.png| new file mode 100644 |
| index 0000000..2b71c50 |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-dark-ax3.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-dark-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-dark-default.png| new file mode 100644 |
| index 0000000..f93648f |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-dark-default.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-light-ax3.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-light-ax3.png| new file mode 100644 |
| index 0000000..1e35710 |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-light-ax3.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-light-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-light-default.png| new file mode 100644 |
| index 0000000..d300428 |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/iphone/paused-light-default.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-dark-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-dark-default.png| new file mode 100644 |
| index 0000000..3eccfb8 |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-dark-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 |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-light-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-light-default.png| new file mode 100644 |
| index 0000000..e2c1817 |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/job-view-paused-light-default.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/paused-dark-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/paused-dark-default.png| new file mode 100644 |
| index 0000000..e48b092 |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/paused-dark-default.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/paused-light-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/paused-light-default.png| new file mode 100644 |
| index 0000000..06bfa53 |
| Binary files /dev/null and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-ask/mac/paused-light-default.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/iphone/marks-dark-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/iphone/marks-dark-default.png| index 1a2cba6..95e0c10 100644 |
| Binary files a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/iphone/marks-dark-default.png and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/iphone/marks-dark-default.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/iphone/marks-light-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/iphone/marks-light-default.png| index 8a21610..e8059db 100644 |
| Binary files a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/iphone/marks-light-default.png and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/iphone/marks-light-default.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/mac/marks-dark-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/mac/marks-dark-default.png| index caad3da..a53fa93 100644 |
| Binary files a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/mac/marks-dark-default.png and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/mac/marks-dark-default.png differ |
diff --git a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/mac/marks-light-default.png b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/mac/marks-light-default.png| index 0846e76..306d4a3 100644 |
| Binary files a/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/mac/marks-light-default.png and b/native/apple/Tests/BaseSnapshots/__Snapshots__/base-look/mac/marks-light-default.png differ |