oficina / equipo Public

Thread card replies and add Copy and Research report shapes

Paul Campbell pushed by paul@keymail.dev f5dd8242eb7ad8139fd07169f611969c0fa7d157 parent 4cd929d
17 files changed, +387 −32
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +5 −0
  • internal/equipo/app.go +1 −0
  • internal/equipo/chat/explore.go +7 −0
  • internal/equipo/chat/roster.go +45 −5
  • internal/equipo/chat/roster_copy.go +52 −0
  • internal/equipo/chat/roster_test.go +31 −0
  • internal/equipo/chat_days.go +2 −0
  • internal/equipo/chat_page.go +9 −1
  • internal/equipo/chat_roster.go +42 −2
  • internal/equipo/copy.go +5 −0
  • internal/equipo/static/chat-anchor.js +3 −3
  • internal/equipo/static/chat-compose.js +12 −0
  • internal/equipo/static/chat-stream.js +8 −2
  • internal/equipo/static/equipo.css +69 −0
  • internal/equipo/templates/chat.html +24 −18
  • internal/thintest/research_pages_test.go +1 −1
  • internal/thintest/roster_browser_test.go +71 −0

CI failed — run details

diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index fdb9178a..2afcf4c7 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -6608,6 +6608,11 @@ records remain unchanged.
| `roster.research_log` | Open the request log | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
| `roster.needs` | %d waiting for you | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.copy_count` | %d of %d strings reviewed | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.stop` | Stop | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.finished` | Done | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.copy_waiting` | Copy review is waiting | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+
## Task 21
Status: DONE_WITH_CONCERNS. Offline 3b acceptance, the complete person API contract
diff --git a/internal/equipo/app.go b/internal/equipo/app.go
index f7886117..66e7f549 100644
--- a/internal/equipo/app.go
+++ b/internal/equipo/app.go
@@ -302,6 +302,7 @@ func RouterWithStore(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logg
r.Get("/conversation/attachments/{id}/preview", a.chatAttachment(true))
r.Post("/conversation/cards/{id}/answer", a.chatCardAnswer)
r.Post("/conversation/cards/{id}/visibility", a.chatCardVisibility)
+ r.Post("/conversation/cards/{id}/reply", a.chatCardReply)
r.Get("/jobs", a.jobsPage)
r.Get("/jobs/{id}", a.jobPage)
r.Post("/jobs/{id}/messages", a.jobSend)
diff --git a/internal/equipo/chat/explore.go b/internal/equipo/chat/explore.go
index b9d0a8d4..6a99c3dd 100644
--- a/internal/equipo/chat/explore.go
+++ b/internal/equipo/chat/explore.go
@@ -245,6 +245,13 @@ func (t *txn) answerDirection(person string, c cardRecord, in wire.AnswerCard) (
if err := t.nextStep(&k, steps, s); err != nil {
return wire.Card{}, wire.Card{}, err
}
+ latest, err := t.steps(k.ID)
+ if err != nil {
+ return wire.Card{}, wire.Card{}, err
+ }
+ if err := t.db.Create(&cardThreadRecord{ID: newID("ct_"), CardID: c.ID, Person: person, StepID: latest[len(latest)-1].ID, Text: note, CreatedAt: t.now()}).Error; err != nil {
+ return wire.Card{}, wire.Card{}, err
+ }
case wire.ChoiceDrop:
if _, err := t.cancelTask(person, k.ID); err != nil {
return wire.Card{}, wire.Card{}, err
diff --git a/internal/equipo/chat/roster.go b/internal/equipo/chat/roster.go
index fe419546..2c6ea1c1 100644
--- a/internal/equipo/chat/roster.go
+++ b/internal/equipo/chat/roster.go
@@ -34,10 +34,12 @@ func (cardThreadRecord) TableName() string { return "chat_card_threads" }
// CardPresentation is browser presentation only. Visibility is separate
// from the decision and never changes a card's revision or authority.
type CardPresentation struct {
- Aside bool
- Thread []CardThreadTurn
- Waiting bool
- TurnID string
+ Coverage CardCopyCoverage
+ Turns []string
+ Aside bool
+ Thread []CardThreadTurn
+ Waiting bool
+ TurnID string
}
type CardThreadTurn struct {
Own bool
@@ -71,7 +73,7 @@ func (s *Store) SetCardAside(ctx context.Context, person, id string, revision in
if err != nil {
return err
}
- if !v.CopyHold {
+ if !v.CopyHold && !v.CopyCanSkip {
return ErrCardConflict
}
}
@@ -101,6 +103,13 @@ func (s *Store) CardPresentations(ctx context.Context, person string, ids []stri
}
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
+ }
+ }
var vs []cardVisibility
if err := tx.Where("person = ? AND card_id = ?", person, c.ID).Find(&vs).Error; err != nil {
return err
@@ -121,6 +130,7 @@ func (s *Store) CardPresentations(ctx context.Context, person string, ids []stri
}
for _, link := range links {
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
@@ -175,3 +185,33 @@ func (s *Store) OpenStandaloneCards(ctx context.Context, person string) (out []w
})
return
}
+
+// ReplyCard continues an answered question in the same private lane.
+// The original decision remains answered; the new message owns its turn.
+func (s *Store) ReplyCard(ctx context.Context, person, id, key, text string) error {
+ text, ok := cleanText(text, 2000)
+ if !ok || key == "" || len(key) > 128 {
+ return ErrInvalid
+ }
+ return s.tx(ctx, func(t *txn) error {
+ if err := s.authority.CurrentPerson(ctx, t.db); err != nil {
+ return err
+ }
+ var c cardRecord
+ if err := t.db.Where("id = ? AND person = ? AND "+coordinatorRole, id, person).First(&c).Error; errors.Is(err, gorm.ErrRecordNotFound) {
+ return ErrNotFound
+ } else if err != nil {
+ return err
+ }
+ if c.Kind != wire.CardQuestion || c.State != wire.CardAnswered {
+ return ErrCardConflict
+ }
+ _, _, err := t.send(c.Lane, person, "thread:"+c.ID+":"+key, text, nil, func(m messageRecord) error {
+ if err := t.db.Create(&cardThreadRecord{ID: newID("ct_"), CardID: c.ID, Person: person, TurnID: m.TurnID, CreatedAt: t.now()}).Error; err != nil {
+ return err
+ }
+ return s.authority.Audit(t.db, person, "card.reply", c.ID)
+ })
+ return err
+ })
+}
diff --git a/internal/equipo/chat/roster_copy.go b/internal/equipo/chat/roster_copy.go
new file mode 100644
index 00000000..82bc8805
--- /dev/null
+++ b/internal/equipo/chat/roster_copy.go
@@ -0,0 +1,52 @@
+package chat
+
+import (
+ "amadan.net/oficina/equipo/internal/wire"
+ "encoding/json"
+ "gorm.io/gorm"
+ "time"
+)
+
+type CardCopyCoverage struct {
+ Known bool
+ Total, Reviewed int
+ Since *time.Time
+}
+
+// Coverage belongs to the newest Copy candidate. A missing extraction is
+// unknown, and repeated review entries count once per extracted key.
+func cardCopyCoverage(tx *gorm.DB, task string) (v CardCopyCoverage, err error) {
+ var steps []stepRecord
+ if err = tx.Where("task_id = ? AND specialist = ?", task, wire.SpecialistCopy).Order("idx DESC").Find(&steps).Error; err != nil || len(steps) == 0 {
+ return
+ }
+ v.Since = steps[0].HeldAt
+ if v.Since == nil && steps[0].Reason != "" {
+ v.Since = &steps[0].UpdatedAt
+ }
+ candidate := steps[0].CandidateSHA
+ for _, s := range steps {
+ if s.CandidateSHA != candidate || s.CopyResult == "" {
+ continue
+ }
+ var result wire.CopyResult
+ if err = json.Unmarshal([]byte(s.CopyResult), &result); err != nil {
+ return
+ }
+ if result.Extraction.Version == 0 {
+ continue
+ }
+ keys, reviewed := map[string]bool{}, map[string]bool{}
+ for _, lit := range result.Extraction.Strings {
+ keys[lit.Key] = true
+ }
+ for _, row := range result.Review.Strings {
+ if keys[row.Key] {
+ reviewed[row.Key] = true
+ }
+ }
+ v.Known, v.Total, v.Reviewed = true, len(keys), len(reviewed)
+ return
+ }
+ return
+}
diff --git a/internal/equipo/chat/roster_test.go b/internal/equipo/chat/roster_test.go
index d6551123..9024015a 100644
--- a/internal/equipo/chat/roster_test.go
+++ b/internal/equipo/chat/roster_test.go
@@ -57,3 +57,34 @@ func TestRosterSetAsideNeverAnswersOrCancels(t *testing.T) {
t.Fatalf("visibility writes not audited: %v", r.audits)
}
}
+
+func TestRosterCopyCoverageKeepsUnknown(t *testing.T) {
+ r := newMeteredRig(t)
+ now := r.s.now()
+ ctx := context.Background()
+ c := cardRecord{ID: "c_copy", Person: hkOwner, Kind: wire.CardTask, TaskID: "tk_copy", State: wire.StageInReview, Revision: 1, CreatedAt: now, UpdatedAt: now}
+ if err := r.s.db.G.Create(&c).Error; err != nil {
+ t.Fatal(err)
+ }
+ step := stepRecord{ID: "s_copy", TaskID: c.TaskID, Idx: 1, Specialist: wire.SpecialistCopy, Person: hkOwner, CandidateSHA: "candidate", CreatedAt: now, UpdatedAt: now}
+ if err := r.s.db.G.Create(&step).Error; err != nil {
+ t.Fatal(err)
+ }
+ read := func() CardPresentation {
+ ps, err := r.s.CardPresentations(ctx, hkOwner, []string{c.ID})
+ if err != nil {
+ t.Fatal(err)
+ }
+ return ps[c.ID]
+ }
+ if got := read(); got.Coverage.Known {
+ t.Fatal("missing extraction became zero")
+ }
+ raw := `{"extraction":{"version":1,"strings":[{"key":"a","text":"One"},{"key":"b","text":"Two"}]},"review":{"version":1,"strings":[{"key":"a","text":"One"},{"key":"a","text":"One"},{"key":"old","text":"Old"}]}}`
+ if err := r.s.db.G.Model(&step).Update("copy_result", raw).Error; err != nil {
+ t.Fatal(err)
+ }
+ if got := read(); !got.Coverage.Known || got.Coverage.Total != 2 || got.Coverage.Reviewed != 1 {
+ t.Fatalf("coverage: %+v", got.Coverage)
+ }
+}
diff --git a/internal/equipo/chat_days.go b/internal/equipo/chat_days.go
index dc73a22f..c9757270 100644
--- a/internal/equipo/chat_days.go
+++ b/internal/equipo/chat_days.go
@@ -70,6 +70,7 @@ func (v chatView) Earlier(address string) chatFeed { return chatFeed{v.Open, add
// there are. A stacked row (decisions, what is still open) puts each
// item on its own line.
type dayRow struct {
+ Count int
Key, Label string
Items []dayItem
More string
@@ -90,6 +91,7 @@ func (r *dayRow) add(it dayItem) {
}
func (r *dayRow) trim() {
+ r.Count = len(r.Items)
if n := len(r.Items) - dayListMax; n > 0 {
r.Items, r.More = r.Items[:dayListMax], fmt.Sprintf(copyText("chat.day.more"), n)
}
diff --git a/internal/equipo/chat_page.go b/internal/equipo/chat_page.go
index 401a343f..48d33d63 100644
--- a/internal/equipo/chat_page.go
+++ b/internal/equipo/chat_page.go
@@ -81,6 +81,8 @@ type chatLine struct {
// chatCard is one card under the message that ends its turn. Line is the
// card's sentence; the forms post to the page routes below.
type chatCard struct {
+ ResearchReports []*researchView
+ ReplyKey string
wire.Card
Line, Change, Agent, Namespace, Note string
Presentation chat.CardPresentation
@@ -235,7 +237,13 @@ func cardView(c wire.Card, choices []string, tasks map[string]wire.Task) chatCar
line := taskLineOf(pt, t.Creator)
line.MergeDropped = dropped
line.richOf(pt, t.Creator, nil, t.UpdatedAt)
- v.Task, v.Line, v.Open = &line, t.Title, line.Retry || line.Cancel || line.Merge || line.Recover
+ line.Track = rosterTrack(pt)
+ v.Task, v.Line, v.Open = &line, t.Title, line.Retry || line.Cancel || line.Merge || line.Recover || t.CopyCanSkip || t.CopyHold
+ for _, step := range t.Steps {
+ if step.Specialist == wire.SpecialistResearch && step.Research != nil {
+ v.ResearchReports = append(v.ResearchReports, researchOf(t.ID, *step.Research))
+ }
+ }
}
}
v.rosterAuthor(tasks)
diff --git a/internal/equipo/chat_roster.go b/internal/equipo/chat_roster.go
index 2faa41c7..58d3086a 100644
--- a/internal/equipo/chat_roster.go
+++ b/internal/equipo/chat_roster.go
@@ -4,8 +4,10 @@ import (
"amadan.net/oficina/equipo/internal/equipo/chat"
"amadan.net/oficina/equipo/internal/wire"
"context"
+ "crypto/rand"
"github.com/go-chi/chi/v5"
"net/http"
+ "slices"
"strconv"
)
@@ -19,7 +21,7 @@ func (v *chatCard) rosterAuthor(tasks map[string]wire.Task) {
if v.Kind == wire.CardResearchSources {
who = wire.SpecialistResearch
}
- if t.CopyHold {
+ if t.CopyHold || t.CopyCanSkip {
who, v.Verb = wire.SpecialistCopy, copyText("roster.holds")
}
v.Author = specialistName(who)
@@ -28,7 +30,7 @@ func (v *chatCard) rosterAuthor(tasks map[string]wire.Task) {
}
func (v chatCard) Interactive() bool {
- return v.Open && (!v.Receipt || v.Task != nil && v.Task.CopyHold)
+ return v.Open && (!v.Receipt || v.Task != nil && (v.Task.CopyHold || v.Task.CopyCanSkip))
}
func (v chatCard) SetAside() bool { return v.Interactive() && v.Presentation.Aside }
@@ -58,7 +60,16 @@ func (a *application) presentRoster(ctx context.Context, address string, view *c
}
for _, c := range cards {
c.Presentation = ps[c.ID]
+ c.ReplyKey = rand.Text()
}
+ turns := map[string]bool{}
+ for _, p := range ps {
+ for _, id := range p.Turns {
+ turns[id] = true
+ }
+ }
+ view.Messages = slices.DeleteFunc(view.Messages, func(m chatLine) bool { return turns[m.TurnID] && len(m.Cards) == 0 && len(m.Receipts) == 0 })
+ view.Waiting = slices.DeleteFunc(view.Waiting, func(t wire.Turn) bool { return turns[t.ID] })
return nil
}
func (a *application) chatCardVisibility(w http.ResponseWriter, r *http.Request) {
@@ -74,3 +85,32 @@ func (a *application) chatCardVisibility(w http.ResponseWriter, r *http.Request)
return a.store.Chat().SetCardAside(ctx, address, chi.URLParam(r, "id"), revision, value == "true")
})
}
+
+func (a *application) chatCardReply(w http.ResponseWriter, r *http.Request) {
+ a.chatActionTo(w, r, workBack(r, r.PostFormValue("task")), func(ctx context.Context, address string) error {
+ return a.store.Chat().ReplyCard(ctx, address, chi.URLParam(r, "id"), r.PostFormValue("request_id"), r.PostFormValue("body"))
+ })
+}
+
+func rosterTrack(t wire.Task) []trackStop {
+ stages := []string{wire.StageNoted, wire.StageInProgress, wire.StageInReview, wire.StageReadyToMerge, wire.StageDone}
+ current := slices.Index(stages, t.Stage)
+ if t.Stage == wire.StageMerging {
+ current = 3
+ }
+ current = max(0, current)
+ out := make([]trackStop, len(stages))
+ for i, s := range stages {
+ out[i] = trackStop{Stage: s, Label: copyText("work.stage." + s), State: "todo"}
+ if i < current {
+ out[i].State = "done"
+ }
+ if i == current {
+ out[i].State, out[i].Tone = "current", "positive"
+ if t.NeedsYou != "" {
+ out[i].Tone = "negative"
+ }
+ }
+ }
+ return out
+}
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index 6f4f3359..feccd23c 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -59,6 +59,11 @@ const BootLog = "Equipo could not start."
// COPY APPROVED BY DELEGATION (Luna pass, 2026-11-01, house rules).
var pageCopy = map[string]string{
+ "roster.copy_count": "%d of %d strings reviewed", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.stop": "Stop", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "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.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/static/chat-anchor.js b/internal/equipo/static/chat-anchor.js
index a6bc5ba8..5c8dcd77 100644
--- a/internal/equipo/static/chat-anchor.js
+++ b/internal/equipo/static/chat-anchor.js
@@ -4,11 +4,11 @@
// already loaded the history back to it.
(function () {
"use strict";
- var m = /^#m-(.+)$/.exec(location.hash);
+ var m = /^#(m|card)-(.+)$/.exec(location.hash);
if (!m) return;
- var id = decodeURIComponent(m[1]);
+ var id = decodeURIComponent(m[2]);
function show() {
- var el = [].find.call(document.querySelectorAll("[data-message]"), function (e) { return e.getAttribute("data-message") === id; });
+ var el = [].find.call(document.querySelectorAll(m[1] === "card" ? "[data-card]" : "[data-message]"), function (e) { return e.getAttribute(m[1] === "card" ? "data-card" : "data-message") === id; });
if (!el) return;
var scroll = el.closest("[equipo-scroll]");
if (scroll) {
diff --git a/internal/equipo/static/chat-compose.js b/internal/equipo/static/chat-compose.js
index 827680c5..97ff436a 100644
--- a/internal/equipo/static/chat-compose.js
+++ b/internal/equipo/static/chat-compose.js
@@ -39,3 +39,15 @@
form.addEventListener("equipo:sent", state);
state();
})();
+
+// Card composers use the main composer's pill and send affordance.
+(function () {
+ "use strict";
+ document.addEventListener("input", function (event) {
+ var form=event.target.closest("[equipo-mini-composer]");if(!form)return;
+ form.toggleAttribute("data-has-content", /\S/.test(event.target.value));
+ });
+ document.addEventListener("toggle", function (event) {
+ if(event.target.matches("[data-direction-thread]") && event.target.open) event.target.querySelector("textarea").focus({preventScroll:true});
+ },true);
+})();
diff --git a/internal/equipo/static/chat-stream.js b/internal/equipo/static/chat-stream.js
index 06d92d70..d2bde991 100644
--- a/internal/equipo/static/chat-stream.js
+++ b/internal/equipo/static/chat-stream.js
@@ -624,6 +624,8 @@
feed.querySelectorAll("[equipo-thinking]:not([data-streaming])").forEach(cycle);
}, 250);
function showDraft(turn) {
+ var sub = feed.querySelector('[data-roster-turn="' + CSS.escape(turn) + '"] [equipo-thread-draft]');
+ if (sub) { sub.textContent = drafts[turn] ? drafts[turn].text : ""; return; }
var el = bubble(turn);
if (!el) return;
var text = drafts[turn] ? drafts[turn].text : "";
@@ -799,12 +801,14 @@
if (more) more.setAttribute("aria-expanded", "true");
});
feed.querySelectorAll("[data-card]").forEach(function (card) {
+ if (card.querySelector("[data-direction-thread][open]")) cardOpen.add(card.dataset.card);
var inputs = {};
card.querySelectorAll("textarea, input:not([type=hidden])").forEach(function (el) { if (el.value) inputs[el.name] = el.value; });
if (Object.keys(inputs).length) cardDrafts.set(card.dataset.card, inputs);
});
next.querySelectorAll("[data-card]").forEach(function (card) {
var old = cardBusy.get(card.dataset.card); if (old) { card.replaceWith(old); return; }
+ var drawer=card.querySelector("[data-direction-thread]"); if(drawer && cardOpen.has(card.dataset.card)) drawer.open=true;
var values = cardDrafts.get(card.dataset.card); if (!values) return;
card.querySelectorAll("textarea, input:not([type=hidden])").forEach(function (el) { if (values[el.name]) { el.value = values[el.name]; el.closest("form").setAttribute("data-has-content", ""); } });
});
@@ -896,6 +900,8 @@
// not the coordinator's, and draws no line here.
return;
}
+ var subchat = (v.turn_id || v.id) && feed.querySelector('[data-roster-turn="' + CSS.escape(v.turn_id || v.id) + '"]');
+ if (subchat && (type === "message" || type === "turn")) { if (type === "message" && v.role === "coordinator") delete drafts[v.turn_id]; refreshSoon(); return; }
if (type === "delta") {
var d = drafts[v.turn_id];
// A new attempt (a failover, a recovery) starts its draft afresh.
@@ -1046,7 +1052,7 @@
});
});
// Card actions preserve the card on failure and expose the result in place.
- var cardBusy = new Map(), cardDrafts = new Map(), toastTimer;
+ var cardBusy = new Map(), cardDrafts = new Map(), cardOpen = new Set(), toastTimer;
function cardSubmit(f, button) {
var card = f.closest("[data-card]"), id = card && card.dataset.card;
if (id && cardBusy.has(id)) return;
@@ -1061,7 +1067,7 @@
if (error) error.hidden = true;
fetch(f.action, { method: "POST", credentials: "same-origin", headers: { "Accept": "application/json" }, body: body })
.then(function (r) { if (!r.ok) throw new Error(r.status === 409 ? "stale" : "card");
- if (id) { cardBusy.delete(id); if (body.get("aside") === null) cardDrafts.delete(id); }
+ if (id) { cardBusy.delete(id); if (body.get("aside") === null) { cardDrafts.delete(id); f.querySelectorAll("textarea").forEach(function (el) { el.value=""; }); } }
return refreshed();
}).then(function () {
if (body.get("aside") === "true") {
diff --git a/internal/equipo/static/equipo.css b/internal/equipo/static/equipo.css
index e5a9628e..d5ada21b 100644
--- a/internal/equipo/static/equipo.css
+++ b/internal/equipo/static/equipo.css
@@ -1830,3 +1830,72 @@ label[equipo-sp-label] { cursor: pointer; }
[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; }
@media (max-width: 500px) { [equipo-chat-header] > [equipo-header-button] { display: none; } [equipo-set-aside] button { inline-size: 2.75rem; } }
+/* A sub-chat is a full-width drawer under its card's actions. */
+[equipo-subchat] { min-inline-size: 0; margin: .125rem -1rem -.875rem; padding: .75rem 1rem .875rem; background: var(--rst-surface-2); border-block-start: 1px solid var(--rst-line); border-end-start-radius: inherit; border-end-end-radius: inherit; }
+[equipo-subchat][data-question-thread] { margin-block-start: 0; border-block-start: 0; background: transparent; }
+[equipo-thread-list] { display: grid; gap: .75rem; margin-block-end: .875rem; }
+[equipo-thread-turn] { display: grid; grid-template-columns: 1.5rem minmax(0,1fr); column-gap: .5rem; align-items: start; }
+[equipo-thread-avatar] { display: grid; place-items: center; inline-size: 1.5rem; block-size: 1.5rem; border: 1px solid var(--rst-line); border-radius: var(--rst-radius); background: var(--rst-surface); color: var(--rst-text-muted); }
+[equipo-thread-avatar] svg { inline-size: 1rem; block-size: 1rem; }
+[equipo-thread-bubble] { justify-self: start; padding: .375rem .75rem .5rem; border-radius: var(--rst-radius) calc(7 * var(--rst-radius) / 3) calc(7 * var(--rst-radius) / 3); background: var(--rst-surface); border: 1px solid var(--rst-line); max-inline-size: 92%; min-inline-size: 0; font-size: var(--rst-fs-sm); }
+[equipo-thread-who] { font-size: var(--rst-fs-xs); font-weight: 650; color: var(--rst-text-muted); margin-block-end: .25rem; }
+[equipo-thread-who] time { font-weight: 400; color: var(--rst-text-faint); margin-inline-start: .375rem; }
+[equipo-thread-text] { overflow-wrap: anywhere; line-height: 1.5; }
+[equipo-thread-text] p { margin: 0; }
+[equipo-thread-turn][data-own] { grid-template-columns: minmax(0,1fr); padding-inline-start: 2rem; }
+[equipo-thread-turn][data-own] [equipo-thread-bubble] { justify-self: end; background: var(--rst-accent-soft); border-color: var(--rst-light-rim); border-radius: calc(7 * var(--rst-radius) / 3) var(--rst-radius) calc(7 * var(--rst-radius) / 3) calc(7 * var(--rst-radius) / 3); }
+[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%; }
+[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: var(--rst-focus-halo); }
+[equipo-mini-pill] textarea { flex: 1; min-inline-size: 0; inline-size: 100%; min-block-size: 1.5rem; max-block-size: 8rem; field-sizing: content; border: 0; background: transparent; padding: .375rem 0; outline: none; box-shadow: none; resize: none; font: inherit; font-size: 1rem; color: var(--rst-text); caret-color: var(--rst-accent); }
+[equipo-mini-pill] textarea::placeholder { color: var(--rst-text-muted); }
+[equipo-mini-pill] button { display: grid; place-items: center; flex: none; inline-size: 2.25rem; block-size: 2.25rem; padding: .375rem; border: 0; border-radius: 50%; color: var(--rst-text-faint); background: var(--rst-surface-2); cursor: pointer; }
+[equipo-mini-composer][data-has-content] [equipo-mini-pill] button { color: var(--rst-on-accent-fill); background: var(--rst-accent-fill); box-shadow: var(--rst-shadow-lift); }
+[equipo-card] [equipo-thread-open] { color: var(--rst-text); cursor: pointer; padding: .375rem 0; font-size: var(--rst-fs-sm); }
+[equipo-subchat][data-direction-thread]:not([open]) { margin: 0; padding: 0; border: 0; background: transparent; }
+[equipo-subchat][open] > summary { margin-block-end: .75rem; }
+[equipo-thread-wait] { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; color: var(--rst-text-muted); font-size: var(--rst-fs-sm); }
+[equipo-thread-draft] { inline-size: 100%; white-space: pre-wrap; }
+[equipo-reading-dots] { display: flex; gap: .2rem; }
+[equipo-reading-dots] i { inline-size: .25rem; block-size: .25rem; background: currentColor; border-radius: 50%; }
+[equipo-card-done] { font-weight: 600; margin: 0; }
+[equipo-needs-pill] { display: flex; align-items: center; gap: .375rem; padding: .25rem .625rem; border: 1px solid var(--rst-line); border-radius: calc(4 * var(--rst-radius)); font-size: var(--rst-fs-sm); }
+@media (max-width:500px) { [equipo-subchat] { margin-inline: -.875rem; padding-inline: .875rem; } [equipo-mini-pill] button { min-inline-size: 2.75rem; } }
+[equipo-roster-card][data-done] { background: transparent; border-color: transparent; padding: .25rem 0; box-shadow: none; }
+[equipo-card-done] { display: flex; align-items: center; gap: .5rem; color: var(--rst-tone-positive-fg); }
+[equipo-thread-avatar][equipo-coordinator-mark] { border-color: transparent; background: transparent; }
+[equipo-needs-pill] { text-decoration: none; }
+[equipo-copy-hold] { display: grid; gap: .75rem; }
+[equipo-copy-hold] h3, [equipo-copy-hold] p, [data-research-report] h3, [data-research-report] p { margin: 0; }
+[equipo-copy-hold] h3 { padding-inline-end: 2rem; font-size: 1.125rem; line-height: 1.3; }
+[equipo-copy-meter] { display: grid; gap: .375rem; color: var(--rst-text-muted); font-size: var(--rst-fs-sm); }
+[equipo-copy-meter] meter { display: block; inline-size: 100%; block-size: .5rem; border: 0; background: var(--rst-tone-neutral-bg); border-radius: var(--rst-radius); }
+[equipo-copy-meter] meter::-webkit-meter-bar { background: var(--rst-tone-neutral-bg); border: 0; }
+[equipo-copy-meter] meter::-webkit-meter-optimum-value { background: var(--rst-tone-warning-fg); }
+[equipo-copy-meter] meter::-moz-meter-bar { background: var(--rst-tone-warning-fg); }
+[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-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); }
+[equipo-daybar] [data-kind="decided"] { background: var(--rst-accent); }
+[equipo-daybar] [data-kind="open"] { background: var(--rst-tone-warning-fg); }
+[equipo-daybar] [data-kind="started"] { background: var(--rst-text-faint); }
+[equipo-day-legend] { display: flex; flex-wrap: wrap; gap: .25rem 1.125rem; color: var(--rst-text-muted); font-size: var(--rst-fs-sm); }
+[equipo-day-legend] b { color: var(--rst-text); font-size: 1rem; font-variant-numeric: tabular-nums; }
+[equipo-rollup]:not([data-expanded]) [equipo-day-rows] { display: none; }
+[equipo-rollup][data-expanded] [equipo-day-rows] { margin-block-start: .75rem; }
+[equipo-roster-report] [equipo-track-full] li { justify-items: start; }
+[equipo-roster-report] [equipo-track-full] li::before { inset-inline: .875rem 0; inset-block-start: .625rem; block-size: .125rem; background: var(--rst-control-border); opacity: 1; }
+[equipo-roster-report] [equipo-track-full] li[data-s="done"]::before, [equipo-roster-report] [equipo-track-full] li[data-s="done"] [equipo-dot]::after { background: var(--rst-tone-positive-fg); border-color: var(--rst-tone-positive-fg); }
+[equipo-roster-report] [equipo-track-full] li[data-tone="negative"] > span { color: var(--rst-tone-negative-fg); }
+[equipo-roster-report] [equipo-track-full] li[data-tone="positive"] > span { color: var(--rst-tone-positive-fg); }
+[equipo-roster-card] [rst-btn="primary"]:hover { background: var(--rst-accent-fill-hover); }
+[equipo-roster-card] [rst-btn="primary"]:active { background: var(--rst-accent-fill-press); transform: translateY(1px); }
+[equipo-roster-card] button:active { transform: translateY(1px); }
diff --git a/internal/equipo/templates/chat.html b/internal/equipo/templates/chat.html
index 8e2fa4c7..ee6aeed5 100644
--- a/internal/equipo/templates/chat.html
+++ b/internal/equipo/templates/chat.html
@@ -2,24 +2,29 @@
{{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 .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 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}}
+{{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 and (not .Open) .Note (not .Presentation.Thread)}} data-done{{end}}>
+{{if .Interactive}}<form method="post" action="/conversation/cards/{{.ID}}/visibility" data-card-form data-busy="false" 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 and (not .Open) .Note (ne .Kind "direction")}}<p equipo-card-done>{{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 data-busy="false" 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}}
{{else if eq .Kind "housekeeping"}}<p equipo-card-line data-digest>{{icon "list-checks"}}<span>{{.Line}} <a href="/housekeeping" data-digest-link>{{copy "chat.housekeeping.link"}}</a></span></p>
-{{else if .Receipt}}<p equipo-card-line>{{icon "folder"}}<span>{{.Line}}</span></p>{{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}}">{{if or (eq .Kind "home") (eq .Kind "combined")}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<button equipo-link name="choice" value="undo" type="submit" data-card-undo>{{copy "chat.card.undo"}}</button></form>{{else}}<details equipo-change><summary equipo-link>{{.Change}}</summary><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<select rst-input name="choice" aria-label="{{.Change}}">{{range .Choices}}<option>{{.}}</option>{{end}}</select><button rst-btn="primary" type="submit">{{copy "chat.card.use"}}</button></form></details>{{if .Remove}}<form method="post" action="/conversation/projects/{{.ProjectID}}/remove" data-card-form><button equipo-link type="submit">{{copy "chat.card.remove"}}</button></form>{{end}}{{end}}</span>{{end}}
-{{else if eq .Kind "question"}}<p equipo-card-line>{{.Line}}</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" .}}{{range .Options}}<button rst-btn name="choice" value="{{.}}" type="submit">{{.}}</button>{{else}}<input rst-input name="choice" required maxlength="2000" aria-label="{{copy "chat.card.answer"}}"><button rst-btn="primary" type="submit">{{copy "chat.card.answer"}}</button>{{end}}</form>{{else}}<p equipo-card-note>{{printf (copy "chat.card.answered") .Choice}}</p>{{end}}
-{{else if eq .Kind "home"}}<p equipo-card-line>{{icon "folder"}}<span>{{.Line}}</span></p><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="confirm" type="submit">{{copy "chat.card.confirm"}}</button></form>
-{{else if eq .Kind "direction"}}<p equipo-card-line>{{.Line}}</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" .}}<textarea rst-input name="note" maxlength="1000" rows="2" aria-label="{{copy "chat.card.direction_note"}}" placeholder="{{copy "chat.card.direction_note"}}"></textarea>{{range .Options}}<button rst-btn="{{if eq . "build"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-direction-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
-{{else if eq .Kind "specialist"}}<p equipo-card-line>{{.Line}}</p>{{with .Specialist}}{{range .Capabilities}}<p equipo-card-note data-capability="{{.ID}}">{{.Words}}</p>{{end}}<p equipo-card-note data-specialist-brief>{{printf (copy "chat.card.specialist_brief") .Brief}}</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 . "add"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-specialist-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
-{{else if eq .Kind "research_sources"}}<p equipo-card-line>{{.Line}}</p>{{with .Name}}<p equipo-card-note data-research-task>{{printf (copy "chat.card.research_for") .}}</p>{{end}}{{with .Research}}<p equipo-card-note data-research-question>{{printf (copy "chat.card.research_looks_for") .Question}}</p><ul equipo-card-list data-research-urls>{{range .URLs}}<li><code>{{.}}</code></li>{{end}}</ul>{{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 . "allow"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-research-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
-{{else if eq .Kind "research_inventory"}}<p equipo-card-line>{{.Line}}</p>{{with .Inventory}}<ul equipo-card-list data-research-addresses>{{range .Addresses}}<li><code>{{.}}</code></li>{{end}}</ul>{{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" .}}<button rst-btn="primary" name="choice" value="confirm" type="submit" data-inventory-confirm>{{copy "chat.card.inventory_confirm"}}</button></form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
-{{else if eq .Kind "publish"}}<p equipo-card-line>{{.Line}}</p>{{with .Site}}{{if .URL}}<p equipo-card-note><a href="{{.URL}}" rel="noopener" target="_blank" data-site-link>{{copy "chat.card.site_link"}}</a></p>{{end}}{{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 . "publish"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-publish-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
-{{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}}</li>{{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}}
+{{else if .Receipt}}<p equipo-card-line>{{icon "folder"}}<span>{{.Line}}</span></p>{{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}}">{{if or (eq .Kind "home") (eq .Kind "combined")}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form data-busy="false"><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<button equipo-link name="choice" value="undo" type="submit" data-card-undo>{{copy "chat.card.undo"}}</button></form>{{else}}<details equipo-change><summary equipo-link>{{.Change}}</summary><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form data-busy="false"><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<select rst-input name="choice" aria-label="{{.Change}}">{{range .Choices}}<option>{{.}}</option>{{end}}</select><button rst-btn="primary" type="submit">{{copy "chat.card.use"}}</button></form></details>{{if .Remove}}<form method="post" action="/conversation/projects/{{.ProjectID}}/remove" data-card-form data-busy="false"><button equipo-link type="submit">{{copy "chat.card.remove"}}</button></form>{{end}}{{end}}</span>{{end}}
+{{else if eq .Kind "question"}}<div equipo-subchat data-question-thread data-roster-turn="{{.Presentation.TurnID}}">
+<div equipo-thread-list><div equipo-thread-turn data-first><span equipo-thread-avatar>{{if eq .AuthorIcon "sparkles"}}{{template "roster-mark" .}}{{else}}{{icon .AuthorIcon}}{{end}}</span><div equipo-thread-bubble><div equipo-thread-who>{{.Author}}</div><div equipo-thread-text>{{.Line}}</div></div></div>{{template "roster-thread-turns" .}}</div>
+{{if .Open}}{{if .Options}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form data-busy="false" equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{range .Options}}<button rst-btn name="choice" value="{{.}}" type="submit">{{.}}</button>{{end}}</form>{{else}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form data-busy="false" equipo-mini-composer><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<div equipo-mini-pill><textarea name="choice" required maxlength="2000" rows="1" aria-label="{{copy "chat.card.answer"}}" placeholder="{{copy "chat.card.answer"}}"></textarea><button type="submit" data-thread-send aria-label="{{copy "conversation.send_short"}}" data-busy-label="{{copy "roster.sending"}}">{{icon "arrow-up"}}</button></div></form>{{end}}{{else if not .Presentation.Waiting}}<form method="post" action="/conversation/cards/{{.ID}}/reply" data-card-form data-busy="false" equipo-mini-composer><input type="hidden" name="request_id" value="{{.ReplyKey}}">{{template "card-job" .}}<div equipo-mini-pill><textarea name="body" required maxlength="2000" rows="1" aria-label="{{copy "roster.reply"}}" placeholder="{{copy "roster.reply"}}"></textarea><button type="submit" data-thread-send aria-label="{{copy "conversation.send_short"}}" data-busy-label="{{copy "roster.sending"}}">{{icon "arrow-up"}}</button></div></form>{{end}}</div>
+{{else if eq .Kind "home"}}<p equipo-card-line>{{icon "folder"}}<span>{{.Line}}</span></p><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form data-busy="false" equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<button rst-btn="primary" name="choice" value="confirm" type="submit">{{copy "chat.card.confirm"}}</button></form>
+{{else if eq .Kind "direction"}}<p equipo-card-line>{{.Line}}</p>{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form data-busy="false" equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{range .Options}}{{if ne . "again"}}<button rst-btn="{{if eq . "build"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-direction-choice="{{.}}"{{if eq . "build"}} data-busy-label="{{copy "roster.building"}}"{{end}}>{{copy (printf "chat.card.%s" .)}}</button>{{end}}{{end}}</form><details equipo-subchat data-direction-thread><summary equipo-thread-open>{{copy "chat.card.again"}}</summary><div equipo-thread-list><div equipo-thread-turn><span equipo-thread-avatar>{{icon .AuthorIcon}}</span><div equipo-thread-bubble><div equipo-thread-who>{{.Author}}</div><div equipo-thread-text>{{copy "roster.change"}}</div></div></div></div><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form data-busy="false" equipo-mini-composer><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="choice" value="again">{{template "card-job" .}}<div equipo-mini-pill><textarea name="note" required maxlength="1000" rows="1" aria-label="{{copy "roster.reply"}}" placeholder="{{copy "roster.reply"}}"></textarea><button type="submit" data-thread-send data-direction-choice="again" aria-label="{{copy "conversation.send_short"}}" data-busy-label="{{copy "roster.sending"}}">{{icon "arrow-up"}}</button></div></form></details>{{else}}{{with .Note}}<p equipo-card-done>{{.}}</p>{{end}}{{if .Presentation.Thread}}<div equipo-subchat><div equipo-thread-list>{{template "roster-thread-turns" .}}</div></div>{{end}}{{end}}
+{{else if eq .Kind "specialist"}}<p equipo-card-line>{{.Line}}</p>{{with .Specialist}}{{range .Capabilities}}<p equipo-card-note data-capability="{{.ID}}">{{.Words}}</p>{{end}}<p equipo-card-note data-specialist-brief>{{printf (copy "chat.card.specialist_brief") .Brief}}</p>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form data-busy="false" equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{range .Options}}<button rst-btn="{{if eq . "add"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-specialist-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
+{{else if eq .Kind "research_sources"}}<p equipo-card-line>{{.Line}}</p>{{with .Name}}<p equipo-card-note data-research-task>{{printf (copy "chat.card.research_for") .}}</p>{{end}}{{with .Research}}<p equipo-card-note data-research-question>{{printf (copy "chat.card.research_looks_for") .Question}}</p><ul equipo-card-list data-research-urls>{{range .URLs}}<li><code>{{.}}</code></li>{{end}}</ul>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form data-busy="false" equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{range .Options}}<button rst-btn="{{if eq . "allow"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-research-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
+{{else if eq .Kind "research_inventory"}}<p equipo-card-line>{{.Line}}</p>{{with .Inventory}}<ul equipo-card-list data-research-addresses>{{range .Addresses}}<li><code>{{.}}</code></li>{{end}}</ul>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form data-busy="false" equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<button rst-btn="primary" name="choice" value="confirm" type="submit" data-inventory-confirm>{{copy "chat.card.inventory_confirm"}}</button></form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
+{{else if eq .Kind "publish"}}<p equipo-card-line>{{.Line}}</p>{{with .Site}}{{if .URL}}<p equipo-card-note><a href="{{.URL}}" rel="noopener" target="_blank" data-site-link>{{copy "chat.card.site_link"}}</a></p>{{end}}{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form data-busy="false" equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{range .Options}}<button rst-btn="{{if eq . "publish"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-publish-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
+{{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 data-busy="false" 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 data-busy="false" 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 data-busy="false"><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 not .SetAside}}{{range .ResearchReports}}<div equipo-roster-byline><b>{{copy "work.specialist.research"}}</b><span>{{copy "roster.reports"}}</span></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">{{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>{{.Task.StageLine}}</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 data-busy="false"><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}}{{if .Presentation.Waiting}}<div equipo-thread-wait role="status"><span equipo-reading-dots aria-hidden="true"><i></i><i></i><i></i></span><span>{{printf (copy "roster.waiting") .Author}}</span><div equipo-thread-draft></div></div>{{end}}{{end}}
+{{define "roster-undo"}}<form method="post" action="/conversation/cards/{{.ID}}/visibility" data-card-form data-busy="false"><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="{{.CreatedAt.Format "2006-01-02T15:04:05Z07:00"}}">{{.CreatedAt.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"}}{{with .Task}}<div equipo-roster-report>
@@ -43,6 +48,7 @@
{{define "chat-day"}}<li equipo-rollup id="day-{{.Key}}" data-day="{{.Key}}"{{if .Expanded}} data-expanded{{end}}>
<section equipo-day-box aria-labelledby="day-title-{{.Key}}">
<header equipo-day-head><h2 id="day-title-{{.Key}}"><time datetime="{{.Key}}">{{.Label}}</time></h2><span equipo-day-count>{{.Messages}}</span></header>
+{{if not .Quiet}}<div equipo-daybar aria-hidden="true">{{range .Rows}}<i data-kind="{{.Key}}" style="flex-grow:{{.Count}}"></i>{{end}}</div><div equipo-day-legend>{{range .Rows}}<span data-kind="{{.Key}}"><b>{{.Count}}</b> {{.Label}}</span>{{end}}</div>{{end}}
{{if .Quiet}}<p equipo-day-quiet>{{copy "chat.day.quiet"}}</p>{{else}}<dl equipo-day-rows>{{range .Rows}}{{template "day-row" .}}{{end}}</dl>{{end}}
<a equipo-day-toggle href="{{.Toggle}}" data-day-toggle="{{.Key}}" aria-expanded="{{if .Expanded}}true{{else}}false{{end}}" aria-controls="day-feed-{{.Key}}"><span>{{if .Expanded}}{{copy "chat.day.hide"}}{{else}}{{copy "chat.day.show"}}{{end}}</span>{{icon "chevron-down"}}</a>
</section>
@@ -51,7 +57,7 @@
{{define "day-row"}}<div equipo-day-row data-row="{{.Key}}"><dt>{{.Label}}</dt><dd{{if .Stack}} data-stack{{end}}>{{range $i, $it := .Items}}{{if and $i (not $.Stack)}}, {{end}}<span equipo-day-item>{{if .TaskID}}<a href="/tasks/{{.TaskID}}">{{.Text}}</a>{{else}}{{.Text}}{{end}}{{with .Note}}: <span equipo-day-decision>{{.}}</span>{{end}}</span>{{end}}{{with .More}} <span equipo-day-more>{{.}}</span>{{end}}</dd></div>{{end}}
{{define "content"}}
<div equipo-conversation{{if .Chat.Job}} data-job="{{.Chat.Job.ID}}"{{else}} data-chat-stream{{end}} data-card-failed="{{copy "roster.failed"}}" data-card-stale="{{copy "roster.stale"}}" data-card-busy="{{copy "roster.busy"}}" data-card-retry="{{copy "roster.retry"}}" data-aside-label="{{copy "roster.aside"}}" 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>{{with .Chat.Job}}<h1>{{.Label}}</h1><a href="/jobs" equipo-link data-jobs-all>{{copy "jobs.all"}}</a><a href="/conversation" equipo-link data-jobs-back>{{copy "jobs.back"}}</a>{{else}}<h1>{{copy "conversation.title"}}</h1>{{if .Chat.FromBase}}<a href="/jobs" equipo-header-button aria-label="{{copy "jobs.title"}}" title="{{copy "jobs.title"}}" data-jobs-link>{{icon "inbox"}}</a>{{end}}<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>{{end}}</header>
+<header equipo-chat-header>{{with .Chat.Job}}<h1>{{.Label}}</h1><a href="/jobs" equipo-link data-jobs-all>{{copy "jobs.all"}}</a><a href="/conversation" equipo-link data-jobs-back>{{copy "jobs.back"}}</a>{{else}}<h1>{{copy "conversation.title"}}</h1>{{if .Rail.Needs.Known}}<a equipo-needs-pill href="/tasks?needs=you" aria-label="{{printf (copy "roster.needs") .Rail.Needs.N}}">{{icon "inbox"}}<span>{{.Rail.Needs.N}}</span></a>{{end}}{{if .Chat.FromBase}}<a href="/jobs" equipo-header-button aria-label="{{copy "jobs.title"}}" title="{{copy "jobs.title"}}" data-jobs-link>{{icon "inbox"}}</a>{{end}}<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>{{end}}</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"}}">
<section id="conversation-feed">
diff --git a/internal/thintest/research_pages_test.go b/internal/thintest/research_pages_test.go
index 43deea32..b629a980 100644
--- a/internal/thintest/research_pages_test.go
+++ b/internal/thintest/research_pages_test.go
@@ -107,7 +107,7 @@ func TestResearchSourcesCardPage(t *testing.T) {
r.sourcesCard(wire.CardAnswered)
r.backdate(-48 * time.Hour)
after := cardOf(t, r.get(owner, "/conversation", 200), card.ID)
- if strings.Contains(after, "<form") || !strings.Contains(after, "<p equipo-card-note>Allowed. Research can read these pages.</p>") {
+ if strings.Contains(after, "<form") || !strings.Contains(after, "Allowed. Research can read these pages.</p>") || !strings.Contains(after, "data-done") {
t.Fatalf("answered card:\n%s", after)
}
}
diff --git a/internal/thintest/roster_browser_test.go b/internal/thintest/roster_browser_test.go
index 3ee33e09..5e1604b7 100644
--- a/internal/thintest/roster_browser_test.go
+++ b/internal/thintest/roster_browser_test.go
@@ -3,6 +3,7 @@
package thintest
import (
+ "amadan.net/oficina/equipo/internal/wire"
"fmt"
"testing"
)
@@ -56,3 +57,73 @@ func TestBrowserRosterSetAside(t *testing.T) {
}
}
}
+
+func TestBrowserRosterSubchat(t *testing.T) {
+ 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)
+ if res := r.call("roster-q", wire.ToolAskPerson, map[string]any{"question": "Which page should change?", "options": []string{}}); res.Code != "asked" {
+ t.Fatalf("ask: %+v", res)
+ }
+ if err := r.runner.Send(r.ctx, "roster-q-reply", wire.FrameReply, wire.Reply{TurnID: r.turn, Attempt: 1, Text: "One question before I start."}); err != nil {
+ t.Fatal(err)
+ }
+ r.wait("replied", func(c *Conversation) bool { return c.Turns[r.turn].State == wire.TurnReplied })
+ 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-subchat] [equipo-mini-composer]')`, "question as a sub-chat")
+ p.check(`document.querySelector('[equipo-subchat] [equipo-thread-turn]').textContent.includes('Which page should change?')`, "first word is not a turn")
+ p.check(`(()=>{const i=document.querySelector('[equipo-mini-composer] textarea');i.value='The sign-in page.';i.dispatchEvent(new Event('input',{bubbles:true}));i.focus();return true})()`, "type")
+ p.shot(fmt.Sprintf("roster-thread-typing-%d-%s", width, scheme))
+ p.click(`[equipo-mini-composer] [data-thread-send]`)
+ f, body := r.expect(wire.FrameMessage)
+ m := body.(*wire.MessageCommand)
+ r.runner.Send(r.ctx, "roster-a", wire.FrameAck, wire.Ack{ID: f.ID})
+ p.wait(`document.querySelector('[equipo-subchat] [data-own]') && document.querySelector('[equipo-thread-wait]')`, "sent and waiting")
+ p.shot(fmt.Sprintf("roster-thread-waiting-%d-%s", width, scheme))
+ r.runner.Send(r.ctx, "roster-answer", wire.FrameReply, wire.Reply{TurnID: m.TurnID, Attempt: 1, Text: "I’ll start with the sign-in page."})
+ 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.fits("sub-chat")
+ p.shot(fmt.Sprintf("roster-thread-answered-%d-%s", width, scheme))
+ })
+ }
+ }
+}
+
+func TestBrowserRosterDecisionStates(t *testing.T) {
+ 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 := newToolRigAt(t, wire.ProtocolCurrent)
+ id, c := r.toDirection("roster", "Explore a shorter setup")
+ p := openInner(t, r.inst.URL, r.inst.Cookie(), width, 844, width == 390, scheme, "reduce")
+ defer p.stop()
+ p.open("/conversation")
+ card := `[data-card="` + c.ID + `"]`
+ p.wait(`document.querySelector('`+card+` [data-direction-choice="build"]')`, "direction")
+ p.check(`(()=>{window.__fetch=window.fetch;window.fetch=function(url,opts){if(opts&&opts.method==='POST')return new Promise(resolve=>{window.__release=()=>resolve(new Response('{}',{status:503}));});return window.__fetch(url,opts)};return true})()`, "hold request")
+ p.click(card + ` [data-direction-choice="build"]`)
+ p.check(`(()=>{const c=document.querySelector('`+card+`');return c.getAttribute('aria-busy')==='true' && c.querySelector('[aria-busy="true"]').textContent.includes('Building') && [...c.querySelectorAll('button')].every(b=>b.disabled)})()`, "busy and sibling disabled")
+ p.shot(fmt.Sprintf("roster-decision-busy-%d-%s", width, scheme))
+ p.check(`(()=>{window.__release();return true})()`, "fail")
+ p.wait(`!document.querySelector('`+card+` [equipo-card-error]').hidden`, "in-place error")
+ p.shot(fmt.Sprintf("roster-decision-error-%d-%s", width, scheme))
+ p.check(`(()=>{window.fetch=window.__fetch;return true})()`, "restore request")
+ p.click(card + ` [data-direction-thread] summary`)
+ p.check(`document.activeElement===document.querySelector('`+card+` textarea')`, "Try again focuses sub-chat")
+ p.check(`(()=>{const i=document.querySelector('`+card+` textarea');i.value='Keep the runner step, drop the tour.';i.dispatchEvent(new Event('input',{bubbles:true}));return true})()`, "note")
+ p.click(card + ` [data-thread-send]`)
+ p.wait(`document.querySelector('`+card+` [data-own]')`, "sent direction note")
+ if k := r.task(id); k.Stage != wire.StageInProgress {
+ t.Fatalf("note did not choose another round: %s", k.Stage)
+ }
+ p.fits("direction states")
+ p.shot(fmt.Sprintf("roster-decision-sent-%d-%s", width, scheme))
+ })
+ }
+ }
+}