Match chat screens to the round two mockups
Co-Authored-By: Astra <noreply@openai.com>
42 files changed,
+656
−196
docs/mockups/built/2026-11-05/after/conversation-1280.pngbinarydocs/mockups/built/2026-11-05/after/conversation-390.pngbinarydocs/mockups/built/2026-11-05/after/conversation-history-1280.pngbinarydocs/mockups/built/2026-11-05/after/conversation-history-390.pngbinarydocs/mockups/built/2026-11-05/after/nav-1280.pngbinarydocs/mockups/built/2026-11-05/after/nav-390.pngbinarydocs/mockups/built/2026-11-05/after/thread-1280.pngbinarydocs/mockups/built/2026-11-05/after/thread-390.pngbinarydocs/mockups/built/2026-11-05/after/thread-history-1280.pngbinarydocs/mockups/built/2026-11-05/after/thread-history-390.pngbinarydocs/superpowers/plans/CONTROLLER-REPORT-chat-ui.md+113 −0docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+14 −0internal/browsertest/browser.go+64 −0internal/equipo/chat_navigation_test.go+38 −0internal/equipo/conversation/chat.go+12 −0internal/equipo/conversation/handlers.go+11 −1internal/equipo/conversation/project_message.go+34 −0internal/equipo/conversation/views.go+11 −0internal/equipo/copy.go+16 −3internal/equipo/handlers.go+6 −9internal/equipo/library/navigation.go+45 −4internal/equipo/planning/task_views.go+2 −0internal/equipo/static/chat.js+19 −0internal/equipo/static/equipo.css+92 −35internal/equipo/task_page_handlers.go+0 −15internal/equipo/task_views.go+5 −0internal/equipo/templates/chrome.html+5 −5internal/equipo/templates/conversation.html+2 −3internal/equipo/templates/conversation_card.html+21 −21internal/equipo/templates/thread.html+1 −3internal/equipotest/browser_test.go+10 −55internal/equipotest/chat_browser_test.go+22 −18internal/equipotest/chat_style_browser_test.go+40 −0internal/equipotest/pages_test.go+2 −2internal/equipotest/task_browser_test.go+8 −7internal/plan3test/conversation_browser_test.go+6 −3internal/plan3test/conversation_test.go+15 −6internal/plan3test/forms_fixture.go+7 −0internal/plan3test/plan3_release_test.go+2 −2internal/plan3test/teams_navigation_browser_test.go+1 −1internal/runnerproto/question_options_test.go+14 −0internal/runnerproto/question_views.go+18 −3
CI passed — run details
diff --git a/docs/mockups/built/2026-11-05/after/conversation-1280.png b/docs/mockups/built/2026-11-05/after/conversation-1280.png| index 3be0fcfb..6e95cfce 100644 |
| Binary files a/docs/mockups/built/2026-11-05/after/conversation-1280.png and b/docs/mockups/built/2026-11-05/after/conversation-1280.png differ |
diff --git a/docs/mockups/built/2026-11-05/after/conversation-390.png b/docs/mockups/built/2026-11-05/after/conversation-390.png| index ac0013e5..0c6d3bb7 100644 |
| Binary files a/docs/mockups/built/2026-11-05/after/conversation-390.png and b/docs/mockups/built/2026-11-05/after/conversation-390.png differ |
diff --git a/docs/mockups/built/2026-11-05/after/conversation-history-1280.png b/docs/mockups/built/2026-11-05/after/conversation-history-1280.png| index 5f88a5c3..23cc75d5 100644 |
| Binary files a/docs/mockups/built/2026-11-05/after/conversation-history-1280.png and b/docs/mockups/built/2026-11-05/after/conversation-history-1280.png differ |
diff --git a/docs/mockups/built/2026-11-05/after/conversation-history-390.png b/docs/mockups/built/2026-11-05/after/conversation-history-390.png| index 14f77c93..c563ac7a 100644 |
| Binary files a/docs/mockups/built/2026-11-05/after/conversation-history-390.png and b/docs/mockups/built/2026-11-05/after/conversation-history-390.png differ |
diff --git a/docs/mockups/built/2026-11-05/after/nav-1280.png b/docs/mockups/built/2026-11-05/after/nav-1280.png| index 4e70655d..b210a4de 100644 |
| Binary files a/docs/mockups/built/2026-11-05/after/nav-1280.png and b/docs/mockups/built/2026-11-05/after/nav-1280.png differ |
diff --git a/docs/mockups/built/2026-11-05/after/nav-390.png b/docs/mockups/built/2026-11-05/after/nav-390.png| index c39ad53e..09976c90 100644 |
| Binary files a/docs/mockups/built/2026-11-05/after/nav-390.png and b/docs/mockups/built/2026-11-05/after/nav-390.png differ |
diff --git a/docs/mockups/built/2026-11-05/after/thread-1280.png b/docs/mockups/built/2026-11-05/after/thread-1280.png| index 86fd0259..af6c9791 100644 |
| Binary files a/docs/mockups/built/2026-11-05/after/thread-1280.png and b/docs/mockups/built/2026-11-05/after/thread-1280.png differ |
diff --git a/docs/mockups/built/2026-11-05/after/thread-390.png b/docs/mockups/built/2026-11-05/after/thread-390.png| index f139a991..4cf2cea4 100644 |
| Binary files a/docs/mockups/built/2026-11-05/after/thread-390.png and b/docs/mockups/built/2026-11-05/after/thread-390.png differ |
diff --git a/docs/mockups/built/2026-11-05/after/thread-history-1280.png b/docs/mockups/built/2026-11-05/after/thread-history-1280.png| index b47f18ae..fe6d1c1b 100644 |
| Binary files a/docs/mockups/built/2026-11-05/after/thread-history-1280.png and b/docs/mockups/built/2026-11-05/after/thread-history-1280.png differ |
diff --git a/docs/mockups/built/2026-11-05/after/thread-history-390.png b/docs/mockups/built/2026-11-05/after/thread-history-390.png| index 76c4351e..4812e2f4 100644 |
| Binary files a/docs/mockups/built/2026-11-05/after/thread-history-390.png and b/docs/mockups/built/2026-11-05/after/thread-history-390.png differ |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-chat-ui.md b/docs/superpowers/plans/CONTROLLER-REPORT-chat-ui.md| index 4f3a6891..4ba6a664 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-chat-ui.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-chat-ui.md |
| @@ -142,3 +142,116 @@ Delivery target: `origin/chat-ui`. The harness stopped its loopback servers and |
| browsers and removed its temporary databases and profiles. The task scratch |
| files were removed at handoff; the 24 comparison PNGs remain in the repository. |
| The release/install areas named in the brief were not changed. |
| + |
| +## Round 2 |
| + |
| +Starting point: `b42b4ed`, the second brief on `acf53a2`. The sidebar now has |
| +one team name and switch control, one Specialists heading, compact status text, |
| +and project and Needs you counts. Playbooks and the template library are under |
| +Team. Failed count reads remain unavailable. |
| + |
| +Incoming messages are plain text under their sender label. Your messages use a |
| +right-aligned tinted bubble, with a small keyboard-accessible actions menu. |
| +Dates separate days, including retained history after live updates. The header |
| +and rounded composer stay in place while the feed scrolls. On phones the back |
| +link shares the title row. The composer has a placeholder, an accessible label, |
| +and a small Send button. Its project picker appears only in the main conversation |
| +when projects exist. Choosing a project prefixes the message with its name, |
| +visible in the sent message. This supplies context without changing project |
| +permissions or automatically assigning a task. |
| + |
| +Question cards use a hairline border and attention tint. Single-field native |
| +questions with options have one-tap answers. Free text starts at one line and |
| +grows as you type; Send and Deny retain the existing answer handlers. Task cards |
| +link to their thread, include project, kind and age, and use step pills with |
| +category, action, model and account. Arrows connect the steps; active and done |
| +states have markers as well as colour. Edit plan and Why these models are small |
| +controls. Evidence and project correction remain available in the card's details. |
| + |
| +Navigation reads now live with the navigation view. Browser wait, click and |
| +capture helpers are shared in `internal/browsertest`. Existing size ceilings are |
| +unchanged. Vendored assets, schema, release code and README prose are unchanged. |
| + |
| +### Round 2 verification |
| + |
| +The first browser run failed on the sidebar, message presentation, date separator, |
| +header, question, task actions and composer. The first project-context test failed |
| +because the selection was absent from the message. The first option-label test |
| +failed because native option labels were discarded. Adding date separators also |
| +exposed a retained-history offset failure; rebuilding the separators across |
| +retained and newly loaded messages fixed it. Final review also found the missing |
| +recommendation-kind label. `TestChatTaskKinds` failed before that pending copy |
| +entry was added. |
| + |
| +All commands use `GOTOOLCHAIN=go1.26.10 CGO_ENABLED=0`: |
| + |
| +- Browser checks, passed: `go test -tags browser ./internal/equipotest ./internal/plan3test -run '^(TestChatBrowser|TestFoundationBrowserWalk|TestRunnerTaskBrowserWalk|TestConversationLayout|TestTeamsHierarchyBrowser)$' -count=1`. |
| +- Scriptless checks, passed: `EQUIPO_BROWSER_NO_JS=1 go test -tags browser ./internal/equipotest -run '^(TestChatBrowser|TestFoundationBrowserWalk|TestRunnerTaskBrowserWalk)$' -count=1`. |
| +- Focused checks, passed: `go test ./internal/equipo ./internal/plan3test ./internal/runnerproto -run '^(TestChatNavigationStatus|TestChatTaskKinds|TestConversationMessageReplay|TestPlan3ReleaseBoundaries|TestQuestionOptionLabels)$' -count=1`. |
| +- Full gate: `GOFLAGS=-p=2 make -k ci`, one run, exit 2. The failures were two old assertions: `TestRailRoutes` required a separate Teams row with an icon, and `TestConversationNoProjectPicker` rejected a selector even when projects existed. They now check the team switch and the conditional picker. Their focused rerun passed. The full affected-package rerun, `GOFLAGS=-p=2 go test ./internal/equipotest ./internal/plan3test -count=1`, passed: 334.069s and 197.220s respectively. The application package still exceeded its advisory 300s local limit. Final browser reruns passed in 37.214s and 5.582s. |
| + |
| +Build, vet, formatting, static analysis, vulnerability and secret scans, size |
| +budgets, adapter, containment, migration and performance checks passed in that |
| +full run. The test step took 17m33.138s: 27 packages passed and two failed on the |
| +assertions above. No second full gate run was made. The final recommendation |
| +label was added during the gate and passed the task-kind, template-copy and |
| +copy-inventory checks separately. |
| + |
| +Conversation first-byte time was 25.721 ms median, 33.421 ms worst; task threads |
| +were 22.319 ms median, 28.049 ms worst. Both are within the 150 ms budget. |
| +Cold boot was 119 ms median against 500 ms. |
| + |
| +The full run emitted these local advisory timing notices. CI enforces them; |
| +passing the functional checks does not certify these timing limits. |
| + |
| +| Package | Observed | Limit | |
| +|---|---:|---:| |
| +| `internal/directlive` | 9m20.368s | 6m | |
| +| `internal/runner` | 8m10.746s | 5m30s | |
| +| `internal/runner/provider` | 32.779s | 15s | |
| +| `internal/runner/provider/claude` | 1m6.783s | 45s | |
| +| `internal/runner/provider/codex` | 57.863s | 35s | |
| + |
| +Twenty-one mutations were applied separately and restored. Each failed its guard: |
| + |
| +| Guard command | Deliberate breakages caught | |
| +|---|---| |
| +| `go test -tags browser ./internal/equipotest -run '^TestChatBrowser$' -count=1` | Separate brand restored; team switch removed from header; duplicate specialist heading; wrapping counts; missing project count; boxed incoming text; visible own email; missing message menu; missing date separator; expanded header; multiline initial question field; missing options; missing age; missing plan controls; missing placeholder; page overflow; wrong option answer field. | |
| +| `go test -tags browser ./internal/plan3test -run '^TestConversationLayout$' -count=1` | Removed date rebuilding from retained history. | |
| +| `go test ./internal/plan3test -run '^TestConversationMessageReplay$' -count=1` | Selected project omitted from the message. | |
| +| `go test ./internal/runnerproto -run '^TestQuestionOptionLabels$' -count=1` | Native option labels discarded. | |
| +| `go test ./internal/equipo -run '^TestChatNavigationStatus$' -count=1` | Working count replaced with zero. | |
| + |
| +### Round 2 captures and copy |
| + |
| +The ten `after/*.png` files under `docs/mockups/built/2026-11-05/` are replaced |
| +at the original 1280×900 and 390×900 sizes. Before and reference images remain |
| +unchanged. The fixture question now includes Net and Subtotal options so the |
| +one-tap controls can be compared with the reference. Capture uses the original |
| +command above, with `EQUIPO_CHAT_BASELINE=1`; the four history captures also use |
| +`EQUIPO_CHAT_HISTORY=1`. Captures exclude replies inserted by browser assertions. |
| + |
| +Each new entry below has `// COPY REVIEW PENDING` in `copy.go`. The consolidated |
| +Plan 3 inventory contains the same pending entries. Its test now expects the |
| +release-copy check to reject this branch while that copy is pending. |
| + |
| +| Key | Draft text | |
| +|---|---| |
| +| `task.kind.recommendation` | Recommendation | |
| +| `nav.switch` | switch | |
| +| `nav.idle` | idle | |
| +| `nav.waiting` | waiting | |
| +| `nav.queued` | queued | |
| +| `conversation.placeholder` | Ask for a fix, a feature, or what’s next | |
| +| `conversation.today` | Today | |
| +| `conversation.message_actions` | Message actions | |
| +| `conversation.any_project` | Any project | |
| +| `conversation.why_models` | Why these models? | |
| +| `conversation.send_short` | Send | |
| +| `conversation.age_minutes` | %d min | |
| +| `conversation.age_hours` | %d hr | |
| +| `conversation.age_days` | %d d | |
| + |
| +No copy-review server was started. The harness closed its loopback servers and |
| +browsers. Scratch captures, mutation scripts and test logs were removed. Delivery |
| +target is `origin/chat-ui`; no default-branch push or deployment. |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index 18eed055..d89af5da 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -4719,6 +4719,20 @@ records remain unchanged. |
| | Key or section | Draft text | Owning task | State / surface | |
| | --- | --- | --- | --- | |
| +| `task.kind.recommendation` | Recommendation | Chat UI round 2 | Runtime; COPY REVIEW REQUIRED | |
| +| `conversation.age_minutes` | %d min | Chat UI round 2 | Runtime; COPY REVIEW REQUIRED | |
| +| `conversation.age_hours` | %d hr | Chat UI round 2 | Runtime; COPY REVIEW REQUIRED | |
| +| `conversation.age_days` | %d d | Chat UI round 2 | Runtime; COPY REVIEW REQUIRED | |
| +| `conversation.send_short` | Send | Chat UI round 2 | Runtime; COPY REVIEW REQUIRED | |
| +| `nav.queued` | queued | Chat UI round 2 | Runtime; COPY REVIEW REQUIRED | |
| +| `nav.switch` | switch | Chat UI round 2 | Runtime; COPY REVIEW REQUIRED | |
| +| `nav.idle` | idle | Chat UI round 2 | Runtime; COPY REVIEW REQUIRED | |
| +| `nav.waiting` | waiting | Chat UI round 2 | Runtime; COPY REVIEW REQUIRED | |
| +| `conversation.placeholder` | Ask for a fix, a feature, or what’s next | Chat UI round 2 | Runtime; COPY REVIEW REQUIRED | |
| +| `conversation.today` | Today | Chat UI round 2 | Runtime; COPY REVIEW REQUIRED | |
| +| `conversation.message_actions` | Message actions | Chat UI round 2 | Runtime; COPY REVIEW REQUIRED | |
| +| `conversation.any_project` | Any project | Chat UI round 2 | Runtime; COPY REVIEW REQUIRED | |
| +| `conversation.why_models` | Why these models? | Chat UI round 2 | Runtime; COPY REVIEW REQUIRED | |
| | `notifications.question` | A question needs your answer. | 19 | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) | |
| | `notifications.task_ready` | A task is ready for you to review. | 19 | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) | |
| | `notifications.interrupted` | Work stopped and needs your attention. | 19 | Runtime; COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) | |
diff --git a/internal/browsertest/browser.go b/internal/browsertest/browser.go| new file mode 100644 |
| index 00000000..9eb319ba |
| --- /dev/null |
| +++ b/internal/browsertest/browser.go |
| @@ -0,0 +1,64 @@ |
| +//go:build browser |
| + |
| +package browsertest |
| + |
| +import ( |
| + "amadan.net/rastrillo/rastrillo/harness" |
| + "context" |
| + "fmt" |
| + "github.com/chromedp/chromedp" |
| + "os" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + "time" |
| +) |
| + |
| +func Wait(expression string) chromedp.Action[chromedp.Void] { |
| + return chromedp.Func(func(ctx context.Context, target *chromedp.Target) error { |
| + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) |
| + defer cancel() |
| + tick := time.NewTicker(20 * time.Millisecond) |
| + defer tick.Stop() |
| + for { |
| + ok, err := chromedp.Evaluate[bool]("document.readyState === 'complete' && ("+expression+")")(ctx, target) |
| + if err == nil && ok { |
| + return nil |
| + } |
| + select { |
| + case <-ctx.Done(): |
| + return fmt.Errorf("waiting for %s: %w (last evaluation: %v)", expression, ctx.Err(), err) |
| + case <-tick.C: |
| + } |
| + } |
| + }) |
| +} |
| + |
| +func Click(selector string) chromedp.Action[chromedp.Void] { |
| + return chromedp.Func(func(ctx context.Context, target *chromedp.Target) error { |
| + ctx, cancel := context.WithTimeout(ctx, 8*time.Second) |
| + defer cancel() |
| + _, err := chromedp.RunResponse(ctx, chromedp.Click(chromedp.CSS(selector))) |
| + return err |
| + }) |
| +} |
| + |
| +func Screenshot(t *testing.T, rig *harness.Rig, name string) { |
| + t.Helper() |
| + dir := os.Getenv("EQUIPO_BROWSER_ARTIFACTS") |
| + if dir == "" { |
| + return |
| + } |
| + if strings.HasPrefix(name, "mockup-") && strings.HasSuffix(name, "-390") { |
| + harness.Evaluate[bool](rig, `(()=>{const e=location.pathname.includes('native')?document.querySelectorAll('.ph')[2]:document.querySelector('.phone');e?.scrollIntoView({block:'start'});return true})()`) |
| + } |
| + if os.Getenv("EQUIPO_CHAT_HISTORY") == "1" { |
| + harness.Evaluate[bool](rig, `(()=>{const e=document.querySelector('[equipo-scroll]');if(e)e.scrollTop=0;return true})()`) |
| + } |
| + if err := os.MkdirAll(dir, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(filepath.Join(dir, name+".png"), harness.Read(rig, chromedp.CaptureScreenshot()), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
diff --git a/internal/equipo/chat_navigation_test.go b/internal/equipo/chat_navigation_test.go| new file mode 100644 |
| index 00000000..2d80c63f |
| --- /dev/null |
| +++ b/internal/equipo/chat_navigation_test.go |
| @@ -0,0 +1,38 @@ |
| +package equipo |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo/library" |
| + "bytes" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +func TestChatNavigationStatus(t *testing.T) { |
| + for _, tc := range []struct { |
| + count SpecialistWorkView |
| + text string |
| + }{ |
| + {SpecialistWorkView{CountsKnown: true}, "idle"}, |
| + {SpecialistWorkView{CountsKnown: true, Working: 1}, "1"}, |
| + {SpecialistWorkView{CountsKnown: true, Working: 1, Queued: 1}, "1 · 1 queued"}, |
| + {SpecialistWorkView{CountsKnown: true, Waiting: 1}, "1 waiting"}, |
| + {SpecialistWorkView{}, "Unavailable"}, |
| + } { |
| + data := pageData{Nav: []NavItem{{Key: "engineering", Group: "specialists", Href: "/specialists/engineering", CopyKey: "nav.engineering", Icon: "code"}}, NavigationView: library.NavigationView{Counts: map[string]SpecialistWorkView{"engineering": tc.count}}} |
| + var out bytes.Buffer |
| + if err := pages["conversation"].ExecuteTemplate(&out, "region:rail", data); err != nil { |
| + t.Fatal(err) |
| + } |
| + if !strings.Contains(out.String(), ">"+tc.text+"</small>") { |
| + t.Fatalf("status %q missing: %s", tc.text, out.String()) |
| + } |
| + } |
| +} |
| + |
| +func TestChatTaskKinds(t *testing.T) { |
| + for _, kind := range []string{"bug", "feature", "rendered_change", "recommendation", "investigation"} { |
| + if pageCopy["task.kind."+kind] == "" { |
| + t.Errorf("missing chat task kind %s", kind) |
| + } |
| + } |
| +} |
diff --git a/internal/equipo/conversation/chat.go b/internal/equipo/conversation/chat.go| index ea6a0296..581bc4a0 100644 |
| --- a/internal/equipo/conversation/chat.go |
| +++ b/internal/equipo/conversation/chat.go |
| @@ -3,6 +3,8 @@ package conversation |
| import ( |
| "amadan.net/oficina/equipo/internal/equipo/library" |
| "amadan.net/oficina/equipo/internal/equipo/planning" |
| + "fmt" |
| + "time" |
| ) |
| func (v *Page) PrepareChat(address string, specialists []library.Specialist, taskView func(string) (planning.TaskViewData, error), copyText func(string) string) error { |
| @@ -49,6 +51,16 @@ func (v *Page) PrepareChat(address string, specialists []library.Specialist, tas |
| if err != nil { |
| return err |
| } |
| + if !w.CreatedAt.IsZero() && copyText != nil { |
| + elapsed := max(time.Duration(0), v.Now.Sub(w.CreatedAt)) |
| + n, key := int(elapsed.Minutes()), "conversation.age_minutes" |
| + if elapsed >= 24*time.Hour { |
| + n, key = int(elapsed.Hours()/24), "conversation.age_days" |
| + } else if elapsed >= time.Hour { |
| + n, key = int(elapsed.Hours()), "conversation.age_hours" |
| + } |
| + w.ChatAge = fmt.Sprintf(copyText(key), n) |
| + } |
| work = &w |
| tasks[id] = work |
| } |
diff --git a/internal/equipo/conversation/handlers.go b/internal/equipo/conversation/handlers.go| index 4a636cea..68eb1c12 100644 |
| --- a/internal/equipo/conversation/handlers.go |
| +++ b/internal/equipo/conversation/handlers.go |
| @@ -3,6 +3,7 @@ package conversation |
| import ( |
| "net/http" |
| "net/url" |
| + "strconv" |
| "amadan.net/oficina/equipo/internal/equipo/planning" |
| "amadan.net/rastrillo/rastrillo/auth" |
| @@ -59,7 +60,16 @@ func (h *Handler) Send(w http.ResponseWriter, r *http.Request) { |
| m, err := planning.ReadMutation(w, r, h.App.Invalid) |
| task := chi.URLParam(r, "id") |
| if err == nil { |
| - _, err = h.App.SendMessage(r.Context(), a, task, r.PostForm.Get("body"), m) |
| + if raw := r.PostForm.Get("project_id"); raw != "" { |
| + project, parseErr := strconv.ParseInt(raw, 10, 64) |
| + if parseErr != nil || project <= 0 || task != "" { |
| + err = h.App.Invalid |
| + } else { |
| + _, err = h.App.SendProjectMessage(r.Context(), a, r.PostForm.Get("body"), project, m) |
| + } |
| + } else { |
| + _, err = h.App.SendMessage(r.Context(), a, task, r.PostForm.Get("body"), m) |
| + } |
| } |
| if err != nil { |
| h.Failure(w, r, err) |
diff --git a/internal/equipo/conversation/project_message.go b/internal/equipo/conversation/project_message.go| new file mode 100644 |
| index 00000000..93c8f8fe |
| --- /dev/null |
| +++ b/internal/equipo/conversation/project_message.go |
| @@ -0,0 +1,34 @@ |
| +package conversation |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "gorm.io/gorm" |
| +) |
| + |
| +// The picker adds visible context to the person's message. It does not grant |
| +// project access or override the coordinator's project checks. |
| +func (s *Application) SendProjectMessage(ctx context.Context, actor Actor, body string, projectID int64, m Mutation) (Message, error) { |
| + if body == "" { |
| + return Message{}, s.Invalid |
| + } |
| + actor.Address = s.Normalize(actor.Address) |
| + var msg Message |
| + err := s.Write(ctx, func(tx *gorm.DB) error { |
| + cs := s.Conversation(tx) |
| + if _, err := cs.deps.Authorize(tx, actor); err != nil { |
| + return err |
| + } |
| + var project struct{ Name string } |
| + err := tx.Table("projects").Select("name").Where("id=?", projectID).Take(&project).Error |
| + if errors.Is(err, gorm.ErrRecordNotFound) { |
| + return s.NotFound |
| + } |
| + if err != nil { |
| + return err |
| + } |
| + msg, err = cs.SendMessage(actor, "", project.Name+"\n\n"+body, m) |
| + return err |
| + }) |
| + return msg, err |
| +} |
diff --git a/internal/equipo/conversation/views.go b/internal/equipo/conversation/views.go| index 9cb3449d..48ed51a9 100644 |
| --- a/internal/equipo/conversation/views.go |
| +++ b/internal/equipo/conversation/views.go |
| @@ -33,6 +33,9 @@ type CardView struct { |
| } |
| type Page struct { |
| ThreadTitle string |
| + Today string |
| + Now time.Time |
| + Projects []planning.ProjectOption |
| ThreadPlan *planning.Page |
| Live live.View |
| Topic, ThreadID, RequestID, NextURL string |
| @@ -47,9 +50,17 @@ type Page struct { |
| func (s *Application) View(ctx context.Context, a Actor, task, cursor string, plans *planning.Application) (out Page, err error) { |
| a.Address = s.Normalize(a.Address) |
| out.ThreadID = task |
| + out.Now = s.Now().UTC() |
| + out.Today = out.Now.Format("2006-01-02") |
| out.RequestID = rand.Text() |
| err = s.Write(ctx, func(tx *gorm.DB) error { |
| cs := s.Conversation(tx) |
| + if _, err := cs.deps.Authorize(tx, a); err != nil { |
| + return err |
| + } |
| + if err := tx.Table("projects").Select("id", "name").Order("name, id").Find(&out.Projects).Error; err != nil { |
| + return err |
| + } |
| var page ConversationPage |
| if task == "" { |
| main, e := cs.main(a) |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index f11398b3..8956a1ed 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -265,8 +265,8 @@ var pageCopy = map[string]string{ |
| "task.kind.feature": "Feature", |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): task.kind.rendered_change |
| "task.kind.rendered_change": "Website change", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): task.kind.investigation |
| - "task.kind.investigation": "Investigation", |
| + "task.kind.investigation": "Investigation", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): task.kind.investigation |
| + "task.kind.recommendation": "Recommendation", // COPY REVIEW PENDING |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): playbooks.title |
| "playbooks.title": "Playbooks", |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): playbooks.new |
| @@ -422,7 +422,20 @@ var pageCopy = map[string]string{ |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): conversation.title |
| "conversation.title": "Conversation", |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): conversation.empty |
| - "conversation.empty": "Start a conversation with your coordinator.", |
| + "conversation.empty": "Start a conversation with your coordinator.", |
| + "conversation.age_minutes": "%d min", // COPY REVIEW PENDING |
| + "conversation.age_hours": "%d hr", // COPY REVIEW PENDING |
| + "conversation.age_days": "%d d", // COPY REVIEW PENDING |
| + "conversation.send_short": "Send", // COPY REVIEW PENDING |
| + "nav.queued": "queued", // COPY REVIEW PENDING |
| + "nav.switch": "switch", // COPY REVIEW PENDING |
| + "nav.idle": "idle", // COPY REVIEW PENDING |
| + "nav.waiting": "waiting", // COPY REVIEW PENDING |
| + "conversation.placeholder": "Ask for a fix, a feature, or what’s next", // COPY REVIEW PENDING |
| + "conversation.today": "Today", // COPY REVIEW PENDING |
| + "conversation.message_actions": "Message actions", // COPY REVIEW PENDING |
| + "conversation.any_project": "Any project", // COPY REVIEW PENDING |
| + "conversation.why_models": "Why these models?", // COPY REVIEW PENDING |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): conversation.composer |
| "conversation.composer": "Message your coordinator", |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): conversation.send |
diff --git a/internal/equipo/handlers.go b/internal/equipo/handlers.go| index a04c4867..c7e050b4 100644 |
| --- a/internal/equipo/handlers.go |
| +++ b/internal/equipo/handlers.go |
| @@ -48,12 +48,11 @@ type pageData struct { |
| Tasks []TaskViewData |
| TaskView TaskViewData |
| Work SpecialistWorkView |
| - Counts map[string]SpecialistWorkView |
| - Connections []ConnectionView |
| - Choices []ProjectConnectionView |
| - Recovery *team.RecoverySnapshot |
| - Question TaskQuestion |
| - |
| + library.NavigationView |
| + Connections []ConnectionView |
| + Choices []ProjectConnectionView |
| + Recovery *team.RecoverySnapshot |
| + Question TaskQuestion |
| PairingConfirmation, Origin, UserCode string |
| Enrolment Runner |
| Runners []Runner |
| @@ -92,9 +91,7 @@ func (a *application) page(r *http.Request, key string) (pageData, error) { |
| } |
| data.Specialists = rows |
| data.Nav, data.SpecialistNames = library.WithSpecialists(rows) |
| - if err := a.fillCounts(r, &data); err != nil { |
| - return pageData{}, err |
| - } |
| + data.NavigationView.Load(r.Context(), a.store, Actor{Address: data.Address}, data.Specialists) |
| return data, nil |
| } |
| func (a *application) failure(w http.ResponseWriter, r *http.Request, err error) { |
diff --git a/internal/equipo/library/navigation.go b/internal/equipo/library/navigation.go| index d22862f1..bd2b49fe 100644 |
| --- a/internal/equipo/library/navigation.go |
| +++ b/internal/equipo/library/navigation.go |
| @@ -1,6 +1,10 @@ |
| package library |
| -import "amadan.net/oficina/equipo/internal/equipo/planning" |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo/kernel" |
| + "amadan.net/oficina/equipo/internal/equipo/planning" |
| + "context" |
| +) |
| type NavItem struct{ Key, Group, Href, CopyKey, Icon string } |
| @@ -16,8 +20,8 @@ func Navigation() []NavItem { |
| {"copy", "specialists", "/specialists/copy", "nav.copy", "type"}, |
| {"engineering", "specialists", "/specialists/engineering", "nav.engineering", "code"}, |
| {"review", "specialists", "/specialists/review", "nav.review", "check-circle"}, |
| - {"playbooks", "", "/playbooks", "playbooks.title", "route"}, |
| - {"templates", "specialists", "/templates", "templates.title", "plus"}, |
| + {"playbooks", "team", "/playbooks", "playbooks.title", "route"}, |
| + {"templates", "team", "/templates", "templates.title", "plus"}, |
| {"preferences", "team", "/preferences", "preferences.title", "sliders"}, |
| {"coordinator", "team", "/settings/coordinator", "coordinator.settings", "message-circle"}, |
| {"connections", "team", "/connections", "nav.connections", "plug"}, |
| @@ -42,7 +46,7 @@ func WithSpecialists(rows []Specialist) ([]NavItem, map[string]string) { |
| names[row.Key] = row.Name |
| } |
| for i, item := range nav { |
| - if item.Key == "templates" { |
| + if item.Key == "playbooks" { |
| custom := []NavItem{} |
| for _, row := range rows { |
| if row.Role == "" { |
| @@ -66,3 +70,40 @@ func NavigationCounts(counts map[string]planning.SpecialistWorkView, rows []Spec |
| } |
| return unknown |
| } |
| + |
| +type NavigationView struct { |
| + Counts map[string]planning.SpecialistWorkView |
| + NavProjects, NavNeeds *int |
| +} |
| + |
| +type NavigationStore interface { |
| + SpecialistCounts(context.Context, kernel.Actor) (map[string]planning.SpecialistWorkView, error) |
| + Projects(context.Context) ([]kernel.ProjectGroup, error) |
| + Journey(context.Context, kernel.Actor) ([]planning.TaskViewData, error) |
| +} |
| + |
| +func (v *NavigationView) Load(ctx context.Context, store NavigationStore, actor kernel.Actor, rows []Specialist) { |
| + if v.Counts != nil { |
| + return |
| + } |
| + counts, err := store.SpecialistCounts(ctx, actor) |
| + v.Counts = NavigationCounts(counts, rows, err) |
| + groups, err := store.Projects(ctx) |
| + if err == nil { |
| + n := 0 |
| + for _, group := range groups { |
| + n += len(group.Projects) |
| + } |
| + v.NavProjects = &n |
| + } |
| + tasks, err := store.Journey(ctx, actor) |
| + if err == nil { |
| + n := 0 |
| + for _, task := range tasks { |
| + if task.NeedsYou { |
| + n++ |
| + } |
| + } |
| + v.NavNeeds = &n |
| + } |
| +} |
diff --git a/internal/equipo/planning/task_views.go b/internal/equipo/planning/task_views.go| index 5c910bd5..34e1d71d 100644 |
| --- a/internal/equipo/planning/task_views.go |
| +++ b/internal/equipo/planning/task_views.go |
| @@ -35,6 +35,8 @@ type TaskEvidence struct { |
| } |
| type TaskViewData struct { |
| CanStopOldRunner bool |
| + CreatedAt time.Time |
| + ChatAge string |
| Isolation team.IsolationSnapshot |
| Task Task |
| Project kernel.Project |
diff --git a/internal/equipo/static/chat.js b/internal/equipo/static/chat.js| index bbf154a8..d4ef91f3 100644 |
| --- a/internal/equipo/static/chat.js |
| +++ b/internal/equipo/static/chat.js |
| @@ -50,12 +50,18 @@ |
| }); |
| function retainHistory(changes) { |
| var list = chat.querySelector("[equipo-feed]"); |
| + var dates = new Map(); |
| + function collectDates(root) { |
| + root.querySelectorAll("[equipo-day] time").forEach(function (el) { dates.set(el.getAttribute("datetime"), el.textContent); }); |
| + } |
| + collectDates(list); |
| var current = Array.from(list.querySelectorAll("[data-message]")); |
| var ids = new Set(current.map(function (el) { return el.dataset.message; })); |
| var first = current.length ? Number(current[0].dataset.sequence) : 0; |
| changes.forEach(function (change) { |
| Array.from(change.removedNodes).forEach(function (old) { |
| if (old.id !== "conversation-feed") return; |
| + collectDates(old); |
| old.querySelectorAll("[data-message]").forEach(function (el) { |
| var sequence = Number(el.dataset.sequence); |
| if (ids.has(el.dataset.message) || sequence >= first) return; |
| @@ -65,6 +71,19 @@ |
| }); |
| }); |
| }); |
| + list.querySelectorAll("[equipo-day]").forEach(function (el) { el.remove(); }); |
| + var day = ""; |
| + list.querySelectorAll("[data-message]").forEach(function (el) { |
| + var date = el.querySelector("time").getAttribute("datetime").slice(0, 10); |
| + if (date === day) return; |
| + day = date; |
| + var separator = document.createElement("li"), time = document.createElement("time"); |
| + separator.setAttribute("equipo-day", ""); |
| + time.setAttribute("datetime", date); |
| + time.textContent = dates.get(date) || date; |
| + separator.append(time); |
| + list.insertBefore(separator, el); |
| + }); |
| } |
| var observer = new MutationObserver(function (changes) { |
| var feedChanged = changes.some(function (c) { return Array.from(c.addedNodes).some(function (n) { return n.id === "conversation-feed"; }); }); |
diff --git a/internal/equipo/static/equipo.css b/internal/equipo/static/equipo.css| index 1ec67dd9..c0e1cc92 100644 |
| --- a/internal/equipo/static/equipo.css |
| +++ b/internal/equipo/static/equipo.css |
| @@ -50,7 +50,6 @@ |
| } |
| [rst-shell-sidebar~="teams"] > [rst-shell-back] { display: none; } |
| @media (max-width: 799.98px) { |
| - [equipo-team-heading] { display: none; } |
| [equipo-team-index] > [rst-shell-back] { |
| display: flex; |
| align-items: center; |
| @@ -61,47 +60,105 @@ |
| } |
| } |
| +body:has([equipo-conversation]) { overflow: hidden; } |
| +[rst-shell-sidebar]:has([equipo-conversation]) { block-size: 100dvh; overflow: hidden; } |
| +[rst-shell-main]:has([equipo-conversation]) { min-block-size: 0; overflow: hidden; } |
| [rst-page]:has([equipo-conversation]) { display: flex; flex-direction: column; block-size: 100dvh; max-width: none; padding: 0; } |
| -[equipo-conversation] { display: flex; flex-direction: column; flex: 1; min-block-size: 0; inline-size: 100%; max-width: 60rem; } |
| -[equipo-chat-header] { flex: none; padding: var(--rst-sp-4) var(--rst-sp-5); border-block-end: 1px solid var(--rst-line); } |
| -[equipo-chat-header] h1 { font-size: var(--rst-fs-lg); margin: 0; } |
| -[equipo-chat-header] p { margin-block: var(--rst-sp-1); font-size: var(--rst-fs-sm); } |
| -[equipo-chat-header] > a { font-size: var(--rst-fs-sm); } |
| -[equipo-scroll] { flex: 1; min-block-size: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; overflow-anchor: none; padding: var(--rst-sp-4) var(--rst-sp-5); } |
| +[equipo-conversation] { display: flex; flex-direction: column; flex: 1; min-block-size: 0; inline-size: 100%; max-width: none; } |
| +[equipo-chat-header] { display: flex; align-items: center; gap: var(--rst-sp-3); flex: none; padding: var(--rst-sp-3) var(--rst-sp-5); border-block-end: 1px solid var(--rst-line); } |
| +[equipo-chat-header] h1 { flex: 1; font-size: var(--rst-fs-base); margin: 0; } |
| +[equipo-chat-header] > a { color: var(--rst-text-muted); } |
| +[equipo-scroll] { flex: 1; min-block-size: 0; overflow-y: auto; overscroll-behavior: contain; overflow-anchor: none; padding: var(--rst-sp-4) max(var(--rst-sp-5), calc((100% - 48rem) / 2)); } |
| #conversation-feed { min-block-size: 100%; display: flex; flex-direction: column; } |
| -[equipo-feed] { display: flex; flex-direction: column; gap: var(--rst-sp-5); list-style: none; margin: auto 0 0; padding: 0; } |
| -[equipo-message] { max-inline-size: 88%; margin: 0; align-self: flex-start; } |
| +[equipo-feed] { display: flex; flex-direction: column; gap: var(--rst-sp-4); list-style: none; margin: auto 0 0; padding: 0; } |
| +[equipo-day] { align-self: center; color: var(--rst-text-muted); font-size: var(--rst-fs-sm); } |
| +[equipo-message] { position: relative; max-inline-size: 88%; margin: 0; align-self: flex-start; } |
| [equipo-message="own"] { align-self: flex-end; } |
| -[equipo-message-meta] { display: flex; align-items: baseline; gap: var(--rst-sp-3); color: var(--rst-text-muted); font-size: var(--rst-fs-sm); margin-block-end: var(--rst-sp-2); } |
| -[equipo-message-meta] strong { font-weight: 500; min-width: 0; } |
| -[equipo-message-meta] time { white-space: nowrap; margin-inline-start: auto; } |
| -[equipo-bubble] { padding: var(--rst-sp-3) var(--rst-sp-4); border: 1px solid var(--rst-line); border-radius: var(--rst-radius); background: var(--rst-surface); } |
| -[equipo-message="own"] [equipo-bubble] { background: var(--rst-accent-soft); } |
| +[equipo-message-meta] { display: flex; align-items: baseline; gap: var(--rst-sp-3); color: var(--rst-text-muted); font-size: var(--rst-fs-sm); margin-block-end: var(--rst-sp-1); } |
| +[equipo-message-meta] strong { font-weight: 400; min-width: 0; } |
| +[equipo-message-meta] time { white-space: nowrap; margin-inline-start: auto; font-size: var(--rst-fs-xs); } |
| +[equipo-message="own"] [equipo-message-meta] { position: absolute; inset-inline-end: var(--rst-sp-2); inset-block-end: 0; } |
| +[equipo-message="own"] time { opacity: 0; } |
| +[equipo-message="own"]:hover time, [equipo-message="own"]:focus-within time { opacity: 1; } |
| +[equipo-bubble] { padding: 0; border: 0; background: transparent; } |
| +[equipo-message="own"] [equipo-bubble] { padding: var(--rst-sp-3) var(--rst-sp-4); border: 1px solid var(--rst-line); border-radius: calc(2 * var(--rst-radius)); background: var(--rst-accent-soft); } |
| [equipo-message-body] { margin: 0; } |
| -[equipo-message] details { margin-block-start: var(--rst-sp-2); font-size: var(--rst-fs-sm); } |
| +[equipo-message-actions] { font-size: var(--rst-fs-sm); text-align: end; } |
| +[equipo-message-actions] > summary { cursor: pointer; list-style: none; color: var(--rst-text-muted); inline-size: 2rem; margin-inline-start: auto; } |
| +[equipo-message-actions] > form { text-align: start; padding-block: var(--rst-sp-2); } |
| [equipo-feed-card] { min-width: 0; } |
| -[equipo-feed-card] > [equipo-card] { margin: 0; } |
| +[equipo-feed-card] > [equipo-card] { margin: 0; position: relative; padding: var(--rst-sp-3); border-radius: calc(2 * var(--rst-radius)); } |
| [equipo-feed-card] h2 { font-size: var(--rst-fs-base); margin: 0; } |
| [equipo-feed-card] h2 a { color: var(--rst-text); text-decoration: none; } |
| -[equipo-chat-task] [equipo-steps] { flex-wrap: nowrap; overflow-x: auto; padding-block-end: var(--rst-sp-2); } |
| -[equipo-chat-task] [equipo-step] { flex: 1 0 8rem; font-size: var(--rst-fs-sm); } |
| -[equipo-chat-task] [equipo-step][data-state="running"] { background: var(--rst-accent-soft); } |
| -[equipo-chat-task] [equipo-step][data-state="succeeded"] { background: var(--rst-tone-positive-bg); } |
| -#chat-composer { flex: none; padding: var(--rst-sp-3) var(--rst-sp-5) max(var(--rst-sp-4), env(safe-area-inset-bottom)); border-block-start: 1px solid var(--rst-line); background: var(--rst-surface); } |
| -#composer { max-width: none; margin: 0; grid-template-columns: minmax(0, 1fr) auto; gap: var(--rst-sp-3); align-items: end; } |
| -#composer label { font-size: var(--rst-fs-sm); color: var(--rst-text-muted); } |
| -#composer textarea { resize: none; min-block-size: 3.5rem; max-block-size: 9rem; color: var(--rst-text); } |
| -#composer button { margin-block-end: var(--rst-sp-1); } |
| -[equipo-announcements] { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); } |
| -[equipo-count] { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } |
| -[rst-shell-nav] a > span { min-width: 0; } |
| +[equipo-task-link]::after { content: ""; position: absolute; inset: 0; border-radius: inherit; } |
| +[equipo-chat-task] :is(details, form, [equipo-actions], a:not([equipo-task-link])) { position: relative; z-index: 1; } |
| +[equipo-chat-task] [equipo-secondary] { margin-block: var(--rst-sp-1); font-size: var(--rst-fs-sm); } |
| +[equipo-chat-task] [equipo-steps] { flex-wrap: nowrap; overflow-x: auto; padding-block: var(--rst-sp-2); margin: 0; gap: var(--rst-sp-5); } |
| +[equipo-chat-task] [equipo-step] { position: relative; flex: 1 0 7rem; max-inline-size: 11rem; font-size: var(--rst-fs-sm); gap: 0; padding: var(--rst-sp-2); white-space: nowrap; } |
| +[equipo-chat-task] [equipo-step] + [equipo-step]::before { content: "→"; position: absolute; inset-inline-start: calc(-1 * var(--rst-sp-4)); inset-block-start: 40%; color: var(--rst-text-muted); } |
| +[equipo-chat-task] [equipo-step] strong { font-size: var(--rst-fs-xs); text-transform: uppercase; letter-spacing: 0.03em; } |
| +[equipo-chat-task] [equipo-step] .icon { display: none; } |
| +[equipo-chat-task] [equipo-value], [equipo-step-state] { color: var(--rst-text-muted); font-size: var(--rst-fs-xs); } |
| +[equipo-chat-task] [equipo-step][data-state="running"] { background: var(--rst-accent-soft); border-color: var(--rst-accent); } |
| +[equipo-chat-task] [equipo-step][data-state="succeeded"] { background: var(--rst-tone-positive-bg); color: var(--rst-tone-positive-fg); } |
| +[equipo-chat-task] [equipo-actions] { margin-block: var(--rst-sp-2) 0; } |
| +[equipo-conversation] [rst-btn] { font-size: var(--rst-fs-sm); min-block-size: 1.75rem; padding: var(--rst-sp-1) var(--rst-sp-3); white-space: nowrap; } |
| +[equipo-models] > summary { list-style: none; } |
| +[equipo-task-details] { margin-block-start: var(--rst-sp-2); font-size: var(--rst-fs-xs); color: var(--rst-text-muted); } |
| +[equipo-task-details] a { margin-inline-end: var(--rst-sp-3); } |
| +[equipo-feed-card] > [equipo-question] { background: color-mix(in srgb, var(--rst-tone-warning-bg) 45%, var(--rst-surface)); border: 1px solid color-mix(in srgb, var(--rst-tone-warning-fg) 25%, var(--rst-line)); } |
| +[equipo-question] [equipo-form] { gap: var(--rst-sp-2); } |
| +[equipo-question] label { font-size: var(--rst-fs-sm); } |
| +[equipo-question] textarea { min-block-size: 2rem; resize: none; field-sizing: content; max-block-size: 9rem; } |
| +[equipo-question] [equipo-actions] { margin-block: var(--rst-sp-2) 0; } |
| +#chat-composer { flex: none; padding: var(--rst-sp-3) max(var(--rst-sp-4), calc((100% - 50rem) / 2)) max(var(--rst-sp-3), env(safe-area-inset-bottom)); background: var(--rst-surface); } |
| +#composer { display: grid; max-width: none; margin: 0; padding: var(--rst-sp-3); border: 1px solid var(--rst-line); border-radius: calc(2 * var(--rst-radius)); gap: var(--rst-sp-2); } |
| +#composer:focus-within { border-color: var(--rst-accent); } |
| +#composer textarea { border: 0; background: transparent; padding: 0; box-shadow: none; resize: none; min-block-size: 1.5rem; max-block-size: 9rem; field-sizing: content; color: var(--rst-text); } |
| +[equipo-composer-tools] { display: flex; align-items: center; gap: var(--rst-sp-2); } |
| +#composer select { width: auto; max-width: 65%; border-radius: var(--rst-radius-pill); font-size: var(--rst-fs-sm); min-block-size: 1.75rem; padding-block: var(--rst-sp-1); } |
| +#composer button { margin-inline-start: auto; } |
| +[equipo-announcements], [equipo-visually-hidden] { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); } |
| +[equipo-count] { display: inline; flex: none; margin-inline-start: auto; white-space: nowrap; overflow: visible; font-size: var(--rst-fs-xs); } |
| +[equipo-attention] { color: var(--rst-tone-warning-fg); } |
| +[rst-shell-nav] a { gap: var(--rst-sp-2); } |
| +[rst-shell-nav] a > span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } |
| +[equipo-team-heading] { display: flex; align-items: center; gap: var(--rst-sp-2); margin-block-end: var(--rst-sp-3); } |
| +[equipo-team-heading] [rst-shell-brand] { flex: 1; min-width: 0; } |
| +#nav-teams { font-size: var(--rst-fs-xs); color: var(--rst-text-muted); padding-inline: 0; } |
| +@media (min-width: 800px) { |
| + [rst-shell-sidebar] { grid-template-columns: 17rem minmax(0, 1fr); } |
| +} |
| @media (max-width: 799px) { |
| - [rst-page]:has([equipo-conversation]) { block-size: calc(100dvh - var(--rst-shell-strip)); } |
| - [equipo-chat-header], [equipo-scroll], #chat-composer { padding-inline: var(--rst-sp-3); } |
| + [equipo-chat-header], [equipo-scroll], #chat-composer { padding-inline: var(--rst-sp-3); } |
| [equipo-chat-header] { padding-block: var(--rst-sp-2); } |
| - [equipo-chat-header] p { display: none; } |
| - [equipo-message] { max-inline-size: 94%; } |
| - [equipo-message-meta] { gap: var(--rst-sp-2); } |
| - [equipo-feed] { gap: var(--rst-sp-4); } |
| - #composer { gap: var(--rst-sp-2); } |
| + [equipo-message-meta] { gap: var(--rst-sp-2); } |
| + [rst-shell-sidebar~="index"] [rst-shell-title] { display: none; } |
| + [equipo-team-heading] { padding-block: var(--rst-sp-4); padding-inline-end: var(--rst-sp-6); } |
| + [equipo-chat-task] [equipo-steps] { gap: var(--rst-sp-4); } |
| +} |
| +[equipo-choice] { display: inline-block; margin-block-end: var(--rst-sp-2); margin-inline-end: var(--rst-sp-2); } |
| +[rst-shell-rail]:has([equipo-team-heading]) > [rst-shell-title] { display: none; } |
| +[equipo-message-actions] > summary .icon { display: inline-block; } |
| +[equipo-message-actions]:not([open]) { position: absolute; inset-inline-start: -2rem; inset-block-start: var(--rst-sp-2); } |
| +[equipo-message-actions]:not([open]) > summary { opacity: 0; } |
| +[equipo-message]:hover [equipo-message-actions] > summary, [equipo-message-actions]:focus-within > summary { opacity: 1; } |
| +[equipo-chat-task] [equipo-step][data-state="running"] > span:first-of-type { font-weight: 700; } |
| +[equipo-chat-task] [equipo-step][data-state="running"] > span:first-of-type::before { content: "● "; } |
| +[equipo-chat-task] [equipo-step][data-state="succeeded"] > span:first-of-type::after { content: " ✓"; } |
| +[equipo-chat-task] [equipo-step][data-state="waiting"] { background: var(--rst-tone-warning-bg); } |
| +[equipo-chat-task] [equipo-step][data-state="waiting"] > span:first-of-type::before { content: "… "; } |
| +@media (max-width: 799px) { |
| + [rst-shell-sidebar]:has([equipo-conversation]) > [rst-shell-back] { position: absolute; inset-block-start: 0; inset-inline-start: 0; z-index: 2; background: transparent; border: 0; min-block-size: 2.75rem; block-size: 2.75rem; } |
| + [equipo-chat-header] { min-block-size: 2.75rem; box-sizing: border-box; padding-inline-start: 6.5rem; } |
| + [equipo-chat-header] h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } |
| + [equipo-message-actions]:not([open]) > summary { opacity: 1; } |
| +} |
| +html:has([equipo-conversation]) { overflow: hidden; scrollbar-gutter: auto; } |
| +[equipo-question] textarea { padding: var(--rst-sp-1) var(--rst-sp-2); } |
| +@media (max-width: 799px) { |
| + [equipo-feed], #composer { font-size: var(--rst-fs-sm); } |
| } |
| +[equipo-chat-task] [equipo-step] > span:first-of-type { overflow: hidden; text-overflow: ellipsis; } |
| +[equipo-question] > h2 { margin-block-end: var(--rst-sp-2); } |
| +[equipo-feed-card] > [equipo-card] > form { position: relative; z-index: 1; } |
diff --git a/internal/equipo/task_page_handlers.go b/internal/equipo/task_page_handlers.go| index 4834c8a8..47b5cbd7 100644 |
| --- a/internal/equipo/task_page_handlers.go |
| +++ b/internal/equipo/task_page_handlers.go |
| @@ -6,7 +6,6 @@ import ( |
| "strconv" |
| "strings" |
| - "amadan.net/oficina/equipo/internal/equipo/library" |
| "amadan.net/rastrillo/rastrillo/live" |
| "github.com/go-chi/chi/v5" |
| ) |
| @@ -16,14 +15,6 @@ func (a *application) renderLive(w http.ResponseWriter, r *http.Request, name st |
| a.failure(w, r, ErrUnavailable) |
| } |
| } |
| -func (a *application) fillCounts(r *http.Request, data *pageData) error { |
| - if data.Counts != nil { |
| - return nil |
| - } |
| - counts, err := a.store.SpecialistCounts(r.Context(), Actor{Address: data.Address}) |
| - data.Counts = library.NavigationCounts(counts, data.Specialists, err) |
| - return nil |
| -} |
| func (a *application) taskList(w http.ResponseWriter, r *http.Request) { |
| key := strings.TrimPrefix(r.URL.Path, "/") |
| data, err := a.page(r, key) |
| @@ -36,9 +27,6 @@ func (a *application) taskList(w http.ResponseWriter, r *http.Request) { |
| return |
| } |
| data.Tasks, err = a.store.Journey(r.Context(), Actor{Address: data.Address}) |
| - if err == nil { |
| - err = a.fillCounts(r, &data) |
| - } |
| if err != nil { |
| a.failure(w, r, err) |
| return |
| @@ -59,9 +47,6 @@ func (a *application) taskDetail(w http.ResponseWriter, r *http.Request) { |
| if err == nil { |
| data.TaskView, err = a.store.TaskView(r.Context(), Actor{Address: data.Address}, chi.URLParam(r, "id")) |
| } |
| - if err == nil { |
| - err = a.fillCounts(r, &data) |
| - } |
| if err != nil { |
| a.failure(w, r, err) |
| return |
diff --git a/internal/equipo/task_views.go b/internal/equipo/task_views.go| index b7116f49..5b740c68 100644 |
| --- a/internal/equipo/task_views.go |
| +++ b/internal/equipo/task_views.go |
| @@ -209,6 +209,11 @@ func (s *Store) taskViewAt(tx *gorm.DB, actor Actor, task Task) (TaskViewData, e |
| v.StateKey = "trial.reconnect" |
| v.NeedsYou = true |
| } |
| + var firstPlan planning.Revision |
| + if err := tx.Where("task_id=?", task.ID).Order("revision").Limit(1).Find(&firstPlan).Error; err != nil { |
| + return v, storeError(err) |
| + } |
| + v.CreatedAt = firstPlan.CreatedAt |
| persisted, err := s.planningAt(tx).Plan(task) |
| if err != nil { |
| return v, storeError(err) |
diff --git a/internal/equipo/templates/chrome.html b/internal/equipo/templates/chrome.html| index e5175ea9..da3fef98 100644 |
| --- a/internal/equipo/templates/chrome.html |
| +++ b/internal/equipo/templates/chrome.html |
| @@ -1,4 +1,4 @@ |
| -{{define "rail-brand"}}{{end}} |
| +{{define "rail-brand"}}<span hidden></span>{{end}} |
| {{define "title"}}{{copy .Title}} · {{copy "brand"}}{{end}} |
| {{define "head"}}{{.Live.Head (T "rastrillo.ui.live.paused") (T "rastrillo.ui.live.unconfirmed")}}<link rel="stylesheet" href="{{asset "static/equipo.css"}}">{{if eq .Key "conversation"}}<script defer src="{{asset "static/chat.js"}}"></script>{{end}}{{end}} |
| {{define "up"}}/work{{if .Key}}#nav-{{.Key}}{{end}}{{end}} |
| @@ -7,12 +7,12 @@ |
| {{define "nav"}} |
| {{template "region:rail" .}}{{end}} |
| {{define "region:rail"}}<nav rst-shell-nav id="rail" {{.Live.Attrs .CollectionTopic}}> |
| +<div equipo-team-heading>{{template "brand" .}}<a id="nav-teams" href="/teams"{{if eq .Key "teams"}} aria-current="page"{{end}}>{{copy "nav.switch"}}</a></div> |
| {{$names := .SpecialistNames}}{{$counts := .Counts}}{{$key := .Key}}{{$group := ""}} |
| -{{range .Nav}} |
| +{{range .Nav}}{{if ne .Key "teams"}} |
| {{if ne .Group $group}}{{if .Group}}<p equipo-nav-group>{{copy (printf "nav.%s" .Group)}}</p>{{end}}{{$group = .Group}}{{end}} |
| -<a id="nav-{{.Key}}" href="{{.Href}}"{{if eq .Key $key}} aria-current="page"{{end}}>{{icon .Icon}}<span>{{if index $names .Key}}{{index $names .Key}}{{else}}{{copy .CopyKey}}{{end}}{{if eq .Group "specialists"}}{{with index $counts .Key}}{{if .CountsKnown}}<small equipo-count>{{.Working}} · {{.Queued}} {{copy "activity.queued"}} · {{.Waiting}} {{copy "task.state.waiting"}}</small>{{else}}<small equipo-count>{{copy "counts.unavailable"}}</small>{{end}}{{end}}{{end}}</span></a> |
| -{{if eq .Key "teams"}}<div equipo-team-heading>{{template "brand" $}}</div>{{end}} |
| -{{end}} |
| +<a id="nav-{{.Key}}" href="{{.Href}}"{{if eq .Key $key}} aria-current="page"{{end}}>{{icon .Icon}}<span>{{if index $names .Key}}{{index $names .Key}}{{else}}{{copy .CopyKey}}{{end}}</span>{{if eq .Group "specialists"}}{{with index $counts .Key}}<small equipo-count{{if .Waiting}} equipo-attention{{end}}>{{if .CountsKnown}}{{if .Waiting}}{{.Waiting}} {{copy "nav.waiting"}}{{else if .Working}}{{.Working}}{{if .Queued}} · {{.Queued}} {{copy "nav.queued"}}{{end}}{{else if .Queued}}{{.Queued}} {{copy "nav.queued"}}{{else}}{{copy "nav.idle"}}{{end}}{{else}}{{copy "counts.unavailable"}}{{end}}</small>{{end}}{{end}}{{if eq .Key "projects"}}<small equipo-count>{{if $.NavProjects}}{{$.NavProjects}}{{else}}{{copy "counts.unavailable"}}{{end}}</small>{{end}}{{if eq .Key "needs-you"}}<small equipo-count equipo-attention>{{if $.NavNeeds}}{{$.NavNeeds}}{{else}}{{copy "counts.unavailable"}}{{end}}</small>{{end}}</a> |
| +{{end}}{{end}} |
| </nav>{{end}} |
| {{define "region:notice"}}<div id="notice" role="status"></div>{{end}} |
| {{define "profile"}}{{if .Address}}<span rst-person-av aria-hidden="true">{{icon "users"}}</span><span rst-person-name>{{.Address}}</span>{{else}}<span rst-person-av="empty placeholder" aria-hidden="true"></span><span rst-person-name>{{copy "nav.account"}}</span>{{end}}{{end}} |
diff --git a/internal/equipo/templates/conversation.html b/internal/equipo/templates/conversation.html| index 0b4f79f1..54b0b98a 100644 |
| --- a/internal/equipo/templates/conversation.html |
| +++ b/internal/equipo/templates/conversation.html |
| @@ -1,9 +1,8 @@ |
| +{{define "up-label"}}{{copy "nav.work"}}{{end}} |
| {{define "title"}}{{copy "conversation.title"}}{{end}} |
| {{define "content"}} |
| <div equipo-conversation> |
| -<header equipo-chat-header><h1>{{copy "conversation.title"}}</h1><p equipo-muted>{{copy "conversation.private"}}</p> |
| -<a href="/settings/coordinator">{{copy "coordinator.settings"}}</a> |
| -</header> |
| +<header equipo-chat-header><h1>{{copy "conversation.title"}}</h1><a href="/settings/coordinator" aria-label="{{copy "coordinator.settings"}}">{{icon "info"}}</a></header> |
| <div equipo-scroll tabindex="0" role="region" aria-label="{{copy "conversation.title"}}">{{template "region:conversation-feed" .}}</div> |
| <div equipo-announcements role="status" aria-live="polite" aria-atomic="false"></div> |
| {{template "region:chat-composer" .}} |
diff --git a/internal/equipo/templates/conversation_card.html b/internal/equipo/templates/conversation_card.html| index da92c120..8e8a2eaf 100644 |
| --- a/internal/equipo/templates/conversation_card.html |
| +++ b/internal/equipo/templates/conversation_card.html |
| @@ -2,8 +2,8 @@ |
| <div id="chat-composer" {{.Live.Attrs .Conversation.Topic}}> |
| <form id="composer" data-live-form="conversation-feed" equipo-form method="post" action="{{if .Conversation.ThreadID}}/tasks/{{.Conversation.ThreadID}}/thread{{else}}/conversation{{end}}"> |
| <input type="hidden" name="request_id" value="{{.Conversation.RequestID}}"><input type="hidden" name="revision" value="0"> |
| -<label>{{if .Conversation.ThreadID}}{{copy "conversation.thread_reply"}}{{else}}{{copy "conversation.composer"}}{{end}}<textarea id="chat-body" rst-input name="body" required maxlength="16384" rows="2"></textarea></label> |
| -<button rst-btn="primary" type="submit">{{copy "conversation.send"}}</button> |
| +<textarea id="chat-body" rst-input name="body" required maxlength="16384" rows="1" aria-label="{{if .Conversation.ThreadID}}{{copy "conversation.thread_reply"}}{{else}}{{copy "conversation.composer"}}{{end}}" placeholder="{{copy "conversation.placeholder"}}"></textarea> |
| +<div equipo-composer-tools>{{if and .Conversation.Projects (not .Conversation.ThreadID)}}<select rst-input name="project_id" aria-label="{{copy "plan.project"}}"><option value="">{{copy "conversation.any_project"}}</option>{{range .Conversation.Projects}}<option value="{{.ID}}">{{.Name}}</option>{{end}}</select>{{end}}<button rst-btn="primary" type="submit">{{copy "conversation.send_short"}}</button></div> |
| </form> |
| </div> |
| {{end}} |
| @@ -11,14 +11,15 @@ |
| <section id="conversation-feed" {{.Live.Attrs .Conversation.Topic .CollectionTopic}}> |
| {{if .Conversation.NextURL}}<a href="{{.Conversation.NextURL}}">{{copy "conversation.more"}}</a>{{end}} |
| <ol equipo-feed> |
| -{{range .Conversation.Feed}} |
| +{{$day := ""}}{{range .Conversation.Feed}} |
| +{{if .Message}}{{$date := .Message.CreatedAt.Format "2006-01-02"}}{{if ne $date $day}}<li equipo-day><time datetime="{{$date}}">{{if eq $date $.Conversation.Today}}{{copy "conversation.today"}}{{else}}{{.Message.CreatedAt.Format "2 January 2006"}}{{end}}</time></li>{{$day = $date}}{{end}}{{end}} |
| {{if .Message}}{{with .Message}} |
| <li equipo-message="{{if .Own}}own{{else}}incoming{{end}}" data-message="{{.ID}}" data-sequence="{{.Sequence}}"> |
| -<div equipo-message-meta><strong>{{icon .AuthorIcon}}{{.AuthorName}}</strong><time datetime="{{.CreatedAt.Format "2006-01-02T15:04:05Z07:00"}}" title="{{.CreatedAt.Format "2006-01-02 15:04 MST"}}">{{.CreatedAt.Format "15:04"}}</time></div> |
| +<div equipo-message-meta><strong{{if .Own}} equipo-visually-hidden{{end}}>{{icon .AuthorIcon}}{{.AuthorName}}</strong><time datetime="{{.CreatedAt.Format "2006-01-02T15:04:05Z07:00"}}" title="{{.CreatedAt.Format "2006-01-02 15:04 MST"}}">{{.CreatedAt.Format "15:04"}}</time></div> |
| <div equipo-bubble><p equipo-message-body>{{.Body}}</p> |
| {{if .ThreadURL}}<a href="{{.ThreadURL}}">{{copy "conversation.thread_link"}}</a>{{end}} |
| {{if and (not $.Conversation.ThreadID) (eq .AuthorKind "person")}} |
| -{{if $.Conversation.Cards}}<details><summary>{{copy "conversation.route_confirmation"}}</summary><form method="post" action="/conversation/messages/{{.ID}}/route" equipo-form><input type="hidden" name="request_id" value="{{.RouteID}}"><input type="hidden" name="revision" value="{{.Revision}}"><label>{{copy "conversation.thread_link"}}<select rst-input name="task_id" required>{{range $.Conversation.Cards}}{{with .Plan}}<option value="{{.Task.ID}}">{{.Task.Description}}</option>{{end}}{{end}}</select></label><button rst-btn type="submit">{{copy "conversation.route_confirmation"}}</button></form></details>{{end}} |
| +{{if $.Conversation.Cards}}<details equipo-message-actions><summary aria-label="{{copy "conversation.message_actions"}}" title="{{copy "conversation.message_actions"}}">{{icon "kebab"}}</summary><form method="post" action="/conversation/messages/{{.ID}}/route" equipo-form><input type="hidden" name="request_id" value="{{.RouteID}}"><input type="hidden" name="revision" value="{{.Revision}}"><label>{{copy "conversation.thread_link"}}<select rst-input name="task_id" required>{{range $.Conversation.Cards}}{{with .Plan}}<option value="{{.Task.ID}}">{{.Task.Description}}</option>{{end}}{{end}}</select></label><button rst-btn type="submit">{{copy "conversation.route_confirmation"}}</button></form></details>{{end}} |
| {{end}} |
| </div></li> |
| {{end}}{{else}}{{with .Card}}<li equipo-feed-card data-entry="{{.ID}}" data-sequence="{{.Sequence}}">{{template "conversation-card" .}}</li>{{end}}{{end}} |
| @@ -27,25 +28,24 @@ |
| </section> |
| {{end}} |
| {{define "conversation-card"}} |
| -<article equipo-card data-card="{{.ID}}"> |
| +<article equipo-card data-card="{{.ID}}"{{if or .NativeQuestion .Question}} equipo-question{{end}}> |
| {{if eq .Kind "task"}}{{with .Work}}{{template "chat-task" .}}{{end}} |
| -{{with .Plan}}<a href="/tasks/{{.Task.ID}}/plan#project">{{copy "plan.correct_project"}}</a><p><span equipo-badge>{{copy "plan.revision"}} {{.Plan.Revision}}</span> <span equipo-badge>{{if eq .Task.ApprovalRevision .Plan.Revision}}{{copy "plan.approved"}}{{else}}{{copy "plan.proposed"}}{{end}}</span></p> |
| -{{if and .CanEdit (ne .Task.ApprovalRevision .Plan.Revision)}}<form method="post" action="/tasks/{{.Task.ID}}/plan/approve"><input type="hidden" name="request_id" value="{{.ApproveID}}"><input type="hidden" name="revision" value="{{.Plan.Revision}}"><button rst-btn type="submit">{{copy "plan.approve"}}</button></form>{{end}} |
| -{{end}}{{end}} |
| +{{with .Plan}}{{if and .CanEdit (ne .Task.ApprovalRevision .Plan.Revision)}}<form method="post" action="/tasks/{{.Task.ID}}/plan/approve"><input type="hidden" name="request_id" value="{{.ApproveID}}"><input type="hidden" name="revision" value="{{.Plan.Revision}}"><button rst-btn type="submit">{{copy "plan.approve"}}</button></form>{{end}}{{end}}{{end}} |
| {{with .NativeQuestion}} |
| -<h2>{{copy "task.questions"}}</h2>{{if not .Fields}}<pre>{{.Text}}</pre>{{end}} |
| -<span equipo-badge>{{copy (printf "question.%s" .State)}}</span> |
| +{{if not .Fields}}<pre>{{.Text}}</pre>{{else if eq (len .Fields) 1}}<h2>{{(index .Fields 0).Prompt}}</h2>{{end}} |
| +{{if ne .State "pending"}}<small equipo-secondary>{{copy (printf "question.%s" .State)}}</small>{{end}} |
| +{{if and .CanAnswer (eq (len .Fields) 1)}}{{$q := .}}{{range (index .Fields 0).Options}}<form equipo-choice method="post" action="/tasks/{{$.Work.Task.ID}}/questions/{{$q.ID}}/answer"><input type="hidden" name="revision" value="{{$q.Revision}}"><input type="hidden" name="behavior" value="allow"><button rst-btn type="submit" name="answer_0" value="{{.}}">{{.}}</button></form>{{end}}{{end}} |
| {{if .CanAnswer}}<form method="post" action="/tasks/{{$.Work.Task.ID}}/questions/{{.ID}}/answer" equipo-form> |
| <input type="hidden" name="revision" value="{{.Revision}}"> |
| -{{range $i,$field:=.Fields}}<label>{{$field.Prompt}}<textarea rst-input name="answer_{{$i}}" rows="2" maxlength="8192"></textarea></label>{{end}} |
| -<div equipo-actions>{{if .Fields}}<button rst-btn="primary" type="submit" name="behavior" value="allow">{{copy "question.send_answer"}}</button>{{else if .CanAllow}}<button rst-btn="primary" type="submit" name="behavior" value="allow">{{copy "question.allow_once"}}</button>{{end}}<button rst-btn type="submit" name="behavior" value="deny">{{copy "question.deny"}}</button></div></form>{{end}} |
| +{{range $i,$field:=.Fields}}<label>{{if ne (len $.NativeQuestion.Fields) 1}}{{$field.Prompt}}{{end}}<textarea rst-input aria-label="{{$field.Prompt}}" name="answer_{{$i}}" rows="1" placeholder="{{copy "question.reply"}}" maxlength="8192"></textarea></label>{{end}} |
| +<div equipo-actions>{{if .Fields}}<button rst-btn="primary" type="submit" name="behavior" value="allow">{{copy "conversation.send_short"}}</button>{{else if .CanAllow}}<button rst-btn="primary" type="submit" name="behavior" value="allow">{{copy "question.allow_once"}}</button>{{end}}<button rst-btn type="submit" name="behavior" value="deny">{{copy "question.deny"}}</button></div></form>{{end}} |
| {{end}} |
| {{with .Question}} |
| -<h2>{{.Prompt}}</h2><span equipo-badge>{{copy (printf "question.%s" .State)}}</span> |
| +<h2>{{.Prompt}}</h2>{{if ne .State "pending"}}<small equipo-secondary>{{copy (printf "question.%s" .State)}}</small>{{end}} |
| {{if $.CanAnswer}}<form method="post" action="/conversation/questions/{{.ID}}/answer" equipo-actions><input type="hidden" name="request_id" value="{{$.RequestID}}"><input type="hidden" name="revision" value="{{.Revision}}">{{range .Options}}<button rst-btn name="option_id" value="{{.ID}}" type="submit">{{.Label}}</button>{{end}}</form> |
| -<form method="post" action="/conversation/questions/{{.ID}}/answer" equipo-form><input type="hidden" name="request_id" value="{{$.RequestID}}"><input type="hidden" name="revision" value="{{.Revision}}"><label>{{copy "question.reply"}}<textarea rst-input name="text" required maxlength="8192"></textarea></label><button rst-btn type="submit">{{copy "question.send_answer"}}</button></form>{{end}} |
| +<form method="post" action="/conversation/questions/{{.ID}}/answer" equipo-form><input type="hidden" name="request_id" value="{{$.RequestID}}"><input type="hidden" name="revision" value="{{.Revision}}"><textarea rst-input name="text" rows="1" aria-label="{{copy "question.reply"}}" placeholder="{{copy "question.reply"}}" required maxlength="8192"></textarea><button rst-btn type="submit">{{copy "conversation.send_short"}}</button></form>{{end}} |
| {{end}} |
| -{{if eq .Kind "question"}}<a href="/tasks/{{.TaskID}}/questions/{{.ResourceID}}">{{copy "task.answer"}}</a>{{end}} |
| + |
| {{if eq .Kind "coordinator"}} |
| {{if .WaitingTaskURL}}<p>{{copy "coordinator.waiting_label"}} <a href="{{.WaitingTaskURL}}">{{.WaitingLabel}}</a></p>{{else}}<p>{{copy .CopyKey}}</p>{{end}} |
| {{if .ActionKeys}}<div equipo-actions><form method="post" action="/settings/coordinator"><input type="hidden" name="action" value="retry"><input type="hidden" name="request_id" value="{{.RequestID}}"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="turn_id" value="{{.ResourceID}}"><button rst-btn type="submit">{{copy "coordinator.retry"}}</button></form><form method="post" action="/settings/coordinator"><input type="hidden" name="action" value="reset"><input type="hidden" name="request_id" value="{{.ResetID}}"><input type="hidden" name="revision" value="{{.BindingRevision}}"><button rst-btn type="submit">{{copy "coordinator.reset"}}</button></form></div>{{end}} |
| @@ -57,12 +57,12 @@ |
| {{define "chat-task"}} |
| <div equipo-chat-task> |
| -<h2><a href="/tasks/{{.Task.ID}}/thread">{{.Task.Description}}</a></h2> |
| -<p equipo-secondary>{{.Project.Name}} · {{copy .StateKey}}</p> |
| -<ol equipo-steps>{{range .Steps}}<li equipo-step data-step="{{.Key}}" data-state="{{.State}}"><strong>{{icon .CategoryIcon}}{{if .CategoryName}}{{.CategoryName}}{{else}}{{copy (printf "nav.%s" .Category)}}{{end}}</strong><span>{{copy (printf "plan.action.%s" .Action)}}</span><span equipo-badge>{{copy (printf "step.%s" .State)}}</span><span equipo-value>{{.Model}} {{.Account}}{{.Person}}</span></li>{{end}}</ol> |
| -<div equipo-actions><a href="/tasks/{{.Task.ID}}/thread">{{copy "conversation.thread_link"}}</a><a href="/tasks/{{.Task.ID}}/plan">{{copy "plan.edit"}}</a></div> |
| +<h2><a equipo-task-link href="/tasks/{{.Task.ID}}/thread">{{.Task.Description}}</a></h2> |
| +<p equipo-secondary>{{.Project.Name}} · {{copy (printf "task.kind.%s" .Task.Kind)}} {{if .ChatAge}}· <time datetime="{{.CreatedAt.Format "2006-01-02T15:04:05Z07:00"}}" title="{{.CreatedAt.Format "2 January 2006 15:04 MST"}}">{{.ChatAge}}</time>{{end}}<span equipo-visually-hidden>{{copy .StateKey}}</span></p> |
| +<ol equipo-steps>{{range .Steps}}<li equipo-step data-step="{{.Key}}" data-state="{{.State}}"><strong>{{icon .CategoryIcon}}{{if .CategoryName}}{{.CategoryName}}{{else}}{{copy (printf "nav.%s" .Category)}}{{end}}</strong><span title="{{copy (printf "plan.action.%s" .Action)}}">{{copy (printf "plan.action.%s" .Action)}}</span><span equipo-step-state equipo-visually-hidden>{{copy (printf "step.%s" .State)}}</span><span equipo-value title="{{.Model}} {{.Account}}{{.Person}}">{{.Model}}{{if and .Model .Account}} · {{end}}{{.Account}}{{.Person}}</span></li>{{end}}</ol> |
| +<div equipo-actions><a rst-btn href="/tasks/{{.Task.ID}}/plan">{{copy "plan.edit"}}</a><details equipo-models><summary rst-btn>{{copy "conversation.why_models"}}</summary><ul>{{range .Steps}}{{if .Reason}}<li><strong>{{copy (printf "plan.action.%s" .Action)}}</strong>: {{.Reason}}</li>{{end}}{{end}}</ul><a href="/tasks/{{.Task.ID}}/plan">{{copy "plan.edit"}}</a> <a href="/tasks/{{.Task.ID}}/plan#project">{{copy "plan.correct_project"}}</a></details></div> |
| {{range .Evidence}}{{if eq .Role "candidate"}}<p equipo-value>{{copy "task.evidence"}}: {{.Hash}}</p>{{end}}{{end}} |
| -<a href="/tasks/{{.Task.ID}}">{{copy "task.evidence"}}</a> |
| +{{if .Evidence}}<details equipo-task-details><summary>{{copy "task.evidence"}}</summary><a href="/tasks/{{.Task.ID}}">{{copy "task.evidence"}}</a><a href="/tasks/{{.Task.ID}}/plan#project">{{copy "plan.correct_project"}}</a></details>{{end}} |
| {{if .CanMerge}}<a rst-btn href="/tasks/{{.Task.ID}}/merge">{{copy "task.merge"}}</a>{{end}} |
| {{if eq .Task.Kind "rendered_change"}}<a rst-btn href="/tasks/{{.Task.ID}}/rendered-change">{{copy "evidence.render_approval"}}</a>{{end}} |
| {{template "trial-label" .Isolation}} |
diff --git a/internal/equipo/templates/thread.html b/internal/equipo/templates/thread.html| index 5e816434..26493edd 100644 |
| --- a/internal/equipo/templates/thread.html |
| +++ b/internal/equipo/templates/thread.html |
| @@ -3,9 +3,7 @@ |
| {{define "up"}}/tasks/{{.Conversation.ThreadID}}{{end}} |
| {{define "content"}} |
| <div equipo-conversation> |
| -<header equipo-chat-header><h1>{{.Conversation.ThreadTitle}}</h1><p equipo-muted>{{copy "conversation.shared_thread"}}</p> |
| -<a href="/tasks/{{.Conversation.ThreadID}}/plan">{{copy "plan.edit"}}</a> |
| -</header> |
| +<header equipo-chat-header><h1>{{.Conversation.ThreadTitle}}</h1><a href="/tasks/{{.Conversation.ThreadID}}/plan" aria-label="{{copy "plan.edit"}}">{{icon "info"}}</a></header> |
| <div equipo-scroll tabindex="0" role="region" aria-label="{{copy "conversation.title"}}">{{template "region:conversation-feed" .}}</div> |
| <div equipo-announcements role="status" aria-live="polite" aria-atomic="false"></div> |
| {{template "region:chat-composer" .}} |
diff --git a/internal/equipotest/browser_test.go b/internal/equipotest/browser_test.go| index b314a934..5a532d84 100644 |
| --- a/internal/equipotest/browser_test.go |
| +++ b/internal/equipotest/browser_test.go |
| @@ -3,6 +3,7 @@ |
| package equipotest |
| import ( |
| + "amadan.net/oficina/equipo/internal/browsertest" |
| "context" |
| "fmt" |
| "io" |
| @@ -12,7 +13,6 @@ import ( |
| "path/filepath" |
| "strings" |
| "testing" |
| - "time" |
| "amadan.net/oficina/equipo/internal/equipo" |
| "amadan.net/rastrillo/rastrillo/db" |
| @@ -69,7 +69,7 @@ func TestFoundationBrowserWalk(t *testing.T) { |
| t.Helper() |
| t.Log(note) |
| rig.Screen("body", note) |
| - rig.Run(browserWait(`!document.documentElement.matches(":active-view-transition") && document.getAnimations().every(a => a.playState !== "running")`)) |
| + rig.Run(browsertest.Wait(`!document.documentElement.matches(":active-view-transition") && document.getAnimations().every(a => a.playState !== "running")`)) |
| check(`document.documentElement.scrollWidth <= document.documentElement.clientWidth && document.body.scrollWidth <= document.documentElement.clientWidth`, "horizontal overflow: "+note) |
| } |
| goTo := func(path string) { |
| @@ -79,10 +79,10 @@ func TestFoundationBrowserWalk(t *testing.T) { |
| } |
| clickTo := func(selector, path string) { |
| t.Helper() |
| - rig.Run(browserClick(selector), browserWait(fmt.Sprintf(`location.pathname + location.hash === %q`, path))) |
| + rig.Run(browsertest.Click(selector), browsertest.Wait(fmt.Sprintf(`location.pathname + location.hash === %q`, path))) |
| screen(path) |
| } |
| - shot := func(name string) { browserScreenshot(t, rig, name) } |
| + shot := func(name string) { browsertest.Screenshot(t, rig, name) } |
| for _, width := range []int64{1280, 390} { |
| rig.Run(chromedp.EmulateViewport(width, 900)) |
| goTo("/conversation") |
| @@ -97,14 +97,14 @@ func TestFoundationBrowserWalk(t *testing.T) { |
| check(fmt.Sprintf(`document.querySelector('[aria-current="page"]').getAttribute('href') === %q`, path), "wrong active destination") |
| if strings.HasPrefix(path, "/specialists/") && width == 390 { |
| key := strings.TrimPrefix(path, "/specialists/") |
| - rig.Run(chromedp.Click(chromedp.CSS(`[rel="up"]`)), browserWait(`location.pathname === '/work'`)) |
| + rig.Run(chromedp.Click(chromedp.CSS(`[rel="up"]`)), browsertest.Wait(`location.pathname === '/work'`)) |
| selected := "document.activeElement" |
| if noJS { |
| selected = "document.querySelector(':target')" |
| } |
| - rig.Run(browserWait(fmt.Sprintf(`%s?.id === %q`, selected, "nav-"+key))) |
| + rig.Run(browsertest.Wait(fmt.Sprintf(`%s?.id === %q`, selected, "nav-"+key))) |
| check(fmt.Sprintf(`%s?.id === %q && %s.getBoundingClientRect().bottom <= innerHeight && %s.getBoundingClientRect().top >= 0`, selected, "nav-"+key, selected, selected), "back link missed visible index row") |
| - rig.Run(browserWait(`!document.documentElement.matches(":active-view-transition") && document.getAnimations().every(a => a.playState !== "running")`)) |
| + rig.Run(browsertest.Wait(`!document.documentElement.matches(":active-view-transition") && document.getAnimations().every(a => a.playState !== "running")`)) |
| check(`document.documentElement.scrollWidth <= innerWidth`, "parent index overflow") |
| shot("parent-" + key) |
| // The pinned chromedp can retain stale DOM node IDs after a |
| @@ -132,7 +132,7 @@ func TestFoundationBrowserWalk(t *testing.T) { |
| goTo("/settings") |
| label := fmt.Sprintf("Browser account %d", width) |
| - rig.Run(chromedp.SendKeys(chromedp.CSS(`form[action="/accounts"]:has(input[name="id"][value="0"]) input[name="label"]`), label), browserClick(`form[action="/accounts"]:has(input[name="id"][value="0"]) button`), browserWait(fmt.Sprintf(`Array.from(document.querySelectorAll('h2')).some(e => e.textContent === %q)`, label))) |
| + rig.Run(chromedp.SendKeys(chromedp.CSS(`form[action="/accounts"]:has(input[name="id"][value="0"]) input[name="label"]`), label), browsertest.Click(`form[action="/accounts"]:has(input[name="id"][value="0"]) button`), browsertest.Wait(fmt.Sprintf(`Array.from(document.querySelectorAll('h2')).some(e => e.textContent === %q)`, label))) |
| screen("account saved") |
| for _, kind := range []string{"app", "website", "repository"} { |
| goTo("/projects/new") |
| @@ -149,7 +149,7 @@ func TestFoundationBrowserWalk(t *testing.T) { |
| if kind != "repository" { |
| rig.Run(chromedp.SendKeys(chromedp.CSS(`[name="app_name"]`), fmt.Sprintf("%s-%d", kind, width))) |
| } |
| - rig.Run(browserClick(`[equipo-form] button[type="submit"]`), browserWait(` /^\/projects\/\d+$/.test(location.pathname)`)) |
| + rig.Run(browsertest.Click(`[equipo-form] button[type="submit"]`), browsertest.Wait(` /^\/projects\/\d+$/.test(location.pathname)`)) |
| screen("created " + kind) |
| check(fmt.Sprintf(`document.querySelector('main h1').textContent === %q && !!document.querySelector('[data-project-kind="%s"]')`, name, kind), "project metadata missing") |
| path := harness.Read(rig, chromedp.Location()) |
| @@ -158,7 +158,7 @@ func TestFoundationBrowserWalk(t *testing.T) { |
| check(fmt.Sprintf(`document.querySelector('h3 a[href=%q]').getClientRects().length > 1`, path), "long project name does not wrap") |
| clickTo(fmt.Sprintf(`h3 a[href=%q]`, path), path) |
| clickTo(fmt.Sprintf(`a[href=%q]`, path+"/edit"), path+"/edit") |
| - rig.Run(chromedp.SetValue(chromedp.CSS(`[name="name"]`), name+" edited"), chromedp.SetValue(chromedp.CSS(`[name="default_branch"]`), "release/browser"), browserClick(`[equipo-form] button[type="submit"]`), browserWait(fmt.Sprintf(`location.pathname === %q`, path))) |
| + rig.Run(chromedp.SetValue(chromedp.CSS(`[name="name"]`), name+" edited"), chromedp.SetValue(chromedp.CSS(`[name="default_branch"]`), "release/browser"), browsertest.Click(`[equipo-form] button[type="submit"]`), browsertest.Wait(fmt.Sprintf(`location.pathname === %q`, path))) |
| screen("edited " + kind) |
| goTo(path) |
| check(fmt.Sprintf(`document.querySelector('main h1').textContent === %q && document.querySelector('[equipo-metadata]').textContent.includes('release/browser')`, name+" edited"), "edit did not persist") |
| @@ -177,51 +177,6 @@ func TestFoundationBrowserWalk(t *testing.T) { |
| check(`location.pathname === '/signin' && !document.querySelector('[data-project-count]')`, "signout retained project access") |
| } |
| -func browserWait(expression string) chromedp.Action[chromedp.Void] { |
| - return chromedp.Func(func(ctx context.Context, target *chromedp.Target) error { |
| - ctx, cancel := context.WithTimeout(ctx, 5*time.Second) |
| - defer cancel() |
| - tick := time.NewTicker(20 * time.Millisecond) |
| - defer tick.Stop() |
| - for { |
| - ok, err := chromedp.Evaluate[bool]("document.readyState === 'complete' && ("+expression+")")(ctx, target) |
| - if err == nil && ok { |
| - return nil |
| - } |
| - select { |
| - case <-ctx.Done(): |
| - return fmt.Errorf("waiting for %s: %w (last evaluation: %v)", expression, ctx.Err(), err) |
| - case <-tick.C: |
| - } |
| - } |
| - }) |
| -} |
| - |
| -func browserClick(selector string) chromedp.Action[chromedp.Void] { |
| - return chromedp.Func(func(ctx context.Context, target *chromedp.Target) error { |
| - ctx, cancel := context.WithTimeout(ctx, 8*time.Second) |
| - defer cancel() |
| - _, err := chromedp.RunResponse(ctx, chromedp.Click(chromedp.CSS(selector))) |
| - return err |
| - }) |
| -} |
| - |
| -func browserScreenshot(t *testing.T, rig *harness.Rig, name string) { |
| - t.Helper() |
| - dir := os.Getenv("EQUIPO_BROWSER_ARTIFACTS") |
| - if dir == "" { |
| - return |
| - } |
| - if strings.HasPrefix(name, "mockup-") && strings.HasSuffix(name, "-390") { |
| - harness.Evaluate[bool](rig, `(()=>{const e=location.pathname.includes('native')?document.querySelectorAll('.ph')[2]:document.querySelector('.phone');e?.scrollIntoView({block:'start'});return true})()`) |
| - } |
| - if os.Getenv("EQUIPO_CHAT_HISTORY") == "1" { |
| - harness.Evaluate[bool](rig, `(()=>{const e=document.querySelector('[equipo-scroll]');if(e)e.scrollTop=0;return true})()`) |
| - } |
| - executionMust(t, os.MkdirAll(dir, 0700)) |
| - executionMust(t, os.WriteFile(filepath.Join(dir, name+".png"), harness.Read(rig, chromedp.CaptureScreenshot()), 0600)) |
| -} |
| - |
| func browserSignin(t *testing.T, rig *harness.Rig, mailer *capturingMailer) { |
| t.Helper() |
| c := signinClient(t, rig.Origin) |
diff --git a/internal/equipotest/chat_browser_test.go b/internal/equipotest/chat_browser_test.go| index 15509d7d..4e0bd8d5 100644 |
| --- a/internal/equipotest/chat_browser_test.go |
| +++ b/internal/equipotest/chat_browser_test.go |
| @@ -3,23 +3,24 @@ |
| package equipotest |
| import ( |
| - "context" |
| - "fmt" |
| - "net/http" |
| - "os" |
| - "testing" |
| - |
| + "amadan.net/oficina/equipo/internal/browsertest" |
| "amadan.net/oficina/equipo/internal/equipo" |
| "amadan.net/rastrillo/rastrillo/harness" |
| + "context" |
| + "fmt" |
| "github.com/chromedp/cdproto/cdp" |
| "github.com/chromedp/cdproto/emulation" |
| "github.com/chromedp/chromedp" |
| "github.com/chromedp/chromedp/kb" |
| + "net/http" |
| + "os" |
| + "testing" |
| ) |
| func TestChatBrowser(t *testing.T) { |
| f, _ := questionFixture(t) |
| task := f.a.TaskID |
| + mustSQL(t, f.d, "UPDATE questions SET raw_request=?", `{"provider":"claude","name":"AskUserQuestion","input":{"questions":[{"question":"Which invoice total should appear?","options":[{"label":"Net"},{"label":"Subtotal"}]}]}}`) |
| mustSQL(t, f.d, "UPDATE tasks SET description=? WHERE id=?", "Fix the invoice total", task) |
| mustSQL(t, f.d, "UPDATE projects SET name=?", "Comercio") |
| for _, thread := range []string{"", task} { |
| @@ -61,36 +62,36 @@ func TestChatBrowser(t *testing.T) { |
| return err |
| })) |
| browserSignin(t, rig, mailer) |
| - |
| check := func(expression, reason string) { |
| t.Helper() |
| if !harness.Evaluate[bool](rig, expression) { |
| t.Fatal(reason) |
| } |
| } |
| - shot := func(name string) { browserScreenshot(t, rig, name) } |
| + shot := func(name string) { browsertest.Screenshot(t, rig, name) } |
| baseline := os.Getenv("EQUIPO_CHAT_BASELINE") == "1" |
| for _, width := range []int64{1280, 390} { |
| rig.Run(chromedp.EmulateViewport(width, 900)) |
| for _, screen := range []struct{ name, path string }{{"conversation", "/conversation"}, {"thread", "/tasks/" + task + "/thread"}, {"nav", "/work"}} { |
| - rig.Run(chromedp.Navigate(rig.Origin+screen.path), browserWait(`!document.documentElement.matches(":active-view-transition")`)) |
| + rig.Run(chromedp.Navigate(rig.Origin+screen.path), browsertest.Wait(`!document.documentElement.matches(":active-view-transition")`)) |
| shot(fmt.Sprintf("%s-%d", screen.name, width)) |
| if baseline { |
| continue |
| } |
| check(`document.documentElement.scrollWidth<=innerWidth`, "horizontal overflow") |
| + checkChatStyle(t, rig, screen.name == "nav") |
| if screen.name == "nav" { |
| continue |
| } |
| if screen.name == "conversation" { |
| - check(`document.querySelector("[equipo-feed]").children[2].hasAttribute("equipo-feed-card")`, "task card detached from its message") |
| + check(`document.querySelector("[data-card=chat-task]").parentElement.previousElementSibling.dataset.sequence === "2"`, "task card detached from its message") |
| } |
| rig.Screen("body", fmt.Sprintf("chat %s %d", screen.name, width)) |
| check(`!!document.querySelector('ol[equipo-feed]') && !!document.querySelector('[aria-live="polite"]')`, "missing accessible chat feed") |
| check(`document.querySelectorAll('[equipo-message] time[datetime]').length>=6`, "missing message times") |
| check(`document.querySelector('#composer').getBoundingClientRect().bottom<=innerHeight && document.querySelector('#composer textarea').getBoundingClientRect().top>0`, "composer outside viewport") |
| if noJS { |
| - rig.Run(chromedp.SendKeys(chromedp.CSS(`#composer textarea`), "Scriptless reply"), browserClick(`#composer button`)) |
| + rig.Run(chromedp.SendKeys(chromedp.CSS(`#composer textarea`), "Scriptless reply"), browsertest.Click(`#composer button`)) |
| check(`document.querySelector('#conversation-feed').textContent.includes('Scriptless reply')`, "scriptless reply missing") |
| continue |
| } |
| @@ -104,21 +105,21 @@ func TestChatBrowser(t *testing.T) { |
| rig.Run(chromedp.SendKeys(chromedp.CSS(`#composer textarea`), "Keep this draft")) |
| _, err := f.s.SendMessage(connectionContext, ownerActor, thread, liveText, equipo.Mutation{RequestID: liveText}) |
| executionMust(t, err) |
| - rig.Run(browserWait(fmt.Sprintf(`document.querySelector('#conversation-feed').textContent.includes(%q)`, liveText))) |
| + rig.Run(browsertest.Wait(fmt.Sprintf(`document.querySelector('#conversation-feed').textContent.includes(%q)`, liveText))) |
| check(`window.chatDocument && document.querySelector('#chat-body').value==='Keep this draft' && document.activeElement.id==='chat-body'`, "live update lost document, draft or focus") |
| check(`(()=>{const s=document.querySelector('[equipo-scroll]');return s.scrollHeight-s.clientHeight-s.scrollTop<3})()`, "live update did not follow bottom") |
| harness.Evaluate[bool](rig, `(()=>{const s=document.querySelector('[equipo-scroll]');s.scrollTop=0;return true})()`) |
| - rig.Run(browserWait(`document.querySelector('[equipo-scroll]').scrollTop===0`)) |
| + rig.Run(browsertest.Wait(`document.querySelector('[equipo-scroll]').scrollTop===0`)) |
| _, err = f.s.SendMessage(connectionContext, ownerActor, thread, liveText+" while reading", equipo.Mutation{RequestID: liveText + "-reading"}) |
| executionMust(t, err) |
| - rig.Run(browserWait(fmt.Sprintf(`document.querySelector('#conversation-feed').textContent.includes(%q)`, liveText+" while reading"))) |
| + rig.Run(browsertest.Wait(fmt.Sprintf(`document.querySelector('#conversation-feed').textContent.includes(%q)`, liveText+" while reading"))) |
| check(`document.querySelector('[equipo-scroll]').scrollTop<3`, "live update pulled reader to bottom") |
| check(`document.querySelector('[equipo-announcements]').textContent.includes('while reading')`, "new message not announced") |
| harness.Evaluate[bool](rig, `(()=>{const t=document.querySelector("#chat-body");t.value="Browser reply";t.focus();return true})()`) |
| rig.Run(chromedp.KeyEvent(kb.Enter, chromedp.KeyModifiers(chromedp.ModifierShift))) |
| check(`document.querySelector('#composer textarea').value.endsWith('\n')`, "Shift+Enter did not add a newline") |
| - rig.Run(chromedp.KeyEvent(kb.Enter), browserWait(`document.querySelector('#composer button').disabled && document.querySelector('#chat-body').readOnly`)) |
| - rig.Run(browserWait(`document.querySelector('#composer textarea').value==='' && document.querySelector('#conversation-feed').textContent.includes('Browser reply')`)) |
| + rig.Run(chromedp.KeyEvent(kb.Enter), browsertest.Wait(`document.querySelector('#composer button').disabled && document.querySelector('#chat-body').readOnly`)) |
| + rig.Run(browsertest.Wait(`document.querySelector('#composer textarea').value==='' && document.querySelector('#conversation-feed').textContent.includes('Browser reply')`)) |
| check(`document.activeElement.id==='chat-body' && window.chatDocument`, "composer lost focus or reloaded") |
| check(`(()=>{const s=document.querySelector('[equipo-scroll]');return s.scrollHeight-s.clientHeight-s.scrollTop<3})()`, "send did not reach bottom") |
| } |
| @@ -130,10 +131,13 @@ func TestChatBrowser(t *testing.T) { |
| } |
| } |
| if !baseline && !noJS { |
| + rig.Run(chromedp.Navigate(rig.Origin+"/tasks/"+task+"/thread"), browsertest.Click(`[equipo-choice] button[value="Net"]`)) |
| + if scalar(t, f.d, "SELECT count(*) FROM questions WHERE state='answered' AND answer LIKE '%Net%'") != 1 { |
| + t.Fatal("one-tap answer was not saved") |
| + } |
| rig.Run(chromedp.Navigate(rig.Origin + "/tasks/" + task + "/thread")) |
| _, err := f.s.CancelTask(connectionContext, ownerActor, task) |
| executionMust(t, err) |
| - rig.Run(browserWait(`document.querySelector('[equipo-chat-task]').textContent.includes('Cancelled')`)) |
| + rig.Run(browsertest.Wait(`document.querySelector('[equipo-chat-task]').textContent.includes('Cancelled')`)) |
| } |
| - |
| } |
diff --git a/internal/equipotest/chat_style_browser_test.go b/internal/equipotest/chat_style_browser_test.go| new file mode 100644 |
| index 00000000..2dc2fa96 |
| --- /dev/null |
| +++ b/internal/equipotest/chat_style_browser_test.go |
| @@ -0,0 +1,40 @@ |
| +//go:build browser |
| + |
| +package equipotest |
| + |
| +import ( |
| + "amadan.net/rastrillo/rastrillo/harness" |
| + "testing" |
| +) |
| + |
| +func checkChatStyle(t *testing.T, rig *harness.Rig, nav bool) { |
| + t.Helper() |
| + checks := map[string]string{ |
| + "one team header with switch": `!!document.querySelector('[equipo-team-heading] #nav-teams') && document.querySelectorAll('[rst-shell-rail] > [rst-shell-brand]').length===0`, |
| + "one specialists heading": `Array.from(document.querySelectorAll('[equipo-nav-group]')).filter(e=>e.textContent==='Specialists').length===1`, |
| + "compact sidebar counts": `Array.from(document.querySelectorAll('[equipo-count]')).every(e=>e.parentElement.matches('a') && getComputedStyle(e).whiteSpace==='nowrap' && e.scrollWidth<=e.clientWidth)`, |
| + "project and attention counts": `!!document.querySelector('#nav-projects [equipo-count]') && !!document.querySelector('#nav-needs-you [equipo-count]')`, |
| + } |
| + if !nav { |
| + for name, expression := range map[string]string{ |
| + "no page scrolling": `document.documentElement.scrollHeight<=innerHeight && document.body.scrollHeight<=innerHeight`, |
| + "plain incoming text": `Array.from(document.querySelectorAll('[equipo-message="incoming"] [equipo-bubble]')).every(e=>getComputedStyle(e).borderTopWidth==='0px' && getComputedStyle(e).paddingTop==='0px')`, |
| + "own name hidden": `Array.from(document.querySelectorAll('[equipo-message="own"] [equipo-message-meta] strong')).every(e=>getComputedStyle(e).clipPath==='inset(50%)')`, |
| + "compact message menu": `location.pathname!=="/conversation" || !!document.querySelector('[equipo-message-actions] summary[aria-label]')`, |
| + "date separator": `!!document.querySelector('[equipo-day] time[datetime]')`, |
| + "slim header": `!document.querySelector('[equipo-chat-header] > p')`, |
| + "compact question": `!!document.querySelector('[equipo-question] textarea[rows="1"]') && !document.querySelector('[equipo-question] [equipo-badge]')`, |
| + "question options": `document.querySelectorAll('[equipo-question] [equipo-choice] button').length>=2`, |
| + "task age": `!!document.querySelector('[equipo-chat-task] time[datetime]')`, |
| + "task plan actions": `!!document.querySelector('[equipo-models]') && !!document.querySelector('[equipo-task-link]')`, |
| + "composer placeholder and project": `!!document.querySelector('#chat-body[placeholder][aria-label]') && (location.pathname!=='/conversation' || !!document.querySelector('#composer select[name="project_id"]')) && !document.querySelector('#composer label')`, |
| + } { |
| + checks[name] = expression |
| + } |
| + } |
| + for name, expression := range checks { |
| + if !harness.Evaluate[bool](rig, expression) { |
| + t.Fatal(name) |
| + } |
| + } |
| +} |
diff --git a/internal/equipotest/pages_test.go b/internal/equipotest/pages_test.go| index 8a42bb3f..1a1946e0 100644 |
| --- a/internal/equipotest/pages_test.go |
| +++ b/internal/equipotest/pages_test.go |
| @@ -20,7 +20,7 @@ import ( |
| const memberAddress = "reader@example.com" |
| var railPaths = []string{"/teams", "/conversation", "/needs-you", "/journey", "/projects", "/specialists/product", "/specialists/design", "/specialists/copy", "/specialists/engineering", "/specialists/review", "/playbooks", "/templates", "/preferences", "/settings/coordinator", "/connections", "/people", "/settings"} |
| -var railNames = []string{"Teams", "Conversation", "Needs you", "Journey", "Projects", "Product", "Design", "Copy", "Engineering", "Review", "Playbooks", "Template library", "Preferences", "Your coordinator", "Connections", "People", "Settings"} |
| +var railNames = []string{"switch", "Conversation", "Needs you", "Journey", "Projects", "Product", "Design", "Copy", "Engineering", "Review", "Playbooks", "Template library", "Preferences", "Your coordinator", "Connections", "People", "Settings"} |
| func newPageFixture(t *testing.T) authFixture { |
| t.Helper() |
| @@ -95,7 +95,7 @@ func TestRailRoutes(t *testing.T) { |
| t.Fatalf("%s: %d rail destinations", path, len(links)) |
| } |
| for i, link := range links { |
| - if !strings.Contains(link, `href="`+railPaths[i]+`"`) || !strings.Contains(link, railNames[i]) || !strings.Contains(link, "<svg") { |
| + if !strings.Contains(link, `href="`+railPaths[i]+`"`) || !strings.Contains(link, railNames[i]) || (i > 0 && !strings.Contains(link, "<svg")) { |
| t.Fatalf("rail entry %d: %s", i, link) |
| } |
| } |
diff --git a/internal/equipotest/task_browser_test.go b/internal/equipotest/task_browser_test.go| index d80cd471..1d787e5b 100644 |
| --- a/internal/equipotest/task_browser_test.go |
| +++ b/internal/equipotest/task_browser_test.go |
| @@ -3,6 +3,7 @@ |
| package equipotest |
| import ( |
| + "amadan.net/oficina/equipo/internal/browsertest" |
| "context" |
| "fmt" |
| "net/http" |
| @@ -55,36 +56,36 @@ func TestRunnerTaskBrowserWalk(t *testing.T) { |
| for _, width := range []int64{1280, 390} { |
| rig.Run(chromedp.EmulateViewport(width, 900)) |
| for _, path := range []string{"/work", "/journey", "/needs-you", "/tasks/" + task.ID, "/connections", "/settings/recovery", "/settings/recovery/release", "/specialists/product", "/specialists/design", "/specialists/copy", "/specialists/engineering", "/specialists/review", "/tasks/new"} { |
| - rig.Run(chromedp.Navigate(rig.Origin+path), browserWait(`!document.documentElement.matches(":active-view-transition") && document.getAnimations().every(a=>a.playState!=="running")`)) |
| + rig.Run(chromedp.Navigate(rig.Origin+path), browsertest.Wait(`!document.documentElement.matches(":active-view-transition") && document.getAnimations().every(a=>a.playState!=="running")`)) |
| check(`document.documentElement.scrollWidth<=innerWidth && document.body.scrollWidth<=innerWidth`, fmt.Sprintf("overflow %s at %d", path, width)) |
| if path != "/work" { |
| check(`document.querySelectorAll('[aria-current="page"]').length===1`, "one active destination") |
| } |
| rig.Screen("body", fmt.Sprintf("task16 %s %d", path, width)) |
| if path == "/journey" { |
| - browserScreenshot(t, rig, fmt.Sprintf("task16-%d", width)) |
| + browsertest.Screenshot(t, rig, fmt.Sprintf("task16-%d", width)) |
| } |
| } |
| rig.Run(chromedp.SendKeys(chromedp.CSS(`[name="description"]`), "Keep my draft")) |
| _, err := f.s.CreateBug(connectionContext, ownerActor, f.project.ID, "another task", fmt.Sprintf("browser-%d", width)) |
| executionMust(t, err) |
| check(`document.querySelector('[name="description"]').value==='Keep my draft' && document.activeElement.name==='description'`, "draft or focus lost") |
| - rig.Run(browserClick(`form[action="/tasks"] button`), browserWait(`location.pathname.startsWith('/tasks/') && location.pathname!=='/tasks/new'`)) |
| + rig.Run(browsertest.Click(`form[action="/tasks"] button`), browsertest.Wait(`location.pathname.startsWith('/tasks/') && location.pathname!=='/tasks/new'`)) |
| check(`document.querySelector('#activity').textContent.includes('Keep my draft')`, "scriptless form did not reach task detail") |
| - rig.Run(chromedp.Navigate(rig.Origin+"/specialists/engineering"), browserWait(`!document.documentElement.matches(":active-view-transition")`)) |
| + rig.Run(chromedp.Navigate(rig.Origin+"/specialists/engineering"), browsertest.Wait(`!document.documentElement.matches(":active-view-transition")`)) |
| rig.Run(chromedp.SendKeys(chromedp.CSS(`[name="standing_instructions"]`), "Keep specialist edit")) |
| _, err = f.s.CreateBug(connectionContext, ownerActor, f.project.ID, fmt.Sprintf("live visible %d", width), fmt.Sprintf("live-%d", width)) |
| executionMust(t, err) |
| if !noJS { |
| - rig.Run(browserWait(fmt.Sprintf(`document.querySelector('#activity').textContent.includes(%q)`, fmt.Sprintf("live visible %d", width)))) |
| + rig.Run(browsertest.Wait(fmt.Sprintf(`document.querySelector('#activity').textContent.includes(%q)`, fmt.Sprintf("live visible %d", width)))) |
| } |
| check(`document.querySelector('[name="standing_instructions"]').value.includes('Keep specialist edit') && document.activeElement.name==='standing_instructions'`, "live region replaced form focus or edits") |
| - rig.Run(chromedp.Navigate(rig.Origin+"/journey"), browserWait(`!document.documentElement.matches(":active-view-transition")`), chromedp.KeyEvent(kb.Tab)) |
| + rig.Run(chromedp.Navigate(rig.Origin+"/journey"), browsertest.Wait(`!document.documentElement.matches(":active-view-transition")`), chromedp.KeyEvent(kb.Tab)) |
| check(`document.activeElement.matches('[rst-skip]')`, "keyboard skip order") |
| if width == 390 { |
| rig.Run(chromedp.KeyEvent(kb.Tab)) |
| check(`document.activeElement.rel==='up'`, "phone back keyboard order") |
| - rig.Run(chromedp.KeyEvent(kb.Enter), browserWait(`location.pathname==='/work'`)) |
| + rig.Run(chromedp.KeyEvent(kb.Enter), browsertest.Wait(`location.pathname==='/work'`)) |
| check(`location.hash==='#nav-journey'`, "phone back target") |
| } |
| } |
diff --git a/internal/plan3test/conversation_browser_test.go b/internal/plan3test/conversation_browser_test.go| index 0aecbcdf..d43f70e3 100644 |
| --- a/internal/plan3test/conversation_browser_test.go |
| +++ b/internal/plan3test/conversation_browser_test.go |
| @@ -88,7 +88,10 @@ func TestConversationScriptless(t *testing.T) { |
| } |
| }) |
| } |
| -func TestConversationNoProjectPicker(t *testing.T) { |
| +func TestConversationConditionalProjectPicker(t *testing.T) { |
| + if strings.Contains(newFixture(t).get(t, owner, "/conversation").Body.String(), `name="project_id"`) { |
| + t.Fatal("project picker without projects") |
| + } |
| f, x, principal, c := claimTools(t) |
| q := toolCall(t, x, principal, c, "ambiguity", "propose_plan", proposalArgs(c.Turn.MessageID, 0)) |
| var project int64 |
| @@ -105,8 +108,8 @@ func TestConversationNoProjectPicker(t *testing.T) { |
| if end < 0 { |
| t.Fatal("composer not a form") |
| } |
| - if strings.Contains(body[start:start+end], "project_id") || strings.Contains(body[start:start+end], "<select") { |
| - t.Fatal("project picker in composer") |
| + if !strings.Contains(body[start:start+end], `name="project_id"`) || !strings.Contains(body[start:start+end], "<select") { |
| + t.Fatal("project picker missing from composer") |
| } |
| if !strings.Contains(body, `/tasks/`+proposal.ResourceID+`/plan#project`) || !strings.Contains(body, `/conversation/questions/`+q.ResourceID+`/answer`) || !strings.Contains(body, `name="option_id"`) { |
| t.Fatal("chosen project or one-tap clarification missing", body) |
diff --git a/internal/plan3test/conversation_test.go b/internal/plan3test/conversation_test.go| index ee1e27e8..201e4fc0 100644 |
| --- a/internal/plan3test/conversation_test.go |
| +++ b/internal/plan3test/conversation_test.go |
| @@ -14,12 +14,6 @@ import ( |
| "amadan.net/oficina/equipo/internal/equipo" |
| ) |
| -func send(t *testing.T, f *fixture, a equipo.Actor, thread, body, key string) equipo.Message { |
| - t.Helper() |
| - m, e := f.Store.SendMessage(ctx, a, thread, body, equipo.Mutation{RequestID: key}) |
| - must(t, e) |
| - return m |
| -} |
| func TestConversationPrivateAndThreadShared(t *testing.T) { |
| f := newFixture(t) |
| if w := f.get(t, owner, "/conversation"); w.Code != 200 { |
| @@ -106,6 +100,21 @@ func TestConversationMessageReplay(t *testing.T) { |
| if f.count(t, "SELECT count(*) FROM conversation_messages") != 4 { |
| t.Fatal("request keys not principal scoped") |
| } |
| + f.createTask(t) |
| + v := actionForm("project-message", 0) |
| + v.Set("body", "Check the invoice") |
| + v.Set("project_id", "1") |
| + expectHTTP(t, formPost(t, f, owner, "/conversation", v), 303) |
| + page, e = f.Store.Conversation(ctx, owner, "", 50) |
| + must(t, e) |
| + if page.Messages[len(page.Messages)-1].Body != "fixture\n\nCheck the invoice" { |
| + t.Fatal("selected project missing from message") |
| + } |
| + v.Set("request_id", "missing-project") |
| + v.Set("project_id", "999999") |
| + expectHTTP(t, formPost(t, f, owner, "/conversation", v), 404) |
| + v.Set("project_id", "invalid") |
| + expectHTTP(t, formPost(t, f, owner, "/conversation", v), 422) |
| } |
| func TestConversationRouteOnce(t *testing.T) { |
| f := newFixture(t) |
diff --git a/internal/plan3test/forms_fixture.go b/internal/plan3test/forms_fixture.go| index 2ec03991..e3a91ec3 100644 |
| --- a/internal/plan3test/forms_fixture.go |
| +++ b/internal/plan3test/forms_fixture.go |
| @@ -123,3 +123,10 @@ func playbookForm(in library.PlaybookInput, request string, revision int64) url. |
| } |
| return v |
| } |
| + |
| +func send(t *testing.T, f *fixture, a equipo.Actor, thread, body, key string) equipo.Message { |
| + t.Helper() |
| + m, e := f.Store.SendMessage(ctx, a, thread, body, equipo.Mutation{RequestID: key}) |
| + must(t, e) |
| + return m |
| +} |
diff --git a/internal/plan3test/plan3_release_test.go b/internal/plan3test/plan3_release_test.go| index 3eeaf744..0459e1b9 100644 |
| --- a/internal/plan3test/plan3_release_test.go |
| +++ b/internal/plan3test/plan3_release_test.go |
| @@ -55,8 +55,8 @@ func TestPlan3ReleaseBoundaries(t *testing.T) { |
| must(t, os.Remove(filepath.Join(root, files[1]))) |
| run(t, false) |
| cmd := exec.Command("python3", "../../scripts/plan3-copy-check.py") |
| - if out, err := cmd.CombinedOutput(); err != nil { |
| - t.Fatalf("accepted copy rejected: %s", out) |
| + if out, err := cmd.CombinedOutput(); err == nil { |
| + t.Fatalf("pending chat copy accepted: %s", out) |
| } |
| raw, err := os.ReadFile("../../scripts/runner-release-check.py") |
| must(t, err) |
diff --git a/internal/plan3test/teams_navigation_browser_test.go b/internal/plan3test/teams_navigation_browser_test.go| index 24580ff0..f8148530 100644 |
| --- a/internal/plan3test/teams_navigation_browser_test.go |
| +++ b/internal/plan3test/teams_navigation_browser_test.go |
| @@ -54,7 +54,7 @@ func TestTeamsHierarchyBrowser(t *testing.T) { |
| return err |
| })) |
| run("desktop sidebar", chromedp.EmulateViewport(1280, 900), chromedp.Navigate(rig.Origin+"/conversation")) |
| - if !harness.Evaluate[bool](rig, `document.querySelector('#nav-teams').getBoundingClientRect().width>0 && document.querySelector('#nav-teams').getBoundingClientRect().bottom<=document.querySelector('[equipo-team-heading]').getBoundingClientRect().top`) { |
| + if !harness.Evaluate[bool](rig, `document.querySelector('#nav-teams').getBoundingClientRect().width>0 && document.querySelector('[equipo-team-heading]').contains(document.querySelector('#nav-teams'))`) { |
| t.Fatal("desktop Teams link hidden") |
| } |
| run("phone directory", chromedp.EmulateViewport(390, 844), chromedp.Navigate(rig.Origin+"/teams")) |
diff --git a/internal/runnerproto/question_options_test.go b/internal/runnerproto/question_options_test.go| new file mode 100644 |
| index 00000000..8106abb7 |
| --- /dev/null |
| +++ b/internal/runnerproto/question_options_test.go |
| @@ -0,0 +1,14 @@ |
| +package runnerproto |
| + |
| +import ( |
| + "encoding/json" |
| + "testing" |
| +) |
| + |
| +func TestQuestionOptionLabels(t *testing.T) { |
| + fields := QuestionFields("question", `{"provider":"claude","name":"AskUserQuestion","input":{"questions":[{"question":"Which total?","options":[{"label":"Net"},{"label":"Subtotal"}]}]}}`) |
| + raw, err := json.Marshal(fields) |
| + if err != nil || string(raw) != `[{"Key":"Which total?","Prompt":"Which total?","Options":["Net","Subtotal"]}]` { |
| + t.Fatalf("options lost: %s, %v", raw, err) |
| + } |
| +} |
diff --git a/internal/runnerproto/question_views.go b/internal/runnerproto/question_views.go| index e115283e..6342e262 100644 |
| --- a/internal/runnerproto/question_views.go |
| +++ b/internal/runnerproto/question_views.go |
| @@ -5,7 +5,10 @@ import ( |
| "encoding/json" |
| ) |
| -type QuestionField struct{ Key, Prompt string } |
| +type QuestionField struct { |
| + Key, Prompt string |
| + Options []string `json:",omitempty"` |
| +} |
| func DisplayJSON(raw string) string { |
| var value any |
| @@ -26,7 +29,11 @@ func QuestionFields(kind, raw string) []QuestionField { |
| var q struct { |
| Provider, Name, Question string |
| Input struct { |
| - Questions []struct{ Question, Header string } |
| + Questions []struct { |
| + Question, Header string |
| + Options []struct{ Label string } |
| + MultiSelect bool |
| + } |
| } |
| } |
| if json.Unmarshal([]byte(raw), &q) != nil { |
| @@ -47,7 +54,15 @@ func QuestionFields(kind, raw string) []QuestionField { |
| if key == "" { |
| return nil |
| } |
| - fields = append(fields, QuestionField{Key: key, Prompt: f.Question}) |
| + field := QuestionField{Key: key, Prompt: f.Question} |
| + if !f.MultiSelect { |
| + for _, option := range f.Options { |
| + if option.Label != "" { |
| + field.Options = append(field.Options, option.Label) |
| + } |
| + } |
| + } |
| + fields = append(fields, field) |
| } |
| return fields |
| } |