oficina / equipo Public

browser tests: judge draft commits and the row menu from page facts

TestBrowserDraftStreamsFormatted read the last streamed render by
sampling animation frames. A commit that landed between the frame that
painted the last draw and the next sampled frame hid that draw, and the
test saw a render about 50 characters short. The recorder is now a
MutationObserver, which reads each draw the moment it lands. The commit
records its time beside the page's own deadline for it (settleBy). A
commit at the 2 s cap, which the page makes by design when the draft is
slow, is logged and not compared. An earlier commit must still be the
last render plus its last characters. The frame budget (30 draws, 95th
percentile 4 ms) is a time on this machine, so like the CI timing
budgets it is enforced only where EQUIPO_CI_DEDICATED=1 and reported
elsewhere. At least two draws are always required.

TestBrowserInnerScreens read the row menu's opacity straight after
load. It failed 4 times in 60 on hosted CI with the menu part way
through its .15 s opacity transition. It now waits for the menu's
transitions to end and then requires opacity 0, so a menu shown at rest
still fails. When the menu is not at rest on load, the test logs what
was moving, hovered and focused.

App code is unchanged. The thintest size budget goes to the measured
13251.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev d3ee1e69162c286642856a7f31a8f926e782ed3a parent eaed1a1
3 files changed, +47 −13
  • .rastrillo/budgets.txt +1 −1
  • internal/headless/browser_stream_markdown_test.go +38 −11
  • internal/thintest/inner_browser_test.go +8 −1

CI cancelled — superseded by a newer push — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 093b6ea0..fb9b02cb 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -62,5 +62,5 @@ perf GET /conversation/attachments/{id}/preview skip Composer attachments: an im
perf GET /api/v1/runners skip Mac runners person API: bearer-only JSON for devices; the browser shows runners in the Team section.
time cmd/equipo-runner 60s Mac runners slice B: TestReleaseRunnerHasNoFakeWorker builds the release runner exactly as make release-runner does and the thin package under the testbuild tag (measured 11.9s locally with a warm cache).
size internal/headless - 8400 Merge authority extends 4c_checks_card to end in Equipo's own merge, measured by the real runner, with its receipt (about 30 lines); measured 8330. Claude's sign-in by a link adds its end-to-end, contained-launch and real runner kill tests (signin_test.go, signin_contained_test.go, about 400 lines); measured 8090.
-size internal/thintest - 13244 The thinking cycles drive takes a still clock, a timer that is seen to look and the page's record of each phrase, so a slow machine cannot fail it (about 50 lines); measured 13244. The browser lane merged onto the ship buttons: measured 13197. The ship buttons add their contract and browser tests (ships_buttons_test.go, ships_buttons_browser_test.go, about 190 lines); measured 13196. Merge authority merged onto Machines in Settings, with the re-run ruling's cases and stale thinking lines: measured 12998. Merge authority thin v1 adds its contracts (mergeauth_contract_test.go, about 650 lines) the protocol-aware rigs and the Mac re-run contract (macrecheck_mergeauth_contract_test.go) and the review fixes' contracts; measured 12535 with main merged. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Machines in Settings adds its fixture, page and browser tests (machines_fixture_test.go, machines_pages_test.go, machines_browser_test.go, about 160 lines); measured 11759. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Stale thinking lines merged onto Machines in Settings: measured 11967. Machines in Settings adds its fixture, page and browser tests (machines_fixture_test.go, machines_pages_test.go, machines_browser_test.go, about 160 lines); measured 11759. Stale thinking lines add their browser drive (stale_thinking_browser_test.go, about 200 lines) and the queued test now checks the note; measured 11795. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Spend 1 merged onto the four UI branches: measured 11325. Spend 1 marks overcounting Claude rows (about 120 lines); it adds the task page's spend contract and the 0059 upgrade (spend_pages_test.go, about 100 lines) and the fix round feedback by protocol (about 40); measured 10224. The team panel merged onto Projects UX and the Settings UX pass: measured 11064 with all three. The team panel adds its page contract and the drawer's browser drive at 1280 and 390 (team_panel_test.go, team_panel_browser_test.go, about 300 lines); measured 10235. Projects UX merged onto the Settings UX pass: measured 10768 with both. Projects UX adds the Projects page contracts (order, quiet fold, filter, stars and Undo, the coordinator's star, repository counts, whole words), the decision cards' Mac and Ask about this contracts and their browser drive (projects_pages_test.go, projects_browser_test.go, about 330 lines); measured 10321. The Settings UX pass adds the Settings pattern's page contracts and the savebar, Housekeeping groups and Teams browser drives (settings_ux_pages_test.go, settings_ux_browser_test.go, about 430 lines); measured 10390. Claude's sign-in by a link adds the code contract (signin_contract_test.go: the card, the code route's refusals, the wrong-code card, the kind it becomes and the canary sweep, about 220 lines); measured 9896. The Connections Add page and the Settings rail add their page contracts and the rail's browser drive (connections_add_pages_test.go, settings_rail_pages_test.go, about 230 lines); measured 9676. Claude setup tokens add the token and Check again contracts; measured 9444 with the composer and Mac lines merged. The instant thinking line adds its browser drive (instant_browser_test.go, about 230 lines); measured 9064 with the composer and Mac lines merged. Mac runners add the role, scoping, migration, placement, withdrawal, transfer and publication contracts (about 900 test lines) beside the thin v1 contracts; one package keeps one instance harness.
+size internal/thintest - 13251 The inner screens drive waits for the row menu's opacity transition to end before it reads the menu at rest (about 7 lines); measured 13251. The thinking cycles drive takes a still clock, a timer that is seen to look and the page's record of each phrase, so a slow machine cannot fail it (about 50 lines); measured 13244. The browser lane merged onto the ship buttons: measured 13197. The ship buttons add their contract and browser tests (ships_buttons_test.go, ships_buttons_browser_test.go, about 190 lines); measured 13196. Merge authority merged onto Machines in Settings, with the re-run ruling's cases and stale thinking lines: measured 12998. Merge authority thin v1 adds its contracts (mergeauth_contract_test.go, about 650 lines) the protocol-aware rigs and the Mac re-run contract (macrecheck_mergeauth_contract_test.go) and the review fixes' contracts; measured 12535 with main merged. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Machines in Settings adds its fixture, page and browser tests (machines_fixture_test.go, machines_pages_test.go, machines_browser_test.go, about 160 lines); measured 11759. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Stale thinking lines merged onto Machines in Settings: measured 11967. Machines in Settings adds its fixture, page and browser tests (machines_fixture_test.go, machines_pages_test.go, machines_browser_test.go, about 160 lines); measured 11759. Stale thinking lines add their browser drive (stale_thinking_browser_test.go, about 200 lines) and the queued test now checks the note; measured 11795. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Spend 1 merged onto the four UI branches: measured 11325. Spend 1 marks overcounting Claude rows (about 120 lines); it adds the task page's spend contract and the 0059 upgrade (spend_pages_test.go, about 100 lines) and the fix round feedback by protocol (about 40); measured 10224. The team panel merged onto Projects UX and the Settings UX pass: measured 11064 with all three. The team panel adds its page contract and the drawer's browser drive at 1280 and 390 (team_panel_test.go, team_panel_browser_test.go, about 300 lines); measured 10235. Projects UX merged onto the Settings UX pass: measured 10768 with both. Projects UX adds the Projects page contracts (order, quiet fold, filter, stars and Undo, the coordinator's star, repository counts, whole words), the decision cards' Mac and Ask about this contracts and their browser drive (projects_pages_test.go, projects_browser_test.go, about 330 lines); measured 10321. The Settings UX pass adds the Settings pattern's page contracts and the savebar, Housekeeping groups and Teams browser drives (settings_ux_pages_test.go, settings_ux_browser_test.go, about 430 lines); measured 10390. Claude's sign-in by a link adds the code contract (signin_contract_test.go: the card, the code route's refusals, the wrong-code card, the kind it becomes and the canary sweep, about 220 lines); measured 9896. The Connections Add page and the Settings rail add their page contracts and the rail's browser drive (connections_add_pages_test.go, settings_rail_pages_test.go, about 230 lines); measured 9676. Claude setup tokens add the token and Check again contracts; measured 9444 with the composer and Mac lines merged. The instant thinking line adds its browser drive (instant_browser_test.go, about 230 lines); measured 9064 with the composer and Mac lines merged. Mac runners add the role, scoping, migration, placement, withdrawal, transfer and publication contracts (about 900 test lines) beside the thin v1 contracts; one package keeps one instance harness.
perf GET /api/v1/projects/{id}/merge-policy skip Merge authority person API: bearer-only JSON for devices; the browser reads the policy on /projects/{id}.
diff --git a/internal/headless/browser_stream_markdown_test.go b/internal/headless/browser_stream_markdown_test.go
index afed7f2c..16ce4d01 100644
--- a/internal/headless/browser_stream_markdown_test.go
+++ b/internal/headless/browser_stream_markdown_test.go
@@ -4,6 +4,7 @@ package headless
import (
"context"
+ "os"
"sort"
"testing"
"time"
@@ -22,6 +23,16 @@ import (
// render plus at most its last characters (normalised HTML; the same
// height when equal). A long reply is drawn within light.js's frame
// budget (about 4 ms).
+//
+// Everything is judged from what the page records as it happens: each
+// draw is read the moment it lands (a MutationObserver, not a sampled
+// frame, so a commit straight after the last draw cannot hide it), and
+// the commit records its time beside the deadline the page set for it
+// (settleBy). The page commits an undrawn draft only at that 2 s cap; a
+// commit at the cap is logged, and anything earlier must be the last
+// render plus its last characters. The frame budget is a time on this
+// machine, so like the CI timing budgets it is enforced only where
+// EQUIPO_CI_DEDICATED=1 and reported elsewhere.
func TestBrowserDraftStreamsFormatted(t *testing.T) {
_, inst, r := localEnv(t)
r.start(t)
@@ -52,19 +63,21 @@ func TestBrowserDraftStreamsFormatted(t *testing.T) {
return err
}), chromedp.EmulateViewport(1280, 800), chromedp.Navigate(inst.URL+"/conversation"), browsertest.Wait(`!!document.querySelector('[data-chat-stream]') && document.querySelector('[equipo-offline]').hidden`))
}
- // record follows the next reply frame by frame until it is committed:
- // its last render (the fade spans unwrapped) and height, markup shown
- // outside code, the fade inside a list item, where two list items sit,
- // and each draw's time.
- record := `(()=>{const s=window.__s={el:null,last:null,h:0,stray:null,fade:null,lines:null,frames:[],done:false};
+ // record follows the next reply until it is committed: its last
+ // render (the fade spans unwrapped) and height, markup shown outside
+ // code, the fade inside a list item, where two list items sit, each
+ // draw's time, and when it was committed against the page's deadline
+ // for it (settleBy).
+ record := `(()=>{const s=window.__s={el:null,last:null,h:0,stray:null,fade:null,lines:null,frames:[],done:false,at:0,by:0};
new PerformanceObserver(l=>{for(const e of l.getEntries())if(e.name==='equipo-draft')s.frames.push(e.duration)}).observe({type:'measure'});
window.__norm=b=>{const c=document.createElement('div');c.innerHTML=b.innerHTML;c.querySelectorAll('[equipo-stream-caret]').forEach(e=>e.remove());c.querySelectorAll('span[data-new]').forEach(e=>e.replaceWith(new Text(e.textContent)));c.normalize();return c.innerHTML};
-const f=()=>{if(!s.el)s.el=document.querySelector('[equipo-thinking][data-streaming]');const x=s.el;
-if(x&&x.hasAttribute('equipo-thinking')){const b=x.querySelector('[data-stream-text]');if(b&&b.firstChild){s.last=window.__norm(b);s.h=b.getBoundingClientRect().height;
+const f=()=>{if(s.done)return;if(!s.el)s.el=document.querySelector('[equipo-thinking][data-streaming]');const x=s.el;if(!x)return;
+if(!x.hasAttribute('equipo-thinking')){s.done=true;s.at=Date.now();s.by=x.settleBy||0;return}
+const b=x.querySelector('[data-stream-text]');if(b&&b.firstChild){s.last=window.__norm(b);s.h=b.getBoundingClientRect().height;
const c=document.createElement('div');c.innerHTML=b.innerHTML;c.querySelectorAll('pre, code').forEach(e=>e.remove());if(/[*\x60]|\]\(/.test(c.textContent))s.stray=c.textContent;
const n=b.querySelector('li [data-new]');if(n&&!s.fade){const st=getComputedStyle(n);s.fade=st.animationName+' '+st.animationDuration}
-const li=b.querySelectorAll('ul > li');if(li.length>=2&&!s.lines)s.lines=[li[0].getBoundingClientRect().top,li[1].getBoundingClientRect().top,li[0].textContent,li[1].textContent]}}
-if(!x||x.hasAttribute('equipo-thinking'))requestAnimationFrame(f);else s.done=true};f();return true})()`
+const li=b.querySelectorAll('ul > li');if(li.length>=2&&!s.lines)s.lines=[li[0].getBoundingClientRect().top,li[1].getBoundingClientRect().top,li[0].textContent,li[1].textContent]}};
+new MutationObserver(f).observe(document.body,{childList:true,subtree:true,characterData:true,attributes:true});f();return true})()`
send := func(text string) {
t.Helper()
check(record, "record")
@@ -73,6 +86,14 @@ if(!x||x.hasAttribute('equipo-thinking'))requestAnimationFrame(f);else s.done=tr
committed := func(reason string) {
t.Helper()
run(browsertest.WaitWithin(`window.__s.done && !!window.__s.el.dataset.message`, 60*time.Second))
+ if evaluateIn[bool](t, ctx, `window.__s.by>0 && window.__s.at>=window.__s.by`) {
+ // The draft was still drawing when the page's 2 s wait ran
+ // out: the page commits then by design, so how far the last
+ // render was behind is this machine's speed, not the page.
+ t.Logf("%s: committed at the 2 s cap, %d ms past the deadline; the last render is not compared", reason, evaluateIn[int](t, ctx, `window.__s.at-window.__s.by`))
+ check(`window.__s.stray===null`, reason+": markup characters showed while streaming")
+ return
+ }
// Past what the two share, the last render has only the closing
// tags of the text it ends in.
check(`(()=>{const f=window.__norm(window.__s.el.querySelector('[equipo-message-body]')),l=window.__s.last;let k=0;while(k<l.length&&l[k]===f[k])k++;window.__s.same=l===f;return l===f||/^(<\/[a-z]+>\s*)+$/.test(l.slice(k))&&f.length-k<80})()`, reason+": the committed reply is not the last streamed render plus its last characters")
@@ -97,10 +118,16 @@ if(!x||x.hasAttribute('equipo-thinking'))requestAnimationFrame(f);else s.done=tr
// The runner sends the deltas it has about ten times a second.
frames := evaluateIn[[]float64](t, ctx, `window.__s.frames`)
sort.Float64s(frames)
- if n := len(frames); n < 30 || frames[n*95/100] > 4 {
+ n := len(frames)
+ if n < 2 {
+ t.Fatalf("long reply: %d draws: it was not drawn as it streamed", n)
+ }
+ t.Logf("long reply: %d draws, median %.2f ms, 95th %.2f ms, worst %.2f ms", n, frames[n/2], frames[n*95/100], frames[n-1])
+ if os.Getenv("EQUIPO_CI_DEDICATED") != "1" {
+ t.Logf("long reply: frame budget (30 or more draws, 95th percentile 4 ms) reported, not enforced: a shared machine's load is not the page's time (EQUIPO_CI_DEDICATED=1 enforces it)")
+ } else if n < 30 || frames[n*95/100] > 4 {
t.Fatalf("long reply: %d draws (want 30 or more), 95th percentile %.2f ms (budget 4 ms)", n, frames[n*95/100])
}
- t.Logf("long reply: %d draws, median %.2f ms, 95th %.2f ms, worst %.2f ms", len(frames), frames[len(frames)/2], frames[len(frames)*95/100], frames[len(frames)-1])
}
// evaluateIn is the value of a page expression in the browser of ctx.
diff --git a/internal/thintest/inner_browser_test.go b/internal/thintest/inner_browser_test.go
index 97bce717..3b78f079 100644
--- a/internal/thintest/inner_browser_test.go
+++ b/internal/thintest/inner_browser_test.go
@@ -200,7 +200,14 @@ func TestBrowserInnerScreens(t *testing.T) {
if size.touch {
p.check(`getComputedStyle(`+row(g.stopped)+`.querySelector('[equipo-menu]')).opacity==='1'`, "⋯ hidden on touch")
} else {
- p.check(`getComputedStyle(`+row(g.stopped)+`.querySelector('[equipo-menu]')).opacity==='0'`, "⋯ shown before hover")
+ // At rest, before any hover or focus, the ⋯ is hidden. Its
+ // opacity eases (a .15 s transition), so the check waits for the
+ // menu's transitions to end and only then reads it.
+ menu := row(g.stopped) + `.querySelector('[equipo-menu]')`
+ if why := eval[string](p, `(()=>{const m=`+menu+`;if(getComputedStyle(m).opacity==='0')return '';return JSON.stringify({opacity:getComputedStyle(m).opacity,moving:m.getAnimations().map(a=>[a.transitionProperty||a.animationName,a.playState,a.currentTime]),hover:[...document.querySelectorAll(':hover')].map(e=>e.tagName+[...e.attributes].map(x=>'['+x.name+']').join('')).slice(-2),within:m.closest('[equipo-row]').matches(':focus-within'),active:document.activeElement?.tagName,open:m.open})})()`); why != "" {
+ t.Logf("⋯ not yet at rest on load: %s", why)
+ }
+ p.wait(menu+`.getAnimations().length===0 && getComputedStyle(`+menu+`).opacity==='0'`, "⋯ hidden before hover")
}
box := eval[[]float64](p, `(()=>{`+row(g.noras)+`.scrollIntoView({block:'center'});const r=`+row(g.noras)+`.getBoundingClientRect();return [r.x+r.width*0.45,r.y+r.height-6]})()`)
p.do(chromedp.MouseEvent(input.DispatchMouseEventTypeMousePressed, box[0], box[1], chromedp.ButtonLeft, chromedp.ClickCount(1)), chromedp.MouseEvent(input.DispatchMouseEventTypeMouseReleased, box[0], box[1], chromedp.ButtonLeft, chromedp.ClickCount(1)))