oficina / equipo Public

Gate 1d: connections in Settings, browser checks, switched line kept

Settings links to the Connections page. Browser tests for A1 (Add
Codex: OpenAI's page and code, then the connection), A4 (Add Claude
elsewhere: only the finish-on-runner card, nothing to paste), F1 (the
switched line under a reply that moved) and F7 (the waiting card, then
the reply once Codex is added, without a reload). They caught the live
page dropping the switched line when a reply settled into its draft:
fixed in chat-stream.js.

CI: an unused regexp removed (staticcheck); size and time records for
the thin runner and the headless suite with reasons.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 959559062644ffcd0208380f648a6b104fa81306 parent 487e250
5 files changed, +94 −7
  • .rastrillo/budgets.txt +2 −2
  • internal/equipo/static/chat-stream.js +3 −0
  • internal/equipo/templates/settings.html +1 −0
  • internal/headless/browser_connections_test.go +88 −0
  • internal/runner/connect/login.go +0 −5

CI failed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 222c4d01..15bcba2c 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -35,10 +35,10 @@ time internal/runner/provider 15s Plan 3 CI repair measured 10.346s for the full
perf GET /releases/* skip Verified runner release file downloads, not browser GET screens.
time internal/runner/containment 15s Plan 3 loaded CI measured 10.817s; niced serial reruns measured 5.773s and 5.750s. The added coordinator mount check has no repeated launches to remove; 15s leaves 38 percent headroom for namespace, process-exit and recovery assertions.
time internal/tryequipo 30s Release starter-set controller K3 records CI runs of 10.8s and 13.1s; 30s retains the guide integration checks with headroom on the shared runner.
-size internal/runner/thin 10300 - Connections slice 1 adds the Codex coordinator beside the Claude one (codex.go: the pinned app-server over JSON-RPC in the converse containment, sharing the coordinator base, desk, tool socket and session table), the connection registry over the bindings with health and provider limits (conns.go), in-app sign-in attempts (connector.go) and turn failover and holding (failover.go), about 1500 lines; the pure parts (the choice function, limit parsing, the app-server client, the sign-in flows) live in internal/runner/connect. Measured 10097. Thin v1 slice 4c adds the merge step (mergestep.go, about 190 lines) and the rebase round beside the slice 4b ask fixes. Thin v1 slice 3 adds Engineering steps beside the coordinator: the durable step state and engine (step.go) and the executor that checks out the task tree, runs the CLI in the implement containment, commits and pushes (engineer.go), about 800 lines sharing the coordinator's launch, tool socket and account selection. Measured 5686 source lines. Splitting would export the launch internals; revisit at the slice 7 sweep. Slice 4 adds checks and review on a candidate (judge.go) and the merge watch (merge.go), about 800 lines, sharing the Engineer launch path; measured 6808, 7035 after review round 1 (branch head watch, deadlines, streamed outputs). Slice 4b keeps Engineering and Review sessions and answers the creator's questions from them (ask.go: kept-session and ask state, read-only git tools, the answer stream), about 700 lines on the same launch path.
+size internal/runner/thin 10900 - Connections slice 1 (after Astra round 1) also keeps a durable ledger of each turn's write tools so a later attempt never repeats one (effects.go), the waiting state between attempts and usage rows per attempt, about 500 lines more; measured 10590 before gate 1d. Connections slice 1 adds the Codex coordinator beside the Claude one (codex.go: the pinned app-server over JSON-RPC in the converse containment, sharing the coordinator base, desk, tool socket and session table), the connection registry over the bindings with health and provider limits (conns.go), in-app sign-in attempts (connector.go) and turn failover and holding (failover.go), about 1500 lines; the pure parts (the choice function, limit parsing, the app-server client, the sign-in flows) live in internal/runner/connect. Measured 10097. Thin v1 slice 4c adds the merge step (mergestep.go, about 190 lines) and the rebase round beside the slice 4b ask fixes. Thin v1 slice 3 adds Engineering steps beside the coordinator: the durable step state and engine (step.go) and the executor that checks out the task tree, runs the CLI in the implement containment, commits and pushes (engineer.go), about 800 lines sharing the coordinator's launch, tool socket and account selection. Measured 5686 source lines. Splitting would export the launch internals; revisit at the slice 7 sweep. Slice 4 adds checks and review on a candidate (judge.go) and the merge watch (merge.go), about 800 lines, sharing the Engineer launch path; measured 6808, 7035 after review round 1 (branch head watch, deadlines, streamed outputs). Slice 4b keeps Engineering and Review sessions and answers the creator's questions from them (ask.go: kept-session and ask state, read-only git tools, the answer stream), about 700 lines on the same launch path.
time internal/thintest 30s Thin v1 contract tests: a real instance and a scripted runner per test, fixtures replayed against every request, frame and event. Slice 3 adds the task, step-sync and grant contracts; CI measured 14.805s. 30s keeps room for the slice 4 review contracts.
time internal/runner/thin 45s Thin v1 slice 4 review: real git repositories for the merge and squash checks, a stalled fetch, and a 16 MiB candidate streamed through the review diff and the checks pack (about 5s). Measured 17.8s locally under load. Slice 4b review adds a 16 MiB git output bound, an injected index-pack failure and stall (3s deadline) and held-answer tests; measured 30.3s locally under load. 45s keeps 33 percent headroom.
-time internal/headless 240s Thin v1 headless suite: real instance, runner and bubblewrap per scenario (spec 7, under two minutes). Slice 4 adds the review and checks scenarios (4_review with its fix rounds, branch move and merge; 4_checks_honest); loaded CI measured 170s on 2026-11-07. Slice 4b adds 4b_ask (about 12s); loaded CI measured 182.9s. 240s keeps 30 percent headroom.
+time internal/headless 360s Connections slice 1 adds TestHeadlessConnections (usage rows, failover, Codex coordinator, device code, Claude sign-in, failure kinds, cancel and sign-out, writes replayed, Engineering and Review moving connection, the waiting turn): eleven scenarios, about 55 to 100s locally. Thin v1 headless suite: real instance, runner and bubblewrap per scenario (spec 7, under two minutes). Slice 4 adds the review and checks scenarios (4_review with its fix rounds, branch move and merge; 4_checks_honest); loaded CI measured 170s on 2026-11-07. Slice 4b adds 4b_ask (about 12s); loaded CI measured 182.9s. 240s keeps 30 percent headroom.
perf GET /api/v1/turns/{id} skip Thin v1 person API: bearer-only JSON for devices, not a browser screen.
perf GET /api/v1/events skip Thin v1 person event stream (Server-Sent Events), long-lived by design; not a screen.
perf GET /api/runner/stream skip Thin v1 runner WebSocket, bearer-only and long-lived; not a browser screen.
diff --git a/internal/equipo/static/chat-stream.js b/internal/equipo/static/chat-stream.js
index 0bffac3b..52db9a86 100644
--- a/internal/equipo/static/chat-stream.js
+++ b/internal/equipo/static/chat-stream.js
@@ -243,6 +243,9 @@
line.setAttribute("data-leaving", "");
setTimeout(function () { line.remove(); }, moving() ? 900 : 0);
}
+ // The quiet line under a reply that moved connection.
+ var switched = server.querySelector("[data-switched]");
+ if (switched && !live.querySelector("[data-switched]")) live.append(switched);
return live;
}
// kind is a turn the coordinator takes on its own (move_in, explore):
diff --git a/internal/equipo/templates/settings.html b/internal/equipo/templates/settings.html
index 4f261d77..bde94ddb 100644
--- a/internal/equipo/templates/settings.html
+++ b/internal/equipo/templates/settings.html
@@ -1,6 +1,7 @@
{{define "content"}}
<a href="/settings/devices">{{copy "device.list"}}</a>
<a href="/settings/coordinator">{{copy "coordinator.settings"}}</a>
+<a href="/conversation/connections" data-connections-link>{{copy "chat.connections.title"}}</a>
<a href="/preferences">{{copy "preferences.title"}}</a>{{if .Owner}}<a href="/settings/recovery">{{copy "recovery.title"}}</a>{{end}}
<h1>{{copy "nav.settings"}}</h1>
<p>{{copy "account.note"}}</p>
diff --git a/internal/headless/browser_connections_test.go b/internal/headless/browser_connections_test.go
new file mode 100644
index 00000000..6f806a9f
--- /dev/null
+++ b/internal/headless/browser_connections_test.go
@@ -0,0 +1,88 @@
+//go:build browser
+
+package headless
+
+import (
+ "context"
+ "fmt"
+ "path/filepath"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/browsertest"
+ "amadan.net/oficina/equipo/internal/thintest"
+ "amadan.net/oficina/equipo/internal/wire"
+ "github.com/chromedp/chromedp"
+)
+
+// Connections slice 1, gate 1d: the pages a person uses, in a browser.
+
+// waitLong is browsertest.Wait with room for a turn that moves
+// connection (two cold starts) to arrive.
+func waitLong(expression string) chromedp.Action[chromedp.Void] {
+ return chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
+ deadline := time.Now().Add(45 * time.Second)
+ for {
+ ok, err := chromedp.Evaluate[bool]("document.readyState === 'complete' && ("+expression+")")(ctx, target)
+ if err == nil && ok {
+ return nil
+ }
+ if time.Now().After(deadline) {
+ return fmt.Errorf("waiting for %s (last evaluation: %v)", expression, err)
+ }
+ time.Sleep(50 * time.Millisecond)
+ }
+ })
+}
+
+func connectionsPage(t *testing.T, inst *thintest.Instance) *page {
+ t.Helper()
+ cookie := inst.Cookie()
+ p := openPage(t, inst.URL, cookie.Name, cookie.Value, 390, 844, false)
+ t.Cleanup(p.stop)
+ return p
+}
+
+// A1 and A4: Add Codex shows OpenAI's page and the code, and the page
+// turns to the connection once the person approves; Add Claude, with the
+// browser elsewhere, shows only the finish-on-runner card.
+func TestBrowserConnectionsAdd(t *testing.T) {
+ _, inst, r := localEnv(t)
+ r.start(t)
+ p := connectionsPage(t, inst)
+ p.run(chromedp.Navigate(inst.URL+"/conversation/connections"), browsertest.Wait(`!!document.querySelector('[data-connections]')`))
+ p.check(`!!document.querySelector('[data-add="codex"]') && !!document.querySelector('[data-add="claude"]')`, "no Add buttons")
+ p.check(`(()=>{document.querySelector('[data-add="codex"]').click();return true})()`, "Add Codex")
+ p.run(browsertest.Wait(`!!document.querySelector('[data-device-code]')`))
+ p.check(`document.querySelector('[data-device-code]').textContent.includes('https://auth.openai.com/codex/device') && /FAKE-/.test(document.querySelector('[data-device-code]').textContent)`, "the device code card does not show the page and the code")
+ writeJSON(t, filepath.Join(r.root, "accounts", ".fake-device.json"), map[string]any{"email": second, "plan": "pro"})
+ p.run(waitLong(`[...document.querySelectorAll('[data-connection-state]')].some(e=>e.textContent.includes('Healthy')) && document.body.textContent.includes('` + second + `') && !document.querySelector('[data-device-code]')`))
+ p.check(`(()=>{document.querySelector('[data-add="claude"]').click();return true})()`, "Add Claude")
+ p.run(browsertest.Wait(`!!document.querySelector('[data-finish-on]')`))
+ p.check(`document.body.textContent.includes('equipo-runner login claude') && !!document.querySelector('[data-same-machine]') && !document.querySelector('[data-sign-in]') && !document.querySelector('input[type="password"],input[name="code"]')`, "the finish-on-runner card is not the only way shown, or it asks for a paste")
+}
+
+// F1 and F7 on the conversation page: the switched line under a reply
+// that moved connection, and the waiting card that turns into the reply
+// once a connection is added, without a reload.
+func TestBrowserConnectionsConversation(t *testing.T) {
+ env, inst, r := localEnv(t)
+ r.addAccount(t, "claude", "claude-2", second)
+ r.start(t)
+ p := connectionsPage(t, inst)
+ p.send("Hello. limit:" + thintest.Owner)
+ p.run(waitLong(`!!document.querySelector('[data-switched]') && document.querySelector('[data-switched]').textContent.startsWith('Switched to Claude')`))
+ // F7: claude-2 limited too; nothing can answer.
+ p.send("Again. limit:" + second)
+ p.run(waitLong(`!!document.querySelector('[data-no-connection]') && document.querySelector('[data-no-connection]').textContent.includes('Nothing can answer right now.') && !!document.querySelector('[data-add-connection]')`))
+ p.check(`!document.body.textContent.includes('Send your message again')`, "the old retry line is shown")
+ writeJSON(t, filepath.Join(r.root, "accounts", ".fake-device.json"), map[string]any{"email": "third@example.com", "plan": "pro"})
+ ctx := t.Context()
+ c, err := env.Client.Connect(ctx, wire.Connect{Provider: "codex"})
+ if err != nil {
+ t.Fatal(err)
+ }
+ _ = c
+ p.run(waitLong(`!document.querySelector('[data-no-connection]') && [...document.querySelectorAll('[data-switched]')].some(e=>e.textContent.startsWith('Switched to Codex'))`))
+ var _ = time.Second
+}
diff --git a/internal/runner/connect/login.go b/internal/runner/connect/login.go
index 86bbca68..8a9db0f2 100644
--- a/internal/runner/connect/login.go
+++ b/internal/runner/connect/login.go
@@ -11,7 +11,6 @@ import (
"os"
"os/exec"
"path/filepath"
- "regexp"
"strings"
"syscall"
"time"
@@ -147,10 +146,6 @@ func CodexDeviceLogin(ctx context.Context, binary, home string, env []string, pr
}
}
-// signInURL is the authorize URL Claude's CLI hands its browser: the
-// loopback flow, redirecting to http://localhost:<port>/callback.
-var signInURL = regexp.MustCompile(`https://[a-z.]+/[A-Za-z0-9/_.-]*oauth/authorize\?[^\s"'\x1b\x07]+`)
-
// claudeHosts are the sign-in pages Claude's CLI may send a browser to.
var claudeHosts = []string{"claude.ai", "claude.com", "platform.claude.com", "console.anthropic.com"}