carlos / platform Public

Add app stars, filtering, and expiry controls in settings

Group apps by personal stars and temporary lifetime. Keep expiry read-only
on the index; owners extend it from app settings. Preserve current console
identity marks and mobile navigation.

Draft checkpoint: final copy approval and full CI are still required
before merge or release.
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 0e51ece104965ac974a47185604d1035a090c6fc parent 322d244
17 files changed, +1,138 −19
  • internal/console/applist.go +302 −0
  • internal/console/applist_test.go +427 −0
  • internal/console/applistcopy.go +19 −0
  • internal/console/applistview_test.go +91 −0
  • internal/console/appstarcleanup_test.go +79 −0
  • internal/console/claim_invariant_fixtures_test.go +22 −0
  • internal/console/claim_invariant_probes_nonapp_test.go +18 −0
  • internal/console/icons.go +4 −0
  • internal/console/ownership.go +1 −0
  • internal/console/server.go +24 −1
  • internal/console/store.go +11 −0
  • internal/console/store_gate.go +1 −0
  • internal/console/templates/app_settings.html +17 −0
  • internal/console/templates/apps.html +86 −17
  • internal/console/testdata/claim-routes.txt +2 −0
  • internal/provision/app_lists_census_test.go +33 −0
  • internal/provision/plan9_b8_census_test.go +1 −1

CI passed — run details

diff --git a/internal/console/applist.go b/internal/console/applist.go
new file mode 100644
index 000000000..60e308b46
--- /dev/null
+++ b/internal/console/applist.go
@@ -0,0 +1,302 @@
+package console
+
+import (
+ "context"
+ "crypto/subtle"
+ "errors"
+ "log"
+ "net/http"
+ "net/url"
+ "strings"
+ "time"
+)
+
+// The account home's app list: personal stars, the temporary apps' expiry
+// and the owner's Extend form. Stars are one person's bookmarks in one
+// account; they grant nothing and change nothing about the app.
+
+// appListRefusals is the Extend form's new refusal text. The page's own
+// labels are appListCopy (applistcopy.go). Both are held at their zero
+// values until Paul approves them in copy review (the proposed ids are in
+// writing/app-lists/backend-strings.json); a refusal whose text is still
+// empty redirects without a notice.
+type appListRefusals struct {
+ // ExtendExpired: the app's expiry has passed, but the expiry pass has
+ // not trashed it yet.
+ ExtendExpired string
+ // ExtendAtLimit: the expiry is already 30 days from now, so no choice
+ // moves it later.
+ ExtendAtLimit string
+ ExtendSuccess string
+ ExtendFailed string
+ StarFailed string
+}
+
+var approvedAppListRefusals = appListRefusals{}
+
+// extendDays are the Extend form's choices. Anything else is refused.
+var extendDays = map[string]int{"1": 1, "7": 7, "30": 30}
+
+// maxAppFilter bounds the q filter: an app name is at most 63 bytes and a
+// host at most 253.
+const maxAppFilter = 256
+
+func (s *Store) migrateAppStars() error {
+ // Keyed by the app row's lifetime, not its name: a rename keeps the star,
+ // and a purged app's name taken again by a new app does not inherit it.
+ _, err := s.db.Exec(`CREATE TABLE IF NOT EXISTS app_stars (
+ account_id INTEGER NOT NULL,
+ address TEXT NOT NULL,
+ lifetime TEXT NOT NULL,
+ starred_at INTEGER NOT NULL,
+ PRIMARY KEY (account_id, address, lifetime)
+);`)
+ return err
+}
+
+// SetAppStar records the desired state: on stars, off unstars. Repeating
+// either is a no-op.
+func (s *Store) SetAppStar(accountID int64, address, lifetime string, on bool, now time.Time) error {
+ if lifetime == "" {
+ return errors.New("console: app has no lifetime id")
+ }
+ if on {
+ _, err := s.db.Exec(`INSERT INTO app_stars (account_id, address, lifetime, starred_at) VALUES (?, ?, ?, ?)
+ON CONFLICT (account_id, address, lifetime) DO NOTHING`, accountID, address, lifetime, now.Unix())
+ return err
+ }
+ _, err := s.db.Exec(`DELETE FROM app_stars WHERE account_id = ? AND address = ? AND lifetime = ?`, accountID, address, lifetime)
+ return err
+}
+
+// StarredLifetimes is the set of app lifetimes address has starred in the
+// account.
+func (s *Store) StarredLifetimes(accountID int64, address string) (map[string]bool, error) {
+ rows, err := s.db.Query(`SELECT lifetime FROM app_stars WHERE account_id = ? AND address = ?`, accountID, address)
+ if err != nil {
+ return nil, err
+ }
+ defer rows.Close()
+ out := map[string]bool{}
+ for rows.Next() {
+ var l string
+ if err := rows.Scan(&l); err != nil {
+ return nil, err
+ }
+ out[l] = true
+ }
+ return out, rows.Err()
+}
+
+// partitionApps splits the rows into the page's three lists, in their
+// given order. A star wins: a starred temporary app is listed under
+// Starred and keeps its ExpiresAt.
+func partitionApps(rows []appRow) (starred, regular, temporary []appRow) {
+ for _, r := range rows {
+ switch {
+ case r.Starred:
+ starred = append(starred, r)
+ case !r.ExpiresAt.IsZero():
+ temporary = append(temporary, r)
+ default:
+ regular = append(regular, r)
+ }
+ }
+ return starred, regular, temporary
+}
+
+// fillAppLists marks p.Apps with the viewer's stars and each temporary
+// app's expiry, then fills the page's three lists from the rows q keeps.
+// p.Apps stays every live app, so the page can tell "no apps" from "no
+// matches".
+func (s *Server) fillAppLists(p *page, acct *Account, addr, q string) error {
+ lives, err := s.store.AppLivesIn(acct.ID)
+ if err != nil {
+ return err
+ }
+ stars, err := s.store.StarredLifetimes(acct.ID, addr)
+ if err != nil {
+ return err
+ }
+ lifeOf := make(map[string]AppLife, len(lives))
+ for _, l := range lives {
+ lifeOf[l.App] = l
+ }
+ for i := range p.Apps {
+ l, ok := lifeOf[p.Apps[i].App]
+ if !ok {
+ continue
+ }
+ p.Apps[i].Starred = l.Lifetime != "" && stars[l.Lifetime]
+ if l.Temporary() {
+ p.Apps[i].ExpiresAt = time.Unix(l.ExpiresAt, 0).UTC()
+ }
+ }
+ p.AppFilter = appFilter(q)
+ p.StarredApps, p.RegularApps, p.TemporaryApps = partitionApps(filterApps(p.Apps, p.AppFilter))
+ return nil
+}
+
+// appFilter reads the q filter: trimmed, lower-cased, bounded.
+func appFilter(q string) string {
+ q = strings.ToLower(strings.TrimSpace(q))
+ if len(q) > maxAppFilter {
+ q = q[:maxAppFilter]
+ }
+ return q
+}
+
+// filterApps keeps the rows whose name or host contains q. An empty q keeps
+// every row.
+func filterApps(rows []appRow, q string) []appRow {
+ if q == "" {
+ return rows
+ }
+ var out []appRow
+ for _, r := range rows {
+ if strings.Contains(strings.ToLower(r.App), q) || strings.Contains(strings.ToLower(r.URL), q) {
+ out = append(out, r)
+ }
+ }
+ return out
+}
+
+// accountHomeURL is where the star and Extend forms return to, carrying the
+// filter the form posted. The path is built here, never taken from the
+// request, so it cannot leave the console.
+func accountHomeURL(sqid, q string) string {
+ u := "/a/" + url.PathEscape(sqid) + "/"
+ if q = appFilter(q); q != "" {
+ u += "?" + url.Values{"q": {q}}.Encode()
+ }
+ return u
+}
+
+// handleAppStar is POST /a/{sqid}/apps/{app}/star: any member, CSRF,
+// starred=true or false as the desired state. The star is the viewer's own,
+// so a member cannot change anyone else's.
+func (s *Server) handleAppStar(w http.ResponseWriter, r *http.Request) {
+ addr, raw, acct, _, app, ok := s.accountApp(w, r)
+ if !ok {
+ return
+ }
+ if subtle.ConstantTimeCompare([]byte(r.FormValue("csrf")), []byte(raw)) != 1 {
+ s.renderMessage(w, r, http.StatusForbidden, "Refused", "Cross-site request blocked.")
+ return
+ }
+ var on bool
+ switch r.FormValue("starred") {
+ case "true":
+ on = true
+ case "false":
+ default:
+ s.renderMessage(w, r, http.StatusBadRequest, "Refused", "That request could not be read.")
+ return
+ }
+ life, err := s.store.AppLife(acct.ID, app)
+ if err == nil && (life == nil || life.Trashed()) {
+ // Trashed or purged since accountApp looked.
+ s.renderMessage(w, r, http.StatusNotFound, "Not found", "No such app here.")
+ return
+ }
+ if err == nil {
+ err = s.store.SetAppStar(acct.ID, addr, life.Lifetime, on, time.Now())
+ }
+ if err != nil {
+ log.Printf("console: star %s/%s: %v", acct.Sqid, app, err)
+ s.renderMessage(w, r, http.StatusInternalServerError, "Error", approvedAppListRefusals.StarFailed)
+ return
+ }
+ http.Redirect(w, r, accountHomeURL(acct.Sqid, r.FormValue("q")), http.StatusSeeOther)
+}
+
+var (
+ errTemporaryExpired = errors.New("console: the app's expiry has passed")
+ errExpiryAtLimit = errors.New("console: the app's expiry is already at the limit")
+)
+
+// extendAppExpiry moves a live temporary app's expiry later by days, from
+// the current expiry, but never past temporaryTTLMax from now. It never
+// moves an expiry earlier, and refuses an app whose expiry has passed: the
+// expiry pass owns that app now. It holds the app lock and settles first,
+// exactly as setAppTTL does, so it serialises with keep, ttl, restore, trash
+// and the expiry pass.
+func (s *Server) extendAppExpiry(ctx context.Context, acct *Account, app string, days int, now time.Time) (time.Time, error) {
+ defer s.lockApp(acct.Sqid, app)()
+ life, err := s.temporaryLive(ctx, acct, app, now)
+ if err != nil {
+ return time.Time{}, err
+ }
+ cur := time.Unix(life.ExpiresAt, 0)
+ if !cur.After(now) {
+ return time.Time{}, errTemporaryExpired
+ }
+ exp := cur.Add(time.Duration(days) * 24 * time.Hour)
+ if limit := now.Add(temporaryTTLMax).Truncate(time.Second); exp.After(limit) {
+ exp = limit
+ }
+ if !exp.After(cur) {
+ return time.Time{}, errExpiryAtLimit
+ }
+ ok, err := s.store.SetAppExpiryContext(ctx, acct.ID, app, exp)
+ if err != nil {
+ return time.Time{}, err
+ }
+ if !ok {
+ return time.Time{}, errTemporaryInTrash
+ }
+ return exp, nil
+}
+
+// handleAppExtend is POST /a/{sqid}/apps/{app}/extend, the app list's
+// Extend form: owners only, CSRF, days=1, 7 or 30. No passkey step: like
+// Keep, it only delays the app's deletion.
+func (s *Server) handleAppExtend(w http.ResponseWriter, r *http.Request) {
+ addr, raw, acct, role, app, ok := s.accountApp(w, r)
+ if !ok {
+ return
+ }
+ if subtle.ConstantTimeCompare([]byte(r.FormValue("csrf")), []byte(raw)) != 1 {
+ s.renderMessage(w, r, http.StatusForbidden, "Refused", "Cross-site request blocked.")
+ return
+ }
+ if role != RoleOwner {
+ http.NotFound(w, r)
+ return
+ }
+ days, ok := extendDays[r.FormValue("days")]
+ if !ok {
+ s.renderMessage(w, r, http.StatusBadRequest, "Refused", "That request could not be read.")
+ return
+ }
+ back := func(kind, msg string) {
+ if msg != "" {
+ s.setFlash(w, kind, msg)
+ }
+ http.Redirect(w, r, appSettingsURL(acct.Sqid, app, "general"), http.StatusSeeOther)
+ }
+ ctx, cancel := context.WithTimeout(r.Context(), 20*time.Second)
+ defer cancel()
+ exp, err := s.extendAppExpiry(ctx, acct, app, days, time.Now())
+ switch {
+ case err == nil:
+ case errors.Is(err, errNotTemporary):
+ back("ok", app+" is already permanent.")
+ return
+ case errors.Is(err, errTemporaryInTrash), errors.Is(err, errAppGone):
+ back("err", app+" is in the Trash. Restore it from the Trash page first.")
+ return
+ case errors.Is(err, errTemporaryExpired):
+ back("err", approvedAppListRefusals.ExtendExpired)
+ return
+ case errors.Is(err, errExpiryAtLimit):
+ back("err", approvedAppListRefusals.ExtendAtLimit)
+ return
+ default:
+ log.Printf("console: extend %s/%s: %v", acct.Sqid, app, err)
+ back("err", approvedAppListRefusals.ExtendFailed)
+ return
+ }
+ s.audit(acct, app, addr, "ttl", "set "+app+" to expire "+exp.UTC().Format("2006-01-02 15:04 UTC"))
+ back("ok", strings.NewReplacer("{app}", app, "{date}", exp.UTC().Format("2006-01-02 15:04 UTC")).Replace(approvedAppListRefusals.ExtendSuccess))
+}
diff --git a/internal/console/applist_test.go b/internal/console/applist_test.go
new file mode 100644
index 000000000..dcb79cd1e
--- /dev/null
+++ b/internal/console/applist_test.go
@@ -0,0 +1,427 @@
+package console
+
+import (
+ "github.com/carlosframework/platform/internal/release"
+ "net/http"
+ "net/url"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+)
+
+func starredOf(t *testing.T, fx *consoleFixture, address string) map[string]bool {
+ t.Helper()
+ lifes, err := fx.st.StarredLifetimes(OpsAccountID, address)
+ if err != nil {
+ t.Fatal(err)
+ }
+ out := map[string]bool{}
+ lives, err := fx.st.AppLivesIn(OpsAccountID)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, l := range lives {
+ if lifes[l.Lifetime] {
+ out[l.App] = true
+ }
+ }
+ return out
+}
+
+func star(t *testing.T, fx *consoleFixture, c *http.Client, csrf, app, on string) (int, string) {
+ t.Helper()
+ status, loc, _ := postForm(t, c, fx.u("/apps/"+app+"/star"), url.Values{"csrf": {csrf}, "starred": {on}})
+ return status, loc
+}
+
+// A star is desired state, kept across requests, and the viewer's own:
+// another member of the same account sees none of it.
+func TestAppStarIsPersonalIdempotentAndPersistent(t *testing.T) {
+ fx := newConsoleFixture(t)
+ if err := fx.st.AddMember(OpsAccountID, "kim@keymail.dev", RoleMember, time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ paul, paulCSRF := signInAs(t, fx, "paul@keymail.dev", "code-star-paul")
+ kim, kimCSRF := signInAs(t, fx, "kim@keymail.dev", "code-star-kim")
+
+ for i := 0; i < 2; i++ {
+ if status, loc := star(t, fx, paul, paulCSRF, "kass", "true"); status != http.StatusSeeOther || loc != fx.path("/") {
+ t.Fatalf("star #%d = %d %q, want 303 to the account home", i, status, loc)
+ }
+ }
+ if got := starredOf(t, fx, "paul@keymail.dev"); !got["kass"] || len(got) != 1 {
+ t.Fatalf("paul's stars = %v, want kass", got)
+ }
+ if got := starredOf(t, fx, "kim@keymail.dev"); len(got) != 0 {
+ t.Fatalf("kim's stars = %v, want none: stars are personal", got)
+ }
+ // Kim unstarring kass touches only Kim's (absent) star.
+ if status, _ := star(t, fx, kim, kimCSRF, "kass", "false"); status != http.StatusSeeOther {
+ t.Fatalf("kim unstar = %d", status)
+ }
+ if got := starredOf(t, fx, "paul@keymail.dev"); !got["kass"] {
+ t.Fatal("another member's unstar removed paul's star")
+ }
+ for i := 0; i < 2; i++ {
+ if status, _ := star(t, fx, paul, paulCSRF, "kass", "false"); status != http.StatusSeeOther {
+ t.Fatalf("unstar #%d = %d", i, status)
+ }
+ }
+ if got := starredOf(t, fx, "paul@keymail.dev"); len(got) != 0 {
+ t.Fatalf("paul's stars after unstar = %v", got)
+ }
+}
+
+func TestAppStarGates(t *testing.T) {
+ fx := newConsoleFixture(t)
+ paul, csrf := signInAs(t, fx, "paul@keymail.dev", "code-star-gates")
+
+ if status, _ := star(t, fx, paul, "wrong", "kass", "true"); status != http.StatusForbidden {
+ t.Errorf("bad CSRF = %d, want 403", status)
+ }
+ if status, _ := star(t, fx, paul, csrf, "kass", "yes"); status != http.StatusBadRequest {
+ t.Errorf("starred=yes = %d, want 400", status)
+ }
+ if status, _ := star(t, fx, paul, csrf, "no-such-app", "true"); status != http.StatusNotFound {
+ t.Errorf("unknown app = %d, want 404", status)
+ }
+ tempApp(t, fx, "tmp-t", time.Now().Add(time.Hour))
+ fx.st.TrashAppRow(OpsAccountID, "tmp-t", time.Now())
+ if status, _ := star(t, fx, paul, csrf, "tmp-t", "true"); status != http.StatusNotFound {
+ t.Errorf("trashed app = %d, want 404", status)
+ }
+ if got := starredOf(t, fx, "paul@keymail.dev"); len(got) != 0 {
+ t.Fatalf("refused stars were written: %v", got)
+ }
+
+ // A signed-in non-member gets the plain 404 an unrouted URL gets, before
+ // any CSRF answer that would confirm the account exists.
+ eve, eveCSRF := signInAs(t, fx, "eve@keymail.dev", "code-star-eve")
+ for _, tok := range []string{eveCSRF, "wrong"} {
+ status, _, body := postForm(t, eve, fx.u("/apps/kass/star"), url.Values{"csrf": {tok}, "starred": {"true"}})
+ if status != http.StatusNotFound || strings.Contains(body, "kass") {
+ t.Errorf("non-member star = %d %q, want a bare 404", status, body)
+ }
+ }
+ if l, _ := fx.st.StarredLifetimes(OpsAccountID, "eve@keymail.dev"); len(l) != 0 {
+ t.Fatalf("a non-member's star was written: %v", l)
+ }
+ // Signed out: sent to the front page, nothing written.
+ anon := &http.Client{CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
+ if status, loc, _ := postForm(t, anon, fx.u("/apps/kass/star"), url.Values{"csrf": {csrf}, "starred": {"true"}}); status != http.StatusFound || loc != "/" {
+ t.Errorf("signed-out star = %d %q", status, loc)
+ }
+}
+
+// The star follows the app's lifetime: a rename keeps it, a new app that
+// takes a purged app's name does not inherit it, and the same app name in
+// another account is another app.
+func TestAppStarFollowsTheAppLifetime(t *testing.T) {
+ fx := newConsoleFixture(t)
+ paul, csrf := signInAs(t, fx, "paul@keymail.dev", "code-star-life")
+ const otherID = 4242
+ if err := fx.st.CreateAccount(otherID, "cdef", "Other", "paul@keymail.dev", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ if err := fx.st.AddMember(otherID, "paul@keymail.dev", RoleOwner, time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := fx.st.CreateAppIn(otherID, "kass", "paul@keymail.dev", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := fx.st.CreateAppIn(OpsAccountID, "blog", "paul@keymail.dev", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ if status, _ := star(t, fx, paul, csrf, "blog", "true"); status != http.StatusSeeOther {
+ t.Fatalf("star = %d", status)
+ }
+ if l, _ := fx.st.StarredLifetimes(otherID, "paul@keymail.dev"); len(l) != 0 {
+ t.Fatalf("a star in bab shows in another account: %v", l)
+ }
+ if err := fx.st.RenameAppIn(OpsAccountID, "blog", "blog-two"); err != nil {
+ t.Fatal(err)
+ }
+ if got := starredOf(t, fx, "paul@keymail.dev"); !got["blog-two"] {
+ t.Fatalf("stars after rename = %v, want blog-two", got)
+ }
+ if err := fx.st.TrashAppRow(OpsAccountID, "blog-two", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ if err := fx.st.PurgeAppRow(OpsAccountID, "blog-two"); err != nil {
+ t.Fatal(err)
+ }
+ if ok, err := fx.st.CreateAppIn(OpsAccountID, "blog-two", "paul@keymail.dev", time.Now()); err != nil || !ok {
+ t.Fatalf("recreate = %v %v", ok, err)
+ }
+ if got := starredOf(t, fx, "paul@keymail.dev"); len(got) != 0 {
+ t.Fatalf("stars after purge and recreate = %v, want none", got)
+ }
+}
+
+func TestPartitionApps(t *testing.T) {
+ exp := time.Date(2026, 11, 7, 0, 0, 0, 0, time.UTC)
+ rows := []appRow{
+ {App: "a"},
+ {App: "b", Starred: true},
+ {App: "tmp-c", ExpiresAt: exp},
+ {App: "tmp-d", ExpiresAt: exp, Starred: true},
+ {App: "e"},
+ }
+ st, reg, tmp := partitionApps(rows)
+ names := func(rs []appRow) string {
+ var n []string
+ for _, r := range rs {
+ n = append(n, r.App)
+ }
+ return strings.Join(n, ",")
+ }
+ if names(st) != "b,tmp-d" || names(reg) != "a,e" || names(tmp) != "tmp-c" {
+ t.Fatalf("partition = %q %q %q", names(st), names(reg), names(tmp))
+ }
+ if !st[1].ExpiresAt.Equal(exp) {
+ t.Fatal("a starred temporary app lost its expiry")
+ }
+ if got := names(filterApps([]appRow{{App: "shop", URL: "shop.example.com"}, {App: "blog", URL: "news.example.org"}}, appFilter(" NEWS "))); got != "blog" {
+ t.Fatalf("filter by host = %q", got)
+ }
+}
+
+// The account home fills the three lists from the viewer's stars and the
+// rows' expiries, filters by q, and keeps Apps whole.
+func TestAccountHomePartitionsByViewer(t *testing.T) {
+ fx := newConsoleFixture(t)
+ exp := time.Now().Add(48 * time.Hour).Truncate(time.Second)
+ tempApp(t, fx, "tmp-a", exp)
+ tempApp(t, fx, "tmp-b", exp)
+ if err := fx.st.AddMember(OpsAccountID, "kim@keymail.dev", RoleMember, time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ paul, csrf := signInAs(t, fx, "paul@keymail.dev", "code-home-paul")
+ star(t, fx, paul, csrf, "tmp-a", "true")
+ star(t, fx, paul, csrf, "kass", "true")
+
+ names := func(rs []appRow) string {
+ var n []string
+ for _, r := range rs {
+ n = append(n, r.App)
+ }
+ return strings.Join(n, ",")
+ }
+ acct, err := fx.st.AccountBySqid(fx.sqid)
+ if err != nil || acct == nil {
+ t.Fatal(err)
+ }
+ lists := func(addr, q string) page {
+ t.Helper()
+ var p page
+ for _, a := range []string{"kass", "titogo", "tmp-a", "tmp-b"} {
+ p.Apps = append(p.Apps, appRow{App: a})
+ }
+ if err := fx.srv.fillAppLists(&p, acct, addr, q); err != nil {
+ t.Fatal(err)
+ }
+ return p
+ }
+ got := lists("paul@keymail.dev", "")
+ if names(got.StarredApps) != "kass,tmp-a" || names(got.RegularApps) != "titogo" || names(got.TemporaryApps) != "tmp-b" {
+ t.Fatalf("paul's lists = %q %q %q", names(got.StarredApps), names(got.RegularApps), names(got.TemporaryApps))
+ }
+ if !got.StarredApps[1].ExpiresAt.Equal(exp) || !got.StarredApps[0].ExpiresAt.IsZero() {
+ t.Fatalf("starred expiries = %v %v", got.StarredApps[0].ExpiresAt, got.StarredApps[1].ExpiresAt)
+ }
+ got = lists("paul@keymail.dev", " TMP ")
+ if got.AppFilter != "tmp" || len(got.Apps) != 4 || names(got.StarredApps) != "tmp-a" || len(got.RegularApps) != 0 || names(got.TemporaryApps) != "tmp-b" {
+ t.Fatalf("filtered = %q %d %q %q %q", got.AppFilter, len(got.Apps), names(got.StarredApps), names(got.RegularApps), names(got.TemporaryApps))
+ }
+ got = lists("kim@keymail.dev", "")
+ if len(got.StarredApps) != 0 || names(got.RegularApps) != "kass,titogo" || names(got.TemporaryApps) != "tmp-a,tmp-b" {
+ t.Fatalf("kim's lists = %q %q %q", names(got.StarredApps), names(got.RegularApps), names(got.TemporaryApps))
+ }
+ // The page itself renders with all of it in place.
+ for _, u := range []string{fx.u("/"), fx.u("/?q=tmp")} {
+ if status, _, _ := get(t, paul, u); status != http.StatusOK {
+ t.Fatalf("GET %s = %d", u, status)
+ }
+ }
+}
+
+// Stars live in SQLite: a reopened store still has them.
+func TestAppStarsSurviveReopen(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "console.db")
+ st, err := Open(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := st.SetAppStar(1, "paul@keymail.dev", "life-1", true, time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ if err := st.SetAppStar(1, "paul@keymail.dev", "", true, time.Now()); err == nil {
+ t.Fatal("a star with no lifetime was accepted")
+ }
+ st.Close()
+ st, err = Open(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer st.Close()
+ if l, err := st.StarredLifetimes(1, "paul@keymail.dev"); err != nil || !l["life-1"] || len(l) != 1 {
+ t.Fatalf("after reopen = %v %v", l, err)
+ }
+ if l, _ := st.StarredLifetimes(2, "paul@keymail.dev"); len(l) != 0 {
+ t.Fatalf("account 2 sees account 1's star: %v", l)
+ }
+}
+
+func extend(t *testing.T, fx *consoleFixture, c *http.Client, csrf, app, days string) (int, string) {
+ t.Helper()
+ status, loc, _ := postForm(t, c, fx.u("/apps/"+app+"/extend"), url.Values{"csrf": {csrf}, "days": {days}, "q": {"tmp"}})
+ return status, loc
+}
+
+func TestAppExtendMovesTheExpiryWithinTheCap(t *testing.T) {
+ fx := newConsoleFixture(t)
+ paul, csrf := signInAs(t, fx, "paul@keymail.dev", "code-extend")
+ exp := time.Now().Add(2 * 24 * time.Hour).Truncate(time.Second)
+ tempApp(t, fx, "tmp-a", exp)
+
+ status, loc := extend(t, fx, paul, csrf, "tmp-a", "7")
+ if status != http.StatusSeeOther || loc != fx.path("/apps/tmp-a/settings") {
+ t.Fatalf("extend = %d %q", status, loc)
+ }
+ if l := lifeOf(t, fx, "tmp-a"); l.ExpiresAt != exp.Add(7*24*time.Hour).Unix() {
+ t.Fatalf("expiry = %v, want the old expiry plus 7 days", time.Unix(l.ExpiresAt, 0))
+ }
+ // 9 days out plus 30 is past the cap: 30 days from now, not more.
+ before := time.Now()
+ extend(t, fx, paul, csrf, "tmp-a", "30")
+ after := time.Now()
+ l := lifeOf(t, fx, "tmp-a")
+ if l.ExpiresAt < before.Add(temporaryTTLMax).Unix()-1 || l.ExpiresAt > after.Add(temporaryTTLMax).Unix() {
+ t.Fatalf("capped expiry = %v, want 30 days from now", time.Unix(l.ExpiresAt, 0))
+ }
+ // At the cap, a further extension changes nothing and never shortens.
+ capped := l.ExpiresAt
+ if status, _ := extend(t, fx, paul, csrf, "tmp-a", "1"); status != http.StatusSeeOther {
+ t.Fatalf("extend at the cap = %d", status)
+ }
+ if l := lifeOf(t, fx, "tmp-a"); l.ExpiresAt < capped {
+ t.Fatalf("expiry moved earlier: %v < %v", l.ExpiresAt, capped)
+ }
+}
+
+func TestExtendAppExpiryRefusals(t *testing.T) {
+ fx := newConsoleFixture(t)
+ acct, err := fx.st.AccountBySqid(fx.sqid)
+ if err != nil || acct == nil {
+ t.Fatal(err)
+ }
+ now := time.Now().Truncate(time.Second)
+
+ // Past the cap already (clock moved, or set by hand): refused, unchanged.
+ far := now.Add(temporaryTTLMax + time.Hour)
+ tempApp(t, fx, "tmp-far", far)
+ if _, err := fx.srv.extendAppExpiry(t.Context(), acct, "tmp-far", 30, now); err != errExpiryAtLimit {
+ t.Fatalf("beyond the cap: %v, want errExpiryAtLimit", err)
+ }
+ if l := lifeOf(t, fx, "tmp-far"); l.ExpiresAt != far.Unix() {
+ t.Fatal("an extension shortened the expiry")
+ }
+ // Expired but not yet trashed by the pass: refused, unchanged.
+ gone := now.Add(-time.Minute)
+ tempApp(t, fx, "tmp-old", gone)
+ if _, err := fx.srv.extendAppExpiry(t.Context(), acct, "tmp-old", 1, now); err != errTemporaryExpired {
+ t.Fatalf("expired: %v, want errTemporaryExpired", err)
+ }
+ if l := lifeOf(t, fx, "tmp-old"); l.ExpiresAt != gone.Unix() {
+ t.Fatal("an expired app's expiry moved")
+ }
+ // Permanent, trashed, restoring, purged.
+ if _, err := fx.srv.extendAppExpiry(t.Context(), acct, "kass", 1, now); err != errNotTemporary {
+ t.Fatalf("permanent: %v", err)
+ }
+ if l := lifeOf(t, fx, "kass"); l.Temporary() {
+ t.Fatal("an extension made a permanent app temporary")
+ }
+ // Trashed in the bucket: settling first finds it (restoring is the same
+ // temporaryLive refusal).
+ tempApp(t, fx, "tmp-t", now.Add(time.Hour))
+ if err := release.TrashApp(t.Context(), fx.rel, fx.sqid, "tmp-t", expiryActor, now); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := fx.srv.extendAppExpiry(t.Context(), acct, "tmp-t", 1, now); err != errTemporaryInTrash {
+ t.Fatalf("trashed: %v", err)
+ }
+ if l := lifeOf(t, fx, "tmp-t"); l.ExpiresAt != now.Add(time.Hour).Unix() {
+ t.Fatal("a trashed app's expiry moved")
+ }
+ if _, err := fx.srv.extendAppExpiry(t.Context(), acct, "tmp-none", 1, now); err != errAppGone {
+ t.Fatalf("no row: %v", err)
+ }
+}
+
+func TestAppExtendGates(t *testing.T) {
+ fx := newConsoleFixture(t)
+ exp := time.Now().Add(24 * time.Hour).Truncate(time.Second)
+ tempApp(t, fx, "tmp-a", exp)
+ if err := fx.st.AddMember(OpsAccountID, "kim@keymail.dev", RoleMember, time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ paul, csrf := signInAs(t, fx, "paul@keymail.dev", "code-extend-paul")
+ kim, kimCSRF := signInAs(t, fx, "kim@keymail.dev", "code-extend-kim")
+ eve, eveCSRF := signInAs(t, fx, "eve@keymail.dev", "code-extend-eve")
+
+ if status, _ := extend(t, fx, paul, "wrong", "tmp-a", "7"); status != http.StatusForbidden {
+ t.Errorf("bad CSRF = %d, want 403", status)
+ }
+ for _, d := range []string{"", "0", "2", "31", "-1", "7d"} {
+ if status, _ := extend(t, fx, paul, csrf, "tmp-a", d); status != http.StatusBadRequest {
+ t.Errorf("days=%q = %d, want 400", d, status)
+ }
+ }
+ // A member gets the same 404 a non-member does.
+ if status, _ := extend(t, fx, kim, kimCSRF, "tmp-a", "7"); status != http.StatusNotFound {
+ t.Errorf("member extend = %d, want 404", status)
+ }
+ if status, _ := extend(t, fx, eve, eveCSRF, "tmp-a", "7"); status != http.StatusNotFound {
+ t.Errorf("non-member extend = %d, want 404", status)
+ }
+ if l := lifeOf(t, fx, "tmp-a"); l.ExpiresAt != exp.Unix() {
+ t.Fatalf("a refused extension moved the expiry to %v", time.Unix(l.ExpiresAt, 0))
+ }
+ // A permanent app: redirect, no expiry set.
+ if status, _ := extend(t, fx, paul, csrf, "kass", "7"); status != http.StatusSeeOther {
+ t.Errorf("permanent extend = %d", status)
+ }
+ if l := lifeOf(t, fx, "kass"); l.Temporary() {
+ t.Fatal("extend made a permanent app temporary")
+ }
+}
+
+// An extension queued on the app lock behind the expiry pass's trash finds
+// the trash when it gets the lock and refuses (TestKeepAndTTLRecheckAfterTheLock's
+// shape).
+func TestAppExtendRechecksAfterTheLock(t *testing.T) {
+ fx := newConsoleFixture(t)
+ paul, csrf := signInAs(t, fx, "paul@keymail.dev", "code-extend-race")
+ exp := time.Now().Add(time.Hour).Truncate(time.Second)
+ tempApp(t, fx, "tmp-a", exp)
+
+ unlock := fx.srv.lockApp(fx.sqid, "tmp-a")
+ done := make(chan int, 1)
+ go func() {
+ status, _ := extend(t, fx, paul, csrf, "tmp-a", "7")
+ done <- status
+ }()
+ waitForWaiter(t, &fx.srv.appLocks, fx.sqid+"/tmp-a")
+ if err := release.TrashApp(t.Context(), fx.rel, fx.sqid, "tmp-a", expiryActor, time.Now()); err != nil {
+ t.Error(err)
+ }
+ unlock()
+ if status := <-done; status != http.StatusSeeOther {
+ t.Fatalf("queued extend = %d, want the 303 back with a notice", status)
+ }
+ if l := lifeOf(t, fx, "tmp-a"); !l.Trashed() || l.ExpiresAt != exp.Unix() {
+ t.Fatalf("row = %+v, want trashed with its original expiry", l)
+ }
+}
diff --git a/internal/console/applistcopy.go b/internal/console/applistcopy.go
new file mode 100644
index 000000000..3b33d3a9a
--- /dev/null
+++ b/internal/console/applistcopy.go
@@ -0,0 +1,19 @@
+package console
+
+type appListCopy struct {
+ Starred, Regular, Temporary string
+ Filter, FilterPlaceholder, NoMatches string
+ Star, Unstar, Expires, Extend string
+ OneDay, SevenDays, ThirtyDays, ExtensionHelp string
+}
+
+var approvedAppListCopy = appListCopy{
+ Starred: "Starred",
+ Regular: "Other apps",
+ Temporary: "Temporary apps",
+ Filter: "Filter apps",
+ FilterPlaceholder: "By name or hostname",
+ Star: "Star app",
+ Unstar: "Unstar app",
+ Expires: "Expires",
+}
diff --git a/internal/console/applistview_test.go b/internal/console/applistview_test.go
new file mode 100644
index 000000000..f3a60b6b6
--- /dev/null
+++ b/internal/console/applistview_test.go
@@ -0,0 +1,91 @@
+package console
+
+import (
+ "bytes"
+ "net/http"
+ "strings"
+ "testing"
+ "time"
+)
+
+func TestAppListGroupsRenderExpiryAndOwnerControls(t *testing.T) {
+ expiry := time.Date(2026, 11, 7, 14, 0, 0, 0, time.UTC)
+ starred := appRow{App: "tmp-favourite", URL: "tmp-favourite.example.com", Starred: true, ExpiresAt: expiry}
+ regular := appRow{App: "permanent"}
+ temporary := appRow{App: "tmp-other", ExpiresAt: expiry}
+ for _, owner := range []bool{false, true} {
+ p := page{Account: &Account{Name: "Example"}, Nav: "/a/example", Base: "/a/tst", CSRF: "test-csrf", Role: RoleMember,
+ Apps: []appRow{starred, regular, temporary}, StarredApps: []appRow{starred}, RegularApps: []appRow{regular}, TemporaryApps: []appRow{temporary},
+ AppListCopy: appListCopy{Starred: "starred-heading", Regular: "regular-heading", Temporary: "temporary-heading"},
+ }
+ if owner {
+ p.Role = RoleOwner
+ }
+ var out bytes.Buffer
+ if err := templates.ExecuteTemplate(&out, "apps", p); err != nil {
+ t.Fatal(err)
+ }
+ body := out.String()
+ if strings.Count(body, `class="app-mark"`) != 3 {
+ t.Fatal("app identity marks missing from grouped lists")
+ }
+ if strings.Contains(body, `action="/a/example`) {
+ t.Fatal("mutation uses ambiguous account name")
+ }
+ if !strings.Contains(body, `action="/a/tst/apps/tmp-favourite/star"`) {
+ t.Fatal("star form lacks canonical account path")
+ }
+ if strings.Count(body, `data-app-row data-app-name=`) != 3 {
+ t.Fatalf("wrong row count: %d", strings.Count(body, `data-app-row data-app-name=`))
+ }
+ a, b, c := strings.Index(body, "starred-heading"), strings.Index(body, "regular-heading"), strings.Index(body, "temporary-heading")
+ if !(a >= 0 && a < b && b < c) {
+ t.Fatal("groups out of order")
+ }
+ if strings.Count(body, `datetime="2026-11-07T14:00:00Z"`) != 2 {
+ t.Fatal("temporary expiry missing, including starred temporary app")
+ }
+ if got := strings.Count(body, `/extend"`); got != 0 {
+ t.Fatalf("owner=%v: %d extension forms", owner, got)
+ }
+ if !strings.Contains(body, `aria-pressed="true"`) || !strings.Contains(body, `name="csrf" value="test-csrf"`) {
+ t.Fatal("star state or CSRF absent")
+ }
+ }
+}
+
+func TestAppExpiryControlsOnlyInSettings(t *testing.T) {
+ fx := newConsoleFixture(t)
+ expiry := time.Now().Add(24 * time.Hour).Truncate(time.Second)
+ tempApp(t, fx, "tmp-settings", expiry)
+ if err := fx.st.AddMember(OpsAccountID, "member@keymail.dev", RoleMember, time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ owner, _ := signInAs(t, fx, "paul@keymail.dev", "expiry-settings-owner")
+ member, _ := signInAs(t, fx, "member@keymail.dev", "expiry-settings-member")
+ action := `action="` + fx.path("/apps/tmp-settings/extend") + `"`
+ for _, c := range []struct {
+ name string
+ client *http.Client
+ path string
+ want bool
+ }{
+ {"owner settings", owner, "/apps/tmp-settings/settings", true},
+ {"member settings", member, "/apps/tmp-settings/settings", false},
+ {"owner index", owner, "/", false},
+ {"permanent settings", owner, "/apps/kass/settings", false},
+ } {
+ t.Run(c.name, func(t *testing.T) {
+ status, _, body := get(t, c.client, fx.u(c.path))
+ if status != http.StatusOK {
+ t.Fatalf("status=%d", status)
+ }
+ if strings.Contains(body, action) != c.want {
+ t.Fatalf("expiry form present=%v, want %v", strings.Contains(body, action), c.want)
+ }
+ if c.want && !strings.Contains(body, `name="csrf"`) {
+ t.Fatal("expiry form has no CSRF token")
+ }
+ })
+ }
+}
diff --git a/internal/console/appstarcleanup_test.go b/internal/console/appstarcleanup_test.go
new file mode 100644
index 000000000..2b93267bb
--- /dev/null
+++ b/internal/console/appstarcleanup_test.go
@@ -0,0 +1,79 @@
+package console
+
+import (
+ "testing"
+ "time"
+)
+
+func TestAppStarsEndWithMembership(t *testing.T) {
+ st := openTestStore(t)
+ id := tempStoreAccount(t, st)
+ now := time.Now()
+ if err := st.AddMember(id, "member@example.com", RoleMember, now); err != nil {
+ t.Fatal(err)
+ }
+ if err := st.SetAppStar(id, "member@example.com", "old-life", true, now); err != nil {
+ t.Fatal(err)
+ }
+ if err := st.RemoveMember(id, "member@example.com"); err != nil {
+ t.Fatal(err)
+ }
+ stars, err := st.StarredLifetimes(id, "member@example.com")
+ if err != nil || len(stars) != 0 {
+ t.Fatalf("stars after removal: %v %v", stars, err)
+ }
+}
+
+func TestAppStarsEndWithAccount(t *testing.T) {
+ for _, reap := range []bool{false, true} {
+ st := openTestStore(t)
+ id := tempStoreAccount(t, st)
+ now := time.Now()
+ if err := st.SetAppStar(id, "member@example.com", "old-life", true, now); err != nil {
+ t.Fatal(err)
+ }
+ var err error
+ if reap {
+ err = st.ReapAccount(id, now)
+ } else {
+ err = st.DeleteAccount(id, now)
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ stars, err := st.StarredLifetimes(id, "member@example.com")
+ if err != nil || len(stars) != 0 {
+ t.Fatalf("reap=%v: stars after deletion: %v %v", reap, stars, err)
+ }
+ }
+}
+
+func TestAppStarsEndOnlyWhenAppPurged(t *testing.T) {
+ st := openTestStore(t)
+ id := tempStoreAccount(t, st)
+ now := time.Now()
+ if _, err := st.CreateAppIn(id, "demo", "member@example.com", now); err != nil {
+ t.Fatal(err)
+ }
+ life := mustLife(t, st, id, "demo")
+ if err := st.SetAppStar(id, "member@example.com", life.Lifetime, true, now); err != nil {
+ t.Fatal(err)
+ }
+ if err := st.PurgeAppRow(id, "demo"); err != nil {
+ t.Fatal(err)
+ }
+ stars, err := st.StarredLifetimes(id, "member@example.com")
+ if err != nil || len(stars) != 1 {
+ t.Fatal("live app lost star")
+ }
+ if err := st.TrashAppRow(id, "demo", now); err != nil {
+ t.Fatal(err)
+ }
+ if err := st.PurgeAppRow(id, "demo"); err != nil {
+ t.Fatal(err)
+ }
+ stars, err = st.StarredLifetimes(id, "member@example.com")
+ if err != nil || len(stars) != 0 {
+ t.Fatalf("stars after purge: %v %v", stars, err)
+ }
+}
diff --git a/internal/console/claim_invariant_fixtures_test.go b/internal/console/claim_invariant_fixtures_test.go
index eecb2fdd9..9355886c1 100644
--- a/internal/console/claim_invariant_fixtures_test.go
+++ b/internal/console/claim_invariant_fixtures_test.go
@@ -1045,6 +1045,7 @@ var claimFixtures = map[string]claimFixture{
do: claimForm("/a/bab/apps/new", "name", "claim-web-new"),
}},
"route POST /a/{sqid}/apps/new/region": claimRead("answers a region guess as JSON; writes nothing"),
+ "route POST /a/{sqid}/apps/{app}/star": claimNonApp("the viewer's own bookmark in app_stars, keyed by account, person and app lifetime; reads the app row, writes nothing of the app's"),
"route POST /a/{sqid}/delete": claimNonApp("deletes an account only when it holds no app: AppCount is re-checked before the step-up and DeleteAccount refuses otherwise"),
"route POST /a/{sqid}/errors/level": claimNonApp("the account-level error log level (telemetry account record)"),
"route POST /a/{sqid}/fleets/{fleet}/detach": claimNonApp("detaches a fleet box in the registry; places no app"),
@@ -1247,6 +1248,27 @@ var claimFixtures = map[string]claimFixture{
setup: func(t *testing.T, cx *claimCase) { cx.temporary(t, "tmp-claim-keep") },
do: claimForm("/a/bab/apps/tmp-claim-keep/keep"),
}},
+ // The app list's Extend form (applist.go): setAppTTL's lock, settle and
+ // conditional update, from the current expiry.
+ "route POST /a/{sqid}/apps/{app}/extend": {door: &claimDoor{
+ apps: claimRefs("bab/tmp-claim-extend"),
+ setup: func(t *testing.T, cx *claimCase) { cx.temporary(t, "tmp-claim-extend") },
+ do: claimForm("/a/bab/apps/tmp-claim-extend/extend", "days", "7"),
+ check: func(t *testing.T, cx *claimCase, open bool) string {
+ l, err := cx.st.AppLife(OpsAccountID, "tmp-claim-extend")
+ if err != nil || l == nil {
+ return fmt.Sprintf("read the row: %v", err)
+ }
+ moved := l.ExpiresAt > time.Now().Add(5*24*time.Hour).Unix()
+ switch {
+ case open && !moved:
+ return "the open extension did not move the expiry"
+ case !open && moved:
+ return "the expiry moved while the app was closed under a foreign exclusive operation"
+ }
+ return ""
+ },
+ }},
// Account transfer is refused for every app on an enabled console
// (claimUnsupported); the world is one where it would otherwise run.
"route POST /a/{sqid}/apps/{app}/move": {refused: &claimRefusalFixture{
diff --git a/internal/console/claim_invariant_probes_nonapp_test.go b/internal/console/claim_invariant_probes_nonapp_test.go
index cb5893d76..723a3d270 100644
--- a/internal/console/claim_invariant_probes_nonapp_test.go
+++ b/internal/console/claim_invariant_probes_nonapp_test.go
@@ -639,6 +639,24 @@ var claimNonAppProbes = map[string]claimProbe{
return ""
},
},
+ "route POST /a/{sqid}/apps/{app}/star": {
+ do: claimFormReply("/a/bab/apps/kass/star", "starred", "true"),
+ status: http.StatusSeeOther, loc: "/a/bab/",
+ effect: func(t *testing.T, cx *claimCase, r claimReply) string {
+ l, err := cx.st.AppLife(OpsAccountID, "kass")
+ if err != nil || l == nil {
+ return fmt.Sprintf("read kass: %v", err)
+ }
+ stars, err := cx.st.StarredLifetimes(OpsAccountID, claimFxOwner)
+ if err != nil {
+ return err.Error()
+ }
+ if !stars[l.Lifetime] {
+ return "kass was not starred for the owner"
+ }
+ return ""
+ },
+ },
"route POST /a/{sqid}/errors/level": {
do: claimFormReply("/a/bab/errors/level", "level", "warn"),
status: http.StatusSeeOther, loc: "/a/bab/settings",
diff --git a/internal/console/icons.go b/internal/console/icons.go
index e80849051..f539b2fc7 100644
--- a/internal/console/icons.go
+++ b/internal/console/icons.go
@@ -63,6 +63,9 @@ const (
// (Lucide: check).
iconCheck template.HTML = iconOpen + `<path d="M20 6 9 17l-5-5"/></svg>`
+ // (Lucide: star)
+ iconStar template.HTML = iconOpen + `<path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.123 2.123 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.123 2.123 0 0 0 1.597-1.16z"/></svg>`
+
// "New account", in the same column the check sits in (Lucide: plus).
iconPlus template.HTML = iconOpen + `<path d="M5 12h14"/><path d="M12 5v14"/></svg>`
@@ -194,6 +197,7 @@ var icons = map[string]template.HTML{
"chevron-down": iconChevronDown,
"check": iconCheck,
"plus": iconPlus,
+ "star": iconStar,
"arrow-down": iconArrowDown,
"flask-conical": iconFlask,
"triangle-alert": iconTriangleAlert,
diff --git a/internal/console/ownership.go b/internal/console/ownership.go
index 37f8b88bc..56d464b19 100644
--- a/internal/console/ownership.go
+++ b/internal/console/ownership.go
@@ -833,6 +833,7 @@ func (s *Store) DeleteAccount(accountID int64, now time.Time) error {
return fmt.Errorf("console: this account still holds %d app(s)", apps)
}
for _, stmt := range []string{
+ `DELETE FROM app_stars WHERE account_id = ?`,
`DELETE FROM memberships WHERE account_id = ?`,
`DELETE FROM invites WHERE account_id = ?`,
} {
diff --git a/internal/console/server.go b/internal/console/server.go
index b6f64bc34..238422b2a 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -2009,6 +2009,10 @@ func NewServer(cfg Config, st *Store) (*Server, error) {
s.registerRoute("POST /a/{sqid}/apps/{app}/rename", s.handleAppRename)
s.registerRoute("POST /a/{sqid}/apps/{app}/region", s.handleAppRegionSet)
s.registerRoute("POST /a/{sqid}/apps/{app}/keep", s.handleAppKeep)
+ // The app list's star (any member, the viewer's own) and Extend form
+ // (owners) (applist.go).
+ s.registerRoute("POST /a/{sqid}/apps/{app}/star", s.handleAppStar)
+ s.registerRoute("POST /a/{sqid}/apps/{app}/extend", s.handleAppExtend)
s.registerRoute("POST /a/{sqid}/apps/{app}/delete", s.handleAppDelete)
s.registerRoute("POST /a/{sqid}/apps/{app}/move", s.handleAppMoveAccount)
// The control-plane flag's two directions, both browser-only and both
@@ -2437,7 +2441,15 @@ type page struct {
planAcctID int64
FlashErr string // one-shot error notice
- Apps []appRow // account home
+ Apps []appRow // account home
+ // The account home's lists (applist.go): Apps after the q filter
+ // (AppFilter), split into the viewer's starred apps, the other permanent
+ // apps and the other temporary apps. Apps stays every live app.
+ StarredApps []appRow
+ RegularApps []appRow
+ TemporaryApps []appRow
+ AppFilter string
+ AppListCopy appListCopy
Detail *AppView // /a/{sqid}/apps/{app}
Versions []VersionView // app page: shipped releases, newest first
Tags []release.Tag // releases tab: every tag this app has cut, changelog and all
@@ -2818,6 +2830,10 @@ type appRow struct {
// Elsewhere RC-15's counts of its instances in other regions.
Region appRegionFacts
Elsewhere []regionCount
+ // Starred is the viewer's own star (applist.go). ExpiresAt is a
+ // temporary app's expiry, zero for a permanent app.
+ Starred bool
+ ExpiresAt time.Time
}
func (s *Server) render(w http.ResponseWriter, status int, name string, p page) {
@@ -2825,6 +2841,7 @@ func (s *Server) render(w http.ResponseWriter, status int, name string, p page)
p.BrowserRestartCopy = approvedBrowserRestartCopy
p.MismatchCopy = approvedMismatchCopy
p.SigninCopy = approvedSigninView
+ p.AppListCopy = approvedAppListCopy
s.chrome(&p)
if s.writeTemplate(w, status, name, p) != nil {
return
@@ -4059,6 +4076,12 @@ 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)
}
+ // 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 {
+ log.Printf("console: app list %s: %v", acct.Sqid, err)
+ s.renderMessage(w, r, http.StatusInternalServerError, "Error", "Could not read your apps. Please try again.")
+ return
+ }
}
// The Trash link, and only when there is something in it. Best-effort: a
// failed count costs a link, never the page.
diff --git a/internal/console/store.go b/internal/console/store.go
index e9d4eb8e8..fe48e4d84 100644
--- a/internal/console/store.go
+++ b/internal/console/store.go
@@ -662,6 +662,10 @@ func (s *Store) migrate() error {
if err := s.migratePlanLapse(); err != nil {
return err
}
+ // The app list's personal stars (applist.go), for the same reason.
+ if err := s.migrateAppStars(); err != nil {
+ return err
+ }
// Plans 6b's seat count on the plan row (planmembers.go).
if err := s.migratePlanSeats(); err != nil {
return err
@@ -1500,6 +1504,9 @@ func removeMemberTx(tx *sql.Tx, accountID int64, address string) error {
if err := lastOwnerGuard(tx, accountID, address); err != nil {
return err
}
+ if _, err := tx.Exec(`DELETE FROM app_stars WHERE account_id = ? AND address = ?`, accountID, address); err != nil {
+ return err
+ }
_, err := tx.Exec(`DELETE FROM memberships WHERE account_id = ? AND address = ?`,
accountID, address)
return err
@@ -1742,6 +1749,7 @@ func (s *Store) ReapAccount(accountID int64, now time.Time) error {
}
defer tx.Rollback()
for _, stmt := range []string{
+ `DELETE FROM app_stars WHERE account_id = ?`,
`DELETE FROM memberships WHERE account_id = ?`,
`DELETE FROM invites WHERE account_id = ?`,
`DELETE FROM apps WHERE account_id = ?`,
@@ -2059,6 +2067,9 @@ func (s *Store) PurgeAppRow(accountID int64, app string) error {
return err
}
defer tx.Rollback()
+ if _, err := tx.ExecContext(ctx, `DELETE FROM app_stars WHERE account_id = ? AND lifetime IN (SELECT lifetime FROM apps WHERE account_id = ? AND app = ? AND deleted_at != 0)`, accountID, accountID, app); err != nil {
+ return err
+ }
res, err := tx.ExecContext(ctx, `DELETE FROM apps WHERE account_id = ? AND app = ? AND deleted_at != 0`, accountID, app)
if err != nil {
return err
diff --git a/internal/console/store_gate.go b/internal/console/store_gate.go
index afd308024..a35944aa7 100644
--- a/internal/console/store_gate.go
+++ b/internal/console/store_gate.go
@@ -188,6 +188,7 @@ var claimAppsTerminal = map[string][]string{
// cannot silently ship ungated. There is deliberately no exemption class:
// audit and mail telemetry are app-scoped and are gated like the rest.
var claimSQLTables = map[string]claimSQLTable{
+ "app_stars": {NonApp: "personal bookmarks keyed by account, address and app lifetime; grants no app authority"},
// ---- app-scoped: gated ----
"apps": {Account: "account_id", App: "app", AppID: "app_id", Terminal: claimAppsTerminal},
// Legacy per-app grants carry no account column, so a permit for app
diff --git a/internal/console/templates/app_settings.html b/internal/console/templates/app_settings.html
index 09be4156e..46d1231e5 100644
--- a/internal/console/templates/app_settings.html
+++ b/internal/console/templates/app_settings.html
@@ -18,6 +18,23 @@
</div>
<p class="small"><a href="{{.Nav}}/apps/{{.Detail.App}}/settings/pipeline">Release pipeline</a> — the channels a
release moves through, and what each one takes to promote onto.</p>
+{{if not .ExpiresAt.IsZero}}
+<h2>{{.AppListCopy.Expires}}</h2>
+<p><time datetime="{{.ExpiresAt.Format "2006-01-02T15:04:05Z07:00"}}">{{fmtTime .ExpiresAt}}</time></p>
+{{if .IsOwner}}
+<form method="post" action="{{.Base}}/apps/{{.Detail.App}}/extend" class="settings-row">
+ <input type="hidden" name="csrf" value="{{.CSRF}}">
+ <label for="extend-days">{{.AppListCopy.Extend}}</label>
+ <select id="extend-days" name="days">
+ <option value="1">{{.AppListCopy.OneDay}}</option>
+ <option value="7" selected>{{.AppListCopy.SevenDays}}</option>
+ <option value="30">{{.AppListCopy.ThirtyDays}}</option>
+ </select>
+ <button type="submit" class="btn-sm">{{.AppListCopy.Extend}}</button>
+</form>
+<p class="small">{{.AppListCopy.ExtensionHelp}}</p>
+{{end}}
+{{end}}
<h2>{{.RegionCopy.PickerLabel}}</h2>
{{if .StoredRegion.Known}}
<p>{{.StoredRegion.Sentence}}{{with .StoredRegion.SourceSentence}} {{.}}{{end}}</p>
diff --git a/internal/console/templates/apps.html b/internal/console/templates/apps.html
index a27c28f15..b5afd9792 100644
--- a/internal/console/templates/apps.html
+++ b/internal/console/templates/apps.html
@@ -7,21 +7,83 @@
{{if .Apps}}
<h1>Apps</h1>
</div>
-<div class="tablewrap app-list">
-<table role="table">
- <tr class="app-head" role="row"><th role="columnheader" scope="col">App</th><th role="columnheader" scope="col">Running at</th><th role="columnheader" scope="col">{{$.RegionCopy.PickerLabel}}</th><th role="columnheader" scope="col">Health</th><th role="columnheader" scope="col">{{$.StatusCopy.ObservedLabel}}</th></tr>
- {{range .Apps}}
- <tr role="row" data-app-row>
- <td role="cell" class="app-name"><a href="{{$.Nav}}/apps/{{.App}}">{{template "app_mark" .App}}<span class="app-label">{{.App}}</span></a></td>
+<form class="app-filter" method="get" action="{{.Base}}/">
+<label for="app-filter">{{.AppListCopy.Filter}}</label>
+<input id="app-filter" name="q" type="search" value="{{.AppFilter}}" placeholder="{{.AppListCopy.FilterPlaceholder}}" autocomplete="off" aria-controls="app-lists">
+<button type="submit">{{.AppListCopy.Filter}}</button></form>
+<div id="app-lists">
+{{if .StarredApps}}<section class="app-group" data-app-group><h2>{{.AppListCopy.Starred}}</h2><div class="tablewrap app-list"><table role="table">
+ <tr class="app-head" role="row"><th role="columnheader" scope="col">App</th><th role="columnheader" scope="col">Running at</th><th role="columnheader" scope="col">{{$.RegionCopy.PickerLabel}}</th><th role="columnheader" scope="col">Health</th><th role="columnheader" scope="col">{{$.StatusCopy.ObservedLabel}}</th><th role="columnheader" scope="col">{{$.AppListCopy.Expires}}</th></tr>
+{{range .StarredApps}}
+ <tr role="row" data-app-row data-app-name="{{.App}}" data-app-host="{{.URL}}">
+ <td role="cell" class="app-name"><form class="app-star" method="post" action="{{$.Base}}/apps/{{.App}}/star">
+ <input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="q" value="{{$.AppFilter}}">
+ <input type="hidden" name="starred" value="{{if .Starred}}false{{else}}true{{end}}">
+ <button class="linkish" type="submit" aria-label="{{if .Starred}}{{$.AppListCopy.Unstar}}{{else}}{{$.AppListCopy.Star}}{{end}}" aria-pressed="{{.Starred}}"> {{icon "star"}}</button>
+ </form><a href="{{$.Nav}}/apps/{{.App}}">{{template "app_mark" .App}}<span class="app-label">{{.App}}</span></a></td>
<td role="cell" class="app-host">{{if .URL}}<a href="https://{{.URL}}">{{.URL}}</a>{{else}}—{{end}}</td>
<td role="cell" class="app-region">{{if .Region.Known}}{{.Region.Text}}{{range .Elsewhere}}<br><span class="small">{{.Line}}</span>{{end}}{{else}}—{{end}}</td>
<td role="cell" class="app-health"><span class="chip chip-health-{{.Verdict}}">{{.VerdictLabel}}</span></td>
<td role="cell" class="app-observed{{if not (or .Deployment.Mixed .Deployment.UniformVersion .CanaryN)}} app-empty{{end}}"><span class="app-meta-label">{{$.StatusCopy.ObservedLabel}}</span>{{if .Deployment.Mixed}}{{$.StatusCopy.Mixed}}{{else if .Deployment.UniformVersion}}<code>{{.Deployment.UniformVersion}}</code>{{else}}—{{end}}{{if .CanaryN}} <span class="chip chip-canary">{{.CanaryN}} test version{{if ne .CanaryN 1}}s{{end}}</span>{{end}}</td>
+ <td role="cell" class="app-expiry{{if .ExpiresAt.IsZero}} app-empty{{end}}"><span class="app-meta-label">{{$.AppListCopy.Expires}}</span>{{if not .ExpiresAt.IsZero}}<time datetime="{{.ExpiresAt.Format "2006-01-02T15:04:05Z07:00"}}">{{fmtTime .ExpiresAt}}</time>
+ {{else}}—{{end}}</td>
</tr>
- {{end}}
-</table>
+{{end}}</table></div></section>{{end}}
+{{if .RegularApps}}<section class="app-group" data-app-group><h2>{{.AppListCopy.Regular}}</h2><div class="tablewrap app-list"><table role="table">
+ <tr class="app-head" role="row"><th role="columnheader" scope="col">App</th><th role="columnheader" scope="col">Running at</th><th role="columnheader" scope="col">{{$.RegionCopy.PickerLabel}}</th><th role="columnheader" scope="col">Health</th><th role="columnheader" scope="col">{{$.StatusCopy.ObservedLabel}}</th><th role="columnheader" scope="col">{{$.AppListCopy.Expires}}</th></tr>
+{{range .RegularApps}}
+ <tr role="row" data-app-row data-app-name="{{.App}}" data-app-host="{{.URL}}">
+ <td role="cell" class="app-name"><form class="app-star" method="post" action="{{$.Base}}/apps/{{.App}}/star">
+ <input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="q" value="{{$.AppFilter}}">
+ <input type="hidden" name="starred" value="{{if .Starred}}false{{else}}true{{end}}">
+ <button class="linkish" type="submit" aria-label="{{if .Starred}}{{$.AppListCopy.Unstar}}{{else}}{{$.AppListCopy.Star}}{{end}}" aria-pressed="{{.Starred}}"> {{icon "star"}}</button>
+ </form><a href="{{$.Nav}}/apps/{{.App}}">{{template "app_mark" .App}}<span class="app-label">{{.App}}</span></a></td>
+ <td role="cell" class="app-host">{{if .URL}}<a href="https://{{.URL}}">{{.URL}}</a>{{else}}—{{end}}</td>
+ <td role="cell" class="app-region">{{if .Region.Known}}{{.Region.Text}}{{range .Elsewhere}}<br><span class="small">{{.Line}}</span>{{end}}{{else}}—{{end}}</td>
+ <td role="cell" class="app-health"><span class="chip chip-health-{{.Verdict}}">{{.VerdictLabel}}</span></td>
+ <td role="cell" class="app-observed{{if not (or .Deployment.Mixed .Deployment.UniformVersion .CanaryN)}} app-empty{{end}}"><span class="app-meta-label">{{$.StatusCopy.ObservedLabel}}</span>{{if .Deployment.Mixed}}{{$.StatusCopy.Mixed}}{{else if .Deployment.UniformVersion}}<code>{{.Deployment.UniformVersion}}</code>{{else}}—{{end}}{{if .CanaryN}} <span class="chip chip-canary">{{.CanaryN}} test version{{if ne .CanaryN 1}}s{{end}}</span>{{end}}</td>
+ <td role="cell" class="app-expiry{{if .ExpiresAt.IsZero}} app-empty{{end}}"><span class="app-meta-label">{{$.AppListCopy.Expires}}</span>{{if not .ExpiresAt.IsZero}}<time datetime="{{.ExpiresAt.Format "2006-01-02T15:04:05Z07:00"}}">{{fmtTime .ExpiresAt}}</time>
+ {{else}}—{{end}}</td>
+ </tr>
+{{end}}</table></div></section>{{end}}
+{{if .TemporaryApps}}<section class="app-group" data-app-group><h2>{{.AppListCopy.Temporary}}</h2><div class="tablewrap app-list"><table role="table">
+ <tr class="app-head" role="row"><th role="columnheader" scope="col">App</th><th role="columnheader" scope="col">Running at</th><th role="columnheader" scope="col">{{$.RegionCopy.PickerLabel}}</th><th role="columnheader" scope="col">Health</th><th role="columnheader" scope="col">{{$.StatusCopy.ObservedLabel}}</th><th role="columnheader" scope="col">{{$.AppListCopy.Expires}}</th></tr>
+{{range .TemporaryApps}}
+ <tr role="row" data-app-row data-app-name="{{.App}}" data-app-host="{{.URL}}">
+ <td role="cell" class="app-name"><form class="app-star" method="post" action="{{$.Base}}/apps/{{.App}}/star">
+ <input type="hidden" name="csrf" value="{{$.CSRF}}"><input type="hidden" name="q" value="{{$.AppFilter}}">
+ <input type="hidden" name="starred" value="{{if .Starred}}false{{else}}true{{end}}">
+ <button class="linkish" type="submit" aria-label="{{if .Starred}}{{$.AppListCopy.Unstar}}{{else}}{{$.AppListCopy.Star}}{{end}}" aria-pressed="{{.Starred}}"> {{icon "star"}}</button>
+ </form><a href="{{$.Nav}}/apps/{{.App}}">{{template "app_mark" .App}}<span class="app-label">{{.App}}</span></a></td>
+ <td role="cell" class="app-host">{{if .URL}}<a href="https://{{.URL}}">{{.URL}}</a>{{else}}—{{end}}</td>
+ <td role="cell" class="app-region">{{if .Region.Known}}{{.Region.Text}}{{range .Elsewhere}}<br><span class="small">{{.Line}}</span>{{end}}{{else}}—{{end}}</td>
+ <td role="cell" class="app-health"><span class="chip chip-health-{{.Verdict}}">{{.VerdictLabel}}</span></td>
+ <td role="cell" class="app-observed{{if not (or .Deployment.Mixed .Deployment.UniformVersion .CanaryN)}} app-empty{{end}}"><span class="app-meta-label">{{$.StatusCopy.ObservedLabel}}</span>{{if .Deployment.Mixed}}{{$.StatusCopy.Mixed}}{{else if .Deployment.UniformVersion}}<code>{{.Deployment.UniformVersion}}</code>{{else}}—{{end}}{{if .CanaryN}} <span class="chip chip-canary">{{.CanaryN}} test version{{if ne .CanaryN 1}}s{{end}}</span>{{end}}</td>
+ <td role="cell" class="app-expiry{{if .ExpiresAt.IsZero}} app-empty{{end}}"><span class="app-meta-label">{{$.AppListCopy.Expires}}</span>{{if not .ExpiresAt.IsZero}}<time datetime="{{.ExpiresAt.Format "2006-01-02T15:04:05Z07:00"}}">{{fmtTime .ExpiresAt}}</time>
+ {{else}}—{{end}}</td>
+ </tr>
+{{end}}</table></div></section>{{end}}
+</div><p id="app-no-matches" role="status" {{if or .StarredApps .RegularApps .TemporaryApps}}hidden{{end}}>{{.AppListCopy.NoMatches}}</p>
+{{else}}
+ <h1>Welcome to {{.ConsoleName}}</h1>
</div>
+<p>The account <strong>{{.Account.Name}}</strong> is ready. No apps live here yet — claim a name below and it's yours.</p>
+{{end}}
+{{if .TrashN}}<p class="small"><a href="{{.Nav}}/trash">Trash ({{.TrashN}})</a>: deleted apps you can still
+ restore, each until the date shown there.</p>{{end}}
+<p><a class="btn" href="{{.Nav}}/apps/new">Create app</a></p>
+
<style>
+.app-filter { display: flex; align-items: stretch; gap: .5rem; max-width: 32rem; margin: 1rem 0; }
+.app-filter label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
+.app-filter input { flex: 1; min-width: 0; width: auto; max-width: none; box-sizing: border-box; min-height: 40px; font-size: 16px; }
+.app-filter button { flex-shrink: 0; width: auto; margin: 0; min-height: 40px; padding: 8px 12px; font-size: 13px; }
+.app-group { margin: 1.5rem 0; }.app-group h2 { margin: 0 0 .5rem; }
+.app-star { display: inline; margin-right: .5rem; }.app-star button { background: none; border: 0; color: var(--accent); padding: .4rem; }
+.app-star button[aria-pressed="true"] svg { fill: currentColor; }
+.app-star button:focus-visible { outline: 2px solid var(--accent); }.app-extend { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }.app-extend select { width: auto; }.app-group time { white-space: nowrap; }
+.app-meta-label { display: none; }
+
.app-list .app-meta-label { display: none; }
.app-list tr[data-app-row] { position: relative; }
.app-list .app-name a { display: inline-flex; align-items: center; gap: 0.65rem; max-width: 100%; min-height: 44px; }
@@ -39,7 +101,7 @@
.tablewrap.app-list > table { display: block; width: 100%; margin: 0; }
.tablewrap.app-list > table > tbody { display: block; }
.tablewrap.app-list tr.app-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
-.tablewrap.app-list tr[data-app-row] { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "name name" "host host" "health region" "observed observed"; gap: 4px 12px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
+.tablewrap.app-list tr[data-app-row] { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "name name" "host host" "health region" "observed observed" "expiry expiry"; gap: 4px 12px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.tablewrap.app-list > table > tbody > tr[data-app-row]:last-child { border-bottom: 0; }
.tablewrap.app-list > table tr[data-app-row] > td { display: block; min-width: 0; margin: 0; padding: 0; border: 0; overflow-wrap: anywhere; white-space: normal; }
.tablewrap.app-list > table tr[data-app-row] > td.app-name { grid-area: name; padding-left: 0; font-size: 17px; line-height: 24px; font-weight: 600; }
@@ -57,14 +119,21 @@
.tablewrap.app-list .app-meta-label { display: inline; margin-right: 6px; font-size: 12px; color: var(--muted); }
.tablewrap.app-list > table tr[data-app-row] > td.app-empty { display: none; }
}
+
+.app-list .app-star, .app-list .app-extend { position: relative; z-index: 2; }
+.app-list .app-star button { min-width: 44px; min-height: 44px; }
+@media (max-width: 800px) {
+.app-group { margin: 20px 0 0; }
+.app-group h2 { font-size: 14px; line-height: 20px; margin: 0 0 4px; }
+.tablewrap.app-list > table tr[data-app-row] > td.app-name { padding-right: 48px; }
+.app-list .app-star { position: absolute; right: 8px; top: 12px; margin: 0; }
+.app-list .app-star button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; margin: 0; }
+.app-list .app-star svg { width: 18px; height: 18px; }
+.tablewrap.app-list > table tr[data-app-row] > td.app-expiry { grid-area: expiry; font-size: 13px; line-height: 20px; }
+.app-list .app-expiry time { white-space: normal; }
+.app-list .app-extend { max-width: 100%; margin-top: 6px; }
+.app-list .app-extend select, .app-list .app-extend button { min-height: 44px; font-size: 13px; padding: 0 12px; max-width: 100%; box-sizing: border-box; }
+}
</style>
-{{else}}
- <h1>Welcome to {{.ConsoleName}}</h1>
-</div>
-<p>The account <strong>{{.Account.Name}}</strong> is ready. No apps live here yet — claim a name below and it's yours.</p>
-{{end}}
-{{if .TrashN}}<p class="small"><a href="{{.Nav}}/trash">Trash ({{.TrashN}})</a>: deleted apps you can still
- restore, each until the date shown there.</p>{{end}}
-<p><a class="btn" href="{{.Nav}}/apps/new">Create app</a></p>
{{template "bottom" .}}{{end}}
diff --git a/internal/console/testdata/claim-routes.txt b/internal/console/testdata/claim-routes.txt
index 8803e8889..a9167ab18 100644
--- a/internal/console/testdata/claim-routes.txt
+++ b/internal/console/testdata/claim-routes.txt
@@ -168,6 +168,7 @@ route POST /a/{sqid}/apps/{app}/delete
route POST /a/{sqid}/apps/{app}/domains/attach
route POST /a/{sqid}/apps/{app}/domains/detach
route POST /a/{sqid}/apps/{app}/errors/level
+route POST /a/{sqid}/apps/{app}/extend
route POST /a/{sqid}/apps/{app}/fasttrack
route POST /a/{sqid}/apps/{app}/gate
route POST /a/{sqid}/apps/{app}/instances/{host}/restart
@@ -188,6 +189,7 @@ route POST /a/{sqid}/apps/{app}/region
route POST /a/{sqid}/apps/{app}/rename
route POST /a/{sqid}/apps/{app}/restart
route POST /a/{sqid}/apps/{app}/rollback
+route POST /a/{sqid}/apps/{app}/star
route POST /a/{sqid}/apps/{app}/store/destroy
route POST /a/{sqid}/apps/{app}/swap
route POST /a/{sqid}/billing/change
diff --git a/internal/provision/app_lists_census_test.go b/internal/provision/app_lists_census_test.go
new file mode 100644
index 000000000..acb27382e
--- /dev/null
+++ b/internal/provision/app_lists_census_test.go
@@ -0,0 +1,33 @@
+package provision
+
+// Record-write census entry for the app list's stars and Extend form
+// (branch app-lists), layered on regionHAP2aTransfersWriteCensusInventory (main's
+// newest at 322d2447). Reviewed by the branch author. No record write is
+// added, moved or reclassified:
+// - NewServer: registers POST /a/{sqid}/apps/{app}/star and
+// POST /a/{sqid}/apps/{app}/extend (internal/console/applist.go). The
+// star writes the console's SQLite app_stars table; the Extend form
+// writes the apps row's expires_at through setAppTTL's store update.
+// Neither writes a bucket record. Same "instances" literal: still
+// key-site.
+func appListsWriteCensusInventory() []censusEntry {
+ entries := append([]censusEntry(nil), regionHAP2aTransfersWriteCensusInventory()...)
+ repins := []censusEntry{
+ {"internal/console/server.go", "NewServer", "key-site", "lit:instances", "4c82a24f2574a6c29de312add6cc8eaded45db5e15e88ea37677b76eb68d154e"},
+ }
+ for _, r := range repins {
+ found := false
+ for i, e := range entries {
+ if e.File == r.File && e.Unit == r.Unit {
+ if e.Class != r.Class || e.Kinds != r.Kinds {
+ panic("app-lists re-pin changes the class or kinds of " + r.File + ":" + r.Unit)
+ }
+ entries[i], found = r, true
+ }
+ }
+ if !found {
+ panic("app-lists re-pin of an unlisted unit " + r.File + ":" + r.Unit)
+ }
+ }
+ return entries
+}
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go
index 1aa828c82..589d685db 100644
--- a/internal/provision/plan9_b8_census_test.go
+++ b/internal/provision/plan9_b8_census_test.go
@@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) {
if len(got) < 100 {
t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root)
}
- inventory := regionHAP2aTransfersWriteCensusInventory()
+ inventory := appListsWriteCensusInventory()
problems := append(censusDiff(inventory, got), censusPolicy(inventory)...)
if len(problems) > 0 {
t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n "))