Merge main (thinking-stale, copy-queued) into merge-authority
Merge of origin/main febd1a2; budget records combined and remeasured.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 files changed,
+397
−31
.rastrillo/budgets.txt+2 −2docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+1 −0internal/equipo/chat_page.go+25 −1internal/equipo/copy.go+1 −0internal/equipo/static/chat-stream.js+145 −14internal/equipo/templates/chat.html+2 −1internal/thintest/instant_browser_test.go+31 −13internal/thintest/stale_thinking_browser_test.go+190 −0
CI passed — run details
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt| index 8e2cbd58..dd905800 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 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/equipo 16980 - Merge authority merged onto Machines in Settings and stale thinking lines: measured 16914. Stale thinking lines (the queued note in chat_page.go and chat.html, the refresh and turn ownership in chat-stream.js, about 60 lines) merged onto Machines in Settings: measured 16725. 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. 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. |
| @@ -62,5 +62,5 @@ perf GET /conversation/attachments/{id}/preview skip Composer attachments: an im |
| perf GET /api/v1/runners skip Mac runners person API: bearer-only JSON for devices; the browser shows runners in the Team section. |
| time cmd/equipo-runner 60s Mac runners slice B: TestReleaseRunnerHasNoFakeWorker builds the release runner exactly as make release-runner does and the thin package under the testbuild tag (measured 11.9s locally with a warm cache). |
| size internal/headless - 8400 Merge authority extends 4c_checks_card to end in Equipo's own merge, measured by the real runner, with its receipt (about 30 lines); measured 8330. Claude's sign-in by a link adds its end-to-end, contained-launch and real runner kill tests (signin_test.go, signin_contained_test.go, about 400 lines); measured 8090. |
| -size internal/thintest - 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. |
| +size internal/thintest - 13070 Merge authority merged onto Machines in Settings, with the re-run ruling's cases and stale thinking lines: measured 12998. Merge authority thin v1 adds its contracts (mergeauth_contract_test.go, about 650 lines) the protocol-aware rigs and the Mac re-run contract (macrecheck_mergeauth_contract_test.go) and the review fixes' contracts; measured 12535 with main merged. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Machines in Settings adds its fixture, page and browser tests (machines_fixture_test.go, machines_pages_test.go, machines_browser_test.go, about 160 lines); measured 11759. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Stale thinking lines merged onto Machines in Settings: measured 11967. Machines in Settings adds its fixture, page and browser tests (machines_fixture_test.go, machines_pages_test.go, machines_browser_test.go, about 160 lines); measured 11759. Stale thinking lines add their browser drive (stale_thinking_browser_test.go, about 200 lines) and the queued test now checks the note; measured 11795. Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Spend 1 merged onto the four UI branches: measured 11325. Spend 1 marks overcounting Claude rows (about 120 lines); it adds the task page's spend contract and the 0059 upgrade (spend_pages_test.go, about 100 lines) and the fix round feedback by protocol (about 40); measured 10224. The team panel merged onto Projects UX and the Settings UX pass: measured 11064 with all three. The team panel adds its page contract and the drawer's browser drive at 1280 and 390 (team_panel_test.go, team_panel_browser_test.go, about 300 lines); measured 10235. Projects UX merged onto the Settings UX pass: measured 10768 with both. Projects UX adds the Projects page contracts (order, quiet fold, filter, stars and Undo, the coordinator's star, repository counts, whole words), the decision cards' Mac and Ask about this contracts and their browser drive (projects_pages_test.go, projects_browser_test.go, about 330 lines); measured 10321. The Settings UX pass adds the Settings pattern's page contracts and the savebar, Housekeeping groups and Teams browser drives (settings_ux_pages_test.go, settings_ux_browser_test.go, about 430 lines); measured 10390. Claude's sign-in by a link adds the code contract (signin_contract_test.go: the card, the code route's refusals, the wrong-code card, the kind it becomes and the canary sweep, about 220 lines); measured 9896. The Connections Add page and the Settings rail add their page contracts and the rail's browser drive (connections_add_pages_test.go, settings_rail_pages_test.go, about 230 lines); measured 9676. Claude setup tokens add the token and Check again contracts; measured 9444 with the composer and Mac lines merged. The instant thinking line adds its browser drive (instant_browser_test.go, about 230 lines); measured 9064 with the composer and Mac lines merged. Mac runners add the role, scoping, migration, placement, withdrawal, transfer and publication contracts (about 900 test lines) beside the thin v1 contracts; one package keeps one instance harness. |
| perf GET /api/v1/projects/{id}/merge-policy skip Merge authority person API: bearer-only JSON for devices; the browser reads the policy on /projects/{id}. |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index 8f8ef7ef..f2a65837 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -5995,6 +5995,7 @@ records remain unchanged. |
| | `teams.forgotten` | %s forgotten. | Settings UX pass (Paul, 2026-11-11): Teams, in the row's place before Undo; %s is the team's name | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) | |
| | `teams.undo` | Undo | Settings UX pass (Paul, 2026-11-11): Teams, after Forget | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) | |
| | `chat.activity.star_project` | Starring a project… | Coordinator activity (projects-ux) | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) | |
| +| `chat.queued` | Waiting its turn | Conversation: the note under a message sent while a turn runs (thinking-stale hot fix) | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) | |
| | `work.reason.provider_failed` | the model connection failed | Tasks: why a step stopped (projects-ux) | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) | |
| | `work.reason.provider_rejected` | the model service declined the request | Tasks: why a step stopped (projects-ux) | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) | |
| | `work.reason.policy_rejected` | Equipo's rules blocked it | Tasks: why a step stopped (projects-ux) | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) | |
diff --git a/internal/equipo/chat_page.go b/internal/equipo/chat_page.go| index 2e2ee8aa..786f3c7b 100644 |
| --- a/internal/equipo/chat_page.go |
| +++ b/internal/equipo/chat_page.go |
| @@ -43,7 +43,10 @@ type chatLine struct { |
| Switched string |
| // Waiting is the quiet status under a person's message whose turn |
| // waits for a connection (no thinking line, no timer). |
| - Waiting string |
| + Waiting string |
| + // Queued is the quiet note under the latest message of a turn queued |
| + // behind the running one (no thinking line, no timer). |
| + Queued string |
| ID, Text, TurnID string |
| // Files are what the person attached to their message. |
| Files []wire.MessageAttachment |
| @@ -253,6 +256,16 @@ func (a *application) chatPage(w http.ResponseWriter, r *http.Request) { |
| held = held || t.State == wire.TurnWaiting && t.Reason == wire.ReasonNoConnection |
| } |
| waitingTurns := map[string]bool{} |
| + // The person's turns go one at a time: the oldest in flight has the |
| + // thinking line, and one queued behind it a quiet note under its |
| + // latest message instead of a line and timer of its own. |
| + var ahead *wire.Turn |
| + for i, t := range snap.Turns { |
| + if t.Kind == wire.TurnPerson && !wire.Terminal(t.State) && (ahead == nil || t.CreatedAt.Before(ahead.CreatedAt) || t.CreatedAt.Equal(ahead.CreatedAt) && t.ID < ahead.ID) { |
| + ahead = &snap.Turns[i] |
| + } |
| + } |
| + queuedTurns := map[string]bool{} |
| var latest *wire.Turn |
| for i, t := range snap.Turns { |
| if !wire.Terminal(t.State) { |
| @@ -268,6 +281,10 @@ func (a *application) chatPage(w http.ResponseWriter, r *http.Request) { |
| } |
| continue |
| } |
| + if t.Kind == wire.TurnPerson && t.State == wire.TurnQueued && ahead != nil && ahead.ID != t.ID { |
| + queuedTurns[t.ID] = true |
| + continue |
| + } |
| view.Waiting = append(view.Waiting, t) |
| } |
| // Turns the coordinator takes on its own never end in a note. |
| @@ -280,6 +297,13 @@ func (a *application) chatPage(w http.ResponseWriter, r *http.Request) { |
| view.Messages[i].Waiting = copyText("chat.waiting_connection") |
| } |
| } |
| + // One note at most: under the person's latest waiting message. |
| + for i := len(view.Messages) - 1; i >= 0; i-- { |
| + if m := &view.Messages[i]; m.Own && queuedTurns[m.TurnID] { |
| + m.Queued = copyText("chat.queued") |
| + break |
| + } |
| + } |
| if latest != nil && (latest.State == wire.TurnFailed || latest.State == wire.TurnCancelled) { |
| key := "chat." + latest.State |
| if latest.Reason == wire.ReasonStorageFull { |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index 13c7a8b0..31e753dc 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -792,6 +792,7 @@ var pageCopy = map[string]string{ |
| "chat.connections.reason.already_connected": "That account is already connected.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "chat.connections.offline": "Your runner is offline. Start it to add a connection.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "chat.waiting_connection": "Waiting for a connection", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "chat.queued": "Waiting its turn", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| "chat.connections.title_codex": "Connect Codex", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "chat.connections.title_claude": "Connect Claude", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "chat.connections.open_openai": "Open OpenAI", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
diff --git a/internal/equipo/static/chat-stream.js b/internal/equipo/static/chat-stream.js| index 2b89b135..25886291 100644 |
| --- a/internal/equipo/static/chat-stream.js |
| +++ b/internal/equipo/static/chat-stream.js |
| @@ -420,6 +420,22 @@ |
| gone.remove(); |
| } |
| } |
| + // drawn: the draft shows the whole text it has been given (none asked |
| + // for or waiting for a frame). The committed reply waits for that, up to |
| + // two seconds, so the end of a long stream is drawn before it commits. |
| + function drawn(live) { |
| + var body = live.querySelector("[data-stream-text]"), d = body && body.draft; |
| + return !live.holding && (!d || !d.busy && d.asked === d.want && !d.frame); |
| + } |
| + function whenDrawn(live, then) { |
| + if (live.drawWait) return; |
| + live.drawWait = true; |
| + (function wait() { |
| + if (live.isConnected && !drawn(live) && Date.now() < live.settleBy) return setTimeout(wait, 50); |
| + live.drawWait = false; |
| + then(); |
| + })(); |
| + } |
| // The committed reply takes over its draft in place: the same element, |
| // now with the server's attributes, time and markdown. No reflow. |
| function settle(live, server) { |
| @@ -454,7 +470,8 @@ |
| } |
| // kind is a turn the coordinator takes on its own (move_in, explore): |
| // its line says so before any activity arrives. |
| - function bubble(turn, kind) { |
| + function bubble(turn, kind, waited) { |
| + if (!turn) return null; |
| var el = lineFor(turn); |
| if (!el && !kind && pending.length) { |
| // The line shown since the send becomes this turn's, in place. |
| @@ -472,8 +489,9 @@ |
| el.dataset.kind = kind; |
| el.querySelector("[equipo-activity]").textContent = label; |
| } |
| - // The timer counts from the send that started this turn. |
| - el.dataset.started = String(!kind && Date.now() - lastSend < 60000 ? lastSend : Date.now()); |
| + // The timer counts from the send that started this turn (a turn |
| + // that waited behind another, from now). |
| + el.dataset.started = String(!kind && !waited && Date.now() - lastSend < 60000 ? lastSend : Date.now()); |
| feed.append(el); |
| enliven(el); |
| tick(); |
| @@ -491,6 +509,43 @@ |
| function lineFor(turn) { |
| return turn ? feed.querySelector('[equipo-thinking][data-turn="' + CSS.escape(turn) + '"]') : null; |
| } |
| + // ── One line at a time ───────────────────────────────────────────── |
| + // The person's turns go one at a time. A turn queued behind the running |
| + // one has no line or timer of its own: a quiet note under the person's |
| + // latest message says it waits (queued holds those turns; revs the |
| + // newest turn revision seen, so a late answer to a send never undoes |
| + // its turn's event). Turns the coordinator takes on its own never hold |
| + // a person's turn back here: they give way. |
| + var queued = {}, revs = {}; |
| + feed.querySelectorAll("[data-queued]").forEach(function (n) { |
| + var m = n.closest("[data-turn-id]"); |
| + if (m && m.dataset.turnId) queued[m.dataset.turnId] = true; |
| + }); |
| + // behind: another person's turn holds the line (sending: or a line |
| + // shown since a send that no turn has adopted yet). |
| + function behind(turn, sending) { |
| + if (thread) return false; |
| + if (sending && pending.length) return true; |
| + return Array.from(feed.querySelectorAll("[equipo-thinking]:not([data-kind]):not([data-optimistic])")).some(function (el) { |
| + return el.dataset.turn && el.dataset.turn !== turn && !ended[el.dataset.turn]; |
| + }); |
| + } |
| + function notes() { |
| + if (thread) return; |
| + var want = null; |
| + feed.querySelectorAll('[equipo-message="own"]').forEach(function (m) { |
| + var turn = m.dataset.turnId; |
| + if (turn ? queued[turn] && !ended[turn] : m.queuedAtSend) want = m; |
| + }); |
| + feed.querySelectorAll("[data-queued]").forEach(function (n) { if (n.parentElement !== want) n.remove(); }); |
| + if (want && !want.querySelector(":scope > [data-queued]")) { |
| + var note = document.createElement("p"); |
| + note.setAttribute("equipo-card-note", ""); |
| + note.setAttribute("data-queued", ""); |
| + note.textContent = root.dataset.queuedNote || ""; |
| + want.append(note); |
| + } |
| + } |
| function optimistic(who) { |
| // Nothing can answer: the server's quiet status says so instead. |
| if (!thread && feed.querySelector("[data-no-connection]")) return null; |
| @@ -525,7 +580,7 @@ |
| // already has one (the message joined an earlier queued turn) or is over. |
| function claim(el, turn) { |
| if (!el || !turn || !el.isConnected || !el.hasAttribute("data-optimistic")) return; |
| - if (lineFor(turn) || ended[turn]) drop(el); |
| + if (lineFor(turn) || ended[turn] || queued[turn]) drop(el); |
| else adopt(el, turn); |
| } |
| // Who a thread question goes to, as ask-target.js shows it. |
| @@ -567,6 +622,7 @@ |
| }, 250); |
| function showDraft(turn) { |
| var el = bubble(turn); |
| + if (!el) return; |
| var text = drafts[turn] ? drafts[turn].text : ""; |
| if (!text) return; |
| // The first words: the line fades where it sits, and the text |
| @@ -589,6 +645,7 @@ |
| } |
| function showActivity(v) { |
| var el = bubble(v.turn_id); |
| + if (!el) return; |
| if (drafts[v.turn_id] && drafts[v.turn_id].text) { |
| // A tool after text: show the line again under the draft. |
| delete el.dataset.streaming; |
| @@ -601,7 +658,10 @@ |
| // drafts are put back. Refreshes run one at a time (a request during one |
| // runs once after it), and a page older than the one shown is dropped. |
| var inflight = null, again = false; |
| - var pageCursor = cursor; |
| + // shape is the cursor of the newest event that changes what the page |
| + // shows (a turn, a message, a card): a page rendered before it is |
| + // stale, and is followed by another. |
| + var pageCursor = cursor, shape = cursor; |
| function refresh() { |
| if (inflight) { |
| again = true; |
| @@ -633,6 +693,8 @@ |
| var at = Number(page.dataset.cursor) || 0; |
| if (at < pageCursor) return; |
| pageCursor = at; |
| + var stale = at < shape; |
| + if (stale) again = true; |
| // Keep live timers and activity lines across the re-render. |
| // A newly committed reply settles into its draft's element; a turn |
| // may already have earlier messages on the page. |
| @@ -651,6 +713,9 @@ |
| var fresh = el.matches('[equipo-message="incoming"][data-turn-id]') && !shown[el.dataset.message]; |
| var turn = el.hasAttribute("equipo-thinking") ? el.dataset.turn : fresh ? el.dataset.turnId : ""; |
| var old = turn && keep[turn]; |
| + // A page from before the turn ended never brings its line back. |
| + if (!old && el.hasAttribute("equipo-thinking") && ended[turn]) return null; |
| + if (el.hasAttribute("equipo-thinking") && !el.dataset.kind) delete queued[turn]; |
| if (!old && el.hasAttribute("equipo-thinking") && !el.dataset.kind && pending.length && !ended[turn]) { |
| // The server shows the turn before its event came: the line |
| // shown since the send takes it, with the server's words. |
| @@ -668,13 +733,24 @@ |
| } |
| if (!old) return el; |
| delete keep[turn]; |
| - return el.hasAttribute("equipo-thinking") ? old : settle(old, el); |
| - })); |
| + if (el.hasAttribute("equipo-thinking")) return old; |
| + old.settleBy = old.settleBy || Date.now() + 2000; |
| + if (!drawn(old) && Date.now() < old.settleBy) { |
| + // The draft is still drawing its last words: the reply |
| + // settles on the refresh after it has. |
| + whenDrawn(old, refreshSoon); |
| + return old; |
| + } |
| + return settle(old, el); |
| + }).filter(Boolean)); |
| + // A stale page lacks lines for turns that started since: they stay. |
| + if (stale) Object.keys(keep).forEach(function (turn) { if (!ended[turn] && !queued[turn]) feed.append(keep[turn]); }); |
| local.forEach(function (el) { place(el); }); |
| pending.forEach(function (el) { feed.append(el); }); |
| Object.keys(drafts).forEach(function (turn) { |
| if (feed.querySelector('[equipo-thinking][data-turn="' + CSS.escape(turn) + '"]')) showDraft(turn); |
| }); |
| + notes(); |
| tick(); |
| scroll(); |
| }); |
| @@ -684,6 +760,7 @@ |
| if (e.cursor <= cursor) return; |
| cursor = e.cursor; |
| var v = e.data; |
| + if (type === "turn" || type === "message" || type === "card" || type === "task" || type === "step") shape = cursor; |
| if (type === "thinking") { |
| root.dataset.thinkingSet = v.set; |
| return; |
| @@ -714,7 +791,9 @@ |
| return; |
| } |
| if ((type !== "delta" && type !== "activity") || !question || !(v.turn_id in asked)) return; |
| - } else if (question || type === "question") { |
| + } else if (question || type === "question" || (type === "delta" || type === "activity") && (e.resource !== "turn" || !v.turn_id)) { |
| + // A specialist's step reports activity on the same stream: it is |
| + // not the coordinator's, and draws no line here. |
| return; |
| } |
| if (type === "delta") { |
| @@ -730,18 +809,31 @@ |
| if (v.role === "coordinator") { |
| delete drafts[v.turn_id]; |
| ended[v.turn_id] = true; |
| + notes(); |
| refreshSoon(); |
| return; |
| } |
| + // A send from this page still waiting for its answer: the event |
| + // names it in place, so the messages keep the order they were sent. |
| + var mine = Array.from(local).find(function (el) { return !el.dataset.message && el.isConnected && el.querySelector("[equipo-message-body]").textContent === v.text; }); |
| + if (mine) { |
| + mine.dataset.message = v.id; |
| + mine.dataset.turnId = v.turn_id || ""; |
| + notes(); |
| + return; |
| + } |
| var own = template("equipo-own-template"); |
| own.dataset.message = v.id; |
| + own.dataset.turnId = v.turn_id || ""; |
| own.querySelector("[equipo-message-body]").textContent = v.text; |
| sentFiles(own, served(v.attachments)); |
| own.querySelector("time").textContent = new Date(v.created_at).toTimeString().slice(0, 5); |
| var waiting = feed.querySelector("[equipo-thinking]"); |
| feed.insertBefore(own, waiting); |
| + notes(); |
| scroll(); |
| } else if (type === "turn") { |
| + revs[v.id] = Math.max(revs[v.id] || 0, v.revision || 0); |
| var heldNow = !!feed.querySelector("[data-no-connection]"); |
| if (v.state === "waiting" && v.reason === "no_connection" || v.state === "queued" && heldNow) { |
| // Nothing can answer yet: no thinking line, no timer; the quiet |
| @@ -753,9 +845,18 @@ |
| drop(thinking); |
| ended[v.id] = true; |
| refreshSoon(); |
| + } else if (v.state === "queued" && !v.kind && behind(v.id)) { |
| + // Behind the running turn: the note, and no line or timer. |
| + delete ended[v.id]; |
| + queued[v.id] = true; |
| + drop(lineFor(v.id)); |
| + notes(); |
| } else if (v.state === "queued" || v.state === "running" || v.state === "waiting") { |
| delete ended[v.id]; |
| - var shownDraft = bubble(v.id, v.kind); |
| + var waited = !!queued[v.id]; |
| + delete queued[v.id]; |
| + notes(); |
| + var shownDraft = bubble(v.id, v.kind, waited); |
| if (drafts[v.id] && drafts[v.id].attempt !== v.attempt) { |
| // The refused attempt's words go; the next attempt's follow. |
| delete drafts[v.id]; |
| @@ -767,15 +868,23 @@ |
| } |
| // Going again on a connection: the status and the card go. |
| if (heldNow || feed.querySelector('[data-message] [data-waiting-connection]')) refreshSoon(); |
| + } else if (v.state === "replied" && v.reply_id) { |
| + ended[v.id] = true; |
| + delete queued[v.id]; |
| + notes(); |
| } else if (v.state === "replied" && !v.reply_id) { |
| // A turn that ended with nothing to say (an empty explore). |
| delete drafts[v.id]; |
| ended[v.id] = true; |
| + delete queued[v.id]; |
| + notes(); |
| var quiet = feed.querySelector('[equipo-thinking][data-turn="' + CSS.escape(v.id) + '"]'); |
| if (quiet) quiet.remove(); |
| } else if (v.state === "failed" || v.state === "cancelled") { |
| delete drafts[v.id]; |
| ended[v.id] = true; |
| + delete queued[v.id]; |
| + notes(); |
| var el = feed.querySelector('[equipo-thinking][data-turn="' + CSS.escape(v.id) + '"]'); |
| if (el) el.remove(); |
| // A move-in that gave way to the person, or stopped, is not the |
| @@ -872,6 +981,14 @@ |
| }); |
| box.hidden = false; |
| } |
| + // The coordinator's line for a send, or, sent while a turn runs, the |
| + // quiet note: the message waits its turn. |
| + function lineOrNote(el, who) { |
| + el.queuedAtSend = behind("", true); |
| + if (!el.queuedAtSend) return optimistic(who); |
| + notes(); |
| + return null; |
| + } |
| function post(el, text, id, extra, files, line) { |
| el.dataset.pending = ""; |
| delete el.dataset.sendFailed; |
| @@ -886,10 +1003,21 @@ |
| .then(function (sent) { |
| local.delete(el); |
| delete el.dataset.pending; |
| + if (!thread && sent.turn) { |
| + // The send's view of its turn, unless an event said more since. |
| + if ((sent.turn.revision || 0) > (revs[sent.turn.id] || 0)) { |
| + if (sent.turn.state === "queued" && behind(sent.turn.id)) queued[sent.turn.id] = true; |
| + else delete queued[sent.turn.id]; |
| + } |
| + el.dataset.turnId = sent.turn.id; |
| + } |
| // A conversation send names its turn; a thread question is its own. |
| claim(line, thread ? sent.message.id : sent.turn && sent.turn.id); |
| - if (feed.querySelector('[data-message="' + CSS.escape(sent.message.id) + '"]')) { |
| + notes(); |
| + var shown = feed.querySelector('[data-message="' + CSS.escape(sent.message.id) + '"]'); |
| + if (shown && shown !== el) { |
| el.remove(); |
| + notes(); |
| return; |
| } |
| el.dataset.message = sent.message.id; |
| @@ -903,8 +1031,10 @@ |
| } |
| }) |
| .catch(function () { |
| - // Nothing was sent: no line waits for a reply. |
| + // Nothing was sent: no line waits for a reply, nor a note. |
| drop(line); |
| + el.queuedAtSend = false; |
| + notes(); |
| delete el.dataset.pending; |
| el.dataset.sendFailed = ""; |
| var retry = document.createElement("button"); |
| @@ -912,7 +1042,7 @@ |
| retry.setAttribute("rst-btn", ""); |
| retry.dataset.retrySend = ""; |
| retry.textContent = form.dataset.retry; |
| - retry.addEventListener("click", function () { post(el, text, id, extra, files, optimistic(extra.specialist)); }); |
| + retry.addEventListener("click", function () { post(el, text, id, extra, files, lineOrNote(el, extra.specialist)); }); |
| el.querySelector("[equipo-bubble]").append(retry); |
| }); |
| } |
| @@ -936,8 +1066,9 @@ |
| local.add(el); |
| lastSend = Date.now(); |
| place(el); |
| - // The coordinator's line, now: nothing waits on the network. |
| - var line = optimistic(who); |
| + // The coordinator's line, now: nothing waits on the network. Sent |
| + // while a turn runs, the message waits its turn: the note instead. |
| + var line = lineOrNote(el, who); |
| scroll(true); |
| // The form's other fields as they are now (who a question is for). |
| var extra = {}; |
diff --git a/internal/equipo/templates/chat.html b/internal/equipo/templates/chat.html| index 791311e7..f1919dda 100644 |
| --- a/internal/equipo/templates/chat.html |
| +++ b/internal/equipo/templates/chat.html |
| @@ -13,7 +13,7 @@ |
| {{define "work-task-receipt"}}{{with .Task}}<p equipo-card-line>{{icon "check-circle"}}<span><a href="/tasks/{{.ID}}">{{.Title}}</a></span><span equipo-stage data-stage="{{.Stage}}" data-needs="{{.NeedsYou}}">{{.StageLine}}</span></p>{{if and .Pushed (not .MergedLine)}}<p equipo-card-note data-pushed><span>{{.Pushed}}</span><a href="{{.URL}}" rel="noopener" target="_blank" data-open-amadan>{{copy "work.open"}}</a></p>{{end}}{{if or .ChecksLine .ReviewLine}}<p equipo-card-note data-judged>{{with .ChecksLine}}<span data-checks>{{.}}</span>{{end}}{{with .ReviewLine}}<span data-verdict>{{.}}</span>{{end}}</p>{{end}}{{if .MergedLine}}<p equipo-card-note data-merged><span>{{.MergedLine}}</span><a href="{{.RepoURL}}" rel="noopener" target="_blank" data-open-amadan>{{copy "work.open"}}</a></p>{{end}}{{end}}{{if .Open}}<button type="button" equipo-receipt-more aria-expanded="false" aria-controls="acts-{{.ID}}" aria-label="{{copy "chat.card.more"}}">⋯</button><span equipo-receipt-actions id="acts-{{.ID}}">{{template "work-task-actions" .Task}}</span>{{end}}{{end}} |
| {{define "message-files"}}{{with .}}<div equipo-message-files>{{range .}}{{if eq .Kind "image"}}<a equipo-file-thumb href="/conversation/attachments/{{.ID}}" target="_blank" rel="noopener" data-attachment="{{.ID}}"><img src="/conversation/attachments/{{.ID}}/preview" alt="{{.Name}}"{{if .Width}} width="{{.Width}}" height="{{.Height}}"{{end}} loading="lazy" decoding="async"></a>{{else}}<a equipo-file-chip href="/conversation/attachments/{{.ID}}" target="_blank" rel="noopener" data-attachment="{{.ID}}">{{icon "file-text"}}<span equipo-file-name>{{.Name}}</span><span equipo-file-size>{{fileSize .Size}}</span></a>{{end}}{{end}}</div>{{end}}{{end}} |
| {{define "content"}} |
| -<div equipo-conversation data-chat-stream data-thinking-set="{{.ThinkingSet}}" data-thinking-words="{{.ThinkingWords}}" data-cursor="{{.Chat.Cursor}}" data-person="{{.Address}}" data-elapsed="{{copy "chat.elapsed"}}" data-moving-in="{{copy "chat.moving_in"}}" data-exploring="{{copy "chat.exploring"}}"> |
| +<div equipo-conversation data-chat-stream data-thinking-set="{{.ThinkingSet}}" data-thinking-words="{{.ThinkingWords}}" data-cursor="{{.Chat.Cursor}}" data-person="{{.Address}}" data-elapsed="{{copy "chat.elapsed"}}" data-moving-in="{{copy "chat.moving_in"}}" data-exploring="{{copy "chat.exploring"}}" data-queued-note="{{copy "chat.queued"}}"> |
| <header equipo-chat-header><h1>{{copy "conversation.title"}}</h1><a href="/conversation/settings/notebook" equipo-header-button aria-label="{{copy "chat.notebook.link"}}" title="{{copy "chat.notebook.link"}}">{{icon "notebook"}}</a><a href="/housekeeping" equipo-header-button aria-label="{{copy "chat.housekeeping.link"}}" title="{{copy "chat.housekeeping.link"}}" data-housekeeping-link>{{icon "list-checks"}}</a><a href="/conversation/settings/connections" equipo-header-button aria-label="{{copy "chat.connections.title"}}" title="{{copy "chat.connections.title"}}" data-connections-link>{{icon "plug"}}</a></header> |
| <p equipo-offline role="status"{{if not .Chat.Offline}} hidden{{end}}>{{copy "chat.offline"}}</p> |
| <div equipo-scroll tabindex="0" role="region" aria-label="{{copy "conversation.title"}}"> |
| @@ -32,6 +32,7 @@ |
| <div equipo-message-meta><strong{{if .Own}} equipo-visually-hidden{{end}}>{{if .Own}}{{$.Address}}{{else}}{{icon "message-circle"}}{{copy "conversation.coordinator"}}{{end}}</strong><time datetime="{{.CreatedAt.Format "2006-01-02T15:04:05Z07:00"}}">{{.CreatedAt.Format "15:04"}}</time></div> |
| {{if .Own}}{{template "message-files" .Files}}{{end}}<div equipo-bubble>{{if .Own}}<p equipo-message-body>{{.Text}}</p>{{else}}<div equipo-message-body equipo-markdown>{{chatMarkdown .Text}}</div>{{end}}</div> |
| {{with .Waiting}}<p equipo-card-note data-waiting-connection>{{.}}</p>{{end}} |
| +{{with .Queued}}<p equipo-card-note data-queued>{{.}}</p>{{end}} |
| {{with .Switched}}<p equipo-card-note data-switched>{{.}}</p>{{end}} |
| </li> |
| {{range .Cards}}{{template "chat-card" .}}{{end}}{{end}} |
diff --git a/internal/thintest/instant_browser_test.go b/internal/thintest/instant_browser_test.go| index bffefc85..05cbf4c2 100644 |
| --- a/internal/thintest/instant_browser_test.go |
| +++ b/internal/thintest/instant_browser_test.go |
| @@ -189,9 +189,11 @@ func messageFrame(t *testing.T, r *rig, runner *FakeRunner) wire.Frame { |
| // TestBrowserInstantThinkingQueued: while one turn runs, a second message |
| // queues a turn behind it and a third joins that queued turn (the server |
| -// says so in its answer). Every send shows a line at once; when the server |
| -// has answered, there is one line per turn, each the element shown at the |
| -// send, and nothing is orphaned. |
| +// says so in its answer). The first send shows its line at once; the |
| +// queued ones show no line or timer of their own, only a quiet note under |
| +// the latest (Paul, 2026-11-11: ten stacked lines, "Did I push it too |
| +// hard?"). When the server has answered there is one line, the element |
| +// shown at the first send, and nothing is orphaned. |
| func TestBrowserInstantThinkingQueued(t *testing.T) { |
| r, runner := instantRig(t) |
| p := instantPage(t, r) |
| @@ -203,18 +205,25 @@ func TestBrowserInstantThinkingQueued(t *testing.T) { |
| p.wait(`!window.__first.hasAttribute('data-optimistic')`, "the first turn adopted its line") |
| first := eval[string](p, `window.__first.dataset.turn`) |
| r.wait("first running", func(c *Conversation) bool { return c.Turns[first].State == wire.TurnRunning }) |
| - p.check(sendNow+`('And a second.')`, "no line for the second send") |
| - p.check(`(()=>{window.__second=window.__line;return true})()`, "keep the second") |
| - p.check(sendNow+`('And a third.')`, "no line for the third send") |
| - p.check(`(()=>{window.__third=window.__line;return document.querySelectorAll('[equipo-thinking][data-optimistic]').length===2 && window.__held.length===2})()`, "two waiting lines, both sends held") |
| + // queuedNow sends text and reports in the same task that the only line |
| + // is still the first's and the note is under this message. |
| + queuedNow := `(text=>{ |
| + const box=document.querySelector('#composer textarea');box.value=text;box.dispatchEvent(new Event('input')); |
| + document.querySelector('#composer').requestSubmit(); |
| + const lines=[...document.querySelectorAll('[equipo-thinking]')], notes=[...document.querySelectorAll('[data-queued]')]; |
| + return lines.length===1 && lines[0]===window.__first && notes.length===1 && notes[0].closest('[equipo-message="own"]').querySelector('[equipo-message-body]').textContent===text; |
| +})` |
| + p.check(queuedNow+`('And a second.')`, "a line of its own, or no note, for the second send") |
| + p.check(queuedNow+`('And a third.')`, "a line of its own, or no note, for the third send") |
| + p.check(`window.__held.length===2`, "both sends held") |
| p.check(`window.__release()`, "release the second") |
| - p.wait(`!window.__second.hasAttribute('data-optimistic') && window.__second.dataset.turn!==`+jsString(first), "the queued turn adopted the second line") |
| + p.wait(`window.__answered===2`, "the second answered") |
| p.check(`window.__release()`, "release the third") |
| - p.wait(`window.__answered===3 && !document.querySelector('[equipo-thinking][data-optimistic]')`, "the third line gone") |
| - lines := `[...document.querySelectorAll('[equipo-thinking]')].map(l=>(l===window.__first?'first:':l===window.__second?'second:':l===window.__third?'third:':'')+l.dataset.turn).join(' ')` |
| - second := eval[string](p, `window.__second.dataset.turn`) |
| - if got := eval[string](p, lines); got != "first:"+first+" second:"+second { |
| - t.Fatalf("lines %q, want the first and second for turns %s and %s", got, first, second) |
| + p.wait(`window.__answered===3`, "the third answered") |
| + p.wait(`document.querySelectorAll('[data-queued]').length===1 && [...document.querySelectorAll('[equipo-message="own"]')].find(m=>m.querySelector('[data-queued]')).querySelector('[equipo-message-body]').textContent==='And a third.'`, "one note, under the third") |
| + lines := `[...document.querySelectorAll('[equipo-thinking]')].map(l=>(l===window.__first?'first:':'')+l.dataset.turn).join(' ')` |
| + if got := eval[string](p, lines); got != "first:"+first { |
| + t.Fatalf("lines %q, want only the first's for turn %s", got, first) |
| } |
| snap, err := r.client.Snapshot(r.ctx) |
| if err != nil { |
| @@ -223,5 +232,14 @@ func TestBrowserInstantThinkingQueued(t *testing.T) { |
| if len(snap.Turns) != 2 { |
| t.Fatalf("the third message did not join the queued turn: %+v", snap.Turns) |
| } |
| + var second string |
| + for _, v := range snap.Turns { |
| + if v.ID != first { |
| + second = v.ID |
| + } |
| + } |
| + // The first replies: the queued turn's line comes, the note goes. |
| + runner.Send(r.ctx, "r-q1", wire.FrameReply, wire.Reply{TurnID: first, Attempt: 1, Text: "First done."}) |
| + p.wait(`document.querySelectorAll('[equipo-thinking]').length===1 && document.querySelector('[equipo-thinking]').dataset.turn===`+jsString(second)+` && !document.querySelector('[data-queued]')`, "the second turn's line, no note") |
| p.stayed("queued sends") |
| } |
diff --git a/internal/thintest/stale_thinking_browser_test.go b/internal/thintest/stale_thinking_browser_test.go| new file mode 100644 |
| index 00000000..51c216a3 |
| --- /dev/null |
| +++ b/internal/thintest/stale_thinking_browser_test.go |
| @@ -0,0 +1,190 @@ |
| +//go:build browser |
| + |
| +package thintest |
| + |
| +import ( |
| + "context" |
| + "strconv" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| + "github.com/chromedp/cdproto/cdp" |
| + "github.com/chromedp/cdproto/page" |
| + "github.com/chromedp/chromedp" |
| +) |
| + |
| +// TestBrowserThinkingLinesClear: Paul on staging, 2026-11-11, "Did I push |
| +// it too hard?": ten Coordinator lines stacked, timers 22 s to 139 s, for |
| +// a conversation where every turn had replied. A specialist was at work |
| +// on a task meanwhile, and each of its step activity events (no turn) |
| +// drew a new thinking line that nothing took away. |
| +// |
| +// Messages go quickly, some while a turn runs (one joins the queued |
| +// turn), one reply lands while a refresh is in flight, and the task's |
| +// step reports activity throughout. While a turn runs there is one |
| +// thinking line (the running turn's) and the waiting message has a quiet |
| +// queued note instead of a line and timer of its own. Once every turn has |
| +// replied there is no thinking line, live and after a reload, and each |
| +// reply shows once. |
| +func TestBrowserThinkingLinesClear(t *testing.T) { |
| + r := newToolRig(t) |
| + // A task whose step keeps running: its activity reaches the stream. |
| + task := taskID(t, r.call("k1", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Swipe back from the edge does nothing", "brief": "x"})) |
| + r.call("k2", wire.ToolStartTask, map[string]string{"task": task, "brief": "go"}) |
| + _, body := r.expect(wire.FrameDispatch) |
| + d := body.(*wire.DispatchCommand) |
| + r.step("r-s1", wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: strings.Repeat("1", 40)}) |
| + acts := 0 |
| + activity := func() { |
| + t.Helper() |
| + acts++ |
| + r.activity("act-"+strconv.Itoa(acts), wire.StepActivityReport{TaskID: task, StepID: d.StepID, Attempt: 1, Kind: wire.ActivityRead, Subject: "panes/swipe.go"}) |
| + r.wait("step activity", func(c *Conversation) bool { return len(c.StepActivity[d.StepID]) == acts }) |
| + } |
| + reply := func(turn, text string) { |
| + t.Helper() |
| + if err := r.runner.Send(r.ctx, "r-"+turn, wire.FrameReply, wire.Reply{TurnID: turn, Attempt: 1, Text: text}); err != nil { |
| + t.Fatal(err) |
| + } |
| + r.wait("replied", func(c *Conversation) bool { return c.Turns[turn].State == wire.TurnReplied }) |
| + } |
| + // next is the turn the instance dispatches next, acked: running. |
| + next := func() string { |
| + t.Helper() |
| + _, body := r.expect(wire.FrameMessage) |
| + turn := body.(*wire.MessageCommand).TurnID |
| + r.wait("running", func(c *Conversation) bool { return c.Turns[turn].State == wire.TurnRunning }) |
| + return turn |
| + } |
| + reply(r.turn, "Started on the swipe.") |
| + |
| + p := openInner(t, r.inst.URL, r.inst.Cookie(), 390, 844, true, "dark", "no-preference") |
| + defer p.stop() |
| + // Count the events the page has applied, and hold the page's refresh |
| + // answers on demand (the request goes; its answer waits). |
| + p.do(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error { |
| + _, err := cdp.Call(ctx, target, page.AddScriptToEvaluateOnNewDocument, page.AddScriptToEvaluateOnNewDocumentParams{Source: `(()=>{ |
| +const ES=window.EventSource;window.__seen={}; |
| +window.EventSource=function(u,o){const s=new ES(u,o);const add=s.addEventListener.bind(s);s.addEventListener=function(t,f,x){return add(t,function(e){f.call(this,e);window.__seen[t]=(window.__seen[t]||0)+1},x)};return s}; |
| +window.EventSource.prototype=ES.prototype; |
| +const fetch0=window.fetch.bind(window);window.__hold=false;window.__held=[]; |
| +window.fetch=(url,opts)=>{const f=fetch0(url,opts);if(!window.__hold||opts&&opts.method==='POST'||!String(url).endsWith('/conversation'))return f;return new Promise(go=>window.__held.push(()=>go(f)))}; |
| +window.__release=()=>{window.__hold=false;const h=window.__held.splice(0);h.forEach(f=>f());return h.length}; |
| +})()`}) |
| + return err |
| + })) |
| + p.open("/conversation") |
| + p.wait(`document.querySelector('[data-chat-stream]') && window.__seen`, "the conversation") |
| + turns := func() string { |
| + var out []string |
| + r.conv.Locked(func(c *Conversation) { |
| + for id, v := range c.Turns { |
| + out = append(out, id+" "+v.State+" "+strings.Join(v.MessageIDs, ",")) |
| + } |
| + }) |
| + return strings.Join(out, "; ") |
| + } |
| + // What the feed shows, for a failure: lines by turn, messages by turn. |
| + state := `[...document.querySelectorAll('[equipo-feed] > *')].map(l=>l.hasAttribute('equipo-thinking')?'line:'+l.dataset.turn+(l.hasAttribute('data-optimistic')?'(optimistic)':''):l.matches('[equipo-message]')?l.getAttribute('equipo-message')+':'+(l.dataset.turnId||'-')+':'+l.querySelector('[equipo-message-body]').textContent.slice(0,24)+(l.querySelector('[data-queued]')?' (queued)':''):l.tagName).join('\n')` |
| + wait := func(expression, what string) { |
| + t.Helper() |
| + for deadline := time.Now().Add(8 * time.Second); !eval[bool](p, `!!(`+expression+`)`); time.Sleep(40 * time.Millisecond) { |
| + if time.Now().After(deadline) { |
| + t.Fatalf("waiting for %s; the feed:\n%s\nturns: %s", what, eval[string](p, state), turns()) |
| + } |
| + } |
| + } |
| + check := func(expression, what string) { |
| + t.Helper() |
| + if !eval[bool](p, `!!(`+expression+`)`) { |
| + t.Fatalf("%s; the feed:\n%s\nturns: %s", what, eval[string](p, state), turns()) |
| + } |
| + } |
| + // send types text and sends it; behind a running turn, nothing but |
| + // that turn's line shows, from the moment of sending. |
| + send := func(text string, behind bool) { |
| + t.Helper() |
| + check(`(()=>{const box=document.querySelector('#composer textarea');box.value=`+jsString(text)+`;box.dispatchEvent(new Event('input'));document.querySelector('#composer').requestSubmit();return `+strconv.FormatBool(!behind)+` || document.querySelectorAll('[equipo-thinking]').length===1})()`, "a second line at the send of "+text) |
| + } |
| + lines := `document.querySelectorAll('[equipo-thinking]').length` |
| + lineFor := func(turn string) string { |
| + return `document.querySelectorAll('[equipo-thinking]').length===1 && document.querySelector('[equipo-thinking]').dataset.turn===` + jsString(turn) |
| + } |
| + seen := func(n int) string { return `(window.__seen.activity||0)>=` + strconv.Itoa(n) } |
| + own := func(text string) string { |
| + return `[...document.querySelectorAll('[equipo-message="own"]')].find(m=>m.querySelector('[equipo-message-body]').textContent===` + jsString(text) + `)` |
| + } |
| + queued := func(text string) string { return `!!` + own(text) + `?.querySelector('[data-queued]')` } |
| + notes := `document.querySelectorAll('[data-queued]').length` |
| + count := func(text string) string { |
| + return `[...document.querySelectorAll('[equipo-message="incoming"][data-message]')].filter(m=>m.textContent.includes(` + text + `)).length===1` |
| + } |
| + once := func(text string) string { return count(jsString(text)) } |
| + wait(once("Started on the swipe.")+` && `+lines+`===0`, "the opening reply, no line") |
| + activity() |
| + wait(seen(1), "the first step activity") |
| + check(lines+`===0`, "a step's activity drew a coordinator line") |
| + |
| + // M1 runs; the specialist goes on meanwhile. |
| + send("First thing.", false) |
| + t1 := next() |
| + wait(lineFor(t1), "one line, for the first turn") |
| + activity() |
| + wait(seen(2), "step activity while a turn runs") |
| + check(lineFor(t1), "a second line beside the running turn's") |
| + |
| + // M2 while T1 runs: queued, a quiet note and no line of its own; M3 |
| + // joins the queued turn. |
| + send("And a second.", true) |
| + wait(queued("And a second."), "the queued note under the second message") |
| + check(lineFor(t1), "a line and timer for the queued turn") |
| + wait(own("And a second.")+`?.dataset.message`, "the second message sent") |
| + send("And a third.", true) |
| + wait(queued("And a third.")+` && `+notes+`===1`, "one queued note, under the latest message") |
| + check(lineFor(t1), "a line and timer for the joined turn") |
| + wait(own("And a third.")+`?.dataset.turnId===`+own("And a second.")+`.dataset.turnId`, "the third message joined the queued turn") |
| + |
| + // T1 replies: the queued turn runs, its note goes, its line comes. |
| + reply(t1, "Done with the first.") |
| + t2 := next() |
| + wait(once("Done with the first.")+` && `+lineFor(t2)+` && `+notes+`===0`, "the first reply once, one line for the second turn, no note") |
| + activity() |
| + wait(seen(3), "step activity") |
| + check(lineFor(t2), "a second line beside the running turn's") |
| + |
| + // A refresh in flight (a task recorded during T2) when T2's reply |
| + // lands and T3 starts running. |
| + check(`(()=>{window.__hold=true;return true})()`, "hold refreshes") |
| + r.turn = t2 |
| + r.call("k3", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Pull to refresh stalls", "brief": "y"}) |
| + wait(`window.__held.length>=1`, "a refresh in flight") |
| + send("A fourth.", true) |
| + wait(queued("A fourth."), "the queued note under the fourth message") |
| + reply(t2, "Second done.") |
| + t3 := next() |
| + activity() |
| + wait(seen(4), "step activity during the refresh") |
| + wait(`document.querySelector('[equipo-thinking][data-turn=`+jsString(t3)+`]')`, "the third turn's line") |
| + // The answer from before T3 started never takes its line away. |
| + check(`(()=>{window.__t3=document.querySelector('[equipo-thinking][data-turn=`+jsString(t3)+`]');return window.__release()>=1})()`, "release the refresh") |
| + wait(once("Second done.")+` && `+lineFor(t3)+` && `+notes+`===0`, "the second reply once, one line for the third turn") |
| + check(`document.querySelector('[equipo-thinking]')===window.__t3 && window.__t3.isConnected`, "the third turn's line went and came back") |
| + |
| + reply(t3, "Fourth handled.") |
| + wait(once("Fourth handled.")+` && `+lines+`===0`, "the last reply, no line") |
| + // The specialist is still at work after the chat goes quiet. |
| + activity() |
| + activity() |
| + wait(seen(6), "step activity after every turn replied") |
| + check(lines+`===0`, "stale thinking lines once every turn replied") |
| + replies := `["Started on the swipe.","Done with the first.","Second done.","Fourth handled."].every(t=>` + count("t") + `)` |
| + check(replies, "a reply missing or shown twice") |
| + p.stayed("quick sends") |
| + |
| + p.open("/conversation") |
| + wait(`document.querySelector('[data-chat-stream]')`, "the conversation again") |
| + check(lines+`===0 && `+notes+`===0`, "a thinking line or queued note after a reload") |
| + check(replies, "a reply missing or shown twice after a reload") |
| +} |