oficina / equipo Public

Align Roster keyboard order and browser checks with approved actions

Paul Campbell pushed by paul@keymail.dev d70efa86572443d395ba00922a87b1f6b5abfd40 parent 2eeaf06
8 files changed, +27 −23
  • .rastrillo/budgets.txt +2 −2
  • internal/equipo/static/equipo.css +1 −4
  • internal/equipo/templates/chat.html +1 −1
  • internal/headless/browser_review_test.go +3 −3
  • internal/headless/browser_tasks_test.go +13 −10
  • internal/thintest/roster_browser_test.go +4 −0
  • internal/thintest/roster_contract_test.go +2 −2
  • internal/thintest/roster_reports_browser_test.go +1 −1

CI failed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 1056468f..814d45f1 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -70,8 +70,8 @@ perf GET /api/v1/tasks/{id}/files/{file} skip Research kept images: bearer-only
perf GET /tasks/{id}/files/{file} skip Research kept images: the bytes of one image, shown on the task page; a file, not a screen.
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 TestReleaseRunnerHasNoFakeWorker builds the release runner and the thin package under testbuild (about 12s locally).
-size internal/headless - 10739 End-to-end scenarios through a real runner and instance: the Copy setting, wording flag and the Assistant's job threads. Measured 10739 test lines.
-size internal/thintest - 28437 The contract and browser tests share the instance harness; Roster adds Reply/Stop/CSRF guards and desktop/phone state captures. Measured 28437 test lines.
+size internal/headless - 10742 End-to-end scenarios through a real runner and instance: the Copy setting, wording flag and the Assistant's job threads. Measured 10742 test lines.
+size internal/thintest - 28441 The contract and browser tests share the instance harness; Roster adds Reply/Stop/CSRF guards and desktop/phone state captures. Measured 28441 test lines.
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}.
perf GET /api/v1/usage skip Thin v1 person API: bearer-only JSON for devices; the browser reads usage through /usage.
perf GET /api/v1/advice skip Thin v1 person API: bearer-only JSON for devices; the browser reads advice through /usage and /conversation.
diff --git a/internal/equipo/static/equipo.css b/internal/equipo/static/equipo.css
index 38f6c4ea..9788194d 100644
--- a/internal/equipo/static/equipo.css
+++ b/internal/equipo/static/equipo.css
@@ -1948,8 +1948,6 @@ label[equipo-sp-label] { cursor: pointer; }
[equipo-conversation]:not([data-task]) [equipo-thinking][data-streaming] [equipo-bubble] { display: block; }
[equipo-thinking][data-streaming] [equipo-turn-stop] { display: none; }
[equipo-roster-facts] dd, [equipo-roster-facts] code { white-space: normal; overflow-wrap: anywhere; }
-/* Task menus open deliberately; hidden actions reserve no card space. */
-[equipo-card="task"] [equipo-receipt-more] { position: absolute; inset-inline-end: .5rem; inset-block-end: .5rem; display: inline-flex; align-items: center; justify-content: center; inline-size: 2.75rem; min-block-size: 2.75rem; }
[equipo-roster-links] a { text-decoration: none; }
[equipo-roster-links] a:not([rst-btn]) { color: var(--rst-text-muted); }
[equipo-roster-report-head] [equipo-card-line] { color: var(--rst-text); }
@@ -1963,7 +1961,6 @@ label[equipo-sp-label] { cursor: pointer; }
[equipo-needs-chip] .icon { inline-size: .875rem; block-size: .875rem; }
[equipo-copy-hold] [equipo-actions] { display: flex; flex-wrap: wrap; }
[equipo-copy-hold] [equipo-actions] [rst-btn] { white-space: nowrap; }
-[equipo-copy-hold] [equipo-actions] a[rst-btn="primary"] { order: -1; }
@container roster (max-width:500px) {
[equipo-copy-hold] [equipo-actions] a[rst-btn="primary"] { inline-size: 100%; }
[equipo-copy-hold] [equipo-actions] [rst-btn] { white-space: nowrap; }
@@ -1975,4 +1972,4 @@ label[equipo-sp-label] { cursor: pointer; }
[equipo-conversation]:not([data-task]) [equipo-thinking]:not([data-streaming]) [equipo-bubble] { display: flex; align-items: center; gap: .5rem; flex: 1; min-inline-size: 0; }
[equipo-conversation]:not([data-task]) [equipo-thinking]:not([data-streaming]) [data-stream-text] { display: none; }
[equipo-turn-stop] { flex: none; }
-[equipo-turn-stop] button { text-decoration: none; color: var(--rst-text-muted); font-size: var(--rst-fs-sm); min-block-size: 2.75rem; padding-inline: .5rem; }
+[equipo-conversation] [data-turn-stop] { text-decoration: none; color: var(--rst-text-muted); font-size: var(--rst-fs-sm); min-block-size: 2.75rem; padding-inline: .5rem; }
diff --git a/internal/equipo/templates/chat.html b/internal/equipo/templates/chat.html
index d103bb3b..94a59b65 100644
--- a/internal/equipo/templates/chat.html
+++ b/internal/equipo/templates/chat.html
@@ -22,7 +22,7 @@
{{else if eq .Kind "access"}}<p equipo-card-line>{{.Line}}</p>{{if .Open}}<details equipo-grant><summary rst-btn>{{copy "chat.card.grant"}}</summary><p>{{.GrantHow}}</p><code>amadan agent grant {{.Agent}} {{.Namespace}}</code><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<button rst-btn name="choice" value="check" type="submit" data-grant-check>{{copy "chat.card.grant_check"}}</button></form></details>{{end}}
{{end}}<p equipo-card-error role="alert" hidden></p></section>{{end}}{{if .Presentation.Coverage.Skipped}}<section equipo-roster-card data-flat>{{template "work-task-receipt" .}}</section>{{end}}{{if not .SetAside}}{{range .ResearchReports}}<div equipo-roster-byline><span equipo-roster-avatar>{{icon "search"}}</span><b>{{copy "work.specialist.research"}}</b><span>{{copy "roster.reports"}}</span>{{with .At}}<time datetime="{{.Format "2006-01-02T15:04:05Z07:00"}}">{{.Format "15:04"}}</time>{{end}}</div><section equipo-roster-card data-research-report><h3>{{copy "roster.research"}}</h3><p>{{.Summary}}</p><ol equipo-roster-findings>{{range .Facts}}<li><div><strong>{{.Label}}</strong> {{.Value}}</div>{{range .Sources}}{{if .URL}}<a href="{{.URL}}" title="{{.URL}}" target="_blank" rel="noopener">{{.Domain}}</a>{{else}}<span>{{.ID}}</span>{{end}}{{end}}</li>{{end}}{{range .Gaps}}<li data-gap>{{.}}</li>{{end}}</ol><a href="/tasks/{{$.TaskID}}#research-{{.StepID}}">{{copy "roster.research_log"}} ({{len .Fetches}})</a></section>{{end}}{{end}}
</li>{{end}}
-{{define "roster-copy-hold"}}<div equipo-copy-hold><span equipo-roster-stage>{{copy "roster.copy_waiting"}}</span><h3>{{.Line}}</h3><p>{{.HoldReason}}</p>{{with .Presentation.Coverage}}<div equipo-copy-meter>{{if .Known}}{{if .Total}}<meter min="0" max="{{.Total}}" value="{{.Reviewed}}" aria-label="{{printf (copy "roster.copy_count") .Reviewed .Total}}"></meter>{{end}}<span>{{printf (copy "roster.copy_count") .Reviewed .Total}}</span>{{else}}<span>{{copy "roster.copy_coverage"}}</span>{{end}}{{with .Since}}<small>{{printf (copy "roster.copy_since") (.Format "15:04")}}</small>{{end}}</div>{{end}}<div equipo-actions>{{if .Task.CopyCanSkip}}<form method="post" action="/conversation/tasks/{{.TaskID}}/continue-without-copy" data-card-form><button rst-btn type="submit" data-copy-continue>{{copy "copy.continue"}}</button></form>{{end}}<a rst-btn="primary" href="/conversation?about={{.TaskID}}">{{copy "work.decide.ask_coordinator"}}</a></div></div>{{end}}
+{{define "roster-copy-hold"}}<div equipo-copy-hold><span equipo-roster-stage>{{copy "roster.copy_waiting"}}</span><h3>{{.Line}}</h3><p>{{.HoldReason}}</p>{{with .Presentation.Coverage}}<div equipo-copy-meter>{{if .Known}}{{if .Total}}<meter min="0" max="{{.Total}}" value="{{.Reviewed}}" aria-label="{{printf (copy "roster.copy_count") .Reviewed .Total}}"></meter>{{end}}<span>{{printf (copy "roster.copy_count") .Reviewed .Total}}</span>{{else}}<span>{{copy "roster.copy_coverage"}}</span>{{end}}{{with .Since}}<small>{{printf (copy "roster.copy_since") (.Format "15:04")}}</small>{{end}}</div>{{end}}<div equipo-actions><a rst-btn="primary" href="/conversation?about={{.TaskID}}">{{copy "work.decide.ask_coordinator"}}</a>{{if .Task.CopyCanSkip}}<form method="post" action="/conversation/tasks/{{.TaskID}}/continue-without-copy" data-card-form><button rst-btn type="submit" data-copy-continue>{{copy "copy.continue"}}</button></form>{{end}}</div></div>{{end}}
{{define "roster-thread-turns"}}{{range .Presentation.Thread}}<div equipo-thread-turn{{if .Own}} data-own{{end}}>{{if not .Own}}<span equipo-thread-avatar{{if eq $.AuthorIcon "sparkles"}} equipo-coordinator-mark{{end}}>{{if eq $.AuthorIcon "sparkles"}}{{template "roster-mark" .}}{{else}}{{icon $.AuthorIcon}}{{end}}</span>{{end}}<div equipo-thread-bubble>{{if not .Own}}<div equipo-thread-who>{{$.Author}} <time datetime="{{.At.Format "2006-01-02T15:04:05Z07:00"}}">{{.At.Format "15:04"}}</time></div>{{end}}<div equipo-thread-text equipo-markdown>{{chatMarkdown .Text}}</div></div>{{if .Own}}<small equipo-thread-sent>{{copy "roster.sent"}}</small>{{end}}</div>{{end}}{{with .ThreadError}}<p equipo-thread-error role="alert">{{.}}</p>{{end}}{{if .Presentation.Waiting}}<div equipo-thread-wait role="status"><span equipo-reading-dots aria-hidden="true"><i></i><i></i><i></i></span><span>{{if .ThreadActivity}}{{.ThreadActivity}}{{else}}{{printf (copy "roster.waiting") .Author}}{{end}}</span><div equipo-thread-draft></div></div>{{end}}{{end}}
{{define "roster-undo"}}<form method="post" action="/conversation/cards/{{.ID}}/visibility" data-card-form><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="aside" value="false">{{template "card-job" .}}<button equipo-link type="submit" data-aside-undo data-busy-label="{{copy "roster.restoring"}}">{{copy "roster.undo"}}</button></form>{{end}}
{{define "roster-byline"}}<div equipo-roster-byline><span equipo-roster-avatar{{if eq .AuthorIcon "sparkles"}} equipo-coordinator-mark{{end}}>{{if eq .AuthorIcon "sparkles"}}{{template "roster-mark" .}}{{else}}{{icon .AuthorIcon}}{{end}}</span><b>{{.Author}}</b><span>{{.Verb}}</span><time datetime="{{.BylineAt.Format "2006-01-02T15:04:05Z07:00"}}">{{.BylineAt.Format "15:04"}}</time></div>{{end}}
diff --git a/internal/headless/browser_review_test.go b/internal/headless/browser_review_test.go
index ab8b7941..5e9689ec 100644
--- a/internal/headless/browser_review_test.go
+++ b/internal/headless/browser_review_test.go
@@ -28,9 +28,9 @@ func TestBrowserReceiptFollowsReview(t *testing.T) {
p.run(browsertest.Wait(stage + `==='In progress'`))
// The step and the review each sleep 2.5 s on purpose: these waits are
// on that work, so they get the window the rail drive gives it.
- p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;return !!c && c.querySelector('[equipo-stage]').textContent==='In review' && /^Pushed equipo\/tk[a-z0-9]+-fix-the-readme-typo at [0-9a-f]{7}$/.test(c.querySelector('[data-pushed] span').textContent)})()`, 20*time.Second))
- p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;return c.querySelector('[data-verdict]')?.textContent==='Reviewing…' && c.querySelector('[data-checks]')?.textContent==='Checks passed (make ci)'})()`, 20*time.Second))
- p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;const m=c.querySelector('[data-merged]');const a=m?.querySelector('[data-open-amadan]');return c.querySelector('[equipo-stage]').textContent==='Done' && c.querySelector('[data-verdict]').textContent==='Approved (same family, same account)' && !!m && /^Merged into main at [0-9a-f]{7}$/.test(m.querySelector('span').textContent) && !c.querySelector('[data-pushed]') && !!a && a.textContent==='Open on Amadan' && a.target==='_blank' && a.href.startsWith('https://amadan.net/oficina/sample')})()`, 20*time.Second))
+ p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;return !!c && c.querySelector('[equipo-stage]').textContent==='In review' && /^equipo\/tk[a-z0-9]+-fix-the-readme-typo$/.test(c.querySelector('[equipo-roster-facts] code').textContent) && !!c.querySelector('[data-open-amadan]')})()`, 20*time.Second))
+ p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;return c.querySelector('[data-verdict]')?.textContent==='Reviewing' && c.querySelector('[data-checks]')?.textContent==='Passed' && c.querySelector('[data-checks]').nextElementSibling.textContent==='make ci'})()`, 20*time.Second))
+ p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;const m=c.querySelector('[data-merged]');const a=m?.querySelector('[data-open-amadan]');return c.querySelector('[equipo-stage]').textContent==='Done' && c.querySelector('[data-verdict]').textContent==='Approved' && c.querySelector('[data-verdict]').nextElementSibling.textContent==='same family, same account' && !!m && /^Merged into main at [0-9a-f]{7}$/.test(m.querySelector('span').textContent) && !c.querySelector('[data-pushed]') && !!a && a.textContent==='Open on Amadan' && a.target==='_blank' && a.href.startsWith('https://amadan.net/oficina/sample')})()`, 20*time.Second))
p.check(`performance.getEntriesByType('navigation').length===window.__nav`, "the page reloaded")
p.check(`(()=>{const b=`+card+`.querySelector('[data-merged] [data-open-amadan]').getBoundingClientRect();return b.width>0 && b.height>0})()`, "the link to the merge is hidden")
}
diff --git a/internal/headless/browser_tasks_test.go b/internal/headless/browser_tasks_test.go
index 730cdc34..6e1fc89b 100644
--- a/internal/headless/browser_tasks_test.go
+++ b/internal/headless/browser_tasks_test.go
@@ -3,6 +3,7 @@
package headless
import (
+ "github.com/chromedp/chromedp"
"testing"
"amadan.net/oficina/equipo/internal/browsertest"
@@ -15,8 +16,8 @@ func taskCard(title string) string {
// Slice 3: the person reports a bug; a quiet task receipt appears before
// the reply and follows the task live to the pushed branch, its short
-// SHA and Open on Amadan. A slow second task shows Cancel behind ⋯ on a
-// phone, and Cancel ends it.
+// SHA and Open on Amadan. Open the task reaches Cancel on a phone,
+// and Cancel ends a slow second task.
func TestBrowserTaskCard(t *testing.T) {
_, inst, r := localEnv(t)
r.start(t)
@@ -30,16 +31,18 @@ func TestBrowserTaskCard(t *testing.T) {
p.run(browsertest.Wait(`(()=>{const r=` + first + `;const m=[...document.querySelectorAll('[equipo-message="incoming"][data-turn-id="'+r.dataset.turnId+'"]')][0];return !!m && !!(r.compareDocumentPosition(m)&4) && r.hasAttribute('equipo-receipt')})()`))
// Live: the stage moves on and the pushed branch appears without a reload.
p.check(`(()=>{window.__nav=performance.getEntriesByType('navigation').length;return true})()`, "mark")
- p.run(browsertest.Wait(`(()=>{const a=` + first + `?.querySelector('[data-open-amadan]');return !!a && a.href.startsWith('https://amadan.net/oficina/sample?branch=equipo/') && a.target==='_blank' && a.rel==='noopener' && /at [0-9a-f]{7}$/.test(a.previousElementSibling.textContent)})()`))
+ p.run(browsertest.Wait(`(()=>{const a=` + first + `?.querySelector('[data-open-amadan]');return !!a && a.href.startsWith('https://amadan.net/oficina/sample?branch=equipo/') && a.target==='_blank' && a.rel==='noopener' && /^[0-9a-f]{7}$/.test(` + first + `.querySelector('[equipo-roster-facts] code').parentElement.nextElementSibling.textContent)})()`))
p.check(`performance.getEntriesByType('navigation').length===window.__nav`, "the page reloaded")
p.check(`!`+first+`.querySelector('[data-task-retry]')`, "a pushed task offers Retry")
p.send("tool:record_task:oficina/sample|Slow change|x\ntool:start_task:$task|stepsleep:20000 edit:README.md|teh|the")
slow := taskCard("Slow change")
- p.run(browsertest.Wait(`!!` + slow + `?.querySelector('[data-task-cancel]')`))
- // Touch: the action is hidden until ⋯ opens it.
- p.check(`getComputedStyle(`+slow+`.querySelector('[equipo-receipt-actions]')).opacity==='0' && getComputedStyle(`+slow+`.querySelector('[equipo-receipt-more]')).display!=='none'`, "Cancel shown before ⋯")
- p.check(`(()=>{`+slow+`.querySelector('[equipo-receipt-more]').click();return true})()`, "tap ⋯")
- p.run(browsertest.Wait(`getComputedStyle(` + slow + `.querySelector('[equipo-receipt-actions]')).opacity==='1'`))
- p.check(`(()=>{`+slow+`.querySelector('[data-task-cancel]').click();return true})()`, "Cancel")
- p.run(browsertest.Wait(slow + `?.dataset.state==='cancelled' && !` + slow + `.querySelector('[data-task-cancel]')`))
+
+ p.run(browsertest.Wait(`!!` + slow + `?.querySelector('[equipo-roster-links] a[rst-btn]')`))
+ p.check(`!`+slow+`.querySelector('[equipo-receipt-more], [data-task-cancel]')`, "report retained its action menu")
+ p.check(`(()=>{`+slow+`.querySelector('[equipo-roster-links] a[rst-btn]').click();return true})()`, "Open the task")
+ p.run(browsertest.Wait(`!!document.querySelector('#task-head [data-task-cancel]')`))
+ p.check(`(()=>{document.querySelector('#task-head [equipo-menu] summary').click();return true})()`, "task actions")
+ p.check(`(()=>{document.querySelector('#task-head [data-task-cancel]').click();return true})()`, "Cancel")
+ p.run(browsertest.Wait(`!document.querySelector('#task-head [data-task-cancel]')`))
+ p.run(chromedp.Navigate(inst.URL+"/conversation"), browsertest.Wait(slow+`?.dataset.state==='cancelled'`))
}
diff --git a/internal/thintest/roster_browser_test.go b/internal/thintest/roster_browser_test.go
index 41e553be..a1625e05 100644
--- a/internal/thintest/roster_browser_test.go
+++ b/internal/thintest/roster_browser_test.go
@@ -218,6 +218,10 @@ func TestBrowserRosterThinking(t *testing.T) {
p.wait(`document.querySelector('[equipo-thinking] [data-turn-stop]')`, "Stop on thinking line")
p.check(`(()=>{const s=getComputedStyle(document.querySelector('[equipo-thinking] [equipo-sparkle]'));return s.display==='none'})()`, "filled thinking mark remains")
p.wait(`(()=>{const c=document.querySelector('[equipo-thinking]'),n=c.querySelector('[equipo-message-meta] strong'),a=c.querySelector('[equipo-phrase]') || c.querySelector('[equipo-activity]'),b=c.querySelector('[data-turn-stop]');return n.getBoundingClientRect().width>0 && Math.abs(n.getBoundingClientRect().top-a.getBoundingClientRect().top)<10 && getComputedStyle(b).boxShadow==='none'})()`, "one thinking line with a quiet Stop")
+ if width == 390 {
+ p.check(`document.querySelector('[data-turn-stop]').getBoundingClientRect().height>=44`, "Stop has a small touch target")
+ }
+ p.wait(`[...document.querySelectorAll('[equipo-thinking] [equipo-phrase] [data-in] > span')].every(e=>Number(getComputedStyle(e).opacity)>=.99)`, "settled thinking phrase")
p.fits("thinking line")
p.shot(fmt.Sprintf("roster-thinking-%d-%s", width, scheme))
p.click(`[equipo-thinking] [data-turn-stop]`)
diff --git a/internal/thintest/roster_contract_test.go b/internal/thintest/roster_contract_test.go
index 9747642d..4c462109 100644
--- a/internal/thintest/roster_contract_test.go
+++ b/internal/thintest/roster_contract_test.go
@@ -13,8 +13,8 @@ func TestRosterRepliesDoNotBatch(t *testing.T) {
if res := r.call("one", wire.ToolAskPerson, map[string]any{"question": "First question?", "options": []string{}}); res.Code != "asked" {
t.Fatal(res)
}
- // A second existing question, independent of the running turn's tool
- // retry cache, exercises the mounted Reply route for both drawers.
+ // A second stored question exercises the mounted Reply route for
+ // both drawers while the earlier turn remains busy.
if _, err := r.inst.DB.Writer().Exec("INSERT INTO chat_cards(id,person,kind,state,turn_id,question,options,revision,created_at,updated_at,lane) SELECT 'c_second_reply',person,kind,state,turn_id,'Second question?',options,revision,created_at,updated_at,lane FROM chat_cards WHERE kind='question' LIMIT 1"); err != nil {
t.Fatal(err)
}
diff --git a/internal/thintest/roster_reports_browser_test.go b/internal/thintest/roster_reports_browser_test.go
index 7c2a8b96..2db09697 100644
--- a/internal/thintest/roster_reports_browser_test.go
+++ b/internal/thintest/roster_reports_browser_test.go
@@ -46,7 +46,7 @@ func TestBrowserRosterReports(t *testing.T) {
p.shot(fmt.Sprintf("roster-research-%d-%s", width, scheme))
p.check(`document.querySelector('[equipo-copy-meter]').textContent.includes('1 of 2 strings reviewed') && document.querySelector('[equipo-copy-meter] meter').value===1`, "Copy coverage")
p.check(`(()=>{document.querySelector('[equipo-copy-hold]').scrollIntoView({block:'center'});return true})()`, "show Copy")
- p.check(`document.querySelector('[data-copy-continue]').getAttribute('rst-btn')!=='primary' && document.querySelector('[equipo-copy-hold] a[rst-btn="primary"]')?.textContent==='Ask the coordinator'`, "Copy skip encouraged")
+ p.check(`document.querySelector('[data-copy-continue]').getAttribute('rst-btn')!=='primary' && document.querySelector('[equipo-copy-hold] [equipo-actions]').firstElementChild.matches('a[rst-btn="primary"]') && document.querySelector('[equipo-copy-hold] a[rst-btn="primary"]')?.textContent==='Ask the coordinator'`, "Copy skip encouraged")
p.check(`!document.querySelector('[equipo-copy-hold]').textContent.includes('..') && !document.querySelector('[equipo-copy-hold] [equipo-link]')`, "Copy copy or actions drifted")
p.fits("Copy hold")
if width == 390 {