console: show the env save bar on the first edit, Edit/Close in CSS
No per-panel Change button: the save bar is in the form always, hidden until something is staged or a panel is edited (a few lines of script), and shown with scripts off. The row summary carries Edit and Close and CSS on details[open] picks one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/console-mockup-kit/shell.html+2 −0docs/console-styleguide.md+7 −4internal/console/envcopy.go+3 −1internal/console/envform_test.go+23 −8internal/console/templates/app_settings.html+23 −9internal/console/templates/console_chrome.html+2 −0internal/console/testdata/configseal_browser.mjs+10 −3
Intent
<task-notification> <task-id>a500c517b888e4b83</task-id> <tool-use-id>toolu_012HnpzsakfQdu43TWAYxufT</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/abe35d56-e4c2-40df-9005-6e66b76b1f50/tasks/a500c517b888e4b83.output</output-file> <status>completed</status> <summary>Agent "Implement Task 7 settings page" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE. All 12 code and doc files are committed. The report file is in `.superpowers`, which is gitignored like the earlier task reports, so it is not in the commit. Commit: a32a18ee `console: edit an app's settings and secrets on the settings page` Tests: the targeted run is green (`EnvSection|EnvForm|EnvSeal|EnvSecret|EnvCopy|EnvDraft|Styleguide|AppSettings|SettingsPage|ConfigSeal|ConfigValue|BrowserSeal|GettingStarted|MockupKit`), including a real headless Chromium check; gofmt and vet are clean. I looked at the 390 px and 1280 px screenshots and deleted them afterwards. Desktop: the add form is one line. 390 px: the first shot put Secret on the Add line, so I added one phone CSS rule; now the name is line 1 and value, Secret and Add are line 2. Concerns: 1. I changed `configseal.js` by one line. Under Task 6's contract every enabled, named secret field must be filled, so the empty Replace field on each stored secret blocked every submit. A new `data-secret-optional` attribute makes an empty Replace mean "keep the secret". Please review it. 2. I added a visible "Change" button to each Edit panel, plus a hidden default `stage` button so Enter stages. Without them there is no way to apply an edit before the save bar exists, and Enter would hit the first Remove. This is not in the approved mockup. 3. All copy is a draft in `envcopy.go` and not yet copy-reviewed. "Edit" does not switch to "Close" when a row is opened. 4. A console with no bucket cannot render app pages at all (it panics on nil Releases). The read-only test therefore renders the template directly, and the POST door's 409 for that case is untested. 5. I added a third seal-off reason, "unavailable" (the key read failed), with its own line. 6. Task 8 must not put `data-busy` on Save: the chrome's busy script calls `form.submit()` itself and would race the sealing script. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-console-secrets/.superpowers/sdd/2026-11-08-console-secrets/task-7-report.md (includes the final form field protocol for Task 8)</result> <usage><subagent_tokens>256069</subagent_tokens><tool_uses>77</tool_uses><duration_ms>2502507</duration_ms></usage> </task-notification>
Attributed to this commit: 9.34 g CO₂e (1,165,112 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-console-secrets, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/console-mockup-kit/shell.html b/docs/console-mockup-kit/shell.html| index cf3432ace..e4bc39eb7 100644 |
| --- a/docs/console-mockup-kit/shell.html |
| +++ b/docs/console-mockup-kit/shell.html |
| @@ -407,6 +407,8 @@ |
| .outcomes .envvar-value { flex: none; } |
| .envvar-edit { flex: none; color: var(--accent); font-size: 0.9rem; } |
| .envvar[open] .envvar-edit { color: var(--muted); } |
| + .envvar-when-open, .envvar[open] .envvar-when-closed { display: none; } |
| + .envvar[open] .envvar-when-open { display: inline; } |
| .envvar-panel { padding: 0 0.9rem 0.6rem; } |
| .envvar-panel .settings-row { margin: 0; } |
| .envvar-panel input[type=text], .envvar-panel input[type=password] { flex: 1; min-width: 8rem; } |
diff --git a/docs/console-styleguide.md b/docs/console-styleguide.md| index 475b512be..1d8b28259 100644 |
| --- a/docs/console-styleguide.md |
| +++ b/docs/console-styleguide.md |
| @@ -311,11 +311,10 @@ Environments section is built from it. |
| <p class="small">Used by shop.example.com</p> |
| <div class="tablewrap"> |
| <ul class="envvars"> |
| - <li><details class="envvar"><summary><code class="envvar-name">LOG_LEVEL</code><span class="envvar-value">info</span><span class="envvar-edit">Edit</span></summary> |
| + <li><details class="envvar"><summary><code class="envvar-name">LOG_LEVEL</code><span class="envvar-value">info</span><span class="envvar-edit"><span class="envvar-when-closed">Edit</span><span class="envvar-when-open">Close</span></span></summary> |
| <div class="envvar-panel settings-row"> |
| <label class="visually-hidden" for="val.default.LOG_LEVEL">New value for LOG_LEVEL</label> |
| <input type="text" id="val.default.LOG_LEVEL" name="val.default.LOG_LEVEL" value="info" autocomplete="off"> |
| - <button type="submit" class="btn-sm btn-secondary" name="op" value="stage">Change</button> |
| <button type="submit" class="linkish danger" name="op" value="remove:default.LOG_LEVEL">Remove</button> |
| </div> |
| </details></li> |
| @@ -355,8 +354,12 @@ Environments section is built from it. |
| - `.addvar` is one line on a desktop and wraps to two at 390 px with the |
| checkbox beside the value. Its inputs are matched by `name` ending in |
| `.name` and `.value`. |
| -- `.savebar` sticks to the bottom of the screen and is drawn only while |
| - something is staged; Discard is a `linkish` beside the Save button. |
| +- The summary's `.envvar-edit` holds two spans, `.envvar-when-closed` |
| + (Edit) and `.envvar-when-open` (Close); CSS on `.envvar[open]` shows one. |
| +- `.savebar` sticks to the bottom of the screen. It is in the form always, |
| + `hidden` until something is staged or a panel is edited (a small script |
| + un-hides it); with scripts off a `<noscript>` rule shows it. Discard is a |
| + `linkish` beside the Save button. |
| - `.outcomes` turns the same rows into a host list with a chip each, for |
| what happened after a save. |
diff --git a/internal/console/envcopy.go b/internal/console/envcopy.go| index 3de39a3ca..6cf28491b 100644 |
| --- a/internal/console/envcopy.go |
| +++ b/internal/console/envcopy.go |
| @@ -29,7 +29,7 @@ type envPageCopy struct { |
| ValuePlace string |
| Secret string |
| Add string |
| - Stage string // applies an Edit panel's change to the draft |
| + Stage string // the hidden default button's name (Enter stages) |
| SealingNote string |
| NeedsScript string |
| KeylessFlt string // {fleet} |
| @@ -48,6 +48,7 @@ type envPageCopy struct { |
| // The save bar. |
| Save string |
| Discard string |
| + Unsaved string // the bar's line before anything is staged |
| SummaryOne string // {change} {env} |
| SummaryMany string // {n} {env} {changes} |
| ChangeNew string // {name} |
| @@ -143,6 +144,7 @@ var envCopyDraft = envPageCopy{ |
| Save: "Save", |
| Discard: "Discard", |
| + Unsaved: "You have changes that aren't saved yet.", |
| SummaryOne: "1 change: {change} in {env}.", |
| SummaryMany: "{n} changes in {env}: {changes}.", |
| ChangeNew: "new setting {name}", |
diff --git a/internal/console/envform_test.go b/internal/console/envform_test.go| index 90e9693ec..b6ca0927f 100644 |
| --- a/internal/console/envform_test.go |
| +++ b/internal/console/envform_test.go |
| @@ -284,7 +284,7 @@ func TestEnvFormNonMember404(t *testing.T) { |
| func TestEnvFormStageAddRemoveUndoDiscard(t *testing.T) { |
| e := newEnvFx(t) |
| body := e.page(t) |
| - mustNotContain(t, body, `class="savebar"`) |
| + mustContain(t, body, `<div class="savebar" hidden>`) |
| mustContain(t, body, `<span class="envvar-value">info</span>`, `<span class="envvar-value small">Sealed</span>`) |
| // Add an ordinary setting. |
| @@ -295,7 +295,7 @@ func TestEnvFormStageAddRemoveUndoDiscard(t *testing.T) { |
| if status != http.StatusOK { |
| t.Fatalf("add = %d:\n%s", status, body) |
| } |
| - mustContain(t, body, `class="savebar"`, "1 change: new setting MODE in All environments.", |
| + mustContain(t, body, `<div class="savebar">`, "1 change: new setting MODE in All environments.", |
| `name="new.default.MODE" value="fast"`, `name="bundle" value="default"`) |
| // Add a secret, as the sealing script posts it: the box ticked, the |
| @@ -364,7 +364,8 @@ func TestEnvFormStageAddRemoveUndoDiscard(t *testing.T) { |
| if status != http.StatusOK { |
| t.Fatalf("discard = %d", status) |
| } |
| - mustNotContain(t, body, `class="savebar"`, "newenv.", `name="new.`, `name="bundle" value="default"`) |
| + mustNotContain(t, body, `<div class="savebar">`, "newenv.", `name="new.`, `name="bundle" value="default"`) |
| + mustContain(t, body, `<div class="savebar" hidden>`, "<noscript><style>.savebar[hidden]") |
| // Save is Task 8's: for now it draws the draft again and writes nothing. |
| f = envFields(t, body) |
| @@ -466,7 +467,7 @@ func TestEnvFormRefusesSecretPlaintext(t *testing.T) { |
| t.Fatalf("status = %d, want 400", status) |
| } |
| mustContain(t, body, "without being sealed in your browser, so it was thrown away") |
| - mustNotContain(t, body, plain, "API_TOKEN", `class="savebar"`) |
| + mustNotContain(t, body, plain, "API_TOKEN", `<div class="savebar">`) |
| }) |
| } |
| e.spy.none(t) |
| @@ -658,10 +659,16 @@ func TestEnvFormChromium(t *testing.T) { |
| Fill map[string]string `json:"fill"` |
| Tick []string `json:"tick"` |
| Click string `json:"click"` |
| + Input bool `json:"input,omitempty"` |
| + Check string `json:"check,omitempty"` |
| } |
| scenes := []scene{ |
| - {ts.URL + "/page", map[string]string{"add.default.name": "WEBHOOK_SECRET", "add.default.value": secret}, []string{"add.default.secret"}, "add:default"}, |
| - {ts.URL + "/page", map[string]string{"sec.default.STRIPE_KEY": replaced}, nil, "stage"}, |
| + {ts.URL + "/page", map[string]string{"add.default.name": "WEBHOOK_SECRET", "add.default.value": secret}, []string{"add.default.secret"}, "add:default", false, |
| + `document.querySelector(".savebar").hidden === true`}, |
| + {ts.URL + "/page", map[string]string{"sec.default.STRIPE_KEY": replaced}, nil, "stage", false, ""}, |
| + // An edit in a panel shows the hidden save bar; its Discard posts. |
| + {ts.URL + "/page", map[string]string{"val.default.LOG_LEVEL": "warn"}, nil, "discard", true, |
| + `document.querySelector(".savebar").hidden === false && getComputedStyle(document.querySelector(".savebar")).display !== "none"`}, |
| } |
| payload, _ := json.Marshal(scenes) |
| ctx, cancel := context.WithTimeout(t.Context(), 90*time.Second) |
| @@ -673,8 +680,11 @@ func TestEnvFormChromium(t *testing.T) { |
| mu.Lock() |
| defer mu.Unlock() |
| - if len(posts) != 2 { |
| - t.Fatalf("%d posts, want 2: %v", len(posts), posts) |
| + if len(posts) != 3 { |
| + t.Fatalf("%d posts, want 3: %v", len(posts), posts) |
| + } |
| + if d := posts[2]; d.Get("op") != "discard" || d.Get("val.default.LOG_LEVEL") != "warn" { |
| + t.Errorf("discard posted %v", d) |
| } |
| for i, f := range posts { |
| for k, vs := range f { |
| @@ -708,6 +718,11 @@ func TestEnvFormChromium(t *testing.T) { |
| } |
| mustContain(t, body, "1 change: new secret WEBHOOK_SECRET in All environments.") |
| mustNotContain(t, body, secret) |
| + status, _, dbody := postForm(t, e.c, e.fx.u("/apps/shop/settings/environments"), posts[2]) |
| + if status != http.StatusOK { |
| + t.Fatalf("console discarding the browser's edit = %d", status) |
| + } |
| + mustContain(t, dbody, `<div class="savebar" hidden>`, `name="val.default.LOG_LEVEL" value="info"`) |
| e.spy.none(t) |
| if dir := os.Getenv("ENV_FORM_SHOTS"); dir != "" { |
diff --git a/internal/console/templates/app_settings.html b/internal/console/templates/app_settings.html| index 609d76fe7..0dbc9ce9d 100644 |
| --- a/internal/console/templates/app_settings.html |
| +++ b/internal/console/templates/app_settings.html |
| @@ -635,7 +635,7 @@ blocks deletion. Turn the safety delay off on the <a href="{{.Nav}}/apps/{{.AppN |
| <h2>Environments</h2> |
| <p class="small">{{$c.Intro}}</p> |
| {{if $s.EnvError}}<p class="banner error" role="alert">{{$s.EnvError}}</p>{{end}} |
| -<form method="post" action="{{.Nav}}/apps/{{.Detail.App}}/settings/environments"{{with $seal}} data-seal-pub="{{.Pub}}" data-seal-version="{{.Version}}"{{if .Account}} data-account="{{.Account}}" data-app="{{.App}}"{{end}} data-msg-chars="{{$c.MsgChars}}" data-msg-empty="{{$c.MsgEmpty}}" data-msg-seal="{{$c.MsgSeal}}" data-msg-changed="{{$c.MsgChanged}}"{{end}}> |
| +<form method="post" action="{{.Nav}}/apps/{{.Detail.App}}/settings/environments" data-env-form{{with $seal}} data-seal-pub="{{.Pub}}" data-seal-version="{{.Version}}"{{if .Account}} data-account="{{.Account}}" data-app="{{.App}}"{{end}} data-msg-chars="{{$c.MsgChars}}" data-msg-empty="{{$c.MsgEmpty}}" data-msg-seal="{{$c.MsgSeal}}" data-msg-changed="{{$c.MsgChanged}}"{{end}}> |
| <input type="hidden" name="csrf" value="{{.CSRF}}"> |
| {{/* The form's default button: Enter in any field stages (an add row with a name adds). */}} |
| <button type="submit" name="op" value="stage" class="visually-hidden" tabindex="-1" aria-hidden="true">{{$c.Stage}}</button> |
| @@ -650,21 +650,19 @@ blocks deletion. Turn the safety delay off on the <a href="{{.Nav}}/apps/{{.AppN |
| {{range .Vars}}<li>{{if eq .Staged "removed"}}<div class="envvar-row"><code class="envvar-name">{{.Name}}</code><span class="envvar-value"><span class="chip chip-canary">{{$c.Removed}}</span></span><button type="submit" class="linkish" name="op" value="undo:{{$b}}.{{.Name}}" data-seal-skip>{{$c.Undo}}</button></div> |
| {{- else if eq .Staged "new"}}<div class="envvar-row"><code class="envvar-name">{{.Name}}</code><span class="envvar-value">{{if not .Secret}}{{.Value}} {{end}}<span class="chip chip-canary">{{if .Secret}}{{$c.NewSecret}}{{else}}{{$c.New}}{{end}}</span></span><button type="submit" class="linkish" name="op" value="undo:{{$b}}.{{.Name}}" data-seal-skip>{{$c.Undo}}</button></div> |
| {{- else if and .Secret .Staged}}<div class="envvar-row"><code class="envvar-name">{{.Name}}</code><span class="envvar-value"><span class="chip chip-canary">{{$c.Changed}}</span></span><button type="submit" class="linkish" name="op" value="undo:{{$b}}.{{.Name}}" data-seal-skip>{{$c.Undo}}</button></div> |
| - {{- else}}<details class="envvar"{{if .Open}} open{{end}}><summary><code class="envvar-name">{{.Name}}</code><span class="envvar-value{{if .Secret}} small{{end}}">{{if .Secret}}{{$c.Sealed}}{{else}}{{.Value}}{{end}}{{if .Staged}} <span class="chip chip-canary">{{$c.Changed}}</span>{{end}}</span><span class="envvar-edit">{{if .Open}}{{$c.Close}}{{else}}{{$c.Edit}}{{end}}</span></summary> |
| + {{- else}}<details class="envvar"{{if .Open}} open{{end}}><summary><code class="envvar-name">{{.Name}}</code><span class="envvar-value{{if .Secret}} small{{end}}">{{if .Secret}}{{$c.Sealed}}{{else}}{{.Value}}{{end}}{{if .Staged}} <span class="chip chip-canary">{{$c.Changed}}</span>{{end}}</span><span class="envvar-edit"><span class="envvar-when-closed">{{$c.Edit}}</span><span class="envvar-when-open">{{$c.Close}}</span></span></summary> |
| <div class="envvar-panel settings-row"> |
| {{- if .Secret}}{{$id := printf "sec.%s.%s" $b .Name}} |
| <label class="visually-hidden" for="{{$id}}">{{$c.NewValueLabel .Name}}</label> |
| {{- if $seal}} |
| <input type="password" id="{{$id}}" name="{{$id}}" placeholder="{{$c.NewValue}}" autocomplete="off" data-secret-input data-secret-optional disabled> |
| <input type="hidden" name="env.{{$b}}.{{.Name}}" data-envelope-for="{{$id}}"> |
| - <button type="submit" class="btn-sm btn-secondary" name="op" value="stage">{{$c.Stage}}</button> |
| {{- else}} |
| <input type="password" id="{{$id}}" placeholder="{{$c.NewValue}}" autocomplete="off" disabled> |
| {{- end}} |
| {{- else}}{{$id := printf "val.%s.%s" $b .Name}} |
| <label class="visually-hidden" for="{{$id}}">{{$c.NewValueLabel .Name}}</label> |
| <input type="text" id="{{$id}}" name="{{$id}}" value="{{.Value}}" autocomplete="off"> |
| - <button type="submit" class="btn-sm btn-secondary" name="op" value="stage">{{$c.Stage}}</button> |
| {{- end}} |
| {{if .Staged}}<button type="submit" class="linkish" name="op" value="undo:{{$b}}.{{.Name}}" data-seal-skip>{{$c.Undo}}</button>{{end}} |
| <button type="submit" class="linkish danger" name="op" value="remove:{{$b}}.{{.Name}}" data-seal-skip>{{$c.Remove}}</button> |
| @@ -702,15 +700,31 @@ blocks deletion. Turn the safety delay off on the <a href="{{.Nav}}/apps/{{.AppN |
| <input type="hidden" name="newenv.{{$b}}.{{$k}}" value="{{$v}}">{{end}} |
| {{- range .Unset}} |
| <input type="hidden" name="rm.{{$b}}" value="{{.}}">{{end}} |
| - {{- if not .Empty}} |
| - <div class="savebar"> |
| - <p class="small">{{$s.EnvSummary}}</p> |
| +{{- end}} |
| + {{/* The save bar is always in the form: shown while a draft is staged, |
| + un-hidden by the script below on the first edit in a panel (Save |
| + diffs val.* against the bundle shown), and always shown with scripts |
| + off. */}} |
| + <div class="savebar"{{if or (not $d) $d.Empty}} hidden{{end}}> |
| + <p class="small">{{if $s.EnvSummary}}{{$s.EnvSummary}}{{else}}{{$c.Unsaved}}{{end}}</p> |
| <div class="actions"> |
| <button type="submit" class="linkish" name="op" value="discard" data-seal-skip>{{$c.Discard}}</button> |
| <button type="submit" class="btn-sm" name="op" value="save">{{$c.Save}}</button> |
| </div> |
| - </div>{{end}} |
| -{{- end}} |
| + </div> |
| + <noscript><style>.savebar[hidden] { display: flex; }</style></noscript> |
| </form> |
| +<script> |
| +(function () { |
| + var form = document.querySelector("form[data-env-form]"); |
| + var bar = form && form.querySelector(".savebar"); |
| + if (!bar) return; |
| + function edited(e) { |
| + if (e.target.closest && e.target.closest(".envvar-panel")) bar.hidden = false; |
| + } |
| + form.addEventListener("input", edited); |
| + form.addEventListener("change", edited); |
| +})(); |
| +</script> |
| {{if $seal}}<script>{{$s.ConfigSealJS}}</script>{{end}} |
| {{end}} |
diff --git a/internal/console/templates/console_chrome.html b/internal/console/templates/console_chrome.html| index 8494b3bb2..714b90a4e 100644 |
| --- a/internal/console/templates/console_chrome.html |
| +++ b/internal/console/templates/console_chrome.html |
| @@ -269,6 +269,8 @@ |
| .outcomes .envvar-value { flex: none; } |
| .envvar-edit { flex: none; color: var(--accent); font-size: 0.9rem; } |
| .envvar[open] .envvar-edit { color: var(--muted); } |
| + .envvar-when-open, .envvar[open] .envvar-when-closed { display: none; } |
| + .envvar[open] .envvar-when-open { display: inline; } |
| .envvar-panel { padding: 0 0.9rem 0.6rem; } |
| .envvar-panel .settings-row { margin: 0; } |
| .envvar-panel input[type=text], .envvar-panel input[type=password] { flex: 1; min-width: 8rem; } |
diff --git a/internal/console/testdata/configseal_browser.mjs b/internal/console/testdata/configseal_browser.mjs| index 774a75ad5..42daa96a3 100644 |
| --- a/internal/console/testdata/configseal_browser.mjs |
| +++ b/internal/console/testdata/configseal_browser.mjs |
| @@ -3,7 +3,9 @@ |
| // button and waits for the post to land. The Go side counts the posts. |
| // |
| // node configseal_browser.mjs <chromium> <profile dir> <scenes JSON> |
| -// scene: {url, fill: {id: value}, tick: [id], click: <button value>} |
| +// scene: {url, fill: {id: value}, tick: [id], click: <button value>, |
| +// input: fire input events on the filled fields, check: a JS |
| +// expression that must be true before the click} |
| import {spawn} from 'node:child_process'; |
| import assert from 'node:assert/strict'; |
| @@ -58,10 +60,15 @@ try { |
| assert.equal(await evaluate('window.isSecureContext && !!crypto.subtle'), true); |
| await evaluate(`(() => { |
| const fill = ${JSON.stringify(scene.fill || {})}, tick = ${JSON.stringify(scene.tick || [])}; |
| - for (const [id, v] of Object.entries(fill)) document.getElementById(id).value = v; |
| + for (const [id, v] of Object.entries(fill)) { |
| + const el = document.getElementById(id); |
| + el.value = v; |
| + if (${!!scene.input}) el.dispatchEvent(new Event('input', {bubbles: true})); |
| + } |
| for (const id of tick) document.getElementById(id).checked = true; |
| - document.querySelector('button[value="${scene.click}"]').click(); |
| })()`); |
| + if (scene.check) assert.equal(await evaluate(scene.check), true, 'scene check: ' + scene.check); |
| + await evaluate(`document.querySelector('button[value="${scene.click}"]').click()`); |
| await until('location.pathname === "/posted"'); |
| // Leave time for a stray second submit to show up on the Go side. |
| await new Promise(r => setTimeout(r, 300)); |