The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
auth: add a Go to dashboard button to the sign-in success page
Claude7d7e739a6424
diff --git a/cli/beacon/internal/account/login.go b/cli/beacon/internal/account/login.goindex 74a06f1e..13da25f8 100644--- a/cli/beacon/internal/account/login.go+++ b/cli/beacon/internal/account/login.go@@ -176,6 +176,7 @@ func Login(ctx context.Context, opts LoginOptions) (*Session, error) {return nil, err}callback.SetSuccessPage("Signed in to Beacon", "Return to your terminal to finish setting up this machine.")+ callback.SetSuccessLink("Go to dashboard", baseURL)defer callback.Shutdown()callback.Start()diff --git a/cli/beacon/internal/auth/auth_test.go b/cli/beacon/internal/auth/auth_test.goindex fc60802b..ebd84824 100644--- a/cli/beacon/internal/auth/auth_test.go+++ b/cli/beacon/internal/auth/auth_test.go@@ -275,3 +275,20 @@ func TestCallbackServerAcceptsABarePastedCode(t *testing.T) {t.Fatalf("exchange got code=%q state=%q", gotCode, gotState)}}++func TestCallbackServerSuccessPageLinksToTheDashboard(t *testing.T) {+ cs, err := NewCallbackServer("s", "v", func(context.Context, string, string, string) error { return nil }, 0)+ if err != nil {+ t.Fatal(err)+ }+ defer cs.listener.Close()+ if strings.Contains(cs.successHTML(), "<a ") {+ t.Fatalf("no link expected unless one is set: %s", cs.successHTML())+ }++ cs.SetSuccessLink("Go to dashboard", `https://beacon.example/?a=1&b="2"`)+ want := `<a class="button" href="https://beacon.example/?a=1&b="2"">Go to dashboard</a>`+ if page := cs.successHTML(); !strings.Contains(page, want) {+ t.Fatalf("success page should contain %s, got %s", want, page)+ }+}diff --git a/cli/beacon/internal/auth/server.go b/cli/beacon/internal/auth/server.goindex 4e62b54e..e3332373 100644--- a/cli/beacon/internal/auth/server.go+++ b/cli/beacon/internal/auth/server.go@@ -49,6 +49,8 @@ type CallbackServer struct {exchange ExchangeFuncsuccessTitle stringsuccessBody string+ successLabel string+ successHref string}// NewCallbackServer binds the loopback listener. exchangeTimeout should match the@@ -96,6 +98,13 @@ func (cs *CallbackServer) SetSuccessPage(title, body string) {}}+// SetSuccessLink adds a button to the success page, so the browser tab is not a+// dead end. The caller supplies a trusted https URL.+func (cs *CallbackServer) SetSuccessLink(label, href string) {+ cs.successLabel = label+ cs.successHref = href+}+// Port is the ephemeral loopback port the dashboard must redirect to.func (cs *CallbackServer) Port() int {return cs.port@@ -266,10 +275,12 @@ func (cs *CallbackServer) sendResponse(w http.ResponseWriter, success bool, errofunc (cs *CallbackServer) successHTML() string {return renderCallbackPage(callbackPage{- Title: cs.successTitle,- Heading: cs.successTitle,- Lead: cs.successBody,- Note: "You can close this tab.",+ Title: cs.successTitle,+ Heading: cs.successTitle,+ Lead: cs.successBody,+ Note: "You can close this tab.",+ Link: cs.successHref,+ LinkLabel: cs.successLabel,})}@@ -279,6 +290,9 @@ type callbackPage struct {Lead stringNote stringFailed bool+ // Link and LinkLabel render a button under the lead when both are set.+ Link string+ LinkLabel string}// renderCallbackPage draws the one page a browser ever sees from the CLI.@@ -291,6 +305,10 @@ func renderCallbackPage(p callbackPage) string {if p.Failed {accent = "#e5484d"}+ var button string+ if p.Link != "" && p.LinkLabel != "" {+ button = fmt.Sprintf(`<p><a class="button" href="%s">%s</a></p>`, html.EscapeString(p.Link), html.EscapeString(p.LinkLabel))+ }var footer strings.Builderif p.Note != "" {fmt.Fprintf(&footer, `<p class="note">%s</p>`, html.EscapeString(p.Note))@@ -319,6 +337,10 @@ func renderCallbackPage(p callbackPage) string {.lead { margin: 0; color: #a8a8b3; }.note { margin: 28px 0 0; font-size: 13px; color: #74747f; }a { color: %s; }+ .button {+ display: inline-block; margin-top: 24px; padding: 10px 20px; border-radius: 8px;+ background: %s; color: #fff; font-weight: 600; text-decoration: none;+ }@media (prefers-color-scheme: light) {body { background: #fbfbfd; color: #16161a; }.brand { color: #16161a; }@@ -338,8 +360,9 @@ func renderCallbackPage(p callbackPage) string {<h1>%s</h1><p class="lead">%s</p>%s+ %s</main></body>-</html>`, html.EscapeString(p.Title), accent,- html.EscapeString(p.Heading), html.EscapeString(p.Lead), footer.String())+</html>`, html.EscapeString(p.Title), accent, accent,+ html.EscapeString(p.Heading), html.EscapeString(p.Lead), button, footer.String())}