oficina / equipo Public

Fix Roster design drift and guard conversation routes

Paul Campbell pushed by paul@keymail.dev 2eeaf06155413c5062994c3adfb0d89a1ef81139 parent 5578460
19 files changed, +574 −109
  • .rastrillo/budgets.txt +3 −3
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +22 −0
  • internal/equipo/chat/roster.go +89 −38
  • internal/equipo/chat/roster_revision_test.go +101 −0
  • internal/equipo/chat_page.go +5 −1
  • internal/equipo/chat_roster.go +89 −16
  • internal/equipo/chat_roster_test.go +42 −0
  • internal/equipo/copy.go +17 −0
  • internal/equipo/icons/icons.go +1 −0
  • internal/equipo/migrations/0086_conversation_roster.sql +2 −0
  • internal/equipo/migrations/schema.sql +2 −0
  • internal/equipo/research_views.go +9 −0
  • internal/equipo/static/equipo.css +37 −13
  • internal/equipo/templates/chat.html +11 −11
  • internal/thintest/pages_test.go +6 −6
  • internal/thintest/roster_browser_test.go +32 −14
  • internal/thintest/roster_contract_test.go +26 −6
  • internal/thintest/roster_reports_browser_test.go +4 −1
  • internal/thintest/roster_routes_test.go +76 −0

CI failed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 7d6fe4e3..1056468f 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 20241 - The web view models and templates share rendering; Roster adds bylines, reports, private sub-chat views and the Stop route. Measured 20241 source lines.
+size internal/equipo 20344 - The web view models and templates share rendering; Roster adds bylines, fact details, private sub-chat views and the Stop route. Measured 20344 source lines.
size internal/wire 6197 - Runner and person API types share Encode. Protocol 21 adds Copy fields, 22 adds job lanes and job cards. Measured 6197 source lines.
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);
@@ -56,7 +56,7 @@ perf GET /api/v1/tasks/{id} skip Thin v1 person API: bearer-only JSON for device
perf GET /api/v1/assistant/snapshot skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen.
perf GET /api/v1/assistant/messages skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen.
perf GET /api/v1/assistant/events skip Assistant event stream (Server-Sent Events), bearer-only and long-lived; not a screen.
-size internal/equipo/chat 28396 - The transactional conversation store shares authority and dispatch helpers; Roster adds independent personal visibility and links card replies to existing turns. Measured 28396 source lines.
+size internal/equipo/chat 28447 - The transactional conversation store shares authority and dispatch helpers; Roster adds personal visibility and batched, resilient card-thread reads. Measured 28447 source lines.
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.
@@ -71,7 +71,7 @@ perf GET /tasks/{id}/files/{file} skip Research kept images: the bytes of one 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 TestReleaseRunnerHasNoFakeWorker builds the release runner and the thin package under testbuild (about 12s locally).
size internal/headless - 10739 End-to-end scenarios through a real runner and instance: the Copy setting, wording flag and the Assistant's job threads. Measured 10739 test lines.
-size internal/thintest - 28320 The contract and browser tests share the instance harness; Roster adds real action states and desktop/phone captures in both themes. Measured 28320 test lines.
+size internal/thintest - 28437 The contract and browser tests share the instance harness; Roster adds Reply/Stop/CSRF guards and desktop/phone state captures. Measured 28437 test lines.
perf GET /api/v1/projects/{id}/merge-policy skip Merge authority person API: bearer-only JSON for devices; the browser reads the policy on /projects/{id}.
perf GET /api/v1/usage skip Thin v1 person API: bearer-only JSON for devices; the browser reads usage through /usage.
perf GET /api/v1/advice skip Thin v1 person API: bearer-only JSON for devices; the browser reads advice through /usage and /conversation.
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index 683cdb37..5e69a9de 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -7716,3 +7716,25 @@ existing race in the Codex reading fixture: the probe could stop the fake CLI
after its answer but before its marker write. The fixture now writes its
marker before answering. The failed hosted test is the reproduction; the
same targeted test passes repeatedly after the ordering fix.
+
+
+Roster review fixes, 2026-11-14.
+
+| Key | Exact text | Context | Status |
+| --- | --- | --- | --- |
+| `roster.question` | Question | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.decision` | Decision | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.checks_passed` | Passed | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.checks_failed` | Failed | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.checks_none` | No checks found | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.checks_cannot_run` | Can’t run here | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.checks_running` | Running | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.review_approve` | Approved | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.review_changes_requested` | Changes requested | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.review_running` | Reviewing | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.copy_budget` | Copy cannot review all these strings within this task’s token allowance. Ask the coordinator to reduce the scope, or continue without Copy. | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.checks_needs_macos` | Needs macOS | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.checks_needs_network` | Needs network access | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.checks_timeout` | The checks did not finish in time. | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.checks_unavailable` | This runner cannot run the checks. | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.checks_exit` | %s, exit code %d | C · Roster review fixes | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
diff --git a/internal/equipo/chat/roster.go b/internal/equipo/chat/roster.go
index cca934cf..83f0fa7d 100644
--- a/internal/equipo/chat/roster.go
+++ b/internal/equipo/chat/roster.go
@@ -20,7 +20,7 @@ type cardVisibility struct {
func (cardVisibility) TableName() string { return "chat_card_visibility" }
type cardThreadRecord struct {
- MessageID string
+ MessageID string `gorm:"index:chat_card_thread_message"`
ID string `gorm:"primaryKey"`
CardID string `gorm:"index:chat_card_thread_card"`
Person string
@@ -109,41 +109,97 @@ func (s *Store) CardPresentations(ctx context.Context, person string, ids []stri
if err := tx.Where("person = ? AND id IN ? AND "+coordinatorRole, person, ids).Find(&cards).Error; err != nil {
return err
}
+ var visibility []cardVisibility
+ if err := tx.Where("person = ? AND card_id IN ?", person, ids).Find(&visibility).Error; err != nil {
+ return err
+ }
+ aside := map[string]bool{}
+ for _, v := range visibility {
+ aside[v.CardID] = v.Aside
+ }
+ var records []cardThreadRecord
+ if err := tx.Where("person = ? AND card_id IN ?", person, ids).Order("created_at, id").Find(&records).Error; err != nil {
+ return err
+ }
+ links := map[string][]cardThreadRecord{}
+ var answerIDs, turnIDs, stepIDs []string
for _, c := range cards {
- p := CardPresentation{}
- if c.Kind == wire.CardTask {
- var err error
- p.Coverage, err = cardCopyCoverage(tx, c.TaskID)
- if err != nil {
- return err
+ if c.Kind == wire.CardQuestion && c.AnswerMessage != "" {
+ answerIDs = append(answerIDs, c.AnswerMessage)
+ }
+ }
+ var answers []messageRecord
+ if len(answerIDs) > 0 {
+ if err := tx.Where("person = ? AND id IN ?", person, answerIDs).Find(&answers).Error; err != nil {
+ return err
+ }
+ }
+ answerByID := map[string]messageRecord{}
+ for _, m := range answers {
+ answerByID[m.ID] = m
+ }
+ for _, c := range cards {
+ if m, ok := answerByID[c.AnswerMessage]; ok {
+ links[c.ID] = append(links[c.ID], cardThreadRecord{TurnID: m.TurnID, MessageID: m.ID})
+ }
+ }
+ for _, link := range records {
+ links[link.CardID] = append(links[link.CardID], link)
+ }
+ for _, ls := range links {
+ for _, l := range ls {
+ if l.TurnID != "" {
+ turnIDs = append(turnIDs, l.TurnID)
+ } else if l.StepID != "" {
+ stepIDs = append(stepIDs, l.StepID)
}
}
- var vs []cardVisibility
- if err := tx.Where("person = ? AND card_id = ?", person, c.ID).Find(&vs).Error; err != nil {
+ }
+ var turns []turnRecord
+ var messages []messageRecord
+ if len(turnIDs) > 0 {
+ if err := tx.Where("person = ? AND id IN ?", person, turnIDs).Find(&turns).Error; err != nil {
return err
}
- if len(vs) > 0 {
- p.Aside = vs[0].Aside
+ if err := tx.Where("person = ? AND turn_id IN ?", person, turnIDs).Order("seq").Find(&messages).Error; err != nil {
+ return err
}
- var links []cardThreadRecord
- if err := tx.Where("person = ? AND card_id = ?", person, c.ID).Order("created_at, id").Find(&links).Error; err != nil {
+ }
+ turnByID := map[string]turnRecord{}
+ for _, turn := range turns {
+ turnByID[turn.ID] = turn
+ }
+ messagesByTurn := map[string][]messageRecord{}
+ for _, m := range messages {
+ messagesByTurn[m.TurnID] = append(messagesByTurn[m.TurnID], m)
+ }
+ var steps []stepRecord
+ if len(stepIDs) > 0 {
+ if err := tx.Where("person = ? AND id IN ?", person, stepIDs).Find(&steps).Error; err != nil {
return err
}
- if c.AnswerMessage != "" && c.Kind == wire.CardQuestion {
- var m messageRecord
- if err := tx.Where("person = ? AND id = ?", person, c.AnswerMessage).First(&m).Error; err != nil {
+ }
+ stepByID := map[string]stepRecord{}
+ for _, step := range steps {
+ stepByID[step.ID] = step
+ }
+ for _, c := range cards {
+ p := CardPresentation{Aside: aside[c.ID]}
+ if c.Kind == wire.CardTask {
+ var err error
+ p.Coverage, err = cardCopyCoverage(tx, c.TaskID)
+ if err != nil {
return err
}
- links = append([]cardThreadRecord{{TurnID: m.TurnID, MessageID: m.ID}}, links...)
}
- for _, link := range links {
+ for _, link := range links[c.ID] {
+ // A retained reply can outlive its execution record. Keep its
+ // text and clear pending state when that record is absent.
+ p.Waiting, p.TurnID, p.StepID, p.ThreadState = false, "", "", ""
+ p.Activity = nil
if link.TurnID != "" {
p.Turns = append(p.Turns, link.TurnID)
- var ms []messageRecord
- if err := tx.Where("person = ? AND turn_id = ?", person, link.TurnID).Order("seq").Find(&ms).Error; err != nil {
- return err
- }
- for _, m := range ms {
+ for _, m := range messagesByTurn[link.TurnID] {
if m.Role == wire.RolePerson && m.ID != link.MessageID {
continue
}
@@ -152,24 +208,19 @@ func (s *Store) CardPresentations(ctx context.Context, person string, ids []stri
}
p.Thread = append(p.Thread, CardThreadTurn{Own: m.Role == wire.RolePerson, Text: m.Text, At: m.CreatedAt})
}
- var turn turnRecord
- if err := tx.Where("person = ? AND id = ?", person, link.TurnID).First(&turn).Error; err != nil {
- return err
+ if turn, ok := turnByID[link.TurnID]; ok {
+ p.Waiting = turn.State == wire.TurnQueued || turn.State == wire.TurnRunning || turn.State == wire.TurnWaiting
+ p.TurnID, p.ThreadState = turn.ID, turn.State
}
- p.Waiting = turn.State == wire.TurnQueued || turn.State == wire.TurnRunning || turn.State == wire.TurnWaiting
- p.TurnID = turn.ID
- p.ThreadState = turn.State
} else {
p.Thread = append(p.Thread, CardThreadTurn{Own: true, Text: link.Text, At: link.CreatedAt})
- p.StepID = link.StepID
- var step stepRecord
- if err := tx.First(&step, "id = ?", link.StepID).Error; err != nil {
- return err
- }
- p.Waiting = step.State == wire.StepQueued || step.State == wire.StepRunning
- p.Activity = decodeActivity(step.Activity)
- if step.Summary != "" {
- p.Thread = append(p.Thread, CardThreadTurn{Text: step.Summary, At: step.UpdatedAt})
+ if step, ok := stepByID[link.StepID]; ok {
+ p.StepID = step.ID
+ p.Waiting = step.State == wire.StepQueued || step.State == wire.StepRunning
+ p.Activity = decodeActivity(step.Activity)
+ if step.Summary != "" {
+ p.Thread = append(p.Thread, CardThreadTurn{Text: step.Summary, At: step.UpdatedAt})
+ }
}
}
}
diff --git a/internal/equipo/chat/roster_revision_test.go b/internal/equipo/chat/roster_revision_test.go
new file mode 100644
index 00000000..fc178aa7
--- /dev/null
+++ b/internal/equipo/chat/roster_revision_test.go
@@ -0,0 +1,101 @@
+package chat
+
+import (
+ "amadan.net/oficina/equipo/internal/wire"
+ "context"
+ "errors"
+ "testing"
+)
+
+func TestRosterReplyAuthority(t *testing.T) {
+ r := newMeteredRig(t)
+ ctx := context.Background()
+ c := cardRecord{ID: "c_reply", Person: hkOwner, Kind: wire.CardQuestion, State: wire.CardAnswered, Options: "[]", Revision: 1}
+ if err := r.s.db.G.Create(&c).Error; err != nil {
+ t.Fatal(err)
+ }
+ if err := r.s.ReplyCard(ctx, hkMember, c.ID, "other", "Reply"); !errors.Is(err, ErrNotFound) {
+ t.Fatalf("other person: %v", err)
+ }
+ r.removed = true
+ if err := r.s.ReplyCard(ctx, hkOwner, c.ID, "removed", "Reply"); !errors.Is(err, ErrForbidden) {
+ t.Fatalf("removed person: %v", err)
+ }
+ r.removed = false
+ for _, state := range []string{wire.CardOpen, wire.CardResolved} {
+ r.s.db.G.Model(&c).Update("state", state)
+ if err := r.s.ReplyCard(ctx, hkOwner, c.ID, "unanswered", "Reply"); !errors.Is(err, ErrCardConflict) {
+ t.Fatalf("%s: %v", state, err)
+ }
+ }
+ for _, table := range []string{"chat_messages", "chat_turns", "chat_card_threads"} {
+ var n int64
+ r.s.db.G.Table(table).Count(&n)
+ if n != 0 {
+ t.Fatalf("refused reply wrote %s", table)
+ }
+ }
+}
+
+func TestRosterStopAuthority(t *testing.T) {
+ r := newMeteredRig(t)
+ ctx := context.Background()
+ turn := turnRecord{ID: "t_stop", Person: hkOwner, State: wire.TurnQueued}
+ if err := r.s.db.G.Create(&turn).Error; err != nil {
+ t.Fatal(err)
+ }
+ if err := r.s.StopConversationTurn(ctx, hkMember, turn.ID); !errors.Is(err, ErrNotFound) {
+ t.Fatalf("other person: %v", err)
+ }
+ r.removed = true
+ if err := r.s.StopConversationTurn(ctx, hkOwner, turn.ID); !errors.Is(err, ErrForbidden) {
+ t.Fatalf("removed: %v", err)
+ }
+ r.removed = false
+ var got turnRecord
+ r.s.db.G.First(&got, "id = ?", turn.ID)
+ if got.State != wire.TurnQueued || len(r.audits) != 0 {
+ t.Fatal("refused stop changed turn")
+ }
+ if err := r.s.StopConversationTurn(ctx, hkOwner, turn.ID); err != nil {
+ t.Fatal(err)
+ }
+ r.s.db.G.First(&got, "id = ?", turn.ID)
+ if got.State != wire.TurnCancelled {
+ t.Fatalf("own stop: %s", got.State)
+ }
+}
+
+func TestRosterPresentationMissingAssociations(t *testing.T) {
+ for _, missing := range []string{"answer", "turn", "step"} {
+ t.Run(missing, func(t *testing.T) {
+ r := newMeteredRig(t)
+ c := cardRecord{ID: "c_missing", Person: hkOwner, Kind: wire.CardQuestion, State: wire.CardAnswered, Options: "[]", AnswerMessage: "m_missing"}
+ if err := r.s.db.G.Create(&c).Error; err != nil {
+ t.Fatal(err)
+ }
+ if missing == "turn" {
+ if err := r.s.db.G.Create(&messageRecord{ID: "m_missing", Person: hkOwner, TurnID: "t_missing", Role: wire.RolePerson, Text: "Keep my answer"}).Error; err != nil {
+ t.Fatal(err)
+ }
+ }
+ if missing == "step" {
+ r.s.db.G.Model(&c).Update("answer_message", "")
+ if err := r.s.db.G.Create(&cardThreadRecord{ID: "ct_missing", CardID: c.ID, Person: hkOwner, StepID: "s_missing", Text: "Keep my note"}).Error; err != nil {
+ t.Fatal(err)
+ }
+ }
+ ps, err := r.s.CardPresentations(context.Background(), hkOwner, []string{c.ID})
+ if err != nil {
+ t.Fatalf("missing %s failed page: %v", missing, err)
+ }
+ p, ok := ps[c.ID]
+ if !ok || p.Waiting {
+ t.Fatalf("missing association lost card or left it waiting: %+v", p)
+ }
+ if missing != "answer" && len(p.Thread) != 1 {
+ t.Fatalf("lost available reply: %+v", p)
+ }
+ })
+ }
+}
diff --git a/internal/equipo/chat_page.go b/internal/equipo/chat_page.go
index c2461c87..0c29dd46 100644
--- a/internal/equipo/chat_page.go
+++ b/internal/equipo/chat_page.go
@@ -262,7 +262,11 @@ func cardView(c wire.Card, choices []string, tasks map[string]wire.Task) chatCar
}
if t.CopyCanSkip {
if s := lastStep(t); s != nil {
- v.HoldReason = reasonLine(s.Reason, "work.reason.other")
+ if s.Reason == "copy_budget" {
+ v.HoldReason = copyText("roster.copy_budget")
+ } else {
+ v.HoldReason = reasonLine(s.Reason, "work.reason.other")
+ }
}
}
v.Task, v.Line, v.Open = &line, t.Title, line.Retry || line.Cancel || line.Merge || line.Recover || line.CopyCanSkip || line.CopyHold
diff --git a/internal/equipo/chat_roster.go b/internal/equipo/chat_roster.go
index e640db2b..68056657 100644
--- a/internal/equipo/chat_roster.go
+++ b/internal/equipo/chat_roster.go
@@ -5,25 +5,33 @@ import (
"amadan.net/oficina/equipo/internal/wire"
"context"
"crypto/rand"
+ "errors"
+ "fmt"
"github.com/go-chi/chi/v5"
"net/http"
"slices"
"strconv"
+ "strings"
)
func (v *chatCard) rosterAuthor(tasks map[string]wire.Task) {
v.Author, v.AuthorIcon, v.Verb = copyText("conversation.coordinator"), "sparkles", copyText("roster.reports")
- if v.Open && !receiptKind(v.Card) {
+ if !receiptKind(v.Card) {
v.Verb = copyText("roster.asks")
}
- if t, ok := tasks[v.TaskID]; ok {
- who := wire.SpecialistEngineering
- if v.Kind == wire.CardResearchSources || v.Kind == wire.CardResearchInventory {
- who = wire.SpecialistResearch
- }
- if !wire.FinalStage(t.Stage) && (t.CopyHold || t.CopyCanSkip) {
+ who := ""
+ switch v.Kind {
+ case wire.CardTask:
+ who = wire.SpecialistEngineering
+ if t, ok := tasks[v.TaskID]; ok && !wire.FinalStage(t.Stage) && (t.CopyHold || t.CopyCanSkip) {
who, v.Verb = wire.SpecialistCopy, copyText("roster.holds")
}
+ case wire.CardDirection:
+ who = wire.SpecialistEngineering
+ case wire.CardResearchSources, wire.CardResearchInventory:
+ who = wire.SpecialistResearch
+ }
+ if who != "" {
v.Author = specialistName(who)
v.AuthorIcon = map[string]string{wire.SpecialistEngineering: "wrench", wire.SpecialistResearch: "search", wire.SpecialistCopy: "type"}[who]
}
@@ -153,10 +161,7 @@ func rosterTrack(t wire.Task) []trackStop {
out[i].Live = false
out[i].At = nil
if out[i].State == "current" {
- out[i].Tone = "positive"
- if t.NeedsYou != "" {
- out[i].Tone = "negative"
- }
+ out[i].Tone = rosterTone(t)
}
}
return out
@@ -174,10 +179,7 @@ func rosterTrack(t wire.Task) []trackStop {
out[i].State = "done"
}
if i == current {
- out[i].State, out[i].Tone = "current", "positive"
- if t.NeedsYou != "" {
- out[i].Tone = "negative"
- }
+ out[i].State, out[i].Tone = "current", rosterTone(t)
}
}
return out
@@ -185,7 +187,11 @@ func rosterTrack(t wire.Task) []trackStop {
func (a *application) chatTurnStop(w http.ResponseWriter, r *http.Request) {
a.chatActionTo(w, r, workBack(r, ""), func(ctx context.Context, address string) error {
- return a.store.Chat().StopConversationTurn(ctx, address, chi.URLParam(r, "id"))
+ err := a.store.Chat().StopConversationTurn(ctx, address, chi.URLParam(r, "id"))
+ if errors.Is(err, chat.ErrTerminal) {
+ return nil
+ }
+ return err
})
}
@@ -201,3 +207,70 @@ func (v chatView) HasOpen() bool {
}
return false
}
+
+func rosterTone(t wire.Task) string {
+ if t.Checks == wire.ChecksFailed || t.Verdict == "changes_requested" {
+ return "negative"
+ }
+ if t.NeedsYou != "" {
+ return "warning"
+ }
+ return "positive"
+}
+
+func (v chatCard) AsideTitle() string {
+ if v.Task != nil {
+ return v.Task.Title
+ }
+ if v.Name != "" {
+ return v.Name
+ }
+ if v.Kind == wire.CardQuestion {
+ return copyText("roster.question")
+ }
+ return copyText("roster.decision")
+}
+
+func (v taskLine) RosterTone() string { return rosterTone(v.Task) }
+func (v taskLine) RosterChecks() string {
+ if v.Step != nil && v.Step.Specialist == wire.SpecialistChecks && (v.Step.State == wire.StepRunning || v.Step.State == wire.StepQueued) {
+ return copyText("roster.checks_running")
+ }
+ return copyText("roster.checks_" + v.Checks)
+}
+func (v taskLine) RosterReview() string {
+ if v.Step != nil && v.Step.Specialist == wire.SpecialistReview && (v.Step.State == wire.StepRunning || v.Step.State == wire.StepQueued) {
+ return copyText("roster.review_running")
+ }
+ return copyText("roster.review_" + v.Verdict)
+}
+
+func (v taskLine) RosterChecksDetail() string {
+ detail := ""
+ switch v.Checks {
+ case wire.ChecksCannotRun:
+ key := map[string]string{"needs_macos": "roster.checks_needs_macos", "needs_network": "roster.checks_needs_network", "checks_timeout": "roster.checks_timeout"}[v.ChecksReason]
+ if key == "" {
+ key = "roster.checks_unavailable"
+ }
+ detail = copyText(key)
+ case wire.ChecksPassed, wire.ChecksFailed:
+ for _, s := range v.Steps {
+ if s.Specialist != wire.SpecialistChecks || s.State != wire.StepDone || s.CandidateSHA != v.CandidateSHA {
+ continue
+ }
+ detail = s.Gate
+ if s.ExitCode != nil && v.Checks == wire.ChecksFailed {
+ detail = fmt.Sprintf(copyText("roster.checks_exit"), s.Gate, *s.ExitCode)
+ }
+ }
+ if v.ChecksSandbox == wire.SandboxNone {
+ detail = outsideSandbox(detail, v.ChecksSandbox)
+ }
+ }
+ if v.Step != nil && v.Step.Specialist == wire.SpecialistChecks && (v.Step.State == wire.StepRunning || v.Step.State == wire.StepQueued) {
+ detail = v.ChecksLine
+ }
+ return strings.TrimPrefix(detail, ", ")
+}
+func (v taskLine) RosterReviewDetail() string { return copyText("work.review." + v.ReviewLabel) }
diff --git a/internal/equipo/chat_roster_test.go b/internal/equipo/chat_roster_test.go
new file mode 100644
index 00000000..ce2748f8
--- /dev/null
+++ b/internal/equipo/chat_roster_test.go
@@ -0,0 +1,42 @@
+package equipo
+
+import (
+ "amadan.net/oficina/equipo/internal/wire"
+ "testing"
+)
+
+func TestRosterStageTone(t *testing.T) {
+ for _, kind := range []string{"", wire.KindExplore} {
+ for _, tc := range []struct{ checks, verdict, needs, tone string }{
+ {wire.ChecksPassed, "approve", wire.NeedsMerge, "warning"},
+ {wire.ChecksCannotRun, "approve", wire.NeedsMacSandbox, "warning"},
+ {wire.ChecksFailed, "approve", wire.NeedsFixRounds, "negative"},
+ {wire.ChecksPassed, "changes_requested", wire.NeedsFixRounds, "negative"},
+ {wire.ChecksPassed, "approve", "", "positive"},
+ } {
+ task := wire.Task{Kind: kind, Stage: wire.StageInReview, Checks: tc.checks, Verdict: tc.verdict, NeedsYou: tc.needs}
+ for _, stop := range rosterTrack(task) {
+ if stop.State == "current" && stop.Tone != tc.tone {
+ t.Errorf("kind %s %+v tone %s want %s", kind, tc, stop.Tone, tc.tone)
+ }
+ }
+ }
+ }
+}
+
+func TestRosterCardAuthorship(t *testing.T) {
+ tasks := map[string]wire.Task{"task": {ID: "task", Stage: wire.StageInReview, CopyHold: true}}
+ for _, tc := range []struct{ kind, state, author, verb string }{
+ {wire.CardQuestion, wire.CardOpen, "Coordinator", "asks"},
+ {wire.CardQuestion, wire.CardAnswered, "Coordinator", "asks"},
+ {wire.CardMerge, wire.CardOpen, "Coordinator", "asks"},
+ {wire.CardTask, wire.CardOpen, "Copy", "is holding"},
+ {wire.CardDirection, wire.CardOpen, "Engineering", "asks"},
+ {wire.CardResearchSources, wire.CardOpen, "Research", "asks"},
+ } {
+ v := cardView(wire.Card{Kind: tc.kind, State: tc.state, TaskID: "task"}, nil, tasks)
+ if v.Author != tc.author || v.Verb != tc.verb {
+ t.Errorf("%s/%s: %s %s", tc.kind, tc.state, v.Author, v.Verb)
+ }
+ }
+}
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index 2389bcac..2743984c 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -67,6 +67,23 @@ var pageCopy = map[string]string{
"roster.finished": "Done", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
"roster.copy_waiting": "Copy review is waiting", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.question": "Question", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.decision": "Decision", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.checks_passed": "Passed", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.checks_failed": "Failed", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.checks_none": "No checks found", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.checks_cannot_run": "Can’t run here", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.checks_running": "Running", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.review_approve": "Approved", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.review_changes_requested": "Changes requested", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.review_running": "Reviewing", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.copy_budget": "Copy cannot review all these strings within this task’s token allowance. Ask the coordinator to reduce the scope, or continue without Copy.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.checks_needs_macos": "Needs macOS", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.checks_needs_network": "Needs network access", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.checks_timeout": "The checks did not finish in time.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.checks_unavailable": "This runner cannot run the checks.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.checks_exit": "%s, exit code %d", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+
"roster.set_aside": "Set aside", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
"roster.aside": "Set aside, still in Needs you", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
"roster.undo": "Undo", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
diff --git a/internal/equipo/icons/icons.go b/internal/equipo/icons/icons.go
index 9df027b1..9a74bf23 100644
--- a/internal/equipo/icons/icons.go
+++ b/internal/equipo/icons/icons.go
@@ -20,6 +20,7 @@ package icons
import "html/template"
var icons = map[string]template.HTML{
+ "hand": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M8 13V5a2 2 0 0 1 4 0v7-9a2 2 0 0 1 4 0v9-6a2 2 0 0 1 4 0v8c0 5-3 8-7 8-3 0-5-1-7-4l-3-4a2 2 0 0 1 3-3l2 2Z"/></svg>`,
"wrench": `<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="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94z"/></svg>`,
"shield": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true" viewBox="0 0 24 24"><path d="M12 3 3 7v5c0 5 9 9 9 9s9-4 9-9V7z"/></svg>`,
"users": `<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="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" /> <path d="M16 3.128a4 4 0 0 1 0 7.744" /> <path d="M22 21v-2a4 4 0 0 0-3-3.87" /> <circle cx="9" cy="7" r="4" /></svg>`,
diff --git a/internal/equipo/migrations/0086_conversation_roster.sql b/internal/equipo/migrations/0086_conversation_roster.sql
index ec250669..8b0a7906 100644
--- a/internal/equipo/migrations/0086_conversation_roster.sql
+++ b/internal/equipo/migrations/0086_conversation_roster.sql
@@ -2,3 +2,5 @@
CREATE TABLE chat_card_visibility (person text, card_id text, aside numeric, updated_at datetime, PRIMARY KEY (person, card_id));
CREATE TABLE chat_card_threads (id text PRIMARY KEY, card_id text, person text, message_id text, turn_id text, step_id text, text text, created_at datetime);
CREATE INDEX chat_card_thread_card ON chat_card_threads(card_id);
+
+CREATE INDEX chat_card_thread_message ON chat_card_threads(message_id);
diff --git a/internal/equipo/migrations/schema.sql b/internal/equipo/migrations/schema.sql
index 4fba469a..c04fcb94 100644
--- a/internal/equipo/migrations/schema.sql
+++ b/internal/equipo/migrations/schema.sql
@@ -697,3 +697,5 @@ CREATE TABLE chat_card_threads (id text PRIMARY KEY, card_id text, person text,
CREATE TABLE chat_card_visibility (person text, card_id text, aside numeric, updated_at datetime, PRIMARY KEY (person, card_id));
CREATE INDEX chat_card_thread_card ON chat_card_threads(card_id);
+
+CREATE INDEX chat_card_thread_message ON chat_card_threads(message_id);
diff --git a/internal/equipo/research_views.go b/internal/equipo/research_views.go
index f8dabb96..b4c3cd8c 100644
--- a/internal/equipo/research_views.go
+++ b/internal/equipo/research_views.go
@@ -2,6 +2,7 @@ package equipo
import (
"fmt"
+ "net/url"
"time"
"amadan.net/oficina/equipo/internal/wire"
@@ -153,3 +154,11 @@ func researchOf(taskID string, r wire.StepResearch) *researchView {
}
return v
}
+
+func (s researchSource) Domain() string {
+ u, err := url.Parse(s.URL)
+ if err != nil || u.Hostname() == "" {
+ return s.ID
+ }
+ return u.Hostname()
+}
diff --git a/internal/equipo/static/equipo.css b/internal/equipo/static/equipo.css
index afefe5ab..38f6c4ea 100644
--- a/internal/equipo/static/equipo.css
+++ b/internal/equipo/static/equipo.css
@@ -1785,16 +1785,17 @@ label[equipo-sp-label] { cursor: pointer; }
[equipo-roster-report-head] h3 { margin: .125rem 0 0; font-size: 1.125rem; font-weight: 650; line-height: 1.3; letter-spacing: -.015em; }
[equipo-roster-report-head] a { color: inherit; text-decoration: none; }
[equipo-roster-stage] { color: var(--rst-text-muted); font-size: var(--rst-fs-xs); font-weight: 650; }
-[equipo-roster-stage]:not([data-needs=""]) { color: var(--rst-tone-negative-fg); }
+[equipo-roster-stage][data-tone="negative"] { color: var(--rst-tone-negative-fg); }
+[equipo-roster-stage][data-tone="warning"] { color: var(--rst-tone-warning-fg); }
[equipo-roster-facts] { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); margin: 0; border-block-start: 1px solid var(--rst-line); padding-block-start: .625rem; }
[equipo-roster-facts] > div { min-inline-size: 0; padding-inline: .875rem; border-inline-end: 1px solid var(--rst-line); }
[equipo-roster-facts] > div:first-child { padding-inline-start: 0; }
[equipo-roster-facts] > div:last-child { border: 0; }
[equipo-roster-facts] dt { color: var(--rst-text-faint); font-size: var(--rst-fs-xs); }
[equipo-roster-facts] dd { margin: 0; font-weight: 600; font-size: var(--rst-fs-sm); overflow-wrap: anywhere; }
-[equipo-roster-facts] small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--rst-text-muted); }
+[equipo-roster-facts] small { display: block; white-space: normal; overflow-wrap: anywhere; color: var(--rst-text-muted); }
[equipo-roster-facts] code { padding: 0; background: none; border-radius: 0; font-size: var(--rst-fs-xs); }
-[equipo-roster-links] { display: flex; flex-wrap: wrap; gap: .375rem .875rem; font-size: var(--rst-fs-sm); color: var(--rst-text-muted); }
+[equipo-roster-links] { align-items: center; display: flex; flex-wrap: wrap; gap: .375rem .875rem; font-size: var(--rst-fs-sm); color: var(--rst-text-muted); }
[equipo-roster-report] [equipo-track-full] { margin: .125rem 0 0; }
[equipo-conversation] [equipo-message="incoming"] { box-sizing: border-box; inline-size: 100%; max-inline-size: 48rem; align-self: center; padding-inline-start: 3rem; }
[equipo-conversation] [equipo-message-meta] strong { display: flex; align-items: center; gap: .75rem; font-weight: 700; color: var(--rst-text); }
@@ -1819,15 +1820,18 @@ label[equipo-sp-label] { cursor: pointer; }
}
[equipo-set-aside] { position: absolute; inset-block-start: .375rem; inset-inline-end: .375rem; z-index: 1; }
[equipo-set-aside] button { display: grid; place-items: center; border: 0; border-radius: var(--rst-radius); background: transparent; color: var(--rst-text-muted); inline-size: 2.25rem; block-size: 2.25rem; cursor: pointer; }
-[equipo-roster-card][data-ask] > [equipo-card-line] { padding-inline-end: 2rem; font-size: 1.125rem; font-weight: 650; line-height: 1.3; }
+[equipo-roster-card][data-ask] > [equipo-card-line] { padding-inline-end: 2rem; font-size: 1rem; font-weight: 450; line-height: 1.5; }
[equipo-roster-card] button:hover { filter: none; background-color: var(--rst-control-face-hover); }
[equipo-set-aside] button:active { background: var(--rst-control-face-press); transform: translateY(1px); }
[equipo-roster-card] button:focus-visible, [equipo-aside-stub] button:focus-visible { outline: 2px solid var(--rst-accent); outline-offset: 2px; }
[equipo-roster-card] button:disabled { cursor: wait; opacity: .55; }
[equipo-roster-card] button[aria-busy="true"] { opacity: 1; }
-[equipo-aside-stub] { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .5rem; padding: .5rem .75rem; border: 1px dashed var(--rst-control-border); border-radius: calc(2 * var(--rst-radius)); }
-[equipo-aside-stub] small { color: var(--rst-text-muted); }
-[equipo-roster-toast] { position: absolute; inset-block-end: 6.5rem; inset-inline: 1rem; margin-inline: auto; max-inline-size: 40rem; padding: .75rem 1rem; border: 1px solid var(--rst-light-rim); border-radius: calc(2 * var(--rst-radius)); background: var(--rst-surface); box-shadow: var(--rst-shadow-pop); z-index: 5; display: flex; gap: .75rem; flex-wrap: wrap; align-items: baseline; }
+[equipo-aside-stub] { display: flex; align-items: center; gap: .5rem; padding: 0 .75rem; border: 1px dashed var(--rst-control-border); border-radius: calc(2 * var(--rst-radius)); color: var(--rst-text-muted); font-size: var(--rst-fs-xs); white-space: nowrap; }
+[equipo-aside-stub] [data-aside-title] { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; }
+[equipo-aside-stub] small { flex: none; font-size: inherit; }
+[equipo-aside-stub] form { flex: none; margin-inline-start: auto; }
+[equipo-aside-stub] button, [equipo-roster-toast] button { min-block-size: 2.75rem; font-size: inherit; color: inherit; text-decoration: none; }
+[equipo-roster-toast] { position: relative; margin-block-end: .5rem; padding: 0 .75rem; border: 1px solid var(--rst-light-rim); border-radius: calc(2 * var(--rst-radius)); background: var(--rst-surface); box-shadow: var(--rst-shadow-pop); display: flex; gap: .75rem; align-items: center; justify-content: space-between; color: var(--rst-text-muted); font-size: var(--rst-fs-sm); }
[equipo-roster-toast][hidden] { display: none; }
[equipo-card-error] { color: var(--rst-tone-negative-fg); font-size: var(--rst-fs-sm); margin: 0; }
[equipo-card-error] button { margin-inline-start: .5rem; }
@@ -1850,7 +1854,7 @@ label[equipo-sp-label] { cursor: pointer; }
[equipo-thread-sent] { justify-self: end; color: var(--rst-text-faint); font-size: var(--rst-fs-xs); margin-block-start: .25rem; }
[data-question-thread] [data-first] { grid-template-columns: minmax(0,1fr); padding-inline-end: 2rem; }
[data-question-thread] [data-first] [equipo-thread-avatar], [data-question-thread] [data-first] [equipo-thread-who] { display: none; }
-[data-question-thread] [data-first] [equipo-thread-bubble] { padding: 0; border: 0; background: transparent; font-size: 1.125rem; font-weight: 650; line-height: 1.3; max-inline-size: 100%; }
+[data-question-thread] [data-first] [equipo-thread-bubble] { padding: 0; border: 0; background: transparent; font-size: 1rem; font-weight: 450; line-height: 1.5; max-inline-size: 100%; }
[equipo-card] [equipo-mini-composer] { display: block; inline-size: 100%; }
[equipo-mini-pill] { display: flex; gap: .5rem; align-items: end; border: 1px solid var(--rst-control-border); border-radius: calc(4 * var(--rst-radius)); padding: .375rem .5rem .375rem .875rem; background: var(--rst-surface); }
[equipo-mini-pill]:focus-within { border-color: var(--rst-accent); box-shadow: 0 0 0 3px var(--rst-focus-halo); }
@@ -1883,7 +1887,7 @@ label[equipo-sp-label] { cursor: pointer; }
[equipo-roster-findings] { padding-inline-start: 1.5rem; display: grid; gap: .625rem; margin: 0; }
[equipo-roster-findings] li::marker { color: var(--rst-text-muted); font-size: var(--rst-fs-sm); }
[equipo-roster-findings] li[data-gap]::marker { content: "? "; }
-[equipo-roster-findings] a { display: block; color: var(--rst-text-muted); font-size: var(--rst-fs-sm); overflow-wrap: anywhere; }
+[equipo-roster-findings] a { display: inline-flex; align-items: center; margin: .25rem .25rem 0 0; padding: .125rem .5rem; border: 1px solid var(--rst-line); border-radius: 999px; color: var(--rst-text-muted); font-size: var(--rst-fs-xs); text-decoration: none; overflow-wrap: anywhere; }
[equipo-conversation] [equipo-day-box] { background: var(--rst-surface-2); border-radius: calc(8 * var(--rst-radius) / 3); padding: .875rem 1rem; }
[equipo-daybar] { display: flex; gap: .1875rem; block-size: .625rem; margin-block: .75rem; }
[equipo-daybar] i { border-radius: calc(var(--rst-radius) / 2); background: var(--rst-tone-positive-fg); }
@@ -1943,12 +1947,32 @@ label[equipo-sp-label] { cursor: pointer; }
@container roster (max-width:500px) { [equipo-roster-card] [equipo-actions] [rst-btn]:not([rst-btn="primary"]) { font-size: var(--rst-fs-sm); } }
[equipo-conversation]:not([data-task]) [equipo-thinking][data-streaming] [equipo-bubble] { display: block; }
[equipo-thinking][data-streaming] [equipo-turn-stop] { display: none; }
-[equipo-roster-facts] dd, [equipo-roster-facts] code { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+[equipo-roster-facts] dd, [equipo-roster-facts] code { white-space: normal; overflow-wrap: anywhere; }
/* Task menus open deliberately; hidden actions reserve no card space. */
-[equipo-card="task"] [equipo-roster-card] > [equipo-receipt-actions] { display: none; }
-[equipo-card="task"][data-open] [equipo-roster-card] > [equipo-receipt-actions] { display: flex; padding-inline-end: 2.5rem; }
[equipo-card="task"] [equipo-receipt-more] { position: absolute; inset-inline-end: .5rem; inset-block-end: .5rem; display: inline-flex; align-items: center; justify-content: center; inline-size: 2.75rem; min-block-size: 2.75rem; }
-[equipo-roster-links] { padding-inline-end: 2.5rem; }
+[equipo-roster-links] a { text-decoration: none; }
+[equipo-roster-links] a:not([rst-btn]) { color: var(--rst-text-muted); }
[equipo-roster-report-head] [equipo-card-line] { color: var(--rst-text); }
[equipo-roster-stage]::before { content: none; }
[equipo-conversation] [equipo-day-box] { max-inline-size: 48rem; }
+
+[equipo-conversation] [equipo-message-meta] strong { font-size: 1rem; }
+[equipo-roster-report] [equipo-track-full] li[data-tone="warning"] > span { color: var(--rst-tone-warning-fg); }
+[equipo-roster-report] [equipo-track-full] li[data-tone="warning"] [equipo-dot]::after { background: var(--rst-tone-warning-fg); border-color: var(--rst-tone-warning-fg); box-shadow: 0 0 0 4px var(--rst-tone-warning-bg); }
+[equipo-needs-chip] { display: inline-flex; flex: none; align-items: center; gap: .25rem; padding: .125rem .5rem; border: 1px solid transparent; border-radius: 999px; background: var(--rst-tone-warning-bg); color: var(--rst-tone-warning-fg); font-size: var(--rst-fs-xs); font-weight: 650; white-space: nowrap; text-transform: uppercase; }
+[equipo-needs-chip] .icon { inline-size: .875rem; block-size: .875rem; }
+[equipo-copy-hold] [equipo-actions] { display: flex; flex-wrap: wrap; }
+[equipo-copy-hold] [equipo-actions] [rst-btn] { white-space: nowrap; }
+[equipo-copy-hold] [equipo-actions] a[rst-btn="primary"] { order: -1; }
+@container roster (max-width:500px) {
+ [equipo-copy-hold] [equipo-actions] a[rst-btn="primary"] { inline-size: 100%; }
+ [equipo-copy-hold] [equipo-actions] [rst-btn] { white-space: nowrap; }
+}
+/* Before streaming, host, activity, timer and Stop share one baseline. */
+[equipo-conversation]:not([data-task]) [equipo-thinking]:not([data-streaming]) { display: flex; align-items: center; gap: .5rem; }
+[equipo-conversation]:not([data-task]) [equipo-thinking]:not([data-streaming]) [equipo-message-meta] { margin: 0; flex: none; }
+[equipo-conversation]:not([data-task]) [equipo-thinking]:not([data-streaming]) [equipo-message-meta] time { display: none; }
+[equipo-conversation]:not([data-task]) [equipo-thinking]:not([data-streaming]) [equipo-bubble] { display: flex; align-items: center; gap: .5rem; flex: 1; min-inline-size: 0; }
+[equipo-conversation]:not([data-task]) [equipo-thinking]:not([data-streaming]) [data-stream-text] { display: none; }
+[equipo-turn-stop] { flex: none; }
+[equipo-turn-stop] button { text-decoration: none; color: var(--rst-text-muted); font-size: var(--rst-fs-sm); min-block-size: 2.75rem; padding-inline: .5rem; }
diff --git a/internal/equipo/templates/chat.html b/internal/equipo/templates/chat.html
index cde4c1a5..d103bb3b 100644
--- a/internal/equipo/templates/chat.html
+++ b/internal/equipo/templates/chat.html
@@ -2,7 +2,7 @@
{{define "title"}}{{if .Chat.Job}}{{copy "jobs.title"}}{{else}}{{copy "conversation.title"}}{{end}}{{end}}
{{define "card-job"}}{{with .Job}}<input type="hidden" name="from" value="job"><input type="hidden" name="job" value="{{.}}">{{end}}{{end}}
{{define "chat-card"}}<li equipo-card="{{.Kind}}"{{if .Receipt}} equipo-receipt{{end}} id="card-{{.ID}}" data-card="{{.ID}}" data-state="{{.State}}" data-turn-id="{{.TurnID}}">
-{{template "roster-byline" .}}{{if .SetAside}}<section equipo-aside-stub><span>{{.Line}} <small>{{copy "roster.aside"}}</small></span>{{template "roster-undo" .}}</section>{{else}}<section equipo-roster-card{{if .Interactive}} data-ask{{end}}{{if .Receipt}} data-flat{{end}}{{if or (and (not .Open) .Note (not .Presentation.Thread)) .Presentation.Coverage.Skipped}} data-done{{end}}>
+{{template "roster-byline" .}}{{if .SetAside}}<section equipo-aside-stub><span data-aside-title title="{{.AsideTitle}}">{{.AsideTitle}}</span><small>{{copy "roster.aside"}}</small>{{template "roster-undo" .}}</section>{{else}}<section equipo-roster-card{{if .Interactive}} data-ask{{end}}{{if .Receipt}} data-flat{{end}}{{if or (and (not .Open) .Note (not .Presentation.Thread)) .Presentation.Coverage.Skipped}} data-done{{end}}>
{{if .Interactive}}<form method="post" action="/conversation/cards/{{.ID}}/visibility" data-card-form equipo-set-aside><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="aside" value="true">{{template "card-job" .}}<button type="submit" data-set-aside aria-label="{{copy "roster.set_aside"}}" title="{{copy "roster.set_aside"}}" data-busy-label="{{copy "roster.setting_aside"}}">{{icon "x"}}</button></form>{{end}}
{{if .Presentation.Coverage.Skipped}}<p equipo-card-done role="status">{{icon "check"}}{{copy "roster.copy_done"}}</p>{{else if and (not .Open) .Note (ne .Kind "direction")}}<p equipo-card-done role="status">{{icon "check"}}{{.Note}}</p>{{else if and .Task (or .Task.CopyHold .Task.CopyCanSkip)}}{{template "roster-copy-hold" .}}{{else if and .Receipt (eq .Kind "task")}}{{template "work-task-receipt" .}}
{{else if eq .Kind "advice"}}{{if ne .State "resolved"}}<p equipo-card-line data-advice-card>{{icon "lightbulb"}}<span>{{.Line}}</span></p>{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<button rst-btn="primary" name="choice" value="act" type="submit" data-advice-choice="act">{{.ActLabel}}</button><button rst-btn name="choice" value="dismiss" type="submit" data-advice-choice="dismiss">{{.DismissLabel}}</button></form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}{{end}}
@@ -20,19 +20,19 @@
{{else if eq .Kind "merge"}}<p equipo-card-line>{{.Line}}</p>{{with .PreviewURL}}<p equipo-card-note><a href="{{.}}" rel="noopener" target="_blank" data-preview-link>{{copy "chat.card.preview_link"}}</a></p>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{range .Options}}<button rst-btn="{{if eq . "merge"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-merge-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
{{else if or (eq .Kind "merge_ships") (eq .Kind "merge_policy") (eq .Kind "merge_receipt")}}{{if eq .Kind "merge_receipt"}}<div equipo-card-line equipo-markdown data-merge-receipt>{{chatMarkdown .Line}}</div>{{else}}<p equipo-card-line>{{.Line}}</p>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{range .Options}}<button rst-btn="{{if or (eq . "save") (eq . "not_ships")}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-merge-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
{{else if eq .Kind "access"}}<p equipo-card-line>{{.Line}}</p>{{if .Open}}<details equipo-grant><summary rst-btn>{{copy "chat.card.grant"}}</summary><p>{{.GrantHow}}</p><code>amadan agent grant {{.Agent}} {{.Namespace}}</code><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<button rst-btn name="choice" value="check" type="submit" data-grant-check>{{copy "chat.card.grant_check"}}</button></form></details>{{end}}
-{{end}}<p equipo-card-error role="alert" hidden></p></section>{{end}}{{if .Presentation.Coverage.Skipped}}<section equipo-roster-card data-flat>{{template "work-task-receipt" .}}</section>{{end}}{{if not .SetAside}}{{range .ResearchReports}}<div equipo-roster-byline><span equipo-roster-avatar>{{icon "search"}}</span><b>{{copy "work.specialist.research"}}</b><span>{{copy "roster.reports"}}</span>{{with .At}}<time datetime="{{.Format "2006-01-02T15:04:05Z07:00"}}">{{.Format "15:04"}}</time>{{end}}</div><section equipo-roster-card data-research-report><h3>{{copy "roster.research"}}</h3><p>{{.Summary}}</p><ol equipo-roster-findings>{{range .Facts}}<li><div><strong>{{.Label}}</strong> {{.Value}}</div>{{range .Sources}}{{if .URL}}<a href="{{.URL}}" target="_blank" rel="noopener">{{.URL}}</a>{{else}}<span>{{.ID}}</span>{{end}}{{end}}</li>{{end}}{{range .Gaps}}<li data-gap>{{.}}</li>{{end}}</ol><a href="/tasks/{{$.TaskID}}#research-{{.StepID}}">{{copy "roster.research_log"}} ({{len .Fetches}})</a></section>{{end}}{{end}}
+{{end}}<p equipo-card-error role="alert" hidden></p></section>{{end}}{{if .Presentation.Coverage.Skipped}}<section equipo-roster-card data-flat>{{template "work-task-receipt" .}}</section>{{end}}{{if not .SetAside}}{{range .ResearchReports}}<div equipo-roster-byline><span equipo-roster-avatar>{{icon "search"}}</span><b>{{copy "work.specialist.research"}}</b><span>{{copy "roster.reports"}}</span>{{with .At}}<time datetime="{{.Format "2006-01-02T15:04:05Z07:00"}}">{{.Format "15:04"}}</time>{{end}}</div><section equipo-roster-card data-research-report><h3>{{copy "roster.research"}}</h3><p>{{.Summary}}</p><ol equipo-roster-findings>{{range .Facts}}<li><div><strong>{{.Label}}</strong> {{.Value}}</div>{{range .Sources}}{{if .URL}}<a href="{{.URL}}" title="{{.URL}}" target="_blank" rel="noopener">{{.Domain}}</a>{{else}}<span>{{.ID}}</span>{{end}}{{end}}</li>{{end}}{{range .Gaps}}<li data-gap>{{.}}</li>{{end}}</ol><a href="/tasks/{{$.TaskID}}#research-{{.StepID}}">{{copy "roster.research_log"}} ({{len .Fetches}})</a></section>{{end}}{{end}}
</li>{{end}}
-{{define "roster-copy-hold"}}<div equipo-copy-hold><span equipo-roster-stage>{{copy "roster.copy_waiting"}}</span><h3>{{.Line}}</h3><p>{{.HoldReason}}</p>{{with .Presentation.Coverage}}<div equipo-copy-meter>{{if .Known}}{{if .Total}}<meter min="0" max="{{.Total}}" value="{{.Reviewed}}" aria-label="{{printf (copy "roster.copy_count") .Reviewed .Total}}"></meter>{{end}}<span>{{printf (copy "roster.copy_count") .Reviewed .Total}}</span>{{else}}<span>{{copy "roster.copy_coverage"}}</span>{{end}}{{with .Since}}<small>{{printf (copy "roster.copy_since") (.Format "15:04")}}</small>{{end}}</div>{{end}}<div equipo-actions>{{if .Task.CopyCanSkip}}<form method="post" action="/conversation/tasks/{{.TaskID}}/continue-without-copy" data-card-form><button rst-btn="primary" type="submit" data-copy-continue>{{copy "copy.continue"}}</button></form>{{end}}<a rst-btn href="/conversation?about={{.TaskID}}">{{copy "work.decide.ask_coordinator"}}</a><a equipo-link href="/tasks/{{.TaskID}}">{{copy "roster.open_task"}}</a></div></div>{{end}}
-{{define "roster-thread-turns"}}{{range .Presentation.Thread}}<div equipo-thread-turn{{if .Own}} data-own{{end}}>{{if not .Own}}<span equipo-thread-avatar{{if eq $.AuthorIcon "sparkles"}} equipo-coordinator-mark{{end}}>{{if eq $.AuthorIcon "sparkles"}}{{template "roster-mark" .}}{{else}}{{icon $.AuthorIcon}}{{end}}</span>{{end}}<div equipo-thread-bubble><div equipo-thread-who>{{if .Own}}{{copy "work.summary.you"}}{{else}}{{$.Author}}{{end}} <time datetime="{{.At.Format "2006-01-02T15:04:05Z07:00"}}">{{.At.Format "15:04"}}</time></div><div equipo-thread-text equipo-markdown>{{chatMarkdown .Text}}</div></div>{{if .Own}}<small equipo-thread-sent>{{copy "roster.sent"}}</small>{{end}}</div>{{end}}{{with .ThreadError}}<p equipo-thread-error role="alert">{{.}}</p>{{end}}{{if .Presentation.Waiting}}<div equipo-thread-wait role="status"><span equipo-reading-dots aria-hidden="true"><i></i><i></i><i></i></span><span>{{if .ThreadActivity}}{{.ThreadActivity}}{{else}}{{printf (copy "roster.waiting") .Author}}{{end}}</span><div equipo-thread-draft></div></div>{{end}}{{end}}
+{{define "roster-copy-hold"}}<div equipo-copy-hold><span equipo-roster-stage>{{copy "roster.copy_waiting"}}</span><h3>{{.Line}}</h3><p>{{.HoldReason}}</p>{{with .Presentation.Coverage}}<div equipo-copy-meter>{{if .Known}}{{if .Total}}<meter min="0" max="{{.Total}}" value="{{.Reviewed}}" aria-label="{{printf (copy "roster.copy_count") .Reviewed .Total}}"></meter>{{end}}<span>{{printf (copy "roster.copy_count") .Reviewed .Total}}</span>{{else}}<span>{{copy "roster.copy_coverage"}}</span>{{end}}{{with .Since}}<small>{{printf (copy "roster.copy_since") (.Format "15:04")}}</small>{{end}}</div>{{end}}<div equipo-actions>{{if .Task.CopyCanSkip}}<form method="post" action="/conversation/tasks/{{.TaskID}}/continue-without-copy" data-card-form><button rst-btn type="submit" data-copy-continue>{{copy "copy.continue"}}</button></form>{{end}}<a rst-btn="primary" href="/conversation?about={{.TaskID}}">{{copy "work.decide.ask_coordinator"}}</a></div></div>{{end}}
+{{define "roster-thread-turns"}}{{range .Presentation.Thread}}<div equipo-thread-turn{{if .Own}} data-own{{end}}>{{if not .Own}}<span equipo-thread-avatar{{if eq $.AuthorIcon "sparkles"}} equipo-coordinator-mark{{end}}>{{if eq $.AuthorIcon "sparkles"}}{{template "roster-mark" .}}{{else}}{{icon $.AuthorIcon}}{{end}}</span>{{end}}<div equipo-thread-bubble>{{if not .Own}}<div equipo-thread-who>{{$.Author}} <time datetime="{{.At.Format "2006-01-02T15:04:05Z07:00"}}">{{.At.Format "15:04"}}</time></div>{{end}}<div equipo-thread-text equipo-markdown>{{chatMarkdown .Text}}</div></div>{{if .Own}}<small equipo-thread-sent>{{copy "roster.sent"}}</small>{{end}}</div>{{end}}{{with .ThreadError}}<p equipo-thread-error role="alert">{{.}}</p>{{end}}{{if .Presentation.Waiting}}<div equipo-thread-wait role="status"><span equipo-reading-dots aria-hidden="true"><i></i><i></i><i></i></span><span>{{if .ThreadActivity}}{{.ThreadActivity}}{{else}}{{printf (copy "roster.waiting") .Author}}{{end}}</span><div equipo-thread-draft></div></div>{{end}}{{end}}
{{define "roster-undo"}}<form method="post" action="/conversation/cards/{{.ID}}/visibility" data-card-form><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="aside" value="false">{{template "card-job" .}}<button equipo-link type="submit" data-aside-undo data-busy-label="{{copy "roster.restoring"}}">{{copy "roster.undo"}}</button></form>{{end}}
{{define "roster-byline"}}<div equipo-roster-byline><span equipo-roster-avatar{{if eq .AuthorIcon "sparkles"}} equipo-coordinator-mark{{end}}>{{if eq .AuthorIcon "sparkles"}}{{template "roster-mark" .}}{{else}}{{icon .AuthorIcon}}{{end}}</span><b>{{.Author}}</b><span>{{.Verb}}</span><time datetime="{{.BylineAt.Format "2006-01-02T15:04:05Z07:00"}}">{{.BylineAt.Format "15:04"}}</time></div>{{end}}
{{define "roster-mark"}}<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3c1.1 5.8 3.2 7.9 9 9-5.8 1.1-7.9 3.2-9 9-1.1-5.8-3.2-7.9-9-9 5.8-1.1 7.9-3.2 9-9Z"/></svg>{{end}}
{{define "work-task-receipt"}}{{$card := .}}{{with .Task}}<div equipo-roster-report{{if $card.SlimReport}} data-slim{{end}}>
-<div equipo-roster-report-head><div><span equipo-roster-stage equipo-stage data-stage="{{.Stage}}" data-needs="{{.NeedsYou}}">{{.StageLine}}</span><h3 equipo-card-line><a href="/tasks/{{.ID}}">{{.Title}}</a></h3></div>{{if .NeedsYou}}<span rst-badge="warning">{{copy "nav.needs-you"}}</span>{{end}}</div>
+<div equipo-roster-report-head><div><span equipo-roster-stage equipo-stage data-stage="{{.Stage}}" data-tone="{{.RosterTone}}">{{.StageLine}}</span><h3 equipo-card-line><a href="/tasks/{{.ID}}">{{.Title}}</a></h3></div>{{if .NeedsYou}}<span equipo-needs-chip>{{icon "hand"}}{{copy "nav.needs-you"}}</span>{{end}}</div>
{{if and (ne .Stage "cancelled") (not $card.SlimReport)}}{{template "track-full" .}}{{end}}{{with $card.ExplorationSummary}}<p equipo-exploration-summary>{{.}}</p>{{end}}
-<dl equipo-roster-facts>{{if .ChecksLine}}<div><dt>{{copy "roster.checks"}}</dt><dd data-checks title="{{.ChecksLine}}">{{.ChecksLine}}</dd></div>{{end}}{{if .ReviewLine}}<div><dt>{{copy "roster.review"}}</dt><dd data-verdict title="{{.ReviewLine}}">{{.ReviewLine}}</dd></div>{{end}}{{if .Branch}}<div><dt>{{copy "roster.branch"}}</dt><dd><code title="{{.Branch}}">{{.Branch}}</code></dd><small title="{{.CandidateSHA}}">{{short .CandidateSHA}}</small></div>{{end}}</dl>
-{{if .MergeDropped}}<p equipo-card-note>{{copy "work.tl.merge_dropped"}}</p>{{end}}<div equipo-roster-links><a href="/tasks/{{.ID}}">{{copy "roster.open_task"}}</a>{{if and .Pushed (not .MergedLine)}}<span data-pushed><span>{{.Pushed}}</span></span><a href="{{.URL}}" rel="noopener" target="_blank" data-open-amadan>{{copy "work.open"}}</a>{{end}}{{if .MergedLine}}<span data-merged><span>{{.MergedLine}}</span> <a href="{{.RepoURL}}" rel="noopener" target="_blank" data-open-amadan>{{copy "work.open"}}</a></span>{{end}}{{if .PreviewURL}}<a href="{{.PreviewURL}}" rel="noopener" target="_blank" data-preview>{{copy "chat.card.preview_link"}}</a>{{end}}</div>
-</div>{{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}}
+<dl equipo-roster-facts>{{if .ChecksLine}}<div><dt>{{copy "roster.checks"}}</dt><dd data-checks>{{.RosterChecks}}</dd>{{with .RosterChecksDetail}}<small>{{.}}</small>{{end}}</div>{{end}}{{if .ReviewLine}}<div><dt>{{copy "roster.review"}}</dt><dd data-verdict>{{.RosterReview}}</dd>{{with .RosterReviewDetail}}<small>{{.}}</small>{{end}}</div>{{end}}{{if .Branch}}<div><dt>{{copy "roster.branch"}}</dt><dd><code title="{{.Branch}}">{{.Branch}}</code></dd><small title="{{.CandidateSHA}}">{{short .CandidateSHA}}</small></div>{{end}}</dl>
+{{if .MergeDropped}}<p equipo-card-note>{{copy "work.tl.merge_dropped"}}</p>{{end}}<div equipo-roster-links><a rst-btn href="/tasks/{{.ID}}">{{copy "roster.open_task"}}</a>{{if and .Pushed (not .MergedLine)}}<a href="{{.URL}}" rel="noopener" target="_blank" data-open-amadan>{{copy "work.open"}}</a>{{end}}{{if .MergedLine}}<span data-merged><span>{{.MergedLine}}</span> <a href="{{.RepoURL}}" rel="noopener" target="_blank" data-open-amadan>{{copy "work.open"}}</a></span>{{end}}{{if .PreviewURL}}<a href="{{.PreviewURL}}" rel="noopener" target="_blank" data-preview>{{copy "chat.card.preview_link"}}</a>{{end}}</div>
+</div>{{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 "chat-lines"}}{{$address := .Address}}{{range .Lines}}
{{if .CardOnly}}{{range .Cards}}{{template "chat-card" .}}{{end}}{{else}}
@@ -65,7 +65,7 @@
<template equipo-own-template><li equipo-message="own" data-message=""><div equipo-message-meta><strong equipo-visually-hidden>{{.Address}}</strong><time></time></div><div equipo-message-files hidden></div><div equipo-bubble><p equipo-message-body></p></div></li></template>
<template equipo-file-template><a equipo-file-chip href="" target="_blank" rel="noopener" data-attachment="">{{icon "file-text"}}<span equipo-file-name></span><span equipo-file-size></span></a></template>
<template equipo-chip-template><li equipo-chip data-state="uploading"><span equipo-chip-thumb>{{icon "file-text"}}</span><span equipo-chip-text><span equipo-chip-name></span><span equipo-chip-note></span></span><span equipo-chip-progress role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><i></i></span><button type="button" equipo-chip-remove>{{icon "x"}}</button></li></template>
-<template equipo-thinking-template><li equipo-message="incoming" equipo-thinking data-turn="" data-started="" aria-busy="true"><div equipo-message-meta><strong><span equipo-coordinator-mark>{{template "roster-mark" .}}</span>{{copy "conversation.coordinator"}}</strong><time></time></div><div equipo-bubble><div equipo-message-body equipo-markdown data-stream-text></div><p equipo-activity-line><span equipo-activity>{{copy "chat.activity.thinking"}}</span><span equipo-activity-sep aria-hidden="true">·</span><span equipo-elapsed></span></p><form method="post" data-card-form equipo-turn-stop hidden><button equipo-link type="submit" data-turn-stop data-busy-label="{{copy "roster.stopping"}}">{{copy "roster.stop"}}</button></form></div></li></template>
+<template equipo-thinking-template><li equipo-message="incoming" equipo-thinking data-turn="" data-started="" aria-busy="true"><div equipo-message-meta><strong><span equipo-coordinator-mark>{{template "roster-mark" .}}</span>{{copy "conversation.coordinator"}}</strong><time></time></div><div equipo-bubble><div equipo-message-body equipo-markdown data-stream-text></div><p equipo-activity-line><span equipo-activity>{{copy "chat.activity.thinking"}}</span><span equipo-activity-sep aria-hidden="true">·</span><span equipo-elapsed></span></p><form method="post" data-card-form equipo-turn-stop hidden><button rst-btn data-quiet type="submit" data-turn-stop data-busy-label="{{copy "roster.stopping"}}">{{copy "roster.stop"}}</button></form></div></li></template>
<template equipo-ended-template><li equipo-system-note data-ended=""><p></p></li></template>
<ol equipo-feed>
{{range .Chat.Days}}{{template "chat-day" .}}{{end}}
@@ -74,15 +74,15 @@
{{template "chat-lines" (.Chat.Earlier .Address)}}
{{template "chat-lines" (.Chat.Today .Address)}}
{{if not (or .Chat.Days .Chat.Open .Chat.Messages)}}<li data-empty-state="conversation.empty">{{copy "conversation.empty"}}</li>{{end}}
-{{range .Chat.Waiting}}<li equipo-message="incoming" equipo-thinking data-turn="{{.ID}}"{{with .Kind}} data-kind="{{.}}"{{end}} data-started="{{.CreatedAt.UnixMilli}}" aria-busy="true"><div equipo-message-meta><strong><span equipo-coordinator-mark>{{template "roster-mark" .}}</span>{{copy "conversation.coordinator"}}</strong><time></time></div><div equipo-bubble><div equipo-message-body equipo-markdown data-stream-text></div><p equipo-activity-line><span equipo-activity>{{if eq .Kind "move_in"}}{{copy "chat.moving_in"}}{{else if eq .Kind "explore"}}{{copy "chat.exploring"}}{{else}}{{copy "chat.activity.thinking"}}{{end}}</span><span equipo-activity-sep aria-hidden="true">·</span><span equipo-elapsed></span></p><form method="post" action="/conversation/turns/{{.ID}}/stop" data-card-form equipo-turn-stop>{{with $.Chat.Job}}<input type="hidden" name="from" value="job"><input type="hidden" name="job" value="{{.ID}}">{{end}}<button equipo-link type="submit" data-turn-stop data-busy-label="{{copy "roster.stopping"}}">{{copy "roster.stop"}}</button></form></div></li>{{end}}
+{{range .Chat.Waiting}}<li equipo-message="incoming" equipo-thinking data-turn="{{.ID}}"{{with .Kind}} data-kind="{{.}}"{{end}} data-started="{{.CreatedAt.UnixMilli}}" aria-busy="true"><div equipo-message-meta><strong><span equipo-coordinator-mark>{{template "roster-mark" .}}</span>{{copy "conversation.coordinator"}}</strong><time></time></div><div equipo-bubble><div equipo-message-body equipo-markdown data-stream-text></div><p equipo-activity-line><span equipo-activity>{{if eq .Kind "move_in"}}{{copy "chat.moving_in"}}{{else if eq .Kind "explore"}}{{copy "chat.exploring"}}{{else}}{{copy "chat.activity.thinking"}}{{end}}</span><span equipo-activity-sep aria-hidden="true">·</span><span equipo-elapsed></span></p><form method="post" action="/conversation/turns/{{.ID}}/stop" data-card-form equipo-turn-stop>{{with $.Chat.Job}}<input type="hidden" name="from" value="job"><input type="hidden" name="job" value="{{.ID}}">{{end}}<button rst-btn data-quiet type="submit" data-turn-stop data-busy-label="{{copy "roster.stopping"}}">{{copy "roster.stop"}}</button></form></div></li>{{end}}
{{with .Chat.NoConnection}}<li equipo-card="no_connection" data-no-connection="{{.TurnID}}"><p equipo-card-line>{{.Line}}</p><p equipo-actions><a rst-btn="primary" href="/conversation/settings/connections/add" data-add-connection>{{copy "chat.no_connection.add"}}</a></p></li>{{end}}
{{with .Chat.Ended}}<li equipo-system-note data-ended="{{.ID}}"><p>{{copy .Key}}</p></li>{{end}}
</ol>
</section>
</div>
-<div equipo-roster-toast role="status" hidden></div>
<div equipo-announcements role="status" aria-live="polite" aria-atomic="false"></div>
<div id="chat-composer">
+<div equipo-roster-toast role="status" hidden></div>
{{with .Chat.Job}}<form id="composer" equipo-form equipo-composer method="post" action="/jobs/{{.ID}}/messages" data-job-composer>
<input type="hidden" name="request_id" value="{{$.RequestID}}">
<div equipo-pill>
diff --git a/internal/thintest/pages_test.go b/internal/thintest/pages_test.go
index da8e8ca9..70b8ad93 100644
--- a/internal/thintest/pages_test.go
+++ b/internal/thintest/pages_test.go
@@ -77,14 +77,14 @@ func TestPagesTasksAndProjects(t *testing.T) {
base, cand := strings.Repeat("1", 40), "abcdef0"+strings.Repeat("2", 33)
r.step("r-p1", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: base, CandidateSHA: cand})
page := r.get(owner, "/conversation", 200)
- if !strings.Contains(page, `equipo-card="task" equipo-receipt`) || !strings.Contains(page, "Swipe back does nothing") || !strings.Contains(page, `data-task-cancel`) || strings.Contains(page, "data-open-amadan") || strings.Contains(page, "data-task-retry") {
+ if !strings.Contains(page, `equipo-card="task" equipo-receipt`) || !strings.Contains(page, "Swipe back does nothing") || strings.Contains(page, `data-task-cancel`) || !strings.Contains(page, `/tasks/`+id) || strings.Contains(page, "data-open-amadan") || strings.Contains(page, "data-task-retry") {
t.Fatalf("running task card: %s", page)
}
r.step("r-p2", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepDone, BaseSHA: base, CandidateSHA: cand, Pushed: true, Termination: true, Summary: "EdgeSwipe goes back now.", LogTail: "Edit panes/swipe.go"})
r.wait("pushed", func(c *Conversation) bool { return c.Tasks[id].URL != "" })
task, _ := r.client.Task(r.ctx, id)
page = r.get(owner, "/conversation", 200)
- for _, want := range []string{`data-open-amadan`, `href="` + task.URL + `" rel="noopener" target="_blank"`, "Pushed " + task.Branch + " at abcdef0"} {
+ for _, want := range []string{`data-open-amadan`, `href="` + task.URL + `" rel="noopener" target="_blank"`, task.Branch, "abcdef0"} {
if !strings.Contains(page, want) {
t.Fatalf("pushed card lacks %q", want)
}
@@ -98,7 +98,7 @@ func TestPagesTasksAndProjects(t *testing.T) {
}
r.checks("r-pc", c, wire.ChecksPassed, exit(0), "", "ok\n")
rv := r.dispatched(wire.SpecialistReview, base, cand, 0)
- if page = r.get(owner, "/conversation", 200); !strings.Contains(page, "Checks passed (make ci)") || !strings.Contains(page, "Reviewing…") || strings.Contains(page, "data-merge") {
+ if page = r.get(owner, "/conversation", 200); !strings.Contains(page, "data-checks>Passed</dd><small>make ci</small>") || !strings.Contains(page, "data-verdict>Reviewing</dd>") || strings.Contains(page, "data-merge") {
t.Fatalf("card while review runs: %s", page)
}
r.verdict("r-pr", rv, wire.VerdictApprove)
@@ -107,7 +107,7 @@ func TestPagesTasksAndProjects(t *testing.T) {
m := r.dispatched(wire.SpecialistMerge, base, cand, 0)
r.wait("merging", func(c *Conversation) bool { return c.Tasks[id].Stage == wire.StageMerging })
page = r.get(owner, "/conversation", 200)
- for _, want := range []string{">Merging…<", "Checks passed (make ci)", "Approved (same family)", `data-open-amadan>Open on Amadan</a>`} {
+ for _, want := range []string{">Merging…<", "data-checks>Passed</dd><small>make ci</small>", "data-verdict>Approved</dd><small>same family</small>", `data-open-amadan>Open on Amadan</a>`} {
if !strings.Contains(page, want) {
t.Fatalf("merging card lacks %q: %s", want, page)
}
@@ -187,7 +187,7 @@ func TestPagesTasksAndProjects(t *testing.T) {
_, body = r.expect(wire.FrameDispatch)
d2 := body.(*wire.DispatchCommand)
r.step("r-p3", wire.StepReport{TaskID: other, StepID: d2.StepID, Attempt: 1, State: wire.StepFailed, Reason: "provider_failed", Termination: true})
- if p := r.get(owner, "/conversation", 200); !strings.Contains(p, "Stopped: the model connection failed") || !strings.Contains(p, `action="/conversation/tasks/`+other+`/retry"`) {
+ if p := r.get(owner, "/tasks/"+other, 200); !strings.Contains(p, "Stopped: the model connection failed") || !strings.Contains(p, `action="/conversation/tasks/`+other+`/retry"`) {
t.Fatal("failed card lacks its reason or Retry")
}
// A failure without the runner's termination proof offers no Retry.
@@ -196,7 +196,7 @@ func TestPagesTasksAndProjects(t *testing.T) {
_, body = r.expect(wire.FrameDispatch)
d3 := body.(*wire.DispatchCommand)
r.step("r-p4", wire.StepReport{TaskID: third, StepID: d3.StepID, Attempt: 1, State: wire.StepFailed, Reason: "push_failed"})
- if p := r.get(owner, "/conversation", 200); !strings.Contains(p, "Stopped: the push to Amadan failed") || strings.Contains(p, `action="/conversation/tasks/`+third+`/retry"`) {
+ if p := r.get(owner, "/tasks/"+third, 200); !strings.Contains(p, "Stopped: the push to Amadan failed") || strings.Contains(p, `action="/conversation/tasks/`+third+`/retry"`) {
t.Fatal("Retry offered before termination")
}
// A teammate reads the task, without the creator's actions.
diff --git a/internal/thintest/roster_browser_test.go b/internal/thintest/roster_browser_test.go
index b6c69a8b..41e553be 100644
--- a/internal/thintest/roster_browser_test.go
+++ b/internal/thintest/roster_browser_test.go
@@ -26,9 +26,15 @@ func TestBrowserRosterVisual(t *testing.T) {
p.check(`!!document.querySelector('[equipo-roster-facts]')`, "report facts missing")
p.check(`(()=>{const r=document.querySelector("[equipo-roster-report]"),c=r.closest("[equipo-roster-card]");return c.getBoundingClientRect().bottom-r.getBoundingClientRect().bottom<20})()`, "hidden task actions reserve empty space")
p.check(`(()=>{const s=getComputedStyle(document.querySelector('[equipo-coordinator-mark]'));return s.backgroundColor==='rgba(0, 0, 0, 0)' && s.boxShadow==='none'})()`, "coordinator has a tile")
+ p.check(`(()=>{const r=document.querySelector('[equipo-roster-report]');return !r.closest('[data-card]').querySelector('[equipo-receipt-more]') && !r.querySelector('[data-pushed]') && r.querySelector('[equipo-roster-links] a').hasAttribute('rst-btn') && [...r.querySelectorAll('[equipo-roster-links] a')].every(a=>getComputedStyle(a).textDecorationLine==='none')})()`, "report actions drifted")
+ p.check(`document.querySelector('[equipo-roster-report] [aria-current]').dataset.tone==='warning'`, "waiting for you looks failed")
+ p.check(`[...document.querySelectorAll('[equipo-roster-facts] small')].every(e=>getComputedStyle(e).whiteSpace==='normal' && e.scrollWidth<=e.clientWidth+1)`, "fact details truncate")
+ p.check(`(()=>{const c=document.querySelector('[equipo-roster-byline] b'),m=document.querySelector('[equipo-message="incoming"] [equipo-message-meta] strong');return !m||getComputedStyle(c).fontSize===getComputedStyle(m).fontSize})()`, "byline sizes differ")
p.fits("Roster")
p.check(`(()=>{const s=document.querySelector('[equipo-scroll]');s.scrollTop=0;s.dispatchEvent(new Event('scroll'));return true})()`, "top")
p.shot(fmt.Sprintf("roster-%d-%s", width, scheme))
+ p.check(`(()=>{document.querySelector('[equipo-card="merge"]').scrollIntoView({block:'center'});return true})()`, "show coordinator decision")
+ p.shot(fmt.Sprintf("roster-question-%d-%s", width, scheme))
if width == 1280 {
p.check(`(()=>{document.querySelector('[equipo-conversation]').style.inlineSize='440px';return true})()`, "narrow conversation container")
p.check(`getComputedStyle(document.querySelector('[equipo-roster-avatar]')).width==='30px'`, "narrow container did not use phone roster")
@@ -54,6 +60,9 @@ func TestBrowserRosterSetAside(t *testing.T) {
p.wait(`document.querySelector('`+card+` [equipo-aside-stub]')`, "persisted stub")
p.check(`document.querySelector("[equipo-needs-pill]").textContent===`+jsString(before), "set aside changed Needs you count")
p.wait(`document.querySelector('[equipo-roster-toast] [data-aside-undo]')`, "toast undo")
+ p.check(`(()=>{const s=document.querySelector('[equipo-aside-stub]');return parseFloat(getComputedStyle(s).fontSize)<=14 && s.querySelector('[data-aside-title]') && s.getBoundingClientRect().height<=64})()`, "aside is a full question instead of a compact stub")
+ p.check(`(()=>{const t=document.querySelector('[equipo-roster-toast]'),c=document.querySelector('#chat-composer');return t.getBoundingClientRect().left>=c.getBoundingClientRect().left && t.getBoundingClientRect().bottom<=c.getBoundingClientRect().bottom})()`, "toast outside composer column")
+ p.check(`(()=>{const t=document.querySelector('[equipo-roster-toast]').getBoundingClientRect(),b=document.querySelector('[data-turn-stop]')?.getBoundingClientRect();return !b || b.bottom<=t.top || b.top>=t.bottom})()`, "toast covers Stop")
p.shot(fmt.Sprintf("roster-aside-%d-%s", width, scheme))
p.open("/conversation")
p.wait(`document.querySelector('`+card+` [equipo-aside-stub]')`, "stub after reload")
@@ -120,6 +129,8 @@ func TestBrowserRosterSubchat(t *testing.T) {
p.wait(`document.querySelector('[equipo-subchat]').textContent.includes('I’ll start with the sign-in page.')`, "reply inside the sub-chat")
p.open("/conversation")
p.wait(`document.querySelector('[equipo-subchat]').textContent.includes('I’ll start with the sign-in page.')`, "thread after reload")
+ p.check(`!document.querySelector('[equipo-thread-turn][data-own] [equipo-thread-who]')`, "own thread turn repeats a byline")
+ p.check(`parseFloat(getComputedStyle(document.querySelector('[data-first] [equipo-thread-bubble]')).fontWeight)<600`, "question is entirely title weight")
p.fits("sub-chat")
p.shot(fmt.Sprintf("roster-thread-answered-%d-%s", width, scheme))
p.check(`(()=>{const i=document.querySelector('[equipo-mini-composer] textarea');i.value='Keep the email link.';i.dispatchEvent(new Event('input',{bubbles:true}));return true})()`, "follow-up")
@@ -197,18 +208,25 @@ func TestBrowserRosterDecisionStates(t *testing.T) {
}
func TestBrowserRosterThinking(t *testing.T) {
- r := newToolRig(t)
- p := openInner(t, r.inst.URL, r.inst.Cookie(), 390, 844, true, "dark", "reduce")
- defer p.stop()
- p.open("/conversation")
- p.wait(`document.querySelector('[equipo-thinking] [data-turn-stop]')`, "Stop on thinking line")
- p.check(`(()=>{const s=getComputedStyle(document.querySelector('[equipo-thinking] [equipo-sparkle]'));return s.display==='none'})()`, "filled thinking mark remains")
- p.fits("thinking line")
- p.shot("roster-thinking-390-dark")
- p.click(`[equipo-thinking] [data-turn-stop]`)
- cf, _ := r.expect(wire.FrameCancel)
- r.runner.Send(r.ctx, "roster-stop-ack", wire.FrameAck, wire.Ack{ID: cf.ID})
- r.runner.Send(r.ctx, "roster-stop-report", wire.FrameTurn, wire.TurnReport{TurnID: r.turn, Attempt: 1, State: wire.TurnCancelled, Reason: "cancelled"})
- r.wait("stopped", func(c *Conversation) bool { return c.Turns[r.turn].State == wire.TurnCancelled })
- p.wait(`!document.querySelector('[equipo-thinking]')`, "stopped line removed")
+ for _, width := range []int64{1280, 390} {
+ for _, scheme := range []string{"light", "dark"} {
+ t.Run(fmt.Sprintf("%d-%s", width, scheme), func(t *testing.T) {
+ r := newToolRig(t)
+ p := openInner(t, r.inst.URL, r.inst.Cookie(), width, 844, width == 390, scheme, "reduce")
+ defer p.stop()
+ p.open("/conversation")
+ p.wait(`document.querySelector('[equipo-thinking] [data-turn-stop]')`, "Stop on thinking line")
+ p.check(`(()=>{const s=getComputedStyle(document.querySelector('[equipo-thinking] [equipo-sparkle]'));return s.display==='none'})()`, "filled thinking mark remains")
+ p.wait(`(()=>{const c=document.querySelector('[equipo-thinking]'),n=c.querySelector('[equipo-message-meta] strong'),a=c.querySelector('[equipo-phrase]') || c.querySelector('[equipo-activity]'),b=c.querySelector('[data-turn-stop]');return n.getBoundingClientRect().width>0 && Math.abs(n.getBoundingClientRect().top-a.getBoundingClientRect().top)<10 && getComputedStyle(b).boxShadow==='none'})()`, "one thinking line with a quiet Stop")
+ p.fits("thinking line")
+ p.shot(fmt.Sprintf("roster-thinking-%d-%s", width, scheme))
+ p.click(`[equipo-thinking] [data-turn-stop]`)
+ cf, _ := r.expect(wire.FrameCancel)
+ r.runner.Send(r.ctx, "roster-stop-ack", wire.FrameAck, wire.Ack{ID: cf.ID})
+ r.runner.Send(r.ctx, "roster-stop-report", wire.FrameTurn, wire.TurnReport{TurnID: r.turn, Attempt: 1, State: wire.TurnCancelled, Reason: "cancelled"})
+ r.wait("stopped", func(c *Conversation) bool { return c.Turns[r.turn].State == wire.TurnCancelled })
+ p.wait(`!document.querySelector('[equipo-thinking]')`, "stopped line removed")
+ })
+ }
+ }
}
diff --git a/internal/thintest/roster_contract_test.go b/internal/thintest/roster_contract_test.go
index c238af54..9747642d 100644
--- a/internal/thintest/roster_contract_test.go
+++ b/internal/thintest/roster_contract_test.go
@@ -2,6 +2,7 @@ package thintest
import (
"amadan.net/oficina/equipo/internal/wire"
+ "net/url"
"testing"
)
@@ -9,10 +10,13 @@ import (
// composer must queue independently. Otherwise their replies mix threads.
func TestRosterRepliesDoNotBatch(t *testing.T) {
r := newToolRig(t)
- for _, id := range []string{"one"} {
- if res := r.call(id, wire.ToolAskPerson, map[string]any{"question": id + "?", "options": []string{}}); res.Code != "asked" {
- t.Fatal(res)
- }
+ if res := r.call("one", wire.ToolAskPerson, map[string]any{"question": "First question?", "options": []string{}}); res.Code != "asked" {
+ t.Fatal(res)
+ }
+ // A second existing question, independent of the running turn's tool
+ // retry cache, exercises the mounted Reply route for both drawers.
+ if _, err := r.inst.DB.Writer().Exec("INSERT INTO chat_cards(id,person,kind,state,turn_id,question,options,revision,created_at,updated_at,lane) SELECT 'c_second_reply',person,kind,state,turn_id,'Second question?',options,revision,created_at,updated_at,lane FROM chat_cards WHERE kind='question' LIMIT 1"); err != nil {
+ t.Fatal(err)
}
snap, err := r.client.Snapshot(r.ctx)
if err != nil {
@@ -30,13 +34,29 @@ func TestRosterRepliesDoNotBatch(t *testing.T) {
t.Fatal(err)
}
turns = append(turns, answer.Turn.ID)
+ status, _ := r.post(r.inst.Cookie(), "/conversation/cards/"+c.ID+"/reply", url.Values{"request_id": {"followup-" + c.ID}, "body": {"Another detail for " + c.ID}})
+ if status != 303 {
+ t.Fatalf("reply route: %d", status)
+ }
+ var turn string
+ if err := r.inst.DB.Writer().QueryRow("SELECT turn_id FROM chat_card_threads WHERE card_id=?", c.ID).Scan(&turn); err != nil {
+ t.Fatal(err)
+ }
+ turns = append(turns, turn)
}
}
main, err := r.client.Send(r.ctx, "An unrelated request", "unrelated")
if err != nil {
t.Fatal(err)
}
- if len(turns) != 1 || turns[0] == main.Turn.ID || turns[0] == before.Turn.ID {
- t.Fatalf("card replies share a turn: %v, main %s", turns, main.Turn.ID)
+ if len(turns) != 4 {
+ t.Fatalf("want two answers and two replies: %v", turns)
+ }
+ seen := map[string]bool{main.Turn.ID: true, before.Turn.ID: true}
+ for _, id := range turns {
+ if seen[id] {
+ t.Fatalf("card replies share a turn: %v, main %s", turns, main.Turn.ID)
+ }
+ seen[id] = true
}
}
diff --git a/internal/thintest/roster_reports_browser_test.go b/internal/thintest/roster_reports_browser_test.go
index f34dc9d2..7c2a8b96 100644
--- a/internal/thintest/roster_reports_browser_test.go
+++ b/internal/thintest/roster_reports_browser_test.go
@@ -41,13 +41,16 @@ func TestBrowserRosterReports(t *testing.T) {
p.wait(`document.querySelector('[data-research-report]')`, "research findings")
p.check(`document.querySelectorAll('[data-research-report] [equipo-roster-findings] a').length===3 && !!document.querySelector('[data-research-report] [data-gap]')`, "findings lost sources or gaps")
p.check(`(()=>{document.querySelector('[data-research-report]').scrollIntoView({block:'center'});return true})()`, "show Research")
+ p.check(`[...document.querySelectorAll('[equipo-roster-findings] a')].every(a=>a.textContent===new URL(a.href).hostname && getComputedStyle(a).textDecorationLine==='none')`, "Research sources are raw URLs")
p.fits("Research")
p.shot(fmt.Sprintf("roster-research-%d-%s", width, scheme))
p.check(`document.querySelector('[equipo-copy-meter]').textContent.includes('1 of 2 strings reviewed') && document.querySelector('[equipo-copy-meter] meter').value===1`, "Copy coverage")
p.check(`(()=>{document.querySelector('[equipo-copy-hold]').scrollIntoView({block:'center'});return true})()`, "show Copy")
+ p.check(`document.querySelector('[data-copy-continue]').getAttribute('rst-btn')!=='primary' && document.querySelector('[equipo-copy-hold] a[rst-btn="primary"]')?.textContent==='Ask the coordinator'`, "Copy skip encouraged")
+ p.check(`!document.querySelector('[equipo-copy-hold]').textContent.includes('..') && !document.querySelector('[equipo-copy-hold] [equipo-link]')`, "Copy copy or actions drifted")
p.fits("Copy hold")
if width == 390 {
- p.check(`(()=>{const c=document.querySelector("[equipo-copy-hold]"),b=c.querySelector("[data-copy-continue]");return b.getBoundingClientRect().width>=c.clientWidth-2 && b.getBoundingClientRect().height>=44})()`, "phone primary does not span its row")
+ p.check(`(()=>{const c=document.querySelector("[equipo-copy-hold]"),b=c.querySelector('[rst-btn="primary"]');return b.getBoundingClientRect().width>=c.clientWidth-2 && b.getBoundingClientRect().height>=44})()`, "phone primary does not span its row")
}
p.check(`[...document.querySelectorAll("[equipo-roster-card]")].every(c=>c.scrollWidth<=c.clientWidth+1)`, "content overflows a card")
p.shot(fmt.Sprintf("roster-copy-%d-%s", width, scheme))
diff --git a/internal/thintest/roster_routes_test.go b/internal/thintest/roster_routes_test.go
new file mode 100644
index 00000000..6b0f751d
--- /dev/null
+++ b/internal/thintest/roster_routes_test.go
@@ -0,0 +1,76 @@
+package thintest
+
+import (
+ "amadan.net/oficina/equipo/internal/wire"
+ "io"
+ "net/http"
+ "net/url"
+ "strings"
+ "testing"
+)
+
+func TestRosterStopFinishedRedirects(t *testing.T) {
+ r := newToolRig(t)
+ if err := r.runner.Send(r.ctx, "finish-before-stop", wire.FrameReply, wire.Reply{TurnID: r.turn, Attempt: 1, Text: "Finished."}); err != nil {
+ t.Fatal(err)
+ }
+ r.wait("finished", func(c *Conversation) bool { return c.Turns[r.turn].State == wire.TurnReplied })
+ status, location := r.post(r.inst.Cookie(), "/conversation/turns/"+r.turn+"/stop", url.Values{})
+ if status != http.StatusSeeOther || location != "/conversation" {
+ t.Fatalf("finished Stop: %d %s", status, location)
+ }
+}
+
+func TestRosterActionCSRF(t *testing.T) {
+ r := newToolRig(t)
+ if res := r.call("csrf-question", wire.ToolAskPerson, map[string]any{"question": "Which page?", "options": []string{}}); res.Code != "asked" {
+ t.Fatal(res)
+ }
+ snap, err := r.client.Snapshot(r.ctx)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var card wire.Card
+ for _, c := range snap.Cards {
+ if c.Kind == wire.CardQuestion {
+ card = c
+ }
+ }
+ if _, err := r.client.Answer(r.ctx, card.ID, "This one", card.Revision); err != nil {
+ t.Fatal(err)
+ }
+ paths := []string{"/conversation/cards/" + card.ID + "/visibility", "/conversation/cards/" + card.ID + "/reply", "/conversation/turns/" + r.turn + "/stop"}
+ for _, path := range paths {
+ req, _ := http.NewRequest("POST", r.inst.URL+path, strings.NewReader(url.Values{"aside": {"true"}, "revision": {"2"}, "request_id": {"csrf-reply"}, "body": {"Unsafe reply"}}.Encode()))
+ req.AddCookie(r.inst.Cookie())
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ req.Header.Set("Origin", "https://foreign.example")
+ req.Header.Set("Sec-Fetch-Site", "cross-site")
+ res, err := http.DefaultClient.Do(req)
+ if err != nil {
+ t.Fatal(err)
+ }
+ io.Copy(io.Discard, res.Body)
+ res.Body.Close()
+ if res.StatusCode != http.StatusForbidden {
+ t.Fatalf("cross-site %s: %d", path, res.StatusCode)
+ }
+ }
+ var n int
+ for _, q := range []string{"SELECT count(*) FROM chat_card_visibility", "SELECT count(*) FROM chat_card_threads", "SELECT count(*) FROM chat_messages WHERE text='Unsafe reply'", "SELECT count(*) FROM runner_commands WHERE kind='cancel'"} {
+ if err := r.inst.DB.Writer().QueryRow(q).Scan(&n); err != nil {
+ t.Fatal(err)
+ }
+ if n != 0 {
+ t.Fatalf("CSRF changed state: %s", q)
+ }
+ }
+ var state string
+ if err := r.inst.DB.Writer().QueryRow("SELECT state FROM chat_turns WHERE id=?", r.turn).Scan(&state); err != nil {
+ t.Fatal(err)
+ }
+ if state != wire.TurnRunning {
+ t.Fatalf("cross-site Stop changed turn: %s", state)
+ }
+
+}