Console: Running tab heading, Restart app and one toolbar row
The Instances tab heading is now Running, with "Restart app" as a small outlined button at the right of the heading row (same POST, CSRF field and owner check). The filter form becomes the shared .toolbar: one line of equal-height controls. "All" carries the unfiltered row count, and the leftover links and labels that named the tab now say Running (NAV-C10 to C16, added to navCopyBuilt).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
13 files changed,
+183
−20
internal/console/accountreview_test.go+1 −1internal/console/appnav_test.go+132 −0internal/console/approved_nav_copy_test.go+2 −0internal/console/browserrestart.go+2 −1internal/console/listquery.go+2 −1internal/console/listquery_test.go+16 −0internal/console/server_test.go+2 −2internal/console/templates/account_review.html+1 −1internal/console/templates/app_instance.html+1 −1internal/console/templates/app_instances.html+6 −6internal/console/templates/app_settings.html+1 −1internal/console/templates/fleet_byo.html+3 −3internal/console/templates/layout.html+14 −3
CI failed — run details
diff --git a/internal/console/accountreview_test.go b/internal/console/accountreview_test.go| index 67e5493e0..74d80d6f2 100644 |
| --- a/internal/console/accountreview_test.go |
| +++ b/internal/console/accountreview_test.go |
| @@ -229,7 +229,7 @@ func TestPublishedAppWithoutOwnedInstancesWarnsFromOwnedStateOnly(t *testing.T) |
| seedChannel(t, fx, "empty", "stable", "v1") |
| _, _, absentForeign := get(t, c, fx.u("/apps/empty")) |
| if !strings.Contains(absentForeign, `<p class="banner">`+approvedMismatchCopy.NoInstances) || |
| - !strings.Contains(absentForeign, `/apps/empty/instances">Instances</a>`) { |
| + !strings.Contains(absentForeign, `/apps/empty/instances">Running</a>`) { |
| t.Fatalf("published app with no owned instances lacks the warning and Instances link:\n%s", absentForeign) |
| } |
| _, _, settings := get(t, c, fx.u("/apps/empty/settings")) |
diff --git a/internal/console/appnav_test.go b/internal/console/appnav_test.go| index 1124990c6..c84779ca2 100644 |
| --- a/internal/console/appnav_test.go |
| +++ b/internal/console/appnav_test.go |
| @@ -1,10 +1,13 @@ |
| package console |
| import ( |
| + "fmt" |
| "reflect" |
| "regexp" |
| "strings" |
| "testing" |
| + |
| + "github.com/carlosframework/platform/internal/registry" |
| ) |
| var tabLinkRE = regexp.MustCompile(`(?s)<a\b([^>]*)>(.*?)</a>`) |
| @@ -70,3 +73,132 @@ func TestAppTabBarIsOneLevel(t *testing.T) { |
| } |
| } |
| } |
| + |
| +var ( |
| + cssCommentRE = regexp.MustCompile(`(?s)/\*.*?\*/`) |
| + cssRuleRE = regexp.MustCompile(`([^{}]+)\{([^{}]*)\}`) |
| + spacesRE = regexp.MustCompile(`\s+`) |
| +) |
| + |
| +// cssBlock returns the declarations of the first rule in the page's <style> |
| +// whose selector list equals selector exactly (whitespace-normalised). It |
| +// fails the test when there is none. |
| +func cssBlock(t *testing.T, body, selector string) string { |
| + t.Helper() |
| + _, rest, ok := strings.Cut(body, "<style>") |
| + if !ok { |
| + t.Fatal("no <style> in the page") |
| + } |
| + style, _, ok := strings.Cut(rest, "</style>") |
| + if !ok { |
| + t.Fatal("the <style> is never closed") |
| + } |
| + style = cssCommentRE.ReplaceAllString(style, "") |
| + for _, m := range cssRuleRE.FindAllStringSubmatch(style, -1) { |
| + if strings.TrimSpace(spacesRE.ReplaceAllString(m[1], " ")) == selector { |
| + return m[2] |
| + } |
| + } |
| + t.Fatalf("no CSS rule with selector %q", selector) |
| + return "" |
| +} |
| + |
| +func addKassWebRoutes(t *testing.T, fx *consoleFixture) { |
| + t.Helper() |
| + for _, h := range []string{"web-1.example.com", "web-2.example.com"} { |
| + fx.addRoute(t, registry.Route{Host: h, App: "kass", Account: fx.sqid, Kind: "instance", Status: "ready"}) |
| + } |
| +} |
| + |
| +func TestRunningTabHeadingAndToolbar(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + addKassWebRoutes(t, fx) |
| + c := signInPaul(t, fx) |
| + status, _, body := get(t, c, fx.u("/apps/kass/instances")) |
| + if status != 200 { |
| + t.Fatalf("GET /apps/kass/instances = %d", status) |
| + } |
| + if !strings.Contains(body, "<h2>Running</h2>") || strings.Contains(body, "<h2>Instances</h2>") { |
| + t.Errorf("the tab's heading is not Running:\n%s", body) |
| + } |
| + head := strings.Index(body, `<div class="sectionhead">`) |
| + tool := strings.Index(body, `<form method="get" class="toolbar">`) |
| + if head < 0 || tool < head { |
| + t.Fatalf("heading row at %d, toolbar at %d: want the heading row first", head, tool) |
| + } |
| + row := body[head:tool] |
| + want := `class="btn-sm btn-secondary">` + approvedBrowserRestartCopy.AppButton + `</button>` |
| + if !strings.Contains(row, want) { |
| + t.Errorf("the heading row lacks the secondary %q button:\n%s", approvedBrowserRestartCopy.AppButton, row) |
| + } |
| + for _, need := range []string{`method="post" action="` + fx.path("/apps/kass/restart") + `"`, `name="csrf"`} { |
| + if !strings.Contains(row, need) { |
| + t.Errorf("the heading row's restart form lacks %q:\n%s", need, row) |
| + } |
| + } |
| + form, _, _ := strings.Cut(body[tool:], "</form>") |
| + for _, need := range []string{`type="search"`, `name="channel"`, `type="checkbox"`, `<button type="submit" class="btn-sm">Filter</button>`} { |
| + if !strings.Contains(form, need) { |
| + t.Errorf("the toolbar lacks %q:\n%s", need, form) |
| + } |
| + } |
| + // The order inside the toolbar: search, channel, checkbox, Filter. |
| + last := -1 |
| + for _, need := range []string{`type="search"`, `name="channel"`, `type="checkbox"`, `>Filter</button>`} { |
| + i := strings.Index(form, need) |
| + if i < last { |
| + t.Errorf("toolbar order: %q comes too early", need) |
| + } |
| + last = i |
| + } |
| + total := strings.Count(body, `class="instance-address"`) |
| + if total < 2 { |
| + t.Fatalf("only %d instance rows rendered", total) |
| + } |
| + if !strings.Contains(body, fmt.Sprintf(">All %d", total)) && !strings.Contains(body, fmt.Sprintf("All %d\n", total)) { |
| + t.Errorf("the health line does not say All %d:\n%s", total, body) |
| + } |
| +} |
| + |
| +func TestToolbarStyle(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + c := signInPaul(t, fx) |
| + _, _, body := get(t, c, fx.u("/apps/kass/instances")) |
| + for _, d := range []string{"display: flex", "align-items: center", "flex-wrap: wrap"} { |
| + if got := cssBlock(t, body, ".toolbar"); !strings.Contains(got, d) { |
| + t.Errorf(".toolbar lacks %q: %s", d, got) |
| + } |
| + } |
| + if got := cssBlock(t, body, ".toolbar input, .toolbar select, .toolbar button"); !strings.Contains(got, "height: 2rem") { |
| + t.Errorf("toolbar controls lack height: 2rem: %s", got) |
| + } |
| + if strings.Contains(body, "form.listctl") { |
| + t.Error("the form.listctl rule is still in the page") |
| + } |
| +} |
| + |
| +func TestRunningLeftoversNameTheTab(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + var out strings.Builder |
| + p := page{Nav: "/a/bab", AppName: "shop", MismatchCopy: approvedMismatchCopy, AccountReview: AccountReview{NoInstances: true}} |
| + if err := templates.ExecuteTemplate(&out, "accountreviewbanner", p); err != nil { |
| + t.Fatal(err) |
| + } |
| + if !strings.Contains(out.String(), `/apps/shop/instances">Running</a>`) { |
| + t.Errorf("the banner's link does not say Running:\n%s", out.String()) |
| + } |
| + |
| + c := signInPaul(t, fx) |
| + _, _, byo := get(t, c, fx.u("/fleet/byo")) |
| + flat := strings.TrimSpace(spacesRE.ReplaceAllString(strings.ReplaceAll(strings.ReplaceAll(byo, "<code>", ""), "</code>", ""), " ")) |
| + const c16 = "The box appears on your fleet page within minutes. It reports in on a heartbeat, so the page does not update instantly. From there, place an app on it with carlos apps place, or in the app's Settings under Placement." |
| + if !strings.Contains(flat, c16) || strings.Contains(flat, "Instances tab") { |
| + t.Errorf("fleet/byo lacks the NAV-C16 text or still names the Instances tab:\n%s", flat) |
| + } |
| + |
| + addKassWebRoutes(t, fx) |
| + _, _, one := get(t, c, fx.u("/apps/kass/instances/web-1.example.com")) |
| + if !strings.Contains(one, ">Running</a>") { |
| + t.Errorf("the instance page's back link does not say Running:\n%s", one) |
| + } |
| +} |
diff --git a/internal/console/approved_nav_copy_test.go b/internal/console/approved_nav_copy_test.go| index f968fe07e..5a4c3552e 100644 |
| --- a/internal/console/approved_nav_copy_test.go |
| +++ b/internal/console/approved_nav_copy_test.go |
| @@ -29,6 +29,8 @@ var navCopyBuilt = map[string]bool{ |
| "NAV-C29": true, "NAV-C30": true, "NAV-C31": true, "NAV-C32": true, |
| "NAV-C33": true, "NAV-C34": true, "NAV-C35": true, "NAV-C36": true, |
| "NAV-C37": true, "NAV-C38": true, "NAV-C39": true, "NAV-C45": true, |
| + "NAV-C10": true, "NAV-C11": true, "NAV-C12": true, "NAV-C13": true, |
| + "NAV-C14": true, "NAV-C15": true, "NAV-C16": true, |
| } |
| type navCopyRow struct{ ID, Where, Old, New, CheckedBy, Status string } |
diff --git a/internal/console/browserrestart.go b/internal/console/browserrestart.go| index 287b89fc6..23a093c70 100644 |
| --- a/internal/console/browserrestart.go |
| +++ b/internal/console/browserrestart.go |
| @@ -14,7 +14,7 @@ import ( |
| type BrowserRestartCopy struct { |
| AppTitle, AppLine, HostTitle, HostLine string |
| - Button, Success, Audit string |
| + Button, AppButton, Success, Audit string |
| RateLimited, Failed string |
| } |
| @@ -24,6 +24,7 @@ var approvedBrowserRestartCopy = BrowserRestartCopy{ |
| HostTitle: "Restart {host}?", |
| HostLine: "Only {host} receives a restart request. If it is asleep, it remains asleep.", |
| Button: "Restart", |
| + AppButton: "Restart app", |
| Success: "Restart requested for {target}.", |
| Audit: "Restart requested for {target}.", |
| RateLimited: "Too many restart requests. Try again later.", |
diff --git a/internal/console/listquery.go b/internal/console/listquery.go| index 6ab7cfd42..2791e2048 100644 |
| --- a/internal/console/listquery.go |
| +++ b/internal/console/listquery.go |
| @@ -125,6 +125,7 @@ type instancePage struct { |
| Rows []InstanceRow |
| Matching []InstanceRow // rows matching Q+Health+Channel, across all pages |
| Counts map[string]int // health word -> count over ALL rows |
| + AllCount int // rows before any filter |
| Total int // rows matching Q+Health+Channel, across all pages |
| Links []healthLink // non-zero words, healthWords order |
| NextCursor string // "" on the last page |
| @@ -135,7 +136,7 @@ type instancePage struct { |
| // it) and cuts one page. Counts cover every row regardless of filter — the |
| // header's chips are the app's whole health story, and double as filters. |
| func pageInstanceRows(rows []InstanceRow, q instanceQuery, limit int) instancePage { |
| - p := instancePage{Counts: map[string]int{}} |
| + p := instancePage{Counts: map[string]int{}, AllCount: len(rows)} |
| var matched []InstanceRow |
| for _, r := range rows { |
| p.Counts[r.HealthWord]++ |
diff --git a/internal/console/listquery_test.go b/internal/console/listquery_test.go| index 32b245e2f..bde5c8681 100644 |
| --- a/internal/console/listquery_test.go |
| +++ b/internal/console/listquery_test.go |
| @@ -97,3 +97,19 @@ func TestParseInstanceQuery(t *testing.T) { |
| t.Fatalf("%+v", q) |
| } |
| } |
| + |
| +func TestInstancePageAllCountIsUnfiltered(t *testing.T) { |
| + rows := []InstanceRow{ |
| + {Host: "a.example.com", HealthWord: "Serving"}, |
| + {Host: "b.example.com", HealthWord: "Asleep"}, |
| + {Host: "c.example.com", HealthWord: "Asleep"}, |
| + } |
| + pg := pageInstanceRows(rows, instanceQuery{Health: "Asleep"}, 50) |
| + if pg.AllCount != 3 || pg.Total != 2 { |
| + t.Errorf("health filter: AllCount %d Total %d, want 3 and 2", pg.AllCount, pg.Total) |
| + } |
| + pg = pageInstanceRows(rows, instanceQuery{Q: "nomatch"}, 50) |
| + if pg.AllCount != 3 || pg.Total != 0 { |
| + t.Errorf("search filter: AllCount %d Total %d, want 3 and 0", pg.AllCount, pg.Total) |
| + } |
| +} |
diff --git a/internal/console/server_test.go b/internal/console/server_test.go| index 3da825bf6..46b256248 100644 |
| --- a/internal/console/server_test.go |
| +++ b/internal/console/server_test.go |
| @@ -1316,7 +1316,7 @@ func TestAppPageInstances(t *testing.T) { |
| Status: "ready", App: "kass"}) |
| _, _, body := get(t, c, fx.u("/apps/kass/instances")) |
| for _, want := range []string{ |
| - "<h2>Instances</h2>", "Reported by the app itself", "tracks its own internal workers", |
| + "<h2>Running</h2>", "Reported by the app itself", "tracks its own internal workers", |
| "riders-2026", "spring-camp", "trial-run", |
| "eu-west-1", "archived", "read-only since June", |
| } { |
| @@ -2194,7 +2194,7 @@ func TestAppPageOwnerMetricsCrossAccountAppName(t *testing.T) { |
| // the same "just the per-route metrics chrome" scope, at its new address. |
| func resourcesSection(t *testing.T, body string) string { |
| t.Helper() |
| - i := strings.Index(body, "<h2>Instances</h2>") |
| + i := strings.Index(body, "<h2>Running</h2>") |
| if i < 0 { |
| t.Fatalf("no Instances section in:\n%s", body) |
| } |
diff --git a/internal/console/templates/account_review.html b/internal/console/templates/account_review.html| index 717f81702..1af6e4d1f 100644 |
| --- a/internal/console/templates/account_review.html |
| +++ b/internal/console/templates/account_review.html |
| @@ -4,7 +4,7 @@ |
| </p> |
| {{else if .AccountReview.NoInstances}} |
| <p class="banner">{{.MismatchCopy.NoInstances}} |
| - <a href="{{.Nav}}/apps/{{.AppName}}/instances">Instances</a> |
| + <a href="{{.Nav}}/apps/{{.AppName}}/instances">Running</a> |
| </p> |
| {{end}}{{end}} |
diff --git a/internal/console/templates/app_instance.html b/internal/console/templates/app_instance.html| index 39b2d37fb..9eb892327 100644 |
| --- a/internal/console/templates/app_instance.html |
| +++ b/internal/console/templates/app_instance.html |
| @@ -2,7 +2,7 @@ |
| {{if .Flash}}<p class="banner">{{.Flash}}</p>{{end}} |
| {{if .FlashErr}}<p class="banner error">{{.FlashErr}}</p>{{end}} |
| {{template "appnav" .}} |
| -<p><a href="{{.InstanceListURL}}">Instances</a></p> |
| +<p><a href="{{.InstanceListURL}}">Running</a></p> |
| {{with .InstanceDetail}} |
| <h2 class="instance-address">{{.Row.Host}} <a class="instance-open" href="https://{{.Row.Host}}" aria-label="{{$.InstanceCopy.Open}} {{.Row.Host}}">{{icon "external-link"}}</a></h2> |
| <p><a href="{{$.Nav}}/apps/{{$.AppName}}/logs?host={{.Row.Host}}">Logs</a></p> |
diff --git a/internal/console/templates/app_instances.html b/internal/console/templates/app_instances.html| index b3904fcbb..012c89c6f 100644 |
| --- a/internal/console/templates/app_instances.html |
| +++ b/internal/console/templates/app_instances.html |
| @@ -3,13 +3,13 @@ |
| {{if .FlashErr}}<p class="banner error">{{.FlashErr}}</p>{{end}} |
| {{template "appnav" .}} |
| -<h2>Instances</h2> |
| +<div class="sectionhead"><h2>Running</h2> |
| {{if .CanRestartApp}}<form method="post" action="{{.Base}}/apps/{{.AppName}}/restart" class="inline"> |
| <input type="hidden" name="csrf" value="{{.CSRF}}"> |
| - <button type="submit" class="btn-sm">{{.BrowserRestartCopy.Button}}</button> |
| -</form>{{end}} |
| + <button type="submit" class="btn-sm btn-secondary">{{.BrowserRestartCopy.AppButton}}</button> |
| +</form>{{end}}</div> |
| {{if or .InstanceRows .InstanceQuery.Q .InstanceQuery.Health .InstanceQuery.Channel}} |
| -<form method="get" class="listctl"> |
| +<form method="get" class="toolbar"> |
| <input type="search" name="q" value="{{.InstanceQuery.Q}}" placeholder="Filter addresses" aria-label="Filter addresses"> |
| {{if .InstanceQuery.Health}}<input type="hidden" name="health" value="{{healthSlug .InstanceQuery.Health}}">{{end}} |
| <label class="visually-hidden" for="instance-channel">Channel</label> |
| @@ -19,10 +19,10 @@ |
| {{range .InstanceChannels}}<option value="{{.}}"{{if eq . $.InstanceQuery.Channel}} selected{{end}}>{{.}}</option>{{end}} |
| </select> |
| <label><input type="checkbox" name="group" value="channel"{{if .InstanceQuery.Group}} checked{{end}}> {{.InstanceCopy.GroupChannel}}</label> |
| - <button>Filter</button> |
| + <button type="submit" class="btn-sm">Filter</button> |
| </form> |
| <p class="small"> |
| - <a href="{{.InstanceAllURL}}"{{if not .InstanceQuery.Health}} aria-current="true"{{end}}>All</a> |
| + <a href="{{.InstanceAllURL}}"{{if not .InstanceQuery.Health}} aria-current="true"{{end}}>All {{.InstancePage.AllCount}}</a> |
| {{range .InstancePage.Links}} |
| · <a href="{{.URL}}"{{if .Active}} aria-current="true"{{end}}>{{.Word}} {{.Count}}</a> |
| {{end}} |
diff --git a/internal/console/templates/app_settings.html b/internal/console/templates/app_settings.html| index 97a22592c..32246a70a 100644 |
| --- a/internal/console/templates/app_settings.html |
| +++ b/internal/console/templates/app_settings.html |
| @@ -199,7 +199,7 @@ the operator path is <code>console migrate-app --app {{.Detail.App}} --to |
| {{end}} |
| {{else if .AccountReview.NoInstances}} |
| <h2>Account</h2> |
| -<p>{{.MismatchCopy.NoInstances}} <a href="{{.Nav}}/apps/{{.Detail.App}}/instances">Instances</a></p> |
| +<p>{{.MismatchCopy.NoInstances}} <a href="{{.Nav}}/apps/{{.Detail.App}}/instances">Running</a></p> |
| {{else}}{{if .IsOwner}} |
| <h2>Account</h2> |
| <p class="small">This app deploys from {{.Account.Name}}. Moving an app to a |
diff --git a/internal/console/templates/fleet_byo.html b/internal/console/templates/fleet_byo.html| index ddd0339e1..daf5eb678 100644 |
| --- a/internal/console/templates/fleet_byo.html |
| +++ b/internal/console/templates/fleet_byo.html |
| @@ -72,7 +72,7 @@ choice.</p> |
| </ul> |
| <h2>Then</h2> |
| -<p>The box appears on your fleet page within minutes — it self-reports on a heartbeat cadence, not |
| -instantly. From there, place an app on it with <code>carlos apps place</code> or from the app's |
| -Instances tab.</p> |
| +<p>The box appears on your fleet page within minutes. It reports in on a heartbeat, so the page does |
| +not update instantly. From there, place an app on it with <code>carlos apps place</code>, or in the |
| +app's Settings under Placement.</p> |
| {{template "bottom" .}}{{end}} |
diff --git a/internal/console/templates/layout.html b/internal/console/templates/layout.html| index 04f12d4a9..f59b4c695 100644 |
| --- a/internal/console/templates/layout.html |
| +++ b/internal/console/templates/layout.html |
| @@ -53,9 +53,16 @@ |
| it must not break the line it is part of. */ |
| form.inline { display: inline; margin: 0; } |
| form.inline button { vertical-align: baseline; } |
| - /* A list's filter row (the Running tab): its control and its button on one |
| - line, wrapping onto the next when the screen is too narrow for both. */ |
| - form.listctl { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 0 0 0.6rem; } |
| + /* A list's filter row (the Running tab): every control the same height on |
| + one line, wrapping onto the next when the screen is too narrow. */ |
| + .toolbar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0 0 0.6rem; } |
| + .toolbar input, .toolbar select, .toolbar button { height: 2rem; margin: 0; } |
| + /* economics_accounts.html (a frozen operator page) still says listctl. */ |
| + .listctl { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 0 0 0.6rem; } |
| + .toolbar label { display: inline-flex; align-items: center; gap: 0.35rem; } |
| + /* A section heading with its one action at the right end of the row. */ |
| + .sectionhead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 2rem 0 0.75rem; } |
| + .sectionhead h2 { margin: 0; } |
| /* Interface icons: inline SVG from internal/console/icons.go — Lucide, |
| vendored, because this page fetches nothing from anywhere. They carry no |
| width/height of their own, so they size to the text beside them and |
| @@ -439,6 +446,10 @@ |
| .btn-sm, button.btn-sm { |
| font-size: 0.85rem; padding: 0.35rem 0.8rem; border-radius: 0.4rem; |
| } |
| + .btn-secondary, button.btn-secondary { |
| + background: transparent; color: var(--accent); border: 1px solid var(--rule); |
| + } |
| + .btn-secondary:hover, button.btn-secondary:hover:not(.linkish) { background: var(--accent-soft); } |
| button.btn-danger, .btn-danger { background: var(--bad); color: var(--bg); } |
| button.btn-danger:hover, .btn-danger:hover { background: var(--bad); filter: brightness(0.9); } |
| /* The Instances table's in-cell readings: number first, then the 48h |