console: let the operator remove the letterhead logo
Saving without a file kept the current logo, so it could never be removed. A "Remove the logo" box (deck row DPA-C99), shown only while the current letterhead has a logo, saves a new row with none; earlier rows, and the acceptances made under them, keep theirs. A logo and the tick together are refused with the form-error sentence, before the step-up. The step-up stash keeps the tick, so the replay removes it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 files changed,
+135
−5
docs/superpowers/plans/2026-11-25-dpa-acceptance-copy.md+2 −1internal/console/approved_dpa_copy_test.go+2 −0internal/console/oplegal.go+19 −4internal/console/oplegal_test.go+107 −0internal/console/templates/ops_legal.html+5 −0
Intent
diff --git a/docs/superpowers/plans/2026-11-25-dpa-acceptance-copy.md b/docs/superpowers/plans/2026-11-25-dpa-acceptance-copy.md| index 0c8eaf3bd..8ebd4adce 100644 |
| --- a/docs/superpowers/plans/2026-11-25-dpa-acceptance-copy.md |
| +++ b/docs/superpowers/plans/2026-11-25-dpa-acceptance-copy.md |
| @@ -5,7 +5,7 @@ Every new user-facing string of the DPA acceptance plan |
| `internal/console/approved_dpa_copy_test.go` |
| (`TestDPACopyDeckIsApprovedAndApplied`). |
| -Approved 2026-11-25 by Paul in copy review (copy-review skill), all 94 rows unchanged from the draft. Rows DPA-C95 to DPA-C97 (the docs page heading and its menu entry) were approved unedited in a second review the same day. The text below is the approved text, verbatim. The screens were reviewed as a mockup built from the console mockup kit in the same review. |
| +Approved 2026-11-25 by Paul in copy review (copy-review skill), all 94 rows unchanged from the draft. Rows DPA-C95 to DPA-C97 (the docs page heading and its menu entry) were approved unedited in a second review the same day. Row DPA-C99 (the letterhead form's remove-logo checkbox) was added by the DPA follow-ups and is marked approved pending Paul's review; if he edits it, the text here and in the template change together. The text below is the approved text, verbatim. The screens were reviewed as a mockup built from the console mockup kit in the same review. |
| The rules are the burst deck's (`2026-10-31-probe-burst-limit-copy.md`): |
| one table, `| id | where | old | new | checked by | status |`; `where` is a |
| @@ -114,3 +114,4 @@ found literally by the gate once their id is in `dpaCopyBuilt`. |
| | DPA-C96 | docs/site/nav.json (menu label) [docs.dpa.nav_label] | (new) | Data processing agreement | gate | approved | |
| | DPA-C97 | docs/site/nav.json (menu description) [docs.dpa.nav_blurb] | (new) | Accept the agreement that covers personal data in your apps, and keep a record of it. | gate | approved | |
| | DPA-C98 | internal/console/dpapane.go (rate limit) [dpa.ratelimit] | (new) | Too many requests. Wait a minute and try again. | gate | approved | |
| +| DPA-C99 | internal/console/templates/ops_legal.html (letterhead form) [opl.letterhead.remove_logo] | (new) | Remove the logo | gate | approved | |
diff --git a/internal/console/approved_dpa_copy_test.go b/internal/console/approved_dpa_copy_test.go| index 5cfdda0a4..d344df91d 100644 |
| --- a/internal/console/approved_dpa_copy_test.go |
| +++ b/internal/console/approved_dpa_copy_test.go |
| @@ -37,6 +37,8 @@ var dpaCopyBuilt = map[string]bool{ |
| // The shared rate-limit refusal (dpa.ratelimit): the accept POST and |
| // both /fleet/legal POSTs. |
| "DPA-C98": true, |
| + // DPA follow-ups: the letterhead form's remove-logo box. |
| + "DPA-C99": true, |
| // Task 5: the account settings pane and its email (dpa.pane.*, dpa.form.*, |
| // dpa.flash.*, dpa.email.*). |
| "DPA-C01": true, "DPA-C02": true, "DPA-C03": true, "DPA-C04": true, "DPA-C05": true, |
diff --git a/internal/console/oplegal.go b/internal/console/oplegal.go| index 0a23c6b2a..f688b3ff3 100644 |
| --- a/internal/console/oplegal.go |
| +++ b/internal/console/oplegal.go |
| @@ -89,6 +89,8 @@ const ( |
| // legalLogoField carries an uploaded logo as base64 in the form, so a |
| // step-up's stash, which keeps only form values, replays it. |
| legalLogoField = "logo_data" |
| + // legalRemoveLogoField is the letterhead form's remove-logo box. |
| + legalRemoveLogoField = "remove_logo" |
| ) |
| // Field limits, in characters. |
| @@ -130,9 +132,12 @@ type legalAcceptRow struct { |
| } |
| // legalLetterheadForm is the letterhead form's values: the current |
| -// letterhead, or what was typed when a save is refused. |
| +// letterhead, or what was typed when a save is refused. HasLogo is whether |
| +// the current letterhead has a logo, which is when the remove-logo box |
| +// shows; RemoveLogo is that box as posted. |
| type legalLetterheadForm struct { |
| Entity, Office, Number, VAT, Signatory, Privacy, Footer string |
| + HasLogo, RemoveLogo bool |
| } |
| // legalView is the page's data (page.Legal). |
| @@ -243,6 +248,7 @@ func (s *Server) legalView(ctx context.Context, kind string, draft *legalDraft, |
| v.Letterhead = legalLetterheadForm{Entity: cur.Entity, Office: cur.RegisteredOffice, Number: cur.CompanyNumber, |
| VAT: cur.VATNumber, Signatory: cur.Signatory, Privacy: cur.PrivacyAddress, Footer: cur.Footer} |
| } |
| + v.Letterhead.HasLogo = cur != nil && len(cur.Logo) > 0 |
| return v, nil |
| } |
| @@ -535,13 +541,15 @@ func legalLetterheadDraft(r *http.Request) legalLetterheadForm { |
| return legalLetterheadForm{ |
| Entity: r.PostFormValue("entity"), Office: r.PostFormValue("office"), Number: r.PostFormValue("number"), |
| VAT: r.PostFormValue("vat"), Signatory: r.PostFormValue("signatory"), Privacy: r.PostFormValue("privacy"), |
| - Footer: r.PostFormValue("footer"), |
| + Footer: r.PostFormValue("footer"), RemoveLogo: r.PostFormValue(legalRemoveLogoField) != "", |
| } |
| } |
| // handleOpLegalLetterhead saves a new letterhead (spec §3.6), which becomes |
| // the current one; acceptances keep the one they were made under. With no |
| -// logo uploaded, the current letterhead's logo is kept. |
| +// logo uploaded, the current letterhead's logo is kept, unless the |
| +// remove-logo box is ticked: then the new row has none. A logo and the tick |
| +// together are refused. |
| func (s *Server) handleOpLegalLetterhead(w http.ResponseWriter, r *http.Request) { |
| addr, raw, ok := s.legalFormGate(w, r) |
| if !ok { |
| @@ -553,6 +561,13 @@ func (s *Server) handleOpLegalLetterhead(w http.ResponseWriter, r *http.Request) |
| if !s.legalFoldLogo(w, r, addr, raw) { |
| return |
| } |
| + // Refused before the step-up, so a form that cannot save never asks for |
| + // a passkey. A replay meets this check again: it carries both fields. |
| + if r.PostFormValue(legalRemoveLogoField) != "" && r.PostFormValue(legalLogoField) != "" { |
| + lh := legalLetterheadDraft(r) |
| + s.renderLegal(w, r, addr, raw, http.StatusBadRequest, "", legalErrForm, nil, &lh) |
| + return |
| + } |
| if !s.requireFreshAuth(w, r, addr, raw) { |
| return |
| } |
| @@ -590,7 +605,7 @@ func (s *Server) handleOpLegalLetterhead(w http.ResponseWriter, r *http.Request) |
| return |
| } |
| l.Logo = b |
| - } else { |
| + } else if !d.RemoveLogo { |
| cur, err := s.store.CurrentLetterhead(r.Context()) |
| if err != nil { |
| log.Printf("console: letterhead: current: %v", err) |
diff --git a/internal/console/oplegal_test.go b/internal/console/oplegal_test.go| index 6e6843719..b88aeb0ef 100644 |
| --- a/internal/console/oplegal_test.go |
| +++ b/internal/console/oplegal_test.go |
| @@ -957,3 +957,110 @@ func TestOpLegalOutOfOrderPublicationsAgree(t *testing.T) { |
| t.Errorf("pending = %+v, want v2, the newest", p) |
| } |
| } |
| + |
| +// TestOpLegalLetterheadRemoveLogo: the remove-logo box shows only while the |
| +// current letterhead has a logo; ticking it saves a new row with none, while |
| +// an acceptance made under the old row keeps that row's logo; an upload |
| +// with the tick is refused; and a step-up's replay keeps the tick. |
| +func TestOpLegalLetterheadRemoveLogo(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + c := signInOperator(t, fx) |
| + oplFresh(t, fx, c) |
| + box := `name="remove_logo"` |
| + |
| + fields := oplLetterheadFields() |
| + if status, _, body := oplPostLetterhead(t, fx, c, fields, nil); status != http.StatusSeeOther { |
| + t.Fatalf("save = %d %s", status, body) |
| + } |
| + _, _, page := get(t, c, fx.ts.URL+"/fleet/legal") |
| + if strings.Contains(page, box) || strings.Contains(oplText(page), oplDeck(t, "DPA-C99")) { |
| + t.Fatal("the remove-logo box shows for a letterhead with no logo") |
| + } |
| + |
| + logo := oplPNG(t) |
| + if status, _, body := oplPostLetterhead(t, fx, c, fields, logo); status != http.StatusSeeOther { |
| + t.Fatalf("save with logo = %d %s", status, body) |
| + } |
| + old, _ := fx.st.CurrentLetterhead(t.Context()) |
| + if old == nil || !bytes.Equal(old.Logo, logo) { |
| + t.Fatalf("logo not saved: %+v", old) |
| + } |
| + _, _, page = get(t, c, fx.ts.URL+"/fleet/legal") |
| + if !strings.Contains(page, box) || !strings.Contains(oplText(page), oplDeck(t, "DPA-C99")) { |
| + t.Fatalf("no remove-logo box beside a logo:\n%s", page) |
| + } |
| + |
| + // An acceptance made under the letterhead with the logo. |
| + now := time.Now().UTC().Truncate(time.Second) |
| + doc, err := fx.st.PublishLegalDocument(t.Context(), LegalDocument{Kind: "dpa", Version: "1", URL: "https://example.com/dpa/1/", |
| + SHA256: "aa", Summary: "One", PublishedAt: now, EffectiveAt: &now, PublishedBy: "paul@keymail.dev"}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + acct, err := fx.st.AccountBySqid(fx.sqid) |
| + if err != nil || acct == nil { |
| + t.Fatalf("account %v %v", acct, err) |
| + } |
| + if _, err := fx.st.AcceptDPA(t.Context(), DPAAcceptance{AccountID: acct.ID, DocumentID: doc, LetterheadID: old.ID, |
| + LegalName: "Customer Limited", Address: "1 Road", Country: "IE", SignerName: "Kim", SignerRole: "Director", |
| + AcceptedBy: "paul@keymail.dev", AcceptedIP: "192.0.2.1", AcceptedAt: now}); err != nil { |
| + t.Fatal(err) |
| + } |
| + |
| + // An upload with the tick is refused, and nothing is saved. |
| + ticked := oplLetterheadFields() |
| + ticked["remove_logo"] = "on" |
| + status, _, body := oplPostLetterhead(t, fx, c, ticked, oplPNG(t)) |
| + if status != http.StatusBadRequest || !strings.Contains(oplText(body), legalErrForm) { |
| + t.Fatalf("upload with the tick = %d %s", status, body) |
| + } |
| + if !strings.Contains(body, `name="remove_logo" value="on" checked`) { |
| + t.Error("the refused form lost the tick") |
| + } |
| + if lh, _ := fx.st.CurrentLetterhead(t.Context()); lh.ID != old.ID { |
| + t.Fatal("an upload with the tick saved a letterhead") |
| + } |
| + |
| + // The tick alone removes it. |
| + if status, _, body := oplPostLetterhead(t, fx, c, ticked, nil); status != http.StatusSeeOther { |
| + t.Fatalf("remove = %d %s", status, body) |
| + } |
| + lh, _ := fx.st.CurrentLetterhead(t.Context()) |
| + if lh.ID == old.ID || lh.Logo != nil || lh.LogoType != "" || lh.Entity != fields["entity"] { |
| + t.Fatalf("after remove: %+v", lh) |
| + } |
| + live, err := fx.st.LiveDPA(t.Context(), acct.ID) |
| + if err != nil || live == nil || live.LetterheadID != old.ID { |
| + t.Fatalf("live acceptance %+v %v", live, err) |
| + } |
| + if was, _ := fx.st.LetterheadByID(t.Context(), live.LetterheadID); was == nil || !bytes.Equal(was.Logo, logo) || was.LogoType != "image/png" { |
| + t.Fatalf("the earlier acceptance's letterhead lost its logo: %+v", was) |
| + } |
| + _, _, page = get(t, c, fx.ts.URL+"/fleet/legal") |
| + if strings.Contains(page, box) { |
| + t.Fatal("the remove-logo box outlived the logo") |
| + } |
| + |
| + // Through a step-up: the replay keeps the tick. |
| + if status, _, body := oplPostLetterhead(t, fx, c, fields, logo); status != http.StatusSeeOther { |
| + t.Fatalf("save with logo = %d %s", status, body) |
| + } |
| + withLogo, _ := fx.st.CurrentLetterhead(t.Context()) |
| + if err := fx.st.ClearStepUp(sessionToken(t, fx, c)); err != nil { |
| + t.Fatal(err) |
| + } |
| + status, loc, _ := oplPostLetterhead(t, fx, c, ticked, nil) |
| + if status != http.StatusSeeOther || !strings.HasPrefix(loc, fx.fk.srv.URL) { |
| + t.Fatalf("remove without a step-up = %d %q, want 303 to Keymail", status, loc) |
| + } |
| + if lh, _ := fx.st.CurrentLetterhead(t.Context()); lh.ID != withLogo.ID { |
| + t.Fatal("a parked remove was stored") |
| + } |
| + status, loc, body = completeStepUp(t, fx, c, loc) |
| + if status != http.StatusSeeOther || !strings.HasPrefix(loc, "/fleet/legal") { |
| + t.Fatalf("resumed remove = %d %q %s", status, loc, body) |
| + } |
| + if lh, _ := fx.st.CurrentLetterhead(t.Context()); lh.ID == withLogo.ID || lh.Logo != nil || lh.LogoType != "" { |
| + t.Fatalf("resumed remove kept the logo: %+v", lh) |
| + } |
| +} |
diff --git a/internal/console/templates/ops_legal.html b/internal/console/templates/ops_legal.html| index a66f9668e..34bcd7e44 100644 |
| --- a/internal/console/templates/ops_legal.html |
| +++ b/internal/console/templates/ops_legal.html |
| @@ -93,6 +93,11 @@ |
| <label rst-field-label for="opl-logo">Logo (optional)</label> |
| <input type="file" id="opl-logo" name="logo" accept="image/png,image/svg+xml"> |
| </div> |
| + {{- if .HasLogo}} |
| + <div rst-field> |
| + <label><span><input type="checkbox" name="remove_logo" value="on"{{if .RemoveLogo}} checked{{end}}> Remove the logo</span></label> |
| + </div> |
| + {{- end}} |
| <div rst-field> |
| <label rst-field-label for="opl-entity">Company name</label> |
| <input rst-input type="text" id="opl-entity" name="entity" value="{{.Entity}}" maxlength="200" required> |