carlos / platform Public

Console: Placement moves from Running to Settings

"Where this app runs" and the owner's Move form now live at
/settings/placement (nav item NAV-C40, after Domains). POST /place keeps
its path, gates and behaviour; its flash redirects come back to the new
section. The region line stays on Running, under the toolbar. The perf
walk reaches /settings/placement through appSettingsSections; it costs
what its sibling sections do, under their existing over record.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev bcfef0ad3291c31a55f2deb59fc6d865059fa0c9 parent 4fa9c2b
9 files changed, +107 −70
  • internal/console/approved_nav_copy_test.go +2 −1
  • internal/console/appsettings.go +1 −0
  • internal/console/appsettings_sections_test.go +2 −2
  • internal/console/fleets.go +22 −7
  • internal/console/fleets_test.go +52 −27
  • internal/console/lifetimes_read_test.go +1 −1
  • internal/console/server.go +5 −11
  • internal/console/templates/app_instances.html +2 −21
  • internal/console/templates/app_settings.html +20 −0

CI failed — run details

diff --git a/internal/console/approved_nav_copy_test.go b/internal/console/approved_nav_copy_test.go
index 5a4c3552e..98f9a17bc 100644
--- a/internal/console/approved_nav_copy_test.go
+++ b/internal/console/approved_nav_copy_test.go
@@ -28,7 +28,8 @@ var navCopyBuilt = map[string]bool{
"NAV-C25": true, "NAV-C26": true, "NAV-C27": true, "NAV-C28": true,
"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-C37": true, "NAV-C38": true, "NAV-C39": true, "NAV-C40": 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,
}
diff --git a/internal/console/appsettings.go b/internal/console/appsettings.go
index 2a99d45a3..f40993a3b 100644
--- a/internal/console/appsettings.go
+++ b/internal/console/appsettings.go
@@ -56,6 +56,7 @@ import (
var appSettingsSections = map[string]bool{
"general": true,
"domains": true,
+ "placement": true,
"pipeline": true,
"environments": true,
"storage": true,
diff --git a/internal/console/appsettings_sections_test.go b/internal/console/appsettings_sections_test.go
index 2e7369847..b7808c511 100644
--- a/internal/console/appsettings_sections_test.go
+++ b/internal/console/appsettings_sections_test.go
@@ -13,7 +13,7 @@ func TestAppSettingsSectionRoutes(t *testing.T) {
c := newBrowser(t)
signUp(t, fx, c, "code-settings-sections-browser")
- for _, section := range []string{"general", "domains", "storage", "email", "features", "advanced", "delete"} {
+ for _, section := range []string{"general", "domains", "placement", "storage", "email", "features", "advanced", "delete"} {
status, _, body := get(t, c, fx.u("/apps/titogo/settings/"+section))
if status != http.StatusOK {
t.Errorf("GET settings/%s = %d, want 200: %s", section, status, body)
@@ -21,7 +21,7 @@ func TestAppSettingsSectionRoutes(t *testing.T) {
}
_, _, general := get(t, c, fx.u("/apps/titogo/settings"))
for _, want := range []string{
- `aria-label="Settings sections"`, ">General</a>", ">Domains</a>",
+ `aria-label="Settings sections"`, ">General</a>", ">Domains</a>", ">Placement</a>",
">Release pipeline</a>", ">Storage</a>", ">Email</a>",
">Feature flags</a>", ">Advanced</a>", ">Delete</a>",
} {
diff --git a/internal/console/fleets.go b/internal/console/fleets.go
index 6eff34aff..57884877e 100644
--- a/internal/console/fleets.go
+++ b/internal/console/fleets.go
@@ -526,7 +526,7 @@ const placeInstancesFailed = "could not update this app's instances — try agai
// flat, cross-account namespace (see this file's package doc comment).
//
// Every door onto placement calls this — the CLI API's handleAPIPlace, the
-// app Instances tab's handleAppPlace, the fleet page's
+// app Settings Placement section's handleAppPlace, the fleet page's
// handleFleetPlacePage — because the ordering discipline below is the whole
// correctness of the operation, and a second copy of it is a second place
// for it to be got wrong. Callers own authentication, the app-ownership
@@ -778,8 +778,10 @@ func placeFlash(app, target, suffix string) (flash, detail string) {
return app + " is now placed on " + target + ".", "placed " + app + " on " + target + " " + suffix
}
-// handleAppPlace answers the Placement form on an app's Instances tab: move
-// THIS app onto one of the account's fleets, or back to the shared one.
+// handleAppPlace answers the Placement form in an app's Settings
+// (/settings/placement): move THIS app onto one of the account's fleets, or
+// back to the shared one. Every outcome but the cross-account 404 and a
+// claim-accepted answer comes back to that section with a flash.
//
// The gate skeleton is handleAppRename's, deliberately — accountApp, then
// CSRF, then owner (a member gets the byte-identical 404, never a 403 that
@@ -803,8 +805,7 @@ func (s *Server) handleAppPlace(w http.ResponseWriter, r *http.Request) {
}
back := func(kind, msg string) {
s.setFlash(w, kind, msg)
- http.Redirect(w, r, "/a/"+url.PathEscape(acct.Sqid)+"/apps/"+url.PathEscape(app)+"/instances",
- http.StatusSeeOther)
+ http.Redirect(w, r, appSettingsURL(acct.Sqid, app, "placement"), http.StatusSeeOther)
}
target := strings.TrimSpace(r.FormValue("target"))
switch status, msg := s.placeAppTarget(r.Context(), acct, app, target); {
@@ -872,8 +873,22 @@ func (s *Server) handleFleetPlacePage(w http.ResponseWriter, r *http.Request) {
back("ok", flash)
}
-// appPlacementSection reads the app Instances tab's Placement section: where
-// this app runs now, and every fleet the account owns to offer as somewhere
+// populateAppPlacement fills the Settings Placement section: where this app
+// runs, and where else it could. Soft like the rest of Settings — a failed
+// read costs the section's certainty (AppPlacementKnown) and a flash, never
+// the page.
+func (s *Server) populateAppPlacement(p *page, acct *Account) {
+ placement, fleets, known, warn := s.appPlacementSection(acct, p.AppName)
+ p.AppPlacement = placement
+ p.OwnedFleetNames = fleets
+ p.AppPlacementKnown = known
+ if warn != "" && p.FlashErr == "" {
+ p.FlashErr = warn
+ }
+}
+
+// appPlacementSection reads the app Settings' Placement section: where this
+// app runs now, and every fleet the account owns to offer as somewhere
// else it could.
//
// known is the section's twin of sharedFleetCard.PlacementKnown and exists
diff --git a/internal/console/fleets_test.go b/internal/console/fleets_test.go
index 37e3d2b54..afd7e0073 100644
--- a/internal/console/fleets_test.go
+++ b/internal/console/fleets_test.go
@@ -1241,10 +1241,10 @@ func assertPlacement(t *testing.T, fx *consoleFixture, want string) {
}
}
-// TestAppPlacePageMovesAndClears: the owner's Placement form on the app's
-// Instances tab stamps routes AND records (placeAppTarget's whole job) and
-// comes back to the tab with a flash saying what happened — then clears the
-// same way, which is a MOVE BACK to the shared fleet, not a no-op.
+// TestAppPlacePageMovesAndClears: the owner's Placement form in the app's
+// Settings stamps routes AND records (placeAppTarget's whole job) and comes
+// back to the Placement section with a flash saying what happened — then
+// clears the same way, which is a MOVE BACK to the shared fleet, not a no-op.
func TestAppPlacePageMovesAndClears(t *testing.T) {
fx, _ := placeFixture(t, "code-appplace-move")
c := newBrowser(t)
@@ -1253,26 +1253,38 @@ func TestAppPlacePageMovesAndClears(t *testing.T) {
status, loc, _ := postForm(t, c, fx.u("/apps/titogo/place"),
url.Values{"csrf": {csrf}, "target": {"fleet/pi"}})
- if status != http.StatusSeeOther || loc != fx.path("/apps/titogo/instances") {
- t.Fatalf("place = %d -> %q, want 303 -> %q", status, loc, fx.path("/apps/titogo/instances"))
+ if status != http.StatusSeeOther || loc != fx.path("/apps/titogo/settings/placement") {
+ t.Fatalf("place = %d -> %q, want 303 -> %q", status, loc, fx.path("/apps/titogo/settings/placement"))
}
assertPlacement(t, fx, "fleet/pi")
- _, _, body := get(t, c, fx.u("/apps/titogo/instances"))
+ _, _, body := get(t, c, fx.u("/apps/titogo/settings/placement"))
if !strings.Contains(body, "placed on fleet/pi") {
t.Fatalf("no placed flash after the redirect:\n%s", body)
}
status, loc, _ = postForm(t, c, fx.u("/apps/titogo/place"),
url.Values{"csrf": {csrf}, "target": {""}})
- if status != http.StatusSeeOther || loc != fx.path("/apps/titogo/instances") {
- t.Fatalf("clear = %d -> %q, want 303 -> %q", status, loc, fx.path("/apps/titogo/instances"))
+ if status != http.StatusSeeOther || loc != fx.path("/apps/titogo/settings/placement") {
+ t.Fatalf("clear = %d -> %q, want 303 -> %q", status, loc, fx.path("/apps/titogo/settings/placement"))
}
assertPlacement(t, fx, "")
- _, _, body = get(t, c, fx.u("/apps/titogo/instances"))
+ _, _, body = get(t, c, fx.u("/apps/titogo/settings/placement"))
if !strings.Contains(body, "back on the shared fleet") {
t.Fatalf("no cleared flash after the redirect:\n%s", body)
}
+
+ // A refusal comes back to the same section, its reason in the flash.
+ status, loc, _ = postForm(t, c, fx.u("/apps/titogo/place"),
+ url.Values{"csrf": {csrf}, "target": {"not-a-target"}})
+ if status != http.StatusSeeOther || loc != fx.path("/apps/titogo/settings/placement") {
+ t.Fatalf("refused place = %d -> %q, want 303 -> %q", status, loc, fx.path("/apps/titogo/settings/placement"))
+ }
+ assertPlacement(t, fx, "")
+ _, _, body = get(t, c, fx.u("/apps/titogo/settings/placement"))
+ if !strings.Contains(body, "invalid target") {
+ t.Fatalf("no refusal flash after the redirect:\n%s", body)
+ }
}
// TestAppPlacePageMemberRefused: placement is an owner act. A plain member
@@ -1345,20 +1357,20 @@ func TestAppPlacePageForeignFleetIsIdenticalNotFound(t *testing.T) {
assertPlacement(t, fx, "")
}
-// TestAppInstancesPlacementSection: the tab states where the app runs for
-// everyone, and offers the move only to the owner — with the
-// data-does-not-move warning beside the form, because "move" is the one word
-// a customer could reasonably read as "take my data with it".
-func TestAppInstancesPlacementSection(t *testing.T) {
+// TestAppSettingsPlacementSection: the Settings Placement section states
+// where the app runs for everyone, and offers the move only to the owner —
+// with the data-does-not-move warning beside the form, because "move" is the
+// one word a customer could reasonably read as "take my data with it".
+func TestAppSettingsPlacementSection(t *testing.T) {
fx, _ := placeFixture(t, "code-appplace-section")
if err := fx.st.AddMember(OpsAccountID, "sam@keymail.dev", RoleMember, time.Now()); err != nil {
t.Fatal(err)
}
owner := newBrowser(t)
signUp(t, fx, owner, "code-appplace-section-owner")
- st, _, body := get(t, owner, fx.u("/apps/titogo/instances"))
+ st, _, body := get(t, owner, fx.u("/apps/titogo/settings/placement"))
if st != http.StatusOK {
- t.Fatalf("GET instances = %d:\n%s", st, body)
+ t.Fatalf("GET settings/placement = %d:\n%s", st, body)
}
for _, want := range []string{
"<h2>Placement</h2>",
@@ -1372,41 +1384,54 @@ func TestAppInstancesPlacementSection(t *testing.T) {
"hibernated instance state stays in the old placement",
} {
if !strings.Contains(body, want) {
- t.Fatalf("owner instances tab missing %q in:\n%s", want, body)
+ t.Fatalf("owner placement section missing %q in:\n%s", want, body)
+ }
+ }
+
+ // Running no longer carries the section or its form: Placement lives in
+ // Settings now, and one place to move an app is the point.
+ st, _, running := get(t, owner, fx.u("/apps/titogo/instances"))
+ if st != http.StatusOK {
+ t.Fatalf("GET instances = %d:\n%s", st, running)
+ }
+ for _, gone := range []string{"<h2>Placement</h2>", fx.path("/apps/titogo/place")} {
+ if strings.Contains(running, gone) {
+ t.Fatalf("Running tab still carries %q:\n%s", gone, running)
}
}
fx.setUser("sam@keymail.dev")
member := newBrowser(t)
signUp(t, fx, member, "code-appplace-section-member")
- st, _, memberBody := get(t, member, fx.u("/apps/titogo/instances"))
+ st, _, memberBody := get(t, member, fx.u("/apps/titogo/settings/placement"))
if st != http.StatusOK {
- t.Fatalf("member GET instances = %d:\n%s", st, memberBody)
+ t.Fatalf("member GET settings/placement = %d:\n%s", st, memberBody)
}
if !strings.Contains(memberBody, "This app runs on the shared fleet.") {
- t.Fatalf("member instances tab lost the placement statement:\n%s", memberBody)
+ t.Fatalf("member placement section lost the placement statement:\n%s", memberBody)
}
if strings.Contains(memberBody, fx.path("/apps/titogo/place")) {
- t.Fatalf("member instances tab renders the move form it must not have:\n%s", memberBody)
+ t.Fatalf("member placement section renders the move form it must not have:\n%s", memberBody)
}
+ assertNonMember404(t, fx, "/apps/titogo/settings/placement")
}
-// TestAppInstancesPlacementShowsFleet: once placed, the tab names the fleet
+// TestAppSettingsPlacementShowsFleet: once placed, the section names the fleet
// and links to its page, and the form's current fleet is the selected option
// rather than a form that reads as "unplaced" over a placed app.
-func TestAppInstancesPlacementShowsFleet(t *testing.T) {
+func TestAppSettingsPlacementShowsFleet(t *testing.T) {
fx, token := placeFixture(t, "code-appplace-shows")
if st, body := postJSON(t, placeURL(fx, "titogo"), map[string]string{"target": "fleet/pi"}, token); st != http.StatusOK {
t.Fatalf("place = %d %v", st, body)
}
c := newBrowser(t)
signUp(t, fx, c, "code-appplace-shows-browser")
- st, _, body := get(t, c, fx.u("/apps/titogo/instances"))
+ st, _, body := get(t, c, fx.u("/apps/titogo/settings/placement"))
if st != http.StatusOK {
- t.Fatalf("GET instances = %d:\n%s", st, body)
+ t.Fatalf("GET settings/placement = %d:\n%s", st, body)
}
if !strings.Contains(body, "/fleets/pi") || !strings.Contains(body, "<code>pi</code>") {
- t.Fatalf("placed app's tab does not name and link its fleet:\n%s", body)
+ t.Fatalf("placed app's section does not name and link its fleet:\n%s", body)
}
if !strings.Contains(body, `<option value="fleet/pi" selected>`) {
t.Fatalf("the current fleet is not the form's selected option:\n%s", body)
diff --git a/internal/console/lifetimes_read_test.go b/internal/console/lifetimes_read_test.go
index 9a2c8f3e7..7413641ca 100644
--- a/internal/console/lifetimes_read_test.go
+++ b/internal/console/lifetimes_read_test.go
@@ -197,7 +197,7 @@ func TestEveryClaimsOffConsumerIgnoresAFieldlessRecordBesideASlot(t *testing.T)
c := signInPaul(t, l.fx)
csrf := sessionToken(t, l.fx, c)
code, loc, body := postForm(t, c, l.fx.u("/apps/"+ltApp+"/place"), url.Values{"csrf": {csrf}, "target": {""}})
- if code != http.StatusSeeOther || !strings.HasSuffix(loc, "/apps/"+ltApp+"/instances") {
+ if code != http.StatusSeeOther || !strings.HasSuffix(loc, "/apps/"+ltApp+"/settings/placement") {
t.Fatalf("place = %d -> %q %s", code, loc, body)
}
case "placeAppTarget":
diff --git a/internal/console/server.go b/internal/console/server.go
index 4d021af6a..f2d2c6540 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -2228,7 +2228,7 @@ type page struct {
// so the form itself is withheld — never an empty select.
FleetPlaceableApps []string
- // App Instances tab, "Placement" (Task 6): where this app runs
+ // App Settings, /settings/placement: where this app runs
// ("fleet/<name>", or "" for the shared fleet), and the account's own
// fleets as the owner's move options. AppPlacementKnown false means the
// read FAILED — the section then says so instead of claiming the shared
@@ -3889,16 +3889,6 @@ func (s *Server) handleAppInstances(w http.ResponseWriter, r *http.Request) {
p.InstanceUnknownChannel = q.Channel != "" && !hasInstanceChannel(p.InstanceChannels, q.Channel)
p.InstanceGroups = groupInstanceRows(pg.Rows, p.Detail.Channels, pg.Matching)
p.InstanceListURL = p.Nav + "/apps/" + p.AppName + "/instances" + instanceQuerySuffix(q)
- // Placement (Task 6): where this app runs, and where else it could. Soft
- // like everything else on this tab — a failed read costs the section's
- // certainty (AppPlacementKnown) and a flash, never the page.
- placement, fleets, known, warn := s.appPlacementSection(acct, p.AppName)
- p.AppPlacement = placement
- p.OwnedFleetNames = fleets
- p.AppPlacementKnown = known
- if warn != "" && p.FlashErr == "" {
- p.FlashErr = warn
- }
// The app-region note (spec §10). Available is nil for a fleet app and
// for a policy, edges or stored region that could not be read, so those
// show nothing: unreadable never reads as available. Pooled is excluded
@@ -4198,6 +4188,9 @@ func (s *Server) handleAppSettings(w http.ResponseWriter, r *http.Request) {
}
setAppSettingsSection(&p, section)
s.populateAppSettings(r, &p, acct)
+ if section == "placement" {
+ s.populateAppPlacement(&p, acct)
+ }
s.render(w, http.StatusOK, "app_settings", p)
}
@@ -4206,6 +4199,7 @@ func setAppSettingsSection(p *page, section string) {
for _, item := range []struct{ key, label string }{
{"general", "General"},
{"domains", "Domains"},
+ {"placement", "Placement"},
{"pipeline", "Release pipeline"},
{"environments", "Environments"},
{"storage", "Storage"},
diff --git a/internal/console/templates/app_instances.html b/internal/console/templates/app_instances.html
index 012c89c6f..d1e0e514e 100644
--- a/internal/console/templates/app_instances.html
+++ b/internal/console/templates/app_instances.html
@@ -28,6 +28,8 @@
{{end}}
</p>
{{end}}
+{{if .RegionLine}}
+<p id="app-region-line"{{if .RegionLineWarn}} class="banner error"{{end}}>{{.RegionLine}}</p>{{end}}
{{if .InstanceRows}}
<div class="tablewrap">
<table class="instances">
@@ -57,27 +59,6 @@ against that copy's own peak.</p>
<p class="small">The address comes live within a couple of minutes.</p>
{{end}}
-<h2>Placement</h2>{{if .RegionLine}}
-<p id="app-region-line"{{if .RegionLineWarn}} class="banner error"{{end}}>{{.RegionLine}}</p>{{end}}
-{{if .AppPlacementKnown}}
-<p>{{if .AppPlacement}}This app runs on your fleet <a href="{{.Nav}}/fleets/{{fleetName .AppPlacement}}"><code>{{fleetName .AppPlacement}}</code></a>.{{else}}This app runs on the shared fleet.{{end}}</p>
-{{if and .IsOwner .OwnedFleetNames}}
-<form method="post" action="{{.Base}}/apps/{{.AppName}}/place" class="settings-row">
- <input type="hidden" name="csrf" value="{{.CSRF}}">
- <label class="visually-hidden" for="place-target">Where this app runs</label>
- <select id="place-target" name="target">
- <option value=""{{if not .AppPlacement}} selected{{end}}>Shared fleet</option>
- {{range .OwnedFleetNames}}<option value="fleet/{{.}}"{{if eq (printf "fleet/%s" .) $.AppPlacement}} selected{{end}}>fleet/{{.}}</option>{{end}}
- </select>
- <button type="submit" class="btn-sm">Move</button>
-</form>
-<p class="small">Moving changes where this app <em>serves</em>. Data does not move:
-hibernated instance state stays in the old placement's bucket.</p>
-{{end}}
-{{else}}
-<p class="small">Could not read where this app runs.</p>
-{{end}}
-
{{if and .Instances .Instances.Reporting .Instances.Instances}}
<details>
<summary>Reported by the app itself ({{len .Instances.Instances}})</summary>
diff --git a/internal/console/templates/app_settings.html b/internal/console/templates/app_settings.html
index 32246a70a..efb72a2cb 100644
--- a/internal/console/templates/app_settings.html
+++ b/internal/console/templates/app_settings.html
@@ -177,6 +177,26 @@ page asking for it and stay signed in for a week. It is set per instance.</p>
<p class="small">Path rules, such as different numbers for /api/, are set with carlos ratelimit.</p>
{{end}}
+{{end}}
+{{if eq .SettingsSection "placement"}}<h2>Placement</h2>
+{{if .AppPlacementKnown}}
+<p>{{if .AppPlacement}}This app runs on your fleet <a href="{{.Nav}}/fleets/{{fleetName .AppPlacement}}"><code>{{fleetName .AppPlacement}}</code></a>.{{else}}This app runs on the shared fleet.{{end}}</p>
+{{if and .IsOwner .OwnedFleetNames}}
+<form method="post" action="{{.Base}}/apps/{{.AppName}}/place" class="settings-row">
+ <input type="hidden" name="csrf" value="{{.CSRF}}">
+ <label class="visually-hidden" for="place-target">Where this app runs</label>
+ <select id="place-target" name="target">
+ <option value=""{{if not .AppPlacement}} selected{{end}}>Shared fleet</option>
+ {{range .OwnedFleetNames}}<option value="fleet/{{.}}"{{if eq (printf "fleet/%s" .) $.AppPlacement}} selected{{end}}>fleet/{{.}}</option>{{end}}
+ </select>
+ <button type="submit" class="btn-sm">Move</button>
+</form>
+<p class="small">Moving changes where this app <em>serves</em>. Data does not move:
+hibernated instance state stays in the old placement's bucket.</p>
+{{end}}
+{{else}}
+<p class="small">Could not read where this app runs.</p>
+{{end}}
{{end}}
{{if eq .SettingsSection "general"}}
{{if and .Settings .Settings.MismatchTarget}}