oficina / equipo Public

List job threads in Equipo under From Base

GET /jobs lists the person's job threads (new-style hand-offs only,
newest first); GET /jobs/{id} draws one with the conversation template,
read once (no stream), with a reply field posting to
/jobs/{id}/messages. Card answers from a thread return there.
/conversation links to /jobs once the person has a job. The store
gains Jobs, JobThread and SendJob (roster, jobRunner, job.send audit).
New jobs.* strings are marked COPY REVIEW REQUIRED.

CF-J1: TestContractPreviewHeldUntilPublishAnswer checks the merge
card's preview again, read through JobThread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 6aa9bf200229356220346cbfe04eed8dc4bbc666 parent 2f87baf
11 files changed, +577 −24
  • .rastrillo/budgets.txt +3 −3
  • internal/equipo/app.go +3 −0
  • internal/equipo/chat/jobs.go +168 −0
  • internal/equipo/chat_page.go +139 −0
  • internal/equipo/copy.go +9 −0
  • internal/equipo/render.go +1 −1
  • internal/equipo/templates/chat.html +26 −17
  • internal/equipo/templates/jobs.html +10 −0
  • internal/equipo/work_pages.go +5 −0
  • internal/thintest/assistant_job_contract_test.go +196 −0
  • internal/thintest/assistant_outcome_contract_test.go +17 −3
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 28f57d0c..15f90d49 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 19464 - Web pages, handlers, templates and runtime copy stay together. Adds reviewed activity subject formats beside existing activity copy. Measured 19464 source lines.
+size internal/equipo 19620 - Web pages, handlers, templates and runtime copy stay together. Adds the From Base job thread pages beside the conversation. Measured 19620 source lines.
size internal/wire 6088 - Runner and person API types stay together for Encode. Protocol 21 adds job lanes and their downgrade. Measured 6088 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 25436 - The instance store shares transaction and authority helpers. Adds job threads, their tasks and cards beside the person's own lane. Measured 25436 source lines.
+size internal/equipo/chat 25604 - The instance store shares transaction and authority helpers. Adds job threads, their cards and the reads and sends of their pages. Measured 25604 source lines.
perf GET /api/v1/questions/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads questions on /tasks/{id}.
perf GET /api/v1/steps/{id}/log skip Thin v1 person API: bearer-only JSON for devices; the browser shows the log tail on /tasks/{id}.
perf GET /api/v1/connections/preference skip Connections slice 1 person API: bearer-only JSON for devices; the browser shows the preference on /conversation/connections.
@@ -71,7 +71,7 @@ perf GET /tasks/{id}/files/{file} skip Research kept images: the bytes of one im
perf GET /api/v1/runners skip Mac runners person API: bearer-only JSON for devices; the browser shows runners in the Team section.
time cmd/equipo-runner 60s TestReleaseRunnerHasNoFakeWorker builds the release runner and the thin package under testbuild (about 12s locally).
size internal/headless - 10368 End-to-end scenarios through a real runner and instance, browser drives and the Assistant's job threads included. Measured 10368 test lines.
-size internal/thintest - 25320 Contract and browser tests share one instance harness. Adds the job thread hand-off and card lane contracts. Measured 25320 test lines.
+size internal/thintest - 25530 Contract and browser tests share one instance harness. Adds the job thread hand-off, card lane and page contracts. Measured 25530 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/internal/equipo/app.go b/internal/equipo/app.go
index 0e23f08e..8984c439 100644
--- a/internal/equipo/app.go
+++ b/internal/equipo/app.go
@@ -286,6 +286,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.Get("/jobs", a.jobsPage)
+ r.Get("/jobs/{id}", a.jobPage)
+ r.Post("/jobs/{id}/messages", a.jobSend)
r.Post("/conversation/projects/{id}/remove", a.chatProjectRemove)
r.Get("/conversation/notebook", movedTo("/conversation/settings/notebook"))
r.Get("/conversation/settings/notebook", a.chatNotebook)
diff --git a/internal/equipo/chat/jobs.go b/internal/equipo/chat/jobs.go
new file mode 100644
index 00000000..c35cf88a
--- /dev/null
+++ b/internal/equipo/chat/jobs.go
@@ -0,0 +1,168 @@
+package chat
+
+import (
+ "context"
+ "strings"
+ "time"
+ "unicode/utf8"
+
+ "amadan.net/oficina/equipo/internal/wire"
+ "gorm.io/gorm"
+)
+
+// Job threads in Equipo's pages (jobs design, J6). A hand-off's
+// Coordinator thread (lane job:<id>) never shows in the person's own
+// conversation; these are the reads and the send the "From Base" pages
+// use. Only the hand-off's person sees its thread, and only a hand-off
+// with a thread (not a legacy one, whose words went to their
+// conversation) has one.
+
+// auditJobSend is a reply the person posted in a job thread, audited by
+// the message's id alone.
+const auditJobSend = "job.send"
+
+// jobLabelMax is how much of the person's words a job's label keeps.
+const jobLabelMax = 60
+
+// JobRow is one of the person's job threads as /jobs lists it.
+type JobRow struct {
+ ID, Label string
+ UpdatedAt time.Time
+}
+
+// Jobs are the person's job threads, newest first. A legacy hand-off has
+// none, so is not one of them.
+func (s *Store) Jobs(ctx context.Context, person string) (out []JobRow, err error) {
+ err = s.read(ctx, func(tx *gorm.DB) error {
+ if err := s.authority.CurrentPerson(ctx, tx); err != nil {
+ return err
+ }
+ var rows []struct {
+ ID, Text string
+ UpdatedAt time.Time
+ }
+ if err := tx.Table("chat_handoffs AS h").Select("h.id, coalesce(m.text, '') AS text, h.updated_at").Joins("LEFT JOIN chat_messages m ON m.id = h.message_id").Where("h.person = ? AND h.lane = 'job:' || h.id", person).Order("h.created_at DESC, h.id DESC").Scan(&rows).Error; err != nil {
+ return err
+ }
+ out = make([]JobRow, 0, len(rows))
+ for _, r := range rows {
+ out = append(out, JobRow{ID: r.ID, Label: jobLabel(r.Text), UpdatedAt: r.UpdatedAt})
+ }
+ return nil
+ })
+ return out, err
+}
+
+// jobLabel is the person's words cut to jobLabelMax characters (until a
+// hand-off has a title of its own).
+func jobLabel(words string) string {
+ words = strings.TrimSpace(words)
+ if utf8.RuneCountInString(words) <= jobLabelMax {
+ return words
+ }
+ return string([]rune(words)[:jobLabelMax])
+}
+
+// job is the person's hand-off id with a thread of its own: ErrNotFound
+// for another person's, an unknown or a legacy one.
+func job(tx *gorm.DB, person, id string) (handoffRecord, error) {
+ var h handoffRecord
+ if _, ok := wire.JobOf(wire.JobLane(id)); !ok {
+ return h, ErrNotFound
+ }
+ if err := tx.Where("id = ? AND person = ? AND lane = ?", id, person, wire.JobLane(id)).Limit(1).Find(&h).Error; err != nil {
+ return h, err
+ }
+ if h.ID == "" {
+ return h, ErrNotFound
+ }
+ return h, nil
+}
+
+// JobThread reads one of the person's job threads as their conversation
+// reads: its newest messages, its turns, the runner, its cards and the
+// tasks they and the hand-off name.
+func (s *Store) JobThread(ctx context.Context, person, id string) (out wire.Snapshot, err error) {
+ err = s.read(ctx, func(tx *gorm.DB) error {
+ if err := s.authority.CurrentPerson(ctx, tx); err != nil {
+ return err
+ }
+ h, e := job(tx, person, id)
+ if e != nil {
+ return e
+ }
+ if out.Me, e = s.authority.Me(tx, person); e != nil {
+ return e
+ }
+ if out.Cursor, e = maxEvent(tx); e != nil {
+ return e
+ }
+ if out.Messages, out.Turns, e = laneTail(tx, h.Lane, person); e != nil {
+ return e
+ }
+ if out.Runner, e = s.runnerView(tx, person); e != nil {
+ return e
+ }
+ t := &txn{s: s, db: tx}
+ rows, e := t.laneCards(person, h.Lane)
+ if e != nil {
+ return e
+ }
+ names := map[string]bool{}
+ out.Cards = make([]wire.Card, 0, len(rows))
+ for i := len(rows) - 1; i >= 0; i-- {
+ v, e := t.cardView(rows[i])
+ if e != nil {
+ return e
+ }
+ out.Cards = append(out.Cards, v)
+ if v.TaskID != "" {
+ names[v.TaskID] = true
+ }
+ }
+ var followed []string
+ if e = tx.Model(&handoffTaskRecord{}).Where("handoff_id = ?", h.ID).Pluck("task_id", &followed).Error; e != nil {
+ return e
+ }
+ for _, k := range followed {
+ names[k] = true
+ }
+ out.Tasks, e = t.tasksNamed(names)
+ return e
+ })
+ return out, err
+}
+
+// SendJob records a person message in one of their job threads: the
+// roster checked in the write's transaction, a primary able to carry the
+// thread (protocol 21), the message into the thread's lane, audited by
+// its id. The thread takes words only; a message already sent answers as
+// it did.
+func (s *Store) SendJob(ctx context.Context, person, id string, in wire.SendMessage) (out wire.Sent, created bool, err error) {
+ if in.Text = strings.TrimSpace(in.Text); in.Text == "" || len(in.Text) > wire.MaxMessageBytes || !utf8.ValidString(in.Text) || strings.ContainsRune(in.Text, 0) || len(in.Attachments) > 0 || !validKey(in.IdempotencyKey) {
+ return out, false, ErrInvalid
+ }
+ err = s.tx(ctx, func(t *txn) error {
+ if err := s.authority.CurrentPerson(ctx, t.db); err != nil {
+ return err
+ }
+ h, err := job(t.db, person, id)
+ if err != nil {
+ return err
+ }
+ var sent int64
+ if err := t.db.Model(&messageRecord{}).Where("person = ? AND idempotency_key = ? AND lane = ?", person, in.IdempotencyKey, h.Lane).Count(&sent).Error; err != nil {
+ return err
+ }
+ if sent == 0 {
+ if err := t.jobRunner(person); err != nil {
+ return err
+ }
+ }
+ if out, created, err = t.send(h.Lane, person, in.IdempotencyKey, in.Text, nil, nil); err != nil || !created {
+ return err
+ }
+ return t.s.authority.Audit(t.db, person, auditJobSend, out.Message.ID)
+ })
+ return out, created, err
+}
diff --git a/internal/equipo/chat_page.go b/internal/equipo/chat_page.go
index 4985260b..cfd3c53d 100644
--- a/internal/equipo/chat_page.go
+++ b/internal/equipo/chat_page.go
@@ -36,6 +36,22 @@ type chatView struct {
NoConnection *noConnectionCard
Offline bool
Cursor int64
+ // Job is the job thread the page shows instead of the person's own
+ // conversation (/jobs/{id}); FromBase links the conversation to the
+ // person's job threads, which Jobs lists (/jobs).
+ Job *jobHead
+ FromBase bool
+ Jobs []jobLine
+}
+
+// jobHead names the job thread a page shows.
+type jobHead struct{ ID, Label string }
+
+// jobLine is one job thread on /jobs: its label and when it last moved,
+// in the person's zone.
+type jobLine struct {
+ ID, Label, When string
+ At time.Time
}
type noConnectionCard struct{ TurnID, Line string }
@@ -73,6 +89,9 @@ type chatCard struct {
Choices []string
// ActLabel and DismissLabel are an advice card's two buttons.
ActLabel, DismissLabel string
+ // Job is the job thread whose page shows the card: its answer
+ // returns there.
+ Job string
// Task is a task card's task.
Task *taskLine
}
@@ -284,6 +303,14 @@ func (a *application) chatPage(w http.ResponseWriter, r *http.Request) {
a.failure(w, r, chatError(err))
return
}
+ // The work Ask Base handed off has threads of its own: linked from
+ // here once there is one.
+ jobs, err := chats.Jobs(ctx, address)
+ if err != nil {
+ a.failure(w, r, chatError(err))
+ return
+ }
+ view.FromBase = len(jobs) > 0
tasks := map[string]wire.Task{}
for _, t := range snap.Tasks {
tasks[t.ID] = t
@@ -397,6 +424,118 @@ func (a *application) chatSend(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/conversation", http.StatusSeeOther)
}
+// jobsPage lists the person's job threads under "From Base": the work
+// Ask Base handed to their team, newest first.
+func (a *application) jobsPage(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Cache-Control", "no-store")
+ ctx, address, ok := sessionContext(r)
+ if !ok {
+ a.failure(w, r, ErrForbidden)
+ return
+ }
+ chats := a.store.Chat()
+ jobs, err := chats.Jobs(ctx, address)
+ if err != nil {
+ a.failure(w, r, chatError(err))
+ return
+ }
+ data, err := a.page(r, "jobs")
+ if err != nil {
+ a.failure(w, r, err)
+ return
+ }
+ data.Title = "jobs.title"
+ loc := chats.Zone(address)
+ for _, j := range jobs {
+ data.Chat.Jobs = append(data.Chat.Jobs, jobLine{ID: j.ID, Label: j.Label, When: j.UpdatedAt.In(loc).Format("2 Jan 15:04"), At: j.UpdatedAt})
+ }
+ render(w, "jobs", data)
+}
+
+// jobPage is one job thread, drawn with the conversation's template: its
+// messages, the cards it raised, and a reply field. It is read as the
+// page loads (no stream: the person's own conversation is another lane).
+func (a *application) jobPage(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Cache-Control", "no-store")
+ ctx, address, ok := sessionContext(r)
+ if !ok {
+ a.failure(w, r, ErrForbidden)
+ return
+ }
+ id := chi.URLParam(r, "id")
+ chats := a.store.Chat()
+ snap, err := chats.JobThread(ctx, address, id)
+ if err != nil {
+ a.failure(w, r, chatError(err))
+ return
+ }
+ jobs, err := chats.Jobs(ctx, address)
+ if err != nil {
+ a.failure(w, r, chatError(err))
+ return
+ }
+ head := &jobHead{ID: id}
+ for _, j := range jobs {
+ if j.ID == id {
+ head.Label = j.Label
+ }
+ }
+ choices, err := chats.ProjectChoices(ctx, address)
+ if err != nil {
+ a.failure(w, r, chatError(err))
+ return
+ }
+ data, err := a.page(r, "jobs")
+ if err != nil {
+ a.failure(w, r, err)
+ return
+ }
+ data.Title = "jobs.title"
+ tasks := map[string]wire.Task{}
+ for _, t := range snap.Tasks {
+ tasks[t.ID] = t
+ }
+ view := chatView{Offline: !snap.Runner.Online, Cursor: snap.Cursor, Job: head}
+ view.Messages = feedLines(snap.Messages, snap.Cards, choices, tasks)
+ for i := range view.Messages {
+ for _, cards := range [][]chatCard{view.Messages[i].Cards, view.Messages[i].Receipts} {
+ for k := range cards {
+ cards[k].Job = id
+ }
+ }
+ }
+ for _, t := range snap.Turns {
+ if !wire.Terminal(t.State) {
+ view.Waiting = append(view.Waiting, t)
+ }
+ }
+ data.Chat, data.RequestID = view, rand.Text()
+ render(w, "chat", data)
+}
+
+// jobSend is a job thread's reply field: the person's message, into the
+// thread, then back to it.
+func (a *application) jobSend(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Cache-Control", "no-store")
+ ctx, address, ok := sessionContext(r)
+ if !ok {
+ a.failure(w, r, ErrForbidden)
+ return
+ }
+ id := chi.URLParam(r, "id")
+ in := wire.SendMessage{Text: r.PostFormValue("body"), IdempotencyKey: r.PostFormValue("request_id")}
+ if _, _, err := a.store.Chat().SendJob(ctx, address, id, in); err != nil {
+ if errors.Is(err, chat.ErrNoRunner) || errors.Is(err, chat.ErrRunnerTooOld) {
+ // Nothing the person has can carry the thread's turn now.
+ err = ErrConflict
+ }
+ a.failure(w, r, chatError(err))
+ return
+ }
+ // SendJob found the thread, so id is a hand-off id ([a-z0-9_]).
+ http.Redirect(w, r, "/jobs/"+id, http.StatusSeeOther)
+}
+
// chatUpload keeps one file the composer attached, before it is sent:
// the same Upload a device makes, from this origin only (the page shows
// the upload's progress, so it posts the bytes itself).
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index 8226507d..3a71c608 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -1486,6 +1486,15 @@ var pageCopy = map[string]string{
"chat.notebook.reset_help": "Reset clears these notes and starts your coordinator afresh. It moves in again and introduces itself.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"chat.elapsed": "{n}s", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"conversation.title": "Conversation",
+
+ // Job threads (/jobs, /jobs/{id}): the work Ask Base handed to the
+ // team, each in a thread of its own, listed under "From Base".
+ "jobs.title": "From Base", // COPY REVIEW REQUIRED
+ "jobs.lead": "Work Ask Base started for you. You can follow it and reply here.", // COPY REVIEW REQUIRED
+ "jobs.empty": "Nothing has come from Base yet.", // COPY REVIEW REQUIRED
+ "jobs.back": "Back to your conversation", // COPY REVIEW REQUIRED
+ "jobs.all": "All work from Base", // COPY REVIEW REQUIRED
+
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): conversation.empty
"conversation.empty": "Say what you want done. Your coordinator picks the project and tells you, and you can change it.",
"conversation.age_minutes": "%d min", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
diff --git a/internal/equipo/render.go b/internal/equipo/render.go
index f7f4fd88..5e66ef11 100644
--- a/internal/equipo/render.go
+++ b/internal/equipo/render.go
@@ -42,7 +42,7 @@ var pasteBox = func() chatmarkdown.Labels {
}()
func init() {
- for _, name := range []string{"person_devices", "person_device", "teams", "onboarding", "invite", "playbooks", "playbook_form", "playbook_diff", "specialist_form", "template_library", "template_diff", "conversation", "chat", "thread", "plan", "coordinator", "preferences", "index", "empty", "projects", "project", "project_form", "people", "settings", "specialist", "errors", "signin_page", "form_error", "runners", "tasks", "task", "task_form", "question", "merge", "connections", "recovery", "recovery_form", "rendered_approval", "notebook", "housekeeping", "work_tasks", "work_task", "work_projects", "work_project", "models", "work_needs", "settings_hub", "team", "usage"} {
+ for _, name := range []string{"person_devices", "person_device", "teams", "onboarding", "invite", "playbooks", "playbook_form", "playbook_diff", "specialist_form", "template_library", "template_diff", "conversation", "chat", "jobs", "thread", "plan", "coordinator", "preferences", "index", "empty", "projects", "project", "project_form", "people", "settings", "specialist", "errors", "signin_page", "form_error", "runners", "tasks", "task", "task_form", "question", "merge", "connections", "recovery", "recovery_form", "rendered_approval", "notebook", "housekeeping", "work_tasks", "work_task", "work_projects", "work_project", "models", "work_needs", "settings_hub", "team", "usage"} {
page := template.Must(template.New("layout").
Funcs(ui.Funcs(ui.WithIcons(icons.Icon, icons.Assets))).
Funcs(template.FuncMap{"chatMarkdown": pasteBox.Render, "chatDraft": pasteBox.RenderDraft, "fileSize": fileSize, "loadingLine": loadingLine, "split": strings.Split, "since": sinceMillis, "elapsed": elapsedText, "short": short, "agoData": agoData, "agoText": agoText, "hostOf": hostOf, "deref": deref, "agoFormats": agoFormats, "projectAllows": library.ProjectAllowed, "asset": assets.Path, "copy": copyText, "taskGroups": func() []string { return []string{"needs-person", "running", "queued", "finished"} },
diff --git a/internal/equipo/templates/chat.html b/internal/equipo/templates/chat.html
index aecff5a9..9ed15926 100644
--- a/internal/equipo/templates/chat.html
+++ b/internal/equipo/templates/chat.html
@@ -1,20 +1,21 @@
{{define "up-label"}}{{copy "nav.work"}}{{end}}
-{{define "title"}}{{copy "conversation.title"}}{{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" .}}
-{{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}}"><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 "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}}"><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}}"><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}}">{{range .Options}}<button rst-btn name="choice" value="{{.}}" type="submit">{{.}}</button>{{else}}<input rst-input name="choice" required maxlength="2000" aria-label="{{copy "chat.card.answer"}}"><button rst-btn="primary" type="submit">{{copy "chat.card.answer"}}</button>{{end}}</form>{{else}}<p equipo-card-note>{{printf (copy "chat.card.answered") .Choice}}</p>{{end}}
-{{else if eq .Kind "home"}}<p equipo-card-line>{{icon "folder"}}<span>{{.Line}}</span></p><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}"><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}}"><textarea rst-input name="note" maxlength="1000" rows="2" aria-label="{{copy "chat.card.direction_note"}}" placeholder="{{copy "chat.card.direction_note"}}"></textarea>{{range .Options}}<button rst-btn="{{if eq . "build"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-direction-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
-{{else if eq .Kind "specialist"}}<p equipo-card-line>{{.Line}}</p>{{with .Specialist}}{{range .Capabilities}}<p equipo-card-note data-capability="{{.ID}}">{{.Words}}</p>{{end}}<p equipo-card-note data-specialist-brief>{{printf (copy "chat.card.specialist_brief") .Brief}}</p>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{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}}">{{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}}"><button rst-btn="primary" name="choice" value="confirm" type="submit" data-inventory-confirm>{{copy "chat.card.inventory_confirm"}}</button></form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
-{{else if eq .Kind "publish"}}<p equipo-card-line>{{.Line}}</p>{{with .Site}}{{if .URL}}<p equipo-card-note><a href="{{.URL}}" rel="noopener" target="_blank" data-site-link>{{copy "chat.card.site_link"}}</a></p>{{end}}{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{range .Options}}<button rst-btn="{{if eq . "publish"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-publish-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
-{{else if eq .Kind "merge"}}<p equipo-card-line>{{.Line}}</p>{{with .PreviewURL}}<p equipo-card-note><a href="{{.}}" rel="noopener" target="_blank" data-preview-link>{{copy "chat.card.preview_link"}}</a></p>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{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}}">{{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}}"><button rst-btn name="choice" value="check" type="submit" data-grant-check>{{copy "chat.card.grant_check"}}</button></form></details>{{end}}
+{{else if .Receipt}}<p equipo-card-line>{{icon "folder"}}<span>{{.Line}}</span></p>{{if .Open}}<button type="button" equipo-receipt-more aria-expanded="false" aria-controls="acts-{{.ID}}" aria-label="{{copy "chat.card.more"}}">⋯</button><span equipo-receipt-actions id="acts-{{.ID}}">{{if or (eq .Kind "home") (eq .Kind "combined")}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<button equipo-link name="choice" value="undo" type="submit" data-card-undo>{{copy "chat.card.undo"}}</button></form>{{else}}<details equipo-change><summary equipo-link>{{.Change}}</summary><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<select rst-input name="choice" aria-label="{{.Change}}">{{range .Choices}}<option>{{.}}</option>{{end}}</select><button rst-btn="primary" type="submit">{{copy "chat.card.use"}}</button></form></details>{{if .Remove}}<form method="post" action="/conversation/projects/{{.ProjectID}}/remove" data-card-form><button equipo-link type="submit">{{copy "chat.card.remove"}}</button></form>{{end}}{{end}}</span>{{end}}
+{{else if eq .Kind "question"}}<p equipo-card-line>{{.Line}}</p>{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{range .Options}}<button rst-btn name="choice" value="{{.}}" type="submit">{{.}}</button>{{else}}<input rst-input name="choice" required maxlength="2000" aria-label="{{copy "chat.card.answer"}}"><button rst-btn="primary" type="submit">{{copy "chat.card.answer"}}</button>{{end}}</form>{{else}}<p equipo-card-note>{{printf (copy "chat.card.answered") .Choice}}</p>{{end}}
+{{else if eq .Kind "home"}}<p equipo-card-line>{{icon "folder"}}<span>{{.Line}}</span></p><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<button rst-btn="primary" name="choice" value="confirm" type="submit">{{copy "chat.card.confirm"}}</button></form>
+{{else if eq .Kind "direction"}}<p equipo-card-line>{{.Line}}</p>{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<textarea rst-input name="note" maxlength="1000" rows="2" aria-label="{{copy "chat.card.direction_note"}}" placeholder="{{copy "chat.card.direction_note"}}"></textarea>{{range .Options}}<button rst-btn="{{if eq . "build"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-direction-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
+{{else if eq .Kind "specialist"}}<p equipo-card-line>{{.Line}}</p>{{with .Specialist}}{{range .Capabilities}}<p equipo-card-note data-capability="{{.ID}}">{{.Words}}</p>{{end}}<p equipo-card-note data-specialist-brief>{{printf (copy "chat.card.specialist_brief") .Brief}}</p>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{range .Options}}<button rst-btn="{{if eq . "add"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-specialist-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
+{{else if eq .Kind "research_sources"}}<p equipo-card-line>{{.Line}}</p>{{with .Name}}<p equipo-card-note data-research-task>{{printf (copy "chat.card.research_for") .}}</p>{{end}}{{with .Research}}<p equipo-card-note data-research-question>{{printf (copy "chat.card.research_looks_for") .Question}}</p><ul equipo-card-list data-research-urls>{{range .URLs}}<li><code>{{.}}</code></li>{{end}}</ul>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{range .Options}}<button rst-btn="{{if eq . "allow"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-research-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
+{{else if eq .Kind "research_inventory"}}<p equipo-card-line>{{.Line}}</p>{{with .Inventory}}<ul equipo-card-list data-research-addresses>{{range .Addresses}}<li><code>{{.}}</code></li>{{end}}</ul>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<button rst-btn="primary" name="choice" value="confirm" type="submit" data-inventory-confirm>{{copy "chat.card.inventory_confirm"}}</button></form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
+{{else if eq .Kind "publish"}}<p equipo-card-line>{{.Line}}</p>{{with .Site}}{{if .URL}}<p equipo-card-note><a href="{{.URL}}" rel="noopener" target="_blank" data-site-link>{{copy "chat.card.site_link"}}</a></p>{{end}}{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{range .Options}}<button rst-btn="{{if eq . "publish"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-publish-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
+{{else if eq .Kind "merge"}}<p equipo-card-line>{{.Line}}</p>{{with .PreviewURL}}<p equipo-card-note><a href="{{.}}" rel="noopener" target="_blank" data-preview-link>{{copy "chat.card.preview_link"}}</a></p>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{range .Options}}<button rst-btn="{{if eq . "merge"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-merge-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
+{{else if or (eq .Kind "merge_ships") (eq .Kind "merge_policy") (eq .Kind "merge_receipt")}}{{if eq .Kind "merge_receipt"}}<div equipo-card-line equipo-markdown data-merge-receipt>{{chatMarkdown .Line}}</div>{{else}}<p equipo-card-line>{{.Line}}</p>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{range .Options}}<button rst-btn="{{if or (eq . "save") (eq . "not_ships")}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-merge-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}}
+{{else if eq .Kind "access"}}<p equipo-card-line>{{.Line}}</p>{{if .Open}}<details equipo-grant><summary rst-btn>{{copy "chat.card.grant"}}</summary><p>{{.GrantHow}}</p><code>amadan agent grant {{.Agent}} {{.Namespace}}</code><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<button rst-btn name="choice" value="check" type="submit" data-grant-check>{{copy "chat.card.grant_check"}}</button></form></details>{{end}}
{{end}}</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}}
{{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}}
@@ -39,8 +40,8 @@
</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 data-chat-stream data-thinking-set="{{.ThinkingSet}}" data-thinking-words="{{.ThinkingWords}}" data-cursor="{{.Chat.Cursor}}" data-person="{{.Address}}" data-elapsed="{{copy "chat.elapsed"}}" data-moving-in="{{copy "chat.moving_in"}}" data-exploring="{{copy "chat.exploring"}}" data-queued-note="{{copy "chat.queued"}}">
-<header equipo-chat-header><h1>{{copy "conversation.title"}}</h1><a href="/conversation/settings/notebook" equipo-header-button aria-label="{{copy "chat.notebook.link"}}" title="{{copy "chat.notebook.link"}}">{{icon "notebook"}}</a><a href="/housekeeping" equipo-header-button aria-label="{{copy "chat.housekeeping.link"}}" title="{{copy "chat.housekeeping.link"}}" data-housekeeping-link>{{icon "list-checks"}}</a><a href="/conversation/settings/connections" equipo-header-button aria-label="{{copy "chat.connections.title"}}" title="{{copy "chat.connections.title"}}" data-connections-link>{{icon "plug"}}</a></header>
+<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>
<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">
@@ -65,7 +66,15 @@
</div>
<div equipo-announcements role="status" aria-live="polite" aria-atomic="false"></div>
<div id="chat-composer">
-<form id="composer" equipo-form equipo-composer method="post" action="/conversation" data-failed="{{copy "chat.failed"}}" data-failed-many="{{copy "chat.failed_many"}}" data-failed-storage="{{copy "chat.failed_storage"}}" data-retry="{{copy "conversation.retry"}}" data-cancelled="{{copy "chat.cancelled"}}" data-upload="/conversation/attachments" data-max-files="5" data-max-bytes="10485760" data-too-large="{{copy "api.attachment_too_large"}}" data-heic="{{copy "api.attachment_heic"}}" data-too-many="{{copy "chat.attach.too_many"}}" data-upload-failed="{{copy "chat.attach.failed"}}" data-uploading="{{copy "chat.attach.uploading"}}" data-remove="{{copy "chat.attach.remove"}}">
+{{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>
+<div equipo-pill-row>
+<textarea id="chat-body" rst-input name="body" required maxlength="16384" rows="1" aria-label="{{copy "conversation.composer"}}" placeholder="{{copy "conversation.placeholder"}}"></textarea>
+<button type="submit" equipo-send aria-label="{{copy "conversation.send_short"}}" title="{{copy "conversation.send_short"}}">{{icon "arrow-up"}}</button>
+</div>
+</div>
+</form>{{else}}<form id="composer" equipo-form equipo-composer method="post" action="/conversation" data-failed="{{copy "chat.failed"}}" data-failed-many="{{copy "chat.failed_many"}}" data-failed-storage="{{copy "chat.failed_storage"}}" data-retry="{{copy "conversation.retry"}}" data-cancelled="{{copy "chat.cancelled"}}" data-upload="/conversation/attachments" data-max-files="5" data-max-bytes="10485760" data-too-large="{{copy "api.attachment_too_large"}}" data-heic="{{copy "api.attachment_heic"}}" data-too-many="{{copy "chat.attach.too_many"}}" data-upload-failed="{{copy "chat.attach.failed"}}" data-uploading="{{copy "chat.attach.uploading"}}" data-remove="{{copy "chat.attach.remove"}}">
<input type="hidden" name="request_id" value="{{.RequestID}}">
<div equipo-adder hidden><button type="button" equipo-plus aria-label="{{copy "chat.attach.add"}}" title="{{copy "chat.attach.add"}}" aria-haspopup="menu" aria-expanded="false" aria-controls="attach-menu">{{icon "plus"}}</button><div equipo-add-menu id="attach-menu" role="menu" aria-label="{{copy "chat.attach.add"}}" hidden><button type="button" role="menuitem" data-pick="image">{{icon "image"}}<span>{{copy "chat.attach.image"}}</span></button><button type="button" role="menuitem" data-pick="file">{{icon "file-text"}}<span>{{copy "chat.attach.file"}}</span></button></div><input type="file" data-picker="image" accept="image/*" multiple tabindex="-1" aria-hidden="true" equipo-visually-hidden><input type="file" data-picker="file" accept=".txt,.md,.markdown,.csv,.json,.log,.pdf,text/plain,text/markdown,text/csv,application/json,application/pdf" multiple tabindex="-1" aria-hidden="true" equipo-visually-hidden></div>
<div equipo-pill>
@@ -76,7 +85,7 @@
<button type="submit" equipo-send aria-label="{{copy "conversation.send_short"}}" title="{{copy "conversation.send_short"}}">{{icon "arrow-up"}}</button>
</div>
</div>
-</form>
+</form>{{end}}
</div>
</div>
{{end}}
diff --git a/internal/equipo/templates/jobs.html b/internal/equipo/templates/jobs.html
new file mode 100644
index 00000000..db202da8
--- /dev/null
+++ b/internal/equipo/templates/jobs.html
@@ -0,0 +1,10 @@
+{{define "up-label"}}{{copy "nav.work"}}{{end}}
+{{define "title"}}{{copy "jobs.title"}}{{end}}
+{{define "content"}}
+<section equipo-jobs data-jobs>
+<header equipo-chat-header><h1>{{copy "jobs.title"}}</h1></header>
+<p equipo-jobs-lead>{{copy "jobs.lead"}}</p>
+{{with .Chat.Jobs}}<ul equipo-jobs-list role="list">{{range .}}<li data-job="{{.ID}}"><a href="/jobs/{{.ID}}">{{.Label}}</a> <time datetime="{{.At.UTC.Format "2006-01-02T15:04:05Z07:00"}}">{{.When}}</time></li>{{end}}</ul>{{else}}<p data-empty-state="jobs.empty">{{copy "jobs.empty"}}</p>{{end}}
+<p><a href="/conversation" data-jobs-back>{{copy "jobs.back"}}</a></p>
+</section>
+{{end}}
diff --git a/internal/equipo/work_pages.go b/internal/equipo/work_pages.go
index 756aa94d..25cee37b 100644
--- a/internal/equipo/work_pages.go
+++ b/internal/equipo/work_pages.go
@@ -983,6 +983,11 @@ func workBack(r *http.Request, id string) string {
return "/tasks"
case "needs":
return "/tasks?needs=you"
+ case "job":
+ // A card answered on a job thread's page returns there.
+ if job, ok := wire.JobOf(wire.JobLane(r.PostFormValue("job"))); ok {
+ return "/jobs/" + job
+ }
}
return "/conversation"
}
diff --git a/internal/thintest/assistant_job_contract_test.go b/internal/thintest/assistant_job_contract_test.go
new file mode 100644
index 00000000..bb653fc8
--- /dev/null
+++ b/internal/thintest/assistant_job_contract_test.go
@@ -0,0 +1,196 @@
+package thintest
+
+import (
+ "context"
+ "html"
+ "net/http"
+ "net/url"
+ "slices"
+ "strconv"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/equipo/personapi"
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// Job threads in Equipo's pages (jobs design, J6): /jobs lists the
+// person's job threads under "From Base", /jobs/{id} shows one with the
+// conversation page's template and a reply field, and /conversation
+// links there once the person has one.
+
+// jobThread is the request's thread as JobThread reads it for the owner.
+func (o *teamRig) jobThread(request string) wire.Snapshot {
+ o.t.Helper()
+ ctx := personapi.WithVerifiedPrincipal(context.Background(), personapi.PersonPrincipal{Address: Owner, SessionEpoch: time.Now().Unix()})
+ snap, err := o.inst.Store.Chat().JobThread(ctx, Owner, request)
+ if err != nil {
+ o.t.Fatalf("job thread %s: %v", request, err)
+ }
+ return snap
+}
+
+// jobCard is the card of kind on the task in the request's thread, as
+// JobThread reads it.
+func (o *teamRig) jobCard(request, kind, task string) wire.Card {
+ o.t.Helper()
+ for _, c := range o.jobThread(request).Cards {
+ if c.Kind == kind && c.TaskID == task {
+ return c
+ }
+ }
+ return wire.Card{}
+}
+
+// TestContractTeamJobThreadPage: signed in as the hand-off's person,
+// /jobs lists it and /jobs/<request> shows the person's words, the
+// thread's reply and its card; a reply posted there is the thread's next
+// message, dispatched in its lane and audited by id. Another member sees
+// an empty list and gets 404 for the thread and its reply; a legacy
+// hand-off has no thread. /conversation links to /jobs only once the
+// person has a job.
+func TestContractTeamJobThreadPage(t *testing.T) {
+ o := newTeamRig(t)
+ owner := o.inst.Cookie()
+ if page := o.get(owner, "/conversation", http.StatusOK); strings.Contains(page, `href="/jobs"`) {
+ t.Fatal("/conversation links to /jobs before any job")
+ }
+ if page := o.get(owner, "/jobs", http.StatusOK); !strings.Contains(page, `data-empty-state="jobs.empty"`) {
+ t.Fatalf("/jobs with no job: %.300s", page)
+ }
+ o.ask("Can we fix a bug in Tito? Login is broken")
+ request, cmd := o.handoff("jp1", "Login is broken", "")
+ lane := wire.JobLane(request)
+ o.in(cmd.TurnID, func() {
+ if res := o.call("jp-ask", wire.ToolAskPerson, map[string]any{"question": "Which login page is it?", "options": []string{"Web", "App"}}); res.Code != "asked" {
+ t.Fatalf("ask %+v", res)
+ }
+ })
+ if err := o.runner.Send(o.ctx, "r-jp-reply", wire.FrameReply, wire.Reply{TurnID: cmd.TurnID, Attempt: 1, Text: "Looking at the sign in page."}); err != nil {
+ t.Fatal(err)
+ }
+ o.until("the thread's reply", func() bool { return o.turnState(cmd.TurnID) == wire.TurnReplied })
+ card, _ := o.threadQuestion(request)
+
+ list := o.get(owner, "/jobs", http.StatusOK)
+ if !strings.Contains(list, `href="/jobs/`+request+`"`) || !strings.Contains(list, "Login is broken") || strings.Contains(list, `data-empty-state="jobs.empty"`) {
+ t.Fatalf("/jobs %.600s", list)
+ }
+ if page := o.get(owner, "/conversation", http.StatusOK); !strings.Contains(page, `href="/jobs"`) {
+ t.Fatal("/conversation has no From Base link once the person has a job")
+ }
+ page := html.UnescapeString(o.get(owner, "/jobs/"+request, http.StatusOK))
+ for _, want := range []string{"Login is broken", "Looking at the sign in page.", "Which login page is it?", `data-card="` + card + `"`, `action="/jobs/` + request + `/messages"`, `href="/conversation"`, `href="/jobs"`} {
+ if !strings.Contains(page, want) {
+ t.Fatalf("/jobs/%s lacks %q", request, want)
+ }
+ }
+ if strings.Contains(page, "data-chat-stream") {
+ t.Fatal("the thread page follows the person's own conversation stream")
+ }
+
+ // A reply posted on the thread page is the thread's next message.
+ status, loc := o.post(owner, "/jobs/"+request+"/messages", url.Values{"body": {"It is the web one."}, "request_id": {"jp-reply-1"}})
+ if status != http.StatusSeeOther || loc != "/jobs/"+request {
+ t.Fatalf("reply: %d %q", status, loc)
+ }
+ var id, turn string
+ if err := o.inst.DB.Writer().QueryRow("SELECT id, turn_id FROM chat_messages WHERE lane = ? AND role = ? AND text = ?", lane, wire.RolePerson, "It is the web one.").Scan(&id, &turn); err != nil {
+ t.Fatalf("the reply is not in the thread: %v", err)
+ }
+ if next := o.message(lane); next.TurnID != turn || !slices.Equal(next.PersonText, []string{"It is the web one."}) {
+ t.Fatalf("the reply's frame %+v", next)
+ }
+ if n := o.rows("SELECT count(*) FROM audit_events WHERE kind = ? AND record_id = ? AND actor = ?", "job.send", id, Owner); n != 1 {
+ t.Fatalf("%d job.send audits for the reply", n)
+ }
+ // The same request again is the same message.
+ if status, _ := o.post(owner, "/jobs/"+request+"/messages", url.Values{"body": {"It is the web one."}, "request_id": {"jp-reply-1"}}); status != http.StatusSeeOther {
+ t.Fatalf("repeat: %d", status)
+ }
+ if n := o.rows("SELECT count(*) FROM chat_messages WHERE lane = ? AND text = ?", lane, "It is the web one."); n != 1 {
+ t.Fatalf("%d copies of the reply", n)
+ }
+ if n := o.rows("SELECT count(*) FROM chat_messages WHERE coalesce(lane, '') = '' AND text = ?", "It is the web one."); n != 0 {
+ t.Fatal("the reply reached their own conversation")
+ }
+
+ // Another member has no jobs and cannot read or reply to this one.
+ mate := o.memberCookie()
+ if page := o.get(mate, "/jobs", http.StatusOK); strings.Contains(page, request) || !strings.Contains(page, `data-empty-state="jobs.empty"`) {
+ t.Fatalf("another member's /jobs %.300s", page)
+ }
+ o.get(mate, "/jobs/"+request, http.StatusNotFound)
+ if status, _ := o.post(mate, "/jobs/"+request+"/messages", url.Values{"body": {"Mine now."}, "request_id": {"jp-mate"}}); status != http.StatusNotFound {
+ t.Fatalf("another member's reply: %d", status)
+ }
+ if n := o.rows("SELECT count(*) FROM chat_messages WHERE text = ?", "Mine now."); n != 0 {
+ t.Fatal("another member's reply was stored")
+ }
+
+ // A legacy hand-off and an unknown id have no thread.
+ legacy, _ := o.legacyHandoff("jp", "Checkout is slow")
+ o.get(owner, "/jobs/"+legacy, http.StatusNotFound)
+ o.get(owner, "/jobs/h_unknown", http.StatusNotFound)
+ if list := o.get(owner, "/jobs", http.StatusOK); strings.Contains(list, legacy) || strings.Contains(list, "Checkout is slow") {
+ t.Fatal("/jobs lists a legacy hand-off")
+ }
+
+ // A primary back below protocol 21 cannot carry the thread: a new
+ // reply is refused and stored nowhere; one already sent answers as it
+ // did.
+ o.runner.Close()
+ o.wait("offline", func(c *Conversation) bool { return !c.Runner.Online })
+ o.dialAt(wire.Protocol20)
+ if status, _ := o.post(owner, "/jobs/"+request+"/messages", url.Values{"body": {"Any news?"}, "request_id": {"jp-old"}}); status != http.StatusConflict {
+ t.Fatalf("a reply at 20: %d", status)
+ }
+ if n := o.rows("SELECT count(*) FROM chat_messages WHERE text = ?", "Any news?"); n != 0 {
+ t.Fatal("a reply at 20 was stored")
+ }
+ if status, loc := o.post(owner, "/jobs/"+request+"/messages", url.Values{"body": {"It is the web one."}, "request_id": {"jp-reply-1"}}); status != http.StatusSeeOther || loc != "/jobs/"+request {
+ t.Fatalf("the sent reply again at 20: %d %q", status, loc)
+ }
+}
+
+// TestContractTeamJobThreadAnswer: a question card answered from the
+// thread page is answered in the job's lane: the answer is the thread's
+// next message, dispatched there, and the page returns to the thread.
+func TestContractTeamJobThreadAnswer(t *testing.T) {
+ o := newTeamRig(t)
+ owner := o.inst.Cookie()
+ o.ask("Can we fix a bug in Tito? Login is broken")
+ request, cmd := o.handoff("ja1", "Login is broken", "")
+ lane := wire.JobLane(request)
+ o.in(cmd.TurnID, func() {
+ if res := o.call("ja-ask", wire.ToolAskPerson, map[string]any{"question": "Which login page is it?", "options": []string{"Web", "App"}}); res.Code != "asked" {
+ t.Fatalf("ask %+v", res)
+ }
+ })
+ o.reply(cmd.TurnID)
+ card, revision := o.threadQuestion(request)
+ page := o.get(owner, "/jobs/"+request, http.StatusOK)
+ form := `action="/conversation/cards/` + card + `/answer"`
+ if !strings.Contains(page, form) || !strings.Contains(page, `name="job" value="`+request+`"`) {
+ t.Fatalf("the thread's card form: %.2000s", page)
+ }
+ status, loc := o.post(owner, "/conversation/cards/"+card+"/answer", url.Values{"revision": {strconv.FormatInt(revision, 10)}, "choice": {"Web"}, "from": {"job"}, "job": {request}})
+ if status != http.StatusSeeOther || loc != "/jobs/"+request {
+ t.Fatalf("answer: %d %q", status, loc)
+ }
+ var id, turn string
+ if err := o.inst.DB.Writer().QueryRow("SELECT m.id, m.turn_id FROM chat_cards c JOIN chat_messages m ON m.id = c.answer_message WHERE c.id = ? AND c.state = ? AND c.choice = ?", card, wire.CardAnswered, "Web").Scan(&id, &turn); err != nil {
+ t.Fatalf("the card is not answered: %v", err)
+ }
+ if o.laneOf(turn) != lane || o.rows("SELECT count(*) FROM chat_messages WHERE id = ? AND lane = ?", id, lane) != 1 {
+ t.Fatal("the answer is not in the thread")
+ }
+ if next := o.message(lane); next.TurnID != turn || !slices.Equal(next.PersonText, []string{"Web"}) {
+ t.Fatalf("the answer's frame %+v", next)
+ }
+ // A job id that is not one returns to the conversation.
+ if status, loc := o.post(owner, "/conversation/cards/"+card+"/answer", url.Values{"revision": {strconv.FormatInt(revision, 10)}, "choice": {"Web"}, "from": {"job"}, "job": {"../tasks"}}); status != http.StatusSeeOther || loc != "/conversation" {
+ t.Fatalf("a bad job id: %d %q", status, loc)
+ }
+}
diff --git a/internal/thintest/assistant_outcome_contract_test.go b/internal/thintest/assistant_outcome_contract_test.go
index 36c24d26..4662b4b9 100644
--- a/internal/thintest/assistant_outcome_contract_test.go
+++ b/internal/thintest/assistant_outcome_contract_test.go
@@ -136,6 +136,16 @@ func (o *teamRig) mergeFromCard(key, id, base, cand, sha string) {
o.wait("done", func(c *Conversation) bool { return c.Tasks[id].Stage == wire.StageDone })
}
+// requestOf is the hand-off that follows the task.
+func (o *teamRig) requestOf(task string) string {
+ o.t.Helper()
+ var request string
+ if err := o.inst.DB.Writer().QueryRow("SELECT handoff_id FROM chat_handoff_tasks WHERE task_id = ?", task).Scan(&request); err != nil {
+ o.t.Fatal(err)
+ }
+ return request
+}
+
// laneOfCard is the card's lane.
func (o *teamRig) laneOfCard(id string) string {
o.t.Helper()
@@ -949,10 +959,11 @@ func TestContractPreviewHeldUntilPublishAnswer(t *testing.T) {
if previewOf(card) != link {
t.Fatalf("%s: the publish outcome shows no preview: %+v", choice, card)
}
- // The merge card itself is in the job's thread, which no person
- // read shows yet; its preview is the go-ahead's (taskPreview).
+ // The merge card itself is in the job's thread, read as the
+ // thread's page reads it.
+ request := o.requestOf(id)
ahead := o.assistantCard("the merge outcome", isMergeOutcome)
- if previewOf(ahead) != link {
+ if previewOf(ahead) != link || o.jobCard(request, wire.CardMerge, id).PreviewURL != link {
t.Fatalf("%s: the merge cards lost the held preview: %+v", choice, ahead)
}
if _, err := o.a.Answer(o.ctx, card.ID, choice, card.Revision); err != nil {
@@ -967,6 +978,9 @@ func TestContractPreviewHeldUntilPublishAnswer(t *testing.T) {
t.Fatalf("%s: a card shows the released preview: %+v", choice, c)
}
}
+ if c := o.jobCard(request, wire.CardMerge, id); c.ID == "" || c.PreviewURL != "" {
+ t.Fatalf("%s: the merge card shows the released preview: %+v", choice, c)
+ }
if choice != wire.ChoicePublish {
continue
}