console: approved sign-in says go back to the agent
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
internal/console/authcli.go+18 −0internal/console/authcli_test.go+20 −0internal/console/signincopy.go+4 −0internal/console/templates/cli_approve.html+4 −8
Intent
<task-notification> <task-id>a0eccc984b5010fd6</task-id> <tool-use-id>toolu_01T2gseYEoKNFmkyzbAgXNq2</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/a1de5273-c148-49b8-8267-3dee9d49c9c1/tasks/a0eccc984b5010fd6.output</output-file> <status>completed</status> <summary>Agent "Implement Task 2: approve from link" 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 (fix round 1). Both fixes are committed. I appended the fix report to task-2-report.md, but `.superpowers` is gitignored, so the report itself is not in any commit. Commits: - 6894c15a console: approve a CLI login from the code in its link - 65292caf console: describe a typed CLI code like a link code; name the country Fixes: 1. A new helper, `describeCLI`, fills in the login's details, its age and where it came from. Both the link page and the typed-code `continue` path now use it, so a typed code no longer shows "Started just now." with no location line. 2. The location line now gives the country name with the subdivision code in brackets: "United Kingdom (GB-ENG)", or "United Kingdom" without one. An unknown country code falls back to the code. Tests: the new and updated tests failed first and pass now; all `go test ./internal/console -run 'TestCLI' -count=1` tests pass, and gofmt and vet are clean. I did not re-run the claim invariant test because routing and the Approve button are unchanged. Concerns: `git commit` again warned that `packed-refs.lock` already exists, probably another session's git. HEAD is 65292caf and the tree is clean, and I left the lock file alone. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-agent-login-link/.superpowers/sdd/2026-11-07-agent-login-link/task-2-report.md</result> <usage><subagent_tokens>195032</subagent_tokens><tool_uses>8</tool_uses><duration_ms>133720</duration_ms></usage> </task-notification>
Attributed to this commit: 28.1 g CO₂e (3,552,041 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-agent-login-link, 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/internal/console/authcli.go b/internal/console/authcli.go| index ca99a6d91..e82e164ec 100644 |
| --- a/internal/console/authcli.go |
| +++ b/internal/console/authcli.go |
| @@ -1554,6 +1554,9 @@ type cliPage struct { |
| // Started how long ago it began; both only beside a described Request. |
| Place cliPlace |
| Started time.Duration |
| + // Label names the agent or terminal a decision was made about, for the |
| + // decided page. |
| + Label string |
| Tokens []CLIToken |
| Methods []methodRow |
| Days int |
| @@ -1587,6 +1590,15 @@ func (p cliPage) Lede() string { |
| return copyText("cli.lede", "label", label, "console", p.Brand) |
| } |
| +// ApprovedText sends the person back to the agent that asked. |
| +func (p cliPage) ApprovedText() string { |
| + label := p.Label |
| + if label == "" { |
| + label = copyText("cli.unnamed") |
| + } |
| + return copyText("cli.approved", "label", label) |
| +} |
| + |
| // StartedText says how long ago the described login began. |
| func (p cliPage) StartedText() string { |
| if p.Started < time.Minute { |
| @@ -1752,6 +1764,12 @@ func (s *Server) handleCLIApprove(w http.ResponseWriter, r *http.Request) { |
| if action == "approve" && !s.requireFreshAuth(w, r, addr, raw) { |
| return |
| } |
| + // Read the label first so the decided page can name the agent. A |
| + // failed read changes nothing: the decision below reports the error |
| + // and spends the budget exactly as before. |
| + if req, lerr := s.store.CLIAuthByUserCode(code, now); lerr == nil { |
| + p.Label = req.Label |
| + } |
| var err error |
| if action == "deny" { |
| err = s.store.DenyCLIAuth(code, now) |
diff --git a/internal/console/authcli_test.go b/internal/console/authcli_test.go| index a281614c9..f0918604d 100644 |
| --- a/internal/console/authcli_test.go |
| +++ b/internal/console/authcli_test.go |
| @@ -573,6 +573,26 @@ func TestCleanLabelIsPrintableASCII(t *testing.T) { |
| } |
| // A denied login is final and tells the terminal so. |
| +func TestCLIApprovedPagePointsBack(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + browser := newBrowser(t) |
| + signUp(t, fx, browser, "code-approved-back") |
| + _, start := postJSON(t, fx.ts.URL+"/auth/cli/start", map[string]string{"label": "Claude Code on box"}, "") |
| + status, _, body := postGated(t, fx, browser, fx.ts.URL+"/auth/cli/approve", |
| + url.Values{"code": {str(t, start, "user_code")}, "action": {"approve"}, "csrf": {sessionToken(t, fx, browser)}}) |
| + if status != http.StatusOK { |
| + t.Fatalf("approve = %d:\n%s", status, body) |
| + } |
| + for _, want := range []string{"Claude Code on box", `href="/"`, esc(copyText("cli.open_apps"))} { |
| + if !strings.Contains(body, want) { |
| + t.Fatalf("approved page missing %q:\n%s", want, body) |
| + } |
| + } |
| + if strings.Contains(body, "terminal") { |
| + t.Fatalf("approved page still says terminal:\n%s", body) |
| + } |
| +} |
| + |
| func TestCLILoginDeny(t *testing.T) { |
| fx := newConsoleFixture(t) |
| browser := newBrowser(t) |
diff --git a/internal/console/signincopy.go b/internal/console/signincopy.go| index 23410ec5d..3bd0dc990 100644 |
| --- a/internal/console/signincopy.go |
| +++ b/internal/console/signincopy.go |
| @@ -64,6 +64,10 @@ var agentLoginCopy = map[string]string{ |
| "cli.started_now": "Started just now.", |
| "cli.link_unknown": "That link's code has expired or was already used. Ask your agent to start the login again.", |
| "cli.signin_prompt": "Sign in to connect your agent or terminal.", |
| + "cli.approved": "Connected. Go back to {label}; it carries on by itself.", |
| + "cli.open_apps": "Open your apps", |
| + "cli.denied": "Nothing was issued. That sign-in can't be approved now; if it wasn't yours, whoever started it got nothing.", |
| + "cli.settings_link": "agents and terminals", |
| } |
| // copyText returns the approved string for id with each {key} placeholder |
diff --git a/internal/console/templates/cli_approve.html b/internal/console/templates/cli_approve.html| index 4f50330a4..fd3f150ab 100644 |
| --- a/internal/console/templates/cli_approve.html |
| +++ b/internal/console/templates/cli_approve.html |
| @@ -38,14 +38,10 @@ Keymail inbox the moment it is issued.</p> |
| {{define "cli_decided"}}{{template "top" .}} |
| <h1>{{.Title}}</h1> |
| {{if eq .Title "Approved"}} |
| -<p>Your terminal has the credential — it should say so within a couple of |
| -seconds. It expires in {{.Days}} days, and a note is on its way to your Keymail |
| -inbox.</p> |
| -<p><a href="/settings">See every terminal signed in as you</a>, and |
| -revoke any you don't recognise.</p> |
| +<p class="lede">{{.ApprovedText}}</p> |
| +<p><a href="/">{{.CLIText "cli.open_apps"}}</a></p> |
| {{else}} |
| -<p>Nothing was issued. That login attempt is dead and cannot be approved |
| -afterwards; if it wasn't yours, whoever started it got nothing.</p> |
| +<p>{{.CLIText "cli.denied"}}</p> |
| +<p><a href="/">{{.CLIText "cli.open_apps"}}</a></p> |
| {{end}} |
| -<p class="small"><a href="/">Back to the console</a></p> |
| {{template "bottom" .}}{{end}} |