oficina / equipo Public

Merge main (machines-ux, stream-markdown); the re-run ruling

Merge of origin/main 15bca3f (budget records combined).

The controller's ruling on a Mac re-run of an asked SHA: its pass merges
on its own (through authorizeMerge) only when the card asked solely
because checks could not run (the SHA's newest decision or card_refresh
audit row fails environment_reason alone) or the person chose Wait for a
Mac on that SHA's card. Otherwise the SHA stays asked: the card stays
open and is re-decided once as a card_refresh. No recorded reason fails
closed. No new column. TestContractMacRecheckMergeAuthority covers Wait
chosen, checks only, sensitive, held, main ships, missing reason and
another SHA; six mutations killed (MERGEAUTH-PROGRESS.md). Spec rule and
the operating rule "deploy with no merge in flight" (spec 10a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 104bcd5ddbafc78beca6897be65f4082c1b2cc14 parent 43ba14aparent 15bca3f
50 files changed, +1,989 −166
  • .rastrillo/budgets.txt +4 −4
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +85 −0
  • docs/superpowers/plans/MERGEAUTH-PROGRESS.md +32 −0
  • docs/superpowers/specs/2026-11-11-equipo-merge-authority.md +24 −6
  • internal/chatmarkdown/draft.go +174 −0
  • internal/chatmarkdown/draft_test.go +115 −0
  • internal/chatmarkdown/markdown.go +19 −5
  • internal/equipo/app.go +3 −0
  • internal/equipo/chat/macrecheck.go +16 −6
  • internal/equipo/chat/mergeauth.go +63 −1
  • internal/equipo/chat/store.go +4 −0
  • internal/equipo/chat_draft.go +35 −0
  • internal/equipo/copy.go +38 −0
  • internal/equipo/handlers.go +5 −2
  • internal/equipo/icons/icons.go +3 −0
  • internal/equipo/mac_view_test.go +4 −3
  • internal/equipo/machines_view.go +144 −0
  • internal/equipo/machines_view_test.go +181 −0
  • internal/equipo/render.go +1 −1
  • internal/equipo/runner_handlers.go +57 −20
  • internal/equipo/runners.go +61 −3
  • internal/equipo/settings_hub.go +1 −0
  • internal/equipo/static/chat-stream.js +153 −28
  • internal/equipo/static/equipo.css +63 −0
  • internal/equipo/static/machines.js +86 −0
  • internal/equipo/static/nav-stream.js +7 −1
  • internal/equipo/templates/chrome.html +1 −1
  • internal/equipo/templates/connections.html +1 −1
  • internal/equipo/templates/conversation_card.html +1 −1
  • internal/equipo/templates/empty.html +1 −1
  • internal/equipo/templates/onboarding.html +1 −1
  • internal/equipo/templates/runners.html +78 −37
  • internal/equipo/templates/settings_nav.html +1 −1
  • internal/equipo/templates/work_parts.html +1 −1
  • internal/fakeclaude/fake.go +6 −2
  • internal/fakeclaude/markdown.go +44 −0
  • internal/headless/browser_stream_markdown_test.go +117 −0
  • internal/headless/browser_test.go +1 −1
  • internal/plan3test/conversation_draft_test.go +52 −0
  • internal/thintest/inline_style_test.go +1 −1
  • internal/thintest/machines_browser_test.go +55 −0
  • internal/thintest/machines_fixture_test.go +39 −0
  • internal/thintest/machines_pages_test.go +74 −0
  • internal/thintest/macrecheck_contract_test.go +8 −2
  • internal/thintest/macrecheck_mergeauth_contract_test.go +86 −32
  • internal/thintest/projects_pages_test.go +1 −1
  • internal/thintest/settings_pages_test.go +3 −1
  • internal/thintest/settings_rail_pages_test.go +3 −1
  • internal/thintest/settings_ux_browser_test.go +1 −1
  • scripts/runner-reference-allowlist.json +35 −0
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 0da3e3a7..8e2cbd58 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -14,7 +14,7 @@ perf GET /* skip Unknown private paths render 404; this fallback contains no scr
time internal/equipo/team 60s Plan 3 loaded CI measured 45.985s; niced serial reruns measured 18.079s and 22.031s. Keep migration, recovery, accounting and concurrency assertions; 60s leaves 30 percent headroom above loaded CI.
time internal/equipotest 300s Final fix package rerun measured 187.035s (review 172.4s); 300s gives 60 percent headroom for HTTP, sandbox, authority and final regression coverage.
-size internal/equipo 16620 - Merge authority thin v1 adds the project page's "How Equipo merges" section and form (merge_policy_page.go, about 90 lines) and 86 strings; measured 16568 with main (spend-1, the four UI branches) merged. Spend 1 (work_spend.go and the task page lines, about 90 lines) merged onto the four UI branches: measured 16381. The team panel merged onto Projects UX, the Settings pattern and the Connections countdown: measured 16280 with all four. The team panel adds the compact specialist rows, the drawer page and its view (team_panel.go, team.html, team-panel.js, about 420 lines), the activity wording (team_activity.go) and their CSS and copy; the command reading went to its own package (internal/equipo/activity); measured 15788. Projects UX merged onto the Connections countdown and the Settings pattern: measured 15942 with all three. Projects UX adds the Projects page order (starred, active, quiet folded), the auto-star rules and their receipt, whole-word descriptions and the star action (project_order.go, about 200 lines), the Mac decision and Ask about this; measured 15815. Connection resets as a countdown (inText and its words, about 60 lines) and the Settings page pattern (settings_hub.go, team_links.go, about 30 lines) together; measured 15577 with both merged. The Connections Add page and four display fixes add the Add page handler, account naming, stale meter filtering and the resting row's destination (connections_view.go, chat_connections.go, about 120 lines); measured 15467. Claude setup tokens add the token card, sealing route and Check again beside the composer and Mac lines; measured 15350. Settings in sections adds the section pages, the secondary menu and the old URLs' redirects (settings_hub.go, about 110 lines, less the removed Thinking words page); measured 14922. Mac runners (Darwin worker) add the one-tap enrolment link, the runners view's self-probes, /install.sh, the outside-the-sandbox label and their copy (about 90 lines); measured 15058. Mac runners add the runner role, the protocol route and the placement minute, then two-phase removal, Remove now and Recover (about 110 lines). Housekeeping slice 1 adds the Housekeeping view beside the Notebook, the digest line and their copy (housekeeping_page.go, about 170 lines); measured 14513. Thin v1 UX1 thinking words adds the settings page and the set registry wiring (thinking_words.go) and 55 strings of phrases; measured 14411. The Connections page to Paul's approved mockup (connections_view.go: what is answering, the preference, rows with headroom, roles, usage and the recovery action, about 300 lines); measured 14268. Merged with UX1 round 3 (duplicate combining with Undo, timeline headlines) beside the Connections page; measured 13895. Connections slice 1 adds the Connections page, the switched line and the no_connection card and their copy (chat_connections.go, about 220 lines). Measured 12269. Thin v1 UX1 adds the inner screens' view model (work_views.go: stage track, badges, timeline, decisions, project facts, about 830 lines), the rich page handlers and their copy (about 170 lines); measured 13263. Thin v1 slice 4c adds the merged line, the merge card and its copy (about 60 lines). Thin v1 slice 4 adds the thin sidebar (rail.go), review and checks lines on the task card and pages, and their copy (about 190 lines). Thin v1 slice 3 adds the task card, the thin Tasks and Projects pages and their actions over the chat store, and their copy (about 280 lines). Thin v1 slice 2 adds activity labels, card copy and card rendering on the chat page (about 250 lines); slice 1 added the chat wiring and page (about 180 lines) beside code its slice 7 sweep deletes (the live hub, the old coordinator); lower then. Task 7 keeps the existing ceiling by moving transaction-bound event lookup into conversation. Measured 10796 source and 437 test lines; roster, database, pending copy and execution wiring remain here.
+size internal/equipo 16950 - Merge authority merged onto Machines in Settings: measured 16889. Merge authority thin v1 adds the project page's "How Equipo merges" section and form (merge_policy_page.go, about 90 lines) and 86 strings; measured 16568 with main (spend-1, the four UI branches) merged. Spend 1 (work_spend.go and the task page lines, about 90 lines) merged onto the four UI branches: measured 16381. The team panel merged onto Projects UX, the Settings pattern and the Connections countdown: measured 16280 with all four. The team panel adds the compact specialist rows, the drawer page and its view (team_panel.go, team.html, team-panel.js, about 420 lines), the activity wording (team_activity.go) and their CSS and copy; the command reading went to its own package (internal/equipo/activity); measured 15788. Projects UX merged onto the Connections countdown and the Settings pattern: measured 15942 with all three. Projects UX adds the Projects page order (starred, active, quiet folded), the auto-star rules and their receipt, whole-word descriptions and the star action (project_order.go, about 200 lines), the Mac decision and Ask about this; measured 15815. Connection resets as a countdown (inText and its words, about 60 lines) and the Settings page pattern (settings_hub.go, team_links.go, about 30 lines) together; measured 15577 with both merged. Machines in Settings adds the Machines list and Add a machine screens (machines_view.go, the runners.html rewrite, machines.js, their CSS, three icons and 35 strings, about 280 lines); measured 16664. Spend 1 (work_spend.go and the task page lines, about 90 lines) merged onto the four UI branches: measured 16381. The team panel merged onto Projects UX, the Settings pattern and the Connections countdown: measured 16280 with all four. The team panel adds the compact specialist rows, the drawer page and its view (team_panel.go, team.html, team-panel.js, about 420 lines), the activity wording (team_activity.go) and their CSS and copy; the command reading went to its own package (internal/equipo/activity); measured 15788. Projects UX merged onto the Connections countdown and the Settings pattern: measured 15942 with all three. Projects UX adds the Projects page order (starred, active, quiet folded), the auto-star rules and their receipt, whole-word descriptions and the star action (project_order.go, about 200 lines), the Mac decision and Ask about this; measured 15815. Connection resets as a countdown (inText and its words, about 60 lines) and the Settings page pattern (settings_hub.go, team_links.go, about 30 lines) together; measured 15577 with both merged. The Connections Add page and four display fixes add the Add page handler, account naming, stale meter filtering and the resting row's destination (connections_view.go, chat_connections.go, about 120 lines); measured 15467. Claude setup tokens add the token card, sealing route and Check again beside the composer and Mac lines; measured 15350. Settings in sections adds the section pages, the secondary menu and the old URLs' redirects (settings_hub.go, about 110 lines, less the removed Thinking words page); measured 14922. Mac runners (Darwin worker) add the one-tap enrolment link, the runners view's self-probes, /install.sh, the outside-the-sandbox label and their copy (about 90 lines); measured 15058. Mac runners add the runner role, the protocol route and the placement minute, then two-phase removal, Remove now and Recover (about 110 lines). Housekeeping slice 1 adds the Housekeeping view beside the Notebook, the digest line and their copy (housekeeping_page.go, about 170 lines); measured 14513. Thin v1 UX1 thinking words adds the settings page and the set registry wiring (thinking_words.go) and 55 strings of phrases; measured 14411. The Connections page to Paul's approved mockup (connections_view.go: what is answering, the preference, rows with headroom, roles, usage and the recovery action, about 300 lines); measured 14268. Merged with UX1 round 3 (duplicate combining with Undo, timeline headlines) beside the Connections page; measured 13895. Connections slice 1 adds the Connections page, the switched line and the no_connection card and their copy (chat_connections.go, about 220 lines). Measured 12269. Thin v1 UX1 adds the inner screens' view model (work_views.go: stage track, badges, timeline, decisions, project facts, about 830 lines), the rich page handlers and their copy (about 170 lines); measured 13263. Thin v1 slice 4c adds the merged line, the merge card and its copy (about 60 lines). Thin v1 slice 4 adds the thin sidebar (rail.go), review and checks lines on the task card and pages, and their copy (about 190 lines). Thin v1 slice 3 adds the task card, the thin Tasks and Projects pages and their actions over the chat store, and their copy (about 280 lines). Thin v1 slice 2 adds activity labels, card copy and card rendering on the chat page (about 250 lines); slice 1 added the chat wiring and page (about 180 lines) beside code its slice 7 sweep deletes (the live hub, the old coordinator); lower then. Task 7 keeps the existing ceiling by moving transaction-bound event lookup into conversation. Measured 10796 source and 437 test lines; roster, database, pending copy and execution wiring remain here.
size internal/equipotest - 13400 Task 21 repairs historical migration and conversation fixtures after Plan 3. Measured 13024 test lines; the 300s time ceiling is unchanged.
time internal/runner/checks 90s CI worker measured 44.553s (44.6s rounded); 60s gives 34 percent headroom. Shared baseline capture reduces repeated Go runs; retain the CI allowance for sandbox sentinels, timeout and child cleanup. 2026-11-07: loaded CI (host load about 24) measured 66.5s with the package unchanged by thin v1 slice 4 beyond optional check mounts; 90s keeps 35 percent headroom.
time internal/runner 330s Plan 3 CI repair measured 292.120s for the full package (controller CI 472.184s). Parallel plan graphs and removal of repeated progress floods reduced their local targeted run from 146.920s to 30.784s; the original bug graph retains volume coverage. Keep 330s for journal, proxy, recovery and namespace integration, with 13 percent headroom.
@@ -49,7 +49,7 @@ perf GET /api/v1/notebook skip Thin v1 person API: bearer-only JSON for devices;
perf GET /api/v1/thinking skip Thin v1 person API: bearer-only JSON for devices; the browser reads thinking words on /settings/thinking.
perf GET /api/v1/tasks skip Thin v1 person API: bearer-only JSON for devices; the browser reads tasks through /tasks.
perf GET /api/v1/tasks/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads a task through /tasks/{id}.
-size internal/equipo/chat 13970 - Merge authority thin v1 adds the gate's store side (mergeauth.go: authorizeMerge before dispatch and at each hub request, the fence for runners below the merge-facts protocol, the ask card in Equipo's words, the ships question, receipts with Undo, the policy tool and API, about 1000 lines); the gate is pure, in internal/equipo/mergegate, but its inputs and audit must be read and written inside the store's transactions. Measured 13204. Mac recheck runs a waiting task's needs_macos checks again when a Mac that fits arrives (macrecheck.go, about 90 lines); measured 12485. Spend 1 merged onto Projects UX: measured 12376 with both. Spend 1 adds a task's spend from its usage rows (TaskSpend, about 60 lines) and the usage rows' round; measured 12047. Projects UX adds per-person project stars with the auto-star reconciliation, the person's and the coordinator's star_project (stars.go, about 210 lines) and the project's own repository in its view; measured 12206. Claude's sign-in by a link adds the code route beside the token's in SendSecret, the sign-in prompt and the kind it becomes (about 40 lines); measured 11933. Mac runners slices A and B add per-runner mailboxes, placement, withdrawal, the offline rule, the runners view, transfers and publication (runners.go, transfers.go, about 1100 lines). Composer attachments add uploads, the message link, the mailbox relay with chunk frames hydrated from the stored file, and serving (attachments.go, attachments_http.go, about 330 lines); the link and relay run inside the send and dispatch transactions, so they live beside them; sniffing and stripping are pure, in internal/attach. Measured 10292. Merged with UX1 thinking words (f2602d3), measured 9801. Housekeeping slice 1 adds the loop's ledger and state machine, the housekeeping principal's checks inside the shared store functions, reservations, Pause, quiet hours, the digest, claim recovery and the API (housekeeping.go, housekeeping_control.go, housekeeping_http.go, about 1,350 lines); the checks must run inside the store's transactions, so they live beside them; the detectors themselves are pure, in internal/equipo/housekeeping. Measured 9637. Thin v1 UX1 thinking words adds the per-person set and its API (thinking.go, about 100 lines); measured 8305. Connections slice 1 review round 2: the mutation ledger matches record_task by subject only and refuses an ambiguous call with the earlier operations, the preference and forget (about 120 lines); measured 8236. Thin v1 UX1 round 3 adds Equipo combining duplicate tasks reversibly (duplicates.go: detection, the in-transaction fold checks, fold, Undo, about 400 lines) and headlines on findings and steps (headline.go); measured 7898. Connections slice 1 adds connection records from hello and attempts, the connect mailbox, the API, usage rows and the turn's mutation ledger (connections.go and tools.go, about 600 lines); measured 7400 after merging UX1. Thin v1 UX1 adds step activity lines, duplicates and their fold, the coordinator at work on a task, project facts from the runner catalog and open merge cards for the pages (inner.go, about 330 lines); measured 6610 with slice 4c's review fixes. Thin v1 slice 4c adds the merge policy, the merge card, the rebase round and duplicate reports (merge.go, about 380 lines). Thin v1 instance core: conversation, projects, tasks, review and, from slice 4b, questions to the specialists (questions.go, about 470 lines) share one store, transaction and event log; splitting would export the transaction internals. Measured 5514 source lines; revisit at the slice 7 sweep.
+size internal/equipo/chat 14050 - The re-run ruling (recheckMayMerge, refreshAfterRecheck, about 70 lines); measured 13981. Merge authority thin v1 adds the gate's store side (mergeauth.go: authorizeMerge before dispatch and at each hub request, the fence for runners below the merge-facts protocol, the ask card in Equipo's words, the ships question, receipts with Undo, the policy tool and API, about 1000 lines); the gate is pure, in internal/equipo/mergegate, but its inputs and audit must be read and written inside the store's transactions. Measured 13204. Mac recheck runs a waiting task's needs_macos checks again when a Mac that fits arrives (macrecheck.go, about 90 lines); measured 12485. Spend 1 merged onto Projects UX: measured 12376 with both. Spend 1 adds a task's spend from its usage rows (TaskSpend, about 60 lines) and the usage rows' round; measured 12047. Projects UX adds per-person project stars with the auto-star reconciliation, the person's and the coordinator's star_project (stars.go, about 210 lines) and the project's own repository in its view; measured 12206. Claude's sign-in by a link adds the code route beside the token's in SendSecret, the sign-in prompt and the kind it becomes (about 40 lines); measured 11933. Mac runners slices A and B add per-runner mailboxes, placement, withdrawal, the offline rule, the runners view, transfers and publication (runners.go, transfers.go, about 1100 lines). Composer attachments add uploads, the message link, the mailbox relay with chunk frames hydrated from the stored file, and serving (attachments.go, attachments_http.go, about 330 lines); the link and relay run inside the send and dispatch transactions, so they live beside them; sniffing and stripping are pure, in internal/attach. Measured 10292. Merged with UX1 thinking words (f2602d3), measured 9801. Housekeeping slice 1 adds the loop's ledger and state machine, the housekeeping principal's checks inside the shared store functions, reservations, Pause, quiet hours, the digest, claim recovery and the API (housekeeping.go, housekeeping_control.go, housekeeping_http.go, about 1,350 lines); the checks must run inside the store's transactions, so they live beside them; the detectors themselves are pure, in internal/equipo/housekeeping. Measured 9637. Thin v1 UX1 thinking words adds the per-person set and its API (thinking.go, about 100 lines); measured 8305. Connections slice 1 review round 2: the mutation ledger matches record_task by subject only and refuses an ambiguous call with the earlier operations, the preference and forget (about 120 lines); measured 8236. Thin v1 UX1 round 3 adds Equipo combining duplicate tasks reversibly (duplicates.go: detection, the in-transaction fold checks, fold, Undo, about 400 lines) and headlines on findings and steps (headline.go); measured 7898. Connections slice 1 adds connection records from hello and attempts, the connect mailbox, the API, usage rows and the turn's mutation ledger (connections.go and tools.go, about 600 lines); measured 7400 after merging UX1. Thin v1 UX1 adds step activity lines, duplicates and their fold, the coordinator at work on a task, project facts from the runner catalog and open merge cards for the pages (inner.go, about 330 lines); measured 6610 with slice 4c's review fixes. Thin v1 slice 4c adds the merge policy, the merge card, the rebase round and duplicate reports (merge.go, about 380 lines). Thin v1 instance core: conversation, projects, tasks, review and, from slice 4b, questions to the specialists (questions.go, about 470 lines) share one store, transaction and event log; splitting would export the transaction internals. Measured 5514 source lines; revisit at the slice 7 sweep.
perf GET /api/v1/questions/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads questions on /tasks/{id}.
perf GET /api/v1/steps/{id}/log skip Thin v1 person API: bearer-only JSON for devices; the browser shows the log tail on /tasks/{id}.
perf GET /api/v1/connections/preference skip Connections slice 1 person API: bearer-only JSON for devices; the browser shows the preference on /conversation/connections.
@@ -61,6 +61,6 @@ perf GET /conversation/attachments/{id} skip Composer attachments: the bytes of
perf GET /conversation/attachments/{id}/preview skip Composer attachments: an image thumbnail inside the conversation; 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 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 - 8300 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 - 12600 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. 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/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 - 12860 Merge authority merged onto Machines in Settings, with the re-run ruling's cases: measured 12790. 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. 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/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index bfb744c5..47c297d4 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -6079,6 +6079,41 @@ records remain unchanged.
| `work.spend_questions` | Questions | Spend 1 (task page and specialist panel) | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| `work.spend_left_out` | Earlier usage not shown | Spend 1 (task page) | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| `work.spend_steps` | Tokens each step used | Spend 1 (task page and specialist panel) | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.lede` | The computers that do your work. A machine is online when its runner is connected to Equipo. | Machines (Settings): head line | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.mine` | Your machines | Machines (Settings): group heading | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.mine_none` | You have no machines yet. | Machines (Settings): an owner with none of their own | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.others` | Other people's machines | Machines (Settings): folded group of other people's machines | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.state.online` | Online | Machines and Add a machine: row state | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.state.offline` | Offline | Machines and Add a machine: row state | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.state.never` | Never connected | Machines and Add a machine: row state | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.state.removing` | Removing | Machines: row state | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.state.revoked` | Revoked | Machines: row state (a removed machine an owner still sees) | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.never_hint` | This machine was added but has never connected. Check that the runner is running on it. | Machines and Add a machine: row of a machine that never connected | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.last_seen` | Last seen %s | Machines: offline row, after the state | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.role.primary` | Main runner | Machines: row role | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.role.worker` | Runs checks | Machines: row role | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.platform.darwin` | macOS | Machines: row platform | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.platform.linux` | Linux | Machines: row platform | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.version` | Version | Machines: row details label | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.protocol` | Protocol | Machines: row details label | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.tags` | Tags | Machines: row details label | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.enrolled` | Added | Machines: row details label | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.enrolled_by` | Added by | Machines: row details label | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.not_reported` | Not reported yet | Machines: row details value before the first connection | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.revoke_confirm` | Equipo gives this machine no new work and asks it to stop its current work. It removes the machine once it confirms that work has stopped. | Machines: row details, Revoke machine opened | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.revoke_yes` | Yes, revoke it | Machines: row details, Revoke machine confirm button | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.remove_confirm` | For a lost or compromised machine. Equipo removes its access now. Work may still be running on it. Any step it may have started is blocked from retrying until the task's creator recovers it. | Machines: row details, Remove now opened | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.remove_yes` | Yes, remove it now | Machines: row details, Remove now confirm button | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.add` | Add a machine | Machines: add link; Add a machine: title; Settings rail entry | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.add_hint` | Install the runner on a Mac or a Linux machine, then approve it here. | Machines: beside the add link | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.empty_title` | No machines yet | Machines: empty state heading | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.empty_body` | Equipo does its work on your machines. Add one to get started. | Machines: empty state line | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.add_lede` | Install the runner on the machine you want to add, then approve it here. | Add a machine: head line | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.step_install` | On that machine, run this in a terminal. | Add a machine: step 1, above the install line | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.step_code` | It prints a link and a code. Open the link, or type the code here. | Add a machine: step 2, above the code field | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.step_approve` | Check that the label and key fingerprint match the machine, then approve it. You can check its connection below. | Add a machine: step 3 | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.new` | New machines | Add a machine: group heading | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `machines.new_none` | Recently approved machines appear here, along with any that have never connected. | Add a machine: group with no new machines | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
## Task 21
@@ -6803,3 +6838,53 @@ pass merges under slice 4c. The hint is a plain line again: "Merge now
merges it without checks. Wait for a Mac keeps it ready. Once a Mac is set
up, checks run, and if they pass, Equipo merges it by itself." Accepted by
delegation like its neighbours.
+
+## Machines in Settings (2026-11-11)
+
+Machines moved under Settings, beside Connections and drawn like it:
+`/conversation/settings/machines` lists the person's machines as compact
+rows (name, state, role, platform) that open in place for the details
+(platform, version, protocol, tags, checks, when and by whom it was
+added, key fingerprint, self-checks, supervised history, taint or removal).
+Other people's machines, which only an owner sees, are folded and closed
+with a count. Revoke and Remove now sit in the details as quiet buttons,
+each opening a short explanation and a confirm button that posts the
+same form as before. A machine with no runner session reads Never
+connected, tinted, with a line saying to check its runner is running.
+
+`/conversation/settings/machines/add` is Add a machine: the install line
+`/install.sh` answers (shown only when it answers), the code field, and
+the person's new machines (never connected, or approved in the last half
+hour). It follows the person's event stream: nav-stream.js passes the
+`runner` event on as `equipo:runner` and machines.js reads the page again
+without the code and swaps the list in place. There is no new external
+polling; it also rereads its own page once a minute while visible, as a
+runner that stops answering goes offline with no event.
+
+`/runners/enrol` is the address runners print and check, so it still
+serves: without a code it is the Machines list, with `?code=` the Add a
+machine page and its approval card. The approval, inspect, revoke and
+remove-now POSTs, their checks and `approveOrInspect` are unchanged;
+only the pages they render and the 303 targets moved (approval to Add a
+machine, revoke and remove-now to Machines). Machines that have not yet
+been approved cannot appear on Add a machine before their code is
+entered: the enrolment holds only the code's hash and binds no person
+until approval, so listing them would change the approval model.
+
+Copy: 35 new strings. One delegated Astra pass (gpt-6-astra, effort
+high) kept 30 and changed 5 (`machines.lede`, `machines.revoke_confirm`,
+`machines.remove_confirm`, `machines.step_approve`,
+`machines.new_none`); all 35 rows above are marked COPY ACCEPTED BY
+DELEGATION (Astra, 2026-11-11), and copy.go matches. Astra's one flag:
+a machine stays under New machines for half an hour after approval even
+once it connects. That is intended (the person sees it come online), and
+`machines.new_none` now says so.
+
+Verification (targeted, niced):
+
+- `go test ./internal/equipo -run 'TestMachines|TestRunnersViewShowsProbes|TestTemplateCopyKeys|TestRunnerCopyInventory|TestInstallScript'`: ok. Mutations: the others fold rendered open, and the never-connected hint removed: TestMachinesList red for each; restored.
+- `go test ./internal/thintest -run 'TestPagesMachines|TestPagesSettingsSections|TestPagesSettingsRail|TestPagesRemovalAndRecover|TestPagesTaskDecisionsSayWhy|TestPagesInnerScreens'`: ok.
+- `go test -tags browser ./internal/thintest -run 'TestBrowserMachines$'` then `'TestBrowserSettingsShots$'`: ok (the never-connected Mac comes online in place, no reload).
+- `go test ./internal/equipotest -run 'TestEnrolment|TestMacEnrolment|TestRunnerRemovalRevokes|TestRunnerAppCSRF|TestRunner.*HistoryLabel'`: ok.
+- `go test ./internal/plan3test -run 'TestPlan3ReleaseBoundaries|TestOnboarding|TestCoordinatorAcceptance3B|TestInviteSignInPendingMember|TestInviteCurrentAuthority'`: ok.
+- `go test -tags perf ./internal/equipotest -run '^TestPerfScreens$'`: ok. `make budget`: ok after raising internal/equipo to 16664 and internal/thintest to 11759 test lines (measured).
diff --git a/docs/superpowers/plans/MERGEAUTH-PROGRESS.md b/docs/superpowers/plans/MERGEAUTH-PROGRESS.md
index a4014e06..5bb839a5 100644
--- a/docs/superpowers/plans/MERGEAUTH-PROGRESS.md
+++ b/docs/superpowers/plans/MERGEAUTH-PROGRESS.md
@@ -181,3 +181,35 @@ tip fallback fix for every merge (a separate issue).
card and `POST /api/v1/tasks/{id}/undo-merge` (`{"revision": n}`).
`TestContractUndoMerge` adds a person's merge with the hub's answer
(no Undo) and a stale revision (409); mutations killed.
+
+## The ruling on Critical 2 (Mac re-runs of an asked SHA)
+
+The controller ruled: a re-run's pass on the exact candidate may merge
+on its own (through `authorizeMerge`) only when the card asked solely
+because checks could not run, or the person chose Wait for a Mac on that
+SHA's card. For any other reason the SHA stays asked and the card is
+re-decided as a `card_refresh`. No new column: the reason is the SHA's
+newest `decision` or `card_refresh` audit row (`recheckMayMerge`); no
+row counts as another reason (fails closed). The Wait is read from the
+task's newest merge card, so a Wait on an earlier SHA never counts.
+`recheckMac` withdraws the card and clears `merge_asked` only when the
+pass may merge; otherwise `autoMerge` keeps the SHA asked and
+re-decides the card once after the re-run finishes
+(`refreshAfterRecheck`).
+
+`TestContractMacRecheckMergeAuthority` through the real recheck path:
+Wait chosen merges; checks only merges (its reason is seeded, since the
+gate never asks a needs_macos change for checks alone); sensitive, held
+and main ships stay asked with the same card refreshed; a missing reason
+stays asked; a pass on another SHA counts for nothing.
+`TestContractMacRecheckOnlyWaiting` now expects the waiting task's card
+to stay open. Mutations, each killed: checks-only predicate off (checks
+only), Wait ignored (Wait chosen), any failing criterion treated as
+checks only (sensitive, held, ships), no row treated as may-merge
+(missing reason), no refresh after the re-run (sensitive, held, ships),
+the re-run withdrawing the card regardless (sensitive, held, ships).
+
+Operating rule (spec §10a): deploy with no merge in flight. An older
+build already part-way through a hub merge request when the instance
+swaps cannot be stopped by the fence; restart the runners on the new
+build right after the swap.
diff --git a/docs/superpowers/specs/2026-11-11-equipo-merge-authority.md b/docs/superpowers/specs/2026-11-11-equipo-merge-authority.md
index 37fd8a1e..a411fd6b 100644
--- a/docs/superpowers/specs/2026-11-11-equipo-merge-authority.md
+++ b/docs/superpowers/specs/2026-11-11-equipo-merge-authority.md
@@ -101,12 +101,19 @@ func Decide(in Inputs) Decision
card). Outside the sandbox: `ask`, as today. The runner must speak
`wire.ProtocolMergeFacts` here too (Refuse old runners). A pass from a
Mac re-run (mac-recheck, `chat_steps.recheck_by`) on the exact
- candidate makes it eligible when the passing result lands, and is
- then judged like a merge without checks less the environment rule: a
- routine change merges on its own; a sensitive, large or shipping one,
- a held one, or one in an asking project asks. A re-run that fails
- takes the normal fix round; a result on another SHA counts for
- nothing.
+ candidate is eligible when the passing result lands. The controller's
+ ruling on an asked SHA: the re-run's pass may merge on its own (still
+ through `authorizeMerge`, judged like a merge without checks less the
+ environment rule) only when the card asked solely because checks
+ could not run (the SHA's newest `decision` or `card_refresh` audit row
+ fails `environment_reason` alone) or the person chose Wait for a Mac
+ on that SHA's card; then the re-run withdraws the card. For any other
+ reason (sensitive, large, ships, held, ask mode, or no recorded reason,
+ which fails closed) the SHA stays asked: the card stays open and the
+ pass re-decides its words once, as a `card_refresh` (audited, never
+ acted on). A SHA never asked about decides afresh as usual. A re-run
+ that fails takes the normal fix round; a result on another SHA counts
+ for nothing.
4. **Without checks**: `act` only when ALL hold, else `ask`:
| Criterion | Holds when |
@@ -539,6 +546,17 @@ the project page section's sentences; the `hold_merge` and
`set_merge_policy` tool descriptions; the Stopped line for
`merge_not_authorized`.
+## 10a. Operating rule: deploy with no merge in flight
+
+The fence for older runners (§2.3) settles every automatic merge step
+the moment such a runner connects. What it cannot stop is an older build
+that is already part-way through a hub merge request when the instance
+changes: that request goes on, and the forge record and the merge watch
+settle its landing afterwards. So deploy with no merge in flight: before
+an instance swap, check that no merge step is queued or running, and
+restart every runner on the new build right after it. A runner that has
+never connected, or installs from `install.sh`, gets the new build.
+
## 11. Moved to v2
- Verification on the merged commit when checks can run, as its own
diff --git a/internal/chatmarkdown/draft.go b/internal/chatmarkdown/draft.go
new file mode 100644
index 00000000..b438a20b
--- /dev/null
+++ b/internal/chatmarkdown/draft.go
@@ -0,0 +1,174 @@
+package chatmarkdown
+
+import (
+ "bytes"
+ "regexp"
+ "sort"
+ "strings"
+
+ "github.com/yuin/goldmark/ast"
+ "github.com/yuin/goldmark/parser"
+ "github.com/yuin/goldmark/text"
+ "github.com/yuin/goldmark/util"
+)
+
+// A draft is a reply still arriving, rendered by Render's own walk over
+// the same parse. What the next characters could still change is left
+// out until they come:
+//
+// - a last line that is only a list marker, a heading's hashes, a fence
+// or a rule on its way ("-", "2.", "##", "``") waits for more of its
+// line;
+// - in the paragraph still open at the end, an emphasis opener or a
+// backtick with no closer yet is not shown, so its words are plain
+// text until it closes, and a link on its way shows only its words;
+// - an open code fence is an open code block, as goldmark parses it.
+//
+// Everything else is Render's: the same parser, the same escaping, the
+// same links.
+
+// parse is goldmark's default parser with its emphasis and code span
+// parsers watched: what each returns is noted in seen, so a draft
+// can find the openers left without a closer. Watching changes nothing
+// they parse, and Render and RenderDraft share it.
+func parse(source []byte) (ast.Node, *seen) {
+ inline := parser.DefaultInlineParsers()
+ for i, p := range inline {
+ if ip, ok := p.Value.(parser.InlineParser); ok && bytes.ContainsAny(ip.Trigger(), "*_`") {
+ inline[i] = util.Prioritized(watched{ip}, p.Priority)
+ }
+ }
+ p := parser.NewParser(parser.WithBlockParsers(parser.DefaultBlockParsers()...),
+ parser.WithInlineParsers(inline...),
+ parser.WithParagraphTransformers(parser.DefaultParagraphTransformers()...),
+ )
+ s := &seen{}
+ pc := parser.NewContext()
+ pc.Set(seenKey, s)
+ return p.Parse(text.NewReader(source), parser.WithContext(pc)), s
+}
+
+var seenKey = parser.NewContextKey()
+
+type seen struct{ found []ast.Node }
+
+type watched struct{ parser.InlineParser }
+
+func (w watched) Parse(parent ast.Node, block text.Reader, pc parser.Context) ast.Node {
+ n := w.InlineParser.Parse(parent, block, pc)
+ if s, ok := pc.Get(seenKey).(*seen); ok && n != nil {
+ s.found = append(s.found, n)
+ }
+ return n
+}
+
+// markerOnly is a last line with nothing yet but the start of a block:
+// a bullet or a number, hashes, a quote, a fence, a rule or an underline,
+// perhaps with the opener of its first words ("- **").
+var markerOnly = regexp.MustCompile("^[ \t]*(?:[-+*>]|[0-9]{1,9}[.)]?|#{1,6}|[`~]+|[-=_* \t]+)?[ \t]*[*_`]*$")
+
+// steady holds back a last line that is only a block's marker.
+func steady(body string) string {
+ i := strings.LastIndexByte(body, '\n') + 1
+ if markerOnly.MatchString(body[i:]) {
+ return body[:i]
+ }
+ return body
+}
+
+// openLink is a link on its way at the end of a line: its "[" (or "!["),
+// its words, and its "]" or "](" with as much of the destination as has
+// come. Brackets in a code span are not a link (no backtick inside).
+var openLink = regexp.MustCompile("(!?\\[)[^\\[\\]\n`]*(\\](?:\\([^()\\s]*)?)?$")
+
+// unclosed is what a draft leaves out of the paragraph still open at the
+// end: openers without a closer and the brackets of a link on its way.
+func unclosed(root ast.Node, source []byte, s *seen) spans {
+ from := openFrom(root, source)
+ if from < 0 {
+ return nil
+ }
+ var out spans
+ for _, n := range s.found {
+ switch v := n.(type) {
+ case *parser.Delimiter:
+ // What is left of a run that can open: "**Yes" and " *it",
+ // not "2 * 3" (which cannot open) or "it*" (which closes);
+ // and a run at the very end, which can be either once the
+ // next character comes.
+ opens := v.CanOpen && (!v.CanClose || v.OriginalLength >= 2) || v.Segment.Stop == len(source)
+ if v.Length > 0 && opens && v.Segment.Start >= from {
+ out = append(out, v.Segment)
+ }
+ case *ast.Text:
+ // The code span parser returns its backticks as text when no
+ // closing run follows.
+ if v.Segment.Start >= from {
+ out = append(out, v.Segment)
+ }
+ }
+ }
+ line := bytes.LastIndexByte(source, '\n') + 1
+ if line < from {
+ line = from
+ }
+ if m := openLink.FindSubmatchIndex(source[line:]); m != nil && (line+m[2] == 0 || source[line+m[2]-1] != '\\') {
+ out = append(out, text.NewSegment(line+m[2], line+m[3]))
+ if m[4] >= 0 {
+ out = append(out, text.NewSegment(line+m[4], line+m[5]))
+ }
+ }
+ sort.Slice(out, func(i, j int) bool { return out[i].Start < out[j].Start })
+ return out
+}
+
+// openFrom is where the paragraph (or heading) still open at the end of
+// the source starts, or -1 when the source ends in anything else or the
+// last paragraph has ended: a blank line after it, or a heading's line
+// break. Openers before it were never closed and show as the finished
+// message shows them.
+func openFrom(root ast.Node, source []byte) int {
+ n := root
+ for n.LastChild() != nil && n.LastChild().Type() == ast.TypeBlock {
+ n = n.LastChild()
+ }
+ switch n.(type) {
+ case *ast.Paragraph, *ast.TextBlock, *ast.Heading:
+ default:
+ return -1
+ }
+ lines := n.Lines()
+ if lines.Len() == 0 {
+ return -1
+ }
+ breaks := bytes.Count(source[lines.At(lines.Len()-1).Stop:], []byte("\n"))
+ if _, heading := n.(*ast.Heading); heading && breaks > 0 || breaks > 1 {
+ return -1
+ }
+ return lines.At(0).Start
+}
+
+// spans are source ranges a draft leaves out of its text, in order.
+type spans []text.Segment
+
+// value is a text segment's source without the ranges left out.
+func (h spans) value(source []byte, s text.Segment) []byte {
+ if len(h) == 0 {
+ return s.Value(source)
+ }
+ var out []byte
+ at := s.Start
+ for _, x := range h {
+ if x.Stop <= at || x.Start >= s.Stop {
+ continue
+ }
+ if x.Start > at {
+ out = append(out, source[at:x.Start]...)
+ }
+ at = x.Stop
+ }
+ if at < s.Stop {
+ out = append(out, source[at:s.Stop]...)
+ }
+ return out
+}
diff --git a/internal/chatmarkdown/draft_test.go b/internal/chatmarkdown/draft_test.go
new file mode 100644
index 00000000..82bb6496
--- /dev/null
+++ b/internal/chatmarkdown/draft_test.go
@@ -0,0 +1,115 @@
+package chatmarkdown
+
+import (
+ "html"
+ "regexp"
+ "strings"
+ "testing"
+ "unicode/utf8"
+)
+
+// corpus is coordinator replies as they are written: the recorded ones
+// (a bold opening line, a bold-led bullet list and a numbered list run
+// together while streaming) and the rest of the subset the chat renders.
+var corpus = []string{
+ // fakeclaude's markdownSample, which the browser test streams.
+ "**Yes. This is the right shape for it.** The invoice total is counted twice when delivery is added.\n\nTwo people see it:\n\n- **Guest:** sees the total on the basket page.\n- **Customer:** sees it again on the receipt.\n\nWhat I'd do, in [Fix the invoice total](/tasks/tks6kwzzdngr):\n\n1. **Owner of the fix:** Engineering, on the checkout repository.\n2. **One complete change:** the total, the receipt and `go test ./checkout/...` for both.\n3. **Review:** an independent check before it merges.",
+ "**Yes. This is the right shape for it.** The invoice total is counted twice when delivery is added.\n\nTwo people see it:\n\n- **Guest:** sees the total on the basket page.\n- **Customer:** sees it again on the receipt.\n\nWhat I'd do:\n\n1. **Owner of the fix:** Engineering, on the checkout repository.\n2. **One complete change:** the total, the receipt and a test for both.\n3. **Review:** an independent check before it merges.\n",
+ "I've logged [Fix the invoice total](/tasks/tks6kwzzdngr) in [Comercio](/projects/p_abc123). Engineering starts with a reproduction.",
+ "Run `go test ./internal/checkout/...` first, then this:\n\n```go\nfunc total(lines []Line) int {\n\tsum := 0\n\tfor _, l := range lines {\n\t\tsum += l.Price\n\t}\n\treturn sum\n}\n```\n\nThat is *all* it needs.",
+ "## Plan\n\nThree steps, each **small**:\n\n- read the code\n- reproduce it\n- fix it, with *one* test\n\nNested:\n\n1. First\n - a detail\n - another\n2. Second\n\n> Quoted note.\n\nLast line with a hard break \nand its continuation.",
+ "Café con ñandú, señor. ☕ **Ünïcödé** 🎉 works.\nA soft break, then\n\n---\n\nafter a rule.",
+}
+
+// visible is what a reader sees of rendered HTML: the text without tags,
+// entities resolved, runs of whitespace as one space.
+func visible(h string) string {
+ text := html.UnescapeString(regexp.MustCompile(`<[^>]*>`).ReplaceAllString(h, ""))
+ return strings.TrimSpace(strings.Join(strings.Fields(text), " "))
+}
+
+// code is a code block, whose text is the reply's own characters.
+var code = regexp.MustCompile(`(?s)<pre>.*?</pre>`)
+
+// The draft of a whole reply is the reply: the end of a stream adds
+// nothing to the layout but what the last characters bring.
+func TestDraftOfTheWholeReplyIsTheReply(t *testing.T) {
+ for _, reply := range corpus {
+ if got, want := RenderDraft(reply), Render(reply); got != want {
+ t.Errorf("draft of the whole reply differs\n draft: %q\nreply: %q", got, want)
+ }
+ }
+}
+
+// Every prefix of a reply, as it streams: no markup characters show (the
+// corpus has no literal ones), and what shows is the start of what the
+// finished reply shows.
+func TestDraftShowsNoMarkupAndOnlyTheReplysText(t *testing.T) {
+ for _, reply := range corpus {
+ final := visible(string(Render(reply)))
+ for i := 0; i <= len(reply); i++ {
+ if i < len(reply) && !utf8.RuneStart(reply[i]) {
+ continue
+ }
+ draft := string(RenderDraft(reply[:i]))
+ seen := visible(draft)
+ if prose := visible(code.ReplaceAllString(draft, "")); strings.ContainsAny(prose, "*`[]#") || strings.Contains(prose, "](") {
+ t.Fatalf("markup shows at %d %q: %q", i, reply[:i], seen)
+ }
+ if !strings.HasPrefix(final, seen) {
+ t.Fatalf("draft at %d %q shows %q, not the start of %q", i, reply[:i], seen, final)
+ }
+ }
+ }
+}
+
+func TestDraftPartialSyntax(t *testing.T) {
+ for _, c := range []struct{ text, want string }{
+ // An unclosed ** or backtick is plain text until it closes.
+ {"**Yes. This is", "<p>Yes. This is</p>\n"},
+ {"**Yes. This is**", "<p><strong>Yes. This is</strong></p>\n"},
+ {"**closed** and **op", "<p><strong>closed</strong> and op</p>\n"},
+ {"*it", "<p>it</p>\n"},
+ {"Run `go te", "<p>Run go te</p>\n"},
+ {"Run `go test`", "<p>Run <code>go test</code></p>\n"},
+ {"- **Guest:** sees it\n- **Cus", "<ul><li><strong>Guest:</strong> sees it</li>\n<li>Cus</li>\n</ul>\n"},
+ // A paragraph that has ended keeps what it has: it shows as the
+ // finished reply will.
+ {"Para **open\n\nNext", "<p>Para **open</p>\n<p>Next</p>\n"},
+ // Arithmetic is not an opener.
+ {"2 * 3", "<p>2 * 3</p>\n"},
+ // A partial list marker or heading waits for more of its line.
+ {"- **Guest:** a\n-", "<ul><li><strong>Guest:</strong> a</li>\n</ul>\n"},
+ {"- **Guest:** a\n- ", "<ul><li><strong>Guest:</strong> a</li>\n</ul>\n"},
+ {"1. **Owner**\n2", "<ol><li><strong>Owner</strong></li>\n</ol>\n"},
+ {"1. **Owner**\n2.", "<ol><li><strong>Owner</strong></li>\n</ol>\n"},
+ {"Text\n\n##", "<p>Text</p>\n"},
+ {"## Pl", "<p>Pl</p>\n"},
+ {"Text\n--", "<p>Text</p>\n"},
+ // An open code fence is an open code block; a closing fence on
+ // its way shows nothing.
+ {"```go\nfmt.Println(", "<pre><code>fmt.Println(\n</code></pre>\n"},
+ {"```go\nx := 1\n``", "<pre><code>x := 1\n</code></pre>\n"},
+ {"``", ""},
+ // A link on its way shows its words.
+ {"See [Fix the inv", "<p>See Fix the inv</p>\n"},
+ {"See [Fix the invoice]", "<p>See Fix the invoice</p>\n"},
+ {"See [Fix](/tasks/tk1", "<p>See Fix</p>\n"},
+ {"See [Fix](/tasks/tk1)", "<p>See <a href=\"/tasks/tk1\" rel=\"noopener\">Fix</a></p>\n"},
+ {"Code `a[b`", "<p>Code <code>a[b</code></p>\n"},
+ } {
+ if got := string(RenderDraft(c.text)); got != c.want {
+ t.Errorf("RenderDraft(%q)\n got %q\nwant %q", c.text, got, c.want)
+ }
+ }
+}
+
+// The draft keeps the safe subset: the same rules as a finished reply.
+func TestDraftKeepsTheSafeSubset(t *testing.T) {
+ for _, raw := range []string{`<script>alert(1)</script>`, `<img src=x onerror=alert(1)>`, `[x](javascript:alert%281%29)`, "[x](javascript:alert(1)", `![x](https://evil.test/a)`, "<scr"} {
+ got := string(RenderDraft(raw))
+ if strings.Contains(got, "<script") || strings.Contains(got, "<img") || strings.Contains(got, "<scr") || strings.Contains(got, `href="javascript:`) {
+ t.Fatal("unsafe", got)
+ }
+ }
+}
diff --git a/internal/chatmarkdown/markdown.go b/internal/chatmarkdown/markdown.go
index 1cf76bf0..28f26f11 100644
--- a/internal/chatmarkdown/markdown.go
+++ b/internal/chatmarkdown/markdown.go
@@ -8,15 +8,29 @@ import (
"net/url"
"regexp"
- "github.com/yuin/goldmark"
"github.com/yuin/goldmark/ast"
- "github.com/yuin/goldmark/text"
"github.com/yuin/goldmark/util"
)
-func Render(body string) template.HTML {
+// Render renders a finished message.
+func Render(body string) template.HTML { return render(body, false) }
+
+// RenderDraft renders a reply that is still arriving with the same rules,
+// leaving out only what the next characters could still change (see
+// draft.go). The draft of a whole reply is the reply's Render, unless the
+// reply itself ends on an unclosed opener or a bare list marker.
+func RenderDraft(body string) template.HTML { return render(body, true) }
+
+func render(body string, draft bool) template.HTML {
+ var hide spans
+ if draft {
+ body = steady(body)
+ }
source := []byte(body)
- root := goldmark.DefaultParser().Parse(text.NewReader(source))
+ root, seen := parse(source)
+ if draft {
+ hide = unclosed(root, source, seen)
+ }
var out bytes.Buffer
escape := func(b []byte) { out.WriteString(html.EscapeString(string(b))) }
var node func(ast.Node)
@@ -35,7 +49,7 @@ func Render(body string) template.HTML {
case *ast.TextBlock:
children(n)
case *ast.Text:
- escape(util.ResolveEntityNames(util.ResolveNumericReferences(util.UnescapePunctuations(v.Segment.Value(source)))))
+ escape(util.ResolveEntityNames(util.ResolveNumericReferences(util.UnescapePunctuations(hide.value(source, v.Segment)))))
if v.HardLineBreak() {
out.WriteString("<br>\n")
} else if v.SoftLineBreak() {
diff --git a/internal/equipo/app.go b/internal/equipo/app.go
index c1af28a0..e083b703 100644
--- a/internal/equipo/app.go
+++ b/internal/equipo/app.go
@@ -245,6 +245,7 @@ func RouterWithStore(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logg
r.Get("/conversation", a.chatPage)
r.Post("/conversation", a.chatSend)
r.Post("/conversation/attachments", a.chatUpload)
+ r.Post("/conversation/draft", a.chatDraft)
r.Get("/conversation/attachments/{id}", a.chatAttachment(false))
r.Get("/conversation/attachments/{id}/preview", a.chatAttachment(true))
r.Post("/conversation/cards/{id}/answer", a.chatCardAnswer)
@@ -263,6 +264,8 @@ func RouterWithStore(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logg
r.Get("/conversation/connections", movedTo("/conversation/settings/connections"))
r.Get("/conversation/settings/connections", a.connectionsView)
r.Get("/conversation/settings/connections/add", a.connectionsAdd)
+ r.Get("/conversation/settings/machines", a.machinesList)
+ r.Get("/conversation/settings/machines/add", a.machinesAdd)
r.Post("/conversation/connections", a.connectionsStart)
r.Post("/conversation/connections/{id}/cancel", a.connectionsCancel)
r.Post("/conversation/connections/{id}/secret", a.connectionsSecret)
diff --git a/internal/equipo/chat/macrecheck.go b/internal/equipo/chat/macrecheck.go
index 0d8e9ad6..86304d72 100644
--- a/internal/equipo/chat/macrecheck.go
+++ b/internal/equipo/chat/macrecheck.go
@@ -71,14 +71,24 @@ func (t *txn) recheckMac(person, runner string) error {
if ran > 0 {
continue
}
- // The card asked whether to merge without checks; they run now,
- // and their outcome asks afresh if it must.
- if err := t.withdrawMergeCards(*k); err != nil {
+ // The card asked whether to merge without checks; they run now. Merge
+ // authority's ruling: the pass may merge on its own only when the
+ // card asked solely because checks could not run, or the person chose
+ // Wait for a Mac; then the card goes and the outcome decides afresh.
+ // For any other reason the SHA stays asked and the pass only
+ // re-decides the card's words (autoMerge).
+ may, err := t.recheckMayMerge(*k, p)
+ if err != nil {
return err
}
- k.MergeAsked = ""
- if err := t.db.Model(&taskRecord{}).Where("id = ?", k.ID).Update("merge_asked", "").Error; err != nil {
- return err
+ if may {
+ if err := t.withdrawMergeCards(*k); err != nil {
+ return err
+ }
+ k.MergeAsked = ""
+ if err := t.db.Model(&taskRecord{}).Where("id = ?", k.ID).Update("merge_asked", "").Error; err != nil {
+ return err
+ }
}
s := stepRecord{Specialist: wire.SpecialistChecks, Person: p.eng.Person, Round: p.eng.Round, BaseSHA: k.BaseSHA, CandidateSHA: p.candidate, RecheckBy: runner}
k.Stage = wire.StageInReview
diff --git a/internal/equipo/chat/mergeauth.go b/internal/equipo/chat/mergeauth.go
index b9e89840..681e066e 100644
--- a/internal/equipo/chat/mergeauth.go
+++ b/internal/equipo/chat/mergeauth.go
@@ -298,9 +298,14 @@ func (t *txn) auditRow(a mergeAuditRecord) error {
// an attempt for this SHA ended, and only with the primary online: offline,
// nothing is decided and the next sync is the next trigger.
func (t *txn) autoMerge(k *taskRecord, p progress, steps []stepRecord) error {
- if p.merge != nil || p.moved || p.eng == nil || k.MergeAsked == p.candidate {
+ if p.merge != nil || p.moved || p.eng == nil {
return nil
}
+ if k.MergeAsked == p.candidate {
+ // Asked: only the person acts. A Mac re-run that finished since the
+ // card last changed re-decides its words, once.
+ return t.refreshAfterRecheck(*k, p)
+ }
if _, _, verdict, _ := p.judged(); verdict != wire.VerdictApprove {
return nil
}
@@ -321,6 +326,63 @@ func (t *txn) autoMerge(k *taskRecord, p progress, steps []stepRecord) error {
return nil
}
+// recheckMayMerge is merge authority's ruling on a Mac re-run of a SHA:
+// its pass may merge on its own (still through authorizeMerge) only when
+// the SHA was never asked about, the card asked solely because checks
+// could not run (the newest decision or card_refresh row for the SHA
+// fails environment_reason alone), or the person chose Wait for a Mac on
+// it. No row is another reason: it stays asked.
+func (t *txn) recheckMayMerge(k taskRecord, p progress) (bool, error) {
+ if k.MergeAsked == "" || k.MergeAsked != p.candidate {
+ return true, nil
+ }
+ // The SHA's card is the task's newest merge card (one per SHA asked).
+ var card cardRecord
+ if err := t.db.Where("task_id = ? AND kind = ?", k.ID, wire.CardMerge).Order("created_at DESC, rowid DESC").First(&card).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
+ return false, err
+ }
+ if card.State == wire.CardAnswered && card.Choice == wire.ChoiceWaitMac {
+ return true, nil
+ }
+ var a mergeAuditRecord
+ err := t.db.Where("task_id = ? AND candidate_sha = ? AND kind IN ?", k.ID, p.candidate, []string{auditDecision, auditRefresh}).Order("created_at DESC, rowid DESC").First(&a).Error
+ if errors.Is(err, gorm.ErrRecordNotFound) {
+ return false, nil
+ }
+ if err != nil || a.Class != mergegate.ClassAsk {
+ return false, err
+ }
+ var rs []mergegate.Criterion
+ if json.Unmarshal([]byte(a.Reasons), &rs) != nil {
+ return false, nil
+ }
+ failing := 0
+ for _, r := range rs {
+ if !r.OK {
+ if r.Name != mergegate.CritEnvironment {
+ return false, nil
+ }
+ failing++
+ }
+ }
+ return failing > 0, nil
+}
+
+// refreshAfterRecheck re-decides the open card of an asked SHA once a Mac
+// re-run of its checks has finished (a card_refresh: audited, never
+// acted on), the first time after the card last changed.
+func (t *txn) refreshAfterRecheck(k taskRecord, p progress) error {
+ c := p.checks
+ if c == nil || c.RecheckBy == "" || c.State != wire.StepDone || c.FinishedAt == nil {
+ return nil
+ }
+ var stale int64
+ if err := t.db.Model(&cardRecord{}).Where("task_id = ? AND kind = ? AND state = ? AND updated_at < ?", k.ID, wire.CardMerge, wire.CardOpen, *c.FinishedAt).Count(&stale).Error; err != nil || stale == 0 {
+ return err
+ }
+ return t.refreshMergeCards("task_id = ?", k.ID)
+}
+
// mergeByPolicy reports whether a merge step is Equipo's own decision. A
// step from before merge authority without a recorded decider counts as
// Equipo's unless it was labelled without checks (only people merged those).
diff --git a/internal/equipo/chat/store.go b/internal/equipo/chat/store.go
index eb9b2aed..b249c051 100644
--- a/internal/equipo/chat/store.go
+++ b/internal/equipo/chat/store.go
@@ -631,6 +631,10 @@ func maxEvent(tx *gorm.DB) (int64, error) {
// runnerOnline is how long a runner stays online after its last hello.
const runnerOnline = 75 * time.Second
+// RunnerOnline is runnerOnline for the Machines screens, so a machine
+// reads online there exactly when placement counts it online.
+const RunnerOnline = runnerOnline
+
func (s *Store) runnerView(tx *gorm.DB, person string) (wire.Runner, error) {
id, err := s.authority.PrimaryRunner(tx, person)
if err != nil || id == "" {
diff --git a/internal/equipo/chat_draft.go b/internal/equipo/chat_draft.go
new file mode 100644
index 00000000..464cc04a
--- /dev/null
+++ b/internal/equipo/chat_draft.go
@@ -0,0 +1,35 @@
+package equipo
+
+import (
+ "io"
+ "net/http"
+
+ "amadan.net/oficina/equipo/internal/chatmarkdown"
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// chatDraft renders a reply that is still streaming, as far as it has
+// come, with the renderer the finished message uses (chatmarkdown), so
+// the end of a stream changes nothing but the last characters. The page
+// (chat-stream.js) posts the text it has gathered from the deltas; it is
+// rendered and sent back, from this origin only, and nothing is kept.
+func (a *application) chatDraft(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Cache-Control", "no-store")
+ if _, _, ok := sessionContext(r); !ok || r.Header.Get("Sec-Fetch-Site") != "same-origin" {
+ a.failure(w, r, ErrForbidden)
+ return
+ }
+ // A reply is kept to 4*MaxMessageBytes (chat.reply); the form
+ // encoding may triple it.
+ r.Body = http.MaxBytesReader(w, r.Body, 12*wire.MaxMessageBytes+64)
+ if err := r.ParseForm(); err != nil {
+ a.failure(w, r, ErrInvalid)
+ return
+ }
+ text := r.PostForm.Get("text")
+ if len(text) > 4*wire.MaxMessageBytes {
+ text = text[:4*wire.MaxMessageBytes]
+ }
+ w.Header().Set("Content-Type", "text/html; charset=utf-8")
+ _, _ = io.WriteString(w, string(chatmarkdown.RenderDraft(text)))
+}
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index f5966759..faf78953 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -159,6 +159,44 @@ var pageCopy = map[string]string{
"teams.forgotten": "%s forgotten.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
"teams.undo": "Undo", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ // Machines in Settings (Paul, 2026-11-11), accepted by Astra's
+ // delegated copy pass.
+ "machines.lede": "The computers that do your work. A machine is online when its runner is connected to Equipo.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.mine": "Your machines", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.mine_none": "You have no machines yet.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.others": "Other people's machines", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.state.online": "Online", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.state.offline": "Offline", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.state.never": "Never connected", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.state.removing": "Removing", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.state.revoked": "Revoked", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.never_hint": "This machine was added but has never connected. Check that the runner is running on it.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.last_seen": "Last seen %s", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.role.primary": "Main runner", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.role.worker": "Runs checks", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.platform.darwin": "macOS", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.platform.linux": "Linux", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.version": "Version", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.protocol": "Protocol", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.tags": "Tags", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.enrolled": "Added", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.enrolled_by": "Added by", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.not_reported": "Not reported yet", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.revoke_confirm": "Equipo gives this machine no new work and asks it to stop its current work. It removes the machine once it confirms that work has stopped.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.revoke_yes": "Yes, revoke it", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.remove_confirm": "For a lost or compromised machine. Equipo removes its access now. Work may still be running on it. Any step it may have started is blocked from retrying until the task's creator recovers it.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.remove_yes": "Yes, remove it now", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.add": "Add a machine", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.add_hint": "Install the runner on a Mac or a Linux machine, then approve it here.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.empty_title": "No machines yet", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.empty_body": "Equipo does its work on your machines. Add one to get started.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.add_lede": "Install the runner on the machine you want to add, then approve it here.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.step_install": "On that machine, run this in a terminal.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.step_code": "It prints a link and a code. Open the link, or type the code here.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.step_approve": "Check that the label and key fingerprint match the machine, then approve it. You can check its connection below.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.new": "New machines", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "machines.new_none": "Recently approved machines appear here, along with any that have never connected.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+
"account_setup.title": "Connect a model account",
"account_setup.label": "Account label",
"account_setup.runner": "Paired machine",
diff --git a/internal/equipo/handlers.go b/internal/equipo/handlers.go
index a6c7c988..0993fdb7 100644
--- a/internal/equipo/handlers.go
+++ b/internal/equipo/handlers.go
@@ -47,7 +47,11 @@ type pageData struct {
HousekeepingStream bool
Models modelsView
ConnectionsStream bool
- ChatStream bool
+ // Machines is the Machines screens' (machines_view.go);
+ // MachinesStream loads machines.js.
+ Machines machinesView
+ MachinesStream bool
+ ChatStream bool
// ThinkingSet and ThinkingWords are the person's thinking words for
// the thinking line (thinking_words.go).
ThinkingSet, ThinkingWords string
@@ -75,7 +79,6 @@ type pageData struct {
Question TaskQuestion
PairingConfirmation, Origin, UserCode string
Enrolment Runner
- Runners []Runner
Nav []NavItem
Key, Title, EmptyKey, Address, TeamName string
Owner bool
diff --git a/internal/equipo/icons/icons.go b/internal/equipo/icons/icons.go
index ee91a325..06d4af0b 100644
--- a/internal/equipo/icons/icons.go
+++ b/internal/equipo/icons/icons.go
@@ -53,6 +53,9 @@ var icons = map[string]template.HTML{
"external-link": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/></svg>`,
"star": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><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.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"/></svg>`,
"cpu": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><rect width="16" height="16" x="4" y="4" rx="2"/><rect width="6" height="6" x="9" y="9" rx="1"/><path d="M15 2v2"/><path d="M15 20v2"/><path d="M2 15h2"/><path d="M2 9h2"/><path d="M20 15h2"/><path d="M20 9h2"/><path d="M9 2v2"/><path d="M9 20v2"/></svg>`,
+ "monitor": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><path d="M8 21h8"/><path d="M12 17v4"/></svg>`,
+ "laptop": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z"/><path d="M20.054 15.987H3.946"/></svg>`,
+ "server": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><rect width="20" height="8" x="2" y="2" rx="2" ry="2"/><rect width="20" height="8" x="2" y="14" rx="2" ry="2"/><path d="M6 6h.01"/><path d="M6 18h.01"/></svg>`,
"more-horizontal": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg>`,
"chevron-right": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>`,
"chevron-left": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>`,
diff --git a/internal/equipo/mac_view_test.go b/internal/equipo/mac_view_test.go
index c2dcb627..a11f4c73 100644
--- a/internal/equipo/mac_view_test.go
+++ b/internal/equipo/mac_view_test.go
@@ -38,12 +38,13 @@ func TestChecksOutsideTheSandboxAreLabelled(t *testing.T) {
}
}
-// The Connections runner view shows what a Mac said of itself: its
-// platform, where checks run, and each self-probe in words.
+// The Machines details show what a Mac said of itself: its platform,
+// where checks run, and each self-probe in words.
func TestRunnersViewShowsProbes(t *testing.T) {
tainted := time.Now()
- data := pageData{Runners: []Runner{{ID: "r1", Label: "Tito Studio", TaintedAt: &tainted, Report: &setup.RunnerReport{Platform: "darwin/arm64", Sandbox: wire.SandboxNone,
+ records := []machineRecord{{Runner: Runner{ID: "r1", Person: "a@example.com", Label: "Tito Studio", TaintedAt: &tainted, Report: &setup.RunnerReport{Platform: "darwin/arm64", Sandbox: wire.SandboxNone,
Probes: []setup.RunnerProbe{{ID: "P2", Verdict: wire.ProbeFailed, Detail: "allowed: test.keychain; xcodebuild ran in srt"}, {ID: "P7", Verdict: wire.ProbePassed, Detail: "srt 0.0.81"}}}}}}
+ data := pageData{Machines: machinesPage(records, "a@example.com", time.Now(), false, "")}
var buf bytes.Buffer
if err := pages["runners"].ExecuteTemplate(&buf, "content", data); err != nil {
t.Fatal(err)
diff --git a/internal/equipo/machines_view.go b/internal/equipo/machines_view.go
new file mode 100644
index 00000000..8c573055
--- /dev/null
+++ b/internal/equipo/machines_view.go
@@ -0,0 +1,144 @@
+package equipo
+
+import (
+ "fmt"
+ "slices"
+ "strconv"
+ "strings"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/equipo/chat"
+ "amadan.net/oficina/equipo/internal/equipo/setup"
+)
+
+// The Machines screens (Paul, 2026-11-11), in Settings beside
+// Connections and drawn like it: one compact row per machine with its
+// name, its state in words with a dot, its role and its platform; the
+// rest behind a click (the row is a <details>, so it opens without
+// scripts). The person's own machines show; other people's (only an
+// owner sees them) are folded with a count. Revoke and Remove now sit
+// inside the details as quiet buttons, each behind a confirming second
+// click. Add a machine is its own screen: the install line, the code,
+// and the person's new machines until they connect, following the
+// person's event stream. Only presentation lives here: who sees which
+// machine is runnersFor's, approval is the enrolment flow's.
+
+// Machine states, as data-s on the row's state.
+const (
+ machineOnline = "online"
+ machineOffline = "offline"
+ machineNever = "never"
+ machineRemoving = "removing"
+ machineRevoked = "revoked"
+)
+
+// machineNewFor is how long a machine stays on the Add page after it
+// was approved, so the person sees it come online.
+const machineNewFor = 30 * time.Minute
+
+// machinesView is the Machines list and the Add a machine page.
+type machinesView struct {
+ Adding bool
+ // Mine are the person's machines; Others everyone else's an owner
+ // sees, folded.
+ Mine, Others []machineRow
+ // New are the person's machines on the Add page: never connected,
+ // or approved in the last half hour.
+ New []machineRow
+ // Install is the install line, "" when this release has none.
+ Install string
+}
+
+// machineRow is one machine.
+type machineRow struct {
+ ID, Name, Person string
+ // State is one of the machine states; Words says it, Seen when an
+ // offline machine was last seen.
+ State, Words, Seen string
+ // Role and Platform are the row's facts in words; Mark is the icon
+ // in its tile.
+ Role, Platform, Mark string
+ // The details.
+ Raw, Version, Protocol, Tags, Enrolled, EnrolledBy, Fingerprint string
+ Report *setup.RunnerReport
+ Tainted, Removing, Revoked bool
+ Revision int64
+ // Record is the runner itself, for its supervised history.
+ Record Runner
+}
+
+func machinesPage(records []machineRecord, me string, now time.Time, adding bool, install string) machinesView {
+ v := machinesView{Adding: adding, Install: install}
+ for _, r := range records {
+ row := machineRowOf(r, now)
+ switch {
+ case r.Person != me:
+ v.Others = append(v.Others, row)
+ default:
+ v.Mine = append(v.Mine, row)
+ fresh := r.Facts.EnrolledAt != nil && now.Sub(*r.Facts.EnrolledAt) < machineNewFor
+ if adding && !row.Revoked && (row.State == machineNever || fresh) {
+ v.New = append(v.New, row)
+ }
+ }
+ }
+ for _, rows := range [][]machineRow{v.Mine, v.Others, v.New} {
+ slices.SortStableFunc(rows, func(a, b machineRow) int {
+ if c := strings.Compare(strings.ToLower(a.Name), strings.ToLower(b.Name)); c != 0 {
+ return c
+ }
+ return strings.Compare(a.ID, b.ID)
+ })
+ }
+ return v
+}
+
+func machineRowOf(r machineRecord, now time.Time) machineRow {
+ f := r.Facts
+ row := machineRow{ID: r.ID, Name: r.Label, Person: r.Person, Fingerprint: r.MachineKeyHash, Report: r.Report, Tainted: r.TaintedAt != nil, Removing: r.RemovingAt != nil, Revoked: r.RevokedAt != nil, Revision: r.Revision, Record: r.Runner, Mark: "monitor"}
+ if f.Label != "" {
+ row.Name = f.Label
+ }
+ switch {
+ case row.Revoked:
+ row.State = machineRevoked
+ case row.Removing:
+ row.State = machineRemoving
+ case !f.Session:
+ row.State = machineNever
+ case f.Connected && now.Sub(f.SeenAt) < chat.RunnerOnline:
+ row.State = machineOnline
+ default:
+ row.State = machineOffline
+ row.Seen = fmt.Sprintf(copyText("machines.last_seen"), ago(now, f.SeenAt))
+ }
+ row.Words = copyText("machines.state." + row.State)
+ row.Role = copyText("machines.role.primary")
+ if r.Role == setup.RoleWorker {
+ row.Role = copyText("machines.role.worker")
+ }
+ if r.Report != nil {
+ row.Raw = r.Report.Platform
+ os, _, _ := strings.Cut(r.Report.Platform, "/")
+ row.Platform = copyText("machines.platform." + os)
+ if row.Platform == "" {
+ row.Platform = os
+ }
+ switch os {
+ case "darwin":
+ row.Mark = "laptop"
+ case "linux":
+ row.Mark = "server"
+ }
+ }
+ row.Version = f.Versions["runner"]
+ if f.Session {
+ row.Protocol = strconv.Itoa(f.Protocol)
+ }
+ row.Tags = strings.Join(f.Tags, ", ")
+ if f.EnrolledAt != nil {
+ row.Enrolled = f.EnrolledAt.UTC().Format(copyText("runner.requested_format"))
+ row.EnrolledBy = f.EnrolledBy
+ }
+ return row
+}
diff --git a/internal/equipo/machines_view_test.go b/internal/equipo/machines_view_test.go
new file mode 100644
index 00000000..987aafa3
--- /dev/null
+++ b/internal/equipo/machines_view_test.go
@@ -0,0 +1,181 @@
+package equipo
+
+import (
+ "bytes"
+ "regexp"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/equipo/setup"
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// machinesFixture: the person's online Linux primary, their Mac that
+// went quiet, their Mac enrolled at 12:53 UTC that never connected
+// (staging's), a machine being removed, and two of other people's.
+func machinesFixture(now time.Time) []machineRecord {
+ enrolled := time.Date(2026, 11, 11, 12, 53, 0, 0, time.UTC)
+ removing := now
+ return []machineRecord{
+ {Runner: Runner{ID: "r-desk", Person: "me@example.com", Label: "Desk", Role: setup.RolePrimary, Revision: 3, MachineKeyHash: "abc123", Report: &setup.RunnerReport{Platform: "linux/amd64", Sandbox: wire.SandboxBubblewrap}},
+ Facts: machineFacts{Session: true, Connected: true, SeenAt: now.Add(-10 * time.Second), Protocol: 2, Versions: map[string]string{"runner": "v0.9.1"}, Tags: []string{"linux", "go"}, EnrolledAt: &enrolled, EnrolledBy: "me@example.com"}},
+ {Runner: Runner{ID: "r-studio", Person: "me@example.com", Label: "Headless runner", Role: setup.RoleWorker, Revision: 2, Report: &setup.RunnerReport{Platform: "darwin/arm64"}},
+ Facts: machineFacts{Session: true, Connected: true, SeenAt: now.Add(-3 * time.Hour), Protocol: 2, Label: "Tito Studio"}},
+ {Runner: Runner{ID: "r-air", Person: "me@example.com", Label: "Paul's MacBook Air", Role: setup.RoleWorker, Revision: 1},
+ Facts: machineFacts{EnrolledAt: &enrolled, EnrolledBy: "me@example.com"}},
+ {Runner: Runner{ID: "r-old", Person: "me@example.com", Label: "Old box", Role: setup.RoleWorker, Revision: 4, RemovingAt: &removing},
+ Facts: machineFacts{Session: true, SeenAt: now.Add(-time.Minute)}},
+ {Runner: Runner{ID: "r-ana", Person: "ana@example.com", Label: "Ana's desk", Role: setup.RolePrimary, Revision: 1}},
+ {Runner: Runner{ID: "r-bo", Person: "bo@example.com", Label: "Bo's laptop", Role: setup.RolePrimary, Revision: 1}},
+ }
+}
+
+func machinesHTML(t *testing.T, v machinesView) string {
+ t.Helper()
+ var buf bytes.Buffer
+ if err := pages["runners"].ExecuteTemplate(&buf, "content", pageData{Machines: v, Address: "me@example.com"}); err != nil {
+ t.Fatal(err)
+ }
+ return buf.String()
+}
+
+// TestMachinesList: Machines in Settings (Paul, 2026-11-11). The
+// person's own machines are compact rows (name, state, role, platform)
+// whose details open on a click; other people's are folded, closed,
+// with their count; Revoke and Remove now are quiet and ask once more;
+// a machine that never connected says so with what to check.
+func TestMachinesList(t *testing.T) {
+ now := time.Date(2026, 11, 11, 15, 0, 0, 0, time.UTC)
+ v := machinesPage(machinesFixture(now), "me@example.com", now, false, "")
+ if len(v.Mine) != 4 || len(v.Others) != 2 || len(v.New) != 0 {
+ t.Fatalf("mine %d others %d new %d", len(v.Mine), len(v.Others), len(v.New))
+ }
+ state := map[string]string{}
+ for _, m := range append(append([]machineRow{}, v.Mine...), v.Others...) {
+ state[m.ID] = m.State
+ }
+ for id, want := range map[string]string{"r-desk": "online", "r-studio": "offline", "r-air": "never", "r-old": "removing", "r-ana": "never"} {
+ if state[id] != want {
+ t.Fatalf("%s: state %q, want %q", id, state[id], want)
+ }
+ }
+ html := machinesHTML(t, v)
+ row := func(id string) string {
+ t.Helper()
+ m := regexp.MustCompile(`(?s)<details equipo-mach data-machine="` + id + `".*?</summary>`).FindString(html)
+ if m == "" {
+ t.Fatalf("no row %s:\n%s", id, html)
+ }
+ return m
+ }
+ // The row: name, state in words, role, platform; the details only
+ // behind the click.
+ for id, wants := range map[string][]string{
+ "r-desk": {">Desk<", `data-s="online" data-machine-state>Online<`, ">Main runner<", ">Linux<"},
+ "r-studio": {">Tito Studio<", `data-s="offline" data-machine-state>Offline<`, "Last seen 3 h ago", ">Runs checks<", ">macOS<"},
+ "r-air": {">Paul&#39;s MacBook Air<", `data-s="never" data-machine-state>Never connected<`, "data-never-hint>This machine was added but has never connected. Check that the runner is running on it.<"},
+ "r-old": {`data-machine-state>Removing<`},
+ } {
+ r := row(id)
+ for _, want := range wants {
+ if !strings.Contains(r, want) {
+ t.Fatalf("%s row lacks %q: %s", id, want, r)
+ }
+ }
+ if strings.Contains(r, " open") || strings.Contains(r, "Key fingerprint") || strings.Contains(r, "/revoke") {
+ t.Fatalf("%s row shows its details unasked: %s", id, r)
+ }
+ }
+ if strings.Contains(row("r-desk"), "data-never-hint") {
+ t.Fatal("an online machine reads never connected")
+ }
+ // The details.
+ for _, want := range []string{"<dt>Version</dt><dd>v0.9.1</dd>", "<dt>Protocol</dt><dd>2</dd>", "<dt>Tags</dt><dd>linux, go</dd>", "<dt>Added</dt><dd>11 Nov 2026, 12:53 UTC</dd>", "<dt>Added by</dt><dd>me@example.com</dd>", "abc123", `data-sandbox="bubblewrap"`, "Removing: waiting for it to stop its work"} {
+ if !strings.Contains(html, want) {
+ t.Fatalf("details lack %q", want)
+ }
+ }
+ // Quiet destructive actions, each behind a second click, posting the
+ // same forms as ever.
+ for _, want := range []string{
+ `<details equipo-mach-confirm><summary rst-btn data-quiet>Revoke machine</summary>`,
+ `action="/runners/r-desk/revoke"`, `<input type="hidden" name="revision" value="3">`, `data-revoke>Yes, revoke it<`,
+ `<details equipo-mach-confirm><summary rst-btn data-quiet>Remove now</summary>`,
+ `action="/runners/r-desk/remove-now"`, `data-danger data-remove-now>Yes, remove it now<`,
+ } {
+ if !strings.Contains(html, want) {
+ t.Fatalf("actions lack %q", want)
+ }
+ }
+ if strings.Contains(html, `rst-btn="primary"`) && strings.Contains(html, "revoke\" equipo") {
+ t.Fatal("a destructive action is a primary button")
+ }
+ if strings.Contains(regexp.MustCompile(`(?s)data-machine="r-old".*?</details>\n</div>\n</details>`).FindString(html), "/revoke") {
+ t.Fatal("a machine being removed offers Revoke again")
+ }
+ // Other people's machines: folded, closed, counted, each with whose.
+ others := regexp.MustCompile(`<details equipo-mach-others data-other-machines><summary><span>Other people&#39;s machines</span> <span equipo-conn-n>2</span>`)
+ if !others.MatchString(html) || strings.Contains(html, "data-other-machines open") {
+ t.Fatalf("others not folded with a count:\n%s", html)
+ }
+ if !strings.Contains(row("r-ana"), "<span equipo-conn-account>ana@example.com</span>") {
+ t.Fatal("another person's row does not say whose")
+ }
+ if strings.Index(html, "data-my-machines") > strings.Index(html, "data-other-machines") {
+ t.Fatal("other people's machines come before the person's own")
+ }
+ // A member sees only their own: no fold.
+ if html := machinesHTML(t, machinesPage(machinesFixture(now)[:4], "me@example.com", now, false, "")); strings.Contains(html, "data-other-machines") {
+ t.Fatal("a fold with nothing in it")
+ }
+ // No machines: one way forward.
+ if html := machinesHTML(t, machinesPage(nil, "me@example.com", now, false, "")); !strings.Contains(html, `data-empty-state="machines.empty_title"`) || !strings.Contains(html, `href="/conversation/settings/machines/add"`) {
+ t.Fatalf("empty state:\n%s", html)
+ }
+}
+
+// TestMachinesAdd: Add a machine is its own screen: the install line
+// /install.sh answers, the code, and the person's new machines (never
+// connected, or approved in the last half hour) until they connect.
+// With a machine's code it shows that machine and the same approval
+// form as ever.
+func TestMachinesAdd(t *testing.T) {
+ now := time.Date(2026, 11, 11, 13, 0, 0, 0, time.UTC)
+ install := "curl -fsSL https://equipo.example/install.sh | sh"
+ v := machinesPage(machinesFixture(now), "me@example.com", now, true, install)
+ var ids []string
+ for _, m := range v.New {
+ ids = append(ids, m.ID)
+ }
+ if strings.Join(ids, " ") != "r-desk r-air" {
+ t.Fatalf("new machines %v", ids)
+ }
+ html := machinesHTML(t, v)
+ for _, want := range []string{"<code equipo-conn-code data-command data-install>" + install + "</code>", `data-copy="` + install + `"`, `<form method="post" action="/runners/enrol"`, `name="action" value="inspect"`, `name="user_code"`, "data-new-machines", "data-never-hint", `data-src="/conversation/settings/machines/add"`} {
+ if !strings.Contains(html, want) {
+ t.Fatalf("add page lacks %q:\n%s", want, html)
+ }
+ }
+ if strings.Contains(html, "ana@example.com") {
+ t.Fatal("another person's machine on the person's Add page")
+ }
+ if html := machinesHTML(t, machinesPage(nil, "me@example.com", now, true, "")); !strings.Contains(html, "A versioned runner release is not available.") || !strings.Contains(html, "Recently approved machines appear here, along with any that have never connected.") {
+ t.Fatalf("no release, no machines:\n%s", html)
+ }
+ // With a code: the approval card and its form, unchanged fields.
+ var buf bytes.Buffer
+ data := pageData{Machines: v, Address: "me@example.com", UserCode: "ABCDEFGHJK", PairingConfirmation: "conf", Origin: "https://equipo.example", Enrolment: Runner{Label: "Tito Studio", MachineKeyHash: "abc123", RequestedAt: now}}
+ if err := pages["runners"].ExecuteTemplate(&buf, "content", data); err != nil {
+ t.Fatal(err)
+ }
+ card := buf.String()
+ for _, want := range []string{"Add Tito Studio to your team", "abc123", "https://equipo.example", `name="action" value="approve"`, `name="confirmation" value="conf"`, `name="user_code" value="ABCDEFGHJK"`, `rst-btn="primary" type="submit">Approve machine<`} {
+ if !strings.Contains(card, want) {
+ t.Fatalf("approval lacks %q", want)
+ }
+ }
+ if strings.Contains(card, `value="inspect"`) {
+ t.Fatal("the code form beside an approval")
+ }
+}
diff --git a/internal/equipo/render.go b/internal/equipo/render.go
index 9f808a2b..365945f5 100644
--- a/internal/equipo/render.go
+++ b/internal/equipo/render.go
@@ -37,7 +37,7 @@ func init() {
for _, name := range []string{"person_devices", "person_device", "teams", "onboarding", "invite", "playbooks", "playbook_form", "playbook_diff", "specialist_form", "template_library", "template_diff", "conversation", "chat", "thread", "plan", "coordinator", "preferences", "index", "empty", "projects", "project", "project_form", "people", "settings", "specialist", "errors", "signin_page", "form_error", "runners", "tasks", "task", "task_form", "question", "merge", "connections", "recovery", "recovery_form", "rendered_approval", "notebook", "housekeeping", "work_tasks", "work_task", "work_projects", "work_project", "models", "work_needs", "settings_hub", "team"} {
page := template.Must(template.New("layout").
Funcs(ui.Funcs(ui.WithIcons(icons.Icon, icons.Assets))).
- Funcs(template.FuncMap{"chatMarkdown": chatmarkdown.Render, "fileSize": fileSize, "loadingLine": loadingLine, "split": strings.Split, "since": sinceMillis, "elapsed": elapsedText, "short": short, "agoData": agoData, "agoText": agoText, "hostOf": hostOf, "deref": deref, "agoFormats": agoFormats, "projectAllows": library.ProjectAllowed, "asset": assets.Path, "copy": copyText, "taskGroups": func() []string { return []string{"needs-person", "running", "queued", "finished"} },
+ Funcs(template.FuncMap{"chatMarkdown": chatmarkdown.Render, "chatDraft": chatmarkdown.RenderDraft, "fileSize": fileSize, "loadingLine": loadingLine, "split": strings.Split, "since": sinceMillis, "elapsed": elapsedText, "short": short, "agoData": agoData, "agoText": agoText, "hostOf": hostOf, "deref": deref, "agoFormats": agoFormats, "projectAllows": library.ProjectAllowed, "asset": assets.Path, "copy": copyText, "taskGroups": func() []string { return []string{"needs-person", "running", "queued", "finished"} },
"kindKey": func(k ProjectKind) string { return "kind." + string(k) },
"ownerKey": func(k string) string { return "owner." + k },
"roleKey": func(k Role) string { return "role." + string(k) },
diff --git a/internal/equipo/runner_handlers.go b/internal/equipo/runner_handlers.go
index 9edf7427..7d22398b 100644
--- a/internal/equipo/runner_handlers.go
+++ b/internal/equipo/runner_handlers.go
@@ -11,6 +11,7 @@ import (
"amadan.net/oficina/equipo/internal/equipo/team"
"amadan.net/oficina/equipo/internal/runnerproto"
+ "amadan.net/rastrillo/rastrillo"
"amadan.net/rastrillo/rastrillo/auth"
"github.com/go-chi/chi/v5"
)
@@ -140,29 +141,40 @@ func (a *application) exchangeEnrolment(w http.ResponseWriter, r *http.Request)
runnerJSON(w, http.StatusOK, result)
}
+// enrolmentPage is GET /runners/enrol, the address a runner prints
+// (its VerificationURI, which the runner checks, so it stays): with the
+// machine's code it is the Add a machine page showing that machine with
+// its one button (approval is still the confirmed POST below); without,
+// the Machines list.
func (a *application) enrolmentPage(w http.ResponseWriter, r *http.Request) {
+ a.machinesScreen(w, r, r.URL.Query().Get("code") != "")
+}
+
+// machinesList is GET /conversation/settings/machines.
+func (a *application) machinesList(w http.ResponseWriter, r *http.Request) {
+ a.machinesScreen(w, r, false)
+}
+
+// machinesAdd is GET /conversation/settings/machines/add, with ?code=
+// as at /runners/enrol.
+func (a *application) machinesAdd(w http.ResponseWriter, r *http.Request) {
+ a.machinesScreen(w, r, true)
+}
+
+func (a *application) machinesScreen(w http.ResponseWriter, r *http.Request, adding bool) {
w.Header().Set("Cache-Control", "no-store")
w.Header().Set("Referrer-Policy", "no-referrer")
- data, err := a.page(r, "connections")
- if err != nil {
- a.failure(w, r, err)
- return
- }
- data.Title = "runner.title"
- data.Origin = a.origin
id, ok := auth.From(r)
if !ok {
a.failure(w, r, ErrForbidden)
return
}
- data.Runners, err = a.store.runnersFor(r.Context(), Actor{Address: id.Address})
+ data, err := a.machinesData(r, id.Address, adding)
if err != nil {
a.failure(w, r, err)
return
}
- // The link a runner prints carries its code: show that machine with
- // its one button (approval is still the confirmed POST below).
- if code := r.URL.Query().Get("code"); code != "" && len(code) <= 16 {
+ if code := r.URL.Query().Get("code"); adding && code != "" && len(code) <= 16 {
data.Enrolment, err = a.store.approveOrInspect(r.Context(), Actor{Address: id.Address}, code, false)
if err != nil {
a.runnerFormFailure(w, r, err)
@@ -171,8 +183,35 @@ func (a *application) enrolmentPage(w http.ResponseWriter, r *http.Request) {
data.UserCode = code
data.PairingConfirmation = setup.PairingConfirmation(a.store.invitationKey, id.Address, code, a.store.runnerClock.Now())
}
+ render(w, "runners", data)
+}
- a.renderLive(w, r, "runners", data)
+// machinesData is a Machines screen's page: Settings with Machines
+// current, and the machines the person may see.
+func (a *application) machinesData(r *http.Request, address string, adding bool) (pageData, error) {
+ data, err := a.settingsPage(r, "machines", false)
+ if err != nil {
+ return data, err
+ }
+ data.Title = "runner.title"
+ if adding {
+ data.Title = "machines.add"
+ }
+ data.Origin = a.origin
+ records, err := a.store.runnersFor(r.Context(), Actor{Address: address})
+ if err != nil {
+ return data, err
+ }
+ // The install line is the one /install.sh answers, shown only when
+ // that answers (installScript's own conditions).
+ install := ""
+ if instance, err := runnerInstance(a.store.db.G); err == nil && a.installAssets.CachedAvailable() {
+ if _, err := installScriptBody(a.origin, rastrillo.BuildVersion, instance); err == nil {
+ install = "curl -fsSL " + a.origin + "/install.sh | sh"
+ }
+ }
+ data.Machines, data.MachinesStream = machinesPage(records, address, a.store.runnerClock.Now(), adding, install), true
+ return data, nil
}
func (a *application) approveEnrolment(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "no-store")
@@ -195,7 +234,7 @@ func (a *application) approveEnrolment(w http.ResponseWriter, r *http.Request) {
}
}
if r.PostForm.Get("action") == "inspect" {
- data, err := a.page(r, "connections")
+ data, err := a.machinesData(r, id.Address, true)
if err != nil {
a.failure(w, r, err)
return
@@ -205,8 +244,6 @@ func (a *application) approveEnrolment(w http.ResponseWriter, r *http.Request) {
a.runnerFormFailure(w, r, err)
return
}
- data.Title = "runner.title"
- data.Origin = a.origin
data.UserCode = code
data.PairingConfirmation = setup.PairingConfirmation(a.store.invitationKey, id.Address, code, a.store.runnerClock.Now())
render(w, "runners", data)
@@ -220,7 +257,7 @@ func (a *application) approveEnrolment(w http.ResponseWriter, r *http.Request) {
a.runnerFormFailure(w, r, err)
return
}
- http.Redirect(w, r, "/runners/enrol", http.StatusSeeOther)
+ http.Redirect(w, r, "/conversation/settings/machines/add", http.StatusSeeOther)
}
func (a *application) revokeRunner(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, 4096)
@@ -242,7 +279,7 @@ func (a *application) revokeRunner(w http.ResponseWriter, r *http.Request) {
a.failure(w, r, err)
return
}
- http.Redirect(w, r, "/runners/enrol", http.StatusSeeOther)
+ http.Redirect(w, r, "/conversation/settings/machines", http.StatusSeeOther)
}
// removeRunnerNow removes a lost or compromised machine at once.
@@ -266,12 +303,12 @@ func (a *application) removeRunnerNow(w http.ResponseWriter, r *http.Request) {
a.failure(w, r, err)
return
}
- http.Redirect(w, r, "/runners/enrol", http.StatusSeeOther)
+ http.Redirect(w, r, "/conversation/settings/machines", http.StatusSeeOther)
}
func (a *application) runnerFormFailure(w http.ResponseWriter, r *http.Request, err error) {
if errors.Is(err, ErrRunnerNeedsPrimary) {
- renderStatus(w, http.StatusConflict, "form_error", pageData{Nav: Navigation(), Key: "connections", Title: "runner.title", ErrorKey: "runner.needs_primary", Back: "/runners/enrol"})
+ renderStatus(w, http.StatusConflict, "form_error", pageData{Nav: Navigation(), Key: "connections", Title: "runner.title", ErrorKey: "runner.needs_primary", Back: "/conversation/settings/machines/add"})
return
}
if !errors.Is(err, ErrRunnerRateLimited) {
@@ -279,5 +316,5 @@ func (a *application) runnerFormFailure(w http.ResponseWriter, r *http.Request,
return
}
w.Header().Set("Retry-After", "60")
- renderStatus(w, 429, "form_error", pageData{Nav: Navigation(), Key: "connections", Title: "runner.title", ErrorKey: "runner.rate-limited", Back: "/runners/enrol"})
+ renderStatus(w, 429, "form_error", pageData{Nav: Navigation(), Key: "connections", Title: "runner.title", ErrorKey: "runner.rate-limited", Back: "/conversation/settings/machines/add"})
}
diff --git a/internal/equipo/runners.go b/internal/equipo/runners.go
index cdc043fe..da13d81c 100644
--- a/internal/equipo/runners.go
+++ b/internal/equipo/runners.go
@@ -228,8 +228,8 @@ func revokePersonRunners(tx *gorm.DB, person string, now time.Time) error {
return nil
}
-func (s *Store) runnersFor(ctx context.Context, actor Actor) ([]Runner, error) {
- var result []Runner
+func (s *Store) runnersFor(ctx context.Context, actor Actor) ([]machineRecord, error) {
+ var result []machineRecord
err := s.write(ctx, func(tx *gorm.DB) error {
member, err := currentRunnerMember(tx, actor.Address)
if err != nil {
@@ -263,7 +263,11 @@ func (s *Store) runnersFor(ctx context.Context, actor Actor) ([]Runner, error) {
if record.Report, err = runnerReport(tx, record.ID); err != nil {
return storeError(err)
}
- result = append(result, record.Runner)
+ facts, err := machineFactsOf(tx, record.ID)
+ if err != nil {
+ return storeError(err)
+ }
+ result = append(result, machineRecord{Runner: record.Runner, Facts: facts})
}
return nil
})
@@ -273,6 +277,60 @@ func (s *Store) runnersFor(ctx context.Context, actor Actor) ([]Runner, error) {
return result, nil
}
+// machineFacts is what the Machines screens say of a runner beyond its
+// record, read only for runners runnersFor already allowed: its
+// connection (none until its first hello), what its last hello said,
+// and its enrolment's approval.
+type machineFacts struct {
+ // Session: the runner has connected at least once.
+ Session, Connected bool
+ SeenAt time.Time
+ Protocol int
+ Label string
+ Versions map[string]string
+ Tags []string
+ EnrolledAt *time.Time
+ EnrolledBy string
+}
+
+// machineRecord is a runner as the Machines screens list it.
+type machineRecord struct {
+ Runner
+ Facts machineFacts
+}
+
+func machineFactsOf(tx *gorm.DB, id string) (machineFacts, error) {
+ var f machineFacts
+ var sessions []struct {
+ Connected bool
+ SeenAt *time.Time
+ Protocol int
+ Hello string
+ }
+ if err := tx.Raw(`SELECT coalesce(connected, 0) AS connected, seen_at, coalesce(protocol, 1) AS protocol, coalesce(hello, '') AS hello FROM runner_sessions WHERE runner_id = ?`, id).Scan(&sessions).Error; err != nil {
+ return f, err
+ }
+ if len(sessions) == 1 && sessions[0].SeenAt != nil {
+ v := sessions[0]
+ f.Session, f.Connected, f.SeenAt, f.Protocol = true, v.Connected, *v.SeenAt, max(v.Protocol, wire.Protocol1)
+ var h wire.Hello
+ if v.Hello != "" && json.Unmarshal([]byte(v.Hello), &h) == nil {
+ f.Label, f.Versions = h.Label, h.Versions
+ if h.Capabilities != nil && wire.ValidCapabilities(*h.Capabilities) == nil {
+ f.Tags = h.Capabilities.Tags
+ }
+ }
+ }
+ var enrolments []setup.EnrolmentRecord
+ if err := tx.Where("runner_id = ? AND approved_at IS NOT NULL", id).Order("approved_at DESC").Limit(1).Find(&enrolments).Error; err != nil {
+ return f, err
+ }
+ if len(enrolments) == 1 {
+ f.EnrolledAt, f.EnrolledBy = enrolments[0].ApprovedAt, enrolments[0].Person
+ }
+ return f, nil
+}
+
// runnerReport is the runner's newest hello as the Connections view
// shows it: platform, confinement of checks and self-probes, each value
// already checked by the hello's bounds when it was stored.
diff --git a/internal/equipo/settings_hub.go b/internal/equipo/settings_hub.go
index 3bdf0195..fb3e20f1 100644
--- a/internal/equipo/settings_hub.go
+++ b/internal/equipo/settings_hub.go
@@ -44,6 +44,7 @@ type settingsLink struct {
var settingsSections = []settingsLink{
{Key: "thinking", Href: "/conversation/settings/thinking", CopyKey: "thinking.title", Icon: "type"},
{Key: "connections", Href: "/conversation/settings/connections", CopyKey: "settings.connections", Icon: "plug"},
+ {Key: "machines", Href: "/conversation/settings/machines", CopyKey: "runner.title", Icon: "monitor"},
{Key: "housekeeping", Href: "/conversation/settings/housekeeping", CopyKey: "settings.housekeeping", Icon: "list-checks"},
{Key: "notebook", Href: "/conversation/settings/notebook", CopyKey: "settings.notebook_open", Icon: "notebook"},
{Key: "teams", Href: "/teams", CopyKey: "settings.teams_open", Icon: "users"},
diff --git a/internal/equipo/static/chat-stream.js b/internal/equipo/static/chat-stream.js
index d7baa8f1..2b89b135 100644
--- a/internal/equipo/static/chat-stream.js
+++ b/internal/equipo/static/chat-stream.js
@@ -267,39 +267,157 @@
var line = li.querySelector("[equipo-activity-line]");
if (line) line.toggleAttribute("data-leaving", gone);
}
- // The streaming draft, drawn as the committed message will be: one
- // paragraph per blank-line break, new text fading in, nothing redrawn.
+ // ── The streaming draft ────────────────────────────────────────────
+ // The draft is drawn by the renderer the committed reply uses: the
+ // server's (POST /conversation/draft, chatmarkdown.RenderDraft), so a
+ // list is a list as it streams and the end of the stream changes
+ // nothing but the last words. One request at a time per draft, always
+ // with the whole text so far; its answer is drawn at the next frame.
function drawDraft(li, text) {
var body = li.querySelector("[data-stream-text]");
if (!body) return;
- var paras = text.split(/\n\s*\n/).filter(function (p) { return /\S/.test(p); });
- var ps = body.querySelectorAll(":scope > p");
- paras.forEach(function (para, i) {
- var p = ps[i];
- if (!p) {
- p = document.createElement("p");
- p.drawn = "";
- body.append(p);
+ var d = body.draft || (body.draft = { want: "", asked: null, html: null, frame: 0, busy: false });
+ d.want = text;
+ ask(body, d);
+ }
+ function ask(body, d) {
+ if (d.busy || d.want === d.asked || body.draft !== d || !body.isConnected) return;
+ d.asked = d.want;
+ d.busy = true;
+ fetch("/conversation/draft", { method: "POST", credentials: "same-origin", headers: { "Accept": "text/html" }, body: new URLSearchParams({ text: d.asked }) })
+ .then(function (r) { if (!r.ok) throw new Error("draft"); return r.text(); })
+ .then(function (html) {
+ d.busy = false;
+ d.html = html;
+ if (!d.frame) d.frame = requestAnimationFrame(function () { d.frame = 0; paint(body, d); });
+ ask(body, d);
+ }, function () {
+ // The next words ask again, or a second from now; the committed
+ // reply replaces the draft either way.
+ d.busy = false;
+ d.asked = null;
+ setTimeout(function () { ask(body, d); }, 1000);
+ });
+ }
+ // paint draws the latest render over what is on screen, keeping it:
+ // a block that is the same stays as it is, text that grew gets its new
+ // part as a [data-new] span (the words fade in, gently under reduced
+ // motion), and only what changed is replaced. Timed as "equipo-draft".
+ function paint(body, d) {
+ if (body.draft !== d || !body.hasAttribute("data-stream-text") || d.html === null) return;
+ var started = performance.now();
+ var next = document.createElement("template");
+ next.innerHTML = d.html;
+ var caret = body.querySelector("[equipo-stream-caret]");
+ if (caret) caret.remove();
+ patch(body, next.content);
+ if (LOOK.handoff !== "gone") {
+ // The caret or dot ends the last line of text.
+ var end = body;
+ while (end.lastElementChild && /^(P|UL|OL|LI|PRE|CODE|BLOCKQUOTE)$/.test(end.lastElementChild.tagName)) end = end.lastElementChild;
+ if (end !== body) {
+ if (!caret) {
+ caret = document.createElement("span");
+ caret.setAttribute("equipo-stream-caret", LOOK.handoff);
+ caret.setAttribute("aria-hidden", "true");
+ }
+ end.append(caret);
}
- if (para.indexOf(p.drawn) !== 0) {
- p.textContent = para;
- } else if (para.length > p.drawn.length) {
- var add = document.createElement("span");
- add.setAttribute("data-new", "");
- add.textContent = para.slice(p.drawn.length);
- p.append(add);
+ }
+ try { performance.measure("equipo-draft", { start: started }); } catch (_) { /* older browsers */ }
+ scroll();
+ }
+ // Text on screen: plain text and the spans that faded in.
+ function textish(n) { return n instanceof Text || n.tagName === "SPAN" && n.hasAttribute("data-new"); }
+ function fresh(s) {
+ if (!/\S/.test(s)) return new Text(s);
+ var span = document.createElement("span");
+ span.setAttribute("data-new", "");
+ span.textContent = s;
+ return span;
+ }
+ function same(a, b) {
+ if (a.tagName !== b.tagName || a.attributes.length !== b.attributes.length) return false;
+ for (var i = 0; i < b.attributes.length; i++) if (a.getAttribute(b.attributes[i].name) !== b.attributes[i].value) return false;
+ return true;
+ }
+ // common is how much two texts share from the start, never splitting a
+ // surrogate pair.
+ function common(a, b) {
+ var k = 0, n = Math.min(a.length, b.length);
+ while (k < n && a.charCodeAt(k) === b.charCodeAt(k)) k++;
+ if (k > 0 && k < b.length && b.charCodeAt(k - 1) >= 0xD800 && b.charCodeAt(k - 1) < 0xDC00) k--;
+ return k;
+ }
+ // copy brings a piece of the render onto the page; the first seen.n
+ // characters of its text were on screen already and stay still.
+ function copy(w, seen) {
+ if (w instanceof Text) {
+ var out = document.createDocumentFragment(), n = Math.min(seen.n, w.data.length);
+ if (n) out.append(new Text(w.data.slice(0, n)));
+ if (n < w.data.length) out.append(fresh(w.data.slice(n)));
+ seen.n -= n;
+ return out;
+ }
+ var el = document.createElement(w.tagName);
+ for (var i = 0; i < w.attributes.length; i++) el.setAttribute(w.attributes[i].name, w.attributes[i].value);
+ for (var c = w.firstChild; c; c = c.nextSibling) el.append(copy(c, seen));
+ return el;
+ }
+ // patch makes el's children the render's (next), keeping what is on
+ // screen: el's children are walked once, in step with the render's.
+ function patch(el, next) {
+ var at = el.firstChild;
+ // run takes the text on screen from at: its pieces and its words.
+ function run() {
+ var r = { parts: [], text: "" };
+ while (at && textish(at)) {
+ r.parts.push(at);
+ r.text += at.textContent;
+ at = at.nextSibling;
}
- p.drawn = para;
- });
- for (var i = paras.length; i < ps.length; i++) ps[i].remove();
- var caret = body.querySelector("[equipo-stream-caret]");
- if (LOOK.handoff !== "gone" && body.lastElementChild) {
- if (!caret) {
- caret = document.createElement("span");
- caret.setAttribute("equipo-stream-caret", LOOK.handoff);
- caret.setAttribute("aria-hidden", "true");
+ return r;
+ }
+ // left puts back, still, what of a run the render did not take, for
+ // the next piece to take (a link that has just completed, say).
+ function left(r, k) {
+ r.parts.forEach(function (p) { p.remove(); });
+ if (k < r.text.length) {
+ var rest = new Text(r.text.slice(k));
+ el.insertBefore(rest, at);
+ at = rest;
+ }
+ }
+ for (var w = next.firstChild; w; w = w.nextSibling) {
+ if (w instanceof Text) {
+ var r = run(), k = common(r.text, w.data);
+ if (k === r.text.length) {
+ if (k < w.data.length) el.insertBefore(fresh(w.data.slice(k)), at);
+ continue;
+ }
+ // What was drawn changed: what they share stays still.
+ left(r, k);
+ if (k) el.insertBefore(new Text(w.data.slice(0, k)), at);
+ if (k < w.data.length) el.insertBefore(fresh(w.data.slice(k)), at);
+ } else if (at && !textish(at) && same(at, w)) {
+ patch(at, w);
+ at = at.nextSibling;
+ } else {
+ // A new element: the start of its words that were on screen as
+ // plain text in its place (an opener that just closed) stays still.
+ var seen = { n: 0 };
+ if (at && textish(at)) {
+ var t = run();
+ seen.n = common(t.text, w.textContent);
+ left(t, seen.n);
+ }
+ el.insertBefore(copy(w, seen), at);
}
- body.lastElementChild.append(caret);
+ }
+ while (at) {
+ var gone = at;
+ at = at.nextSibling;
+ gone.remove();
}
}
// The committed reply takes over its draft in place: the same element,
@@ -315,6 +433,10 @@
time.textContent = done.textContent;
}
var body = live.querySelector("[equipo-message-body]"), final = server.querySelector("[equipo-message-body]");
+ if (body && body.draft) {
+ cancelAnimationFrame(body.draft.frame);
+ delete body.draft;
+ }
if (body && final) {
Array.from(body.attributes).forEach(function (a) { body.removeAttribute(a.name); });
Array.from(final.attributes).forEach(function (a) { body.setAttribute(a.name, a.value); });
@@ -638,7 +760,10 @@
// The refused attempt's words go; the next attempt's follow.
delete drafts[v.id];
var body = shownDraft && shownDraft.querySelector("[data-stream-text]");
- if (body) body.textContent = "";
+ if (body) {
+ delete body.draft;
+ body.textContent = "";
+ }
}
// Going again on a connection: the status and the card go.
if (heldNow || feed.querySelector('[data-message] [data-waiting-connection]')) refreshSoon();
diff --git a/internal/equipo/static/equipo.css b/internal/equipo/static/equipo.css
index b557db40..a57c99ba 100644
--- a/internal/equipo/static/equipo.css
+++ b/internal/equipo/static/equipo.css
@@ -1440,3 +1440,66 @@ label[equipo-sp-label] { cursor: pointer; }
[equipo-team-facts] { flex-direction: column; }
[equipo-team-facts] > * + *::before { content: none; }
}
+
+/* Machines (Paul, 2026-11-11), in Settings and drawn like Connections:
+ the same list, dots, tiles and quiet actions. A row is a <details>
+ that opens in place for the rest; a machine that never connected is
+ tinted and says what to check. Revoke and Remove now are quiet and
+ ask once more. Hairlines and tints only, never a stripe. */
+[equipo-machines] { container: mach / inline-size; }
+[equipo-mach] + [equipo-mach] { border-block-start: 1px solid var(--rst-line); }
+[equipo-mach-sum] { list-style: none; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: var(--rst-sp-4); align-items: center; padding: var(--rst-sp-4); cursor: pointer; transition: background .15s; }
+[equipo-mach-sum]::-webkit-details-marker { display: none; }
+[equipo-mach-sum]:hover { background: var(--rst-tint-hover, var(--rst-surface-2)); }
+[equipo-mach-sum]:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--rst-focus-edge, var(--rst-accent)); }
+[equipo-mach-sum] > .icon, [equipo-mach-others] > summary > .icon { inline-size: 1rem; block-size: 1rem; margin: 0; color: var(--rst-text-faint, var(--rst-text-muted)); transition: transform .2s var(--equipo-ease, ease); }
+[equipo-mach][open] > [equipo-mach-sum] > .icon, [equipo-mach-others][open] > summary > .icon { transform: rotate(180deg); }
+[equipo-mach-body] { min-inline-size: 0; display: grid; gap: .35rem; }
+[equipo-mach-hint] { font-size: var(--rst-fs-sm); color: var(--rst-text); max-inline-size: 60ch; line-height: 1.45; }
+[equipo-mach][data-state="never"] > [equipo-mach-sum] { background: color-mix(in srgb, var(--rst-tone-warning-bg) 30%, var(--rst-surface)); }
+[equipo-mach][data-state="never"] > [equipo-mach-sum]:hover { background: color-mix(in srgb, var(--rst-tone-warning-bg) 45%, var(--rst-surface)); }
+[equipo-mach][data-new] { animation: equipo-row-in .55s var(--equipo-ease, ease) both, equipo-row-glow 2.4s ease-out .3s backwards; }
+[equipo-conn-state][data-s="online"]::before { background: var(--rst-tone-positive-fg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rst-tone-positive-fg) 18%, transparent); }
+[equipo-conn-state][data-s="never"]::before { background: var(--rst-tone-warning-fg); }
+[equipo-conn-state]:is([data-s="offline"], [data-s="removing"], [data-s="revoked"]) { color: var(--rst-text-muted); font-weight: 400; }
+[equipo-conn-state]:is([data-s="offline"], [data-s="removing"], [data-s="revoked"])::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--rst-line-strong, var(--rst-text-muted)); }
+[equipo-mach-sum] [equipo-pmark]:not([data-s="online"]) { filter: saturate(.35); opacity: .75; }
+[equipo-mach-detail] { display: grid; gap: var(--rst-sp-3); padding: 0 var(--rst-sp-4) var(--rst-sp-4) calc(2 * var(--rst-sp-4) + 2.25rem); font-size: var(--rst-fs-sm); }
+[equipo-mach-facts] { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem var(--rst-sp-5); margin: 0; font-size: var(--rst-fs-sm); }
+[equipo-mach-facts] dt { color: var(--rst-text-muted); }
+[equipo-mach-facts] dd { margin: 0; min-inline-size: 0; overflow-wrap: anywhere; }
+[equipo-mach-key] { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: var(--rst-fs-xs); }
+[equipo-mach-unknown] { color: var(--rst-text-faint, var(--rst-text-muted)); }
+[equipo-mach-note] { margin: 0; color: var(--rst-text-muted); max-inline-size: 62ch; line-height: 1.45; }
+[equipo-mach-sub] { margin: var(--rst-sp-1) 0 0; font-size: var(--rst-fs-sm); font-weight: 600; }
+[equipo-mach-detail] [equipo-probes] { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
+[equipo-probe-verdict] { color: var(--rst-text-muted); }
+[data-verdict="passed"] > [equipo-probe-verdict], [data-verdict="denied"] > [equipo-probe-verdict] { color: var(--rst-tone-positive-fg); }
+[data-verdict="failed"] > [equipo-probe-verdict] { color: var(--rst-tone-negative-fg); }
+[equipo-mach-detail] > p { margin: 0; color: var(--rst-text-muted); }
+[equipo-mach-detail] > pre, [equipo-mach-pre] { margin: 0; font-size: var(--rst-fs-xs); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--rst-text-muted); }
+[equipo-mach-actions] { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-start; gap: var(--rst-sp-2); padding-block-start: var(--rst-sp-3); border-block-start: 1px solid var(--rst-line); }
+[equipo-mach-actions] > [equipo-mach-note] { margin-inline-end: auto; align-self: center; }
+[equipo-mach-confirm] > summary { list-style: none; cursor: pointer; }
+[equipo-mach-confirm] > summary::-webkit-details-marker { display: none; }
+[equipo-mach-confirm] > summary:hover { color: var(--rst-text); }
+[equipo-mach-confirm][open] { flex-basis: 100%; display: grid; justify-items: end; }
+[equipo-mach-confirm][open] > summary { color: var(--rst-text); }
+[equipo-mach-confirm] > div { display: grid; justify-items: end; gap: var(--rst-sp-2); max-inline-size: 30rem; margin-block-start: var(--rst-sp-1); text-align: end; }
+[equipo-mach-confirm] > div > p { margin: 0; color: var(--rst-text-muted); font-size: var(--rst-fs-sm); line-height: 1.45; }
+[equipo-mach-confirm] [data-danger] { color: var(--rst-tone-negative-fg); border-color: color-mix(in srgb, var(--rst-tone-negative-fg) 35%, var(--rst-line)); }
+[equipo-mach-others] { margin: 0 0 var(--rst-sp-5); }
+[equipo-mach-others] > summary { list-style: none; display: inline-flex; align-items: center; gap: var(--rst-sp-2); margin: 0 0 var(--rst-sp-2); padding: .25rem 0; font-weight: 600; cursor: pointer; border-radius: var(--rst-radius-sm, 4px); }
+[equipo-mach-others] > summary::-webkit-details-marker { display: none; }
+[equipo-mach-others] > summary:focus-visible { outline: 2px solid var(--rst-focus-edge, var(--rst-accent)); outline-offset: 2px; }
+[equipo-mach-none] { margin: 0; padding: var(--rst-sp-4); border: 1px dashed var(--rst-line-strong, var(--rst-line)); border-radius: calc(2 * var(--rst-radius)); color: var(--rst-text-muted); font-size: var(--rst-fs-sm); }
+[equipo-machines] [equipo-conn-card] { margin-block-end: var(--rst-sp-6); }
+[equipo-machines] [equipo-conn-card] [equipo-mach-facts] { margin-block-start: var(--rst-sp-2); }
+[equipo-machines] [equipo-conn-add-foot] .icon { margin-inline-end: .35em; }
+@container mach (max-width: 600px) {
+ [equipo-mach-sum] { padding: var(--rst-sp-3); column-gap: var(--rst-sp-3); }
+ [equipo-mach-detail] { padding: 0 var(--rst-sp-3) var(--rst-sp-4); }
+ [equipo-mach-facts] { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
+ [equipo-mach-facts] dd + dt { margin-block-start: var(--rst-sp-2); }
+}
+[equipo-machines] [equipo-conn-add-foot] > a { flex: none; white-space: nowrap; }
diff --git a/internal/equipo/static/machines.js b/internal/equipo/static/machines.js
new file mode 100644
index 00000000..79eced18
--- /dev/null
+++ b/internal/equipo/static/machines.js
@@ -0,0 +1,86 @@
+// The Machines screens follow the person's event stream: nav-stream.js
+// hears a runner come online or go away and says so (equipo:runner);
+// this reads the screen again and swaps its live part in place, so a
+// machine just approved on Add a machine shows connecting without a
+// reload. It also reads it again each minute while it is seen, as a
+// machine whose runner stops answering goes offline with no event.
+// Rows open stay open; nothing is read again while a confirmation is
+// open or a control in the live part has focus. The address read is
+// always the screen's own without its code: a refresh never inspects a
+// machine's code again. Copy puts the install line on the clipboard.
+(function () {
+ "use strict";
+ var root = document.querySelector("[data-machines]");
+ if (!root || !window.fetch || !window.DOMParser) return;
+ var src = root.dataset.src;
+ var inflight = null, again = false;
+
+ function busy(box) {
+ return box.querySelector("[equipo-mach-confirm][open]") || box.contains(document.activeElement) && document.activeElement !== document.body && !document.activeElement.matches("summary");
+ }
+ function load() {
+ var box = root.querySelector("[data-machines-live]");
+ if (!box || busy(box)) return Promise.resolve();
+ return fetch(src, { credentials: "same-origin", headers: { "Accept": "text/html" } })
+ .then(function (r) { if (!r.ok) throw new Error("refresh"); return r.text(); })
+ .then(function (body) {
+ var next = new DOMParser().parseFromString(body, "text/html").querySelector("[data-machines-live]");
+ if (!next || busy(box)) return;
+ var open = {}, seen = {};
+ box.querySelectorAll("[data-machine]").forEach(function (el) {
+ seen[el.dataset.machine] = true;
+ if (el.open) open[el.dataset.machine] = true;
+ });
+ var others = box.querySelector("[data-other-machines]");
+ next.querySelectorAll("[data-machine]").forEach(function (el) {
+ if (open[el.dataset.machine]) el.open = true;
+ // Only what is new arrives with its motion.
+ if (!seen[el.dataset.machine]) el.setAttribute("data-new", "");
+ });
+ var folded = next.querySelector("[data-other-machines]");
+ if (others && folded && others.open) folded.open = true;
+ box.replaceChildren.apply(box, Array.from(next.children));
+ setTimeout(function () {
+ box.querySelectorAll("[data-machine][data-new]").forEach(function (el) { el.removeAttribute("data-new"); });
+ }, 2800);
+ });
+ }
+ function refresh() {
+ if (inflight) { again = true; return; }
+ inflight = load().catch(function () {}).finally(function () {
+ inflight = null;
+ if (again) { again = false; refresh(); }
+ });
+ }
+ document.addEventListener("equipo:runner", function () { setTimeout(refresh, 150); });
+ var ticked = Date.now();
+ function tick() {
+ if (document.hidden) return;
+ ticked = Date.now();
+ refresh();
+ }
+ setInterval(tick, 60000);
+ document.addEventListener("visibilitychange", function () {
+ if (Date.now() - ticked >= 60000) tick();
+ });
+
+ // Copy: the clipboard where it can, the line selected otherwise.
+ root.addEventListener("click", function (event) {
+ var button = event.target.closest("[data-copy]");
+ if (!button) return;
+ var label = button.textContent;
+ function done() {
+ button.textContent = button.dataset.copied;
+ button.setAttribute("data-done", "");
+ setTimeout(function () { button.textContent = label; button.removeAttribute("data-done"); }, 1800);
+ }
+ function select() {
+ var row = button.closest("[equipo-conn-code-row]"), code = row && row.querySelector("code");
+ if (!code) return;
+ getSelection().selectAllChildren(code);
+ try { if (document.execCommand("copy")) done(); } catch (e) { /* selected for the person to copy */ }
+ }
+ if (navigator.clipboard && window.isSecureContext) navigator.clipboard.writeText(button.dataset.copy).then(done, select);
+ else select();
+ });
+})();
diff --git a/internal/equipo/static/nav-stream.js b/internal/equipo/static/nav-stream.js
index af9e6e12..765b7d57 100644
--- a/internal/equipo/static/nav-stream.js
+++ b/internal/equipo/static/nav-stream.js
@@ -149,9 +149,15 @@
seen(event);
work("housekeeping");
});
- ["message", "turn", "runner", "ping"].forEach(function (type) {
+ ["message", "turn", "ping"].forEach(function (type) {
source.addEventListener(type, seen);
});
+ // A runner came online or went away: the Machines screens follow
+ // it from this stream (machines.js) rather than opening their own.
+ source.addEventListener("runner", function (event) {
+ seen(event);
+ document.dispatchEvent(new CustomEvent("equipo:runner"));
+ });
source.onerror = function () {
source.close();
// Past retention (410) or a lost session: render afresh, then
diff --git a/internal/equipo/templates/chrome.html b/internal/equipo/templates/chrome.html
index 67c821b8..4787801b 100644
--- a/internal/equipo/templates/chrome.html
+++ b/internal/equipo/templates/chrome.html
@@ -1,6 +1,6 @@
{{define "rail-brand"}}<span hidden></span>{{end}}
{{define "title"}}{{copy .Title}} · {{copy "brand"}}{{end}}
-{{define "head"}}{{.Live.Head (T "rastrillo.ui.live.paused") (T "rastrillo.ui.live.unconfirmed")}}<link rel="stylesheet" href="{{asset "static/equipo.css"}}"><script defer src="{{asset "static/nav-stream.js"}}"></script><script defer src="{{asset "static/work-stream.js"}}"></script><script defer src="{{asset "static/stardust.js"}}"></script><script defer src="{{asset "static/team-panel.js"}}"></script>{{if .HousekeepingStream}}<script defer src="{{asset "static/housekeeping.js"}}"></script>{{end}}{{if or (eq .Key "thinking") (eq .Key "settings-hub")}}<script defer src="{{asset "static/thinking-preview.js"}}"></script><script defer src="{{asset "static/settings.js"}}"></script>{{end}}{{if .ConnectionsStream}}<script defer src="{{asset "static/vendor/tweetnacl/nacl-fast.js"}}"></script><script defer src="{{asset "static/seal.js"}}"></script><script defer src="{{asset "static/connections.js"}}"></script>{{end}}{{if .ChatStream}}<script defer src="{{asset "static/chat-stream.js"}}"></script><script defer src="{{asset "static/chat-compose.js"}}"></script><script defer src="{{asset "static/ask-target.js"}}"></script>{{if eq .Key "conversation"}}<script defer src="{{asset "static/chat-anchor.js"}}"></script><script defer src="{{asset "static/chat-attach.js"}}"></script>{{end}}{{else if eq .Key "conversation"}}<script defer blocking="render" src="{{asset "static/chat-navigation.js"}}"></script><script defer src="{{asset "static/chat.js"}}"></script><script defer src="{{asset "static/chat-send.js"}}"></script>{{end}}{{end}}
+{{define "head"}}{{.Live.Head (T "rastrillo.ui.live.paused") (T "rastrillo.ui.live.unconfirmed")}}<link rel="stylesheet" href="{{asset "static/equipo.css"}}"><script defer src="{{asset "static/nav-stream.js"}}"></script><script defer src="{{asset "static/work-stream.js"}}"></script><script defer src="{{asset "static/stardust.js"}}"></script><script defer src="{{asset "static/team-panel.js"}}"></script>{{if .HousekeepingStream}}<script defer src="{{asset "static/housekeeping.js"}}"></script>{{end}}{{if or (eq .Key "thinking") (eq .Key "settings-hub")}}<script defer src="{{asset "static/thinking-preview.js"}}"></script><script defer src="{{asset "static/settings.js"}}"></script>{{end}}{{if .ConnectionsStream}}<script defer src="{{asset "static/vendor/tweetnacl/nacl-fast.js"}}"></script><script defer src="{{asset "static/seal.js"}}"></script><script defer src="{{asset "static/connections.js"}}"></script>{{end}}{{if .MachinesStream}}<script defer src="{{asset "static/machines.js"}}"></script>{{end}}{{if .ChatStream}}<script defer src="{{asset "static/chat-stream.js"}}"></script><script defer src="{{asset "static/chat-compose.js"}}"></script><script defer src="{{asset "static/ask-target.js"}}"></script>{{if eq .Key "conversation"}}<script defer src="{{asset "static/chat-anchor.js"}}"></script><script defer src="{{asset "static/chat-attach.js"}}"></script>{{end}}{{else if eq .Key "conversation"}}<script defer blocking="render" src="{{asset "static/chat-navigation.js"}}"></script><script defer src="{{asset "static/chat.js"}}"></script><script defer src="{{asset "static/chat-send.js"}}"></script>{{end}}{{end}}
{{define "up"}}/work{{if .Key}}#nav-{{.Key}}{{end}}{{end}}
{{define "up-label"}}{{.TeamName}}{{end}}
{{define "brand"}}<a rst-shell-brand href="/work">{{icon "users"}}{{.TeamName}}</a>{{end}}
diff --git a/internal/equipo/templates/connections.html b/internal/equipo/templates/connections.html
index 7742d041..f4128e6a 100644
--- a/internal/equipo/templates/connections.html
+++ b/internal/equipo/templates/connections.html
@@ -1,3 +1,3 @@
-{{define "content"}}<h1>{{copy "nav.connections"}}</h1><a rst-btn href="/runners/enrol">{{copy "connections.enrol"}}</a>{{template "region:activity" .}}
+{{define "content"}}<h1>{{copy "nav.connections"}}</h1><a rst-btn href="/conversation/settings/machines/add">{{copy "connections.enrol"}}</a>{{template "region:activity" .}}
<a rst-btn href="/onboarding">{{copy "account_setup.add"}}</a><h2>{{copy "connections.personal"}}</h2>{{range .Choices}}<form equipo-form method="post" action="/projects/{{.Project.ID}}/connections"><h3>{{.Project.Name}}</h3><input type="hidden" name="revision" value="{{.Revision}}">{{range .Options}}<label><input type="checkbox" name="connection_id" value="{{.ID}}"{{if .Enabled}} checked{{end}}>{{copy "connections.enable"}}: {{.Label}}</label>{{end}}<label>{{copy "connections.reason"}}<select rst-input name="mode"><option value="best_fit"{{if eq .Mode "best_fit"}} selected{{end}}>{{copy "connections.best_fit"}}</option><option value="pinned"{{if eq .Mode "pinned"}} selected{{end}}>{{copy "connections.pinned"}}</option><option value="ask"{{if eq .Mode "ask"}} selected{{end}}>{{copy "connections.ask"}}</option></select></label><label>{{copy "connections.pin"}}<select rst-input name="pinned_id"><option value="">{{copy "value.none"}}</option>{{$pinned:=.PinnedID}}{{range .Options}}<option value="{{.ID}}"{{if eq .ID $pinned}} selected{{end}}>{{.Label}}</option>{{end}}</select></label><button rst-btn>{{copy "form.save"}}</button></form>{{end}}{{end}}
{{define "region:activity"}}<div id="activity" {{.Live.Attrs .Topic}}>{{range .Connections}}<section equipo-card><h2>{{.Report.AccountLabel}}</h2><p>{{.Person}}</p><p>{{copy "connections.counted_usage"}}</p>{{if .Report.AllowanceKnown}}<span equipo-value>{{.Report.AllowanceRemaining}}</span>{{else}}<p>{{copy "connections.remaining_unknown"}}</p>{{end}}{{if not .Available}}<p>{{if eq .Report.UnavailableReason "account.sign_in_again"}}{{copy "account.sign_in_again"}}{{else}}{{copy "runner.preflight.unavailable"}}{{end}}</p>{{end}}{{template "trial-label" .Isolation}}{{if eq .Isolation.Mode "owner mode"}}<p>{{copy "connections.owner_mode"}}</p>{{end}}<p>{{copy "connections.versions"}}: {{.Report.Provider}} {{.Report.ProviderVersion}} / {{.Report.LauncherVersion}} / {{.Report.BwrapVersion}}</p>{{if .Unverified}}<p>{{copy "isolation.unverified"}}</p>{{else}}<p>{{copy "isolation.confined"}}</p>{{end}}</section>{{else}}<p data-empty-state="connections.empty">{{copy "connections.empty"}}</p>{{end}}</div>{{end}}
diff --git a/internal/equipo/templates/conversation_card.html b/internal/equipo/templates/conversation_card.html
index 23f67b01..556c8392 100644
--- a/internal/equipo/templates/conversation_card.html
+++ b/internal/equipo/templates/conversation_card.html
@@ -31,7 +31,7 @@
</section>
{{end}}
{{define "conversation-card"}}
-{{if .Thinking}}<div equipo-message="incoming" equipo-thinking data-turn="{{.ID}}" aria-busy="true"><div equipo-message-meta><strong>{{icon "message-circle"}}{{copy "conversation.coordinator"}}</strong></div><div equipo-bubble>{{if .ConnectionLabel}}<span>{{printf (copy "coordinator.waiting_connection_label") .ConnectionLabel}}</span>{{else if .PartialText}}<div equipo-markdown data-stream-text>{{chatMarkdown .PartialText}}</div>{{else}}<span equipo-visually-hidden>{{copy "conversation.thinking"}}</span>{{end}}<span equipo-thinking-dots aria-hidden="true"><i></i><i></i><i></i></span></div></div>{{else}}
+{{if .Thinking}}<div equipo-message="incoming" equipo-thinking data-turn="{{.ID}}" aria-busy="true"><div equipo-message-meta><strong>{{icon "message-circle"}}{{copy "conversation.coordinator"}}</strong></div><div equipo-bubble>{{if .ConnectionLabel}}<span>{{printf (copy "coordinator.waiting_connection_label") .ConnectionLabel}}</span>{{else if .PartialText}}<div equipo-markdown data-stream-text>{{chatDraft .PartialText}}</div>{{else}}<span equipo-visually-hidden>{{copy "conversation.thinking"}}</span>{{end}}<span equipo-thinking-dots aria-hidden="true"><i></i><i></i><i></i></span></div></div>{{else}}
<article {{if eq .Kind "coordinator"}}equipo-system-note{{end}} equipo-card data-card="{{.ID}}"{{if or .NativeQuestion .Question}} equipo-question{{end}}>
{{with .ProjectProposal}}
<h2>{{printf (copy "project_setup.heading") .Name .Repository}}</h2><p>{{.Why}}</p>
diff --git a/internal/equipo/templates/empty.html b/internal/equipo/templates/empty.html
index 31302b9d..3cad0841 100644
--- a/internal/equipo/templates/empty.html
+++ b/internal/equipo/templates/empty.html
@@ -1 +1 @@
-{{define "content"}}<h1>{{copy .Title}}</h1><section equipo-note data-empty-state="{{.EmptyKey}}"><p>{{copy .EmptyKey}}</p></section>{{if eq .Key "connections"}}<p><a href="/runners/enrol">{{copy "runner.title"}}</a></p>{{end}}{{end}}
+{{define "content"}}<h1>{{copy .Title}}</h1><section equipo-note data-empty-state="{{.EmptyKey}}"><p>{{copy .EmptyKey}}</p></section>{{if eq .Key "connections"}}<p><a href="/conversation/settings/machines">{{copy "runner.title"}}</a></p>{{end}}{{end}}
diff --git a/internal/equipo/templates/onboarding.html b/internal/equipo/templates/onboarding.html
index e2b57b04..f2e2ab3c 100644
--- a/internal/equipo/templates/onboarding.html
+++ b/internal/equipo/templates/onboarding.html
@@ -14,7 +14,7 @@
{{if eq .Onboarding.State.CurrentStep "runner"}}
<p>{{copy "onboarding.own_machine"}}</p>
{{if .Onboarding.InstallCommand}}<pre>{{.Onboarding.InstallCommand}}</pre>{{else}}<p>{{copy "runner.install.release"}}</p>{{end}}
-<p>{{copy "onboarding.pair"}}</p><a href="/runners/enrol">{{copy "runner.title"}}</a>
+<p>{{copy "onboarding.pair"}}</p><a href="/conversation/settings/machines/add">{{copy "runner.title"}}</a>
<p>{{copy "onboarding.account_pending"}}</p>
{{end}}
{{if eq .Onboarding.State.CurrentStep "specialists"}}<ul data-onboarding-specialists>{{range .Onboarding.Specialists}}<li><a href="/specialists/{{.Key}}">{{.Name}}</a>{{if .Required}} <span equipo-value>{{copy "specialists.required"}}</span>{{end}}</li>{{end}}</ul>
diff --git a/internal/equipo/templates/runners.html b/internal/equipo/templates/runners.html
index cfad7dc6..06c6a6d4 100644
--- a/internal/equipo/templates/runners.html
+++ b/internal/equipo/templates/runners.html
@@ -1,50 +1,91 @@
+{{define "up"}}{{if .Machines.Adding}}/conversation/settings/machines{{else}}{{template "settings-up" .}}{{end}}{{end}}
+{{define "up-label"}}{{if .Machines.Adding}}{{copy "runner.title"}}{{else}}{{template "settings-up-label" .}}{{end}}{{end}}
+{{define "title"}}{{if .Machines.Adding}}{{copy "machines.add"}}{{else}}{{copy "runner.title"}}{{end}}{{end}}
+{{/* The Machines screens (machines_view.go). A row is a <details>: its
+ summary is the compact line, the rest opens under it. Revoke and
+ Remove now are quiet and each asks once more before it posts the
+ same form as ever. */}}
+{{define "mach-row"}}{{$m := .Row}}<details equipo-mach data-machine="{{$m.ID}}" data-state="{{$m.State}}">
+<summary equipo-mach-sum><span equipo-pmark data-s="{{$m.State}}" aria-hidden="true">{{icon $m.Mark}}</span><span equipo-mach-body><span equipo-conn-head><span equipo-conn-name>{{$m.Name}}</span>{{if .Others}}<span equipo-conn-account>{{$m.Person}}</span>{{end}}</span><span equipo-conn-facts><span equipo-conn-state data-s="{{$m.State}}" data-machine-state>{{$m.Words}}</span>{{with $m.Seen}}<span>{{.}}</span>{{end}}<span data-machine-role>{{$m.Role}}</span>{{with $m.Platform}}<span data-machine-platform>{{.}}</span>{{end}}</span>{{if eq $m.State "never"}}<span equipo-mach-hint data-never-hint>{{copy "machines.never_hint"}}</span>{{end}}</span>{{icon "chevron-down"}}</summary>
+<div equipo-mach-detail>
+<dl equipo-mach-facts>
+<dt>{{copy "runner.platform"}}</dt><dd>{{with $m.Raw}}{{.}}{{else}}<span equipo-mach-unknown>{{copy "machines.not_reported"}}</span>{{end}}</dd>
+<dt>{{copy "machines.version"}}</dt><dd>{{with $m.Version}}{{.}}{{else}}<span equipo-mach-unknown>{{copy "machines.not_reported"}}</span>{{end}}</dd>
+<dt>{{copy "machines.protocol"}}</dt><dd>{{with $m.Protocol}}{{.}}{{else}}<span equipo-mach-unknown>{{copy "machines.not_reported"}}</span>{{end}}</dd>
+{{with $m.Tags}}<dt>{{copy "machines.tags"}}</dt><dd>{{.}}</dd>{{end}}
+{{with $m.Report}}{{with .Sandbox}}<dt>{{copy "runner.checks_run"}}</dt><dd data-sandbox="{{.}}">{{copy (printf "runner.sandbox.%s" .)}}</dd>{{end}}{{end}}
+{{with $m.Enrolled}}<dt>{{copy "machines.enrolled"}}</dt><dd>{{.}}</dd>{{end}}
+{{with $m.EnrolledBy}}<dt>{{copy "machines.enrolled_by"}}</dt><dd>{{.}}</dd>{{end}}
+{{if .Others}}<dt>{{copy "runner.person"}}</dt><dd>{{$m.Person}}</dd>{{end}}
+<dt>{{copy "runner.fingerprint"}}</dt><dd equipo-mach-key>{{$m.Fingerprint}}</dd>
+</dl>
+{{if $m.Tainted}}<p equipo-mach-note data-tainted>{{copy "runner.tainted"}}</p>{{end}}
+{{with $m.Report}}{{if .Probes}}<h4 equipo-mach-sub>{{copy "runner.probes"}}</h4>
+<ul equipo-probes>{{range .Probes}}<li data-probe="{{.ID}}" data-verdict="{{.Verdict}}"><span>{{copy (printf "runner.probe.%s" .ID)}}</span> <span equipo-probe-verdict>{{copy (printf "runner.verdict.%s" .Verdict)}}</span>{{with .Detail}} <span equipo-quiet>{{.}}</span>{{end}}</li>{{end}}</ul>{{end}}{{end}}
+{{with $m.Record}}
+{{if .TrialOwner}}<p>{{copy "trial.history"}}: {{.TrialOwner}} / {{.TrialAt}}</p><pre>{{.TrialVersions}}</pre>{{end}}
+{{end}}
+{{if not $m.Revoked}}<div equipo-mach-actions>{{if $m.Removing}}<p equipo-mach-note>{{copy "runner.removing"}}</p>{{else}}<details equipo-mach-confirm><summary rst-btn data-quiet>{{copy "runner.revoke"}}</summary><div><p>{{copy "machines.revoke_confirm"}}</p><form method="post" action="/runners/{{$m.ID}}/revoke" equipo-inline-form>
+<input type="hidden" name="revision" value="{{$m.Revision}}">
+<button rst-btn type="submit" data-revoke>{{copy "machines.revoke_yes"}}</button>
+</form></div></details>{{end}}<details equipo-mach-confirm><summary rst-btn data-quiet>{{copy "runner.remove_now"}}</summary><div><p>{{copy "machines.remove_confirm"}}</p><form method="post" action="/runners/{{$m.ID}}/remove-now" equipo-inline-form>
+<input type="hidden" name="revision" value="{{$m.Revision}}">
+<button rst-btn type="submit" data-danger data-remove-now>{{copy "machines.remove_yes"}}</button>
+</form></div></details></div>{{end}}
+</div>
+</details>{{end}}
{{define "content"}}
-<h1>{{copy "runner.title"}}</h1>
-<p>{{copy "runner.origin"}} <span>{{.Origin}}</span></p>
-{{if .UserCode}}
-<section equipo-card>
-<h2>{{printf (copy "runner.add_title") .Enrolment.Label}}</h2>
-<dl equipo-metadata>
+<div equipo-settings-layout data-section="machines">
+{{template "settings-nav" .}}
+<section equipo-settings-body equipo-machines data-machines{{if .Machines.Adding}} data-adding data-src="/conversation/settings/machines/add"{{else}} data-src="/conversation/settings/machines"{{end}}>
+{{if .Machines.Adding}}{{template "settings-head" (dict "Title" "machines.add" "Lede" "machines.add_lede")}}
+{{if .UserCode}}<div equipo-conn-card data-approve-machine>
+<div equipo-conn-card-head><span equipo-pmark aria-hidden="true">{{icon "monitor"}}</span><div><h3>{{printf (copy "runner.add_title") .Enrolment.Label}}</h3><p>{{copy "runner.confirm"}}</p></div></div>
+<dl equipo-mach-facts>
<dt>{{copy "runner.label"}}</dt><dd>{{.Enrolment.Label}}</dd>
<dt>{{copy "runner.requested"}}</dt><dd>{{.Enrolment.RequestedAt.UTC.Format (copy "runner.requested_format")}}</dd>
-<dt>{{copy "runner.fingerprint"}}</dt><dd>{{.Enrolment.MachineKeyHash}}</dd>
+<dt>{{copy "runner.fingerprint"}}</dt><dd equipo-mach-key>{{.Enrolment.MachineKeyHash}}</dd>
<dt>{{copy "runner.person"}}</dt><dd>{{.Address}}</dd>
</dl>
-<p>{{copy "runner.confirm"}}</p>
-<form method="post" action="/runners/enrol" equipo-form>
+<p equipo-conn-small>{{copy "runner.origin"}} <span>{{.Origin}}</span></p>
+<div equipo-conn-card-foot><span></span><form method="post" action="/runners/enrol" equipo-inline-form>
<input type="hidden" name="action" value="approve">
<input type="hidden" name="confirmation" value="{{.PairingConfirmation}}">
<input type="hidden" name="user_code" value="{{.UserCode}}">
<button rst-btn="primary" type="submit">{{copy "runner.approve"}}</button>
-</form>
-</section>
-{{else}}
-<form method="post" action="/runners/enrol" equipo-form>
+</form></div>
+</div>
+{{else}}<div equipo-conn-card data-add-machine-steps>
+<ol equipo-conn-steps>
+<li><div><p>{{copy "machines.step_install"}}</p>{{with .Machines.Install}}<div equipo-conn-code-row><code equipo-conn-code data-command data-install>{{.}}</code><button type="button" rst-btn data-copy="{{.}}" data-copied="{{copy "chat.connections.copied"}}">{{copy "chat.connections.copy"}}</button></div>{{else}}<p equipo-conn-small>{{copy "runner.install.release"}}</p>{{end}}</div></li>
+<li><div><p>{{copy "machines.step_code"}}</p><form method="post" action="/runners/enrol" equipo-conn-token autocomplete="off">
<input type="hidden" name="action" value="inspect">
-<label>{{copy "runner.code"}}<input rst-input name="user_code" minlength="10" maxlength="10" autocomplete="off" required></label>
-<button rst-btn="primary" type="submit">{{copy "runner.inspect"}}</button>
-</form>
+<label for="machine-code">{{copy "runner.code"}}</label><span equipo-conn-token-row><input rst-input id="machine-code" name="user_code" minlength="10" maxlength="10" autocomplete="off" autocapitalize="characters" spellcheck="false" required><button rst-btn type="submit">{{copy "runner.inspect"}}</button></span>
+</form></div></li>
+<li><div><p>{{copy "machines.step_approve"}}</p></div></li>
+</ol>
+</div>{{end}}
+<div data-machines-live>
+<section equipo-conn-group data-new-machines><h2>{{copy "machines.new"}}{{if .Machines.New}} <span equipo-conn-n>{{len .Machines.New}}</span>{{end}}</h2>
+{{if .Machines.New}}<div equipo-conn-list>{{range .Machines.New}}{{template "mach-row" (dict "Row" . "Others" false)}}{{end}}</div>{{else}}<p equipo-mach-none>{{copy "machines.new_none"}}</p>{{end}}
+</section>
+</div>
+{{else}}{{template "settings-head" (dict "Title" "runner.title" "Lede" "machines.lede")}}
+<div data-machines-live>
+{{if or .Machines.Mine .Machines.Others}}<section equipo-conn-group data-my-machines><h2>{{copy "machines.mine"}} <span equipo-conn-n>{{len .Machines.Mine}}</span></h2>
+{{if .Machines.Mine}}<div equipo-conn-list>{{range .Machines.Mine}}{{template "mach-row" (dict "Row" . "Others" false)}}{{end}}</div>{{else}}<p equipo-mach-none>{{copy "machines.mine_none"}}</p>{{end}}
+<div equipo-conn-add-foot><a rst-btn href="/conversation/settings/machines/add" data-add-machine>{{icon "plus"}}{{copy "machines.add"}}</a><span>{{copy "machines.add_hint"}}</span></div>
+</section>
+{{with .Machines.Others}}<details equipo-mach-others data-other-machines><summary><span>{{copy "machines.others"}}</span> <span equipo-conn-n>{{len .}}</span>{{icon "chevron-down"}}</summary>
+<div equipo-conn-list>{{range .}}{{template "mach-row" (dict "Row" . "Others" true)}}{{end}}</div>
+</details>{{end}}
+{{else}}<section equipo-conn-empty data-empty-state="machines.empty_title"><p equipo-conn-pair><span equipo-pmark aria-hidden="true">{{icon "laptop"}}</span><span equipo-pmark aria-hidden="true">{{icon "server"}}</span></p>
+<h2>{{copy "machines.empty_title"}}</h2>
+<p>{{copy "machines.empty_body"}}</p>
+<a rst-btn="primary" href="/conversation/settings/machines/add" data-add-machine>{{icon "plus"}}{{copy "machines.add"}}</a>
+</section>{{end}}
+</div>
{{end}}
-<h2>{{copy "runner.enrolled"}}</h2>
-{{range .Runners}}
-<section equipo-card>
-<h3>{{.Label}}</h3>
-<dl equipo-metadata>
-<dt>{{copy "runner.person"}}</dt><dd>{{.Person}}</dd>
-<dt>{{copy "runner.fingerprint"}}</dt><dd>{{.MachineKeyHash}}</dd>
-{{with .Report}}<dt>{{copy "runner.platform"}}</dt><dd>{{.Platform}}</dd>{{with .Sandbox}}<dt>{{copy "runner.checks_run"}}</dt><dd data-sandbox="{{.}}">{{copy (printf "runner.sandbox.%s" .)}}</dd>{{end}}{{end}}
-</dl>
-{{if .TaintedAt}}<p data-tainted>{{copy "runner.tainted"}}</p>{{end}}
-{{with .Report}}{{if .Probes}}<h4>{{copy "runner.probes"}}</h4>
-<ul equipo-probes>{{range .Probes}}<li data-probe="{{.ID}}" data-verdict="{{.Verdict}}"><span>{{copy (printf "runner.probe.%s" .ID)}}</span> <span>{{copy (printf "runner.verdict.%s" .Verdict)}}</span>{{with .Detail}} <span equipo-quiet>{{.}}</span>{{end}}</li>{{end}}</ul>{{end}}{{end}}
-{{if .TrialOwner}}<p>{{copy "trial.history"}}: {{.TrialOwner}} / {{.TrialAt}}</p><pre>{{.TrialVersions}}</pre>{{end}}
-{{if not .RevokedAt}}{{if .RemovingAt}}<p>{{copy "runner.removing"}}</p>{{else}}<form method="post" action="/runners/{{.ID}}/revoke" equipo-form>
-<input type="hidden" name="revision" value="{{.Revision}}">
-<button rst-btn type="submit">{{copy "runner.revoke"}}</button>
-</form>{{end}}<form method="post" action="/runners/{{.ID}}/remove-now" equipo-form>
-<input type="hidden" name="revision" value="{{.Revision}}">
-<button rst-btn type="submit">{{copy "runner.remove_now"}}</button>
-</form>{{end}}
</section>
-{{else}}<p>{{copy "runner.empty"}}</p>{{end}}
+</div>
{{end}}
diff --git a/internal/equipo/templates/settings_nav.html b/internal/equipo/templates/settings_nav.html
index a078a431..cb6d86e1 100644
--- a/internal/equipo/templates/settings_nav.html
+++ b/internal/equipo/templates/settings_nav.html
@@ -1,7 +1,7 @@
{{define "settings-nav"}}<nav equipo-settings-nav aria-label="{{copy "nav.settings"}}"><h2 equipo-settings-nav-title>{{copy "nav.settings"}}</h2><ul role="list">{{range .SettingsNav}}<li><a href="{{.Href}}" equipo-settings-link data-settings-link="{{.Key}}"{{if .Current}} aria-current="page"{{end}}>{{icon .Icon}}<span>{{copy .CopyKey}}</span>{{icon "chevron-right"}}</a></li>{{end}}</ul></nav>{{end}}
{{define "settings-up"}}{{if .Settings.Root}}/work#nav-settings-hub{{else}}/conversation/settings{{end}}{{end}}
{{define "settings-up-label"}}{{if .Settings.Root}}{{.TeamName}}{{else}}{{copy "nav.settings"}}{{end}}{{end}}
-{{define "settings-rail"}}<nav rst-shell-nav equipo-settings-rail{{if .RailArriving}} data-arriving{{end}} aria-label="{{copy "nav.settings"}}"><a href="/conversation" equipo-settings-leave data-settings-leave>{{icon "chevron-left"}}<span>{{copy "brand"}}</span></a><p equipo-nav-group>{{copy "nav.settings"}}</p>{{range .SettingsNav}}<a href="{{.Href}}" data-rail-settings="{{.Key}}"{{if and .Current (not $.Models.Adding)}} aria-current="page"{{end}}>{{icon .Icon}}<span>{{copy .CopyKey}}</span></a>{{if eq .Key "connections"}}<a href="/conversation/settings/connections/add" equipo-settings-sub data-rail-settings="connections-add"{{if $.Models.Adding}} aria-current="page"{{end}}>{{icon "plus"}}<span>{{copy "chat.connections.add"}}</span></a>{{end}}{{end}}</nav>{{end}}
+{{define "settings-rail"}}<nav rst-shell-nav equipo-settings-rail{{if .RailArriving}} data-arriving{{end}} aria-label="{{copy "nav.settings"}}"><a href="/conversation" equipo-settings-leave data-settings-leave>{{icon "chevron-left"}}<span>{{copy "brand"}}</span></a><p equipo-nav-group>{{copy "nav.settings"}}</p>{{range .SettingsNav}}<a href="{{.Href}}" data-rail-settings="{{.Key}}"{{if and .Current (not $.Models.Adding) (not $.Machines.Adding)}} aria-current="page"{{end}}>{{icon .Icon}}<span>{{copy .CopyKey}}</span></a>{{if eq .Key "connections"}}<a href="/conversation/settings/connections/add" equipo-settings-sub data-rail-settings="connections-add"{{if $.Models.Adding}} aria-current="page"{{end}}>{{icon "plus"}}<span>{{copy "chat.connections.add"}}</span></a>{{end}}{{if eq .Key "machines"}}<a href="/conversation/settings/machines/add" equipo-settings-sub data-rail-settings="machines-add"{{if $.Machines.Adding}} aria-current="page"{{end}}>{{icon "plus"}}<span>{{copy "machines.add"}}</span></a>{{end}}{{end}}</nav>{{end}}
{{/* The one Settings page pattern (Paul, 2026-11-11: "make sure all the
settings screens have proper UX and aren't just random forms"):
settings-head is every section's title and its one line; a section
diff --git a/internal/equipo/templates/work_parts.html b/internal/equipo/templates/work_parts.html
index 57d19b95..98d7776e 100644
--- a/internal/equipo/templates/work_parts.html
+++ b/internal/equipo/templates/work_parts.html
@@ -30,7 +30,7 @@
{{if $.Head}}{{template "mono" $t.Mono}}<div equipo-d-title><a href="/tasks/{{$t.ID}}">{{$t.Title}}</a><span equipo-quiet>{{$t.Project}} · {{template "source" $t}}</span></div>{{end}}
<p equipo-d-why>{{.Why}}</p>
<p equipo-d-ask>{{.Ask}}</p>
-<div equipo-d-actions>{{with .Card}}<form method="post" action="/conversation/cards/{{.ID}}/answer"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="from" value="{{$.From}}"><input type="hidden" name="task" value="{{$t.ID}}">{{range $.Task.Decision.Choices}}<button equipo-btn{{if .Primary}} data-primary{{end}} type="submit" name="choice" value="{{.Value}}" data-merge-choice="{{.Value}}">{{.Label}}</button>{{end}}</form>{{end}}{{if .Fold}}<form method="post" action="/tasks/{{$t.ID}}/duplicate"><input type="hidden" name="from" value="{{$.From}}"><input type="hidden" name="of" value="{{$t.Dup.ID}}"><button equipo-btn data-primary type="submit" data-task-duplicate>{{copy "work.decide.fold"}}</button></form>{{end}}{{if .Recover}}<form method="post" action="/conversation/tasks/{{$t.ID}}/recover"><input type="hidden" name="from" value="{{$.From}}"><button equipo-btn data-primary type="submit" data-task-recover>{{copy "work.recover"}}</button></form>{{end}}{{if .Retry}}<form method="post" action="/conversation/tasks/{{$t.ID}}/retry"><input type="hidden" name="from" value="{{$.From}}"><button {{if .Fold}}equipo-link{{else}}equipo-btn data-primary{{end}} type="submit" data-task-retry>{{copy "work.retry"}}</button></form>{{end}}{{if .Talk}}<a equipo-btn href="/conversation">{{copy "work.decide.talk"}}</a>{{end}}{{if .Cancel}}<form method="post" action="/conversation/tasks/{{$t.ID}}/cancel"><input type="hidden" name="from" value="{{$.From}}"><button equipo-link type="submit" data-task-cancel>{{copy "work.decide.cancel"}}</button></form>{{end}}{{with .Hint}}<span equipo-quiet>{{.}}</span>{{end}}<span equipo-d-quiet>{{if .Mac}}<a equipo-link href="/runners/enrol" data-set-up-mac>{{copy "work.decide.mac_set_up"}}</a>{{end}}<a equipo-link href="/conversation?about={{$t.ID}}" data-ask-about>{{copy "work.ask_about"}}</a></span></div>
+<div equipo-d-actions>{{with .Card}}<form method="post" action="/conversation/cards/{{.ID}}/answer"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="from" value="{{$.From}}"><input type="hidden" name="task" value="{{$t.ID}}">{{range $.Task.Decision.Choices}}<button equipo-btn{{if .Primary}} data-primary{{end}} type="submit" name="choice" value="{{.Value}}" data-merge-choice="{{.Value}}">{{.Label}}</button>{{end}}</form>{{end}}{{if .Fold}}<form method="post" action="/tasks/{{$t.ID}}/duplicate"><input type="hidden" name="from" value="{{$.From}}"><input type="hidden" name="of" value="{{$t.Dup.ID}}"><button equipo-btn data-primary type="submit" data-task-duplicate>{{copy "work.decide.fold"}}</button></form>{{end}}{{if .Recover}}<form method="post" action="/conversation/tasks/{{$t.ID}}/recover"><input type="hidden" name="from" value="{{$.From}}"><button equipo-btn data-primary type="submit" data-task-recover>{{copy "work.recover"}}</button></form>{{end}}{{if .Retry}}<form method="post" action="/conversation/tasks/{{$t.ID}}/retry"><input type="hidden" name="from" value="{{$.From}}"><button {{if .Fold}}equipo-link{{else}}equipo-btn data-primary{{end}} type="submit" data-task-retry>{{copy "work.retry"}}</button></form>{{end}}{{if .Talk}}<a equipo-btn href="/conversation">{{copy "work.decide.talk"}}</a>{{end}}{{if .Cancel}}<form method="post" action="/conversation/tasks/{{$t.ID}}/cancel"><input type="hidden" name="from" value="{{$.From}}"><button equipo-link type="submit" data-task-cancel>{{copy "work.decide.cancel"}}</button></form>{{end}}{{with .Hint}}<span equipo-quiet>{{.}}</span>{{end}}<span equipo-d-quiet>{{if .Mac}}<a equipo-link href="/conversation/settings/machines/add" data-set-up-mac>{{copy "work.decide.mac_set_up"}}</a>{{end}}<a equipo-link href="/conversation?about={{$t.ID}}" data-ask-about>{{copy "work.ask_about"}}</a></span></div>
</div>{{end}}{{end}}
{{define "star-toggle"}}{{$p := .P}}<form method="post" action="/projects/{{$p.ID}}/star" equipo-star-form><input type="hidden" name="starred" value="{{if $p.Star.On}}0{{else}}1{{end}}"><input type="hidden" name="from" value="{{.From}}"><button type="submit" equipo-star{{if $p.Star.On}} aria-pressed="true"{{if $p.Star.Auto}} data-auto{{end}}{{else}} aria-pressed="false"{{end}} aria-label="{{$p.Star.Label}}" title="{{$p.Star.Who}}" data-star-toggle>{{icon "star"}}</button></form>{{end}}
{{define "project-facts"}}{{with .StackLine}}<span>{{if $.PhoneStack}}{{icon "phone"}}{{else}}{{icon "code"}}{{end}}{{.}}</span>{{end}}{{with .Repos}}<span data-repos>{{icon "git"}}{{if eq (len .) 1}}{{copy "work.project.one_repo"}}{{else}}{{printf (copy "work.project.repos") (len .)}}{{end}}</span>{{end}}{{with .ChecksLine}}<span data-tone="{{if $.Checks.Here}}positive{{else}}warning{{end}}" data-checks-fact>{{if $.Checks.Here}}{{icon "check-circle"}}{{else}}{{icon "help-circle"}}{{end}}{{.}}</span>{{end}}{{end}}
diff --git a/internal/fakeclaude/fake.go b/internal/fakeclaude/fake.go
index 1c487990..b06c72cd 100644
--- a/internal/fakeclaude/fake.go
+++ b/internal/fakeclaude/fake.go
@@ -11,7 +11,8 @@
// steer it: "sleep:<ms>" pauses mid-reply, "crash" exits mid-turn, "fail"
// ends the turn with an error result, "badinit" reports a native tool in
// system/init, "othersession" answers under another session id, "accents"
-// replies with non-ASCII text, "slowstream" pauses after every chunk,
+// replies with non-ASCII text, "replymd" (or "replymd:long") with a
+// formatted one, "chunks:<n>" streams in n deltas, "slowstream" pauses after every chunk,
// "think" opens with a thinking block, "pause:<ms>" waits before any text, and "tool:<name>[:<arg>]" calls an
// Equipo MCP tool before replying (add_project:<repo>,
// create_project:<namespace>/<name>, ask_person:<question>|<option>...,
@@ -712,6 +713,9 @@ func (f *fake) serve(stdin io.Reader, stdout, stderr io.Writer) int {
if strings.Contains(newest, "accents") {
reply = "Café con ñandú, señor. ☕ Ünïcödé 🎉 works."
}
+ if md, ok := markdownReply(newest); ok {
+ reply = md
+ }
if strings.Contains(prompt, "Conversation so far") {
reply += " I see the earlier conversation."
}
@@ -886,7 +890,7 @@ func (f *fake) serve(stdin io.Reader, stdout, stderr io.Writer) int {
if byToken {
reply += " (signed in by token)"
}
- chunks := split(reply, 3)
+ chunks := split(reply, chunkCount(newest))
for i, chunk := range chunks {
if f.partial {
emit(map[string]any{"type": "stream_event", "session_id": f.session, "parent_tool_use_id": nil, "event": map[string]any{"type": "content_block_delta", "index": 0, "delta": map[string]string{"type": "text_delta", "text": chunk}}, "uuid": fmt.Sprintf("delta-%d-%d", turn, i)})
diff --git a/internal/fakeclaude/markdown.go b/internal/fakeclaude/markdown.go
new file mode 100644
index 00000000..dff66ccc
--- /dev/null
+++ b/internal/fakeclaude/markdown.go
@@ -0,0 +1,44 @@
+package fakeclaude
+
+import (
+ "regexp"
+ "strconv"
+ "strings"
+)
+
+// markdownSample is a coordinator reply in the shape the conversation
+// streams most: a bold opening line, a bold-led bullet list and a
+// numbered list, with a task link and inline code.
+const markdownSample = "**Yes. This is the right shape for it.** The invoice total is counted twice when delivery is added.\n\nTwo people see it:\n\n- **Guest:** sees the total on the basket page.\n- **Customer:** sees it again on the receipt.\n\nWhat I'd do, in [Fix the invoice total](/tasks/tks6kwzzdngr):\n\n1. **Owner of the fix:** Engineering, on the checkout repository.\n2. **One complete change:** the total, the receipt and `go test ./checkout/...` for both.\n3. **Review:** an independent check before it merges."
+
+// markdownWord asks for markdownSample as the reply ("replymd"), or for
+// a long reply of it repeated ("replymd:long").
+var markdownWord = regexp.MustCompile(`\breplymd(:long)?\b`)
+
+func markdownReply(newest string) (string, bool) {
+ m := markdownWord.FindStringSubmatch(newest)
+ if m == nil {
+ return "", false
+ }
+ if m[1] == "" {
+ return markdownSample, true
+ }
+ parts := make([]string, 30)
+ for i := range parts {
+ parts[i] = "## Part " + strconv.Itoa(i+1) + "\n\n" + markdownSample
+ }
+ return strings.Join(parts, "\n\n"), true
+}
+
+// chunksWord streams the reply in that many deltas ("chunks:<n>",
+// three without it).
+var chunksWord = regexp.MustCompile(`\bchunks:([0-9]+)`)
+
+func chunkCount(newest string) int {
+ if m := chunksWord.FindStringSubmatch(newest); m != nil {
+ if n, err := strconv.Atoi(m[1]); err == nil && n > 0 {
+ return n
+ }
+ }
+ return 3
+}
diff --git a/internal/headless/browser_stream_markdown_test.go b/internal/headless/browser_stream_markdown_test.go
new file mode 100644
index 00000000..afed7f2c
--- /dev/null
+++ b/internal/headless/browser_stream_markdown_test.go
@@ -0,0 +1,117 @@
+//go:build browser
+
+package headless
+
+import (
+ "context"
+ "sort"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/browsertest"
+ "amadan.net/rastrillo/rastrillo/harness"
+ "github.com/chromedp/cdproto/cdp"
+ "github.com/chromedp/cdproto/emulation"
+ "github.com/chromedp/cdproto/network"
+ "github.com/chromedp/chromedp"
+)
+
+// A formatted reply is formatted as it streams: its bullets are list
+// items on their own lines, no asterisks show, the new words fade in
+// inside the formatting, and the committed reply is the last streamed
+// 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).
+func TestBrowserDraftStreamsFormatted(t *testing.T) {
+ _, inst, r := localEnv(t)
+ r.start(t)
+ alloc, cancelAlloc := chromedp.NewExecAllocator(context.Background(), append(chromedp.DefaultExecAllocatorOptions[:], chromedp.ExecPath(harness.ChromePath(t)), chromedp.Flag("headless", true), chromedp.NoSandbox)...)
+ defer cancelAlloc()
+ ctx, cancel := chromedp.NewContext(alloc)
+ defer cancel()
+ run := func(actions ...chromedp.Action[chromedp.Void]) {
+ t.Helper()
+ if err := chromedp.Do(ctx, actions...); err != nil {
+ t.Fatal(err)
+ }
+ }
+ check := func(expression, reason string) {
+ t.Helper()
+ if !evaluateIn[bool](t, ctx, expression) {
+ t.Fatalf("%s (recorded: %s)", reason, evaluateIn[string](t, ctx, `JSON.stringify(window.__s ? {last: window.__s.last, stray: window.__s.stray, fade: window.__s.fade, lines: window.__s.lines} : null)`))
+ }
+ }
+ cookie := inst.Cookie()
+ open := func(motion string) {
+ t.Helper()
+ run(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
+ if _, err := cdp.Call(ctx, target, network.SetCookie, network.SetCookieParams{Name: cookie.Name, Value: cookie.Value, URL: inst.URL}); err != nil {
+ return err
+ }
+ _, err := cdp.Call(ctx, target, emulation.SetEmulatedMedia, emulation.SetEmulatedMediaParams{Features: []*emulation.MediaFeature{{Name: "prefers-reduced-motion", Value: motion}}})
+ 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};
+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 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})()`
+ send := func(text string) {
+ t.Helper()
+ check(record, "record")
+ check(`(()=>{document.querySelector('#chat-body').value=`+jsString(text)+`;document.querySelector('#composer').requestSubmit();return true})()`, "send")
+ }
+ committed := func(reason string) {
+ t.Helper()
+ run(browsertest.WaitWithin(`window.__s.done && !!window.__s.el.dataset.message`, 60*time.Second))
+ // 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")
+ check(`!window.__s.same || Math.abs(window.__s.el.querySelector('[equipo-message-body]').getBoundingClientRect().height-window.__s.h)<1`, reason+": the reply changed height when committed")
+ t.Logf("%s: last streamed render equal to the committed reply: %v", reason, evaluateIn[bool](t, ctx, `window.__s.same`))
+ check(`window.__s.stray===null`, reason+": markup characters showed while streaming")
+ }
+ for _, m := range []struct{ motion, fade string }{{"no-preference", "equipo-fade 0.32s"}, {"reduce", "equipo-fade 0.2s"}} {
+ open(m.motion)
+ send("replymd chunks:80 sleep:40 slowstream")
+ // While streaming the bullets are list items on their own lines.
+ run(browsertest.WaitWithin(`!!window.__s.lines`, 30*time.Second))
+ check(`window.__s.lines[1]-window.__s.lines[0]>8 && window.__s.lines[2].startsWith('Guest:') && (window.__s.lines[3].startsWith('Customer:') || 'Customer:'.startsWith(window.__s.lines[3]))`, "the bullets did not stream as list items on their own lines")
+ committed(m.motion)
+ check(`window.__s.fade===`+jsString(m.fade), "the words in a list item did not fade in as "+m.fade)
+ check(`(()=>{const b=window.__s.el.querySelector('[equipo-message-body]');return b.querySelectorAll('ol > li').length===3 && b.querySelectorAll('strong').length===6 && !!b.querySelector('a[href="/tasks/tks6kwzzdngr"]') && !!b.querySelector('li code')})()`, "the committed reply lost its formatting")
+ }
+ // A long reply: about 14 KB in 400 deltas.
+ open("no-preference")
+ send("replymd:long chunks:400 sleep:12 slowstream")
+ committed("long reply")
+ // 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 {
+ 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.
+func evaluateIn[T any](t *testing.T, ctx context.Context, expression string) T {
+ t.Helper()
+ var out T
+ if err := chromedp.Do(ctx, chromedp.Func(func(ctx context.Context, target *chromedp.Target) (err error) {
+ out, err = chromedp.Evaluate[T](expression)(ctx, target)
+ return
+ })); err != nil {
+ t.Fatal(err)
+ }
+ return out
+}
diff --git a/internal/headless/browser_test.go b/internal/headless/browser_test.go
index 0af12971..84238961 100644
--- a/internal/headless/browser_test.go
+++ b/internal/headless/browser_test.go
@@ -51,7 +51,7 @@ func TestBrowserChat(t *testing.T) {
// Multibyte text: every delta lands in the draft, which reaches the
// full reply before the committed message replaces it.
send("accents slowstream sleep:700")
- run(browsertest.Wait(`[...document.querySelectorAll('[data-stream-text]')].some(e=>e.textContent==="Café con ñandú, señor. ☕ Ünïcödé 🎉 works.")`))
+ run(browsertest.Wait(`[...document.querySelectorAll('[data-stream-text]')].some(e=>e.textContent.trim()==="Café con ñandú, señor. ☕ Ünïcödé 🎉 works.")`))
run(browsertest.Wait(`[...document.querySelectorAll('[equipo-markdown]:not([data-stream-text])')].some(e=>e.textContent.includes("🎉 works")) && !document.querySelector('[equipo-thinking]')`))
r.stop(t)
run(browsertest.Wait(`!document.querySelector('[equipo-offline]').hidden`))
diff --git a/internal/plan3test/conversation_draft_test.go b/internal/plan3test/conversation_draft_test.go
new file mode 100644
index 00000000..2fce5fc1
--- /dev/null
+++ b/internal/plan3test/conversation_draft_test.go
@@ -0,0 +1,52 @@
+package plan3test
+
+import (
+ "net/http/httptest"
+ "net/url"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/chatmarkdown"
+)
+
+// A streaming reply is drawn by the server's renderer: the page posts the
+// text so far and gets back RenderDraft's HTML, from this origin, to a
+// member only.
+func TestConversationDraftRendersOnTheServer(t *testing.T) {
+ f := newFixture(t)
+ post := func(cookie bool, site, text string) *httptest.ResponseRecorder {
+ t.Helper()
+ r := httptest.NewRequest("POST", "/conversation/draft", strings.NewReader(url.Values{"text": {text}}.Encode()))
+ r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ r.Header.Set("Origin", origin)
+ if site != "" {
+ r.Header.Set("Sec-Fetch-Site", site)
+ }
+ if cookie {
+ r.AddCookie(f.Cookies[owner.Address])
+ }
+ w := httptest.NewRecorder()
+ f.Handler.ServeHTTP(w, r)
+ return w
+ }
+ text := "**Yes.** Two people see it:\n\n- **Guest:** the basket\n- **Cus"
+ w := post(true, "same-origin", text)
+ if w.Code != 200 || w.Body.String() != string(chatmarkdown.RenderDraft(text)) {
+ t.Fatalf("draft render: %d %q", w.Code, w.Body.String())
+ }
+ if !strings.HasPrefix(w.Header().Get("Content-Type"), "text/html") || w.Header().Get("Cache-Control") != "no-store" {
+ t.Fatal("draft headers", w.Header())
+ }
+ if w := post(true, "cross-site", text); w.Code != 403 {
+ t.Fatal("cross-site draft render", w.Code)
+ }
+ if w := post(true, "", text); w.Code != 403 {
+ t.Fatal("draft render without fetch metadata", w.Code)
+ }
+ if w := post(false, "same-origin", text); w.Code == 200 {
+ t.Fatal("draft render without a session")
+ }
+ if w := post(true, "same-origin", strings.Repeat("a", 300<<10)); w.Code == 200 {
+ t.Fatal("oversized draft rendered")
+ }
+}
diff --git a/internal/thintest/inline_style_test.go b/internal/thintest/inline_style_test.go
index b38448b0..58d784b9 100644
--- a/internal/thintest/inline_style_test.go
+++ b/internal/thintest/inline_style_test.go
@@ -17,7 +17,7 @@ func noInlineStyles(t *testing.T, g *gallery) {
t.Helper()
a := g.a
owner := a.inst.Cookie()
- paths := []string{"/conversation", "/tasks", "/projects", "/needs-you", "/housekeeping", "/conversation/settings", "/conversation/settings/thinking", "/conversation/settings/connections", "/conversation/settings/connections/add", "/conversation/settings/housekeeping", "/conversation/settings/notebook", "/work"}
+ paths := []string{"/conversation", "/tasks", "/projects", "/needs-you", "/housekeeping", "/conversation/settings", "/conversation/settings/thinking", "/conversation/settings/connections", "/conversation/settings/connections/add", "/conversation/settings/machines", "/conversation/settings/machines/add", "/conversation/settings/housekeeping", "/conversation/settings/notebook", "/work"}
for _, id := range []string{g.unchecked, g.stopped, g.noras, g.merging, g.running, g.looking} {
if id != "" {
paths = append(paths, "/tasks/"+id)
diff --git a/internal/thintest/machines_browser_test.go b/internal/thintest/machines_browser_test.go
new file mode 100644
index 00000000..46aaa813
--- /dev/null
+++ b/internal/thintest/machines_browser_test.go
@@ -0,0 +1,55 @@
+//go:build browser
+
+package thintest
+
+import (
+ "strconv"
+ "testing"
+)
+
+// TestBrowserMachines: the Machines screens at 1280 and 390. Nothing is
+// wider than the screen; Other people's machines opens on a click; a
+// row opens for its details; Revoke asks once more before its form
+// shows. On Add a machine, the machine that never connected comes
+// online in place when its runner connects, with no reload (the
+// person's stream through nav-stream.js). Saves the after shots when
+// EQUIPO_BROWSER_ARTIFACTS names a directory.
+func TestBrowserMachines(t *testing.T) {
+ settled := func(p *innerPage) {
+ p.wait(`document.getAnimations().every(a=>a.playState!=='running'||a.effect&&a.effect.getTiming().iterations===Infinity)`, "the page settled")
+ }
+ r := newMachinesRig(t)
+ for i, size := range settingsSizes {
+ w := strconv.FormatInt(size.w, 10)
+ p := openInner(t, r.inst.URL, r.inst.Cookie(), size.w, size.h, size.touch, "light", "no-preference")
+ p.open("/conversation/settings/machines")
+ p.fits("machines")
+ p.check(`!document.querySelector('[data-other-machines]').open && !document.querySelector('[data-other-machines] [data-machine]').checkVisibility()`, "others not folded")
+ p.check(`[...document.querySelectorAll('[data-my-machines] [equipo-mach]')].every(d=>!d.open)`, "a row open unasked")
+ p.check(`getComputedStyle(document.querySelector('[data-state="never"] [data-never-hint]')).display!=='none'`, "the never-connected hint is hidden")
+ settled(p)
+ p.shot("after-machines-" + w)
+ p.check(`(document.querySelector('[data-other-machines] > summary').click(),document.querySelector('[data-other-machines]').open)`, "others do not open")
+ never := `document.querySelector('[data-machine="` + r.never + `"]')`
+ p.check(`(`+never+`.querySelector('summary').click(),`+never+`.open)`, "a row does not open")
+ p.check(`!`+never+`.querySelector('[data-revoke]').checkVisibility()`, "Revoke posts without asking")
+ p.check(`(`+never+`.querySelector('[equipo-mach-confirm] > summary').click(),`+never+`.querySelector('[data-revoke]').checkVisibility())`, "Revoke does not ask")
+ p.fits("machines open")
+ settled(p)
+ p.shot("after-machines-open-" + w)
+ p.open("/conversation/settings/machines/add")
+ p.fits("add a machine")
+ settled(p)
+ p.shot("after-machines-add-" + w)
+ if i == 0 {
+ // The machine comes online on the page, which stays.
+ p.check(never+`.dataset.state==='never'`, "not never connected first")
+ r.dialWorker(r.neverToken, "Paul's MacBook Air", 0)
+ p.wait(never+`&&`+never+`.dataset.state==='online'`, "the new machine online in place")
+ p.stayed("machine online")
+ settled(p)
+ p.shot("after-machines-add-online-" + w)
+ }
+ p.stop()
+ }
+}
diff --git a/internal/thintest/machines_fixture_test.go b/internal/thintest/machines_fixture_test.go
new file mode 100644
index 00000000..39253ebf
--- /dev/null
+++ b/internal/thintest/machines_fixture_test.go
@@ -0,0 +1,39 @@
+package thintest
+
+import (
+ "context"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/equipo"
+)
+
+// machinesRig is the Machines screens' fixture: the owner's primary and
+// a Mac worker, both online; one of the owner's machines enrolled that
+// never connected (staging's Mac at 12:53 UTC); and a member's machine,
+// which only an owner sees, folded.
+type machinesRig struct {
+ *runnersRig
+ worker, never, others string
+ // neverToken is the never-connected machine's credential, so a test
+ // can bring it online.
+ neverToken string
+}
+
+const machinesMember = "ana@example.com"
+
+func newMachinesRig(t *testing.T) *machinesRig {
+ t.Helper()
+ r := newRunnersRig(t)
+ w, _ := r.newWorker("Tito Studio")
+ never := r.inst.EnrolRunner(t)
+ if err := r.inst.Store.SetMember(context.Background(), equipo.Actor{Address: Owner}, machinesMember, equipo.RoleMember, true, 0); err != nil {
+ t.Fatal(err)
+ }
+ other := r.inst.EnrolRunnerFor(t, machinesMember)
+ for id, label := range map[string]string{never.RunnerID: "Paul's MacBook Air", other.RunnerID: "Ana's desk"} {
+ if _, err := r.inst.DB.Writer().Exec("UPDATE runners SET label = ? WHERE id = ?", label, id); err != nil {
+ t.Fatal(err)
+ }
+ }
+ return &machinesRig{runnersRig: r, worker: w.fr.Welcome.RunnerID, never: never.RunnerID, others: other.RunnerID, neverToken: never.Token}
+}
diff --git a/internal/thintest/machines_pages_test.go b/internal/thintest/machines_pages_test.go
new file mode 100644
index 00000000..daa52165
--- /dev/null
+++ b/internal/thintest/machines_pages_test.go
@@ -0,0 +1,74 @@
+package thintest
+
+import (
+ "regexp"
+ "strings"
+ "testing"
+)
+
+// TestPagesMachines: Machines in Settings (Paul, 2026-11-11) on a real
+// instance. The owner's own machines are rows (the online primary and
+// Mac, the Mac that never connected saying what to check); a member's
+// machine is folded under Other people's machines, closed, with its
+// count; the details and the quiet, confirmed Revoke and Remove now are
+// behind a click. The member sees only their own. /runners/enrol, the
+// address a runner prints, still serves the list, and with a code the
+// Add a machine page; Add a machine lists the new machine.
+func TestPagesMachines(t *testing.T) {
+ r := newMachinesRig(t)
+ owner := r.inst.Cookie()
+ row := func(page, id string) string {
+ t.Helper()
+ m := regexp.MustCompile(`(?s)<details equipo-mach data-machine="` + id + `" data-state="([a-z]+)">.*?</summary>`).FindString(page)
+ if m == "" {
+ t.Fatalf("no row %s", id)
+ }
+ return m
+ }
+ for _, path := range []string{"/conversation/settings/machines", "/runners/enrol"} {
+ page := r.get(owner, path, 200)
+ mine, others, ok := strings.Cut(page, "data-other-machines")
+ if !ok || !strings.Contains(mine, "data-my-machines") {
+ t.Fatalf("%s: no folded others after the person's own", path)
+ }
+ if !regexp.MustCompile(`<details equipo-mach-others data-other-machines><summary><span>Other people&#39;s machines</span> <span equipo-conn-n>1</span>`).MatchString(page) {
+ t.Fatalf("%s: others not folded, closed, with a count", path)
+ }
+ for id, state := range map[string]string{r.worker: "online", r.never: "never"} {
+ if got := row(mine, id); !strings.Contains(got, `data-state="`+state+`"`) {
+ t.Fatalf("%s: %s is not %s: %s", path, id, state, got)
+ }
+ }
+ if !strings.Contains(row(mine, r.worker), ">Tito Studio<") || !strings.Contains(row(mine, r.worker), ">Runs checks<") {
+ t.Fatalf("%s: the Mac's row: %s", path, row(mine, r.worker))
+ }
+ never := row(mine, r.never)
+ if !strings.Contains(never, "Never connected") || !strings.Contains(never, "Check that the runner is running on it.") {
+ t.Fatalf("%s: never connected unclear: %s", path, never)
+ }
+ if !strings.Contains(row(others, r.others), "ana@example.com") || strings.Contains(mine, r.others) {
+ t.Fatalf("%s: the member's machine is not folded with whose it is", path)
+ }
+ for _, id := range []string{r.worker, r.never} {
+ if !strings.Contains(page, `<form method="post" action="/runners/`+id+`/revoke" equipo-inline-form>`) || !strings.Contains(page, `action="/runners/`+id+`/remove-now"`) {
+ t.Fatalf("%s: %s has no confirmed Revoke and Remove now", path, id)
+ }
+ }
+ if strings.Count(page, "<details equipo-mach-confirm><summary rst-btn data-quiet>") < 4 {
+ t.Fatalf("%s: destructive actions are not quiet confirmations", path)
+ }
+ }
+ // A member sees only their own machine, and no fold.
+ member := r.get(r.inst.SessionFor(t, machinesMember), "/conversation/settings/machines", 200)
+ if strings.Contains(member, "data-other-machines") || !strings.Contains(member, r.others) || strings.Contains(member, r.never) {
+ t.Fatal("a member's Machines shows other people's machines")
+ }
+ // Add a machine: the code, and the new machine waiting to connect.
+ add := r.get(owner, "/conversation/settings/machines/add", 200)
+ if !strings.Contains(add, "data-add-machine-steps") || !strings.Contains(add, `name="action" value="inspect"`) || !strings.Contains(row(add, r.never), `data-state="never"`) || !strings.Contains(add, `href="/conversation/settings/machines" rel="up"`) {
+ t.Fatal("Add a machine lacks its steps, its new machine or its way back")
+ }
+ if strings.Contains(add, "ana@example.com") {
+ t.Fatal("another person's machine on Add a machine")
+ }
+}
diff --git a/internal/thintest/macrecheck_contract_test.go b/internal/thintest/macrecheck_contract_test.go
index 19f575e0..666f63bc 100644
--- a/internal/thintest/macrecheck_contract_test.go
+++ b/internal/thintest/macrecheck_contract_test.go
@@ -108,7 +108,7 @@ func TestContractMacRecheckOnEnrol(t *testing.T) {
// chose Merge (without checks, even back at Ready after the hub refused
// it) and ones whose branch moved off the
// candidate, and re-runs only the one still waiting (left with its card
-// open, which the run withdraws).
+// open, which stays open: it asked for more than checks alone).
func TestContractMacRecheckOnlyWaiting(t *testing.T) {
r := newRunnersRigAt(t, wire.ProtocolMergeFacts)
waiting, sha, open := r.waitingForMac("Still waiting")
@@ -164,7 +164,13 @@ func TestContractMacRecheckOnlyWaiting(t *testing.T) {
t.Fatalf("checks of %s re-ran: %+v", id, runs)
}
}
- r.wait("card withdrawn", func(c *Conversation) bool { return c.Cards[open.ID].State == wire.CardResolved })
+ // Merge authority's ruling: its card asked for a reason other than
+ // checks alone and nobody chose Wait, so the SHA stays asked and the
+ // card stays open while the checks run again.
+ time.Sleep(200 * time.Millisecond)
+ if c := r.cardOf(waiting); c.ID != open.ID || c.State != wire.CardOpen {
+ t.Fatalf("card after the re-run started %+v", c)
+ }
}
// The run follows the usual paths: ending not run again on the Mac
diff --git a/internal/thintest/macrecheck_mergeauth_contract_test.go b/internal/thintest/macrecheck_mergeauth_contract_test.go
index 097f1d23..4c73c0fd 100644
--- a/internal/thintest/macrecheck_mergeauth_contract_test.go
+++ b/internal/thintest/macrecheck_mergeauth_contract_test.go
@@ -41,57 +41,89 @@ func (r *runnersRig) recheckPasses(task, sha, reported string) {
w.send(wire.FrameStep, pass)
}
-// TestContractMacRecheckMergeAuthority: a Mac re-run that passes on the
-// exact candidate counts as that SHA's checks, and the merge it allows
-// still goes through authorizeMerge: a routine change merges on its own
-// (Equipo's decision, confirmed again at the hub request); a sensitive
-// change asks; a held one, or one whose main ships, asks; a pass on
-// another SHA counts for nothing.
+// refreshes counts the task's card_refresh audit rows.
+func (r *runnersRig) refreshes(task string) int {
+ r.t.Helper()
+ var n int
+ if err := r.inst.DB.Writer().QueryRow("SELECT count(*) FROM chat_merge_audit WHERE task_id = ? AND kind = 'card_refresh'", task).Scan(&n); err != nil {
+ r.t.Fatal(err)
+ }
+ return n
+}
+
+// TestContractMacRecheckMergeAuthority: merge authority's ruling on a Mac
+// re-run that passes on the exact candidate. It merges on its own (still
+// through authorizeMerge, its request confirmed again) only when the
+// person chose Wait for a Mac, or the card asked solely because checks
+// could not run. For any other reason (sensitive, held, main ships, no
+// recorded reason) the SHA stays asked: no merge, the same card open,
+// re-decided once as a card_refresh. A pass on another SHA counts for
+// nothing.
func TestContractMacRecheckMergeAuthority(t *testing.T) {
- t.Run("routine", func(t *testing.T) {
- r := newRunnersRigAt(t, wire.ProtocolMergeFacts)
- project := r.project()
- // It asks first only because nobody has said whether main ships;
- // the owner then says it doesn't, and Waits for a Mac.
- task, sha, _ := r.waitingForMacMeasured("Swipe back")
- r.shipsNo(project)
- card := r.cardOf(task)
- if _, err := r.client.Answer(r.ctx, card.ID, wire.ChoiceWaitMac, card.Revision); err != nil {
- t.Fatal(err)
- }
- r.recheckPasses(task, sha, sha)
+ merges := func(t *testing.T, r *runnersRig, task, sha string) {
+ t.Helper()
_, body := r.expect(wire.FrameDispatch)
m := body.(*wire.DispatchCommand)
if m.Specialist != wire.SpecialistMerge || m.CandidateSHA != sha {
t.Fatalf("merge dispatch %+v", m)
}
- if refused := r.lease(r.runner, "routine-confirm", wire.LeaseCheck{StepID: m.StepID, Attempt: m.Attempt, Purpose: wire.LeasePurposeMerge}); refused != "" {
+ if refused := r.lease(r.runner, task+"-confirm", wire.LeaseCheck{StepID: m.StepID, Attempt: m.Attempt, Purpose: wire.LeasePurposeMerge}); refused != "" {
t.Fatalf("the request refused %q", refused)
}
if k, _ := r.client.Task(r.ctx, task); k.MergeDecision == nil || k.MergeDecision.Class != "act" || k.MergeDecision.DecidedBy != "policy" {
t.Fatalf("decision %+v", k.MergeDecision)
}
- })
- asks := func(t *testing.T, r *runnersRig, task, sha, want string) {
+ }
+ staysAsked := func(t *testing.T, r *runnersRig, task, sha string, card wire.Card, want string) {
t.Helper()
+ r.wait("back at Ready", func(c *Conversation) bool { return c.Tasks[task].Stage == wire.StageReadyToMerge })
r.primary.none(wire.FrameDispatch, 300*time.Millisecond)
- card := r.mergeCardsWait(task)
- if !strings.Contains(card.Question, want) {
- t.Fatalf("card %q, want %q", card.Question, want)
+ now := r.cardOf(task)
+ if now.ID != card.ID || now.State != wire.CardOpen || now.Revision <= card.Revision || !strings.Contains(now.Question, want) {
+ t.Fatalf("card after the pass %+v, want %q (was %+v)", now, want, card)
}
- if k, _ := r.client.Task(r.ctx, task); k.Stage != wire.StageReadyToMerge || k.CandidateSHA != sha || k.MergeDecision == nil || k.MergeDecision.Class != "ask" {
+ if r.refreshes(task) < 1 {
+ t.Fatal("no card_refresh row")
+ }
+ if k, _ := r.client.Task(r.ctx, task); k.CandidateSHA != sha || k.MergeDecision == nil || k.MergeDecision.Class != "ask" {
t.Fatalf("after the pass %+v", k.MergeDecision)
}
}
- t.Run("sensitive", func(t *testing.T) {
+ t.Run("wait chosen", func(t *testing.T) {
r := newRunnersRigAt(t, wire.ProtocolMergeFacts)
- r.shipsNo(r.project())
- task, sha, card := r.waitingForMacMeasured("Pay wall", "ios/Woodstar/StoreKit/Purchase.swift")
+ project := r.project()
+ // It asks first only because nobody has said whether main ships;
+ // the owner then says it doesn't, and Waits for a Mac.
+ task, sha, _ := r.waitingForMacMeasured("Swipe back")
+ r.shipsNo(project)
+ card := r.cardOf(task)
if _, err := r.client.Answer(r.ctx, card.ID, wire.ChoiceWaitMac, card.Revision); err != nil {
t.Fatal(err)
}
r.recheckPasses(task, sha, sha)
- asks(t, r, task, sha, "it touches payments")
+ merges(t, r, task, sha)
+ })
+ t.Run("checks only", func(t *testing.T) {
+ r := newRunnersRigAt(t, wire.ProtocolMergeFacts)
+ project := r.project()
+ task, sha, _ := r.waitingForMacMeasured("Swipe up")
+ r.shipsNo(project)
+ // The gate never asks a needs_macos change solely because its checks
+ // could not run (that is an environment reason it accepts), so the
+ // card's recorded reason is seeded: its newest decision fails only
+ // environment_reason.
+ if _, err := r.inst.DB.Writer().Exec(`INSERT INTO chat_merge_audit (id, project_id, task_id, kind, at, candidate_sha, merge_sha, class, stance, decided_by, reasons, inputs, created_at) VALUES ('ma_seed', ?, ?, 'decision', 'dispatch', ?, '', 'ask', 'wait', '', '[{"name":"approved_exact_sha","ok":true},{"name":"environment_reason","ok":false,"value":"checks_timeout"}]', '{}', ?)`, project, task, sha, time.Now().UTC()); err != nil {
+ t.Fatal(err)
+ }
+ r.recheckPasses(task, sha, sha)
+ merges(t, r, task, sha)
+ })
+ t.Run("sensitive", func(t *testing.T) {
+ r := newRunnersRigAt(t, wire.ProtocolMergeFacts)
+ r.shipsNo(r.project())
+ task, sha, card := r.waitingForMacMeasured("Pay wall", "ios/Woodstar/StoreKit/Purchase.swift")
+ r.recheckPasses(task, sha, sha)
+ staysAsked(t, r, task, sha, card, "it touches payments")
})
t.Run("held", func(t *testing.T) {
r := newRunnersRigAt(t, wire.ProtocolMergeFacts)
@@ -101,8 +133,9 @@ func TestContractMacRecheckMergeAuthority(t *testing.T) {
t.Fatalf("hold %+v", res)
}
r.shipsNo(project)
+ card := r.cardOf(task)
r.recheckPasses(task, sha, sha)
- asks(t, r, task, sha, "the person wants to try it on a device first")
+ staysAsked(t, r, task, sha, card, "the person wants to try it on a device first")
})
t.Run("ships", func(t *testing.T) {
r := newRunnersRigAt(t, wire.ProtocolMergeFacts)
@@ -111,15 +144,36 @@ func TestContractMacRecheckMergeAuthority(t *testing.T) {
if _, err := r.client.SetMergePolicy(r.ctx, project, wire.SetMergePolicy{Mode: p.Mode, MaxLines: p.MaxLines, MaxFiles: p.MaxFiles, MainShips: "yes", ExtraSensitive: p.ExtraSensitive, Revision: p.Revision}); err != nil {
t.Fatal(err)
}
- task, sha, _ := r.waitingForMacMeasured("Tab bar")
+ task, sha, card := r.waitingForMacMeasured("Tab bar")
r.recheckPasses(task, sha, sha)
- asks(t, r, task, sha, "main ships to users")
+ staysAsked(t, r, task, sha, card, "main ships to users")
+ })
+ t.Run("missing reason", func(t *testing.T) {
+ r := newRunnersRigAt(t, wire.ProtocolMergeFacts)
+ project := r.project()
+ task, sha, _ := r.waitingForMacMeasured("Old card")
+ r.shipsNo(project)
+ // A card from before merge authority recorded no reason.
+ if _, err := r.inst.DB.Writer().Exec("DELETE FROM chat_merge_audit WHERE task_id = ?", task); err != nil {
+ t.Fatal(err)
+ }
+ card := r.cardOf(task)
+ r.recheckPasses(task, sha, sha)
+ r.wait("back at Ready", func(c *Conversation) bool { return c.Tasks[task].Stage == wire.StageReadyToMerge })
+ r.primary.none(wire.FrameDispatch, 300*time.Millisecond)
+ if now := r.cardOf(task); now.ID != card.ID || now.State != wire.CardOpen {
+ t.Fatalf("card after the pass %+v", now)
+ }
})
t.Run("other SHA", func(t *testing.T) {
r := newRunnersRigAt(t, wire.ProtocolMergeFacts)
project := r.project()
task, sha, _ := r.waitingForMacMeasured("Scroll")
r.shipsNo(project)
+ card := r.cardOf(task)
+ if _, err := r.client.Answer(r.ctx, card.ID, wire.ChoiceWaitMac, card.Revision); err != nil {
+ t.Fatal(err)
+ }
r.recheckPasses(task, sha, strings.Repeat("0", 40))
r.primary.none(wire.FrameDispatch, 300*time.Millisecond)
if k, _ := r.client.Task(r.ctx, task); k.Stage == wire.StageMerging || k.Checks == wire.ChecksPassed {
diff --git a/internal/thintest/projects_pages_test.go b/internal/thintest/projects_pages_test.go
index 1d00c13c..32069b3c 100644
--- a/internal/thintest/projects_pages_test.go
+++ b/internal/thintest/projects_pages_test.go
@@ -253,7 +253,7 @@ func TestPagesTaskDecisionsSayWhy(t *testing.T) {
for _, want := range []string{"Review approved. Checks need a Mac, and no Mac is set up to run them.", "Merge without checks?",
`data-merge-choice="merge">Merge now</button>`, `data-merge-choice="wait_mac">Wait for a Mac</button>`,
"Merge now merges it without checks. Wait for a Mac keeps it ready. Once a Mac is set up, checks run, and if they pass, Equipo merges it by itself.",
- `<a equipo-link href="/runners/enrol" data-set-up-mac>Set up a Mac</a>`, `href="/conversation?about=` + g.unchecked + `" data-ask-about>Ask about this</a>`} {
+ `<a equipo-link href="/conversation/settings/machines/add" data-set-up-mac>Set up a Mac</a>`, `href="/conversation?about=` + g.unchecked + `" data-ask-about>Ask about this</a>`} {
if !strings.Contains(card, want) {
t.Fatalf("Mac decision lacks %q:\n%s", want, card)
}
diff --git a/internal/thintest/settings_pages_test.go b/internal/thintest/settings_pages_test.go
index 9931864d..27a3166c 100644
--- a/internal/thintest/settings_pages_test.go
+++ b/internal/thintest/settings_pages_test.go
@@ -13,11 +13,13 @@ import (
func TestPagesSettingsSections(t *testing.T) {
r := newToolRig(t)
owner := r.inst.Cookie()
- links := []string{`data-settings-link="thinking"`, `data-settings-link="connections"`, `data-settings-link="housekeeping"`, `data-settings-link="notebook"`, `data-settings-link="teams"`}
+ links := []string{`data-settings-link="thinking"`, `data-settings-link="connections"`, `data-settings-link="machines"`, `data-settings-link="housekeeping"`, `data-settings-link="notebook"`, `data-settings-link="teams"`}
for _, tc := range []struct{ path, current, want string }{
{"/conversation/settings", "thinking", `data-root`},
{"/conversation/settings/thinking", "thinking", `data-thinking-words`},
{"/conversation/settings/connections", "connections", `data-connections`},
+ {"/conversation/settings/machines", "machines", `data-machines`},
+ {"/runners/enrol", "machines", `data-my-machines`},
{"/conversation/settings/housekeeping", "housekeeping", `data-hk-settings`},
{"/conversation/settings/notebook", "notebook", `data-notebook-reset`},
} {
diff --git a/internal/thintest/settings_rail_pages_test.go b/internal/thintest/settings_rail_pages_test.go
index eee89860..e2e1c850 100644
--- a/internal/thintest/settings_rail_pages_test.go
+++ b/internal/thintest/settings_rail_pages_test.go
@@ -46,6 +46,8 @@ func TestPagesSettingsRail(t *testing.T) {
"/conversation/settings/thinking": "thinking",
"/conversation/settings/connections": "connections",
"/conversation/settings/connections/add": "connections-add",
+ "/conversation/settings/machines": "machines",
+ "/conversation/settings/machines/add": "machines-add",
"/conversation/settings/housekeeping": "housekeeping",
"/conversation/settings/notebook": "notebook",
} {
@@ -53,7 +55,7 @@ func TestPagesSettingsRail(t *testing.T) {
if nav == "" {
t.Fatalf("%s: no Settings nav in the rail", path)
}
- for _, want := range []string{`<a href="/conversation" equipo-settings-leave data-settings-leave>`, ">Equipo</span>", `data-rail-settings="thinking"`, `data-rail-settings="connections"`, `href="/conversation/settings/connections/add" equipo-settings-sub data-rail-settings="connections-add"`, `data-rail-settings="housekeeping"`, `data-rail-settings="notebook"`, `data-rail-settings="teams"`} {
+ for _, want := range []string{`<a href="/conversation" equipo-settings-leave data-settings-leave>`, ">Equipo</span>", `data-rail-settings="thinking"`, `data-rail-settings="connections"`, `href="/conversation/settings/connections/add" equipo-settings-sub data-rail-settings="connections-add"`, `data-rail-settings="machines"`, `data-rail-settings="housekeeping"`, `data-rail-settings="notebook"`, `data-rail-settings="teams"`} {
if !strings.Contains(nav, want) {
t.Fatalf("%s: the rail's Settings nav lacks %s", path, want)
}
diff --git a/internal/thintest/settings_ux_browser_test.go b/internal/thintest/settings_ux_browser_test.go
index be9ba845..32a28a16 100644
--- a/internal/thintest/settings_ux_browser_test.go
+++ b/internal/thintest/settings_ux_browser_test.go
@@ -261,7 +261,7 @@ func TestBrowserSettingsShots(t *testing.T) {
for _, size := range settingsSizes {
p := openInner(t, r.inst.URL, r.inst.Cookie(), size.w, size.h, size.touch, "light", "no-preference")
var width float64
- for _, s := range []struct{ name, path string }{{"thinking", "/conversation/settings/thinking"}, {"connections", "/conversation/settings/connections"}, {"connections-add", "/conversation/settings/connections/add"}, {"housekeeping", "/conversation/settings/housekeeping"}, {"notebook", "/conversation/settings/notebook"}, {"teams", "/teams"}} {
+ for _, s := range []struct{ name, path string }{{"thinking", "/conversation/settings/thinking"}, {"connections", "/conversation/settings/connections"}, {"connections-add", "/conversation/settings/connections/add"}, {"machines", "/conversation/settings/machines"}, {"machines-add", "/conversation/settings/machines/add"}, {"housekeeping", "/conversation/settings/housekeeping"}, {"notebook", "/conversation/settings/notebook"}, {"teams", "/teams"}} {
p.open(s.path)
p.check(`document.querySelectorAll('[equipo-settings-body] h1').length===1 && !!document.querySelector('[equipo-settings-body] [equipo-sp-head] h1') && getComputedStyle(document.querySelector('[equipo-sp-head] h1')).fontSize==='24px'`, s.name+": not one Settings head")
got := eval[float64](p, `document.querySelector('[equipo-settings-body]').getBoundingClientRect().width`)
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json
index 86ba04a5..dfadfc85 100644
--- a/scripts/runner-reference-allowlist.json
+++ b/scripts/runner-reference-allowlist.json
@@ -11030,5 +11030,40 @@
"match": "npm",
"count": 1,
"reason": "Team panel activity wording: recognises a specialist's npm or node command to describe it in plain words; not a runner dependency."
+ },
+ {
+ "path": "internal/chatmarkdown/draft.go",
+ "line_sha256": "ee91145c8919642eb26c82db1674ec5f86d7a5127626b5780ad4b75816a5e34c",
+ "match": "Node",
+ "count": 1,
+ "reason": "Markdown syntax tree node traversal in the Go renderer; no external runtime."
+ },
+ {
+ "path": "internal/chatmarkdown/draft.go",
+ "line_sha256": "bfd8eb8376e241eca5adaf2bb9c3072529c3bfa7c8e481d2274df30a885fc039",
+ "match": "Node",
+ "count": 1,
+ "reason": "Markdown syntax tree node traversal in the Go renderer; no external runtime."
+ },
+ {
+ "path": "internal/chatmarkdown/draft.go",
+ "line_sha256": "221929a57b168baeb3648aee8733abd4af0a08a0124a1c022f07eadfd182eb27",
+ "match": "Node",
+ "count": 2,
+ "reason": "Markdown syntax tree node traversal in the Go renderer; no external runtime."
+ },
+ {
+ "path": "internal/chatmarkdown/draft.go",
+ "line_sha256": "0a119e5854b4f0f14cbed0e318beedcf8e02a58d81995a51a4e6a70445560211",
+ "match": "Node",
+ "count": 1,
+ "reason": "Markdown syntax tree node traversal in the Go renderer; no external runtime."
+ },
+ {
+ "path": "internal/chatmarkdown/draft.go",
+ "line_sha256": "d60d917f1adaa14b960bae0ec9de8bc3ef9be5178caf139edd0996094c22526b",
+ "match": "Node",
+ "count": 1,
+ "reason": "Markdown syntax tree node traversal in the Go renderer; no external runtime."
}
]