carlos / platform Public

console: one-line claim picker, honest progress, two-link done page

Account picker: one line per account with plan, usage and room chips;
sponsored accounts no longer print the unlimited sentinel or an empty
meter; ineligible accounts sort last; a name search above six accounts.
Returning from Keymail paints the progress view first. Progress: a bar
that never goes back, rotating hints, elapsed time, a stuck box after
the server deadline and a separate "still finishing" box past the
irreversible commit. Done page: "Open in the console" (current members
only) and the live address as an external link. Copy approved by Paul
in copy review; Astra reviewed (two P2s fixed, round 2 READY).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from claim-picker-rows into main.
claude agent, operated by paul@keymail.dev f2cf2828fcbdd863e408a8b37b58529cbbdbb2ea parent 178dcfe
11 files changed, +803 −122
  • internal/console/demo_claim_choice_test.go +206 −18
  • internal/console/demo_claim_copy.go +49 −8
  • internal/console/demo_claim_footer_test.go +13 −11
  • internal/console/demo_claim_page.go +109 −13
  • internal/console/demo_claim_resume_browser_test.go +75 −3
  • internal/console/demo_claim_resume_test.go +17 −1
  • internal/console/demo_claim_status_page.go +6 −0
  • internal/console/demo_claim_ux_test.go +3 −3
  • internal/console/static/demo_claim.js +145 −11
  • internal/console/templates/demo_claim.html +72 −40
  • internal/console/testdata/demo_claim_resume_browser.mjs +108 −14

CI passed — run details

diff --git a/internal/console/demo_claim_choice_test.go b/internal/console/demo_claim_choice_test.go
index 4b3a8842a..3ecf7ce93 100644
--- a/internal/console/demo_claim_choice_test.go
+++ b/internal/console/demo_claim_choice_test.go
@@ -114,6 +114,13 @@ func TestDemoClaimStatusDoor(t *testing.T) {
t.Error("missing stopping explanation")
}
want := 2
+ if tc.state == "claiming" {
+ // Only a claiming payload says whether the commit has happened.
+ want = 3
+ if got["committed"] != (tc.phase == "committed") {
+ t.Errorf("%s: committed = %v", tc.phase, got["committed"])
+ }
+ }
if tc.phase == "done" {
want = 3
if got["url"] != "https://"+op.Target.Host {
@@ -180,9 +187,9 @@ func TestDemoClaimChoiceRoom(t *testing.T) {
reason, room string
}{
{"fits exactly", RoleOwner, 0, true, false, "", "Has room"},
- {"needs two slots", RoleMember, 1, true, false, "Not enough room: 2 of 3 apps and instances in use. This demo needs room for one app and its instance.", ""},
- {"full", RoleOwner, 2, true, false, "Full: 3 of 3 apps and instances in use", ""},
- {"over limit", RoleOwner, 3, true, false, "Full: 4 of 3 apps and instances in use", ""},
+ {"needs two slots", RoleMember, 1, true, false, demoClaimNoRoom, ""},
+ {"full", RoleOwner, 2, true, false, demoClaimFull, ""},
+ {"over limit", RoleOwner, 3, true, false, demoClaimFull, ""},
{"role", "viewer", 0, true, false, demoClaimRoleDenied, ""},
{"role at limit", "viewer", 2, true, false, demoClaimRoleDenied, ""},
{"plans off", RoleOwner, 1, false, false, "", ""},
@@ -215,8 +222,12 @@ func TestDemoClaimChoiceRoom(t *testing.T) {
if !strings.Contains(body, tc.reason) || !strings.Contains(body, `value="`+a.Sqid+`" disabled`) || strings.Contains(body, `action="/demo/claim/select"`) {
t.Error("ineligible account not disabled with its reason")
}
- if !strings.Contains(body, "You are signed in as") || !strings.Contains(body, `<span class="claim-detail">`+tc.reason+"</span>") {
- t.Error("no_accounts missing identity or muted reason")
+ if !strings.Contains(body, "You are signed in as") || !regexp.MustCompile(`<span class="chip chip-(stale|env)">`+regexp.QuoteMeta(tc.reason)+`</span>`).MatchString(body) {
+ t.Error("no_accounts missing identity or status chip")
+ }
+ note := map[string]string{demoClaimNoRoom: demoClaimNoRoomNote, demoClaimRoleDenied: demoClaimRoleDeniedNote}[tc.reason]
+ if note != "" && !strings.Contains(body, `<span class="claim-row-note">`+note+"</span>") {
+ t.Errorf("ineligible row missing its note %q", note)
}
} else if !strings.Contains(body, `type="hidden" name="accountId" value="`+a.Sqid+`"`) {
t.Error("eligible account lost")
@@ -228,18 +239,21 @@ func TestDemoClaimChoiceRoom(t *testing.T) {
if tc.room != "" && strings.Count(body, ">"+tc.room+"<") != 1 {
t.Errorf("single account must show exactly one %q line", tc.room)
}
- if tc.reason == "" || tc.role == "viewer" {
- if strings.Contains(body, "apps and instances") {
- t.Error("eligible or role-disabled account shows counts")
- }
- } else if strings.Count(body, tc.reason) != 1 {
- t.Error("capacity reason must appear once")
+ counted := tc.plans && !tc.fail && tc.role != "viewer"
+ if usage := fmt.Sprintf(demoClaimUsageOf, tc.instances+1, 3); counted != strings.Contains(body, `<span class="claim-usage">`+usage+"</span>") {
+ t.Errorf("usage %q shown = %v, want %v", usage, !counted, counted)
+ }
+ if !counted && strings.Contains(body, `class="claim-usage"`) {
+ t.Error("uncounted account shows a usage figure")
+ }
+ if tc.reason != "" && strings.Count(body, ">"+tc.reason+"<") != 1 {
+ t.Error("status chip must appear once")
}
if (!tc.plans || tc.role == "viewer") && spy.calls.Load() != 0 {
t.Error("plans off or role-disabled account read store")
}
if tc.plans && !tc.fail && tc.role != "viewer" {
- if !strings.Contains(body, ">Free plan<") {
+ if !strings.Contains(body, `<span class="chip chip-env">Free</span>`) {
t.Error("missing plan")
}
if isPlanCap(s.checkRunningThings(t.Context(), a, 2)) != (tc.instances >= 1) {
@@ -386,7 +400,7 @@ func TestDemoClaimProgressAndOutcome(t *testing.T) {
address := "https://a-long-permanent-app-name.account.apps.example.com"
copy := demoClaimBrowserCopy()
copy["completeHeading"] = "example is yours"
- if err := demoClaimPageTemplate.ExecuteTemplate(&rendered, "demo_claim.html", demoClaimPageData{Copy: copy, State: state, Step: 2, URL: address}); err != nil {
+ if err := demoClaimPageTemplate.ExecuteTemplate(&rendered, "demo_claim.html", demoClaimPageData{Copy: copy, State: state, Step: 2, URL: address, ConsoleURL: "/a/k3x9/apps/example", DeadlineIn: "240", DemoName: "example", DemoHost: "example-demo.example.com"}); err != nil {
t.Fatal(err)
}
body := rendered.String()
@@ -394,16 +408,29 @@ func TestDemoClaimProgressAndOutcome(t *testing.T) {
if !strings.Contains(body, `id="claim-status" class="claim-sr-only" role="status" aria-live="polite"`) || !strings.Contains(body, "#claim .claim-sr-only") {
t.Error("live status must use the scoped screen-reader-only class")
}
- if !strings.Contains(body, `data-step="2" aria-current="step">`) || !strings.Contains(body, `<strong>Starting your app</strong>`) {
+ if !strings.Contains(body, `aria-current="step">`) || !strings.Contains(body, `<strong>Starting your app</strong>`) || !regexp.MustCompile(`data-step="2" data-hints="[^"]+" aria-current="step"`).MatchString(body) {
t.Error("current step is not marked")
}
+ for _, want := range []string{`data-deadline-in="240"`, `role="progressbar"`, `id="claim-stuck"`, `id="claim-elapsed"`, demoClaimStuckHeading} {
+ if !strings.Contains(body, want) {
+ t.Errorf("progress view missing %q", want)
+ }
+ }
} else {
if !strings.Contains(body, `<h1 id="claim-heading" tabindex="-1">example is yours</h1>`) || strings.Contains(body, demoClaimComplete) {
t.Error("outcome must appear once, as the heading")
}
- link := regexp.MustCompile(`<a class="btn claim-open" href="([^"]+)" rel="noreferrer">([^<]+)</a>`).FindStringSubmatch(body)
- if len(link) != 3 || link[1] != address || link[2] != demoClaimUX45 || !strings.Contains(body, `<p class="claim-result-address">`+address+`</p>`) {
- t.Error("result link must display the permanent address")
+ // Two actions: the app in the console, and the live address as
+ // its own link opening a new tab, shown once.
+ if !strings.Contains(body, `<a class="btn claim-console" href="/a/k3x9/apps/example">`+demoClaimOpenConsole+`</a>`) {
+ t.Error("missing the console action")
+ }
+ link := regexp.MustCompile(`<a class="claim-open" href="([^"]+)" target="_blank" rel="noopener noreferrer"><span class="claim-open-address">([^<]+)</span><svg[^>]*aria-hidden="true"`).FindStringSubmatch(body)
+ if len(link) != 3 || link[1] != address || link[2] != address || !strings.Contains(body, demoClaimOpensNewTab) {
+ t.Error("result link must display the permanent address with an external-link icon")
+ }
+ if strings.Count(body, ">"+address+"<") != 2 || strings.Contains(body, "claim-result-address") {
+ t.Error("permanent address must show in the ticket and the action row only")
}
}
})
@@ -505,7 +532,7 @@ func TestDemoClaimChoiceAdmissionAndExemption(t *testing.T) {
if spy.calls.Load() != 0 {
t.Error("counted unavailable or exempt account")
}
- if strings.Contains(body, ">Free plan<") {
+ if strings.Contains(body, `<span class="chip chip-env">Free</span>`) {
t.Error("false plan label")
}
if !exempt && (!strings.Contains(body, "<p>unavailable</p>") || strings.Contains(body, demoClaimNoEligibleAccount)) {
@@ -537,3 +564,164 @@ func TestDemoClaimChoicePrivacy(t *testing.T) {
t.Error("another person's proved flow revealed summary or accounts")
}
}
+
+// A sponsored account's "unlimited" limit is a sentinel (sponsorMost). The
+// picker shows how many things run, never the sentinel and never a meter
+// that would sit empty against it.
+func TestDemoClaimChoiceUnlimitedUsage(t *testing.T) {
+ s, _, token := claimTestServer(t)
+ b := newClaimBrowser(t, s, token)
+ b.login("shop@example.com", MethodEmail, true)
+ a := claimAccount(t, s, 501, "shop@example.com", RoleOwner)
+ claimAccount(t, s, 502, "shop@example.com", RoleOwner)
+ s.cfg.PlanCatalog = examplePlanCatalog(t)
+ unlimited := sponsorUnlimited()
+ if _, err := s.store.SetAccountPlan(a.ID, "personal", nil, 0, PlanSourceSponsored, &unlimited, "test", "ops@example.com", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := s.store.CreateAppIn(a.ID, "shop", "shop@example.com", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ if choice := s.demoClaimAccountView(t.Context(), *a, true); choice.Limit != sponsorMost || choice.Usage != fmt.Sprintf(demoClaimUsage, 1) || choice.Status != demoClaimHasRoom {
+ t.Fatalf("sponsored choice = %+v", choice)
+ }
+ body := b.request("GET", "/demo/claim", nil).Body.String()
+ for _, banned := range []string{fmt.Sprint(int64(sponsorMost)), "<meter", "claim-slots"} {
+ if strings.Contains(body, banned) {
+ t.Errorf("sponsored account renders %q", banned)
+ }
+ }
+ if !strings.Contains(body, `<span class="claim-usage">1 running</span>`) || !strings.Contains(body, `<span class="claim-usage">0 of 3 running</span>`) {
+ t.Error("rows lack their usage figures")
+ }
+ for _, c := range []struct {
+ used, limit int
+ want string
+ }{{17, sponsorMost, "17 running"}, {3, 5, "3 of 5 running"}, {0, 0, ""}} {
+ if got := demoClaimUsageText(c.used, c.limit); got != c.want {
+ t.Errorf("usage(%d, %d) = %q, want %q", c.used, c.limit, got, c.want)
+ }
+ }
+}
+
+// Past demoClaimSearchFrom accounts the list gets a search box (hidden until
+// the script shows it); rows that can take the demo come first, each group
+// in its original order.
+func TestDemoClaimChoiceSearchAndOrder(t *testing.T) {
+ for _, n := range []int{demoClaimSearchFrom, demoClaimSearchFrom + 1} {
+ t.Run(fmt.Sprint(n), func(t *testing.T) {
+ s, _, token := claimTestServer(t)
+ b := newClaimBrowser(t, s, token)
+ b.login("shop@example.com", MethodEmail, true)
+ var want, viewers []string
+ for i := 0; i < n; i++ {
+ role := RoleOwner
+ if i%3 == 0 {
+ role = "viewer"
+ }
+ a := claimChoiceAccount(t, s, int64(501+i), "shop@example.com", role)
+ if role == "viewer" {
+ viewers = append(viewers, a.Sqid)
+ } else {
+ want = append(want, a.Sqid)
+ }
+ }
+ want = append(want, viewers...)
+ body := b.request("GET", "/demo/claim", nil).Body.String()
+ var got []string
+ for _, m := range regexp.MustCompile(`type="radio" name="accountId" value="([^"]+)"`).FindAllStringSubmatch(body, -1) {
+ got = append(got, m[1])
+ }
+ if strings.Join(got, ",") != strings.Join(want, ",") {
+ t.Errorf("row order %v, want %v", got, want)
+ }
+ searchable := n > demoClaimSearchFrom
+ if strings.Contains(body, `<p class="claim-search" hidden><input type="search" id="claim-search"`) != searchable || strings.Contains(body, `id="claim-search-empty"`) != searchable {
+ t.Errorf("search box shown = %v, want %v", !searchable, searchable)
+ }
+ if searchable && regexp.MustCompile(`id="claim-search"[^>]* name=`).MatchString(body) {
+ t.Error("search field would be posted with the choice")
+ }
+ })
+ }
+}
+
+// Status access does not establish console access. The claim's own browser
+// keeps seeing the result and the live address, but "Open in the console"
+// needs the signed-in person to be a member of the destination account now,
+// and the app to exist there.
+func TestDemoClaimDoneConsoleLinkNeedsMembership(t *testing.T) {
+ for _, condition := range []string{"member", "viewer", "membership removed", "other person", "app deleted", "signed out"} {
+ t.Run(condition, func(t *testing.T) {
+ s, _, b := claimSigninFixture(t)
+ b.login("shop@example.com", MethodEmail, true)
+ a := claimAccount(t, s, 801, "shop@example.com", RoleOwner)
+ if w := b.post("/demo/claim/select", url.Values{"accountId": {a.Sqid}}); w.Code != 303 {
+ t.Fatalf("select: %d %s", w.Code, w.Body)
+ }
+ if _, err := s.store.db.Exec(`UPDATE demo_claim_ops SET phase='done'`); err != nil {
+ t.Fatal(err)
+ }
+ switch condition {
+ case "viewer":
+ _, _ = s.store.db.Exec(`UPDATE memberships SET role='viewer' WHERE account_id=?`, a.ID)
+ case "membership removed":
+ _, _ = s.store.db.Exec(`DELETE FROM memberships WHERE account_id=?`, a.ID)
+ case "other person":
+ b.login("other@example.com", MethodEmail, true)
+ case "app deleted":
+ _, _ = s.store.db.Exec(`UPDATE apps SET deleted_at=1 WHERE account_id=?`, a.ID)
+ case "signed out":
+ b.session = ""
+ }
+ body := b.request("GET", "/demo/claim", nil).Body.String()
+ if !strings.Contains(body, `data-state="claimed"`) || !strings.Contains(body, `class="claim-open" href="https://`) {
+ t.Fatal("the claim's browser lost its result or live address")
+ }
+ wantLink := condition == "member" || condition == "viewer"
+ if got := strings.Contains(body, `class="btn claim-console"`); got != wantLink {
+ t.Errorf("console link shown = %v, want %v", got, wantLink)
+ }
+ })
+ }
+}
+
+// The commit is the claim's one-way boundary. The status payload and the
+// page say so, so the browser never judges a committed claim by the
+// rollback deadline.
+func TestDemoClaimStatusCommitted(t *testing.T) {
+ s, _, b := claimSigninFixture(t)
+ b.login("shop@example.com", MethodEmail, true)
+ a := claimAccount(t, s, 801, "shop@example.com", RoleOwner)
+ if w := b.post("/demo/claim/select", url.Values{"accountId": {a.Sqid}}); w.Code != 303 {
+ t.Fatalf("select: %d %s", w.Code, w.Body)
+ }
+ status := func() map[string]any {
+ t.Helper()
+ r := httptest.NewRequest("GET", "/demo/claim/status", nil)
+ r.Header.Set("Sec-Fetch-Site", "same-origin")
+ r.AddCookie(&http.Cookie{Name: browserClaimCookieName, Value: b.cookie})
+ w := httptest.NewRecorder()
+ s.mux.ServeHTTP(w, r)
+ var out map[string]any
+ if w.Code != 200 || json.Unmarshal(w.Body.Bytes(), &out) != nil {
+ t.Fatalf("status: %d %s", w.Code, w.Body)
+ }
+ return out
+ }
+ for _, c := range []struct {
+ phase string
+ committed any
+ }{{"verifying", false}, {"committed", true}, {"done", nil}, {"aborting", nil}} {
+ if _, err := s.store.db.Exec(`UPDATE demo_claim_ops SET phase=?`, c.phase); err != nil {
+ t.Fatal(err)
+ }
+ if got := status()["committed"]; got != c.committed {
+ t.Errorf("%s: committed = %v, want %v", c.phase, got, c.committed)
+ }
+ body := b.request("GET", "/demo/claim", nil).Body.String()
+ if strings.Contains(body, "data-committed-for=") != (c.phase == "committed") {
+ t.Errorf("%s: page committed marker wrong", c.phase)
+ }
+ }
+}
diff --git a/internal/console/demo_claim_copy.go b/internal/console/demo_claim_copy.go
index 23086c70c..e5d62fb19 100644
--- a/internal/console/demo_claim_copy.go
+++ b/internal/console/demo_claim_copy.go
@@ -117,14 +117,26 @@ const (
demoClaimDestination = "This goes into %s."
// CLAIM-KEEP-IN: action after choosing an account.
demoClaimKeepIn = "Keep in %s"
- // CLAIM-ROOM-AVAILABLE: the account has room for the app and its instance.
+ // CLAIM-ROOM-AVAILABLE: status chip; the account has room for the app and its instance.
demoClaimHasRoom = "Has room"
- // CLAIM-ROOM-FULL: current use is at or above the catalog cap.
- demoClaimFull = "Full: %d of %d apps and instances in use"
- // CLAIM-ROOM-INSUFFICIENT: one slot remains, but the claim needs two.
- demoClaimNoRoom = "Not enough room: %d of %d apps and instances in use. This demo needs room for one app and its instance."
- // CLAIM-ROLE-DENIED: membership cannot create apps.
- demoClaimRoleDenied = "You can view this account but not add apps. Ask one of its owners."
+ // CLAIM-ROOM-FULL: status chip; current use is at or above the catalog cap.
+ demoClaimFull = "Full"
+ // CLAIM-ROOM-INSUFFICIENT: status chip; one slot remains, but the claim needs two.
+ demoClaimNoRoom = "No room"
+ // CLAIM-ROOM-INSUFFICIENT-NOTE: muted line under a no-room row.
+ demoClaimNoRoomNote = "Needs room for an app and its instance."
+ // CLAIM-ROLE-DENIED: status chip; membership cannot create apps.
+ demoClaimRoleDenied = "View only"
+ // CLAIM-ROLE-DENIED-NOTE: muted line under a view-only row.
+ demoClaimRoleDeniedNote = "Ask an owner to add apps."
+ // CLAIM-USAGE-CAPPED: row usage figure against a plan cap; used, limit.
+ demoClaimUsageOf = "%d of %d running"
+ // CLAIM-USAGE-UNLIMITED: row usage figure when the plan has no cap; used.
+ demoClaimUsage = "%d running"
+ // CLAIM-SEARCH-LABEL: search box label and placeholder above a long account list.
+ demoClaimSearchLabel = "Find an account"
+ // CLAIM-SEARCH-EMPTY: no account name matches the search.
+ demoClaimSearchEmpty = "No accounts match."
// CLAIM-STEP-COPYING: first progress step.
demoClaimCopying = "Copying your data"
// CLAIM-STEP-STARTING: second progress step.
@@ -187,10 +199,39 @@ const (
demoClaimUX75 = "Follow the directions on https://carlosframework.com/start"
demoClaimUX77 = "This app has already been kept"
demoClaimUX80 = "Sign in to the console"
- demoClaimPlan = "%s plan"
demoClaimOpening = "Opening your demo…"
)
+// Progress reassurance, the stuck state and the result actions.
+const (
+ // CLAIM-PROGRESS-LABEL: accessible name of the progress bar.
+ demoClaimProgressLabel = "Progress"
+ // CLAIM-ELAPSED: shown after 30 s of progress; {elapsed} is "45 s" or "1 min 10 s".
+ demoClaimElapsed = "{elapsed} so far. This can take a few minutes."
+ // CLAIM-STUCK-HEADING: past the server's own deadline and the claim still reports running.
+ demoClaimStuckHeading = "This is taking longer than it should."
+ // CLAIM-STUCK-DETAIL: what is true while stuck, and what to do.
+ demoClaimStuckDetail = "Nothing is lost. A move that does not finish is undone, and your demo goes back to how it was."
+ // CLAIM-STUCK-ACTION: reloads the page to read the claim's state again.
+ demoClaimStuckAction = "Check again"
+ // CLAIM-FINISHING-HEADING: committed (the move cannot be undone) but the
+ // last steps are slow. New after copy review; awaiting review.
+ demoClaimFinishingHeading = "Your app is yours now. It is still finishing."
+ // CLAIM-FINISHING-DETAIL: what is true while a committed claim finishes. New; awaiting review.
+ demoClaimFinishingDetail = "The move is done and stays done. The last steps are taking longer than usual."
+ // CLAIM-OPEN-CONSOLE: done page primary action, the app's page in the console.
+ demoClaimOpenConsole = "Open in the console"
+ // CLAIM-OPENS-NEW-TAB: screen-reader suffix on the live address link.
+ demoClaimOpensNewTab = "(opens in a new tab)"
+)
+
+// CLAIM-HINTS-*: reassurance lines that rotate under the active step, one at
+// a time, after the step's own detail line.
+var (
+ demoClaimHintsCopying = []string{"Pausing the demo so nothing changes mid-copy", "Packing up its saved data", "Checking everything arrived"}
+ demoClaimHintsStarting = []string{"Placing it on a server", "Restoring its saved data", "Waiting for its secure address", "Checking it answers", "Still working. A first start can take a minute or two."}
+)
+
// COUNTDOWN-01..14, with the controller's singular-unit ruling.
func demoClaimCountdown(seconds int64) (visible, accessible string) {
unit := func(n int64, name string) string {
diff --git a/internal/console/demo_claim_footer_test.go b/internal/console/demo_claim_footer_test.go
index 5c4754a95..c23234b12 100644
--- a/internal/console/demo_claim_footer_test.go
+++ b/internal/console/demo_claim_footer_test.go
@@ -11,19 +11,21 @@ import (
"testing"
)
-// The digests were taken from the claim page before the footer existed. With
-// neither item configured (or both invalid) the page is these exact bytes.
-const demoClaimFooterBaseStyleHash = "'sha256-0/eCVx0ZVcjLY0c+mSbXxujrLi96B+0QEsMyCIBaADI='"
+// The digests are the claim page with no footer, retaken when the page itself
+// or its script changes (the script tag carries the asset hash; last: the
+// claim-picker-rows review fixes). With neither item configured (or both
+// invalid) the page is these exact bytes.
+const demoClaimFooterBaseStyleHash = "'sha256-jbEMQSC7VKnO3PowM9lc1xx5+TuvoIMmes/XPpn9IEM='"
var demoClaimFooterBaseDigests = map[string]string{
- "template-zero": "48b65f39722b9f26dfd9e1cc74e99b8d25859993e4af6681e886e8a9b09c923f",
- "template-missing": "2c793c646d7199bba6a84e4c552992dfc8fd7d17111a108232b93e4fa92ec5a0",
- "template-error": "1e8177ca639ff61406cfc0bc9db173b6668ac924bf53b875da7a5ef0dd1961ae",
- "template-claimed": "ab4542a9b912449bbc637595e9f51f653b417940eee103e7970eadb710fd667e",
- "template-proof": "9ca3d70d40f86bffa5081768630b3524b60548f2e8ffcb26eaf10e0a0c9e6458",
- "error-page": "f6cd7ee22473fb614b2f247599a1dfe3eac1ce870268ad6332ebafc37fd49a09",
- "get-claim": "c67a7aa13e23edb1a78fec563c17d74f173fa5153dc4fea3c8a10d128c18395d",
- "get-kept": "6050a0a0f5516f8209baf8dcf4a6549986f4f97d1f0026889cc8ad5e1b4c5d93",
+ "template-zero": "307ae622a5541a738bd6d7117eaf00c2058afbc914e9a0f2e48157b3983356f2",
+ "template-missing": "c54a88efef115981799be2d80c0c47326d1fc2e7407cbcd6c96793be1026d8e1",
+ "template-error": "bc32157b2db3b29a739b840e0e9fc6c77c1ed9f7e93341b2a8caa06d41c6cf79",
+ "template-claimed": "fe5aef8746a63ac522ee05652393de418ced5bebc3b2e6894a0f7c4484fa070d",
+ "template-proof": "3c22418e10842d8cfad9a96518e011de43bf6c780b4db67546c2760c6dd81318",
+ "error-page": "d503dc9f496c8eaa8cf34e0ed15862ddf11ac91125d7dfc3451da6f8b13ab0ac",
+ "get-claim": "0d044d6e85e3f8db1a33c19e5e3844f76c7fe6dad9a1fd70da71a9aaeeca00e5",
+ "get-kept": "b7b65fb23266019375e2ec0a8764f15183fcc3450b0f69d0d3c5b218345bc6c5",
}
const (
diff --git a/internal/console/demo_claim_page.go b/internal/console/demo_claim_page.go
index 77b4e04d9..e6de971b0 100644
--- a/internal/console/demo_claim_page.go
+++ b/internal/console/demo_claim_page.go
@@ -13,6 +13,7 @@ import (
"io"
"net/http"
"net/url"
+ "sort"
"strings"
"time"
)
@@ -59,7 +60,22 @@ type demoClaimPageData struct {
TimeLeft, TimeLeftAccessible, EndTime string
Step int
CanClaim, HasIntent, EmailPending bool
- Footer demoClaimFooter
+ // Searchable shows the account filter above a long list.
+ Searchable bool
+ // ConsoleURL is the claimed app's page in the console, for a reader who
+ // can open it; empty otherwise.
+ ConsoleURL string
+ // DeadlineIn is the seconds from render to the operation's server
+ // deadline (negative once past; empty with no operation). Past it the
+ // coordinator undoes an unfinished claim, so a claim that still reports
+ // progress well after it is stuck. Relative, so the browser's clock
+ // does not matter.
+ DeadlineIn string
+ // CommittedFor is set for a claim past its irreversible commit and still
+ // finishing: the seconds since the commit ("0" when unknown). Such a
+ // claim is never judged by the rollback deadline.
+ CommittedFor string
+ Footer demoClaimFooter
}
func (s *Server) demoClaimPageHeaders(w http.ResponseWriter, keymailOrigin string) {
@@ -169,6 +185,15 @@ func (s *Server) handleDemoClaimPage(w http.ResponseWriter, r *http.Request) {
setDemoClaimCookie(w, cookie, expiry)
p.State, p.Step = demoClaimProgressStep(op.Phase)
p.ExpiresAt = op.SourceExpiresAt
+ p.DeadlineIn = fmt.Sprint(op.Deadline.Unix() - time.Now().Unix())
+ if op.Phase == "committed" {
+ var at int64
+ _ = s.store.db.QueryRowContext(r.Context(), `SELECT committed_at FROM demo_claim_commits WHERE operation_id=?`, op.ID).Scan(&at)
+ p.CommittedFor = fmt.Sprint(max(0, time.Now().Unix()-at))
+ if at == 0 {
+ p.CommittedFor = "0"
+ }
+ }
p.App = op.Target.App
if d, err := s.store.demoByID(r.Context(), op.DemoID); err == nil {
p.DemoName, p.DemoHost = d.Name, d.Host
@@ -185,6 +210,7 @@ func (s *Server) handleDemoClaimPage(w http.ResponseWriter, r *http.Request) {
if canContinue {
if acct, err := s.store.AccountByID(op.Target.AccountID); err == nil && acct != nil && acct.Sqid == op.Target.Sqid {
p.AccountName, p.AccountSqid = acct.Name, acct.Sqid
+ p.ConsoleURL = s.demoClaimConsoleURL(address, acct, p.App)
p.Copy["sameChat"] = "Still in the chat where you built it?"
p.Copy["sameChatLine"] = fmt.Sprintf("Tell your agent: “I kept %s. It now lives at %s in my account %s.”", p.App, p.URL, acct.Name)
p.Copy["agentHeading"] = "Starting fresh, in a new chat or with another agent?"
@@ -252,6 +278,9 @@ func (s *Server) handleDemoClaimPage(w http.ResponseWriter, r *http.Request) {
}
}
}
+ // Accounts that can take the demo come first, each group in
+ // its original order. Sort before Single points into the slice.
+ sort.SliceStable(p.Accounts, func(i, j int) bool { return p.Accounts[i].Reason == "" && p.Accounts[j].Reason != "" })
if p.Eligible == 1 {
for i := range p.Accounts {
if p.Accounts[i].Reason == "" {
@@ -264,6 +293,7 @@ func (s *Server) handleDemoClaimPage(w http.ResponseWriter, r *http.Request) {
if resume && selection.Create && len(accounts) == 0 {
p.AutoSubmit = p.CanClaim
}
+ p.Searchable = p.Single == nil && len(p.Accounts) > demoClaimSearchFrom
if len(accounts) > 0 && p.Eligible == 0 {
p.State, p.CanClaim = "no_accounts", false
}
@@ -617,8 +647,7 @@ func demoClaimBrowserCopy() map[string]string {
"codeHeading": demoClaimUX16, "codeWorking": demoClaimUX20, "codeRecovery": demoClaimUX21, "changeAddress": demoClaimUX22,
"accountsHeading": demoClaimUX24, "accountsLabel": demoClaimUX26, "selectWorking": demoClaimUX34,
"copyingDetail": demoClaimUX38, "startingDetail": demoClaimUX40,
- "completeDetail": demoClaimUX44, "open": demoClaimUX45,
- "keepGoing": demoClaimUX47, "agentHeading": demoClaimUX48, "agentDetail": demoClaimUX49,
+ "completeDetail": demoClaimUX44, "keepGoing": demoClaimUX47, "agentHeading": demoClaimUX48, "agentDetail": demoClaimUX49,
"cliHeading": demoClaimUX52, "failureHeading": demoClaimUX61,
"expiredHeading": demoClaimUX72, "newDemo": demoClaimUX74, "newDemoLine": demoClaimUX75,
"keptHeading": demoClaimUX77, "consoleSignin": demoClaimUX80, "opening": demoClaimOpening,
@@ -663,6 +692,20 @@ func demoClaimBrowserCopy() map[string]string {
"disabled": demoClaimUnavailable,
"footerTerms": demoClaimFooterTerms,
"footerAbuse": demoClaimFooterAbuse,
+ "searchLabel": demoClaimSearchLabel,
+ "searchEmpty": demoClaimSearchEmpty,
+ "progressLabel": demoClaimProgressLabel,
+ "elapsed": demoClaimElapsed,
+ "stuckHeading": demoClaimStuckHeading,
+ "stuckDetail": demoClaimStuckDetail,
+ "stuckAction": demoClaimStuckAction,
+ "finishingHeading": demoClaimFinishingHeading,
+ "finishingDetail": demoClaimFinishingDetail,
+ "openConsole": demoClaimOpenConsole,
+ "opensNewTab": demoClaimOpensNewTab,
+ // Rotating lines travel as one attribute each, a line per hint.
+ "hintsCopying": strings.Join(demoClaimHintsCopying, "\n"),
+ "hintsStarting": strings.Join(demoClaimHintsStarting, "\n"),
}
}
@@ -703,14 +746,73 @@ func (s *Server) continueDemoClaimKeymail(w http.ResponseWriter, r *http.Request
s.continueKeymailSignin(w, r, flow, "/demo/claim")
}
+// demoClaimConsoleURL is the claimed app's console page, only when the
+// current session can open it: the signed-in person is a member (any role,
+// as the console's app pages ask) of the destination account and the app
+// exists there. The claim's status cookie shows progress and the live
+// address; it never establishes console access.
+func (s *Server) demoClaimConsoleURL(address string, acct *Account, app string) string {
+ if address == "" || acct == nil {
+ return ""
+ }
+ if role, err := s.store.Role(acct.ID, address); err != nil || role == "" {
+ return ""
+ }
+ if has, err := s.store.HasAppIn(acct.ID, app); err != nil || !has {
+ return ""
+ }
+ return "/a/" + url.PathEscape(acct.Sqid) + "/apps/" + url.PathEscape(app)
+}
+
+// demoClaimSearchFrom is the list length above which the picker offers a
+// search box: past it the list no longer fits a phone screen.
+const demoClaimSearchFrom = 6
+
// Room is a GET-only hint. Reservation still checks under its account lock.
+// Reason is the status chip of an account that cannot take the demo (empty
+// when it can); Room is the chip of one that can, when it was counted.
+// Status and StatusClass are the chip the row shows, Note a short muted line
+// for an ineligible row, and Usage the running count, never the "unlimited"
+// sentinel.
type demoClaimAccountChoice struct {
Sqid, Name, Plan, Room, Reason, Button string
- Slots []bool
+ Status, StatusClass, Note, Usage string
Used, Limit int
}
+// demoClaimUsageText is the row's running figure: "3 of 5 running" under a
+// cap, "17 running" when the plan has none (sponsorMost, as the billing page
+// treats it). A zero limit (not counted) shows nothing.
+func demoClaimUsageText(used, limit int) string {
+ switch {
+ case limit <= 0:
+ return ""
+ case int64(limit) >= sponsorMost:
+ return fmt.Sprintf(demoClaimUsage, used)
+ default:
+ return fmt.Sprintf(demoClaimUsageOf, used, limit)
+ }
+}
+
func (s *Server) demoClaimAccountView(ctx context.Context, a Account, count bool) demoClaimAccountChoice {
+ c := s.demoClaimAccountCount(ctx, a, count)
+ c.Usage = demoClaimUsageText(c.Used, c.Limit)
+ switch {
+ case c.Reason == demoClaimRoleDenied:
+ // The plan does not matter to someone who cannot add apps.
+ c.Plan = ""
+ c.Status, c.StatusClass, c.Note = c.Reason, "chip-env", demoClaimRoleDeniedNote
+ case c.Reason == demoClaimNoRoom:
+ c.Status, c.StatusClass, c.Note = c.Reason, "chip-stale", demoClaimNoRoomNote
+ case c.Reason != "":
+ c.Status, c.StatusClass = c.Reason, "chip-stale"
+ case c.Room != "":
+ c.Status, c.StatusClass = c.Room, "chip-health-ok"
+ }
+ return c
+}
+
+func (s *Server) demoClaimAccountCount(ctx context.Context, a Account, count bool) demoClaimAccountChoice {
c := demoClaimAccountChoice{Sqid: a.Sqid, Name: a.Name, Button: fmt.Sprintf(demoClaimKeepIn, a.Name)}
if !demoClaimCanCreate(a) {
c.Reason = demoClaimRoleDenied
@@ -722,7 +824,7 @@ func (s *Server) demoClaimAccountView(ctx context.Context, a Account, count bool
if row != nil {
name = row.Plan
}
- c.Plan = fmt.Sprintf(demoClaimPlan, planLabel(name))
+ c.Plan = planLabel(name)
}
}
if !count || c.Reason != "" || ctx.Err() != nil {
@@ -737,17 +839,11 @@ func (s *Server) demoClaimAccountView(ctx context.Context, a Account, count bool
return c
}
c.Used, c.Limit = n, limits.RunningThings
- // Keep the drawing bounded for large plans; the numeric ratio stays exact.
- if c.Limit <= 100 {
- for i := 0; i < c.Limit; i++ {
- c.Slots = append(c.Slots, i < n)
- }
- }
switch {
case n >= limits.RunningThings:
- c.Reason = fmt.Sprintf(demoClaimFull, n, limits.RunningThings)
+ c.Reason = demoClaimFull
case n+2 > limits.RunningThings:
- c.Reason = fmt.Sprintf(demoClaimNoRoom, n, limits.RunningThings)
+ c.Reason = demoClaimNoRoom
default:
c.Room = demoClaimHasRoom
}
diff --git a/internal/console/demo_claim_resume_browser_test.go b/internal/console/demo_claim_resume_browser_test.go
index 29ecc78cc..ad0295b09 100644
--- a/internal/console/demo_claim_resume_browser_test.go
+++ b/internal/console/demo_claim_resume_browser_test.go
@@ -45,7 +45,29 @@ func TestDemoClaimSelectStepUpHeadless(t *testing.T) {
mode.Store(4)
phase = "future-phase"
}
- if _, err := s.store.db.Exec(`UPDATE demo_claim_ops SET phase=?`, phase); err != nil {
+ // Past the server's deadline by more than the page's grace, and
+ // still reporting progress: the page must call it stuck.
+ deadline := time.Now().Add(5 * time.Minute).Unix()
+ if r.URL.Query().Get("testProgress") == "stuck" {
+ mode.Store(5)
+ phase = "verifying"
+ deadline = time.Now().Add(-100 * time.Second).Unix()
+ }
+ if r.URL.Query().Get("testProgress") == "starting" {
+ mode.Store(5)
+ phase = "verifying"
+ }
+ // Committed five minutes ago, well past the rollback deadline,
+ // and still finishing: never the rollback box, the finishing one.
+ if r.URL.Query().Get("testProgress") == "committed" {
+ mode.Store(6)
+ phase = "committed"
+ deadline = time.Now().Add(-1000 * time.Second).Unix()
+ if _, err := s.store.db.Exec(`INSERT OR REPLACE INTO demo_claim_commits(operation_id,demo_id,committed_at) SELECT id,demo_id,? FROM demo_claim_ops`, time.Now().Add(-300*time.Second).Unix()); err != nil {
+ t.Error(err)
+ }
+ }
+ if _, err := s.store.db.Exec(`UPDATE demo_claim_ops SET phase=?,deadline=?`, phase, deadline); err != nil {
t.Error(err)
}
}
@@ -72,6 +94,12 @@ func TestDemoClaimSelectStepUpHeadless(t *testing.T) {
if mode.Load() == 4 {
phase = "future-phase"
}
+ if mode.Load() == 5 {
+ phase = "verifying"
+ }
+ if mode.Load() == 6 {
+ phase = "committed"
+ }
if mode.Load() == 2 {
phase = "aborted"
}
@@ -164,9 +192,53 @@ func TestDemoClaimSelectStepUpHeadless(t *testing.T) {
}
}
}
+ // Thirty accounts, as one person had on production: sponsored (no cap),
+ // capped with room, full, short of room and view-only rows.
+ picker, _, pickerToken := claimTestServer(t)
+ picker.registerRoute(routeDecl{Pattern: "GET /static/{hash}/{file...}"}, picker.handleStatic)
+ pickerServer := httptest.NewServer(picker.mux)
+ defer pickerServer.Close()
+ picker.cfg.Origin = pickerServer.URL
+ picker.cfg.PlanCatalog = examplePlanCatalog(t)
+ many := newClaimBrowser(t, picker, pickerToken)
+ many.login("shop@example.com", MethodEmail, true)
+ unlimited := sponsorUnlimited()
+ for i := 1; i <= 30; i++ {
+ role := RoleOwner
+ if i%7 == 0 {
+ role = "viewer"
+ }
+ a := claimChoiceAccount(t, picker, int64(800+i), "shop@example.com", role)
+ if _, err := picker.store.db.Exec(`UPDATE accounts SET name=? WHERE id=?`, fmt.Sprintf("team-%02d", i), a.ID); err != nil {
+ t.Fatal(err)
+ }
+ apps, instances := i%2, 0
+ switch i {
+ case 1, 4, 12:
+ if _, err := picker.store.SetAccountPlan(a.ID, "personal", nil, 0, PlanSourceSponsored, &unlimited, "test", "ops@example.com", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ apps = 17
+ case 3, 10:
+ apps, instances = 1, 2
+ case 6:
+ apps, instances = 1, 1
+ }
+ for j := 0; j < apps; j++ {
+ if _, err := picker.store.CreateAppIn(a.ID, fmt.Sprintf("app%d", j), "shop@example.com", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ }
+ for j := 0; j < instances; j++ {
+ if _, err := picker.cfg.Releases.Put(t.Context(), provision.RecordKey(a.Sqid, "app0", fmt.Sprintf("app0-%d.example.com", j)), []byte(`{}`), ""); err != nil {
+ t.Fatal(err)
+ }
+ }
+ }
singleArgs, _ := json.Marshal(map[string]string{"target": singleServer.URL, "session": one.session, "cookie": one.cookie,
- "capacityTarget": capacityServer.URL, "capacitySession": room.session, "capacityCookie": room.cookie})
- ctx, cancel := context.WithTimeout(t.Context(), 120*time.Second)
+ "capacityTarget": capacityServer.URL, "capacitySession": room.session, "capacityCookie": room.cookie,
+ "pickerTarget": pickerServer.URL, "pickerSession": many.session, "pickerCookie": many.cookie})
+ ctx, cancel := context.WithTimeout(t.Context(), 180*time.Second)
defer cancel()
cmd := exec.CommandContext(ctx, node, "testdata/demo_claim_resume_browser.mjs", chromium, t.TempDir(), ts.URL, b.session, b.cookie, a.Sqid, os.Getenv("CARLOS_DEMO_CLAIM_SCREENSHOTS"), string(singleArgs))
output, err := cmd.CombinedOutput()
diff --git a/internal/console/demo_claim_resume_test.go b/internal/console/demo_claim_resume_test.go
index c0a347595..f070e339d 100644
--- a/internal/console/demo_claim_resume_test.go
+++ b/internal/console/demo_claim_resume_test.go
@@ -83,9 +83,20 @@ func TestDemoClaimSelectStepUpRoundTrip(t *testing.T) {
t.Fatal("resume must consume stash without claiming")
}
w = b.request("GET", "/demo/claim", nil)
- if !strings.Contains(w.Body.String(), `data-auto-submit`) || !strings.Contains(w.Body.String(), `value="`+a.Sqid+`" checked`) {
+ if !strings.Contains(w.Body.String(), `data-auto-submit`) || !strings.Contains(w.Body.String(), `<input type="hidden" name="accountId" value="`+a.Sqid+`">`) {
t.Fatalf("selected account was not resumed: %s", w.Body)
}
+ // The first paint of a resumed choice is the progress view: no
+ // account list flashes up before the script posts the choice.
+ body := w.Body.String()
+ for _, banned := range []string{`type="radio"`, `class="claim-card"`, demoClaimUX24, `id="claim-accounts"`, demoClaimIdentityLabel} {
+ if strings.Contains(body, banned) {
+ t.Errorf("auto-submit first paint shows the account list (%q)", banned)
+ }
+ }
+ if !strings.Contains(body, `<div id="claim-progress" data-stage="0" data-pending`) || !strings.Contains(body, `<h1 id="claim-heading" tabindex="-1">`+demoClaimPageTitle+`</h1>`) || !strings.Contains(body, "<noscript><button type=\"submit\">") {
+ t.Errorf("auto-submit first paint is not the progress view with a no-script button: %s", body)
+ }
if claimBrowserCount(t, s, "demo_claim_ops") != 0 {
t.Fatal("GET claimed")
}
@@ -107,6 +118,11 @@ func TestDemoClaimSelectStepUpRoundTrip(t *testing.T) {
if !strings.Contains(w.Body.String(), demoClaimCopying) {
t.Fatal("no claiming state")
}
+ // Reload or back after the automatic post renders the claim's
+ // progress, never the resumed choice again: nothing replays it.
+ if strings.Contains(w.Body.String(), "data-auto-submit") || strings.Contains(w.Body.String(), "data-pending") {
+ t.Fatal("a reload after the automatic post would post the choice again")
+ }
b.post("/demo/claim/select", url.Values{"accountId": {a.Sqid}})
if claimBrowserCount(t, s, "demo_claim_ops") != 1 {
t.Fatal("duplicate reservation")
diff --git a/internal/console/demo_claim_status_page.go b/internal/console/demo_claim_status_page.go
index 110ea5f44..c05cdee82 100644
--- a/internal/console/demo_claim_status_page.go
+++ b/internal/console/demo_claim_status_page.go
@@ -38,6 +38,12 @@ func (s *Server) handleDemoClaimBrowserStatus(w http.ResponseWriter, r *http.Req
}
state, step := demoClaimProgressStep(op.Phase)
body := map[string]any{"state": state, "step": step}
+ // Past the commit the claim cannot be rolled back (demo_claim_transfer.go
+ // refuses an abort after it), and finishing may run past the deadline, so
+ // the page must not judge it by the rollback deadline.
+ if state == "claiming" {
+ body["committed"] = op.Phase == "committed"
+ }
if state == "claimed" {
body["url"] = "https://" + op.Target.Host
}
diff --git a/internal/console/demo_claim_ux_test.go b/internal/console/demo_claim_ux_test.go
index d161b94b2..9763241cb 100644
--- a/internal/console/demo_claim_ux_test.go
+++ b/internal/console/demo_claim_ux_test.go
@@ -27,8 +27,8 @@ func TestDemoClaimUXProductionPages(t *testing.T) {
a := claimAccount(t, s, 801, "shop@example.com", RoleOwner)
s.cfg.PlanCatalog = examplePlanCatalog(t)
body = b.request("GET", "/demo/claim", nil).Body.String()
- if !strings.Contains(body, `class="claim-slots"`) {
- t.Error("no capacity drawing")
+ if !strings.Contains(body, `<span class="claim-usage">0 of 3 running</span>`) || !strings.Contains(body, `<span class="chip chip-health-ok">Has room</span>`) {
+ t.Error("no capacity figure or status chip")
}
if w := b.post("/demo/claim/select", url.Values{"accountId": {a.Sqid}}); w.Code != 303 {
t.Fatalf("select: %d %s", w.Code, w.Body)
@@ -43,7 +43,7 @@ func TestDemoClaimUXProductionPages(t *testing.T) {
t.Error("ticket lost after selection")
}
if phase == "done" {
- for _, want := range []string{"Open your app", "Still in the chat where you built it?", "No saved source for this app.", `data-state="claimed"`} {
+ for _, want := range []string{demoClaimOpenConsole, `class="claim-open"`, "Still in the chat where you built it?", "No saved source for this app.", `data-state="claimed"`} {
if !strings.Contains(body, want) {
t.Errorf("result missing %q", want)
}
diff --git a/internal/console/static/demo_claim.js b/internal/console/static/demo_claim.js
index a2edb27cb..209233e6e 100644
--- a/internal/console/static/demo_claim.js
+++ b/internal/console/static/demo_claim.js
@@ -29,6 +29,9 @@
const working = [];
addEventListener("pageshow", event => {
if (!event.persisted) return;
+ // Back to a resumed choice's first paint: it was posted already and is
+ // never posted again; read the claim's real state instead.
+ if (document.querySelector("#claim-progress[data-pending]")) { location.replace("/demo/claim"); return; }
submitted = false;
for (const [button, label] of working) {
button.disabled = false;
@@ -83,6 +86,25 @@
button.textContent = selected ? selected.dataset.button : button.dataset.neutral;
};
if (radios.length) { choice.addEventListener("change", update); update(); }
+ // The filter only hides rows: a checked radio stays checked out of view,
+ // and the search field has no name, so it is never posted.
+ const search = document.getElementById("claim-search");
+ if (search) {
+ const rows = [...choice.querySelectorAll("#claim-accounts .claim-card")];
+ const empty = document.getElementById("claim-search-empty");
+ search.parentElement.hidden = false;
+ search.addEventListener("keydown", event => { if (event.key === "Enter") event.preventDefault(); });
+ search.addEventListener("input", () => {
+ const query = search.value.trim().toLocaleLowerCase();
+ let shown = 0;
+ for (const row of rows) {
+ const name = row.querySelector(".claim-row-name").textContent.toLocaleLowerCase();
+ row.hidden = query !== "" && !name.includes(query);
+ if (!row.hidden) shown++;
+ }
+ empty.hidden = shown > 0;
+ });
+ }
}
const clock = claim.querySelector("time[datetime]");
if (clock) {
@@ -130,8 +152,98 @@
let stage = Number(progress.dataset.stage), since = performance.now(), failures = 0;
const setStatus = text => { if (status.textContent !== text) status.textContent = text; };
const hold = async () => { await wait(Math.max(0, minimum - (performance.now() - since))); };
+
+ // Reassurance while the server works. The bar is honest: each stage owns
+ // a band ending at the next stage's mark, and within it the bar eases
+ // toward that mark over the stage's usual time without reaching it. It
+ // never moves back. The server's stage is the only thing that crosses a mark.
+ const opened = performance.now();
+ const fill = progress.querySelector(".claim-bar i");
+ const elapsed = document.getElementById("claim-elapsed");
+ const stuck = document.getElementById("claim-stuck");
+ const calm = matchMedia("(prefers-reduced-motion: reduce)");
+ const marks = [0, 0.1, 0.55, 1];
+ const pace = [5000, 15000, 30000];
+ let entered = opened, shown = marks[Math.min(stage, 3)], rotation = 0, claimingPolls = 0, timers = [];
+ // Stuck: the server undoes an unfinished claim at its deadline (5 minutes
+ // after the account was chosen) and then reports "stopping". A claim
+ // that, on two polls, still reports progress 90 s after that deadline is
+ // stuck. With no deadline to read, 6.5 minutes without a stage change is
+ // (the 5-minute deadline plus the same 90 s).
+ const deadline = progress.dataset.deadlineIn === undefined ? NaN : opened + Number(progress.dataset.deadlineIn) * 1000;
+ // Committed: past the irreversible commit nothing is undone and the
+ // deadline no longer applies; the server finishes on its own retries,
+ // which back off up to minutes apart. Two minutes after the commit the
+ // page says so (the app is theirs, still finishing), never "undone".
+ const finishing = document.getElementById("claim-finishing");
+ const committedFor = progress.dataset.committedFor;
+ let committedAt = committedFor === undefined ? NaN : opened - Number(committedFor) * 1000;
+ const committed = () => Number.isFinite(committedAt);
+ const isStuck = () => {
+ if (committed()) return false;
+ return Number.isFinite(deadline)
+ ? claimingPolls >= 2 && performance.now() > deadline + 90000
+ : performance.now() - entered > 390000;
+ };
+ const isSlowFinish = () => committed() && claimingPolls >= 2 && performance.now() - committedAt > 120000;
+ const draw = () => {
+ if (fill) {
+ let value = 1;
+ if (committed() && stage === 2) {
+ // Verified and committed: only the last steps remain.
+ value = 0.9 + 0.1 * 0.97 * (1 - Math.exp(-(performance.now() - Math.max(committedAt, entered)) / 10000));
+ } else if (stage < 3) {
+ const from = marks[stage], to = marks[stage + 1];
+ value = from + (to - from) * 0.97 * (1 - Math.exp(-(performance.now() - entered) / pace[stage]));
+ }
+ shown = Math.max(shown, value);
+ fill.style.transform = `scaleX(${Math.max(shown, 0.03)})`;
+ fill.parentElement.setAttribute("aria-valuenow", String(Math.round(shown * 100)));
+ }
+ const seconds = Math.floor((performance.now() - opened) / 1000);
+ if (elapsed && seconds >= 30) {
+ elapsed.textContent = elapsed.dataset.template.replace("{elapsed}", seconds >= 60 ? `${Math.floor(seconds / 60)} min ${seconds % 60} s` : `${seconds} s`);
+ elapsed.hidden = false;
+ }
+ };
+ const restoreDetails = () => {
+ rotation = 0;
+ for (const detail of progress.querySelectorAll(".claim-step-detail[data-original]")) {
+ detail.textContent = detail.dataset.original;
+ detail.classList.remove("is-swapping");
+ }
+ };
+ const rotate = () => {
+ const step = progress.querySelector('[aria-current="step"][data-hints]');
+ const detail = step?.querySelector(".claim-step-detail");
+ // Once stuck, the page stops saying it is still working; once
+ // committed, the starting hints (placing, checking) are already done.
+ if (!detail || progress.dataset.stuck !== undefined || committed()) return;
+ if (detail.dataset.original === undefined) detail.dataset.original = detail.textContent;
+ const lines = [detail.dataset.original, ...step.dataset.hints.split("\n").filter(Boolean)];
+ rotation = (rotation + 1) % lines.length;
+ const swap = () => { detail.textContent = lines[rotation]; detail.classList.remove("is-swapping"); };
+ if (calm.matches) swap();
+ else { detail.classList.add("is-swapping"); setTimeout(swap, 200); }
+ };
+ // Stop the reassurance when the claim ends either way.
+ const settle = () => {
+ for (const timer of timers) clearInterval(timer);
+ timers = [];
+ restoreDetails();
+ stuck.hidden = true;
+ finishing.hidden = true;
+ delete progress.dataset.stuck;
+ };
+ draw();
+ timers.push(setInterval(draw, 500), setInterval(rotate, 4500));
+
const setStage = async n => {
stage = n;
+ entered = performance.now();
+ shown = Math.max(shown, marks[Math.min(n, 3)]);
+ restoreDetails();
+ draw();
progress.dataset.stage = String(n);
for (const step of progress.querySelectorAll("[data-step]")) {
const k = Number(step.dataset.step);
@@ -164,10 +276,14 @@
const url = new URL(result.url);
if (url.protocol !== "https:" || url.username || url.password) throw new Error();
const finished = document.getElementById("claim-finished");
- for (const link of claim.querySelectorAll("a.claim-new, .claim-open")) link.href = url.href;
+ // The fresh page carries the console link, which only it can name.
+ const actions = page.querySelector(".claim-result");
+ if (actions) claim.querySelector(".claim-result")?.replaceWith(document.importNode(actions, true));
+ for (const link of claim.querySelectorAll(".claim-open")) link.href = url.href;
+ for (const text of claim.querySelectorAll(".claim-open-address")) text.textContent = url.origin;
const address = claim.querySelector(".claim-address .claim-new");
if (address) address.textContent = url.host;
- claim.querySelector(".claim-result-address").textContent = url.href;
+ settle();
heading.textContent = claim.dataset.completeHeading;
claim.dataset.state = "claimed";
claim.querySelector(".claim-ticket")?.classList.add("is-settled");
@@ -176,7 +292,7 @@
progress.hidden = true;
setTimeout(() => claim.classList.remove("is-celebrating"), 1500);
};
- reload.hidden = true;
+ if (reload) reload.hidden = true;
const poll = async () => {
try {
const response = await fetch("/demo/claim/status", {
@@ -187,9 +303,13 @@
const result = await response.json();
if (!((result.state === "claiming" && [0, 1, 2].includes(result.step)) ||
(["stopping", "aborted"].includes(result.state) && result.step === 0) ||
- (result.state === "claimed" && result.step === 3))) throw new Error();
+ (result.state === "claimed" && result.step === 3)) ||
+ (result.committed !== undefined && typeof result.committed !== "boolean")) throw new Error();
if (result.state === "stopping" || result.state === "aborted") {
await hold();
+ settle();
+ progress.querySelector(".claim-bar")?.remove();
+ elapsed?.remove();
const failed = progress.querySelector('[aria-current="step"]');
if (failed) { failed.classList.add("is-failed"); failed.removeAttribute("aria-current"); }
progress.dataset.stage = "0";
@@ -200,20 +320,34 @@
} else {
await advance(result.step);
if (result.state === "claimed") { await hold(); await finish(result); return; }
+ claimingPolls++;
+ // The commit is the one-way boundary: from here the rollback
+ // promise is false, so its stuck box goes for good.
+ if (result.committed === true && !committed()) {
+ committedAt = performance.now();
+ stuck.hidden = true;
+ delete progress.dataset.stuck;
+ restoreDetails();
+ }
+ if (isStuck() && stuck.hidden) { stuck.hidden = false; progress.dataset.stuck = ""; restoreDetails(); }
+ if (isSlowFinish()) finishing.hidden = false;
}
failures = 0;
} catch (_) {
if (++failures >= 3) {
+ settle();
status.classList.remove("claim-sr-only");
setStatus(progress.dataset.pollFailed);
reload.hidden = false;
return;
}
}
- setTimeout(poll, 3000);
+ // Once stuck, keep checking, more slowly: a late finish still lands.
+ setTimeout(poll, stuck.hidden && finishing.hidden ? 3000 : 10000);
};
- // The initial stage is already painted by the server.
- paint().then(() => { since = performance.now(); setTimeout(poll, minimum); });
+ // The initial stage is already painted by the server. A selection still
+ // to be posted has no operation to poll yet: the form below posts it.
+ if (progress.dataset.pending === undefined) paint().then(() => { since = performance.now(); setTimeout(poll, minimum); });
}
if (!token) {
if (claim.dataset.reveal === "true" && claim.dataset.state === "claimed") {
@@ -225,13 +359,13 @@
}
if (opening) opening.hidden = true;
if (missing) missing.hidden = false;
+ // A resumed selection: the server painted the progress view first, so
+ // post the chosen account straight away. It goes through the page's one
+ // submit guard like a manual choice.
const selection = document.querySelector("form[data-auto-submit]");
if (selection) {
selection.removeAttribute("data-auto-submit");
- const status = document.getElementById("claim-resuming");
- try {
- if (selection.checkValidity()) { status.hidden = false; selection.requestSubmit(); }
- } catch (_) { status.hidden = true; }
+ selection.requestSubmit();
}
return;
}
diff --git a/internal/console/templates/demo_claim.html b/internal/console/templates/demo_claim.html
index 13788753c..040865493 100644
--- a/internal/console/templates/demo_claim.html
+++ b/internal/console/templates/demo_claim.html
@@ -11,14 +11,21 @@
#claim .claim-summary strong, #claim .claim-summary a { display: block; }
#claim .claim-summary p { margin: 0.5rem 0 0; }
#claim fieldset { border: 0; min-width: 0; margin: 1.5rem 0; }
-#claim legend { font-weight: 600; margin-bottom: 0.75rem; }
-#claim .claim-card { display: flex; align-items: flex-start; gap: 0.75rem; border: 1px solid var(--rule); border-radius: var(--rst-radius-sm); padding: 1rem; margin: 0 0 0.65rem; cursor: pointer; }
+#claim legend { margin-bottom: 0.6rem; font: 600 .78rem var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
+#claim .claim-card { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: .3rem .75rem; border: 1px solid var(--rule); border-radius: var(--rst-radius-sm); padding: .55rem .8rem; margin: 0 0 .4rem; cursor: pointer; }
#claim .claim-card:has(:checked) { background: var(--accent-soft); border-color: var(--accent); }
#claim .claim-card:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
#claim [tabindex="-1"]:focus { outline: none; }
#claim .claim-card:has(:disabled) { color: var(--muted); background: var(--rst-surface-2); cursor: not-allowed; }
-#claim .claim-card input { flex: none; width: 1.1rem; height: 1.1rem; margin-top: 0.25rem; accent-color: var(--accent); }
-#claim .claim-card strong, #claim .claim-card .claim-detail { display: block; }
+#claim .claim-card input { flex: none; width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--accent); }
+#claim .claim-row-name { font-weight: 600; overflow-wrap: anywhere; }
+#claim .claim-row-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .4rem .5rem; font-size: .8rem; color: var(--muted); }
+#claim .claim-row-meta .chip { margin: 0; }
+#claim .claim-row-note { grid-column: 2 / -1; font-size: .85rem; color: var(--muted); }
+@media (max-width: 30rem) { #claim .claim-row-meta { grid-column: 2 / -1; justify-content: flex-start; } }
+#claim .claim-search { margin: 0 0 .75rem; }
+#claim .claim-search input { display: block; width: 100%; min-height: 44px; }
+#claim .claim-search-empty { color: var(--muted); }
#claim .claim-detail { color: var(--muted); font-size: 0.9rem; }
#claim .claim-single { margin: 1.5rem 0; }
#claim .claim-single p { margin-bottom: 0.35rem; }
@@ -52,7 +59,7 @@
#claim .claim-tile svg { width: 26px; height: 26px; }
#claim .claim-ticket-body { min-width: 0; display: grid; gap: .2rem; }
#claim .claim-address { display: grid; font: .84rem/1.5 ui-monospace,monospace; }
-#claim .claim-address a { grid-area: 1/1; color: var(--muted); text-decoration: none; }
+#claim .claim-address > * { grid-area: 1/1; color: var(--muted); text-decoration: none; }
#claim .claim-life { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); }
#claim .claim-clock { width: 16px; height: 16px; fill: none; stroke: var(--accent); stroke-width: 1.8; }
#claim .claim-tick, #claim .claim-new { display: none; }
@@ -63,11 +70,19 @@
#claim #code { font-size: 1.6rem; letter-spacing: .3em; text-align: center; }
#claim .claim-keymail { margin: 1rem 0; padding: 1rem 0; border-block: 1px solid var(--rule); font-size: .9rem; }
#claim .claim-keymail p { color: var(--muted); margin: .4rem 0 0; }
-#claim .claim-single { display: block; }
-#claim .claim-slots { display: flex; gap: 3px; flex-wrap: wrap; margin: .5rem 0; }
-#claim .claim-slots i { width: 18px; height: 5px; border-radius: 3px; background: var(--rule); }
-#claim .claim-slots i.used { background: var(--accent); }
-#claim .claim-card:has(:disabled) .used { background: var(--claim-warn); }
+#claim .claim-single { grid-template-columns: minmax(0,1fr) auto; cursor: default; }
+#claim .claim-single p { margin: 0; }
+@media (max-width: 30rem) { #claim .claim-single .claim-row-meta { grid-column: 1 / -1; } }
+#claim .claim-bar { height: 6px; border-radius: 3px; background: var(--rule); overflow: hidden; margin: 0 0 .4rem; }
+#claim .claim-bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transform-origin: left; transform: scaleX(.03); transition: transform .5s linear; }
+#claim [data-stage="1"] .claim-bar i { transform: scaleX(.1); }
+#claim [data-stage="2"] .claim-bar i { transform: scaleX(.55); }
+#claim .claim-elapsed { font-size: .85rem; color: var(--muted); margin: 0 0 1rem; }
+#claim .claim-step-detail { transition: opacity .2s ease; }
+#claim .claim-step-detail.is-swapping { opacity: 0; }
+#claim .claim-stuck { border: 1px solid var(--rule); background: var(--accent-soft); border-radius: var(--rst-radius-sm); padding: 1rem; margin: 0 0 1.5rem; }
+#claim .claim-stuck p { margin: 0 0 .5rem; }
+#claim [data-stuck] [aria-current=step] .claim-node::before, #claim [data-stuck] [aria-current=step] .claim-node::after, #claim [data-stuck] .claim-track, #claim [data-stuck] .claim-track i, #claim [data-stuck] .claim-home { animation: none; }
#claim button[type=submit] { min-height: 50px; border-radius: 10px; }
#claim button.is-working { color: var(--rst-on-accent-fill); opacity: 1; }
#claim button.btn-secondary.is-working { color: var(--accent); }
@@ -86,7 +101,8 @@
#claim [data-stage="2"] .claim-home { animation: claim-breathe 1.6s ease-in-out infinite; }
#claim .claim-steps { list-style: none; padding: 0; }
#claim .claim-steps li { position: relative; min-height: 3rem; padding: 0 0 1.5rem 2.5rem; }
-#claim .claim-step-detail { display: block; font-weight: 400; font-size: .95rem; margin-top: .25rem; }
+#claim .claim-steps strong { font-size: 1.0625rem; }
+#claim .claim-step-detail { display: block; font-weight: 400; font-size: .85rem; margin-top: .25rem; }
#claim .claim-node { position: absolute; left: 0; top: 0; box-sizing: border-box; width: 26px; height: 26px; border: 2px solid var(--muted); border-radius: 50%; }
#claim .claim-node::before { content: ""; position: absolute; inset: -2px; box-sizing: border-box; width: 26px; height: 26px; border: 2px solid transparent; border-radius: 50%; transform-origin: center; }
#claim .claim-node::after { content: ""; position: absolute; inset: 0; margin: auto; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; opacity: 0; }
@@ -98,11 +114,14 @@
#claim .claim-steps .is-done svg { opacity: 1; }
#claim .claim-steps .is-failed { color: var(--claim-warn); }
#claim .claim-steps .is-failed .claim-node { border-color: var(--claim-warn); }
-#claim .claim-result .claim-open { display: block; width: 100%; text-align: center; font-size: 2rem; font-weight: 700; padding: 1.25rem; border-radius: 12px; }
-#claim .claim-result-address { text-align: center; font: .85rem/1.5 ui-monospace,monospace; color: var(--muted); }
+#claim .claim-result { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; }
+#claim .claim-result .btn { border-radius: 10px; }
+#claim .claim-result .claim-open { display: inline-block; max-width: 100%; padding-block: .6rem; font: .9rem/1.4 ui-monospace,monospace; overflow-wrap: anywhere; }
+#claim .claim-result .claim-open .icon { width: 1em; height: 1em; margin-left: .35em; vertical-align: -.125em; }
#claim .claim-next { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
-#claim .claim-next h2 { font-size: 1.15rem; }
-#claim .claim-next h3 { font-size: 1rem; margin-bottom: .3rem; }
+#claim .claim-next h2 { font-size: 1.4rem; }
+#claim .claim-next h3 { font-size: 1.0625rem; margin-bottom: .3rem; }
+#claim .claim-next p { font-size: .925rem; }
#claim .claim-next p { color: var(--muted); }
#claim .claim-paste { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: .75rem; border: 1px solid var(--rule); padding: .6rem; border-radius: 10px; background: var(--rst-surface-2); }
#claim .claim-paste code { background: transparent; padding: 0; white-space: normal; overflow-wrap: anywhere; font-size: .84rem; }
@@ -153,11 +172,11 @@
{{if .DemoName}}<div class="claim-ticket{{if eq .State "claimed"}} is-settled{{end}}">
<span class="claim-tile" aria-hidden="true">{{icon "layers"}}</span>
<div class="claim-ticket-body"><strong>{{.DemoName}}</strong>
-<span class="claim-address"><a class="claim-old" href="https://{{.DemoHost}}" rel="noreferrer">{{.DemoHost}}</a><a class="claim-new" href="{{.URL}}" rel="noreferrer">{{.URL}}</a></span>
+<span class="claim-address"><a class="claim-old" href="https://{{.DemoHost}}" rel="noreferrer">{{.DemoHost}}</a><span class="claim-new">{{.URL}}</span></span>
<span class="claim-life"><svg class="claim-clock" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6"/><path class="claim-hands" d="M8 4v4l3 2"/><path class="claim-tick" d="M4 8l3 3 5-6"/></svg><time class="claim-old" datetime="{{.EndTime}}" title="{{.EndTime}}"><span aria-hidden="true">{{.TimeLeft}}</span><span class="claim-sr-only">{{.TimeLeftAccessible}}</span></time><span class="claim-new">{{.Copy.done}}</span></span></div>
<span class="claim-burst" aria-hidden="true"><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i></span>
</div>{{end}}
-<h1 id="claim-heading" tabindex="-1">{{if eq .State "claimed"}}{{.Copy.completeHeading}}{{else if or (eq .State "stopping") (eq .State "aborted")}}{{.Copy.failureHeading}}{{else if .EmailPending}}{{.Copy.codeHeading}}{{else if and .Address (gt .Eligible 1)}}{{.Copy.accountsHeading}}{{else if eq .State "proof"}}{{.Copy.heading}}{{else}}{{.Copy.title}}{{end}}</h1>
+<h1 id="claim-heading" tabindex="-1">{{if eq .State "claimed"}}{{.Copy.completeHeading}}{{else if or (eq .State "stopping") (eq .State "aborted")}}{{.Copy.failureHeading}}{{else if .AutoSubmit}}{{.Copy.title}}{{else if .EmailPending}}{{.Copy.codeHeading}}{{else if and .Address (gt .Eligible 1)}}{{.Copy.accountsHeading}}{{else if eq .State "proof"}}{{.Copy.heading}}{{else}}{{.Copy.title}}{{end}}</h1>
{{if .Error}}<p role="alert">{{.Error}}</p><p><a href="/demo/claim">{{.Copy.back}}</a></p>{{end}}
{{if eq .State "no_accounts"}}<p>{{.Copy.identity}} <strong>{{.Address}}</strong></p><p>{{.Copy.noAccounts}}</p>
<fieldset class="claim-unavailable"><legend>{{.Copy.accountsLabel}}</legend>{{range .Accounts}}{{template "claim_card" .}}{{end}}</fieldset>{{end}}
@@ -168,23 +187,12 @@
<div id="claim-expired-next" hidden><p>{{.Copy.newDemo}}</p><div class="claim-paste"><code id="claim-new-demo">{{.Copy.newDemoLine}}</code><button class="btn-sm btn-secondary" type="button" data-copy-target="claim-new-demo" data-copy="{{.Copy.copy}}" data-copied="{{.Copy.copied}}" hidden>{{.Copy.copy}}</button></div></div>
<p id="claim-kept-next" hidden><a href="/?next=%2Fdemo%2Fclaim">{{.Copy.consoleSignin}}</a></p>
{{if eq .State "disabled"}}<p>{{.Copy.disabled}}</p>{{end}}
-{{if or (eq .State "claiming") (eq .State "stopping")}}
-<div id="claim-progress" data-stage="{{.Step}}" data-failure-heading="{{.Copy.failureHeading}}" data-neutral="{{.Copy.resuming}}" data-stopping="{{.Copy.stopping}}" data-copying="{{.Copy.copying}}" data-starting="{{.Copy.starting}}" data-done="{{.Copy.done}}" data-aborted="{{.Copy.aborted}}" data-poll-failed="{{.Copy.pollFailed}}">
-<p id="claim-status"{{if gt .Step 0}} class="claim-sr-only"{{end}} role="status" aria-live="polite">{{if eq .State "stopping"}}{{.Copy.stopping}}{{else if eq .Step 2}}{{.Copy.starting}}{{else if eq .Step 1}}{{.Copy.copying}}{{else}}<span class="claim-spinner" aria-hidden="true"></span>{{.Copy.resuming}}{{end}}</p>
-<div class="claim-transit" aria-hidden="true"><span>{{icon "layers"}}</span><span class="claim-track"><i></i><i></i><i></i></span><span class="claim-home">{{icon "server"}}</span></div>
-<ol class="claim-steps">
-<li data-step="1"{{if gt .Step 1}} class="is-done"{{end}}{{if eq .Step 1}} aria-current="step"{{end}}><span class="claim-node" aria-hidden="true"><svg viewBox="0 0 16 16"><path d="M3 8l3 3 7-7"/></svg></span><strong>{{.Copy.copying}}</strong><span class="claim-step-detail">{{.Copy.copyingDetail}}</span></li>
-<li data-step="2"{{if gt .Step 2}} class="is-done"{{end}}{{if eq .Step 2}} aria-current="step"{{end}}><span class="claim-node" aria-hidden="true"><svg viewBox="0 0 16 16"><path d="M3 8l3 3 7-7"/></svg></span><strong>{{.Copy.starting}}</strong><span class="claim-step-detail">{{.Copy.startingDetail}}</span></li>
-<li data-step="3"{{if eq .Step 3}} aria-current="step"{{end}}><span class="claim-node" aria-hidden="true"><svg viewBox="0 0 16 16"><path d="M3 8l3 3 7-7"/></svg></span><strong>{{.Copy.done}}</strong></li>
-</ol>
-
-<a id="claim-reload" href="/demo/claim">{{.Copy.reload}}</a>
-</div>{{end}}
+{{if or (eq .State "claiming") (eq .State "stopping")}}{{template "claim_progress" .}}{{end}}
{{if eq .State "aborted"}}<p>{{.Copy.aborted}}</p>{{end}}
{{if or (eq .State "claimed") (eq .State "claiming") (eq .State "stopping")}}
<div id="claim-finished"{{if ne .State "claimed"}} hidden{{end}}>
<p>{{.Copy.completeDetail}}</p>
-<p class="claim-result"><a class="btn claim-open" href="{{.URL}}" rel="noreferrer">{{.Copy.open}}</a></p><p class="claim-result-address">{{.URL}}</p>
+<p class="claim-result">{{with .ConsoleURL}}<a class="btn claim-console" href="{{.}}">{{$.Copy.openConsole}}</a>{{end}}<a class="claim-open" href="{{.URL}}" target="_blank" rel="noopener noreferrer"><span class="claim-open-address">{{.URL}}</span>{{icon "external-link"}}<span class="claim-sr-only"> {{.Copy.opensNewTab}}</span></a></p>
{{if .AccountSqid}}<section class="claim-next"><h2>{{.Copy.keepGoing}}</h2>
{{if .AccountSqid}}<h3>{{.Copy.sameChat}}</h3><p>{{.Copy.sameChatLine}}</p>
{{if .SourceSteps}}<h3>{{.Copy.agentHeading}}</h3><p>{{.Copy.agentDetail}}</p>
@@ -197,23 +205,31 @@
{{end}}
{{if and .HasIntent .CanClaim}}
{{if .Address}}
+{{if .AutoSubmit}}{{template "claim_progress" .}}
+<form method="post" action="/demo/claim/select" data-auto-submit>
+<input type="hidden" name="nonce" value="{{.Nonce}}"><input type="hidden" name="csrf" value="{{.CSRF}}">
+{{if .SelectedAccount}}<input type="hidden" name="accountId" value="{{.SelectedAccount}}">{{else}}<input type="hidden" name="create" value="1">{{end}}
+<noscript><button type="submit">{{.Copy.confirm}}</button></noscript>
+</form>
+{{else}}
<p>{{.Copy.identity}} <strong>{{.Address}}</strong></p>
-<form method="post" action="/demo/claim/select"{{if .AutoSubmit}} data-auto-submit{{end}}>
+<form method="post" action="/demo/claim/select">
<input type="hidden" name="nonce" value="{{.Nonce}}"><input type="hidden" name="csrf" value="{{.CSRF}}">
{{if .Single}}
-<fieldset><legend>{{.Copy.accountsLabel}}</legend><div class="claim-single claim-card"><p><strong>{{.Copy.destination}}</strong></p>{{with .Single.Plan}}<p class="claim-detail">{{.}}</p>{{end}}{{template "claim_slots" .Single}}{{with .Single.Room}}<p class="claim-detail">{{.}}</p>{{end}}</div>
+<fieldset><legend>{{.Copy.accountsLabel}}</legend><div class="claim-single claim-card"><p><strong>{{.Copy.destination}}</strong></p>{{template "claim_meta" .Single}}</div>
<input type="hidden" name="accountId" value="{{.Single.Sqid}}">
{{range .Accounts}}{{if .Reason}}{{template "claim_card" .}}{{end}}{{end}}</fieldset>
{{else if .Accounts}}
-<p>{{.Copy.accountsIntro}}</p><fieldset><legend>{{.Copy.accountsLabel}}</legend>
+<p>{{.Copy.accountsIntro}}</p>
+{{if .Searchable}}<p class="claim-search" hidden><input type="search" id="claim-search" aria-label="{{.Copy.searchLabel}}" placeholder="{{.Copy.searchLabel}}" aria-controls="claim-accounts" autocomplete="off" spellcheck="false"></p>{{end}}
+<fieldset id="claim-accounts"><legend>{{.Copy.accountsLabel}}</legend>
{{range .Accounts}}
-<label class="claim-card"><input type="radio" name="accountId" value="{{.Sqid}}"{{if eq .Sqid $.SelectedAccount}} checked{{end}}{{if .Reason}} disabled{{else}} required{{end}} data-button="{{.Button}}">
-<span><strong>{{.Name}}</strong>{{with .Plan}}<span class="claim-detail">{{.}}</span>{{end}}{{template "claim_slots" .}}{{with .Room}}<span class="claim-detail">{{.}}</span>{{end}}{{with .Reason}}<span class="claim-detail">{{.}}</span>{{end}}</span></label>
-{{end}}</fieldset>
+<label class="claim-card"><input type="radio" name="accountId" value="{{.Sqid}}"{{if .Reason}} disabled{{else}} required{{end}} data-button="{{.Button}}"><span class="claim-row-name">{{.Name}}</span>{{template "claim_meta" .}}{{with .Note}}<span class="claim-row-note">{{.}}</span>{{end}}</label>
+{{end}}{{if .Searchable}}<p id="claim-search-empty" class="claim-search-empty" aria-live="polite" hidden>{{.Copy.searchEmpty}}</p>{{end}}</fieldset>
{{else}}<p>{{.Copy.new}}</p><input type="hidden" name="create" value="1">{{end}}
-<p id="claim-resuming" role="status" hidden>{{.Copy.resuming}}</p>
<button type="submit" data-working="{{.Copy.selectWorking}}" data-neutral="{{.Copy.choose}}">{{.Copy.confirm}}</button>
</form>
+{{end}}
{{else}}
{{if .EmailPending}}
<p class="claim-intro">{{.Copy.codeIntro}}</p>
@@ -243,8 +259,24 @@
</html>
{{define "claim_card"}}
-<label class="claim-card"><input type="radio" name="accountId" value="{{.Sqid}}" disabled>
-<span><strong>{{.Name}}</strong>{{with .Plan}}<span class="claim-detail">{{.}}</span>{{end}}{{template "claim_slots" .}}{{with .Room}}<span class="claim-detail">{{.}}</span>{{end}}<span class="claim-detail">{{.Reason}}</span></span></label>
+<label class="claim-card"><input type="radio" name="accountId" value="{{.Sqid}}" disabled><span class="claim-row-name">{{.Name}}</span>{{template "claim_meta" .}}{{with .Note}}<span class="claim-row-note">{{.}}</span>{{end}}</label>
{{end}}
-{{define "claim_slots"}}{{if gt .Limit 0}}{{if .Slots}}<span class="claim-slots" aria-hidden="true">{{range .Slots}}<i{{if .}} class="used"{{end}}></i>{{end}}</span>{{else}}<meter min="0" max="{{.Limit}}" value="{{.Used}}" aria-label="{{.Room}}">{{.Used}} / {{.Limit}}</meter>{{end}}<span class="claim-detail">{{.Used}} / {{.Limit}}</span>{{end}}{{end}}
+{{define "claim_meta"}}<span class="claim-row-meta">{{with .Plan}}<span class="chip chip-env">{{.}}</span>{{end}}{{with .Usage}}<span class="claim-usage">{{.}}</span>{{end}}{{with .Status}}<span class="chip {{$.StatusClass}}">{{.}}</span>{{end}}</span>{{end}}
+
+{{define "claim_progress"}}
+<div id="claim-progress" data-stage="{{.Step}}"{{if .AutoSubmit}} data-pending{{end}}{{with .CommittedFor}} data-committed-for="{{.}}"{{end}}{{with .DeadlineIn}} data-deadline-in="{{.}}"{{end}} data-failure-heading="{{.Copy.failureHeading}}" data-neutral="{{.Copy.resuming}}" data-stopping="{{.Copy.stopping}}" data-copying="{{.Copy.copying}}" data-starting="{{.Copy.starting}}" data-done="{{.Copy.done}}" data-aborted="{{.Copy.aborted}}" data-poll-failed="{{.Copy.pollFailed}}">
+<p id="claim-status"{{if gt .Step 0}} class="claim-sr-only"{{end}} role="status" aria-live="polite">{{if eq .State "stopping"}}{{.Copy.stopping}}{{else if eq .Step 2}}{{.Copy.starting}}{{else if eq .Step 1}}{{.Copy.copying}}{{else}}<span class="claim-spinner" aria-hidden="true"></span>{{.Copy.resuming}}{{end}}</p>
+<div id="claim-stuck" class="claim-stuck" role="alert" hidden><p><strong>{{.Copy.stuckHeading}}</strong></p><p class="claim-detail">{{.Copy.stuckDetail}}</p><a class="btn btn-sm" href="/demo/claim">{{.Copy.stuckAction}}</a></div>
+<div id="claim-finishing" class="claim-stuck" role="status" hidden><p><strong>{{.Copy.finishingHeading}}</strong></p><p class="claim-detail">{{.Copy.finishingDetail}}</p></div>
+<div class="claim-transit" aria-hidden="true"><span>{{icon "layers"}}</span><span class="claim-track"><i></i><i></i><i></i></span><span class="claim-home">{{icon "server"}}</span></div>
+{{if ne .State "stopping"}}<div class="claim-bar" role="progressbar" aria-label="{{.Copy.progressLabel}}" aria-valuemin="0" aria-valuemax="100"><i></i></div>
+<p id="claim-elapsed" class="claim-elapsed" data-template="{{.Copy.elapsed}}" hidden></p>{{end}}
+<ol class="claim-steps">
+<li data-step="1" data-hints="{{.Copy.hintsCopying}}"{{if gt .Step 1}} class="is-done"{{end}}{{if eq .Step 1}} aria-current="step"{{end}}><span class="claim-node" aria-hidden="true"><svg viewBox="0 0 16 16"><path d="M3 8l3 3 7-7"/></svg></span><strong>{{.Copy.copying}}</strong><span class="claim-step-detail">{{.Copy.copyingDetail}}</span></li>
+<li data-step="2" data-hints="{{.Copy.hintsStarting}}"{{if gt .Step 2}} class="is-done"{{end}}{{if eq .Step 2}} aria-current="step"{{end}}><span class="claim-node" aria-hidden="true"><svg viewBox="0 0 16 16"><path d="M3 8l3 3 7-7"/></svg></span><strong>{{.Copy.starting}}</strong><span class="claim-step-detail">{{.Copy.startingDetail}}</span></li>
+<li data-step="3"{{if eq .Step 3}} aria-current="step"{{end}}><span class="claim-node" aria-hidden="true"><svg viewBox="0 0 16 16"><path d="M3 8l3 3 7-7"/></svg></span><strong>{{.Copy.done}}</strong></li>
+</ol>
+{{if not .AutoSubmit}}
+<a id="claim-reload" href="/demo/claim">{{.Copy.reload}}</a>{{end}}
+</div>{{end}}
diff --git a/internal/console/testdata/demo_claim_resume_browser.mjs b/internal/console/testdata/demo_claim_resume_browser.mjs
index 0de1d29b7..5b54820ea 100644
--- a/internal/console/testdata/demo_claim_resume_browser.mjs
+++ b/internal/console/testdata/demo_claim_resume_browser.mjs
@@ -51,11 +51,11 @@ async function key(key, code, number) {
await call('Input.dispatchKeyEvent', {type:'keyUp', key, code, windowsVirtualKeyCode:number});
}
async function capture(state) {
- await captureClaim(call, evaluate, screenshots, state);
+ await captureClaim(call, evaluate, screenshots, state, [360, 1280]);
await captureClaim(call, evaluate, '', state, [1100]);
assert.equal(security.length, 0, JSON.stringify(security));
}
-const timer = setTimeout(() => { chrome.kill('SIGKILL'); process.exitCode = 1; }, 115000);
+const timer = setTimeout(() => { chrome.kill('SIGKILL'); process.exitCode = 1; }, 175000);
try {
const created = await call('Target.createTarget', {url:'about:blank'}, false);
session = (await call('Target.attachToTarget', {targetId:created.targetId, flatten:true}, false)).sessionId;
@@ -74,10 +74,12 @@ try {
window.addEventListener('submit', event => {
const form = event.target;
if (form.getAttribute('action') !== '/demo/claim/select') return;
+ // A manual choice submits from the visible list with its button
+ // disabled; a resumed one from the progress view, with no list at all.
claimSubmitted(JSON.stringify({
- disabled:form.querySelector('button[type=submit]').disabled,
- visible:form.getBoundingClientRect().height > 0,
- auto:!document.getElementById('claim-resuming').hidden,
+ disabled:form.querySelector('button[type=submit]')?.disabled ?? null,
+ list:!!document.querySelector('#claim input[type=radio]'),
+ auto:!!document.querySelector('#claim-progress[data-pending]'),
account:new FormData(form).get('accountId')
}));
});
@@ -96,7 +98,7 @@ try {
await capture('one');
await call('Page.navigate',{url:single.target+'/demo/claim?long=1'});
await until('document.readyState === "complete" && document.querySelectorAll(".claim-card").length === 2');
- assert.equal(await evaluate('document.querySelector(".claim-card strong").textContent.length > 100'), true);
+ assert.equal(await evaluate('document.querySelector(".claim-card .claim-row-name").textContent.length > 100'), true);
assert.equal(await evaluate('document.querySelector(".claim-address .claim-old").textContent.length > 100'), true);
await evaluate('document.querySelector(".claim-card input").click()');
await capture('long-name');
@@ -108,9 +110,46 @@ try {
await until('document.readyState === "complete" && document.querySelectorAll(".claim-card").length === 2');
const capacityCards = await evaluate('Array.from(document.querySelectorAll(".claim-card"), card => ({text:card.innerText,disabled:card.querySelector("input").disabled}))');
assert(capacityCards.every(card=>card.disabled));
- assert(capacityCards.some(card=>card.text.includes('Full: 3 of 3 apps and instances in use')));
- assert(capacityCards.some(card=>card.text.includes('Not enough room: 2 of 3 apps and instances in use. This demo needs room for one app and its instance.')));
+ assert(capacityCards.some(card=>card.text.includes('Full') && card.text.includes('3 of 3 running')));
+ assert(capacityCards.some(card=>card.text.includes('No room') && card.text.includes('2 of 3 running') && card.text.includes('Needs room for an app and its instance.')));
await capture('capacity');
+ // The thirty-account picker: one line per account, no sentinel, no meter,
+ // the accounts that can take it first, and a search box that filters.
+ await call('Network.setCookies', {cookies:[
+ {name:'carlos_console_session',value:single.pickerSession,url:single.pickerTarget,path:'/',httpOnly:true,sameSite:'Lax'},
+ {name:'carlos_demo_claim_flow',value:single.pickerCookie,url:single.pickerTarget,path:'/demo/claim',httpOnly:true,secure:true,sameSite:'Lax'}
+ ]});
+ await call('Page.navigate',{url:single.pickerTarget+'/demo/claim'});
+ await until('document.readyState === "complete" && document.querySelectorAll(".claim-card").length === 30');
+ assert.equal(await evaluate('document.body.innerText.includes("2305843009213693951") || !!document.querySelector("meter")'), false, 'sentinel or meter shown');
+ assert.equal(await evaluate('document.querySelector(".claim-search").hidden'), false, 'script did not reveal the search box');
+ assert.deepEqual(await evaluate('(() => { const d = Array.from(document.querySelectorAll(".claim-card input"), i => i.disabled); return d.indexOf(true) === -1 || d.slice(d.indexOf(true)).every(Boolean); })()'), true, 'eligible rows must come first');
+ assert.equal(await evaluate('Array.from(document.querySelectorAll(".claim-card")).some(c => c.innerText.includes("17 running") && c.innerText.includes("Has room"))'), true, 'sponsored row');
+ assert.equal(await evaluate('Array.from(document.querySelectorAll(".claim-card")).some(c => c.innerText.includes("View only") && c.innerText.includes("Ask an owner"))'), true, 'viewer row');
+ // A row is one line at desktop width: its height is a single line plus padding.
+ await call('Emulation.setDeviceMetricsOverride', {width:1280, height:900, deviceScaleFactor:1, mobile:false});
+ assert.equal(await evaluate('Array.from(document.querySelectorAll(".claim-card:has(input:not(:disabled))")).every(c => c.getBoundingClientRect().height < 56)'), true, 'eligible rows wrap at desktop width');
+ await captureClaim(call, evaluate, screenshots, 'picker-30', [360, 1280]);
+ await evaluate('document.querySelector(".claim-card input:not(:disabled)").click()');
+ const pickedLabel = await evaluate('document.querySelector("#claim button[type=submit]").textContent');
+ await evaluate('document.getElementById("claim-search").focus()');
+ for (const ch of 'TEAM-2') await call('Input.insertText', {text:ch});
+ await until('Array.from(document.querySelectorAll(".claim-card")).filter(c => !c.hidden).length === 10');
+ assert.equal(await evaluate('Array.from(document.querySelectorAll(".claim-card")).filter(c => !c.hidden).every(c => c.querySelector(".claim-row-name").textContent.startsWith("team-2"))'), true);
+ assert.equal(await evaluate('document.querySelector(".claim-card input:checked")?.closest("label").hidden'), true, 'test needs the chosen row filtered out');
+ assert.equal(await evaluate('document.querySelector("#claim button[type=submit]").textContent'), pickedLabel, 'filtering changed the choice');
+ const submissionsBefore = submissions.length;
+ await key('Enter', 'Enter', 13);
+ await new Promise(r => setTimeout(r, 300));
+ assert.equal(submissions.length, submissionsBefore, 'Enter in the search box submitted the form');
+ assert.equal(await evaluate('location.pathname + location.search'), '/demo/claim');
+ await captureClaim(call, evaluate, screenshots, 'picker-search', [360, 1280]);
+ for (const ch of 'zz') await call('Input.insertText', {text:ch});
+ await until('document.getElementById("claim-search-empty").hidden === false');
+ assert.equal(await evaluate('document.querySelectorAll(".claim-card:not([hidden])").length'), 0);
+ assert.equal(await evaluate('!!document.querySelector(".claim-card input:checked")'), true, 'a filtered-out choice was cleared');
+ await captureClaim(call, evaluate, screenshots, 'picker-empty', [360]);
+ process.stdout.write('picker: thirty rows, eligible first, search filters, Enter stays put\n');
await call('Network.setCookies', {cookies:[
{name:'carlos_console_session',value:sessionToken,url:target,path:'/',httpOnly:true,sameSite:'Lax'},
{name:'carlos_demo_claim_flow',value:flowCookie,url:target,path:'/demo/claim',httpOnly:true,secure:true,sameSite:'Lax'}
@@ -147,8 +186,10 @@ try {
await evaluate(`document.querySelector('input[value='+${JSON.stringify(account)}+']').click()`);
assert.equal(await evaluate('document.querySelectorAll("script").length'),1);
assert.equal(await evaluate('document.querySelector("#claim button[type=submit]").textContent'), 'Keep in Personal projects');
- assert.equal(await evaluate('Array.from(document.querySelectorAll(".claim-card:has(input:not(:disabled))")).every(card => card.innerText.includes("Has room") && !card.innerText.includes("apps and instances"))'),true);
- assert.deepEqual(await evaluate('Array.from(document.querySelectorAll(".claim-card:has(input:disabled) .claim-detail")).map(el => el.textContent)'),['Free plan', 'You can view this account but not add apps. Ask one of its owners.']);
+ assert.equal(await evaluate('Array.from(document.querySelectorAll(".claim-card:has(input:not(:disabled))")).every(card => card.innerText.includes("Has room") && card.innerText.includes(" running"))'),true);
+ assert.deepEqual(await evaluate('Array.from(document.querySelectorAll(".claim-card:has(input:disabled) .chip, .claim-card:has(input:disabled) .claim-row-note")).map(el => el.textContent)'),['View only', 'Ask an owner to add apps.']);
+ assert.equal(await evaluate('document.querySelector(".claim-card:last-of-type input").disabled'),true,'the view-only account must sort last');
+ assert.equal(await evaluate('!!document.querySelector(".claim-search")'),false,'three accounts need no search box');
await capture('many');
await evaluate(`const form = document.querySelector('form[action="/demo/claim/select"]'); form.addEventListener('submit', event => event.preventDefault(), {once:true}); form.requestSubmit(); document.querySelector('#claim input[type=radio]:not(:disabled)').click()`);
assert.equal(await evaluate('document.querySelector("#claim button[type=submit]").disabled'),true,'radio change re-enabled submitted button');
@@ -162,9 +203,9 @@ try {
assert.equal(await evaluate('location.hash'),'');
assert.equal(security.length,0,JSON.stringify(security));
assert.deepEqual(submissions, [
- {disabled:true,visible:true,auto:false,account},
- {disabled:true,visible:true,auto:true,account}
- ],'manual and automatic submissions must disable the button, retain the form and preserve the selected account');
+ {disabled:true,list:true,auto:false,account},
+ {disabled:null,list:false,auto:true,account}
+ ],'a manual choice disables its button; a resumed one posts the same account from the progress view, with no list painted');
process.stdout.write('after: keyboard choice, redirect, callback, JS auto-submit; no CSP violations\n');
await until('document.querySelector("li[aria-current=step]")?.dataset.step === "2"');
assert.equal(await evaluate('document.getElementById("claim-status").textContent'),'Starting your app');
@@ -180,7 +221,11 @@ try {
assert.equal(await evaluate('window.liveWrites'),0,'unchanged poll rewrote live region');
await until('document.getElementById("claim").dataset.state === "claimed"');
await capture('done');
- assert.equal(await evaluate('document.querySelector(".claim-result a").textContent'),'Open your app');
+ assert.equal(await evaluate('document.querySelector(".claim-result .claim-console").textContent'),'Open in the console');
+ assert.equal(await evaluate('document.querySelector(".claim-result .claim-console").pathname.startsWith('+JSON.stringify('/a/'+account+'/apps/')+')'),true,'console link must name the claimed account');
+ assert.equal(await evaluate('document.querySelector(".claim-result .claim-open").target'),'_blank');
+ assert.equal(await evaluate('new URL(document.querySelector(".claim-result .claim-open").href).origin === document.querySelector(".claim-result .claim-open-address").textContent'),true);
+ assert.equal(await evaluate('document.querySelector(".claim-result .claim-open svg").getAttribute("aria-hidden")'),'true');
assert.equal(await evaluate('document.querySelector("#claim h1").textContent.endsWith(" is yours")'),true);
assert.equal(await evaluate('document.querySelector(".claim-command").open'),false);
await evaluate('document.querySelector(".claim-command").open = true');
@@ -250,6 +295,55 @@ try {
assert.equal(await evaluate('document.getElementById("claim-status").textContent'),'Keeping your demo in the account you chose…');
assert.equal(await evaluate('document.querySelectorAll("[aria-current=step]").length'),0);
process.stdout.write('fallback: stopped after three failures, retained no-script reload, stopped on abort; no CSP violations\n');
+ // A long "Starting your app": the bar sits inside the step's band and
+ // never goes back, and the step's detail rotates through reassurance.
+ await call('Page.navigate',{url:target+'/demo/claim?testProgress=starting'});
+ await until('document.querySelector("li[aria-current=step]")?.dataset.step === "2"');
+ const original = await evaluate('document.querySelector("li[aria-current=step] .claim-step-detail").textContent');
+ const bar = 'Number(document.querySelector(".claim-bar").getAttribute("aria-valuenow"))';
+ const first = await evaluate(bar);
+ assert(first >= 55 && first < 100, 'bar outside the starting band: '+first);
+ await until('document.querySelector("li[aria-current=step] .claim-step-detail").textContent !== '+JSON.stringify(original));
+ const later = await evaluate(bar);
+ assert(later >= first && later < 100, 'bar went back or finished early: '+first+' then '+later);
+ assert.equal(await evaluate('document.getElementById("claim-elapsed").hidden'),true,'elapsed shown before 30 s');
+ assert.equal(await evaluate('document.getElementById("claim-stuck").hidden'),true,'stuck before the deadline');
+ await capture('starting-hint');
+ // Past the server's deadline plus grace, still reporting progress: stuck.
+ await call('Page.navigate',{url:target+'/demo/claim?testProgress=stuck'});
+ await until('!!document.getElementById("claim-progress")');
+ assert.equal(await evaluate('document.getElementById("claim-stuck").hidden'),true,'stuck before polling');
+ await until('document.getElementById("claim-stuck")?.hidden === false');
+ assert.equal(await evaluate('document.getElementById("claim-stuck").getAttribute("role")'),'alert');
+ assert.equal(await evaluate('document.querySelector("#claim-stuck a").getAttribute("href")'),'/demo/claim');
+ assert.equal(await evaluate('document.querySelectorAll("#claim-stuck a").length'),1,'only the really-long case offers Check again');
+ assert.equal(await evaluate('document.getElementById("claim-progress").hasAttribute("data-stuck")'),true);
+ assert.equal(await evaluate('document.querySelector("li[aria-current=step] .claim-step-detail").textContent'),original,'stuck page still rotates reassurance');
+ await capture('stuck');
+ assert.equal(security.length,0,JSON.stringify(security));
+ process.stdout.write('reassurance: bar in band and monotonic, hints rotate, stuck after the deadline\n');
+ // Past the irreversible commit the rollback deadline does not apply: an
+ // overdue committed claim says it is the person's and still finishing,
+ // never that it will be undone.
+ await call('Page.navigate',{url:target+'/demo/claim?testProgress=committed'});
+ await until('!!document.getElementById("claim-progress")?.dataset.committedFor');
+ const committedPolls = statusRequests;
+ await until('document.getElementById("claim-finishing")?.hidden === false');
+ assert(statusRequests >= committedPolls + 2, 'finishing shown before two polls');
+ assert.equal(await evaluate('document.getElementById("claim-stuck").hidden'),true,'committed claim shown the rollback box');
+ assert.equal(await evaluate('document.getElementById("claim-progress").hasAttribute("data-stuck")'),false);
+ assert.equal(await evaluate('document.getElementById("claim-finishing").innerText.includes("undone")'),false);
+ assert.equal(await evaluate('document.getElementById("claim-finishing").getAttribute("role")'),'status');
+ // The page re-checks by itself; a finishing claim offers nothing to press.
+ assert.equal(await evaluate('document.querySelectorAll("#claim-finishing a, #claim-finishing button").length'),0,'finishing box has an action');
+ const finishingPolls = statusRequests;
+ for (let i=0; i<120 && statusRequests === finishingPolls; i++) await new Promise(r=>setTimeout(r,100));
+ assert(statusRequests > finishingPolls, 'finishing box stopped checking');
+ assert(await evaluate(bar) >= 90, 'committed bar below its band');
+ await capture('committed-finishing');
+ assert.equal(await evaluate('document.getElementById("claim-stuck").hidden'),true,'rollback box appeared later');
+ assert.equal(security.length,0,JSON.stringify(security));
+ process.stdout.write('committed: no rollback promise past the commit; finishing message instead\n');
} finally {
clearTimeout(timer);
const closed = new Promise(resolve => chrome.once('exit',resolve));