carlos / platform Public

console: getting started domain link names the first live app

The owner's Attach a domain link now targets the first live app in page
order (starred, regular, temporary), falling back to the first app.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev ce59a4abe3685c09a682dc9fbe9a70fcc68f26c8 parent c3027f1
4 files changed, +84 −20
  • internal/console/gettingstarted.go +27 −17
  • internal/console/gettingstarted_page_test.go +30 −0
  • internal/console/gettingstarted_test.go +21 −0
  • internal/console/server.go +6 −3

Intent

Attributed to this commit: 66.1 g CO₂e (1,352,432 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-first-run-next-steps, 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/gettingstarted.go b/internal/console/gettingstarted.go
index 30bc75eca..a129c0496 100644
--- a/internal/console/gettingstarted.go
+++ b/internal/console/gettingstarted.go
@@ -85,7 +85,7 @@ type gettingStartedView struct {
// buildGettingStarted returns the card, or nil when the person hid it or it
// already completed. complete is true when every step is done or skipped.
-func buildGettingStarted(marks map[gsMark]bool, connected, anyLive bool, role string, firstApp string, consoleName string) (view *gettingStartedView, complete bool) {
+func buildGettingStarted(marks map[gsMark]bool, connected, anyLive bool, role string, domainApp string, consoleName string) (view *gettingStartedView, complete bool) {
if marks[gsHidden] || marks[gsCompleted] {
return nil, false
}
@@ -131,17 +131,17 @@ func buildGettingStarted(marks map[gsMark]bool, connected, anyLive bool, role st
Steps: steps,
CanCreate: role == RoleOwner || role == RoleMember,
IsOwner: role == RoleOwner,
- DomainApp: firstApp,
+ DomainApp: domainApp,
Copy: c,
}, false
}
// fillGettingStarted puts the Getting started card on the account home.
-// anyLive is appIsLive over every app in the account, not the filtered
-// lists. Only console-database reads: no bucket call. A failed read never
-// fails the page: unread tokens leave step 1 open, unread marks show no
-// card and no Show link.
-func (s *Server) fillGettingStarted(p *page, acct *Account, addr, role string, anyLive bool) {
+// live is the apps appIsLive calls live, over every app in the account,
+// not the filtered lists. Only console-database reads: no bucket call. A
+// failed read never fails the page: unread tokens leave step 1 open,
+// unread marks show no card and no Show link.
+func (s *Server) fillGettingStarted(p *page, acct *Account, addr, role string, live map[string]bool) {
now := time.Now()
connected := false
if tokens, err := s.store.CLITokens(addr); err != nil {
@@ -154,16 +154,8 @@ func (s *Server) fillGettingStarted(p *page, acct *Account, addr, role string, a
log.Printf("console: getting started marks %s: %v", acct.Sqid, err)
return
}
- // The domain link names the first app the page lists.
- firstApp := ""
- starred, regular, temporary := partitionApps(p.Apps)
- for _, rows := range [][]appRow{starred, regular, temporary} {
- if len(rows) > 0 {
- firstApp = rows[0].App
- break
- }
- }
- view, complete := buildGettingStarted(marks, connected, anyLive, role, firstApp, s.consoleName())
+ anyLive := len(live) > 0
+ view, complete := buildGettingStarted(marks, connected, anyLive, role, gsDomainApp(p.Apps, live), s.consoleName())
if complete {
if s.gsBeforeCompleteHook != nil {
s.gsBeforeCompleteHook()
@@ -181,6 +173,24 @@ func (s *Server) fillGettingStarted(p *page, acct *Account, addr, role string, a
p.ShowGettingStarted = view == nil
}
+// gsDomainApp is the app the domain link names: the first live app in the
+// page's order (starred, regular, temporary), else the first app, else "".
+func gsDomainApp(apps []appRow, live map[string]bool) string {
+ starred, regular, temporary := partitionApps(apps)
+ first := ""
+ for _, rows := range [][]appRow{starred, regular, temporary} {
+ for _, r := range rows {
+ if live[r.App] {
+ return r.App
+ }
+ if first == "" {
+ first = r.App
+ }
+ }
+ }
+ return first
+}
+
// GettingStartedCopy is the card's strings, for the Show link the page
// offers when there is no card to carry them.
func (p page) GettingStartedCopy() gettingStartedCopy { return approvedGettingStartedCopy }
diff --git a/internal/console/gettingstarted_page_test.go b/internal/console/gettingstarted_page_test.go
index e52fd4b00..a27e399df 100644
--- a/internal/console/gettingstarted_page_test.go
+++ b/internal/console/gettingstarted_page_test.go
@@ -286,6 +286,36 @@ func TestGettingStartedMemberNoDomainLink(t *testing.T) {
}
}
+// The owner's domain link names the first live app the page lists, not
+// merely the first app: kass comes first but has failed, so the link goes
+// to the static site that is live.
+func TestGettingStartedDomainLinkFirstLiveApp(t *testing.T) {
+ fx := newConsoleFixture(t)
+ reg, err := registry.Open(fx.regPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := reg.Upsert(registry.Route{Host: "kass.carlosapp.dev", Kind: "instance", Status: "failed",
+ Version: "v1", App: "kass", Channel: "stable", Addr: "127.0.0.1:9001"}); err != nil {
+ t.Fatal(err)
+ }
+ reg.Close()
+ gsStaticSite(t, fx, "site")
+ cliToken(t, fx, "paul@keymail.dev", "code-gs-live-dom-cli")
+ paul, _ := signInAs(t, fx, "paul@keymail.dev", "code-gs-live-dom")
+ if err := fx.st.SetGettingStartedMark(OpsAccountID, "paul@keymail.dev", gsSecretsSkip, time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ body := gsHome(t, fx, paul, "")
+ if got := gsRenderedState(body, "domain"); got != "open" {
+ t.Fatalf("domain = %q, want open", got)
+ }
+ card := gsCard(t, body)
+ if !strings.Contains(card, fx.path("/apps/site/settings/domains")) || strings.Contains(card, fx.path("/apps/kass/settings/domains")) {
+ t.Fatalf("domain link does not name the first live app:\n%s", card)
+ }
+}
+
// The card reads only the console database: rendering it costs no S3
// request beyond what the page already makes.
func TestGettingStartedNoS3(t *testing.T) {
diff --git a/internal/console/gettingstarted_test.go b/internal/console/gettingstarted_test.go
index 3e29e4c0c..2374b086f 100644
--- a/internal/console/gettingstarted_test.go
+++ b/internal/console/gettingstarted_test.go
@@ -170,3 +170,24 @@ func TestBuildGettingStarted(t *testing.T) {
t.Errorf("copy: %+v", v.Copy)
}
}
+
+func TestGettingStartedDomainAppOrder(t *testing.T) {
+ apps := []appRow{{App: "b"}, {App: "a", Starred: true}, {App: "c"}, {App: "t", ExpiresAt: time.Now()}}
+ for _, c := range []struct {
+ live map[string]bool
+ want string
+ }{
+ {nil, "a"},
+ {map[string]bool{"c": true}, "c"},
+ {map[string]bool{"c": true, "b": true}, "b"},
+ {map[string]bool{"t": true}, "t"},
+ {map[string]bool{"a": true, "b": true}, "a"},
+ } {
+ if got := gsDomainApp(apps, c.live); got != c.want {
+ t.Errorf("live %v: got %q want %q", c.live, got, c.want)
+ }
+ }
+ if got := gsDomainApp(nil, nil); got != "" {
+ t.Errorf("no apps: %q", got)
+ }
+}
diff --git a/internal/console/server.go b/internal/console/server.go
index c014d759f..c32ce1595 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -4276,7 +4276,8 @@ func (s *Server) handleAccountHome(w http.ResponseWriter, r *http.Request) {
s.renderMessage(w, r, http.StatusInternalServerError, "Error", "Could not read your apps. Please try again.")
return
}
- anyLive := false
+ // live is the apps appIsLive calls live, over every app.
+ live := map[string]bool{}
if len(apps) > 0 {
views, err := s.assembleAppsNamed(r.Context(), acct.Sqid, acct.Name, apps)
if err != nil {
@@ -4291,7 +4292,9 @@ func (s *Server) handleAccountHome(w http.ResponseWriter, r *http.Request) {
row.Elsewhere = elsewhereCounts(v.Routes, acct.Sqid, row.Region)
p.Apps = append(p.Apps, row)
// Over every app, before the q filter narrows the lists.
- anyLive = anyLive || appIsLive(row, v, acct.Sqid)
+ if appIsLive(row, v, acct.Sqid) {
+ live[v.App] = true
+ }
}
// The viewer's stars, the expiries and the q filter (applist.go).
if err := s.fillAppLists(&p, acct, addr, r.URL.Query().Get("q")); err != nil {
@@ -4307,7 +4310,7 @@ func (s *Server) handleAccountHome(w http.ResponseWriter, r *http.Request) {
} else {
p.TrashN = len(trashed)
}
- s.fillGettingStarted(&p, acct, addr, role, anyLive)
+ s.fillGettingStarted(&p, acct, addr, role, live)
s.render(w, http.StatusOK, "apps", p)
}