oficina / equipo Public

Merge branch 'conversation-roster' into main

Redesign the conversation as Roster

Bylines name who is talking and the project; flat reports with a stage
track and labelled facts; raised decision cards with clear feedback;
per-person Set aside with undo; questions and replies as sub-chats with
a compact composer; one-line thinking with Stop. Migration 0086.
Designed and reviewed by Fable; picked by Paul 2026-11-14.
claude agent, operated by paul@keymail.dev 991f12d5fbc2f2c79dd0ffc76917acfd08bccc20 parent c8bf8d0parent fa518ff
52 files changed, +2,339 −103
  • .rastrillo/budgets.txt +4 −4
  • docs/superpowers/plans/2026-11-14-conversation-roster.md +42 −0
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +53 −0
  • internal/equipo/app.go +3 −0
  • internal/equipo/chat/explore.go +7 −0
  • internal/equipo/chat/models.go +1 −1
  • internal/equipo/chat/projects.go +1 −1
  • internal/equipo/chat/roster.go +387 −0
  • internal/equipo/chat/roster_context_test.go +50 −0
  • internal/equipo/chat/roster_copy.go +54 −0
  • internal/equipo/chat/roster_revision_test.go +101 −0
  • internal/equipo/chat/roster_test.go +132 −0
  • internal/equipo/chat/store.go +2 −1
  • internal/equipo/chat_days.go +10 −0
  • internal/equipo/chat_page.go +66 −3
  • internal/equipo/chat_roster.go +290 −0
  • internal/equipo/chat_roster_test.go +42 −0
  • internal/equipo/copy.go +68 −16
  • internal/equipo/icons/icons.go +2 −0
  • internal/equipo/migrations/0086_conversation_roster.sql +6 −0
  • internal/equipo/migrations/schema.sql +8 −0
  • internal/equipo/rail.go +3 −1
  • internal/equipo/research_views.go +18 −0
  • internal/equipo/static/chat-anchor.js +3 −3
  • internal/equipo/static/chat-compose.js +20 −0
  • internal/equipo/static/chat-stream.js +96 −11
  • internal/equipo/static/equipo.css +225 −0
  • internal/equipo/templates/chat.html +31 −13
  • internal/equipo/templates/work_needs.html +2 −1
  • internal/equipo/templates/work_parts.html +1 −1
  • internal/equipo/templates/work_task.html +1 −1
  • internal/equipo/work_pages.go +13 −0
  • internal/equipo/work_views.go +15 −0
  • internal/equipo/work_views_test.go +9 −0
  • internal/headless/browser_cards_test.go +1 −1
  • internal/headless/browser_notebook_test.go +21 −14
  • internal/headless/browser_review_test.go +3 −3
  • internal/headless/browser_tasks_test.go +13 −10
  • internal/plan3test/plan3_release_test.go +2 −1
  • internal/thintest/gallery_test.go +1 −1
  • internal/thintest/housekeeping_browser_test.go +4 −2
  • internal/thintest/inner_browser_test.go +2 −2
  • internal/thintest/merge_contract_test.go +1 −1
  • internal/thintest/pages_test.go +6 −6
  • internal/thintest/publish_contract_test.go +1 −1
  • internal/thintest/research_pages_test.go +3 −3
  • internal/thintest/rollup_browser_test.go +1 −1
  • internal/thintest/roster_browser_test.go +255 −0
  • internal/thintest/roster_contract_test.go +62 −0
  • internal/thintest/roster_reports_browser_test.go +114 −0
  • internal/thintest/roster_routes_test.go +76 −0
  • scripts/runner-reference-allowlist.json +7 −0

CI passed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 3bf127f5..6ced0391 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 19893 - Web pages, handlers, templates and runtime copy stay together: Oficina ID route wiring, the Copy setting and the job thread pages. Measured 19893 source lines.
+size internal/equipo 20359 - The web view models and templates share rendering; Roster adds bylines, fact details, private sub-chat views and the Stop route. Measured 20359 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 28039 - The instance store shares transaction and authority helpers: Copy reviews and ledger, job threads, titles, cards and nudges. Measured 28039 source lines.
+size internal/equipo/chat 28488 - The transactional conversation store shares authority and dispatch helpers; Roster adds personal visibility and batched card-thread and project-context reads. Measured 28488 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.
@@ -70,8 +70,8 @@ perf GET /api/v1/tasks/{id}/files/{file} skip Research kept images: bearer-only
perf GET /tasks/{id}/files/{file} skip Research kept images: the bytes of one image, shown on the task page; a file, not a screen.
perf GET /api/v1/runners skip Mac runners person API: bearer-only JSON for devices; the browser shows runners in the Team section.
time cmd/equipo-runner 60s TestReleaseRunnerHasNoFakeWorker builds the release runner and the thin package under testbuild (about 12s locally).
-size internal/headless - 10732 End-to-end scenarios through a real runner and instance: the Copy setting, wording flag and the Assistant's job threads. Measured 10732 test lines.
-size internal/thintest - 27960 Contract and browser tests share one instance harness: the Assistant's hand-off, outcome and job contracts and the models'. Measured 27960 test lines.
+size internal/headless - 10742 End-to-end scenarios through a real runner and instance: the Copy setting, wording flag and the Assistant's job threads. Measured 10742 test lines.
+size internal/thintest - 28469 The contract and browser tests share the instance harness; Roster adds Reply/Stop/CSRF guards and desktop/phone state captures. Measured 28469 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/2026-11-14-conversation-roster.md b/docs/superpowers/plans/2026-11-14-conversation-roster.md
new file mode 100644
index 00000000..81aa9b1f
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-14-conversation-roster.md
@@ -0,0 +1,42 @@
+# C · Roster implementation
+
+Paul approved Roster on 14 November 2026. The authority is the sibling
+mockups/C-build-notes.md, c-roster.html and its States sheet. Keep the bare
+muted coordinator sparkle, “Set aside”, and questions threaded from their
+first word. This dispatch is the controller brief for this branch.
+
+## Slices
+
+1. Commit browser expectations, then the visual system: bylines, specialist
+ tiles, flat reports, stage tracks and labelled facts.
+2. Add raised interactive cards and feedback. Persist set-aside per person
+ in a separate visibility record; undo restores visibility. Neither action
+ changes the decision, task, question or runner commands. Keep Needs you
+ and task access intact, including decisions without a task.
+3. Render card-scoped sub-chats with durable replies, real pending state,
+ compact composers and streamed refresh. Trace existing question and
+ direction dispatch before adding any server association needed.
+4. Check the phone layout at 390 and desktop at 1280 in both themes.
+5. Finish the live thinking line and roll-up counts/bar. Inspect screenshots
+ against the approved mockups and correct the UX in one batched pass.
+
+## Verification
+
+Write failing tests first and record their failures. Cover real action
+states, stale revisions, set-aside/undo across reload, personal isolation,
+continued Needs you/task reachability, sub-chat round trip and no horizontal
+overflow. Mutate the no-answer/no-cancel and authority guards, observe the
+failures, then restore. Run the existing WebKit lane when available.
+
+Trace every server gap from the build notes: authorship, dismissal, thread
+association, Copy coverage, Research sources/gaps/log, preview summary and
+cross-page events. Preserve unknown counts; never invent progress or replies.
+Use the next migration after main (currently 0085); change wire protocols
+only if needed. Keep vendored theme files unchanged.
+
+Run targeted tests, make budget, scripts/runner-dead-references.py,
+make lanes-check and make copy-release-check. Use Paul's delegated Astra
+copy pass, with dated acceptance in copy.go and the Plan 3 inventory; no
+copy-review server. Commit and push slices to conversation-roster and poll
+hosted CI. No merge or deployment. Save desktop/phone light/dark captures
+in ../shots and the SHA, CI, gaps, tests and mutation evidence in ../report.md.
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index 8b3265d5..c497a14f 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -6580,6 +6580,59 @@ records remain unchanged.
| `copy.continue` | Continue without Copy | Copy specialist | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13) |
| `copy.round_budget` | Copy repairs are paused or have used today’s automatic allowance. | Copy specialist | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13) |
+| `roster.set_aside` | Set aside | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.aside` | Set aside, still in Needs you | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.undo` | Undo | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.reports` | reports | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.asks` | asks | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.holds` | is holding | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.busy` | Working… | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.setting_aside` | Setting aside… | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.restoring` | Restoring… | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.building` | Building… | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.sending` | Sending… | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.failed` | Couldn’t confirm that change. Try again. | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.stale` | This item has changed. Check it before trying again. | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.retry` | Try again | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.sent` | Sent | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.reply` | Reply | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.change` | What should change? | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.waiting` | %s is reading | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.checks` | Checks | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.review` | Review | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.branch` | Branch | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.open_task` | Open the task | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.copy_coverage` | Review coverage is not available yet. | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.copy_since` | Held since %s | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.research` | Research findings | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `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) |
+
+| `roster.copy_done` | Continuing without Copy. | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+| `roster.stopping` | Stopping… | C · Roster conversation | Runtime; COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14) |
+
+| `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) |
+
## 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 74dfa493..9aa8d3d3 100644
--- a/internal/equipo/app.go
+++ b/internal/equipo/app.go
@@ -301,6 +301,9 @@ func RouterWithStore(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logg
r.Get("/conversation/attachments/{id}", a.chatAttachment(false))
r.Get("/conversation/attachments/{id}/preview", a.chatAttachment(true))
r.Post("/conversation/cards/{id}/answer", a.chatCardAnswer)
+ r.Post("/conversation/cards/{id}/visibility", a.chatCardVisibility)
+ r.Post("/conversation/cards/{id}/reply", a.chatCardReply)
+ r.Post("/conversation/turns/{id}/stop", a.chatTurnStop)
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/models.go b/internal/equipo/chat/models.go
index 42c8a828..d530a8e7 100644
--- a/internal/equipo/chat/models.go
+++ b/internal/equipo/chat/models.go
@@ -7,7 +7,7 @@ package chat
import "time"
// Models are the tables this package owns, for the migration check.
-var Models = []any{&copyAttemptRecord{}, &copyReviewRecord{}, &copyFeedbackRecord{}, &turnRecord{}, &messageRecord{}, &eventRecord{}, &commandRecord{}, &inboxRecord{}, &runnerSessionRecord{}, &projectRecord{}, &cardRecord{}, &toolCallRecord{}, &settingRecord{}, &coordinatorRecord{}, &notebookRecord{}, &taskRecord{}, &stepRecord{}, &entryRecord{}, &attachmentRecord{}, &starRecord{}, &questionRecord{}, &connectionRecord{}, &usageRecord{}, &distinctRecord{}, &hkRecord{}, &hkFailureRecord{}, &hkSettingsRecord{}, &fileRecord{}, &fileDataRecord{}, &transferRecord{}, &mergePolicyRecord{}, &mergeAuditRecord{}, &specialistRecord{}, &grantRecord{}, &specialistAuditRecord{}, &researchSourceRecord{}, &researchAddressRecord{}, &researchPrefixRecord{}, &researchInventoryRecord{}, &researchRecord{}, &researchFetchRecord{}, &taskFileRecord{}, &taskFileDataRecord{}, &releaseRecord{}, &adviceRecord{}, &assistantHostRecord{}, &handoffRecord{}, &handoffTurnRecord{}, &handoffTaskRecord{}, &handoffActionRecord{}}
+var Models = []any{&cardVisibility{}, &cardThreadRecord{}, &copyAttemptRecord{}, &copyReviewRecord{}, &copyFeedbackRecord{}, &turnRecord{}, &messageRecord{}, &eventRecord{}, &commandRecord{}, &inboxRecord{}, &runnerSessionRecord{}, &projectRecord{}, &cardRecord{}, &toolCallRecord{}, &settingRecord{}, &coordinatorRecord{}, &notebookRecord{}, &taskRecord{}, &stepRecord{}, &entryRecord{}, &attachmentRecord{}, &starRecord{}, &questionRecord{}, &connectionRecord{}, &usageRecord{}, &distinctRecord{}, &hkRecord{}, &hkFailureRecord{}, &hkSettingsRecord{}, &fileRecord{}, &fileDataRecord{}, &transferRecord{}, &mergePolicyRecord{}, &mergeAuditRecord{}, &specialistRecord{}, &grantRecord{}, &specialistAuditRecord{}, &researchSourceRecord{}, &researchAddressRecord{}, &researchPrefixRecord{}, &researchInventoryRecord{}, &researchRecord{}, &researchFetchRecord{}, &taskFileRecord{}, &taskFileDataRecord{}, &releaseRecord{}, &adviceRecord{}, &assistantHostRecord{}, &handoffRecord{}, &handoffTurnRecord{}, &handoffTaskRecord{}, &handoffActionRecord{}}
type turnRecord struct {
ID string `gorm:"primaryKey"`
diff --git a/internal/equipo/chat/projects.go b/internal/equipo/chat/projects.go
index 8b2c399c..dff97863 100644
--- a/internal/equipo/chat/projects.go
+++ b/internal/equipo/chat/projects.go
@@ -825,7 +825,7 @@ func (t *txn) answerHome(person string, c cardRecord, in wire.AnswerCard) (wire.
// answerPrefix gives the coordinator the question a message answers.
func (t *txn) answerPrefix(m messageRecord) (string, error) {
var c cardRecord
- err := t.db.Where("answer_message = ? AND person = ?", m.ID, m.Person).First(&c).Error
+ err := t.db.Where("person = ? AND (answer_message = ? OR id IN (SELECT card_id FROM chat_card_threads WHERE message_id = ? AND person = ?))", m.Person, m.ID, m.ID, m.Person).First(&c).Error
if errors.Is(err, gorm.ErrRecordNotFound) {
return m.Text, nil
}
diff --git a/internal/equipo/chat/roster.go b/internal/equipo/chat/roster.go
new file mode 100644
index 00000000..30036c72
--- /dev/null
+++ b/internal/equipo/chat/roster.go
@@ -0,0 +1,387 @@
+package chat
+
+import (
+ "context"
+ "errors"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/wire"
+ "gorm.io/gorm"
+ "gorm.io/gorm/clause"
+)
+
+type cardVisibility struct {
+ Person string `gorm:"primaryKey"`
+ CardID string `gorm:"primaryKey"`
+ Aside bool
+ UpdatedAt time.Time
+}
+
+func (cardVisibility) TableName() string { return "chat_card_visibility" }
+
+type cardThreadRecord struct {
+ MessageID string `gorm:"index:chat_card_thread_message"`
+ ID string `gorm:"primaryKey"`
+ CardID string `gorm:"index:chat_card_thread_card"`
+ Person string
+ TurnID string
+ StepID string
+ Text string
+ CreatedAt time.Time
+}
+
+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 CardContext struct {
+ ProjectID, ProjectTitle, TaskTitle string
+}
+
+type CardPresentation struct {
+ Context CardContext
+ OwnMessages []string
+ Activity []wire.ActivityLine
+ ThreadState string
+ StepID string
+ Coverage CardCopyCoverage
+ Turns []string
+ Aside bool
+ Thread []CardThreadTurn
+ Waiting bool
+ TurnID string
+}
+type CardThreadTurn struct {
+ Own bool
+ Text string
+ At time.Time
+}
+
+func (s *Store) SetCardAside(ctx context.Context, person, id string, revision int64, aside bool) error {
+ 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.Revision != revision {
+ return ErrCardConflict
+ }
+ if c.State != wire.CardOpen && c.State != wire.CardHomeAsk && c.Kind != wire.CardTask {
+ return ErrCardConflict
+ }
+ if c.Kind == wire.CardTask {
+ k, err := t.loadTask(c.TaskID)
+ if err != nil {
+ return err
+ }
+ if wire.FinalStage(k.Stage) || k.CancelRequested {
+ return ErrCardConflict
+ }
+ v, err := t.taskView(k)
+ if err != nil {
+ return err
+ }
+ if !v.CopyHold && !v.CopyCanSkip {
+ return ErrCardConflict
+ }
+ }
+ v := cardVisibility{Person: person, CardID: id, Aside: aside, UpdatedAt: t.now()}
+ if err := t.db.Clauses(clause.OnConflict{Columns: []clause.Column{{Name: "person"}, {Name: "card_id"}}, DoUpdates: clause.AssignmentColumns([]string{"aside", "updated_at"})}).Create(&v).Error; err != nil {
+ return err
+ }
+ if err := s.authority.Audit(t.db, person, "card.visibility", id); err != nil {
+ return err
+ }
+ return t.cardEvent(c)
+ })
+}
+
+func (s *Store) CardPresentations(ctx context.Context, person string, ids []string) (out map[string]CardPresentation, err error) {
+ out = map[string]CardPresentation{}
+ if len(ids) == 0 {
+ return out, nil
+ }
+ err = s.read(ctx, func(tx *gorm.DB) error {
+ if err := s.authority.CurrentPerson(ctx, tx); err != nil {
+ return err
+ }
+ var cards []cardRecord
+ if err := tx.Where("person = ? AND id IN ? AND "+coordinatorRole, person, ids).Find(&cards).Error; err != nil {
+ return err
+ }
+ contexts, err := cardContexts(tx, person, cards)
+ if 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 {
+ 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 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 err := tx.Where("person = ? AND turn_id IN ?", person, turnIDs).Order("seq").Find(&messages).Error; err != nil {
+ return err
+ }
+ }
+ 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
+ }
+ }
+ stepByID := map[string]stepRecord{}
+ for _, step := range steps {
+ stepByID[step.ID] = step
+ }
+ for _, c := range cards {
+ p := CardPresentation{Aside: aside[c.ID], Context: contexts[c.ID]}
+ if c.Kind == wire.CardTask {
+ var err error
+ p.Coverage, err = cardCopyCoverage(tx, c.TaskID)
+ if err != nil {
+ return err
+ }
+ }
+ 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)
+ for _, m := range messagesByTurn[link.TurnID] {
+ if m.Role == wire.RolePerson && m.ID != link.MessageID {
+ continue
+ }
+ if m.Role == wire.RolePerson {
+ p.OwnMessages = append(p.OwnMessages, m.ID)
+ }
+ p.Thread = append(p.Thread, CardThreadTurn{Own: m.Role == wire.RolePerson, Text: m.Text, At: m.CreatedAt})
+ }
+ 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
+ }
+ } else {
+ p.Thread = append(p.Thread, CardThreadTurn{Own: true, Text: link.Text, At: link.CreatedAt})
+ 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})
+ }
+ }
+ }
+ }
+ out[c.ID] = p
+ }
+ return nil
+ })
+ return
+}
+
+// OpenStandaloneCards keeps questions without a task reachable in Needs you.
+type StandaloneCard struct {
+ wire.Card
+ Job string
+}
+
+func (s *Store) OpenStandaloneCards(ctx context.Context, person string) (out []StandaloneCard, err error) {
+ err = s.read(ctx, func(tx *gorm.DB) error {
+ if err := s.authority.CurrentPerson(ctx, tx); err != nil {
+ return err
+ }
+ var cs []cardRecord
+ if err := tx.Where("person = ? AND coalesce(task_id, '') = '' AND state IN ? AND "+coordinatorRole, person, []string{wire.CardOpen, wire.CardHomeAsk}).Order("created_at, id").Find(&cs).Error; err != nil {
+ return err
+ }
+ t := &txn{s: s, db: tx, ctx: ctx}
+ for _, c := range cs {
+ v, err := t.cardView(c)
+ if err != nil {
+ return err
+ }
+ job, _ := wire.JobOf(c.Lane)
+ out = append(out, StandaloneCard{Card: v, Job: job})
+ }
+ return nil
+ })
+ 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 || !validKey(key) {
+ 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
+ }
+ if _, job := wire.JobOf(c.Lane); job {
+ if err := t.jobRunner(person); err != nil {
+ return err
+ }
+ }
+ _, _, err := t.send(c.Lane, person, "card:reply:"+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, MessageID: m.ID, CreatedAt: t.now()}).Error; err != nil {
+ return err
+ }
+ if err := s.authority.Audit(t.db, person, "card.reply", c.ID); err != nil {
+ return err
+ }
+ return t.followAnswer(c, m)
+ })
+ return err
+ })
+}
+
+// StopConversationTurn stops a verified person's own or job Coordinator,
+// with its audit and cancellation command in the same transaction.
+func (s *Store) StopConversationTurn(ctx context.Context, person, id string) error {
+ return s.tx(ctx, func(t *txn) error {
+ if err := s.authority.CurrentPerson(ctx, t.db); err != nil {
+ return err
+ }
+ var turn turnRecord
+ if err := t.db.Where("id = ? AND person = ? AND "+coordinatorRole, id, person).First(&turn).Error; errors.Is(err, gorm.ErrRecordNotFound) {
+ return ErrNotFound
+ } else if err != nil {
+ return err
+ }
+ if wire.Terminal(turn.State) {
+ return ErrTerminal
+ }
+ if err := s.authority.Audit(t.db, person, "turn.cancel", id); err != nil {
+ return err
+ }
+ return t.cancelTurn(turn)
+ })
+}
+
+// ResolvedAsideCards keeps today's resolution of an older stub in place
+// even when the original question belongs to a collapsed earlier day.
+func (s *Store) ResolvedAsideCards(ctx context.Context, person, lane string, since time.Time) (out []wire.Card, err error) {
+ err = s.read(ctx, func(tx *gorm.DB) error {
+ if err := s.authority.CurrentPerson(ctx, tx); err != nil {
+ return err
+ }
+ var cs []cardRecord
+ if err := tx.Where("person = ? AND coalesce(lane, '') = ? AND updated_at >= ? AND state IN ? AND EXISTS (SELECT 1 FROM chat_card_visibility v WHERE v.card_id = chat_cards.id AND v.person = chat_cards.person AND v.aside = ?)", person, lane, since, []string{wire.CardAnswered, wire.CardResolved}, true).Order("created_at, id").Find(&cs).Error; err != nil {
+ return err
+ }
+ t := &txn{s: s, db: tx, ctx: ctx}
+ for _, c := range cs {
+ v, err := t.cardView(c)
+ if err != nil {
+ return err
+ }
+ out = append(out, v)
+ }
+ return nil
+ })
+ return
+}
+
+// cardContexts reads the current task/project names for the authorised cards,
+// including historical cards whose project is no longer active.
+func cardContexts(tx *gorm.DB, person string, cards []cardRecord) (map[string]CardContext, error) {
+ out := map[string]CardContext{}
+ if len(cards) == 0 {
+ return out, nil
+ }
+ ids := make([]string, 0, len(cards))
+ for _, c := range cards {
+ ids = append(ids, c.ID)
+ }
+ var rows []struct {
+ ID, Repo string
+ CardContext
+ }
+ err := tx.Table("chat_cards AS c").
+ Select("c.id, p.id AS project_id, p.title AS project_title, p.repo, t.title AS task_title").
+ Joins("LEFT JOIN chat_tasks AS t ON t.id = c.task_id").
+ Joins("LEFT JOIN chat_projects AS p ON p.id = coalesce(nullif(t.project_id, ''), c.project_id)").
+ Where("c.person = ? AND c.id IN ?", person, ids).Scan(&rows).Error
+ if err != nil {
+ return nil, err
+ }
+ for _, row := range rows {
+ if row.ProjectTitle == "" && row.Repo != "" {
+ row.ProjectTitle = ProjectTitle(row.Repo, nil)
+ }
+ out[row.ID] = row.CardContext
+ }
+ return out, nil
+}
diff --git a/internal/equipo/chat/roster_context_test.go b/internal/equipo/chat/roster_context_test.go
new file mode 100644
index 00000000..dc8fd03b
--- /dev/null
+++ b/internal/equipo/chat/roster_context_test.go
@@ -0,0 +1,50 @@
+package chat
+
+import (
+ "amadan.net/oficina/equipo/internal/wire"
+ "context"
+ "testing"
+)
+
+func TestRosterCardContext(t *testing.T) {
+ r := newMeteredRig(t)
+ ctx := context.Background()
+ for _, p := range []projectRecord{{ID: "p_old", Title: "Earlier", Repo: "amadan.net/one/old"}, {ID: "p_current", Title: "Woodstar", Repo: "amadan.net/one/current", State: "removed"}} {
+ if err := r.s.db.G.Create(&p).Error; err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := r.s.db.G.Create(&taskRecord{ID: "tk_context", ProjectID: "p_current", Title: "Improve sign-in", Creator: hkOwner}).Error; err != nil {
+ t.Fatal(err)
+ }
+ for _, c := range []cardRecord{
+ {ID: "c_task", Person: hkOwner, TaskID: "tk_context", ProjectID: "p_old", Kind: wire.CardQuestion},
+ {ID: "c_project", Person: hkOwner, ProjectID: "p_old", Kind: wire.CardProject},
+ {ID: "c_global", Person: hkOwner, Kind: wire.CardQuestion},
+ {ID: "c_other", Person: hkMember, TaskID: "tk_context", Kind: wire.CardQuestion},
+ {ID: "c_missing", Person: hkOwner, TaskID: "gone", ProjectID: "p_old", Kind: wire.CardQuestion},
+ } {
+ if err := r.s.db.G.Create(&c).Error; err != nil {
+ t.Fatal(err)
+ }
+ }
+ got, err := r.s.CardPresentations(ctx, hkOwner, []string{"c_task", "c_project", "c_global", "c_other", "c_missing"})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if c := got["c_task"].Context; c.ProjectID != "p_current" || c.ProjectTitle != "Woodstar" || c.TaskTitle != "Improve sign-in" {
+ t.Fatalf("task context: %+v", c)
+ }
+ if c := got["c_project"].Context; c.ProjectTitle != "Earlier" || c.TaskTitle != "" {
+ t.Fatalf("project-only context: %+v", c)
+ }
+ if c := got["c_global"].Context; c != (CardContext{}) {
+ t.Fatalf("invented context: %+v", c)
+ }
+ if _, ok := got["c_other"]; ok {
+ t.Fatal("other person's card exposed")
+ }
+ if c := got["c_missing"].Context; c.ProjectTitle != "Earlier" || c.TaskTitle != "" {
+ t.Fatalf("missing task failed graceful context: %+v", c)
+ }
+}
diff --git a/internal/equipo/chat/roster_copy.go b/internal/equipo/chat/roster_copy.go
new file mode 100644
index 00000000..e9e18afa
--- /dev/null
+++ b/internal/equipo/chat/roster_copy.go
@@ -0,0 +1,54 @@
+package chat
+
+import (
+ "amadan.net/oficina/equipo/internal/wire"
+ "encoding/json"
+ "gorm.io/gorm"
+ "time"
+)
+
+type CardCopyCoverage struct {
+ Skipped bool
+ 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.Skipped = steps[0].Note == "copy-skip" && steps[0].State == wire.StepDone
+ 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_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/roster_test.go b/internal/equipo/chat/roster_test.go
new file mode 100644
index 00000000..3de35b83
--- /dev/null
+++ b/internal/equipo/chat/roster_test.go
@@ -0,0 +1,132 @@
+package chat
+
+import (
+ "context"
+ "errors"
+ "reflect"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+func TestRosterSetAsideNeverAnswersOrCancels(t *testing.T) {
+ r := newMeteredRig(t)
+ ctx := context.Background()
+ now := r.s.now()
+ task := taskRecord{ID: "tk_roster", Creator: hkOwner, Stage: wire.StageInProgress, Revision: 1, CreatedAt: now, UpdatedAt: now}
+ if err := r.s.db.G.Create(&task).Error; err != nil {
+ t.Fatal(err)
+ }
+ c := cardRecord{TaskID: task.ID, ID: "c_roster", Person: hkOwner, Kind: wire.CardQuestion, State: wire.CardOpen, Question: "Which page?", Options: "[]", Revision: 1, CreatedAt: now, UpdatedAt: now}
+ if err := r.s.db.G.Create(&c).Error; err != nil {
+ t.Fatal(err)
+ }
+ if err := r.s.SetCardAside(ctx, hkMember, c.ID, 1, true); !errors.Is(err, ErrNotFound) {
+ t.Fatalf("other person: %v", err)
+ }
+ r.removed = true
+ if err := r.s.SetCardAside(ctx, hkOwner, c.ID, 1, true); !errors.Is(err, ErrForbidden) {
+ t.Fatalf("removed: %v", err)
+ }
+ r.removed = false
+ if err := r.s.SetCardAside(ctx, hkOwner, c.ID, 0, true); !errors.Is(err, ErrCardConflict) {
+ t.Fatalf("stale: %v", err)
+ }
+ for _, aside := range []bool{true, true, false, true, false} {
+ if err := r.s.SetCardAside(ctx, hkOwner, c.ID, 1, aside); err != nil {
+ t.Fatal(err)
+ }
+ var after cardRecord
+ if err := r.s.db.G.First(&after, "id = ?", c.ID).Error; err != nil {
+ t.Fatal(err)
+ }
+ if !reflect.DeepEqual(after, c) {
+ t.Fatalf("set aside answered or changed card: %+v", after)
+ }
+ var afterTask taskRecord
+ if err := r.s.db.G.First(&afterTask, "id = ?", task.ID).Error; err != nil {
+ t.Fatal(err)
+ }
+ if !reflect.DeepEqual(afterTask, task) {
+ t.Fatalf("set aside changed or cancelled task: %+v", afterTask)
+ }
+ for _, table := range []string{"runner_commands", "chat_messages", "chat_steps"} {
+ var n int64
+ if err := r.s.db.G.Table(table).Count(&n).Error; err != nil {
+ t.Fatal(err)
+ }
+ if n != 0 {
+ t.Fatalf("set aside dispatched or cancelled work: %s=%d", table, n)
+ }
+ }
+ got, err := r.s.CardPresentations(ctx, hkOwner, []string{c.ID})
+ if err != nil || got[c.ID].Aside != aside {
+ t.Fatalf("persistence: %+v %v", got, err)
+ }
+ }
+ if len(r.audits) != 5 {
+ 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)
+ }
+}
+
+func TestRosterFinalCopyCannotBeSetAside(t *testing.T) {
+ r := copyPendingRig(t, wire.StepQueued, "copy_budget")
+ r.exec("UPDATE chat_tasks SET stage='cancelled',copy_hold=1 WHERE id='tkcopy'")
+ c := cardRecord{ID: "c_final_copy", Person: hkOwner, Kind: wire.CardTask, TaskID: "tkcopy", State: wire.StageInReview, Revision: 1, Options: "[]", CreatedAt: r.now, UpdatedAt: r.now}
+ r.must(r.s.db.G.Create(&c).Error)
+ if err := r.s.SetCardAside(r.ctx, hkOwner, c.ID, 1, true); !errors.Is(err, ErrCardConflict) {
+ t.Fatalf("ended Copy hold was hidden: %v", err)
+ }
+}
+
+func TestRosterFollowupCarriesQuestion(t *testing.T) {
+ r := newMeteredRig(t)
+ c := cardRecord{ID: "c_followup", Person: hkOwner, Kind: wire.CardQuestion, State: wire.CardAnswered, Question: "Which page should change?", Options: "[]", Revision: 1}
+ if err := r.s.db.G.Create(&c).Error; err != nil {
+ t.Fatal(err)
+ }
+ if err := r.s.db.G.Create(&cardThreadRecord{ID: "ct_followup", CardID: c.ID, Person: hkOwner, MessageID: "m_followup"}).Error; err != nil {
+ t.Fatal(err)
+ }
+ if err := r.s.tx(context.Background(), func(tx *txn) error {
+ text, err := tx.answerPrefix(messageRecord{ID: "m_followup", Person: hkOwner, Text: "Keep the email link."})
+ if err == nil && !strings.Contains(text, c.Question) {
+ t.Fatalf("follow-up lost card context: %q", text)
+ }
+ return err
+ }); err != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/internal/equipo/chat/store.go b/internal/equipo/chat/store.go
index 5cdff7d2..9991b1d0 100644
--- a/internal/equipo/chat/store.go
+++ b/internal/equipo/chat/store.go
@@ -546,10 +546,11 @@ func (t *txn) send(lane, person, key, text string, files []string, before func(m
// card raised in a hand-off's turn, start a turn of their own, which
// nothing joins: its work is the hand-off's alone.
alone, err := t.handoffMessage(key)
+ alone = alone || strings.HasPrefix(key, "card:")
if err != nil {
return out, false, err
}
- err = t.db.Where("person = ? AND coalesce(lane, '') = ? AND dispatched = ? AND state = ? AND coalesce(kind, '') = '' AND NOT EXISTS (SELECT 1 FROM chat_handoff_turns WHERE turn_id = chat_turns.id)", person, lane, false, wire.TurnQueued).Order("created_at DESC, id DESC").First(&turn).Error
+ err = t.db.Where("person = ? AND coalesce(lane, '') = ? AND dispatched = ? AND state = ? AND coalesce(kind, '') = '' AND NOT EXISTS (SELECT 1 FROM chat_handoff_turns WHERE turn_id = chat_turns.id) AND NOT EXISTS (SELECT 1 FROM chat_messages WHERE turn_id = chat_turns.id AND idempotency_key LIKE 'card:%')", person, lane, false, wire.TurnQueued).Order("created_at DESC, id DESC").First(&turn).Error
fresh := errors.Is(err, gorm.ErrRecordNotFound) || err == nil && alone
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return out, false, err
diff --git a/internal/equipo/chat_days.go b/internal/equipo/chat_days.go
index dc73a22f..348ec2ac 100644
--- a/internal/equipo/chat_days.go
+++ b/internal/equipo/chat_days.go
@@ -70,6 +70,8 @@ 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 {
+ Width int
+ Count int
Key, Label string
Items []dayItem
More string
@@ -90,6 +92,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)
}
@@ -317,6 +320,13 @@ func (a *application) earlierDays(ctx context.Context, address string, loc *time
d.Rows = append(d.Rows, *r)
}
}
+ total := 0
+ for _, r := range d.Rows {
+ total += r.Count
+ }
+ for j := range d.Rows {
+ d.Rows[j].Width = max(1, (d.Rows[j].Count*100+total/2)/total)
+ }
d.Quiet = len(d.Rows) == 0
if !d.Expanded {
continue
diff --git a/internal/equipo/chat_page.go b/internal/equipo/chat_page.go
index ab3d177e..af2367d0 100644
--- a/internal/equipo/chat_page.go
+++ b/internal/equipo/chat_page.go
@@ -81,8 +81,19 @@ 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 {
+ ProjectMono monoLine
+ ThreadActivity string
+ ThreadError string
+ ResearchReports []*researchView
+ HoldReason string
+ BylineAt time.Time
+ SlimReport bool
+ ExplorationSummary string
+ ReplyKey string
wire.Card
Line, Change, Agent, Namespace, Note string
+ Presentation chat.CardPresentation
+ Author, AuthorIcon, Verb string
// GrantHow introduces an access card's grant command.
GrantHow string
Open, Remove, Receipt bool
@@ -105,7 +116,7 @@ type notebookLine struct {
}
func cardView(c wire.Card, choices []string, tasks map[string]wire.Task) chatCard {
- v := chatCard{Card: c, Choices: choices}
+ v := chatCard{Card: c, Choices: choices, BylineAt: c.CreatedAt}
switch c.Kind {
case wire.CardProject:
v.Line = fmt.Sprintf(copyText("chat.card."+c.State), c.Name)
@@ -230,11 +241,47 @@ func cardView(c wire.Card, choices []string, tasks map[string]wire.Task) chatCar
if t, ok := tasks[c.TaskID]; ok {
// A task card sits in its creator's own conversation.
pt, dropped := pageTask(t)
+ if wire.FinalStage(pt.Stage) {
+ pt.CopyHold, pt.CopyCanSkip = false, false
+ }
line := taskLineOf(pt, t.Creator)
line.MergeDropped = dropped
- v.Task, v.Line, v.Open = &line, t.Title, line.Retry || line.Cancel || line.Merge || line.Recover
+ line.richOf(pt, t.Creator, nil, t.UpdatedAt)
+ line.Track = rosterTrack(pt)
+ v.BylineAt = t.UpdatedAt
+ v.SlimReport = t.NeedsYou == "" && (t.Stage == wire.StageReadyToMerge || t.Stage == wire.StageDone)
+ if t.Kind == wire.KindExplore {
+ for i := len(t.Steps) - 1; i >= 0; i-- {
+ if t.Steps[i].Specialist == wire.SpecialistEngineering {
+ v.ExplorationSummary = headline(t.Steps[i].Headline, t.Steps[i].Summary)
+ break
+ }
+ }
+ }
+ if t.CopyHold {
+ v.HoldReason = copyText("copy.round_budget")
+ }
+ if t.CopyCanSkip {
+ if s := lastStep(t); s != nil {
+ 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
+ for _, step := range t.Steps {
+ if step.Specialist == wire.SpecialistResearch && step.Research != nil {
+ report := researchOf(t.ID, *step.Research)
+ report.StepID = step.ID
+ report.At = step.FinishedAt
+ v.ResearchReports = append(v.ResearchReports, report)
+ }
+ }
}
}
+ v.rosterAuthor(tasks)
return v
}
@@ -394,6 +441,10 @@ func (a *application) chatPage(w http.ResponseWriter, r *http.Request) {
}
view.Ended = &chatEnded{ID: latest.ID, Key: key}
}
+ if err := a.presentRoster(ctx, address, &view); err != nil {
+ a.failure(w, r, chatError(err))
+ return
+ }
data.Chat, data.ChatStream, data.RequestID = view, true, rand.Text()
data.ThinkingSet, data.ThinkingWords = a.thinkingFor(ctx, address)
render(w, "chat", data)
@@ -509,6 +560,10 @@ func (a *application) jobPage(w http.ResponseWriter, r *http.Request) {
view.Waiting = append(view.Waiting, t)
}
}
+ if err := a.presentRoster(ctx, address, &view); err != nil {
+ a.failure(w, r, chatError(err))
+ return
+ }
data.Chat, data.RequestID = view, rand.Text()
render(w, "chat", data)
}
@@ -635,7 +690,15 @@ func (a *application) chatActionTo(w http.ResponseWriter, r *http.Request, back
a.failure(w, r, ErrForbidden)
return
}
- if err := act(ctx, address); err != nil && !errors.Is(err, chat.ErrCardConflict) {
+ if err := act(ctx, address); err != nil {
+ if errors.Is(err, chat.ErrCardConflict) {
+ if strings.Contains(r.Header.Get("Accept"), "application/json") {
+ runnerJSON(w, http.StatusConflict, struct{}{})
+ return
+ }
+ http.Redirect(w, r, back, http.StatusSeeOther)
+ return
+ }
a.failure(w, r, chatError(err))
return
}
diff --git a/internal/equipo/chat_roster.go b/internal/equipo/chat_roster.go
new file mode 100644
index 00000000..f870f779
--- /dev/null
+++ b/internal/equipo/chat_roster.go
@@ -0,0 +1,290 @@
+package equipo
+
+import (
+ "amadan.net/oficina/equipo/internal/equipo/chat"
+ "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 !receiptKind(v.Card) {
+ v.Verb = copyText("roster.asks")
+ }
+ 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]
+ }
+}
+
+func (v chatCard) Interactive() bool {
+ 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 }
+
+func (a *application) presentRoster(ctx context.Context, address string, view *chatView) error {
+ lane := wire.LaneCoordinator
+ if view.Job != nil {
+ lane = wire.JobLane(view.Job.ID)
+ }
+ closed, err := a.store.Chat().ResolvedAsideCards(ctx, address, lane, chat.DayStart(a.store.Chat().Now(), a.store.Chat().Zone(address)))
+ if err != nil {
+ return err
+ }
+ shown := map[string]bool{}
+ noteShown := func(lines []chatLine) {
+ for _, line := range lines {
+ for _, cs := range [][]chatCard{line.Cards, line.Receipts} {
+ for _, c := range cs {
+ shown[c.ID] = true
+ }
+ }
+ }
+ }
+ noteShown(view.Messages)
+ noteShown(view.Open)
+ for _, day := range view.Days {
+ noteShown(day.Feed.Lines)
+ }
+ for _, c := range closed {
+ if !shown[c.ID] {
+ v := cardView(c, nil, nil)
+ v.Job, _ = wire.JobOf(lane)
+ if v.Note == "" && c.Kind != wire.CardQuestion {
+ v.Note = copyText("roster.finished")
+ }
+ view.Open = append(view.Open, chatLine{ID: c.ID, CardOnly: true, Cards: []chatCard{v}, CreatedAt: c.CreatedAt})
+ }
+ }
+ slices.SortStableFunc(view.Open, func(a, b chatLine) int { return a.CreatedAt.Compare(b.CreatedAt) })
+ var cards []*chatCard
+ collect := func(lines []chatLine) {
+ for i := range lines {
+ for _, cs := range [][]chatCard{lines[i].Cards, lines[i].Receipts} {
+ for j := range cs {
+ cards = append(cards, &cs[j])
+ }
+ }
+ }
+ }
+ collect(view.Messages)
+ collect(view.Open)
+ for i := range view.Days {
+ collect(view.Days[i].Feed.Lines)
+ }
+ ids := make([]string, 0, len(cards))
+ for _, c := range cards {
+ ids = append(ids, c.ID)
+ }
+ ps, err := a.store.Chat().CardPresentations(ctx, address, ids)
+ if err != nil {
+ return err
+ }
+ for _, c := range cards {
+ c.Presentation = ps[c.ID]
+ if c.Presentation.Context.ProjectTitle != "" {
+ c.ProjectMono = monoOf(c.Presentation.Context.ProjectTitle, c.Presentation.Context.ProjectID)
+ }
+ c.ReplyKey = rand.Text()
+ if n := len(c.Presentation.Activity); n > 0 {
+ c.ThreadActivity = activityText(c.Presentation.Activity[n-1])
+ }
+ if c.Presentation.ThreadState == wire.TurnFailed {
+ c.ThreadError = copyText("chat.failed")
+ }
+ if c.Presentation.ThreadState == wire.TurnCancelled {
+ c.ThreadError = copyText("chat.cancelled")
+ }
+ }
+ turns := map[string]bool{}
+ own := map[string]bool{}
+ for _, p := range ps {
+ for _, id := range p.OwnMessages {
+ own[id] = true
+ }
+ for _, id := range p.Turns {
+ turns[id] = true
+ }
+ }
+ view.Messages = slices.DeleteFunc(view.Messages, func(m chatLine) bool {
+ return (own[m.ID] || !m.Own && turns[m.TurnID]) && len(m.Cards) == 0 && len(m.Receipts) == 0
+ })
+ if view.Ended != nil && turns[view.Ended.ID] {
+ view.Ended = nil
+ }
+ 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) {
+ a.chatActionTo(w, r, workBack(r, r.PostFormValue("task")), func(ctx context.Context, address string) error {
+ revision, err := strconv.ParseInt(r.PostFormValue("revision"), 10, 64)
+ if err != nil {
+ return chat.ErrInvalid
+ }
+ value := r.PostFormValue("aside")
+ if value != "true" && value != "false" {
+ return chat.ErrInvalid
+ }
+ 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 {
+ if t.Kind == wire.KindExplore {
+ v := taskLine{}
+ v.trackOf(t)
+ out := slices.DeleteFunc(v.Track, func(s trackStop) bool { return s.Stage == wire.StageInvestigated })
+ for i := range out {
+ out[i].Live = false
+ out[i].At = nil
+ if out[i].State == "current" {
+ out[i].Tone = rosterTone(t)
+ }
+ }
+ return out
+ }
+ 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", rosterTone(t)
+ }
+ }
+ return out
+}
+
+func (a *application) chatTurnStop(w http.ResponseWriter, r *http.Request) {
+ a.chatActionTo(w, r, workBack(r, ""), func(ctx context.Context, address string) error {
+ err := a.store.Chat().StopConversationTurn(ctx, address, chi.URLParam(r, "id"))
+ if errors.Is(err, chat.ErrTerminal) {
+ return nil
+ }
+ return err
+ })
+}
+
+func (v chatView) HasOpen() bool {
+ for _, line := range v.Open {
+ for _, cards := range [][]chatCard{line.Cards, line.Receipts} {
+ for _, c := range cards {
+ if c.Open {
+ return true
+ }
+ }
+ }
+ }
+ 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.Presentation.Context.TaskTitle != "" {
+ return v.Presentation.Context.TaskTitle
+ }
+ 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) }
+
+func (v chatCard) ContextTask() string {
+ title := v.Presentation.Context.TaskTitle
+ if v.Kind == wire.CardTask || (v.Open && strings.Contains(v.Line, title)) {
+ return ""
+ }
+ return title
+}
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 3542cb60..2743984c 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -59,22 +59,74 @@ const BootLog = "Equipo could not start."
// COPY APPROVED BY DELEGATION (Luna pass, 2026-11-01, house rules).
var pageCopy = map[string]string{
- "id.door": "Sign in with Oficina ID", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.title": "Oficina ID", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.unlinked": "No Equipo account is linked to this Oficina ID.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.help": "Sign in by email, then link your Oficina ID in Settings.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.link": "Link Oficina ID", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.reauth": "Sign in by email again before linking or unlinking your Oficina ID.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.confirm": "Link this Oficina ID to your Equipo account?", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.confirm_button": "Confirm link", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.unlink": "Unlink Oficina ID", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.unlink_confirm": "Unlink your Oficina ID? You can still sign in by email. Your work will stay in Equipo.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.linked_at": "Linked on %s", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.not_linked": "You have not linked an Oficina ID.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.failed": "This sign-in could not be completed. Try again or sign in by email.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.email": "Sign in by email", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.signed_out": "You are signed out of Equipo.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
- "id.home_signout": "Sign out of Oficina ID too", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "roster.copy_done": "Continuing without Copy.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.stopping": "Stopping…", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+
+ "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.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)
+ "roster.reports": "reports", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.asks": "asks", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.holds": "is holding", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.busy": "Working…", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.setting_aside": "Setting aside…", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.restoring": "Restoring…", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.building": "Building…", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.sending": "Sending…", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.failed": "Couldn’t confirm that change. Try again.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.stale": "This item has changed. Check it before trying again.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.retry": "Try again", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.sent": "Sent", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.reply": "Reply", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.change": "What should change?", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.waiting": "%s is reading", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.checks": "Checks", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.review": "Review", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.branch": "Branch", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.open_task": "Open the task", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.copy_coverage": "Review coverage is not available yet.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.copy_since": "Held since %s", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.research": "Research findings", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.research_log": "Open the request log", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "roster.needs": "%d waiting for you", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)
+ "id.door": "Sign in with Oficina ID", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.title": "Oficina ID", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.unlinked": "No Equipo account is linked to this Oficina ID.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.help": "Sign in by email, then link your Oficina ID in Settings.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.link": "Link Oficina ID", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.reauth": "Sign in by email again before linking or unlinking your Oficina ID.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.confirm": "Link this Oficina ID to your Equipo account?", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.confirm_button": "Confirm link", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.unlink": "Unlink Oficina ID", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.unlink_confirm": "Unlink your Oficina ID? You can still sign in by email. Your work will stay in Equipo.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.linked_at": "Linked on %s", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.not_linked": "You have not linked an Oficina ID.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.failed": "This sign-in could not be completed. Try again or sign in by email.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.email": "Sign in by email", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.signed_out": "You are signed out of Equipo.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
+ "id.home_signout": "Sign out of Oficina ID too", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
"work.reason.copy_budget": "Copy cannot review all these strings within this task’s token allowance. Continue without Copy or ask the coordinator.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
"work.reason.copy_budget_unknown": "Copy’s token use is unknown. Check the last attempt before continuing.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13)
diff --git a/internal/equipo/icons/icons.go b/internal/equipo/icons/icons.go
index a7f3a244..9a74bf23 100644
--- a/internal/equipo/icons/icons.go
+++ b/internal/equipo/icons/icons.go
@@ -20,6 +20,8 @@ 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>`,
"message-circle": `<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="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,
diff --git a/internal/equipo/migrations/0086_conversation_roster.sql b/internal/equipo/migrations/0086_conversation_roster.sql
new file mode 100644
index 00000000..8b0a7906
--- /dev/null
+++ b/internal/equipo/migrations/0086_conversation_roster.sql
@@ -0,0 +1,6 @@
+-- A person's stream visibility is independent of the decision.
+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 b79021f5..c04fcb94 100644
--- a/internal/equipo/migrations/schema.sql
+++ b/internal/equipo/migrations/schema.sql
@@ -691,3 +691,11 @@ CREATE TRIGGER equipo_member_identity AFTER INSERT ON members WHEN NEW.identity_
END;
CREATE TABLE equipo_id_accounts (id INTEGER PRIMARY KEY AUTOINCREMENT, binding TEXT NOT NULL UNIQUE, member_key TEXT NOT NULL UNIQUE, linked_at INTEGER NOT NULL DEFAULT 0);
CREATE TABLE equipo_id_reauth (id_hash TEXT PRIMARY KEY, account_id INTEGER NOT NULL, session_hash TEXT NOT NULL, started INTEGER NOT NULL, expires INTEGER NOT NULL, purpose TEXT NOT NULL, ready INTEGER NOT NULL DEFAULT 0);
+
+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 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/rail.go b/internal/equipo/rail.go
index 8be0d83a..a5164114 100644
--- a/internal/equipo/rail.go
+++ b/internal/equipo/rail.go
@@ -99,7 +99,9 @@ func (a *application) rail(ctx context.Context, person string) railView {
needs++
}
}
- v.Needs = railCount{needs, true}
+ if questions, err := c.OpenStandaloneCards(ctx, person); err == nil {
+ v.Needs = railCount{needs + len(questions), true}
+ }
}
}
if conns, err := c.Connections(ctx, person); err == nil {
diff --git a/internal/equipo/research_views.go b/internal/equipo/research_views.go
index d5831d3b..b4c3cd8c 100644
--- a/internal/equipo/research_views.go
+++ b/internal/equipo/research_views.go
@@ -2,6 +2,8 @@ package equipo
import (
"fmt"
+ "net/url"
+ "time"
"amadan.net/oficina/equipo/internal/wire"
)
@@ -15,6 +17,8 @@ import (
// them: the summary, each fact with the pages it came from, what it could
// not find, the images it kept and its fetch log.
type researchView struct {
+ At *time.Time
+ StepID string
Summary string
Facts []researchFact
Gaps []string
@@ -62,6 +66,8 @@ func researchItem(t wire.Task, s wire.Step, v taskLine, title string) timelineIt
if s.Research != nil {
// What it fetched before it stopped: the fetch log alone.
it.Research = researchOf(t.ID, *s.Research)
+ it.Research.StepID = s.ID
+ it.Research.At = s.FinishedAt
}
case wire.StepCancelled:
// Cancelled with a reason of its own (Research left the team, the
@@ -72,6 +78,8 @@ func researchItem(t wire.Task, s wire.Step, v taskLine, title string) timelineIt
}
if s.Research != nil {
it.Research = researchOf(t.ID, *s.Research)
+ it.Research.StepID = s.ID
+ it.Research.At = s.FinishedAt
}
default:
it.Kind, it.What, it.Took, it.At = "step", title, took(s), s.FinishedAt
@@ -83,6 +91,8 @@ func researchItem(t wire.Task, s wire.Step, v taskLine, title string) timelineIt
break
}
it.Research = researchOf(t.ID, *s.Research)
+ it.Research.StepID = s.ID
+ it.Research.At = s.FinishedAt
}
return it
}
@@ -144,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/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..35d73b06 100644
--- a/internal/equipo/static/chat-compose.js
+++ b/internal/equipo/static/chat-compose.js
@@ -39,3 +39,23 @@
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) {if(event.target.hasAttribute("data-restored")){delete event.target.dataset.restored;return;}event.target.querySelector("textarea").focus({preventScroll:true});}
+ },true);
+})();
+(function () {
+ "use strict";
+ document.addEventListener("keydown", function(e) {
+ var form=e.target.closest("[equipo-mini-composer]");
+ if(!form || e.target.tagName!=="TEXTAREA" || e.key!=="Enter" || e.shiftKey || e.isComposing || e.keyCode===229)return;
+ e.preventDefault();var send=form.querySelector("[data-thread-send]");if(send && !send.disabled)form.requestSubmit(send);
+ });
+})();
diff --git a/internal/equipo/static/chat-stream.js b/internal/equipo/static/chat-stream.js
index a0646e54..18acd330 100644
--- a/internal/equipo/static/chat-stream.js
+++ b/internal/equipo/static/chat-stream.js
@@ -21,7 +21,9 @@
var id = el.dataset.turn || el.dataset.turnId;
if (thread && id) asked[id] = asked[id] || "";
});
+ root.setAttribute("data-roster-enhanced", "");
var feed = root.querySelector("[equipo-feed]");
+ root.querySelectorAll("[data-card-form]").forEach(function(f){f.dataset.busy="false";});
var offline = root.querySelector("[equipo-offline]");
var form = document.getElementById("composer");
var cursor = Number(root.dataset.cursor) || 0;
@@ -226,6 +228,11 @@
var cs = getComputedStyle(li).maxInlineSize;
var max = /%$/.test(cs) ? parseFloat(cs) / 100 * li.parentElement.clientWidth : parseFloat(cs) || li.parentElement.clientWidth;
var room = Math.floor(max - (line.offsetWidth - phrase.offsetWidth) - 8);
+ if (!thread) {
+ var elapsed=line.querySelector("[equipo-elapsed]"), sep=line.querySelector("[equipo-activity-sep]");
+ var gap=parseFloat(getComputedStyle(line).columnGap)||0;
+ room=Math.floor(line.clientWidth-(elapsed?elapsed.offsetWidth:0)-(sep?sep.offsetWidth:0)-gap*3-8);
+ }
phrase.querySelectorAll("[data-in]").forEach(function (old) {
old.removeAttribute("data-in");
old.setAttribute("data-out", "");
@@ -443,6 +450,7 @@
// now with the server's attributes, time and markdown. No reflow.
function settle(live, server) {
clearTimeout(live.holding);
+ var stop=live.querySelector("[equipo-turn-stop]");if(stop)stop.remove();
var line = live.querySelector("[equipo-activity-line]");
Array.from(live.attributes).forEach(function (a) { live.removeAttribute(a.name); });
Array.from(server.attributes).forEach(function (a) { live.setAttribute(a.name, a.value); });
@@ -611,6 +619,8 @@
var format = root.dataset.elapsed || "{n}s";
feed.querySelectorAll("[equipo-thinking]").forEach(function (el) {
enliven(el);
+ var stop = el.querySelector("[equipo-turn-stop]");
+ if (stop && el.dataset.turn && !el.hasAttribute("data-optimistic")) { stop.action="/conversation/turns/"+encodeURIComponent(el.dataset.turn)+"/stop"; stop.hidden=false; }
var out = el.querySelector("[equipo-elapsed]");
var started = Number(el.dataset.started) || Date.now();
if (out) out.textContent = format.replace("{n}", String(Math.max(0, Math.floor((Date.now() - started) / 1000))));
@@ -624,6 +634,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 : "";
@@ -776,8 +788,11 @@
.then(function (body) {
var doc = new DOMParser().parseFromString(body, "text/html");
var next = doc.querySelector("[equipo-feed]");
+ if (next) next.querySelectorAll("[data-card-form]").forEach(function(f){f.dataset.busy="false";});
var page = doc.querySelector("[data-chat-stream]");
if (!next || !page) return;
+ var pill=root.querySelector("[equipo-needs-pill]"), nextPill=doc.querySelector("[equipo-needs-pill]");
+ if(pill && nextPill) pill.replaceWith(nextPill);
var build = newer(doc);
if (build) reloadWhenQuiet(build);
var at = Number(page.dataset.cursor) || 0;
@@ -788,6 +803,8 @@
// Keep live timers and activity lines across the re-render.
// A newly committed reply settles into its draft's element; a turn
// may already have earlier messages on the page.
+ var focused=document.activeElement, focusedCard=focused && focused.closest("[data-card]");
+ var cardFocus=focusedCard && /^(TEXTAREA|INPUT)$/.test(focused.tagName) ? {id:focusedCard.dataset.card,name:focused.name,start:focused.selectionStart,end:focused.selectionEnd} : null;
var keep = {}, shown = {}, opened = {};
feed.querySelectorAll("[equipo-thinking]:not([data-optimistic])").forEach(function (el) { keep[el.dataset.turn] = el; });
// A receipt the person opened with ⋯ stays open.
@@ -798,6 +815,18 @@
var more = el.querySelector("[equipo-receipt-more]");
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.dataset.restored="";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", ""); } });
+ });
feed.querySelectorAll("[data-message]").forEach(function (el) { shown[el.dataset.message] = true; });
feed.replaceChildren.apply(feed, Array.from(next.children).map(function (el) {
var fresh = el.matches('[equipo-message="incoming"][data-turn-id]') && !shown[el.dataset.message];
@@ -833,12 +862,16 @@
}
return settle(old, el);
}).filter(Boolean));
+ if(cardFocus) {
+ var target=feed.querySelector('[data-card="'+CSS.escape(cardFocus.id)+'"] [name="'+CSS.escape(cardFocus.name)+'"]');
+ if(target) {target.focus({preventScroll:true});if(target.setSelectionRange)target.setSelectionRange(cardFocus.start,cardFocus.end);}
+ }
// A stale page lacks lines for turns that started since: they stay.
if (stale) Object.keys(keep).forEach(function (turn) { if (!ended[turn] && !queued[turn]) feed.append(keep[turn]); });
local.forEach(function (el) { place(el); });
pending.forEach(function (el) { feed.append(el); });
Object.keys(drafts).forEach(function (turn) {
- if (feed.querySelector('[equipo-thinking][data-turn="' + CSS.escape(turn) + '"]')) showDraft(turn);
+ if (feed.querySelector('[equipo-thinking][data-turn="' + CSS.escape(turn) + '"], [data-roster-turn="' + CSS.escape(turn) + '"] [equipo-thread-draft]')) showDraft(turn);
});
notes();
tick();
@@ -856,6 +889,7 @@
return;
}
var question = e.resource === "question";
+ if(type==="activity" && e.resource==="step" && v.step_id && feed.querySelector('[data-roster-step="'+CSS.escape(v.step_id)+'"]')) { refreshSoon(); return; }
if (thread) {
// The thread: its own questions' streams; everything else about
// the task is rendered by the server, like a committed reply.
@@ -886,6 +920,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.
@@ -1035,17 +1071,66 @@
toggle.removeAttribute("aria-busy");
});
});
- // Card actions (Change, Remove, answers) post in the background and the
- // card events re-render the feed; without script the forms still work.
- feed.addEventListener("submit", function (event) {
- var f = event.target.closest("[data-card-form]");
- if (!f) return;
- event.preventDefault();
- var body = new URLSearchParams(new FormData(f, event.submitter));
- f.querySelectorAll("button").forEach(function (b) { b.disabled = true; });
+ // Card actions preserve the card on failure and expose the result in place.
+ 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;
+ var body = new URLSearchParams(new FormData(f, button));
+ var previous = button && button.innerHTML;
+ var controls = card || f;
+ if (id) cardBusy.set(id, card);
+ controls.setAttribute("aria-busy", "true");
+ controls.querySelectorAll("button").forEach(function (b) { b.disabled = true; });
+ if (button) { button.setAttribute("aria-busy", "true"); button.textContent = button.dataset.busyLabel || root.dataset.cardBusy; }
+ var error = controls.querySelector("[equipo-card-error]");
+ 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("card"); return refresh(); })
- .catch(function () { refreshSoon(); });
+ .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); f.querySelectorAll("textarea").forEach(function (el) { el.value=""; }); } }
+ if (f.matches("[equipo-turn-stop]")) return;
+ return refreshed();
+ }).then(function () {
+ if (body.get("aside") === "true") {
+ var stub = feed.querySelector('[data-card="' + CSS.escape(id) + '"] [equipo-aside-stub]');
+ var toast = root.querySelector("[equipo-roster-toast]");
+ if (stub && toast) {
+ toast.replaceChildren(document.createTextNode(root.dataset.asideLabel), stub.querySelector("form").cloneNode(true));
+ toast.hidden = false;
+ // Re-pin before the smaller scroll area can report a scroll
+ // event and clear following. Stop stays above the composer.
+ scroll();
+ clearTimeout(toastTimer); toastTimer = setTimeout(function () { toast.hidden = true; scroll(); }, 7000);
+ var undo = stub.querySelector("button"); if (undo) undo.focus({preventScroll:true});
+ }
+ } else if (body.get("aside") === "false") {
+ var toast = root.querySelector("[equipo-roster-toast]"); if (toast) toast.hidden = true;
+ var restored = feed.querySelector('[data-card="' + CSS.escape(id) + '"] [data-set-aside]'); if (restored) restored.focus({preventScroll:true});
+ }
+ }).catch(function (e) {
+ if (id) cardBusy.delete(id);
+ controls.removeAttribute("aria-busy");
+ controls.querySelectorAll("button").forEach(function (b) { b.disabled = false; });
+ if (button) { button.removeAttribute("aria-busy"); button.innerHTML = previous; }
+ if (!error) { error = document.createElement("p"); error.setAttribute("equipo-card-error", ""); error.setAttribute("role", "alert"); controls.append(error); }
+ error.hidden = false;
+ error.textContent = e.message === "stale" ? root.dataset.cardStale : root.dataset.cardFailed;
+ var retry = document.createElement("button"); retry.type = "button"; retry.setAttribute("equipo-link", ""); retry.textContent = root.dataset.cardRetry;
+ retry.addEventListener("click", function () { if (e.message === "stale") refreshed(); else cardSubmit(f, button); }); error.append(retry);
+ });
+ }
+ root.addEventListener("click", function(event) {
+ var open=event.target.closest("[data-thread-open]"); if(!open || open.disabled)return;
+ var drawer=open.closest("[data-card]").querySelector("[data-direction-thread]"); drawer.open=true; drawer.querySelector("textarea").focus();
+ });
+ root.addEventListener("submit", function (event) {
+ var f = event.target.closest("[data-card-form]"); if (!f) return;
+ event.preventDefault();
+ // A toast uses the live stub's form, so it has the card's revision.
+ if (f.closest("[equipo-roster-toast]")) {
+ var match = feed.querySelector('[equipo-aside-stub] form[action="' + CSS.escape(f.getAttribute("action")) + '"]');
+ if (match) cardSubmit(match, match.querySelector("button")); else f.closest("[equipo-roster-toast]").hidden=true;
+ } else cardSubmit(f, event.submitter);
});
// Sending stays on this page: no navigation, so no page transition. The
// bubble shows at once; the background post uses the form's own action
diff --git a/internal/equipo/static/equipo.css b/internal/equipo/static/equipo.css
index 5ef5b5d8..1962f1ae 100644
--- a/internal/equipo/static/equipo.css
+++ b/internal/equipo/static/equipo.css
@@ -1766,3 +1766,228 @@ label[equipo-sp-label] { cursor: pointer; }
[equipo-copy-form] textarea { min-block-size: 6rem; }
[equipo-copy-flag] { padding: var(--rst-sp-4); }
[equipo-t-head] > [data-copy-flag] { grid-column: 1 / -1; }
+
+/* Roster: bylines sit on the page; only decisions are raised. */
+[equipo-conversation] { -webkit-text-size-adjust: 100%; }
+[equipo-conversation] [equipo-scroll] { container: roster / inline-size; }
+[equipo-conversation] [equipo-feed] { gap: 1rem; font-size: 1rem; }
+[equipo-conversation] [equipo-card] { display: block; position: relative; inline-size: 100%; max-inline-size: 48rem; align-self: center; margin: 0; padding: 0 0 0 3rem; border: 0; border-radius: 0; background: transparent; font-size: 1rem; }
+[equipo-roster-byline] { display: flex; flex-wrap: wrap; align-items: center; gap: .125rem .375rem; min-block-size: 1.875rem; margin-block-end: .125rem; color: var(--rst-text-muted); font-size: var(--rst-fs-sm); }
+[equipo-roster-byline] b { font-size: 1rem; font-weight: 700; color: var(--rst-text); }
+[equipo-roster-byline] time { color: var(--rst-text-faint); font-size: var(--rst-fs-xs); }
+[equipo-roster-avatar] { display: grid; place-items: center; position: absolute; inset-inline-start: 0; inset-block-start: 0; inline-size: 1.875rem; block-size: 1.875rem; border: 1px solid var(--rst-line); border-radius: calc(var(--rst-radius) * 11 / 6); background: var(--rst-surface); box-shadow: var(--rst-shadow-lift); }
+[equipo-coordinator-mark] { display: inline-grid; place-items: center; background: transparent; border-color: transparent; box-shadow: none; color: var(--rst-text-muted); }
+[equipo-coordinator-mark] svg { inline-size: 1.375rem; block-size: 1.375rem; }
+[equipo-roster-card] { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; padding: .625rem 1rem; border: 1px solid var(--rst-line); border-radius: calc(var(--rst-radius) * 8 / 3); background: var(--rst-surface-2); }
+[equipo-roster-card][data-ask] { background: var(--rst-surface); border-color: var(--rst-light-rim); box-shadow: var(--rst-shadow-pop); }
+[equipo-roster-report] { display: grid; gap: .5rem; min-inline-size: 0; }
+[equipo-roster-report-head] { display: flex; align-items: start; justify-content: space-between; gap: .625rem; }
+[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][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: .375rem; }
+[equipo-roster-facts] > div { min-inline-size: 0; padding-inline: .625rem; 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 { font-size: var(--rst-fs-xs); line-height: 1.35; 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] { 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: 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); }
+[equipo-conversation] [equipo-message-meta] [equipo-coordinator-mark] { position: absolute; inset-inline-start: 0; inline-size: 2.25rem; }
+[equipo-conversation] [equipo-message-meta] time { margin-inline-start: 0; }
+[equipo-conversation] [equipo-message="incoming"] [equipo-bubble] { font-size: 1rem; line-height: 1.55; }
+@container roster (max-width: 500px) {
+ [equipo-conversation] [equipo-card] { padding-inline-start: 0; }
+ [equipo-roster-byline] { padding-inline-start: 2.5rem; min-block-size: 1.875rem; }
+ [equipo-roster-avatar] { inline-size: 1.875rem; block-size: 1.875rem; }
+ [equipo-roster-card] { border-radius: calc(3 * var(--rst-radius)); padding: .625rem .75rem; }
+ [equipo-roster-facts] { grid-template-columns: 1fr; gap: .25rem; }
+ [equipo-roster-facts] > div { display: grid; grid-template-columns: 4.5rem minmax(0,1fr); padding: 0; border: 0; align-items: baseline; }
+ [equipo-roster-facts] small { grid-column: 2; }
+ [equipo-roster-report] [equipo-track-full] li:not([aria-current]) > span:last-of-type { visibility: hidden; }
+ [equipo-roster-report] [equipo-track-full] small { display: none; }
+ [equipo-conversation] [equipo-message="incoming"] { padding-inline-start: 0; }
+ [equipo-conversation] [equipo-message="incoming"] [equipo-message-meta] { padding-inline-start: 2.5rem; min-block-size: 1.875rem; }
+ [equipo-roster-card] [equipo-actions] { display: grid; grid-template-columns: 1fr 1fr; }
+ [equipo-roster-card] button { min-block-size: 2.75rem; }
+ [equipo-roster-card] [rst-btn="primary"] { grid-column: 1 / -1; }
+}
+[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: 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: 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; }
+@media (max-width: 500px) { [equipo-chat-header] > [equipo-header-button] { display: none; } }
+@container roster (max-width: 500px) { [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 -.625rem; padding: .5rem 1rem .625rem; 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: .5rem; margin-block-end: .5rem; }
+[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: 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); }
+[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); }
+@container roster (max-width:500px) { [equipo-subchat] { margin-inline: -.75rem; padding-inline: .75rem; } [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: .5rem; }
+[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: inline-flex; align-items: center; margin: 0 .25rem 0 0; color: var(--rst-text-muted); font-size: var(--rst-fs-xs); text-decoration: none; overflow-wrap: anywhere; }
+[equipo-roster-findings] a > span { padding: .125rem .5rem; border: 1px solid var(--rst-line); border-radius: 999px; }
+[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-edge); transform: translateY(1px); }
+[equipo-roster-card] button:active { transform: translateY(1px); }
+/* One quiet live line; the roster byline already carries the mark. */
+[equipo-conversation]:not([data-task]) [equipo-thinking] [equipo-sparkle] { display: none; }
+[equipo-conversation]:not([data-task]) [equipo-thinking] [equipo-bubble] { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: .5rem; }
+[equipo-conversation]:not([data-task]) [equipo-thinking] [data-stream-text] { grid-column: 1 / -1; }
+[equipo-conversation]:not([data-task]) [equipo-thinking] [equipo-activity-line] { grid-column: 1; margin: 0; color: var(--rst-text-muted); font-size: var(--rst-fs-sm); }
+[equipo-turn-stop] { grid-column: 2; margin: 0; }
+[equipo-turn-stop][hidden] { display: none; }
+[equipo-turn-stop] button { min-block-size: 2.75rem; font-size: var(--rst-fs-sm); color: var(--rst-text-muted); }
+[equipo-conversation] [equipo-thinking] [equipo-coordinator-mark] { animation: roster-think 2.6s ease-in-out infinite; }
+@keyframes roster-think { 50% { transform: rotate(45deg) scale(.85); opacity: .5; } }
+@media (prefers-reduced-motion: reduce) { [equipo-conversation] [equipo-thinking] [equipo-coordinator-mark] { animation: none; } }
+[equipo-mini-pill] button[aria-busy="true"] { inline-size: auto; border-radius: calc(4 * var(--rst-radius)); font-size: var(--rst-fs-xs); padding-inline: .75rem; }
+[equipo-set-aside] button[aria-busy="true"] { inline-size: auto; padding-inline: .5rem; background: var(--rst-surface); font-size: var(--rst-fs-xs); }
+[equipo-roster-card] { color: var(--rst-text); }
+[equipo-copy-hold] > p, [data-research-report] > p { color: var(--rst-text-muted); }
+[equipo-copy-hold] > [equipo-roster-stage] { color: var(--rst-tone-warning-fg); }
+[equipo-roster-byline] { position: relative; }
+[equipo-roster-avatar] { inset-inline-start: -3rem; }
+[equipo-roster-card] + [equipo-roster-byline] { margin-block-start: 1rem; }
+@container roster (max-width:500px) {
+ [equipo-roster-avatar] { inset-inline-start: 0; }
+ [equipo-roster-card] [equipo-actions] > form:has([rst-btn="primary"]) { grid-column: 1 / -1; }
+ [equipo-roster-card] [equipo-actions] > form { display: contents; }
+ [equipo-roster-card] [equipo-actions] [rst-btn] { min-block-size: 2.75rem; min-inline-size: 0; white-space: normal; text-align: center; justify-content: center; padding-inline: .5rem; }
+}
+[equipo-roster-card][data-done] > :not([equipo-card-done], [equipo-roster-task]) { display: none; }
+[data-thread-open] { display: none; }
+[data-roster-enhanced] [data-thread-open] { display: inline-flex; }
+[data-roster-enhanced] [data-direction-thread] > summary { display: none; }
+[equipo-roster-report][data-slim] [equipo-roster-report-head] h3 { font-size: .9375rem; }
+[equipo-roster-report][data-slim] [equipo-roster-facts] { display: flex; flex-wrap: wrap; gap: .5rem 1rem; border: 0; padding: 0; }
+[equipo-roster-report][data-slim] [equipo-roster-facts] > div { padding: 0; border: 0; }
+[equipo-roster-report][data-slim] [equipo-roster-facts] dt { display: none; }
+[equipo-exploration-summary] { margin: 0; color: var(--rst-text-muted); }
+[equipo-roster-card] + [equipo-roster-card] { margin-block-start: .75rem; }
+[equipo-conversation]:not([data-task]) [equipo-thinking] [equipo-activity-line] { inline-size: 100%; min-inline-size: 0; }
+[equipo-roster-report] [equipo-roster-stage][equipo-stage] { margin: 0; padding: 0; border: 0; background: transparent; font-size: var(--rst-fs-xs); }
+[equipo-thread-error] { color: var(--rst-tone-negative-fg); font-size: var(--rst-fs-sm); }
+@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: normal; overflow-wrap: anywhere; }
+[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; }
+@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-conversation] [data-turn-stop] { text-decoration: none; color: var(--rst-text-muted); font-size: var(--rst-fs-sm); min-block-size: 2.75rem; padding-inline: .5rem; }
+
+[equipo-roster-project] { display: inline-flex; align-items: center; gap: .25rem; min-inline-size: 0; max-inline-size: 50%; color: var(--rst-text-muted); }
+[equipo-roster-project] [equipo-mono] { inline-size: 1rem; block-size: 1rem; font-size: .625rem; }
+[equipo-project-name] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+[equipo-roster-task] { margin: 0; color: var(--rst-text-muted); font-size: var(--rst-fs-xs); line-height: 1.35; overflow-wrap: anywhere; }
+[equipo-roster-research-head] { display: flex; flex-wrap: wrap; gap: .125rem .5rem; align-items: baseline; }
+[equipo-roster-research-head] h3 { font-size: 1rem; }
+[equipo-roster-facts] dd { line-height: 1.35; }
+@container roster (max-width:500px) {
+ [equipo-roster-card] a[rst-btn], [equipo-roster-links] a, [data-research-report] > a, [equipo-roster-findings] a { min-block-size: 2.75rem; display: inline-flex; align-items: center; }
+}
+@container roster (max-width:500px) {
+ [equipo-roster-report-head] h3 a { position: relative; }
+ [equipo-roster-report-head] h3 a::after { content: ""; position: absolute; inset-inline: 0; min-inline-size: 2.75rem; block-size: 2.75rem; inset-block-start: 50%; transform: translateY(-50%); }
+ [equipo-aside-stub] button, [equipo-roster-toast] button { min-inline-size: 2.75rem; }
+ [equipo-roster-card] [data-preview-link], [equipo-roster-card] [data-site-link] { display: inline-flex; align-items: center; min-block-size: 2.75rem; }
+}
diff --git a/internal/equipo/templates/chat.html b/internal/equipo/templates/chat.html
index 9ed15926..fe91e38d 100644
--- a/internal/equipo/templates/chat.html
+++ b/internal/equipo/templates/chat.html
@@ -1,14 +1,18 @@
{{define "up-label"}}{{copy "nav.work"}}{{end}}
{{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}} data-card="{{.ID}}" data-state="{{.State}}" data-turn-id="{{.TurnID}}">
-{{if and .Receipt (eq .Kind "task")}}{{template "work-task-receipt" .}}
+{{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 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}}
+{{with .ContextTask}}<p equipo-roster-task>{{.}}</p>{{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}}
{{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 "question"}}<div equipo-subchat data-question-thread data-roster-turn="{{.Presentation.TurnID}}">
+<div equipo-thread-list role="log" aria-live="polite"><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 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 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 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 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 "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" .}}{{range .Options}}{{if eq . "again"}}<button type="button" rst-btn data-thread-open>{{copy "chat.card.again"}}</button>{{else}}<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 role="log" aria-live="polite"><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 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 role="status">{{.}}</p>{{end}}{{if .Presentation.Thread}}<div equipo-subchat data-roster-step="{{.Presentation.StepID}}"><div equipo-thread-list role="log" aria-live="polite">{{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 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}}
@@ -16,14 +20,26 @@
{{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}}</li>{{end}}
-{{define "work-task-receipt"}}{{with .Task}}<p equipo-card-line>{{icon "check-circle"}}<span><a href="/tasks/{{.ID}}">{{.Title}}</a></span><span equipo-stage data-stage="{{.Stage}}" data-needs="{{.NeedsYou}}">{{.StageLine}}</span></p>{{if and .Pushed (not .MergedLine)}}<p equipo-card-note data-pushed><span>{{.Pushed}}</span><a href="{{.URL}}" rel="noopener" target="_blank" data-open-amadan>{{copy "work.open"}}</a></p>{{end}}{{if or .ChecksLine .ReviewLine}}<p equipo-card-note data-judged>{{with .ChecksLine}}<span data-checks>{{.}}</span>{{end}}{{with .ReviewLine}}<span data-verdict>{{.}}</span>{{end}}</p>{{end}}{{if .MergedLine}}<p equipo-card-note data-merged><span>{{.MergedLine}}</span><a href="{{.RepoURL}}" rel="noopener" target="_blank" data-open-amadan>{{copy "work.open"}}</a></p>{{end}}{{if .PreviewURL}}<p equipo-card-note data-preview><a href="{{.PreviewURL}}" rel="noopener" target="_blank">{{.PreviewLine}}</a></p>{{end}}{{end}}{{if .Open}}<button type="button" equipo-receipt-more aria-expanded="false" aria-controls="acts-{{.ID}}" aria-label="{{copy "chat.card.more"}}">⋯</button><span equipo-receipt-actions id="acts-{{.ID}}">{{template "work-task-actions" .Task}}</span>{{end}}{{end}}
+{{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>{{template "roster-project" $}}{{with .At}}<time datetime="{{.Format "2006-01-02T15:04:05Z07:00"}}">{{.Format "15:04"}}</time>{{end}}</div><section equipo-roster-card data-research-report><header equipo-roster-research-head><h3>{{copy "roster.research"}}</h3>{{with $.Presentation.Context.TaskTitle}}<span equipo-roster-task>{{.}}</span>{{end}}</header><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"><span>{{.Domain}}</span></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><a rst-btn="primary" href="/conversation?about={{.TaskID}}">{{copy "work.decide.ask_coordinator"}}</a>{{if .Task.CopyCanSkip}}<form method="post" action="/conversation/tasks/{{.TaskID}}/continue-without-copy" data-card-form><button rst-btn type="submit" data-copy-continue>{{copy "copy.continue"}}</button></form>{{end}}</div></div>{{end}}
+{{define "roster-thread-turns"}}{{range .Presentation.Thread}}<div equipo-thread-turn{{if .Own}} data-own{{end}}>{{if not .Own}}<span equipo-thread-avatar{{if eq $.AuthorIcon "sparkles"}} equipo-coordinator-mark{{end}}>{{if eq $.AuthorIcon "sparkles"}}{{template "roster-mark" .}}{{else}}{{icon $.AuthorIcon}}{{end}}</span>{{end}}<div equipo-thread-bubble>{{if not .Own}}<div equipo-thread-who>{{$.Author}} <time datetime="{{.At.Format "2006-01-02T15:04:05Z07:00"}}">{{.At.Format "15:04"}}</time></div>{{end}}<div equipo-thread-text equipo-markdown>{{chatMarkdown .Text}}</div></div>{{if .Own}}<small equipo-thread-sent>{{copy "roster.sent"}}</small>{{end}}</div>{{end}}{{with .ThreadError}}<p equipo-thread-error role="alert">{{.}}</p>{{end}}{{if .Presentation.Waiting}}<div equipo-thread-wait role="status"><span equipo-reading-dots aria-hidden="true"><i></i><i></i><i></i></span><span>{{if .ThreadActivity}}{{.ThreadActivity}}{{else}}{{printf (copy "roster.waiting") .Author}}{{end}}</span><div equipo-thread-draft></div></div>{{end}}{{end}}
+{{define "roster-undo"}}<form method="post" action="/conversation/cards/{{.ID}}/visibility" data-card-form><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="aside" value="false">{{template "card-job" .}}<button equipo-link type="submit" data-aside-undo data-busy-label="{{copy "roster.restoring"}}">{{copy "roster.undo"}}</button></form>{{end}}
+{{define "roster-byline"}}<div equipo-roster-byline><span equipo-roster-avatar{{if eq .AuthorIcon "sparkles"}} equipo-coordinator-mark{{end}}>{{if eq .AuthorIcon "sparkles"}}{{template "roster-mark" .}}{{else}}{{icon .AuthorIcon}}{{end}}</span><b>{{.Author}}</b><span>{{.Verb}}</span>{{template "roster-project" .}}<time datetime="{{.BylineAt.Format "2006-01-02T15:04:05Z07:00"}}">{{.BylineAt.Format "15:04"}}</time></div>{{end}}
+{{define "roster-project"}}{{if .Presentation.Context.ProjectTitle}}<span equipo-roster-project><span aria-hidden="true">·</span>{{template "mono-s" .ProjectMono}}<span equipo-project-name title="{{.Presentation.Context.ProjectTitle}}">{{.Presentation.Context.ProjectTitle}}</span></span>{{end}}{{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-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>{{.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}}
{{range .Receipts}}{{template "chat-card" .}}{{end}}
<li equipo-message="{{if .Own}}own{{else}}incoming{{end}}" data-message="{{.ID}}" data-turn-id="{{.TurnID}}">
-<div equipo-message-meta><strong{{if .Own}} equipo-visually-hidden{{end}}>{{if .Own}}{{$address}}{{else}}{{icon "message-circle"}}{{copy "conversation.coordinator"}}{{end}}</strong><time datetime="{{.CreatedAt.Format "2006-01-02T15:04:05Z07:00"}}">{{.CreatedAt.Format "15:04"}}</time></div>
+<div equipo-message-meta><strong{{if .Own}} equipo-visually-hidden{{end}}>{{if .Own}}{{$address}}{{else}}<span equipo-coordinator-mark>{{template "roster-mark" .}}</span>{{copy "conversation.coordinator"}}{{end}}</strong><time datetime="{{.CreatedAt.Format "2006-01-02T15:04:05Z07:00"}}">{{.CreatedAt.Format "15:04"}}</time></div>
{{if .Own}}{{template "message-files" .Files}}{{end}}<div equipo-bubble>{{if .Own}}<p equipo-message-body>{{.Text}}</p>{{else}}<div equipo-message-body equipo-markdown>{{chatMarkdown .Text}}</div>{{end}}</div>
{{with .Waiting}}<p equipo-card-note data-waiting-connection>{{.}}</p>{{end}}
{{with .Queued}}<p equipo-card-note data-queued>{{.}}</p>{{end}}
@@ -33,6 +49,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}}" data-w="{{.Width}}"></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>
@@ -40,25 +57,25 @@
</li>{{end}}
{{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-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>
+<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 .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">
-<template equipo-message-template><li equipo-message="incoming" data-message=""><div equipo-message-meta><strong>{{icon "message-circle"}}{{copy "conversation.coordinator"}}</strong><time></time></div><div equipo-bubble><div equipo-message-body equipo-chat-text></div></div></li></template>
+<template equipo-message-template><li equipo-message="incoming" data-message=""><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-chat-text></div></div></li></template>
<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>{{icon "message-circle"}}{{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></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}}
{{if .Chat.Days}}<li equipo-day-divider data-today><span>{{copy "chat.day.today"}}</span></li>{{end}}
-{{with .Chat.Open}}<li equipo-day-note data-still-open>{{copy "chat.day.still_open"}}</li>{{end}}
+{{if .Chat.HasOpen}}<li equipo-day-note data-still-open>{{copy "chat.day.still_open"}}</li>{{end}}
{{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>{{icon "message-circle"}}{{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></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>
@@ -66,6 +83,7 @@
</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/equipo/templates/work_needs.html b/internal/equipo/templates/work_needs.html
index 03a49b47..a48afa04 100644
--- a/internal/equipo/templates/work_needs.html
+++ b/internal/equipo/templates/work_needs.html
@@ -1,7 +1,8 @@
{{define "title"}}{{copy "nav.needs-you"}}{{end}}
{{define "content"}}
<section equipo-work equipo-inner data-work-live data-work-region id="work-needs">
-{{with .Thin}}<div equipo-page-head><h1>{{copy "nav.needs-you"}}</h1><p>{{if eq (len .Decisions) 0}}{{copy "work.needs_empty"}}{{else if eq (len .Decisions) 1}}{{copy "work.needs.one"}}{{else}}{{printf (copy "work.needs.many") (len .Decisions)}}{{end}}</p></div>
+{{with .Thin}}<div equipo-page-head><h1>{{copy "nav.needs-you"}}</h1><p>{{if eq .DecisionCount 0}}{{copy "work.needs_empty"}}{{else}}{{printf (copy "roster.needs") .DecisionCount}}{{end}}</p></div>
+{{range .Questions}}<article equipo-decision><h2>{{.Line}}</h2><a equipo-btn href="{{if .Job}}/jobs/{{.Job}}{{else}}/conversation{{end}}?card={{.ID}}#card-{{.ID}}">{{copy "conversation.title"}}</a></article>{{end}}
{{range .Decisions}}{{template "decision" (dict "Task" . "Head" true "From" "needs")}}{{end}}
{{with .Groups}}{{template "work-groups" (dict "Groups" . "From" "needs")}}{{end}}{{end}}
</section>
diff --git a/internal/equipo/templates/work_parts.html b/internal/equipo/templates/work_parts.html
index f949f4fc..f9111329 100644
--- a/internal/equipo/templates/work_parts.html
+++ b/internal/equipo/templates/work_parts.html
@@ -37,7 +37,7 @@
{{if $.Head}}{{template "mono" $t.Mono}}<div equipo-d-title><a href="/tasks/{{$t.ID}}">{{$t.Title}}</a><span equipo-quiet>{{$t.Project}} · {{template "source" $t}}</span></div>{{end}}
<p equipo-d-why>{{.Why}}</p>
<p equipo-d-ask>{{.Ask}}</p>{{if .Link}}<p equipo-quiet data-direction-line>{{with .LinkText}}{{.}} {{end}}<a equipo-link href="{{.Link}}" rel="noopener noreferrer" target="_blank" data-direction-link>{{.LinkLabel}}</a>{{with .AltLink}} <a equipo-link href="{{.}}" rel="noopener noreferrer" target="_blank" data-direction-branch>{{$t.Decision.AltLabel}}</a>{{end}}</p>{{end}}{{with .Said}}<p equipo-quiet data-triage-said>{{.}}</p>{{end}}{{with .Failed}}<p equipo-quiet data-triage-failed>{{.}}</p>{{end}}{{with .Recommend}}<p equipo-quiet data-triage-recommend>{{.}}</p>{{end}}
-<div equipo-d-actions>{{with .Card}}<form method="post" action="/conversation/cards/{{.ID}}/answer"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="from" value="{{$.From}}"><input type="hidden" name="task" value="{{$t.ID}}">{{if $.Task.Decision.Note}}<textarea rst-input name="note" maxlength="1000" rows="2" aria-label="{{copy "chat.card.direction_note"}}" placeholder="{{copy "chat.card.direction_note"}}" data-direction-note></textarea>{{end}}{{range $.Task.Decision.Choices}}<button equipo-btn{{if .Primary}} data-primary{{end}} type="submit" name="choice" value="{{.Value}}" data-merge-choice="{{.Value}}">{{.Label}}</button>{{end}}</form>{{end}}{{if .Fold}}<form method="post" action="/tasks/{{$t.ID}}/duplicate"><input type="hidden" name="from" value="{{$.From}}"><input type="hidden" name="of" value="{{$t.Dup.ID}}"><button equipo-btn data-primary type="submit" data-task-duplicate>{{copy "work.decide.fold"}}</button></form>{{end}}{{if .Recover}}<form method="post" action="/conversation/tasks/{{$t.ID}}/recover"><input type="hidden" name="from" value="{{$.From}}"><button equipo-btn data-primary type="submit" data-task-recover>{{copy "work.recover"}}</button></form>{{end}}{{with .Unsandboxed}}<details equipo-mach-confirm data-unsandboxed><summary equipo-btn>{{copy "work.decide.unsandboxed"}}</summary><div><p>{{.Warning}}</p><form method="post" action="/conversation/tasks/{{$t.ID}}/unsandboxed"><input type="hidden" name="from" value="{{$.From}}"><input type="hidden" name="step" value="{{.Step}}"><input type="hidden" name="attempt" value="{{.Attempt}}"><button equipo-btn data-danger type="submit" data-task-unsandboxed>{{copy "work.decide.unsandboxed_confirm"}}</button></form></div></details>{{end}}{{if .Retry}}<form method="post" action="/conversation/tasks/{{$t.ID}}/retry"><input type="hidden" name="from" value="{{$.From}}"><button {{if .Fold}}equipo-link{{else}}equipo-btn data-primary{{end}} type="submit" data-task-retry>{{copy "work.retry"}}</button></form>{{end}}{{if .Round}}<form method="post" action="/conversation/tasks/{{$t.ID}}/round"><input type="hidden" name="from" value="{{$.From}}"><button equipo-btn data-primary type="submit" data-task-round>{{copy "work.decide.round"}}</button></form>{{end}}{{if .Talk}}<a equipo-btn href="/conversation?about={{$t.ID}}" data-ask-coordinator>{{copy "work.decide.ask_coordinator"}}</a>{{end}}{{if .Cancel}}<form method="post" action="/conversation/tasks/{{$t.ID}}/cancel"><input type="hidden" name="from" value="{{$.From}}"><button equipo-link type="submit" data-task-cancel>{{copy "work.decide.cancel"}}</button></form>{{end}}{{with .Hint}}<span equipo-quiet>{{.}}</span>{{end}}<span equipo-d-quiet>{{if .Mac}}<a equipo-link href="/conversation/settings/machines/add" data-set-up-mac>{{copy "work.decide.mac_set_up"}}</a>{{end}}<a equipo-link href="/conversation?about={{$t.ID}}" data-ask-about>{{copy "work.ask_about"}}</a></span></div>
+<div equipo-d-actions>{{if .CopyContinue}}<form method="post" action="/conversation/tasks/{{$t.ID}}/continue-without-copy"><input type="hidden" name="from" value="{{$.From}}"><button equipo-btn data-primary type="submit" data-copy-continue>{{copy "copy.continue"}}</button></form>{{end}}{{with .Card}}<form method="post" action="/conversation/cards/{{.ID}}/answer"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="from" value="{{$.From}}"><input type="hidden" name="task" value="{{$t.ID}}">{{if $.Task.Decision.Note}}<textarea rst-input name="note" maxlength="1000" rows="2" aria-label="{{copy "chat.card.direction_note"}}" placeholder="{{copy "chat.card.direction_note"}}" data-direction-note></textarea>{{end}}{{range $.Task.Decision.Choices}}<button equipo-btn{{if .Primary}} data-primary{{end}} type="submit" name="choice" value="{{.Value}}" data-merge-choice="{{.Value}}">{{.Label}}</button>{{end}}</form>{{end}}{{if .Fold}}<form method="post" action="/tasks/{{$t.ID}}/duplicate"><input type="hidden" name="from" value="{{$.From}}"><input type="hidden" name="of" value="{{$t.Dup.ID}}"><button equipo-btn data-primary type="submit" data-task-duplicate>{{copy "work.decide.fold"}}</button></form>{{end}}{{if .Recover}}<form method="post" action="/conversation/tasks/{{$t.ID}}/recover"><input type="hidden" name="from" value="{{$.From}}"><button equipo-btn data-primary type="submit" data-task-recover>{{copy "work.recover"}}</button></form>{{end}}{{with .Unsandboxed}}<details equipo-mach-confirm data-unsandboxed><summary equipo-btn>{{copy "work.decide.unsandboxed"}}</summary><div><p>{{.Warning}}</p><form method="post" action="/conversation/tasks/{{$t.ID}}/unsandboxed"><input type="hidden" name="from" value="{{$.From}}"><input type="hidden" name="step" value="{{.Step}}"><input type="hidden" name="attempt" value="{{.Attempt}}"><button equipo-btn data-danger type="submit" data-task-unsandboxed>{{copy "work.decide.unsandboxed_confirm"}}</button></form></div></details>{{end}}{{if .Retry}}<form method="post" action="/conversation/tasks/{{$t.ID}}/retry"><input type="hidden" name="from" value="{{$.From}}"><button {{if .Fold}}equipo-link{{else}}equipo-btn data-primary{{end}} type="submit" data-task-retry>{{copy "work.retry"}}</button></form>{{end}}{{if .Round}}<form method="post" action="/conversation/tasks/{{$t.ID}}/round"><input type="hidden" name="from" value="{{$.From}}"><button equipo-btn data-primary type="submit" data-task-round>{{copy "work.decide.round"}}</button></form>{{end}}{{if .Talk}}<a equipo-btn href="/conversation?about={{$t.ID}}" data-ask-coordinator>{{copy "work.decide.ask_coordinator"}}</a>{{end}}{{if .Cancel}}<form method="post" action="/conversation/tasks/{{$t.ID}}/cancel"><input type="hidden" name="from" value="{{$.From}}"><button equipo-link type="submit" data-task-cancel>{{copy "work.decide.cancel"}}</button></form>{{end}}{{with .Hint}}<span equipo-quiet>{{.}}</span>{{end}}<span equipo-d-quiet>{{if .Mac}}<a equipo-link href="/conversation/settings/machines/add" data-set-up-mac>{{copy "work.decide.mac_set_up"}}</a>{{end}}<a equipo-link href="/conversation?about={{$t.ID}}" data-ask-about>{{copy "work.ask_about"}}</a></span></div>
</div>{{end}}{{end}}
{{define "star-toggle"}}{{$p := .P}}<form method="post" action="/projects/{{$p.ID}}/star" equipo-star-form><input type="hidden" name="starred" value="{{if $p.Star.On}}0{{else}}1{{end}}"><input type="hidden" name="from" value="{{.From}}"><button type="submit" equipo-star{{if $p.Star.On}} aria-pressed="true"{{if $p.Star.Auto}} data-auto{{end}}{{else}} aria-pressed="false"{{end}} aria-label="{{$p.Star.Label}}" title="{{$p.Star.Who}}" data-star-toggle>{{icon "star"}}</button></form>{{end}}
{{define "project-facts"}}{{with .StackLine}}<span>{{if $.PhoneStack}}{{icon "phone"}}{{else}}{{icon "code"}}{{end}}{{.}}</span>{{end}}{{with .Repos}}<span data-repos>{{icon "git"}}{{if eq (len .) 1}}{{copy "work.project.one_repo"}}{{else}}{{printf (copy "work.project.repos") (len .)}}{{end}}</span>{{end}}{{with .ChecksLine}}<span data-tone="{{if $.Checks.Here}}positive{{else}}warning{{end}}" data-checks-fact>{{if $.Checks.Here}}{{icon "check-circle"}}{{else}}{{icon "help-circle"}}{{end}}{{.}}</span>{{end}}{{end}}
diff --git a/internal/equipo/templates/work_task.html b/internal/equipo/templates/work_task.html
index 0b8e4a56..fb793eb2 100644
--- a/internal/equipo/templates/work_task.html
+++ b/internal/equipo/templates/work_task.html
@@ -87,5 +87,5 @@
{{if .Facts}}<dl equipo-facts>{{range .Facts}}<dt>{{.Label}}</dt><dd><span>{{.Value}}</span>{{range .Sources}}{{if .URL}}<a equipo-source href="{{.URL}}" target="_blank" rel="noopener noreferrer" data-source="{{.ID}}">{{.URL}}</a>{{else}}<small equipo-source data-source="{{.ID}}">{{.ID}}</small>{{end}}{{end}}</dd>{{end}}</dl>{{end}}
{{if .Gaps}}<div equipo-gaps><h3>{{copy "work.research.gaps"}}</h3><ul>{{range .Gaps}}<li>{{.}}</li>{{end}}</ul></div>{{end}}
{{if .Images}}<ul equipo-kept>{{range .Images}}<li><figure><img src="{{.Src}}" alt="{{.Description}}" width="{{.Width}}" height="{{.Height}}" loading="lazy" decoding="async"><figcaption><b>{{.RoleWord}}</b> {{.Description}}</figcaption></figure></li>{{end}}</ul>{{end}}
-{{if .Fetches}}<details equipo-tl-more data-fetch-log><summary>{{icon "chevron-down"}}<span>{{printf (copy "work.research.log") (len .Fetches)}}</span></summary><ol equipo-fetch-log>{{range .Fetches}}<li><code>{{.URL}}</code>{{range .Hops}} <span aria-hidden="true">→</span> <code>{{.URL}}</code>{{with .Status}} <span>{{.}}</span>{{end}}{{end}}{{with .Status}} <span>{{.}}</span>{{end}}{{with .Type}} <span>{{.}}</span>{{end}}{{with .Bytes}} <span>{{fileSize .}}</span>{{end}}{{with .Reason}} <span data-reason>{{.}}</span>{{end}}</li>{{end}}</ol></details>{{end}}
+{{if .Fetches}}<details equipo-tl-more data-fetch-log id="research-{{.StepID}}"><summary>{{icon "chevron-down"}}<span>{{printf (copy "work.research.log") (len .Fetches)}}</span></summary><ol equipo-fetch-log>{{range .Fetches}}<li><code>{{.URL}}</code>{{range .Hops}} <span aria-hidden="true">→</span> <code>{{.URL}}</code>{{with .Status}} <span>{{.}}</span>{{end}}{{end}}{{with .Status}} <span>{{.}}</span>{{end}}{{with .Type}} <span>{{.}}</span>{{end}}{{with .Bytes}} <span>{{fileSize .}}</span>{{end}}{{with .Reason}} <span data-reason>{{.}}</span>{{end}}</li>{{end}}</ol></details>{{end}}
</div>{{end}}
diff --git a/internal/equipo/work_pages.go b/internal/equipo/work_pages.go
index f9f7c25b..51645321 100644
--- a/internal/equipo/work_pages.go
+++ b/internal/equipo/work_pages.go
@@ -490,6 +490,7 @@ type workView struct {
// the team's tasks waiting on someone else.
Needs bool
Decisions []taskLine
+ Questions []chatCard
Others []taskLine
// Groups are the Tasks page's (or a project's) tasks by what matters.
Groups []taskGroup
@@ -630,6 +631,16 @@ func (a *application) workTasks(w http.ResponseWriter, r *http.Request) {
if r.URL.Query().Get("needs") == "you" {
// Needs you: the person's own decisions, then what waits on others.
data.Key, data.Title, data.Thin.Needs = "needs-you", "nav.needs-you", true
+ questions, err := a.store.Chat().OpenStandaloneCards(ctx, address)
+ if err != nil {
+ a.failure(w, r, chatError(err))
+ return
+ }
+ for _, c := range questions {
+ v := cardView(c.Card, nil, nil)
+ v.Job = c.Job
+ data.Thin.Questions = append(data.Thin.Questions, v)
+ }
for _, t := range all {
switch {
case t.Group == "needs":
@@ -1069,3 +1080,5 @@ func (a *application) workTaskContinueCopy(w http.ResponseWriter, r *http.Reques
return a.store.Chat().ContinueWithoutCopy(ctx, address, id)
})
}
+
+func (v workView) DecisionCount() int { return len(v.Decisions) + len(v.Questions) }
diff --git a/internal/equipo/work_views.go b/internal/equipo/work_views.go
index 7b330df6..2eb2ea2d 100644
--- a/internal/equipo/work_views.go
+++ b/internal/equipo/work_views.go
@@ -129,6 +129,7 @@ type menuItem struct {
// decisionView is a decision card: why, the question, and the one-tap
// answers. Card is the merge card it answers, if any.
type decisionView struct {
+ CopyContinue bool
Need, Tone, Why, Ask, Hint string
Card *wire.Card
Choices []decisionChoice
@@ -214,6 +215,9 @@ func needsViewer(t wire.Task, viewer string, card *wire.Card) bool {
if t.Creator != viewer || wire.FinalStage(t.Stage) {
return false
}
+ if t.CopyHold || t.CopyCanSkip {
+ return true
+ }
switch t.NeedsYou {
case wire.NeedsRetry, wire.NeedsReviewBlocked, wire.NeedsFixRounds, wire.NeedsBranchMoved, wire.NeedsMergeConflict, wire.NeedsMachineRemoved, wire.NeedsMacSandbox, wire.NeedsDirection:
return true
@@ -225,6 +229,9 @@ func needsViewer(t wire.Task, viewer string, card *wire.Card) bool {
// needsSomeone is the same for any creator, for "Waiting for Nora".
func needsSomeone(t wire.Task) bool {
+ if t.CopyHold || t.CopyCanSkip {
+ return !wire.FinalStage(t.Stage)
+ }
switch t.NeedsYou {
case wire.NeedsRetry, wire.NeedsReviewBlocked, wire.NeedsFixRounds, wire.NeedsBranchMoved, wire.NeedsMergeConflict, wire.NeedsMachineRemoved, wire.NeedsMacSandbox, wire.NeedsDirection:
return !wire.FinalStage(t.Stage)
@@ -620,6 +627,14 @@ func actionOf(id string, d *decisionView, stopped *wire.Step) *rowAction {
// decisionOf is the one card for what the creator must decide.
func decisionOf(t wire.Task, v taskLine) *decisionView {
d := &decisionView{Need: t.NeedsYou}
+ if t.CopyHold || t.CopyCanSkip {
+ d.Need, d.Tone, d.Ask, d.Talk, d.CopyContinue = "copy", "attention", copyText("roster.copy_waiting"), true, t.CopyCanSkip
+ d.Why = copyText("copy.round_budget")
+ if s := lastStep(t); s != nil && s.Reason != "" {
+ d.Why = reasonLine(s.Reason, "work.reason.other")
+ }
+ return d
+ }
who := func(s *wire.Step) string {
if s == nil {
return specialistName(wire.SpecialistEngineering)
diff --git a/internal/equipo/work_views_test.go b/internal/equipo/work_views_test.go
index 3a6a3521..f15e8ef0 100644
--- a/internal/equipo/work_views_test.go
+++ b/internal/equipo/work_views_test.go
@@ -120,3 +120,12 @@ func TestTaskSummaryWaitsOnce(t *testing.T) {
t.Fatalf("fallback %q", got)
}
}
+
+func TestRosterCancelledHoldIsReport(t *testing.T) {
+ task := wire.Task{ID: "tk_roster", Title: "Cancelled work", Creator: "owner@example.com", Stage: wire.StageCancelled, CopyHold: true}
+ v := cardView(wire.Card{ID: "c_roster", Kind: wire.CardTask, TaskID: task.ID}, nil, map[string]wire.Task{task.ID: task})
+ v.Receipt = true
+ if v.Interactive() || v.Task.CopyHold {
+ t.Fatal("cancelled task still asks about its old Copy hold")
+ }
+}
diff --git a/internal/headless/browser_cards_test.go b/internal/headless/browser_cards_test.go
index 5e94e05b..58243ddd 100644
--- a/internal/headless/browser_cards_test.go
+++ b/internal/headless/browser_cards_test.go
@@ -90,7 +90,7 @@ func TestBrowserThinkingAndCards(t *testing.T) {
send("tool:ask_person:Should the panes slide on iPad too?|Yes|No")
run(browsertest.Wait(`!!document.querySelector('[equipo-card="question"][data-state="open"] button[value="Yes"]')`))
check(`(()=>{document.querySelector('[equipo-card="question"][data-state="open"] button[value="Yes"]').click();return true})()`, "answer")
- run(browsertest.Wait(`[...document.querySelectorAll('[equipo-card="question"][data-state="answered"]')].some(e=>e.textContent.includes('You answered: Yes')) && [...document.querySelectorAll('[equipo-message="own"] [equipo-message-body]')].some(e=>e.textContent==='Yes')`))
+ run(browsertest.Wait(`[...document.querySelectorAll('[equipo-card="question"][data-state="answered"] [equipo-thread-turn][data-own] [equipo-thread-text]')].some(e=>e.textContent.trim()==='Yes')`))
run(browsertest.Wait(`!document.querySelector('[equipo-thinking]')`))
// A keyboard shrinks the visual viewport: after a send the newest
diff --git a/internal/headless/browser_notebook_test.go b/internal/headless/browser_notebook_test.go
index e6e98bff..3ba182b2 100644
--- a/internal/headless/browser_notebook_test.go
+++ b/internal/headless/browser_notebook_test.go
@@ -93,22 +93,29 @@ func TestBrowserNotebookLook(t *testing.T) {
for _, theme := range []string{"light", "dark"} {
p.run(chromedp.Navigate(inst.URL+"/conversation"), browsertest.Wait(`!!document.querySelector('[data-chat-stream]')`))
p.theme(theme)
- p.check(`(()=>{const b=document.querySelector('[equipo-chat-header] a[equipo-header-button][href="/conversation/settings/notebook"]');if(!b)return false;const r=b.getBoundingClientRect();return b.getAttribute('aria-label')==='Notebook' && b.title==='Notebook' && !!b.querySelector('svg') && b.textContent.trim()==='' && getComputedStyle(b).cursor==='pointer' && (`+strconv.FormatBool(width < 600)+` ? r.width>=44 && r.height>=44 : r.width>=24)})()`, "header button")
- // Keyboard: Tab reaches the button, and its focus shows.
- for i := 0; i < 30; i++ {
- var on bool
- p.run(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
- var err error
- on, err = chromedp.Evaluate[bool](`document.activeElement && document.activeElement.hasAttribute('equipo-header-button')`)(ctx, target)
- return err
- }))
- if on {
- break
+ if width < 600 {
+ p.check(`getComputedStyle(document.querySelector('[equipo-chat-header] [equipo-header-button]')).display==='none' && !!document.querySelector('[equipo-needs-pill]')`, "phone header keeps the Needs you control")
+ p.run(chromedp.Navigate(inst.URL+"/conversation/settings"), browsertest.Wait(`!!document.querySelector('a[href="/conversation/settings/notebook"]')`))
+ p.check(`(()=>{document.querySelector('a[href="/conversation/settings/notebook"]').click();return true})()`, "Notebook reachable through settings")
+ p.run(browsertest.Wait(`location.pathname==='/conversation/settings/notebook'`))
+ } else {
+ p.check(`(()=>{const b=document.querySelector('[equipo-chat-header] a[equipo-header-button][href="/conversation/settings/notebook"]');if(!b)return false;const r=b.getBoundingClientRect();return b.getAttribute('aria-label')==='Notebook' && b.title==='Notebook' && !!b.querySelector('svg') && b.textContent.trim()==='' && getComputedStyle(b).cursor==='pointer' && (`+strconv.FormatBool(width < 600)+` ? r.width>=44 && r.height>=44 : r.width>=24)})()`, "header button")
+ // Keyboard: Tab reaches the button, and its focus shows.
+ for i := 0; i < 30; i++ {
+ var on bool
+ p.run(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
+ var err error
+ on, err = chromedp.Evaluate[bool](`document.activeElement && document.activeElement.hasAttribute('equipo-header-button')`)(ctx, target)
+ return err
+ }))
+ if on {
+ break
+ }
+ p.run(chromedp.KeyEvent("\t"))
}
- p.run(chromedp.KeyEvent("\t"))
+ p.check(`document.activeElement.hasAttribute('equipo-header-button') && getComputedStyle(document.activeElement).outlineStyle!=='none'`, "keyboard focus on the Notebook button")
+ p.run(chromedp.KeyEvent("\r"), browsertest.Wait(`location.pathname==='/conversation/settings/notebook'`))
}
- p.check(`document.activeElement.hasAttribute('equipo-header-button') && getComputedStyle(document.activeElement).outlineStyle!=='none'`, "keyboard focus on the Notebook button")
- p.run(chromedp.KeyEvent("\r"), browsertest.Wait(`location.pathname==='/conversation/settings/notebook'`))
p.theme(theme)
p.check(`(()=>{const ns=[...document.querySelectorAll('[equipo-notes] > [equipo-note]')];if(ns.length!==5)return false;const page=getComputedStyle(document.body).backgroundColor;return ns.every(n=>{const s=getComputedStyle(n);return s.borderTopWidth==='1px'&&s.borderLeftWidth==='1px'&&s.borderLeftColor===s.borderTopColor&&s.boxShadow!=='none'&&s.backgroundColor!==page&&n.querySelector('[equipo-note-caption] time')})})()`, "notes are not paper cards")
p.check(`(()=>{const q=document.querySelector('[equipo-note][data-said] blockquote p');return !!q && q.textContent.startsWith('I like short replies') && getComputedStyle(q,'::before').content==='"“"' && q.closest('[equipo-note]').querySelector('[equipo-note-caption]').textContent.includes('You said')})()`, "the person's words are not a quote")
diff --git a/internal/headless/browser_review_test.go b/internal/headless/browser_review_test.go
index ab8b7941..5e9689ec 100644
--- a/internal/headless/browser_review_test.go
+++ b/internal/headless/browser_review_test.go
@@ -28,9 +28,9 @@ func TestBrowserReceiptFollowsReview(t *testing.T) {
p.run(browsertest.Wait(stage + `==='In progress'`))
// The step and the review each sleep 2.5 s on purpose: these waits are
// on that work, so they get the window the rail drive gives it.
- p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;return !!c && c.querySelector('[equipo-stage]').textContent==='In review' && /^Pushed equipo\/tk[a-z0-9]+-fix-the-readme-typo at [0-9a-f]{7}$/.test(c.querySelector('[data-pushed] span').textContent)})()`, 20*time.Second))
- p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;return c.querySelector('[data-verdict]')?.textContent==='Reviewing…' && c.querySelector('[data-checks]')?.textContent==='Checks passed (make ci)'})()`, 20*time.Second))
- p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;const m=c.querySelector('[data-merged]');const a=m?.querySelector('[data-open-amadan]');return c.querySelector('[equipo-stage]').textContent==='Done' && c.querySelector('[data-verdict]').textContent==='Approved (same family, same account)' && !!m && /^Merged into main at [0-9a-f]{7}$/.test(m.querySelector('span').textContent) && !c.querySelector('[data-pushed]') && !!a && a.textContent==='Open on Amadan' && a.target==='_blank' && a.href.startsWith('https://amadan.net/oficina/sample')})()`, 20*time.Second))
+ p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;return !!c && c.querySelector('[equipo-stage]').textContent==='In review' && /^equipo\/tk[a-z0-9]+-fix-the-readme-typo$/.test(c.querySelector('[equipo-roster-facts] code').textContent) && !!c.querySelector('[data-open-amadan]')})()`, 20*time.Second))
+ p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;return c.querySelector('[data-verdict]')?.textContent==='Reviewing' && c.querySelector('[data-checks]')?.textContent==='Passed' && c.querySelector('[data-checks]').nextElementSibling.textContent==='make ci'})()`, 20*time.Second))
+ p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;const m=c.querySelector('[data-merged]');const a=m?.querySelector('[data-open-amadan]');return c.querySelector('[equipo-stage]').textContent==='Done' && c.querySelector('[data-verdict]').textContent==='Approved' && c.querySelector('[data-verdict]').nextElementSibling.textContent==='same family, same account' && !!m && /^Merged into main at [0-9a-f]{7}$/.test(m.querySelector('span').textContent) && !c.querySelector('[data-pushed]') && !!a && a.textContent==='Open on Amadan' && a.target==='_blank' && a.href.startsWith('https://amadan.net/oficina/sample')})()`, 20*time.Second))
p.check(`performance.getEntriesByType('navigation').length===window.__nav`, "the page reloaded")
p.check(`(()=>{const b=`+card+`.querySelector('[data-merged] [data-open-amadan]').getBoundingClientRect();return b.width>0 && b.height>0})()`, "the link to the merge is hidden")
}
diff --git a/internal/headless/browser_tasks_test.go b/internal/headless/browser_tasks_test.go
index 730cdc34..6e1fc89b 100644
--- a/internal/headless/browser_tasks_test.go
+++ b/internal/headless/browser_tasks_test.go
@@ -3,6 +3,7 @@
package headless
import (
+ "github.com/chromedp/chromedp"
"testing"
"amadan.net/oficina/equipo/internal/browsertest"
@@ -15,8 +16,8 @@ func taskCard(title string) string {
// Slice 3: the person reports a bug; a quiet task receipt appears before
// the reply and follows the task live to the pushed branch, its short
-// SHA and Open on Amadan. A slow second task shows Cancel behind ⋯ on a
-// phone, and Cancel ends it.
+// SHA and Open on Amadan. Open the task reaches Cancel on a phone,
+// and Cancel ends a slow second task.
func TestBrowserTaskCard(t *testing.T) {
_, inst, r := localEnv(t)
r.start(t)
@@ -30,16 +31,18 @@ func TestBrowserTaskCard(t *testing.T) {
p.run(browsertest.Wait(`(()=>{const r=` + first + `;const m=[...document.querySelectorAll('[equipo-message="incoming"][data-turn-id="'+r.dataset.turnId+'"]')][0];return !!m && !!(r.compareDocumentPosition(m)&4) && r.hasAttribute('equipo-receipt')})()`))
// Live: the stage moves on and the pushed branch appears without a reload.
p.check(`(()=>{window.__nav=performance.getEntriesByType('navigation').length;return true})()`, "mark")
- p.run(browsertest.Wait(`(()=>{const a=` + first + `?.querySelector('[data-open-amadan]');return !!a && a.href.startsWith('https://amadan.net/oficina/sample?branch=equipo/') && a.target==='_blank' && a.rel==='noopener' && /at [0-9a-f]{7}$/.test(a.previousElementSibling.textContent)})()`))
+ p.run(browsertest.Wait(`(()=>{const a=` + first + `?.querySelector('[data-open-amadan]');return !!a && a.href.startsWith('https://amadan.net/oficina/sample?branch=equipo/') && a.target==='_blank' && a.rel==='noopener' && /^[0-9a-f]{7}$/.test(` + first + `.querySelector('[equipo-roster-facts] code').parentElement.nextElementSibling.textContent)})()`))
p.check(`performance.getEntriesByType('navigation').length===window.__nav`, "the page reloaded")
p.check(`!`+first+`.querySelector('[data-task-retry]')`, "a pushed task offers Retry")
p.send("tool:record_task:oficina/sample|Slow change|x\ntool:start_task:$task|stepsleep:20000 edit:README.md|teh|the")
slow := taskCard("Slow change")
- p.run(browsertest.Wait(`!!` + slow + `?.querySelector('[data-task-cancel]')`))
- // Touch: the action is hidden until ⋯ opens it.
- p.check(`getComputedStyle(`+slow+`.querySelector('[equipo-receipt-actions]')).opacity==='0' && getComputedStyle(`+slow+`.querySelector('[equipo-receipt-more]')).display!=='none'`, "Cancel shown before ⋯")
- p.check(`(()=>{`+slow+`.querySelector('[equipo-receipt-more]').click();return true})()`, "tap ⋯")
- p.run(browsertest.Wait(`getComputedStyle(` + slow + `.querySelector('[equipo-receipt-actions]')).opacity==='1'`))
- p.check(`(()=>{`+slow+`.querySelector('[data-task-cancel]').click();return true})()`, "Cancel")
- p.run(browsertest.Wait(slow + `?.dataset.state==='cancelled' && !` + slow + `.querySelector('[data-task-cancel]')`))
+
+ p.run(browsertest.Wait(`!!` + slow + `?.querySelector('[equipo-roster-links] a[rst-btn]')`))
+ p.check(`!`+slow+`.querySelector('[equipo-receipt-more], [data-task-cancel]')`, "report retained its action menu")
+ p.check(`(()=>{`+slow+`.querySelector('[equipo-roster-links] a[rst-btn]').click();return true})()`, "Open the task")
+ p.run(browsertest.Wait(`!!document.querySelector('#task-head [data-task-cancel]')`))
+ p.check(`(()=>{document.querySelector('#task-head [equipo-menu] summary').click();return true})()`, "task actions")
+ p.check(`(()=>{document.querySelector('#task-head [data-task-cancel]').click();return true})()`, "Cancel")
+ p.run(browsertest.Wait(`!document.querySelector('#task-head [data-task-cancel]')`))
+ p.run(chromedp.Navigate(inst.URL+"/conversation"), browsertest.Wait(slow+`?.dataset.state==='cancelled'`))
}
diff --git a/internal/plan3test/plan3_release_test.go b/internal/plan3test/plan3_release_test.go
index c2ee995b..4589e5af 100644
--- a/internal/plan3test/plan3_release_test.go
+++ b/internal/plan3test/plan3_release_test.go
@@ -177,8 +177,9 @@ func plan3CopyInventory(t *testing.T) {
approvedAssistant := strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY APPROVED (Paul, 2026-11-13, copy-review jbltdd2mvwblrz4en6xfhv6d2y, unchanged)") || strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY APPROVED (Paul, 2026-11-13, copy-review 64nswfjbrpsw2pezhyi7y3nenq, unchanged)") || strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY APPROVED (Paul, 2026-11-13, copy-review c3ipwcupsvwv7rpbj2kdbgrsyy, unchanged)")
// Paul's own review of the jobs strings and the API section's job prose.
approvedJobs := strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY APPROVED (Paul, 2026-11-14, copy-review cvaxhn3pwgpxhpssj5cgizqtrq, unchanged)") || strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY APPROVED (Paul, 2026-11-14, copy-review cvaxhn3pwgpxhpssj5cgizqtrq)")
+ acceptedRoster := strings.HasPrefix(key, "roster.") && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)")
acceptedCopy := strings.TrimSuffix(cells[3], " |") == "COPY ACCEPTED BY DELEGATION (Copy, record-bound) sha256:"+copydesk.Hash(rows[key])
- if !acceptedCopy && !strings.Contains(cells[3], "COPY REVIEW REQUIRED") && !acceptedAll && !acceptedGuide && !acceptedRound2 && !acceptedStarter && !acceptedDelegation && !approvedPublish && !approvedAssistant && !approvedJobs {
+ if !acceptedRoster && !acceptedCopy && !strings.Contains(cells[3], "COPY REVIEW REQUIRED") && !acceptedAll && !acceptedGuide && !acceptedRound2 && !acceptedStarter && !acceptedDelegation && !approvedPublish && !approvedAssistant && !approvedJobs {
t.Fatal("entry has no copy review status or applicable acceptance", key)
}
}
diff --git a/internal/thintest/gallery_test.go b/internal/thintest/gallery_test.go
index 9089beec..d8de32cc 100644
--- a/internal/thintest/gallery_test.go
+++ b/internal/thintest/gallery_test.go
@@ -193,7 +193,7 @@ func TestPagesInnerScreens(t *testing.T) {
}
needs := a.get(owner, "/tasks?needs=you", 200)
- has(needs, "Needs you", "2 decisions, each in one tap.", `data-decision="`+g.unchecked+`"`, "Merge without checks?",
+ has(needs, "Needs you", "3 waiting for you", `data-decision="`+g.unchecked+`"`, "Merge without checks?",
`data-merge-choice="merge"`, `data-merge-choice="wait_mac"`, `name="from" value="needs"`, `data-decision="`+g.stopped+`"`, "Try again?", `data-group="others"`, `data-task="`+g.noras+`"`)
// No card for duplicates: Equipo tidies them, or names them quietly.
not(needs, "Needs you", `data-decision="`+g.noras+`"`, "Fold it into the other task?", `action="/tasks/`+g.stopped+`/duplicate"`)
diff --git a/internal/thintest/housekeeping_browser_test.go b/internal/thintest/housekeeping_browser_test.go
index 85449e4f..1e344f39 100644
--- a/internal/thintest/housekeeping_browser_test.go
+++ b/internal/thintest/housekeeping_browser_test.go
@@ -53,13 +53,15 @@ func TestBrowserHousekeeping(t *testing.T) {
p.wait(`document.querySelector('[data-digest]')`, "digest line")
p.check(`document.querySelector('[data-digest]').textContent.includes('Tidied 2 things.')`, "digest words")
p.check(`document.querySelector('[data-digest-link]').getAttribute('href')==='/housekeeping'`, "digest link")
- p.check(`(()=>{const a=document.querySelector('[data-housekeeping-link]');const b=a.getBoundingClientRect();return b.width>0&&b.height>0&&b.top>=0})()`, "header link visible")
+ if !size.touch {
+ p.check(`(()=>{const a=document.querySelector('[data-housekeeping-link]');const b=a.getBoundingClientRect();return b.width>0&&b.height>0&&b.top>=0})()`, "header link visible")
+ }
p.check(`document.querySelectorAll('[equipo-card="combined"]').length===2`, "two quiet receipts")
p.fits("conversation")
p.shot(fmt.Sprintf("hk-conversation-%d", size.w))
// The view.
- p.click(`[data-housekeeping-link]`)
+ p.click(`[data-digest-link]`)
p.wait(`document.querySelector('[data-housekeeping]')`, "the view")
// Settled, as opened directly (the phone slides the page in).
p.open("/housekeeping")
diff --git a/internal/thintest/inner_browser_test.go b/internal/thintest/inner_browser_test.go
index 85f63f66..0c83d0c6 100644
--- a/internal/thintest/inner_browser_test.go
+++ b/internal/thintest/inner_browser_test.go
@@ -285,7 +285,7 @@ func TestBrowserInnerScreens(t *testing.T) {
// Needs you: one card per decision, the prominent answer in reach.
p.open("/tasks?needs=you")
- p.check(`document.querySelectorAll('[equipo-decision]').length===2`, "two decisions")
+ p.check(`document.querySelectorAll('[equipo-decision][data-decision]').length===2`, "two decisions")
p.check(`(()=>{const b=document.querySelector('[data-decision="`+g.unchecked+`"] [data-merge-choice="merge"]').getBoundingClientRect();return b.width>0 && b.height>=`+map[bool]string{true: "44", false: "30"}[size.touch]+`})()`, "Merge out of reach")
p.fits("needs")
@@ -296,7 +296,7 @@ func TestBrowserInnerScreens(t *testing.T) {
// centre.
mid := `(e=>{const r=e.getBoundingClientRect();return (r.top+r.bottom)/2})`
p.open("/conversation")
- p.check(`(()=>{const m=`+mid+`;const a=m(document.querySelector('[rst-shell-back] > a')),h=m(document.querySelector('[equipo-chat-header] h1')),b=m(document.querySelector('[equipo-chat-header] [equipo-header-button]'));return Math.abs(a-h)<=1 && Math.abs(h-b)<=1})()`, "conversation bar not on one centre line")
+ p.check(`(()=>{const m=`+mid+`;const a=m(document.querySelector('[rst-shell-back] > a')),h=m(document.querySelector('[equipo-chat-header] h1')),b=m(document.querySelector('[equipo-chat-header] [equipo-needs-pill]'));return Math.abs(a-h)<=1 && Math.abs(h-b)<=1})()`, "conversation bar not on one centre line")
for _, path := range []string{"/tasks/" + g.unchecked, "/projects/" + a.conv.Tasks[g.unchecked].ProjectID} {
p.open(path)
p.check(`(()=>{const m=`+mid+`;const bar=document.querySelector('[rst-shell-back]'),l=bar.querySelector('a');const pad=parseFloat(getComputedStyle(bar).paddingTop);const r=bar.getBoundingClientRect();return Math.abs(m(l)-(r.top+pad+r.bottom)/2)<=1})()`, path+" back link off its bar's centre")
diff --git a/internal/thintest/merge_contract_test.go b/internal/thintest/merge_contract_test.go
index e3653b42..370f2fde 100644
--- a/internal/thintest/merge_contract_test.go
+++ b/internal/thintest/merge_contract_test.go
@@ -203,7 +203,7 @@ func TestContractMergeWithoutChecks(t *testing.T) {
if err != nil || out.Card.State != wire.CardAnswered || out.Card.Choice != wire.ChoiceWaitMac {
t.Fatalf("wait %+v %v", out, err)
}
- if page := r.get(r.inst.Cookie(), "/conversation", 200); !strings.Contains(page, "Merge Swipe back on iOS? I&#39;d wait") || !strings.Contains(page, "Waiting for a Mac.") || strings.Contains(page, `data-merge-choice="merge"`) {
+ if page := r.get(r.inst.Cookie(), "/conversation", 200); !strings.Contains(page, `data-card="`+card.ID+`"`) || !strings.Contains(page, "Waiting for a Mac.") || strings.Contains(page, `data-merge-choice="merge"`) {
t.Fatalf("answered card: %s", page)
}
if k, _ := r.client.Task(ctx, id); k.Stage != wire.StageReadyToMerge || k.NeedsYou != wire.NeedsMerge || r.heldKinds(wire.FrameDispatch) != 0 {
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/publish_contract_test.go b/internal/thintest/publish_contract_test.go
index 13484d68..ec7feb37 100644
--- a/internal/thintest/publish_contract_test.go
+++ b/internal/thintest/publish_contract_test.go
@@ -235,7 +235,7 @@ func TestContractPublishSite(t *testing.T) {
if r.audits("publish.authorize") != 4 {
t.Fatalf("authorize audited %d times", r.audits("publish.authorize"))
}
- if page := r.get(r.inst.Cookie(), "/conversation", 200); !strings.Contains(page, "Publish Quick website on the web as "+app+"?") || !strings.Contains(page, "Publishing.") {
+ if page := r.get(r.inst.Cookie(), "/conversation", 200); !strings.Contains(page, `equipo-card="publish"`) || !strings.Contains(page, "Publishing.") {
t.Fatalf("conversation page lacks the publish card")
}
}
diff --git a/internal/thintest/research_pages_test.go b/internal/thintest/research_pages_test.go
index 43deea32..e684395c 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)
}
}
@@ -140,7 +140,7 @@ func TestResearchInventoryCardPage(t *testing.T) {
r.inventoryCard(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>Confirmed. Research will block pages served from these addresses.</p>") {
+ if strings.Contains(after, "<form") || !strings.Contains(after, "Confirmed. Research will block pages served from these addresses.</p>") {
t.Fatalf("confirmed card:\n%s", after)
}
}
@@ -218,7 +218,7 @@ func TestResearchTaskPage(t *testing.T) {
"<li>No phone number found</li>",
`<img src="/tasks/` + id + `/files/` + file + `" alt="The shop&#39;s logo." width="5" height="4" loading="lazy" decoding="async">`,
"<figcaption><b>Logo</b> The shop&#39;s logo.</figcaption>",
- `<details equipo-tl-more data-fetch-log>`, "Web requests (5)", "<code>https://shop.example.com/search?q=&lt;script&gt;alert(3)&lt;/script&gt;</code>",
+ `<details equipo-tl-more data-fetch-log id="research-` + s.ID + `">`, "Web requests (5)", "<code>https://shop.example.com/search?q=&lt;script&gt;alert(3)&lt;/script&gt;</code>",
"<code>https://shop.example.com/</code>", "text/html&#34;&gt;&lt;script&gt;alert(2)&lt;/script&gt;", "<span>5 KB</span>",
"<code>https://shop.example.com/hours</code>", "https://shop.example.com/opening-hours",
"<code>https://cdn.example.net/x.webp</code>", "type_refused",
diff --git a/internal/thintest/rollup_browser_test.go b/internal/thintest/rollup_browser_test.go
index 11824742..a7d9cd1c 100644
--- a/internal/thintest/rollup_browser_test.go
+++ b/internal/thintest/rollup_browser_test.go
@@ -21,7 +21,7 @@ func TestBrowserRollup(t *testing.T) {
for i, tc := range []struct {
width int64
scheme string
- }{{1280, "light"}, {390, "dark"}} {
+ }{{1280, "light"}, {1280, "dark"}, {390, "light"}, {390, "dark"}} {
t.Run(fmt.Sprintf("%d-%s", tc.width, tc.scheme), func(t *testing.T) {
p := openInner(t, r.inst.URL, r.inst.Cookie(), tc.width, 844, tc.width == 390, tc.scheme, "no-preference")
defer p.stop()
diff --git a/internal/thintest/roster_browser_test.go b/internal/thintest/roster_browser_test.go
new file mode 100644
index 00000000..26c3f92a
--- /dev/null
+++ b/internal/thintest/roster_browser_test.go
@@ -0,0 +1,255 @@
+//go:build browser
+
+package thintest
+
+import (
+ "amadan.net/oficina/equipo/internal/wire"
+ "fmt"
+ "github.com/chromedp/cdproto/input"
+ "github.com/chromedp/chromedp"
+ "strings"
+ "testing"
+)
+
+func TestBrowserRosterVisual(t *testing.T) {
+ r := newRollupRig(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) {
+ 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-offline]').hidden`, "connected")
+ p.check(`!!document.querySelector('[equipo-roster-byline]')`, "roster bylines missing")
+ p.check(`[...document.querySelectorAll("[equipo-daybar] i")].every(i=>i.getBoundingClientRect().width>0) && !document.querySelector("[equipo-daybar] [style]")`, "roll-up bar violates the style policy")
+ p.check(`document.querySelector('[equipo-roster-report] [data-track]').children.length===5`, "report needs five stages")
+ 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.check(`[...document.querySelectorAll('[equipo-card="task"], [equipo-card="merge"]')].every(c=>c.querySelector('[equipo-roster-project]')?.textContent.includes('Woodstar') && c.querySelector('[equipo-roster-project] [equipo-mono]'))`, "task and coordinator cards lack project context")
+ p.check(`(()=>{const c=document.querySelector('[equipo-roster-card]'),b=c.previousElementSibling,r=c.querySelector('[equipo-roster-report]');return parseFloat(getComputedStyle(c).paddingTop)<=10 && parseFloat(getComputedStyle(b).marginBottom)<=2 && parseFloat(getComputedStyle(r).rowGap)<=8 && parseFloat(getComputedStyle(c.querySelector('[equipo-roster-facts]')).paddingTop)<=6})()`, "cards remain too loose")
+ if width == 390 {
+ p.check(`document.querySelector('[equipo-roster-links] a[rst-btn]').getBoundingClientRect().height>=44`, "task button lost its phone target")
+ p.check(`parseFloat(getComputedStyle(document.querySelector('[equipo-roster-report-head] h3 a'),'::after').height)>=44`, "task title has a small phone hit area")
+ }
+ 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")
+ }
+
+ })
+ }
+ }
+}
+
+func TestBrowserRosterSetAside(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 := newRollupRig(t)
+ p := openInner(t, r.inst.URL, r.inst.Cookie(), width, 844, width == 390, scheme, "reduce")
+ defer p.stop()
+ p.open("/conversation")
+ card := `[data-card="` + r.askCard.ID + `"]`
+ p.wait(`document.querySelector('`+card+` [data-set-aside]')`, "Set aside")
+ before := eval[string](p, `document.querySelector("[equipo-needs-pill]").textContent`)
+ p.click(card + ` [data-set-aside]`)
+ 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.bottom<=document.querySelector('[equipo-scroll]').getBoundingClientRect().bottom)})()`, "toast covers Stop")
+ p.check(`document.querySelector('`+card+` [equipo-roster-project]')?.textContent.includes('Woodstar')`, "aside lost project context")
+ if width == 390 {
+ p.check(`document.querySelector('[equipo-aside-stub] button').getBoundingClientRect().width>=44`, "Undo has a narrow phone target")
+ }
+ p.shot(fmt.Sprintf("roster-aside-%d-%s", width, scheme))
+ p.open("/conversation")
+ p.wait(`document.querySelector('`+card+` [equipo-aside-stub]')`, "stub after reload")
+ p.open("/tasks?needs=you")
+ p.check(`!!document.querySelector('a[href="/tasks/`+r.asked+`"]')`, "set-aside task left Needs you")
+ p.open("/conversation")
+ p.click(card + ` [data-aside-undo]`)
+ p.wait(`document.querySelector('`+card+` [data-set-aside]')`, "restored card")
+ p.open("/conversation")
+ p.check(`!document.querySelector('`+card+` [equipo-aside-stub]')`, "undo did not persist")
+ p.fits("set aside and undo")
+ p.click(card + ` [data-set-aside]`)
+ p.wait(`document.querySelector('`+card+` [equipo-aside-stub]')`, "set aside again")
+ if _, err := r.client.Answer(r.ctx, r.askCard.ID, wire.ChoiceWaitMac, r.askCard.Revision); err != nil {
+ t.Fatal(err)
+ }
+ p.wait(`!document.querySelector('`+card+` [equipo-aside-stub]') && document.querySelector('`+card+` [equipo-card-done]')`, "answer from elsewhere resolves the stub")
+ })
+ }
+ }
+}
+
+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)
+ task := taskID(t, r.call("thread-task", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Improve sign-in", "brief": "Keep sign-in clear."}))
+ 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.inst.DB.Writer().Exec("UPDATE chat_cards SET task_id=?,project_id=(SELECT project_id FROM chat_tasks WHERE id=?) WHERE kind='question'", task, task); err != nil {
+ t.Fatal(err)
+ }
+ 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(`[data-set-aside]`)
+ p.wait(`document.querySelector('[equipo-aside-stub]')`, "question set aside")
+ p.wait(`document.querySelector('[equipo-roster-toast] [data-aside-undo]')`, "question toast")
+ p.click(`[equipo-roster-toast] [data-aside-undo]`)
+ p.wait(`document.querySelector('[equipo-mini-composer] textarea')?.value==='The sign-in page.'`, "undo retains the draft")
+ p.check(`(()=>{window.__fetch=window.fetch;window.fetch=(url,opts)=>opts?.method==='POST'?new Promise(resolve=>{window.__fail=()=>resolve(new Response('{}',{status:503}))}):window.__fetch(url,opts);return true})()`, "hold question send")
+ p.click(`[equipo-mini-composer] [data-thread-send]`)
+ p.check(`document.querySelector('[data-thread-send]').getAttribute('aria-busy')==='true'`, "question busy")
+ p.shot(fmt.Sprintf("roster-thread-busy-%d-%s", width, scheme))
+ p.check(`(()=>{window.__fail();window.fetch=window.__fetch;return true})()`, "question send fails")
+ p.wait(`document.querySelector('[data-question-thread]').parentElement.querySelector('[equipo-card-error]:not([hidden])')`, "question send error")
+ p.shot(fmt.Sprintf("roster-thread-error-%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-delta", wire.FrameDelta, wire.DeltaReport{TurnID: m.TurnID, Attempt: 1, Offset: 0, Text: "I’ll start"})
+ p.wait(`document.querySelector('[equipo-thread-draft]')?.textContent==='I’ll start'`, "streamed reply in the drawer")
+ 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.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.check(`(()=>{const c=document.querySelector('[data-question-thread]').closest('[data-card]');return c.querySelector('[equipo-roster-project]')?.textContent.includes('Woodstar') && c.querySelector('[equipo-roster-task]')?.textContent==='Improve sign-in'})()`, "thread lost project or task context")
+ 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")
+ p.click(`[equipo-mini-composer] [data-thread-send]`)
+ f2, b2 := r.expect(wire.FrameMessage)
+ m2 := b2.(*wire.MessageCommand)
+ if !strings.Contains(m2.Text, "Which page should change?") || len(m2.PersonText) != 1 || m2.PersonText[0] != "Keep the email link." {
+ t.Fatalf("follow-up context %+v", m2)
+ }
+ r.runner.Send(r.ctx, "roster-a2", wire.FrameAck, wire.Ack{ID: f2.ID})
+ r.runner.Send(r.ctx, "roster-answer2", wire.FrameReply, wire.Reply{TurnID: m2.TurnID, Attempt: 1, Text: "The email link will stay."})
+ p.wait(`document.querySelector('[equipo-subchat]').textContent.includes('The email link will stay.') && document.querySelectorAll('[equipo-subchat] [data-own]').length===2`, "second round stays in the thread")
+ })
+ }
+ }
+}
+
+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")
+ _, built := r.toDirection("roster-build", "Explore compact navigation")
+ 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(`(()=>{document.querySelector('`+card+` [equipo-actions] [name=revision]').value='0';return true})()`, "make stale")
+ p.click(card + ` [data-direction-choice="build"]`)
+ p.wait(`document.querySelector('`+card+` [equipo-card-error]').textContent.includes('This item has changed')`, "stale revision error")
+ if k := r.task(id); k.Stage != wire.StageInReview {
+ t.Fatalf("stale choice changed task: %s", k.Stage)
+ }
+ p.shot(fmt.Sprintf("roster-decision-stale-%d-%s", width, scheme))
+ p.click(card + ` [equipo-card-error] button`)
+ p.wait(`document.querySelector('`+card+` [equipo-actions] [name=revision]').value==='1'`, "refresh stale decision")
+ p.check(`(()=>{const b=document.querySelector('`+card+` [data-direction-choice="build"]');b.scrollIntoView({block:'center'});b.addEventListener('click',e=>e.preventDefault(),{once:true});return true})()`, "inspect pointer states")
+ xy := eval[[]float64](p, `(()=>{const r=document.querySelector('`+card+` [data-direction-choice="build"]').getBoundingClientRect();return [r.x+r.width/2,r.y+r.height/2]})()`)
+ p.do(chromedp.MouseEvent(input.DispatchMouseEventTypeMouseMoved, xy[0], xy[1]))
+ p.check(`document.querySelector('`+card+` [data-direction-choice="build"]').matches(':hover')`, "hover state")
+ p.shot(fmt.Sprintf("roster-decision-hover-%d-%s", width, scheme))
+ // FullScreenshot can restore a different scroll offset on a phone.
+ xy = eval[[]float64](p, `(()=>{const r=document.querySelector('`+card+` [data-direction-choice="build"]').getBoundingClientRect();return [r.x+r.width/2,r.y+r.height/2]})()`)
+ p.do(chromedp.MouseEvent(input.DispatchMouseEventTypeMouseMoved, xy[0], xy[1]))
+ p.do(chromedp.MouseEvent(input.DispatchMouseEventTypeMousePressed, xy[0], xy[1], chromedp.ButtonLeft, chromedp.ClickCount(1)))
+ p.check(`getComputedStyle(document.querySelector('`+card+` [data-direction-choice="build"]')).transform!=='none'`, "pressed state")
+ p.shot(fmt.Sprintf("roster-decision-pressed-%d-%s", width, scheme))
+ p.do(chromedp.MouseEvent(input.DispatchMouseEventTypeMouseReleased, xy[0], xy[1], chromedp.ButtonLeft, chromedp.ClickCount(1)))
+
+ 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-thread-open]`)
+ 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.check(`document.querySelector('`+card+` [equipo-roster-project]')?.textContent.includes('Woodstar')`, "decision lost project context")
+ p.fits("direction states")
+ p.shot(fmt.Sprintf("roster-decision-sent-%d-%s", width, scheme))
+ build := `[data-card="` + built.ID + `"]`
+ p.click(build + ` [data-direction-choice="build"]`)
+ p.wait(`document.querySelector('`+build+` [data-done]')`, "Build collapses to success")
+ p.check(`getComputedStyle(document.querySelector('`+build+` [equipo-card-line]')).display==='none'`, "success retained the open card title")
+ p.shot(fmt.Sprintf("roster-decision-success-%d-%s", width, scheme))
+ })
+ }
+ }
+}
+
+func TestBrowserRosterThinking(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)
+ 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")
+ if width == 390 {
+ p.check(`document.querySelector('[data-turn-stop]').getBoundingClientRect().height>=44`, "Stop has a small touch target")
+ }
+ p.wait(`[...document.querySelectorAll('[equipo-thinking] [equipo-phrase] [data-in] > span')].every(e=>Number(getComputedStyle(e).opacity)>=.99)`, "settled thinking phrase")
+ p.fits("thinking line")
+ p.shot(fmt.Sprintf("roster-thinking-%d-%s", width, scheme))
+ p.click(`[equipo-thinking] [data-turn-stop]`)
+ 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
new file mode 100644
index 00000000..4c462109
--- /dev/null
+++ b/internal/thintest/roster_contract_test.go
@@ -0,0 +1,62 @@
+package thintest
+
+import (
+ "amadan.net/oficina/equipo/internal/wire"
+ "net/url"
+ "testing"
+)
+
+// While one turn is running, answers to different cards and the main
+// composer must queue independently. Otherwise their replies mix threads.
+func TestRosterRepliesDoNotBatch(t *testing.T) {
+ r := newToolRig(t)
+ if res := r.call("one", wire.ToolAskPerson, map[string]any{"question": "First question?", "options": []string{}}); res.Code != "asked" {
+ t.Fatal(res)
+ }
+ // A second stored question exercises the mounted Reply route for
+ // both drawers while the earlier turn remains busy.
+ if _, err := r.inst.DB.Writer().Exec("INSERT INTO chat_cards(id,person,kind,state,turn_id,question,options,revision,created_at,updated_at,lane) SELECT 'c_second_reply',person,kind,state,turn_id,'Second question?',options,revision,created_at,updated_at,lane FROM chat_cards WHERE kind='question' LIMIT 1"); err != nil {
+ t.Fatal(err)
+ }
+ snap, err := r.client.Snapshot(r.ctx)
+ if err != nil {
+ t.Fatal(err)
+ }
+ before, err := r.client.Send(r.ctx, "An earlier main message", "before")
+ if err != nil {
+ t.Fatal(err)
+ }
+ var turns []string
+ for _, c := range snap.Cards {
+ if c.Kind == wire.CardQuestion {
+ answer, err := r.client.Answer(r.ctx, c.ID, "My answer", c.Revision)
+ if err != nil {
+ 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) != 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
new file mode 100644
index 00000000..0214509f
--- /dev/null
+++ b/internal/thintest/roster_reports_browser_test.go
@@ -0,0 +1,114 @@
+//go:build browser
+
+package thintest
+
+import (
+ "amadan.net/oficina/equipo/internal/wire"
+ "fmt"
+ "testing"
+ "time"
+)
+
+func TestBrowserRosterReports(t *testing.T) {
+ r := newToolRigSaying(t, wire.ProtocolCurrent, personWords)
+ r.researchOn()
+ r.inventoryOn()
+ d := r.runningResearch("roster-research")
+ if _, err := r.inst.DB.Writer().Exec("UPDATE chat_tasks SET title='Research the shop' WHERE id=?", d.TaskID); err != nil {
+ t.Fatal(err)
+ }
+ r.step("roster-findings", wire.StepReport{TaskID: d.TaskID, StepID: d.StepID, Attempt: d.Attempt, State: wire.StepDone, Termination: true, Summary: "Read four pages.", Research: &wire.ResearchResult{Findings: findingsJSON(t, goodFindings()), Fetches: fetchLog()}})
+ r.nextDispatch()
+ // A paused Copy attempt, with the runner's stored extraction and review.
+ held := r.shopTask("roster-copy")
+ now := r.inst.Store.Chat().Now()
+ raw := `{"extraction":{"version":1,"strings":[{"key":"a","text":"One"},{"key":"b","text":"Two"}]},"review":{"version":1,"strings":[{"key":"a","text":"One"}]}}`
+ if _, err := r.inst.DB.Writer().Exec("INSERT INTO chat_steps(id,task_id,idx,specialist,person,state,reason,attempt,candidate_sha,copy_result,held_at,revision,created_at,updated_at) VALUES('roster-copy-step',?,1,'copy',?,'queued','copy_budget',1,?,?,?,1,?,?)", held, Owner, candX, raw, now, now, now); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := r.inst.DB.Writer().Exec("UPDATE chat_tasks SET copy_hold=1,stage='in_review' WHERE id=?", held); err != nil {
+ t.Fatal(err)
+ }
+ for _, width := range []int64{1280, 390} {
+ for _, scheme := range []string{"light", "dark"} {
+ t.Run(fmt.Sprintf("%d-%s", width, scheme), func(t *testing.T) {
+ if _, err := r.inst.DB.Writer().Exec("UPDATE chat_steps SET state='queued',reason='copy_budget',note='',withdrawn=0,terminated=0 WHERE id='roster-copy-step'"); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := r.inst.DB.Writer().Exec("UPDATE chat_tasks SET copy_hold=1 WHERE id=?", held); err != nil {
+ t.Fatal(err)
+ }
+ 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-offline]').hidden && 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]').previousElementSibling.scrollIntoView({block:'start'});document.querySelector('[equipo-scroll]').dispatchEvent(new Event('scroll'));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.check(`(()=>{const c=document.querySelector('[data-research-report]');return !!c.previousElementSibling.querySelector('[equipo-roster-project] [equipo-mono]') && c.querySelector('[equipo-roster-task]')?.textContent==='Research the shop'})()`, "Research lacks project and task context")
+ if width == 390 {
+ p.check(`[...document.querySelectorAll('[data-research-report] a')].every(a=>a.getBoundingClientRect().height>=44)`, "Research links lost phone tap targets")
+ }
+ p.fits("Research")
+ p.wait(`(()=>{const b=document.querySelector('[data-research-report]').previousElementSibling.getBoundingClientRect(),s=document.querySelector('[equipo-scroll]').getBoundingClientRect();return b.top>=s.top-1 && b.bottom<s.bottom})()`, "Research byline in view")
+ 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]').closest('[data-card]').scrollIntoView({block:'start'});document.querySelector('[equipo-scroll]').dispatchEvent(new Event('scroll'));return true})()`, "show Copy")
+ p.check(`document.querySelector('[data-copy-continue]').getAttribute('rst-btn')!=='primary' && document.querySelector('[equipo-copy-hold] [equipo-actions]').firstElementChild.matches('a[rst-btn="primary"]') && document.querySelector('[equipo-copy-hold] a[rst-btn="primary"]')?.textContent==='Ask the coordinator'`, "Copy skip encouraged")
+ p.check(`!document.querySelector('[equipo-copy-hold]').textContent.includes('..') && !document.querySelector('[equipo-copy-hold] [equipo-link]')`, "Copy copy or actions drifted")
+ p.check(`!!document.querySelector('[equipo-copy-hold]').closest('[data-card]').querySelector('[equipo-roster-project] [equipo-mono]')`, "Copy lacks project context")
+ p.fits("Copy hold")
+ if width == 390 {
+ 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))
+ p.check(`(()=>{document.querySelector('[equipo-copy-hold]').closest('[data-card]').querySelector('[data-set-aside]').click();return true})()`, "set Copy aside")
+ p.wait(`document.querySelector('[equipo-aside-stub]')`, "Copy stub")
+ p.open("/tasks?needs=you")
+ p.check(`!!document.querySelector('a[href="/tasks/`+held+`"]')`, "Copy hold missing from Needs you")
+ p.open("/tasks/" + held)
+ p.check(`!!document.querySelector('[data-copy-continue]')`, "Copy hold unreachable from task")
+ p.open("/conversation")
+ p.click(`[equipo-aside-stub] [data-aside-undo]`)
+ p.wait(`document.querySelector('[equipo-copy-meter]')`, "Copy restored")
+ p.check(`(()=>{window.__fetch=window.fetch;window.fetch=(url,opts)=>opts?.method==='POST'?new Promise(resolve=>{window.__fail=()=>resolve(new Response('{}',{status:503}))}):window.__fetch(url,opts);return true})()`, "hold Copy action")
+ p.click(`[data-copy-continue]`)
+ p.check(`document.querySelector('[data-copy-continue]').getAttribute('aria-busy')==='true' && document.querySelector('[equipo-copy-hold]').closest('[data-card]').querySelector('[data-set-aside]').disabled`, "Copy busy state")
+ p.shot(fmt.Sprintf("roster-copy-busy-%d-%s", width, scheme))
+ p.check(`(()=>{window.__fail();window.fetch=window.__fetch;return true})()`, "fail Copy action")
+ p.wait(`document.querySelector('[equipo-copy-hold]').parentElement.querySelector('[equipo-card-error]:not([hidden])')`, "Copy error")
+ p.shot(fmt.Sprintf("roster-copy-error-%d-%s", width, scheme))
+ p.click(`[equipo-copy-hold] ~ [equipo-card-error] button`)
+ p.wait(`[...document.querySelectorAll('[equipo-card-done]')].some(e=>e.textContent.includes('Continuing without Copy.'))`, "Copy success")
+ p.shot(fmt.Sprintf("roster-copy-done-%d-%s", width, scheme))
+ })
+ }
+ }
+}
+
+func TestBrowserRosterQuietDay(t *testing.T) {
+ r := newToolRig(t)
+ r.runner.Send(r.ctx, "quiet-reply", wire.FrameReply, wire.Reply{TurnID: r.turn, Attempt: 1, Text: "Nothing else today."})
+ r.wait("quiet reply", func(c *Conversation) bool { return c.Turns[r.turn].State == wire.TurnReplied })
+ now := r.inst.Store.Chat().Now()
+ y := time.Date(now.Year(), now.Month(), now.Day()-1, 12, 0, 0, 0, time.UTC)
+ if _, err := r.inst.DB.Writer().Exec("UPDATE chat_messages SET created_at=?", y); err != nil {
+ t.Fatal(err)
+ }
+ for _, width := range []int64{1280, 390} {
+ for _, scheme := range []string{"light", "dark"} {
+ t.Run(fmt.Sprintf("%d-%s", width, scheme), func(t *testing.T) {
+ p := openInner(t, r.inst.URL, r.inst.Cookie(), width, 844, width == 390, scheme, "reduce")
+ defer p.stop()
+ p.open("/conversation")
+ p.check(`!!document.querySelector('[equipo-day-quiet]') && !document.querySelector('[equipo-daybar]')`, "quiet day invents work")
+ p.shot(fmt.Sprintf("roster-quiet-%d-%s", width, scheme))
+ p.click(`[data-day-toggle]`)
+ p.wait(`document.querySelector('[equipo-day-feed]')?.textContent.includes('Nothing else today.')`, "quiet transcript")
+ p.fits("quiet day")
+ p.shot(fmt.Sprintf("roster-quiet-open-%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)
+ }
+
+}
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json
index 30f38453..b54c086b 100644
--- a/scripts/runner-reference-allowlist.json
+++ b/scripts/runner-reference-allowlist.json
@@ -15748,5 +15748,12 @@
"match": "equipo-runner",
"count": 4,
"reason": "Redacted real hosted CI fixture; retained diagnostic text exercises complete failed-unit classification and recovery."
+ },
+ {
+ "path": "internal/equipo/static/chat-stream.js",
+ "line_sha256": "15b2ed7466c12578d071dd4bfa90f24684c0ab96198f1dae2f69ac06bd6db7cd",
+ "match": "Node",
+ "count": 2,
+ "reason": "Browser DOM text and clone methods for the set-aside undo toast, not a runtime dependency."
}
]