oficina / equipo Public

Connections: name accounts, drop stale meters, say what Automatic does

Four display bugs from Paul's 2026-11-10 22:30Z screenshot (Claude
Ready; Codex promax limited until Thu; Codex keymail serving the
coordinator):

- With more than one connection of a provider, the summary and the
  resting row name the account ("Codex (paul@keymail.dev)", "your other
  Codex account").
- A window whose reset has passed, or a full window on a connection
  that answers, is stale: no percentage or reset until fresh numbers.
- A resting row's destination is where work runs now (the coordinator's
  last connection, then running steps), not the first healthy one.
- Under Automatic the summary says work stays put until the next
  message or step; with a preference, that work moves to it.

Tests build the view from the screenshot's snapshot; each failed on the
old view with the screenshot's exact wrong text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 461ce02fa1e02dd06fd091880d33e5be8b622ed8 parent d6c0e12
5 files changed, +245 −28
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +4 −1
  • internal/equipo/chat_connections.go +1 −1
  • internal/equipo/connections_view.go +105 −25
  • internal/equipo/connections_view_test.go +131 −0
  • internal/equipo/copy.go +4 −1
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index 870453dc..eb20931d 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -5253,7 +5253,10 @@ records remain unchanged.
| `chat.connections.answering.rests_until` | %s rests until %s | Connections slice 1 (Connections page, Paul's approved mockup) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `chat.connections.and` | and | Connections slice 1 (Connections page, Paul's approved mockup) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `chat.connections.answering.too` | Engineering and Review are on %s too. | Connections slice 1 (Connections page, Paul's approved mockup) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
-| `chat.connections.answering.back` | Everything moves back when %s returns. | Connections slice 1 (Connections page, Paul's approved mockup) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
+| `chat.connections.answering.stays` | Work stays where it is until the next message or step, then Equipo picks the healthiest connection with headroom. | Connections page fixes (Paul, 2026-11-10: name the account, say what Automatic does) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
+| `chat.connections.answering.to_preferred` | Work moves to %s, your preference, from the next message or step once it is ready. | Connections page fixes (Paul, 2026-11-10: name the account, say what Automatic does) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
+| `chat.connections.answering.other` | your other %s account | Connections page fixes (Paul, 2026-11-10: name the account, say what Automatic does) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
+| `chat.connections.named` | %s (%s) | Connections page fixes (Paul, 2026-11-10: name the account, say what Automatic does) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `chat.connections.answering.connecting` | %s is connecting. Once it is ready, Review can run on another model family. | Connections slice 1 (Connections page, Paul's approved mockup) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `chat.connections.answering.none` | Nothing can answer right now. | Connections slice 1 (Connections page, Paul's approved mockup) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `chat.connections.answering.no_reset` | %s reported no reset time, so Equipo checks again in 15 minutes | Connections slice 1 (Connections page, Paul's approved mockup) | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
diff --git a/internal/equipo/chat_connections.go b/internal/equipo/chat_connections.go
index 00c5e10b..76b7734c 100644
--- a/internal/equipo/chat_connections.go
+++ b/internal/equipo/chat_connections.go
@@ -195,7 +195,7 @@ func (a *application) connectionsView(w http.ResponseWriter, r *http.Request) {
a.failure(w, r, chatError(err))
return
}
- v := connectionsPage(snap, today, prefer, runner)
+ v := connectionsPage(snap, today, prefer, runner, time.Now())
data.Models, data.ConnectionsStream = v, true
render(w, "models", data)
}
diff --git a/internal/equipo/connections_view.go b/internal/equipo/connections_view.go
index 747a8f54..c92167ef 100644
--- a/internal/equipo/connections_view.go
+++ b/internal/equipo/connections_view.go
@@ -83,7 +83,7 @@ type connOption struct {
// connectionsPage builds the page from the snapshot, today's usage per
// connection and the preference.
-func connectionsPage(snap wire.Snapshot, today map[string]int64, prefer wire.Preferences, runner string) modelsView {
+func connectionsPage(snap wire.Snapshot, today map[string]int64, prefer wire.Preferences, runner string, now time.Time) modelsView {
v := modelsView{Offline: !snap.Runner.Online, Runner: runner, Cursor: snap.Cursor}
v.Prefer = preferControl(prefer)
live := liveRoles(snap)
@@ -114,13 +114,10 @@ func connectionsPage(snap wire.Snapshot, today map[string]int64, prefer wire.Pre
held = append(held, c)
}
}
- healthy := ""
- for _, c := range held {
- if c.State == wire.ConnHealthy {
- healthy = providerName(c.Provider)
- break
- }
+ for i, c := range held {
+ held[i] = freshen(c, now)
}
+ names := namesOf(held)
if coord == "" {
// Nothing answered yet: the first that can, the preferred first.
for _, c := range held {
@@ -129,6 +126,7 @@ func connectionsPage(snap wire.Snapshot, today map[string]int64, prefer wire.Pre
}
}
}
+ work := workOn(snap, held, coord)
for _, c := range held {
row := connRow{ID: c.ID, Provider: c.Provider, Name: providerName(c.Provider), Glyph: providerGlyph(c.Provider), Label: c.Label, Plan: c.Plan, Kind: c.Kind, State: c.State, Words: connectionState(c), Usage: tokensText(today[c.LocalID]), PreferRevision: prefer.Revision}
_, row.UsageTail, _ = strings.Cut(copyText("chat.connections.usage_today"), "%s")
@@ -136,7 +134,7 @@ func connectionsPage(snap wire.Snapshot, today map[string]int64, prefer wire.Pre
row.State = wire.ConnSignInAgain
}
if c.Kind == wire.KindToken {
- tokenFacts(&row, c, time.Now())
+ tokenFacts(&row, c, now)
}
if c.Headroom != nil && row.State != wire.ConnSignedOut && row.State != wire.ConnSignInAgain {
for _, w := range c.Headroom.Windows {
@@ -151,8 +149,14 @@ func connectionsPage(snap wire.Snapshot, today map[string]int64, prefer wire.Pre
row.CheckAgain = c.Kind == wire.KindToken && c.LocalID != ""
case wire.ConnLimited:
row.RolesNote = copyText("chat.connections.roles.resting_none")
- if healthy != "" {
- row.RolesNote = fmt.Sprintf(copyText("chat.connections.roles.resting_moved"), healthy)
+ var to []string
+ for _, w := range work {
+ if w.LocalID != c.LocalID {
+ to = append(to, names.of(w))
+ }
+ }
+ if len(to) > 0 {
+ row.RolesNote = fmt.Sprintf(copyText("chat.connections.roles.resting_moved"), strings.Join(to, copyText("chat.connections.and")))
}
default:
if c.LocalID == coord {
@@ -174,7 +178,7 @@ func connectionsPage(snap wire.Snapshot, today map[string]int64, prefer wire.Pre
}
v.Rows = append(v.Rows, row)
}
- v.Answering = answering(held, coord, v.Attempts)
+ v.Answering = answering(held, coord, v.Attempts, names, prefer.Provider)
return v
}
@@ -235,25 +239,29 @@ func coordinatorOn(snap wire.Snapshot) string {
return ""
}
-// answering says what answers now, or why nothing can.
-func answering(held []wire.Connection, coord string, attempts []modelLine) connAnswering {
+// answering says what answers now, or why nothing can. A connection is
+// named by its account when the person holds more than one of its
+// provider; what happens next is what the choice does, not a promise
+// (Paul, 2026-11-10): under Automatic work stays put until its next
+// message or step; with a preference it moves to the preferred one.
+func answering(held []wire.Connection, coord string, attempts []modelLine, names connNames, prefer string) connAnswering {
if len(held) == 0 {
return connAnswering{}
}
- var on string
+ var on *wire.Connection
var resting []wire.Connection
- for _, c := range held {
+ for i, c := range held {
if c.LocalID == coord && c.State == wire.ConnHealthy {
- on = providerName(c.Provider)
+ on = &held[i]
}
if c.State == wire.ConnLimited {
resting = append(resting, c)
}
}
- if on == "" {
+ if on == nil {
var parts []string
for _, c := range held {
- name := providerName(c.Provider)
+ name := names.of(c)
switch c.State {
case wire.ConnLimited:
if c.Headroom != nil && c.Headroom.ResetsAt != nil {
@@ -275,12 +283,15 @@ func answering(held []wire.Connection, coord string, attempts []modelLine) connA
}
a := connAnswering{}
a.LeadStart, a.LeadEnd, _ = strings.Cut(copyText("chat.connections.answering.on"), "%s")
- a.LeadName = on
+ a.LeadName = names.of(*on)
+ a.Sub = fmt.Sprintf(copyText("chat.connections.answering.too"), a.LeadName)
if len(resting) > 0 {
- var rests, names []string
+ var rests []string
for _, c := range resting {
- name := providerName(c.Provider)
- names = append(names, name)
+ name := names.of(c)
+ if c.Provider == on.Provider && names[c.Provider] == 2 {
+ name = fmt.Sprintf(copyText("chat.connections.answering.other"), providerName(c.Provider))
+ }
if c.Headroom != nil && c.Headroom.ResetsAt != nil {
rests = append(rests, fmt.Sprintf(copyText("chat.connections.answering.rests_until"), name, resetText(*c.Headroom.ResetsAt)))
} else {
@@ -288,9 +299,12 @@ func answering(held []wire.Connection, coord string, attempts []modelLine) connA
}
}
a.LeadEnd = fmt.Sprintf(copyText("chat.connections.answering.while"), strings.Join(rests, copyText("chat.connections.and")))
- a.Sub = fmt.Sprintf(copyText("chat.connections.answering.too"), on) + " " + fmt.Sprintf(copyText("chat.connections.answering.back"), strings.Join(names, copyText("chat.connections.and")))
- } else {
- a.Sub = fmt.Sprintf(copyText("chat.connections.answering.too"), on)
+ switch {
+ case prefer == "":
+ a.Sub += " " + copyText("chat.connections.answering.stays")
+ case prefer != on.Provider && names[prefer] > 0:
+ a.Sub += " " + fmt.Sprintf(copyText("chat.connections.answering.to_preferred"), providerName(prefer))
+ }
}
if len(attempts) > 0 {
a.Sub = fmt.Sprintf(copyText("chat.connections.answering.connecting"), attempts[0].Name)
@@ -298,6 +312,72 @@ func answering(held []wire.Connection, coord string, attempts []modelLine) connA
return a
}
+// connNames counts the person's connections by provider, to name each:
+// the provider, and the account when there is more than one of it.
+type connNames map[string]int
+
+func namesOf(held []wire.Connection) connNames {
+ n := connNames{}
+ for _, c := range held {
+ n[c.Provider]++
+ }
+ return n
+}
+
+func (n connNames) of(c wire.Connection) string {
+ if n[c.Provider] > 1 && c.Label != "" {
+ return fmt.Sprintf(copyText("chat.connections.named"), providerName(c.Provider), c.Label)
+ }
+ return providerName(c.Provider)
+}
+
+// workOn is where the person's work runs now: the coordinator's
+// connection, then those running a step, each once.
+func workOn(snap wire.Snapshot, held []wire.Connection, coord string) []wire.Connection {
+ ids := []string{coord}
+ for _, k := range snap.Tasks {
+ for _, s := range k.Steps {
+ if s.State == wire.StepRunning && s.Account != "" {
+ ids = append(ids, s.Account)
+ }
+ }
+ }
+ var out []wire.Connection
+ seen := map[string]bool{"": true}
+ for _, id := range ids {
+ for _, c := range held {
+ if c.LocalID == id && !seen[id] && c.State == wire.ConnHealthy {
+ seen[id] = true
+ out = append(out, c)
+ }
+ }
+ }
+ return out
+}
+
+// freshen drops what the provider reported that has gone stale: a
+// window or reset time already passed, and a full window on a
+// connection that answers (Paul, 2026-11-10: Ready with a full bar
+// after its reset). The meter stays away until fresh numbers come.
+func freshen(c wire.Connection, now time.Time) wire.Connection {
+ if c.Headroom == nil {
+ return c
+ }
+ h := *c.Headroom
+ if h.ResetsAt != nil && !h.ResetsAt.After(now) {
+ h.ResetsAt = nil
+ }
+ h.Windows = nil
+ for _, w := range c.Headroom.Windows {
+ if w.ResetsAt != nil && !w.ResetsAt.After(now) || c.State == wire.ConnHealthy && w.UsedPercent >= 99.5 {
+ continue
+ }
+ h.Windows = append(h.Windows, w)
+ }
+ c.Headroom = &h
+ return c
+}
+
// meterOf is one reported window in words.
func meterOf(w wire.Window) connMeter {
m := connMeter{Used: int(w.UsedPercent + 0.5), Level: "ok"}
diff --git a/internal/equipo/connections_view_test.go b/internal/equipo/connections_view_test.go
new file mode 100644
index 00000000..c3db6776
--- /dev/null
+++ b/internal/equipo/connections_view_test.go
@@ -0,0 +1,131 @@
+package equipo
+
+import (
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// Paul's screenshot, Tue 2026-11-10 22:30 UTC: Claude paul@tito.io Ready
+// (its week window reported full, resetting Tue 21:00, which has passed);
+// Codex paul@tito.io promax limited until Thu 09:36; Codex
+// paul@keymail.dev prolite Ready, the coordinator's last turn on it.
+var screenshotNow = time.Date(2026, 11, 10, 22, 30, 0, 0, time.UTC)
+
+func screenshotSnapshot() wire.Snapshot {
+ weekReset := time.Date(2026, 11, 10, 21, 0, 0, 0, time.UTC)
+ codexReset := time.Date(2026, 11, 12, 9, 36, 0, 0, time.UTC)
+ return wire.Snapshot{
+ Runner: wire.Runner{ID: "r1", Online: true},
+ Connections: []wire.Connection{
+ {ID: "c-claude", LocalID: "claude-1", Provider: wire.ProviderClaude, Label: "paul@tito.io", State: wire.ConnHealthy, Headroom: &wire.Headroom{Windows: []wire.Window{{Name: "seven_day", UsedPercent: 100, Minutes: 7 * 24 * 60, ResetsAt: &weekReset}}}},
+ {ID: "c-promax", LocalID: "codex-1", Provider: wire.ProviderCodex, Label: "paul@tito.io", Plan: "promax", State: wire.ConnLimited, Headroom: &wire.Headroom{ResetsAt: &codexReset, Windows: []wire.Window{{Name: "secondary", UsedPercent: 100, Minutes: 7 * 24 * 60, ResetsAt: &codexReset}}}},
+ {ID: "c-prolite", LocalID: "codex-2", Provider: wire.ProviderCodex, Label: "paul@keymail.dev", Plan: "prolite", State: wire.ConnHealthy},
+ },
+ Turns: []wire.Turn{
+ {ID: "t1", State: wire.TurnReplied, Connection: "codex-1", UpdatedAt: screenshotNow.Add(-3 * time.Hour)},
+ {ID: "t2", State: wire.TurnReplied, Connection: "codex-2", UpdatedAt: screenshotNow.Add(-10 * time.Minute)},
+ },
+ }
+}
+
+func rowOf(t *testing.T, v modelsView, id string) connRow {
+ t.Helper()
+ for _, r := range v.Rows {
+ if r.ID == id {
+ return r
+ }
+ }
+ t.Fatalf("no row %s", id)
+ return connRow{}
+}
+
+func lead(a connAnswering) string { return a.LeadStart + a.LeadName + a.LeadEnd }
+
+// Bug 1: with two Codex connections, the summary names the account, and
+// the resting one is the other Codex account, not "Codex".
+func TestConnectionsSummaryNamesTheAccount(t *testing.T) {
+ v := connectionsPage(screenshotSnapshot(), nil, wire.Preferences{}, "Tito Studio", screenshotNow)
+ want := "Your coordinator is on Codex (paul@keymail.dev) while your other Codex account rests until Thu 09:36 UTC."
+ if got := lead(v.Answering); got != want {
+ t.Fatalf("lead %q, want %q", got, want)
+ }
+ if v.Answering.LeadName != "Codex (paul@keymail.dev)" {
+ t.Fatalf("bold name %q", v.Answering.LeadName)
+ }
+ // One connection of a provider: the provider alone.
+ snap := screenshotSnapshot()
+ snap.Connections = snap.Connections[:2]
+ snap.Turns = snap.Turns[:0]
+ one := connectionsPage(snap, nil, wire.Preferences{}, "Tito Studio", screenshotNow)
+ if got := lead(one.Answering); got != "Your coordinator is on Claude while Codex rests until Thu 09:36 UTC." {
+ t.Fatalf("one of each: %q", got)
+ }
+}
+
+// Bug 2: a window whose reset has passed shows no stale percentage or
+// reset; nor does a full window on a connection that answers.
+func TestConnectionsStaleMeterAfterReset(t *testing.T) {
+ v := connectionsPage(screenshotSnapshot(), nil, wire.Preferences{}, "Tito Studio", screenshotNow)
+ if m := rowOf(t, v, "c-claude").Meters; len(m) != 0 {
+ t.Fatalf("Claude shows a stale meter after its reset: %+v", m)
+ }
+ // The resting Codex keeps its reported window: its reset is ahead.
+ if m := rowOf(t, v, "c-promax").Meters; len(m) != 1 || m[0].Used != 100 || m[0].Resets != "resets Thu 09:36 UTC" {
+ t.Fatalf("promax meters %+v", m)
+ }
+ snap := screenshotSnapshot()
+ ahead := screenshotNow.Add(30 * time.Hour)
+ snap.Connections[0].Headroom = &wire.Headroom{Windows: []wire.Window{
+ {Name: "five_hour", UsedPercent: 40, Minutes: 300, ResetsAt: &ahead},
+ {Name: "seven_day", UsedPercent: 100, Minutes: 7 * 24 * 60, ResetsAt: &ahead},
+ }}
+ m := rowOf(t, connectionsPage(snap, nil, wire.Preferences{}, "", screenshotNow), "c-claude").Meters
+ if len(m) != 1 || m[0].Used != 40 {
+ t.Fatalf("a Ready connection shows a full window, or lost its fresh one: %+v", m)
+ }
+ // A limited connection whose reset has passed is not "until" then.
+ past := screenshotNow.Add(-time.Hour)
+ snap.Connections[1].Headroom = &wire.Headroom{ResetsAt: &past}
+ if w := rowOf(t, connectionsPage(snap, nil, wire.Preferences{}, "", screenshotNow), "c-promax").Words; w != copyText("chat.connections.limited") {
+ t.Fatalf("limited words %q", w)
+ }
+}
+
+// Bug 3: the resting row says where its work went: the connection the
+// coordinator last answered on, named by account, not the first healthy.
+func TestConnectionsRestingDestination(t *testing.T) {
+ v := connectionsPage(screenshotSnapshot(), nil, wire.Preferences{}, "Tito Studio", screenshotNow)
+ if got := rowOf(t, v, "c-promax").RolesNote; got != "Resting. Its work moved to Codex (paul@keymail.dev)." {
+ t.Fatalf("resting note %q", got)
+ }
+ if r := rowOf(t, v, "c-prolite"); len(r.Roles) != 1 || r.Roles[0].Name != copyText("conversation.coordinator") {
+ t.Fatalf("keymail roles %+v", r.Roles)
+ }
+ if r := rowOf(t, v, "c-claude"); len(r.Roles) != 0 {
+ t.Fatalf("Claude claims a role %+v", r.Roles)
+ }
+ // A step running on Claude: the work went there too.
+ snap := screenshotSnapshot()
+ snap.Tasks = []wire.Task{{ID: "k1", Steps: []wire.Step{{ID: "s1", Specialist: wire.SpecialistEngineering, State: wire.StepRunning, Account: "claude-1"}}}}
+ v = connectionsPage(snap, nil, wire.Preferences{}, "", screenshotNow)
+ if got := rowOf(t, v, "c-promax").RolesNote; got != "Resting. Its work moved to Codex (paul@keymail.dev) and Claude." {
+ t.Fatalf("resting note with a step %q", got)
+ }
+}
+
+// Bug 4: under Automatic there is no "moves back": work stays until its
+// next message or step, then the healthiest with headroom is picked.
+// With a preference, the summary may say work moves to it.
+func TestConnectionsSummaryNoInventedPreference(t *testing.T) {
+ v := connectionsPage(screenshotSnapshot(), nil, wire.Preferences{}, "Tito Studio", screenshotNow)
+ if strings.Contains(v.Answering.Sub, "moves back") || !strings.Contains(v.Answering.Sub, copyText("chat.connections.answering.stays")) {
+ t.Fatalf("automatic sub %q", v.Answering.Sub)
+ }
+ v = connectionsPage(screenshotSnapshot(), nil, wire.Preferences{Provider: wire.ProviderClaude, Revision: 1}, "Tito Studio", screenshotNow)
+ if !strings.Contains(v.Answering.Sub, "Work moves to Claude, your preference,") || strings.Contains(v.Answering.Sub, copyText("chat.connections.answering.stays")) {
+ t.Fatalf("preferred sub %q", v.Answering.Sub)
+ }
+}
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index aecced71..4d347ccf 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -740,7 +740,10 @@ var pageCopy = map[string]string{
"chat.connections.answering.rests_until": "%s rests until %s", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.and": " and ", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.answering.too": "Engineering and Review are on %s too.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
- "chat.connections.answering.back": "Everything moves back when %s returns.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "chat.connections.answering.stays": "Work stays where it is until the next message or step, then Equipo picks the healthiest connection with headroom.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "chat.connections.answering.to_preferred": "Work moves to %s, your preference, from the next message or step once it is ready.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "chat.connections.answering.other": "your other %s account", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "chat.connections.named": "%s (%s)", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.answering.connecting": "%s is connecting. Once it is ready, Review can run on another model family.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.answering.none": "Nothing can answer right now.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.connections.answering.no_reset": "%s reported no reset time, so Equipo checks again in 15 minutes", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)