console: claim console link needs membership; commit ends rollback
Astra round 1 (READY AFTER FIXES), both P2s: - "Open in the console" now needs the current session to be a member (any role, as the app pages ask) of the destination account and the app to exist there. The claim's status cookie still shows the result and the live address, but never establishes console access. - The status payload says whether a claiming operation has committed, and the page carries the seconds since the commit. Past the commit (irreversible; finishing may run past the deadline) the page never shows the rollback stuck box. Two minutes after the commit it shows a "yours, still finishing" box instead; the bar moves to the last band and the starting hints stop. Back to a resumed choice's first paint from the bfcache now reloads the claim instead of sitting on the pending shell; a reload after the automatic post renders progress with no auto-submit marker (tested). Two new strings (finishing heading and detail) await copy review. Footer golden digests retaken for the new script hash.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
10 files changed,
+218
−21
internal/console/demo_claim_choice_test.go+87 −0internal/console/demo_claim_copy.go+5 −0internal/console/demo_claim_footer_test.go+11 −10internal/console/demo_claim_page.go+34 −2internal/console/demo_claim_resume_browser_test.go+13 −0internal/console/demo_claim_resume_test.go+5 −0internal/console/demo_claim_status_page.go+6 −0internal/console/static/demo_claim.js+38 −8internal/console/templates/demo_claim.html+2 −1internal/console/testdata/demo_claim_resume_browser.mjs+17 −0
diff --git a/internal/console/demo_claim_choice_test.go b/internal/console/demo_claim_choice_test.go| index d4714777c..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 { |
| @@ -638,3 +645,83 @@ func TestDemoClaimChoiceSearchAndOrder(t *testing.T) { |
| }) |
| } |
| } |
| + |
| +// 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 bfa2542c6..e5d62fb19 100644 |
| --- a/internal/console/demo_claim_copy.go |
| +++ b/internal/console/demo_claim_copy.go |
| @@ -214,6 +214,11 @@ const ( |
| 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. |
diff --git a/internal/console/demo_claim_footer_test.go b/internal/console/demo_claim_footer_test.go| index 9b3185ca9..c23234b12 100644 |
| --- a/internal/console/demo_claim_footer_test.go |
| +++ b/internal/console/demo_claim_footer_test.go |
| @@ -12,19 +12,20 @@ import ( |
| ) |
| // The digests are the claim page with no footer, retaken when the page itself |
| -// changes (last: the one-line account picker, claim-picker-rows). With |
| -// neither item configured (or both invalid) the page is these exact bytes. |
| +// 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": "b2a2585b5085df3f78941ea2a4459d849ef13715b9f51df83fdc3b42fd185454", |
| - "template-missing": "6e2aef84f98c10cbc49349b49f6865274e8fca54ff56c17846a1595746fe5eec", |
| - "template-error": "64e38dc116cdeae9cfb91b305aabc081f77a3d2fb4a3c0dfdba2963dc3bafa41", |
| - "template-claimed": "e4c9b4a267c8d58dbbf5514de16a6d40320f7992ea498aad799cb593eb3c4a20", |
| - "template-proof": "3bbd6532e51a6a6b40a853f8ccf0af1aa067f424af700a7b09d2f1ea7101c582", |
| - "error-page": "30011bb94cb643d51206c04502fbbf39ea49c714b8e117948cfbf505b6d154be", |
| - "get-claim": "41f8abb5d62650d39dff65d15fde9da6b52ace3926a886956c56c3af5081e8c2", |
| - "get-kept": "4698b2a67ebb90206df4dd855876ea7de458494ec651641605107fa89191cc69", |
| + "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 53f570981..e6de971b0 100644 |
| --- a/internal/console/demo_claim_page.go |
| +++ b/internal/console/demo_claim_page.go |
| @@ -71,7 +71,11 @@ type demoClaimPageData struct { |
| // progress well after it is stuck. Relative, so the browser's clock |
| // does not matter. |
| DeadlineIn string |
| - Footer demoClaimFooter |
| + // 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) { |
| @@ -182,6 +186,14 @@ func (s *Server) handleDemoClaimPage(w http.ResponseWriter, r *http.Request) { |
| 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 |
| @@ -198,7 +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 = "/a/" + url.PathEscape(acct.Sqid) + "/apps/" + url.PathEscape(p.App) |
| + 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?" |
| @@ -687,6 +699,8 @@ func demoClaimBrowserCopy() map[string]string { |
| "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. |
| @@ -732,6 +746,24 @@ 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 |
diff --git a/internal/console/demo_claim_resume_browser_test.go b/internal/console/demo_claim_resume_browser_test.go| index 482b9f205..ad0295b09 100644 |
| --- a/internal/console/demo_claim_resume_browser_test.go |
| +++ b/internal/console/demo_claim_resume_browser_test.go |
| @@ -57,6 +57,16 @@ func TestDemoClaimSelectStepUpHeadless(t *testing.T) { |
| 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) |
| } |
| @@ -87,6 +97,9 @@ func TestDemoClaimSelectStepUpHeadless(t *testing.T) { |
| if mode.Load() == 5 { |
| phase = "verifying" |
| } |
| + if mode.Load() == 6 { |
| + phase = "committed" |
| + } |
| if mode.Load() == 2 { |
| phase = "aborted" |
| } |
diff --git a/internal/console/demo_claim_resume_test.go b/internal/console/demo_claim_resume_test.go| index 019cb134f..f070e339d 100644 |
| --- a/internal/console/demo_claim_resume_test.go |
| +++ b/internal/console/demo_claim_resume_test.go |
| @@ -118,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/static/demo_claim.js b/internal/console/static/demo_claim.js| index 3e20de7b9..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; |
| @@ -168,13 +171,28 @@ |
| // 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; |
| - const isStuck = () => Number.isFinite(deadline) |
| - ? claimingPolls >= 2 && performance.now() > deadline + 90000 |
| - : performance.now() - entered > 390000; |
| + // 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 (stage < 3) { |
| + 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])); |
| } |
| @@ -198,8 +216,9 @@ |
| 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. |
| - if (!detail || progress.dataset.stuck !== undefined) return; |
| + // 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; |
| @@ -213,6 +232,7 @@ |
| timers = []; |
| restoreDetails(); |
| stuck.hidden = true; |
| + finishing.hidden = true; |
| delete progress.dataset.stuck; |
| }; |
| draw(); |
| @@ -283,7 +303,8 @@ |
| 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(); |
| @@ -300,7 +321,16 @@ |
| 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 (_) { |
| @@ -313,7 +343,7 @@ |
| } |
| } |
| // Once stuck, keep checking, more slowly: a late finish still lands. |
| - setTimeout(poll, stuck.hidden ? 3000 : 10000); |
| + setTimeout(poll, stuck.hidden && finishing.hidden ? 3000 : 10000); |
| }; |
| // 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. |
diff --git a/internal/console/templates/demo_claim.html b/internal/console/templates/demo_claim.html| index cc14c256c..23c3ad987 100644 |
| --- a/internal/console/templates/demo_claim.html |
| +++ b/internal/console/templates/demo_claim.html |
| @@ -265,9 +265,10 @@ |
| {{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 .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}}"> |
| +<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><a class="btn btn-sm" href="/demo/claim">{{.Copy.stuckAction}}</a></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}} |
diff --git a/internal/console/testdata/demo_claim_resume_browser.mjs b/internal/console/testdata/demo_claim_resume_browser.mjs| index 6c8dd1421..09829df99 100644 |
| --- a/internal/console/testdata/demo_claim_resume_browser.mjs |
| +++ b/internal/console/testdata/demo_claim_resume_browser.mjs |
| @@ -321,6 +321,23 @@ try { |
| 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'); |
| + 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)); |