Make conversations and task threads behave like chat
Co-Authored-By: Astra <noreply@openai.com>
44 files changed,
+728
−70
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/mockups/built/2026-11-05/before/conversation-1280.pngbinarydocs/mockups/built/2026-11-05/before/conversation-390.pngbinarydocs/mockups/built/2026-11-05/before/nav-1280.pngbinarydocs/mockups/built/2026-11-05/before/nav-390.pngbinarydocs/mockups/built/2026-11-05/before/thread-1280.pngbinarydocs/mockups/built/2026-11-05/before/thread-390.pngbinarydocs/mockups/built/2026-11-05/mockups/conversation-1280.pngbinarydocs/mockups/built/2026-11-05/mockups/conversation-390.pngbinarydocs/mockups/built/2026-11-05/mockups/journey-1280.pngbinarydocs/mockups/built/2026-11-05/mockups/journey-390.pngbinarydocs/mockups/built/2026-11-05/mockups/native-1280.pngbinarydocs/mockups/built/2026-11-05/mockups/native-390.pngbinarydocs/mockups/built/2026-11-05/mockups/nav-1280.pngbinarydocs/mockups/built/2026-11-05/mockups/nav-390.pngbinarydocs/superpowers/plans/CONTROLLER-REPORT-chat-ui.md+144 −0internal/equipo/conversation/cards.go+1 −1internal/equipo/conversation/chat.go+76 −0internal/equipo/conversation/chat_test.go+45 −0internal/equipo/conversation/feed.go+26 −0internal/equipo/conversation/models.go+1 −0internal/equipo/conversation/store.go+3 −3internal/equipo/conversation/views.go+15 −1internal/equipo/conversation_handlers.go+7 −2internal/equipo/static/chat.js+88 −0internal/equipo/static/equipo.css+45 −0internal/equipo/templates/chrome.html+1 −1internal/equipo/templates/conversation.html+5 −3internal/equipo/templates/conversation_card.html+42 −17internal/equipo/templates/thread.html+5 −3internal/equipotest/browser_test.go+33 −24internal/equipotest/chat_browser_test.go+139 −0internal/equipotest/task_browser_test.go+4 −14internal/plan3test/conversation_layout_browser_test.go+20 −1scripts/runner-reference-allowlist.json+28 −0
CI cancelled — superseded by a newer push — run details
Intent
diff --git a/docs/mockups/built/2026-11-05/after/conversation-1280.png b/docs/mockups/built/2026-11-05/after/conversation-1280.png| new file mode 100644 |
| index 00000000..3be0fcfb |
| Binary files /dev/null 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| new file mode 100644 |
| index 00000000..ac0013e5 |
| Binary files /dev/null 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| new file mode 100644 |
| index 00000000..5f88a5c3 |
| Binary files /dev/null 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| new file mode 100644 |
| index 00000000..14f77c93 |
| Binary files /dev/null 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| new file mode 100644 |
| index 00000000..4e70655d |
| Binary files /dev/null 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| new file mode 100644 |
| index 00000000..c39ad53e |
| Binary files /dev/null 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| new file mode 100644 |
| index 00000000..86fd0259 |
| Binary files /dev/null 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| new file mode 100644 |
| index 00000000..f139a991 |
| Binary files /dev/null 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| new file mode 100644 |
| index 00000000..b47f18ae |
| Binary files /dev/null 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| new file mode 100644 |
| index 00000000..76c4351e |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/after/thread-history-390.png differ |
diff --git a/docs/mockups/built/2026-11-05/before/conversation-1280.png b/docs/mockups/built/2026-11-05/before/conversation-1280.png| new file mode 100644 |
| index 00000000..fe6d2778 |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/before/conversation-1280.png differ |
diff --git a/docs/mockups/built/2026-11-05/before/conversation-390.png b/docs/mockups/built/2026-11-05/before/conversation-390.png| new file mode 100644 |
| index 00000000..e086ba12 |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/before/conversation-390.png differ |
diff --git a/docs/mockups/built/2026-11-05/before/nav-1280.png b/docs/mockups/built/2026-11-05/before/nav-1280.png| new file mode 100644 |
| index 00000000..b9e29c0f |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/before/nav-1280.png differ |
diff --git a/docs/mockups/built/2026-11-05/before/nav-390.png b/docs/mockups/built/2026-11-05/before/nav-390.png| new file mode 100644 |
| index 00000000..c39ad53e |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/before/nav-390.png differ |
diff --git a/docs/mockups/built/2026-11-05/before/thread-1280.png b/docs/mockups/built/2026-11-05/before/thread-1280.png| new file mode 100644 |
| index 00000000..6acdab4a |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/before/thread-1280.png differ |
diff --git a/docs/mockups/built/2026-11-05/before/thread-390.png b/docs/mockups/built/2026-11-05/before/thread-390.png| new file mode 100644 |
| index 00000000..fc3f6aaf |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/before/thread-390.png differ |
diff --git a/docs/mockups/built/2026-11-05/mockups/conversation-1280.png b/docs/mockups/built/2026-11-05/mockups/conversation-1280.png| new file mode 100644 |
| index 00000000..4a513727 |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/mockups/conversation-1280.png differ |
diff --git a/docs/mockups/built/2026-11-05/mockups/conversation-390.png b/docs/mockups/built/2026-11-05/mockups/conversation-390.png| new file mode 100644 |
| index 00000000..e9cf92e5 |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/mockups/conversation-390.png differ |
diff --git a/docs/mockups/built/2026-11-05/mockups/journey-1280.png b/docs/mockups/built/2026-11-05/mockups/journey-1280.png| new file mode 100644 |
| index 00000000..d482b037 |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/mockups/journey-1280.png differ |
diff --git a/docs/mockups/built/2026-11-05/mockups/journey-390.png b/docs/mockups/built/2026-11-05/mockups/journey-390.png| new file mode 100644 |
| index 00000000..83cd047e |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/mockups/journey-390.png differ |
diff --git a/docs/mockups/built/2026-11-05/mockups/native-1280.png b/docs/mockups/built/2026-11-05/mockups/native-1280.png| new file mode 100644 |
| index 00000000..9a040b5d |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/mockups/native-1280.png differ |
diff --git a/docs/mockups/built/2026-11-05/mockups/native-390.png b/docs/mockups/built/2026-11-05/mockups/native-390.png| new file mode 100644 |
| index 00000000..66d9e04d |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/mockups/native-390.png differ |
diff --git a/docs/mockups/built/2026-11-05/mockups/nav-1280.png b/docs/mockups/built/2026-11-05/mockups/nav-1280.png| new file mode 100644 |
| index 00000000..833e9e32 |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/mockups/nav-1280.png differ |
diff --git a/docs/mockups/built/2026-11-05/mockups/nav-390.png b/docs/mockups/built/2026-11-05/mockups/nav-390.png| new file mode 100644 |
| index 00000000..bc119db8 |
| Binary files /dev/null and b/docs/mockups/built/2026-11-05/mockups/nav-390.png differ |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-chat-ui.md b/docs/superpowers/plans/CONTROLLER-REPORT-chat-ui.md| new file mode 100644 |
| index 00000000..4f3a6891 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-chat-ui.md |
| @@ -0,0 +1,144 @@ |
| +# Chat UI controller report |
| + |
| +Branch: `chat-ui`, starting at `df2b9e3` (the brief, on deployed `0cb576b`). |
| +No deployment or default-branch changes. |
| + |
| +## Gaps captured before implementation |
| + |
| +- Messages read like paragraphs in a document. Senders had the same layout, |
| + with no timestamps or specialist icons. |
| +- The composer followed the whole document and disappeared below the fold. |
| +- Task cards followed all messages, separate from the messages that introduced them. |
| +- Task threads lacked their task's steps and pending questions. |
| +- Sending used a page navigation. There was no Enter/Shift+Enter chat behavior. |
| +- The navigation counts wrapped onto several lines. |
| + |
| +## Changes |
| + |
| +Both conversation views now use one scrolling column and a docked composer. |
| +Your messages have a tinted bubble aligned to the right. Other people, |
| +coordinators and specialists appear on the left, with an icon, name and time. |
| +Task threads use the task description as their heading. |
| + |
| +Cards sit in message order. Tasks include their steps, model/account labels, |
| +links to their thread and plan, candidate evidence and existing approval actions. |
| +Pending questions can be answered from their cards. Existing authorization and |
| +form handlers remain responsible for those actions. |
| + |
| +The composer uses Rastrillo live forms. Enter sends, Shift+Enter adds a newline, |
| +and composition input is left alone. The send button is disabled while the |
| +request is pending; the textarea becomes read-only so it can retain focus. |
| +Confirmed sends clear the draft and return focus to the composer. Background |
| +updates preserve drafts. The feed follows new messages at the bottom and keeps |
| +the visible message in place while reading older messages, including when the |
| +server's 50-message window moves forward. Message and card scroll identifiers |
| +remain distinct even when their stored IDs match. |
| + |
| +The ordered message list, focusable scroll region and persistent live announcement |
| +region support keyboard and assistive-technology use. Phone navigation retains |
| +the existing index and back links. Styling uses theme tokens and complete borders. |
| +Vendored assets are unchanged. No framework or schema changes were needed. |
| + |
| +Browser fixture helpers for screenshots and real-session sign-in are shared to |
| +stay within the existing source and test size budgets. The old layout assertion |
| +now checks for one column; the foundation walk checks the conversation's empty |
| +state rather than assuming the first navigation destination is empty. |
| + |
| +## Screenshots |
| + |
| +The app ran through the repository's Chromium harness, bound to loopback, with |
| +logged-mail mode allowed, a scratch database, and a real verified session. The |
| +fixture contains a team, project, six messages in each conversation, a task with |
| +steps and a pending question. Both sizes are 900 pixels high. |
| + |
| +All files are under `docs/mockups/built/2026-11-05/`: |
| + |
| +| View | Before | After | |
| +|---|---|---| |
| +| Conversation, desktop | `before/conversation-1280.png` | `after/conversation-1280.png` | |
| +| Conversation, phone | `before/conversation-390.png` | `after/conversation-390.png` | |
| +| Task thread, desktop | `before/thread-1280.png` | `after/thread-1280.png` | |
| +| Task thread, phone | `before/thread-390.png` | `after/thread-390.png` | |
| +| Navigation, desktop | `before/nav-1280.png` | `after/nav-1280.png` | |
| +| Navigation, phone | `before/nav-390.png` | `after/nav-390.png` | |
| + |
| +Reference captures are `mockups/{conversation,nav,journey,native}-{1280,390}.png`. |
| +The phone reference captures scroll to the phone drawing. The built chat opens |
| +at its newest messages; the before version opens at the top of the document. |
| +Before and after captures use the same seed without browser-test replies. |
| +Additional `after/{conversation,thread}-history-{1280,390}.png` captures show |
| +the task steps near the start of each feed. These use `EQUIPO_CHAT_HISTORY=1`. |
| + |
| +Capture command, with `EQUIPO_BROWSER_ARTIFACTS` pointing to the appropriate |
| +scratch directory: `EQUIPO_ALLOW_LOGGED_MAIL=1 EQUIPO_CHAT_BASELINE=1 |
| +GOTOOLCHAIN=go1.26.10 CGO_ENABLED=0 go test -tags browser ./internal/equipotest |
| +-run '^TestChatBrowser$' -count=1`. The baseline flag captures without asserting |
| +the new behavior, so the same fixture runs on the original UI. |
| + |
| +## Verification |
| + |
| +The first `TestChatBrowser` run failed with `missing accessible chat feed` before |
| +implementation. The long-history acceptance check also failed before its fix. |
| + |
| +- `GOTOOLCHAIN=go1.26.10 CGO_ENABLED=0 go test ./internal/equipo/conversation -run '^TestChatFeed$' -count=1`: passed. |
| +- `GOTOOLCHAIN=go1.26.10 CGO_ENABLED=0 go test -tags browser ./internal/equipotest ./internal/plan3test -run '^(TestChatBrowser|TestFoundationBrowserWalk|TestRunnerTaskBrowserWalk|TestConversationLayout|TestTeamsHierarchyBrowser)$' -count=1`: passed. Includes both widths, 200% text, live messages and task progress, draft/focus retention, scrolling, keyboard sends and navigation. |
| +- `EQUIPO_BROWSER_NO_JS=1 GOTOOLCHAIN=go1.26.10 CGO_ENABLED=0 go test -tags browser ./internal/equipotest -run '^(TestChatBrowser|TestFoundationBrowserWalk|TestRunnerTaskBrowserWalk)$' -count=1`: passed. |
| +- `make -k ci`, first run: reference-inventory and project-correction-link failures. Both were fixed. Build, vet, formatting, static analysis, vulnerability and secret scans, size budgets, adapter checks, containment checks, migration and performance checks passed. Some unchanged execution packages exceeded advisory local timing budgets under load. |
| +- `GOFLAGS=-p=2 make -k ci`, final run: **exit 0**. All 31 tested packages passed uncached. Adapter, containment, migration and both required performance checks passed. Two full gate runs were made in total. |
| + |
| +The final full test step took 15m53.465s with two Go packages running at once. |
| +Seven package timing limits were exceeded during this shared-machine run. These |
| +are advisory locally and enforced on CI; a successful local exit does not certify |
| +those timing limits. No limits were increased. |
| + |
| +| Package | Observed | Limit | |
| +|---|---:|---:| |
| +| `internal/directlive` | 6m21.935s | 6m | |
| +| `internal/equipotest` | 5m8.902s | 5m | |
| +| `internal/runner` | 9m25.809s | 5m30s | |
| +| `internal/runner/containment` | 15.385s | 15s | |
| +| `internal/runner/provider` | 35.284s | 15s | |
| +| `internal/runner/provider/claude` | 1m12.855s | 45s | |
| +| `internal/runner/provider/codex` | 1m0.805s | 35s | |
| + |
| +Seventeen mutations were applied separately, tested, then restored. Every |
| +mutation failed its guard. Unit mutations used `go test ./internal/equipo/conversation |
| +-run '^TestChatFeed$' -count=1`; browser mutations used `go test -tags browser |
| +./internal/equipotest -run '^TestChatBrowser$' -count=1`, except the two history |
| +cases, which used `./internal/plan3test -run '^TestConversationLayout$'`. |
| +All commands used `GOTOOLCHAIN=go1.26.10 CGO_ENABLED=0`. |
| + |
| +| Deliberate breakage | Observed failure | |
| +|---|---| |
| +| Remove retained older messages | Message being read disappeared | |
| +| Treat message and card IDs as interchangeable | Visible message moved | |
| +| Reverse feed ordering | Cards detached from messages | |
| +| Style every person as the current viewer | Identity assertion failed | |
| +| Substitute a specialist key for its name | Identity assertion failed | |
| +| Select answered questions instead of pending ones | Thread-card assertion failed | |
| +| Ignore task lookup errors | Denied lookup was hidden | |
| +| Remove the ordered list | Accessible-feed assertion failed | |
| +| Remove machine-readable timestamps | Message-times assertion failed | |
| +| Remove viewport height | Composer left the viewport | |
| +| Remove the feed's live subscription | Live-message wait timed out | |
| +| Clear the draft on live updates | Draft/focus assertion failed | |
| +| Stop following the bottom | Bottom-follow assertion failed | |
| +| Always jump to the bottom | Reading-position assertion failed | |
| +| Suppress live announcements | Announcement assertion failed | |
| +| Send on Shift+Enter | Newline assertion failed | |
| +| Remove Enter submission | Sending-state wait timed out | |
| + |
| +The reference inventory has exact allowances for the supplied brief's excluded |
| +path, DOM properties and the reused isolation-disclosure partial. No broad |
| +allowances or size-budget increases were added. |
| + |
| +## Copy and handoff |
| + |
| +New app-owned runtime strings: **none**. Existing strings are reused. Fixture |
| +messages and labels are test data. No copy-review service was started, and no |
| +README prose was changed. |
| + |
| +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. |
diff --git a/internal/equipo/conversation/cards.go b/internal/equipo/conversation/cards.go| index 5da3d25d..b1275c16 100644 |
| --- a/internal/equipo/conversation/cards.go |
| +++ b/internal/equipo/conversation/cards.go |
| @@ -15,7 +15,7 @@ func (s *Store) allCards(a Actor, main Main) ([]Card, error) { |
| } |
| out := []Card{} |
| for _, c := range rows { |
| - card := Card{ID: c.ID, Kind: c.Kind, ResourceID: c.ResourceID, Revision: c.Revision} |
| + card := Card{Sequence: c.Sequence, ID: c.ID, Kind: c.Kind, ResourceID: c.ResourceID, Revision: c.Revision} |
| switch c.Kind { |
| case "task": |
| t, err := s.deps.Task(s.tx, a, c.ResourceID) |
diff --git a/internal/equipo/conversation/chat.go b/internal/equipo/conversation/chat.go| new file mode 100644 |
| index 00000000..ea6a0296 |
| --- /dev/null |
| +++ b/internal/equipo/conversation/chat.go |
| @@ -0,0 +1,76 @@ |
| +package conversation |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo/library" |
| + "amadan.net/oficina/equipo/internal/equipo/planning" |
| +) |
| + |
| +func (v *Page) PrepareChat(address string, specialists []library.Specialist, taskView func(string) (planning.TaskViewData, error), copyText func(string) string) error { |
| + for i := range v.Messages { |
| + m := &v.Messages[i] |
| + m.Own = m.AuthorKind == "person" && m.AuthorID == address |
| + m.AuthorName, m.AuthorIcon = m.AuthorID, "users" |
| + switch m.AuthorKind { |
| + case "coordinator": |
| + m.AuthorName, m.AuthorIcon = copyText("conversation.coordinator"), "message-circle" |
| + case "specialist": |
| + m.AuthorIcon = "code" |
| + for _, s := range specialists { |
| + if s.Key == m.AuthorID { |
| + m.AuthorIcon = s.Icon |
| + m.AuthorName = s.Name |
| + if m.AuthorName == "" { |
| + m.AuthorName = copyText("nav." + s.Key) |
| + } |
| + break |
| + } |
| + } |
| + case "person": |
| + default: |
| + m.AuthorName, m.AuthorIcon = copyText("brand"), "info" |
| + } |
| + } |
| + if v.ThreadID != "" { |
| + v.Cards = append(v.Cards, CardView{Card: Card{ID: "thread-task", Kind: "task", ResourceID: v.ThreadID, Sequence: -1}, Plan: v.ThreadPlan}) |
| + } |
| + tasks := map[string]*planning.TaskViewData{} |
| + for i := range v.Cards { |
| + c := &v.Cards[i] |
| + id := c.TaskID |
| + if c.Kind == "task" { |
| + id = c.ResourceID |
| + } |
| + if id == "" { |
| + continue |
| + } |
| + work := tasks[id] |
| + if work == nil { |
| + w, err := taskView(id) |
| + if err != nil { |
| + return err |
| + } |
| + work = &w |
| + tasks[id] = work |
| + } |
| + c.Work = work |
| + if c.Kind == "question" { |
| + for j := range work.Questions { |
| + if work.Questions[j].ID == c.ResourceID { |
| + c.NativeQuestion = &work.Questions[j] |
| + break |
| + } |
| + } |
| + } |
| + } |
| + if work := tasks[v.ThreadID]; work != nil { |
| + v.ThreadTitle = work.Task.Description |
| + for i := range work.Questions { |
| + q := &work.Questions[i] |
| + if q.State == "pending" { |
| + v.Cards = append(v.Cards, CardView{Card: Card{ID: "native:" + q.ID, Kind: "question", TaskID: v.ThreadID, ResourceID: q.ID}, Work: work, NativeQuestion: q}) |
| + } |
| + } |
| + } |
| + v.BuildFeed() |
| + return nil |
| +} |
diff --git a/internal/equipo/conversation/chat_test.go b/internal/equipo/conversation/chat_test.go| new file mode 100644 |
| index 00000000..ff8a7638 |
| --- /dev/null |
| +++ b/internal/equipo/conversation/chat_test.go |
| @@ -0,0 +1,45 @@ |
| +package conversation |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo/library" |
| + "amadan.net/oficina/equipo/internal/equipo/planning" |
| + "errors" |
| + "testing" |
| +) |
| + |
| +func TestChatFeed(t *testing.T) { |
| + t.Run("order", func(t *testing.T) { |
| + p := Page{Messages: []MessageView{{Message: Message{ID: "first", Sequence: 1}}, {Message: Message{ID: "reply", Sequence: 3}}}, Cards: []CardView{{Card: Card{ID: "plan", Sequence: 1}}, {Card: Card{ID: "pending"}}}} |
| + p.BuildFeed() |
| + if len(p.Feed) != 4 || p.Feed[0].Message == nil || p.Feed[1].Card == nil || p.Feed[1].Card.ID != "plan" || p.Feed[2].Message == nil || p.Feed[3].Card.ID != "pending" { |
| + t.Fatalf("cards are detached from messages: %+v", p.Feed) |
| + } |
| + }) |
| + t.Run("identity", func(t *testing.T) { |
| + p := Page{Messages: []MessageView{{Message: Message{AuthorKind: "person", AuthorID: "me"}}, {Message: Message{AuthorKind: "person", AuthorID: "teammate"}}, {Message: Message{AuthorKind: "specialist", AuthorID: "custom"}}}} |
| + err := p.PrepareChat("me", []library.Specialist{{Key: "custom", Name: "Accessibility", Icon: "pencil"}}, nil, func(s string) string { return s }) |
| + if err != nil || !p.Messages[0].Own || p.Messages[1].Own || p.Messages[2].AuthorName != "Accessibility" || p.Messages[2].AuthorIcon != "pencil" { |
| + t.Fatalf("identity lost: %+v, %v", p.Messages, err) |
| + } |
| + }) |
| + t.Run("thread questions", func(t *testing.T) { |
| + p := Page{ThreadID: "task"} |
| + err := p.PrepareChat("me", nil, func(id string) (planning.TaskViewData, error) { |
| + if id != "task" { |
| + t.Fatal(id) |
| + } |
| + return planning.TaskViewData{Questions: []planning.TaskQuestion{{ID: "pending", State: "pending", CanAnswer: false}, {ID: "closed", State: "answered"}}}, nil |
| + }, nil) |
| + if err != nil || len(p.Feed) != 2 || p.Feed[0].Card.Work == nil || p.Feed[1].Card.NativeQuestion.ID != "pending" || p.Feed[1].Card.NativeQuestion.CanAnswer { |
| + t.Fatalf("thread cards or authority changed: %+v, %v", p.Feed, err) |
| + } |
| + }) |
| + t.Run("lookup fails closed", func(t *testing.T) { |
| + p := Page{ThreadID: "removed"} |
| + denied := errors.New("denied") |
| + err := p.PrepareChat("me", nil, func(string) (planning.TaskViewData, error) { return planning.TaskViewData{}, denied }, nil) |
| + if !errors.Is(err, denied) { |
| + t.Fatal("task lookup failure hidden", err) |
| + } |
| + }) |
| +} |
diff --git a/internal/equipo/conversation/feed.go b/internal/equipo/conversation/feed.go| new file mode 100644 |
| index 00000000..6281607e |
| --- /dev/null |
| +++ b/internal/equipo/conversation/feed.go |
| @@ -0,0 +1,26 @@ |
| +package conversation |
| + |
| +import "sort" |
| + |
| +type Entry struct { |
| + Message *MessageView |
| + Card *CardView |
| + Sequence int64 |
| +} |
| + |
| +func (p *Page) BuildFeed() { |
| + p.Feed = nil |
| + for i := range p.Messages { |
| + m := &p.Messages[i] |
| + p.Feed = append(p.Feed, Entry{Message: m, Sequence: m.Sequence}) |
| + } |
| + for i := range p.Cards { |
| + c := &p.Cards[i] |
| + sequence := c.Sequence |
| + if sequence == 0 && len(p.Messages) > 0 { |
| + sequence = p.Messages[len(p.Messages)-1].Sequence + 1 |
| + } |
| + p.Feed = append(p.Feed, Entry{Card: c, Sequence: sequence}) |
| + } |
| + sort.SliceStable(p.Feed, func(i, j int) bool { return p.Feed[i].Sequence < p.Feed[j].Sequence }) |
| +} |
diff --git a/internal/equipo/conversation/models.go b/internal/equipo/conversation/models.go| index a16bb400..0a1d238e 100644 |
| --- a/internal/equipo/conversation/models.go |
| +++ b/internal/equipo/conversation/models.go |
| @@ -14,6 +14,7 @@ type Message struct { |
| CreatedAt time.Time |
| } |
| type Card struct { |
| + Sequence int64 `json:"-"` |
| ActionKeys []string `json:",omitempty"` |
| CopyKey, WaitingTaskID, WaitingTaskURL string `json:",omitempty"` |
| ID, Kind, ResourceID, TaskID string |
diff --git a/internal/equipo/conversation/store.go b/internal/equipo/conversation/store.go| index 0f93a933..19828a95 100644 |
| --- a/internal/equipo/conversation/store.go |
| +++ b/internal/equipo/conversation/store.go |
| @@ -236,13 +236,13 @@ func (s *Store) pageAfter(actor kernel.Actor, stream string, through, revision i |
| if err := s.tx.Where("id=? AND person=?", c.ResourceID, actor.Address).First(&q).Error; err != nil { |
| return page, err |
| } |
| - page.Cards = append(page.Cards, Card{ID: c.ID, Kind: c.Kind, ResourceID: q.ID, Revision: q.Revision}) |
| + page.Cards = append(page.Cards, Card{Sequence: c.Sequence, ID: c.ID, Kind: c.Kind, ResourceID: q.ID, Revision: q.Revision}) |
| case "suggest_preference", "suggest_specialist", "suggest_playbook": |
| var msg messageRecord |
| if err := s.tx.Where("id=? AND conversation_id=?", c.ResourceID, stream).First(&msg).Error; err != nil { |
| return page, err |
| } |
| - page.Cards = append(page.Cards, Card{ID: c.ID, Kind: c.Kind, ResourceID: msg.ID, Revision: msg.Revision}) |
| + page.Cards = append(page.Cards, Card{Sequence: c.Sequence, ID: c.ID, Kind: c.Kind, ResourceID: msg.ID, Revision: msg.Revision}) |
| default: |
| return page, s.deps.Invalid |
| } |
| @@ -252,7 +252,7 @@ func (s *Store) pageAfter(actor kernel.Actor, stream string, through, revision i |
| if err != nil { |
| return page, err |
| } |
| - page.Cards = append(page.Cards, Card{ID: c.ID, Kind: c.Kind, ResourceID: task.ID, Revision: task.Revision}) |
| + page.Cards = append(page.Cards, Card{Sequence: c.Sequence, ID: c.ID, Kind: c.Kind, ResourceID: task.ID, Revision: task.Revision}) |
| } |
| if more { |
| c := cursorRecord{ID: rand.Text(), Principal: actor.Address, StreamID: stream, After: end, Through: through, Revision: page.Revision, ExpiresAt: time.Now().UTC().Add(24 * time.Hour)} |
diff --git a/internal/equipo/conversation/views.go b/internal/equipo/conversation/views.go| index 1674ae09..9cb3449d 100644 |
| --- a/internal/equipo/conversation/views.go |
| +++ b/internal/equipo/conversation/views.go |
| @@ -16,10 +16,14 @@ import ( |
| type MessageView struct { |
| Message |
| - RouteID, ThreadURL string |
| + RouteID, ThreadURL string |
| + AuthorName, AuthorIcon string |
| + Own bool |
| } |
| type CardView struct { |
| Card |
| + Work *planning.TaskViewData |
| + NativeQuestion *planning.TaskQuestion |
| Plan *planning.Page |
| Question *runnerproto.ClarificationQuestion |
| CanAnswer bool |
| @@ -28,10 +32,13 @@ type CardView struct { |
| WaitingLabel string |
| } |
| type Page struct { |
| + ThreadTitle string |
| + ThreadPlan *planning.Page |
| Live live.View |
| Topic, ThreadID, RequestID, NextURL string |
| Revision int64 |
| Messages []MessageView |
| + Feed []Entry |
| Cards []CardView |
| Tasks []planning.ProjectOption |
| BindingRevision int64 |
| @@ -81,6 +88,13 @@ func (s *Application) View(ctx context.Context, a Actor, task, cursor string, pl |
| if err != nil { |
| return err |
| } |
| + if task != "" { |
| + p, e := plans.At(tx).Page(a, task) |
| + if e != nil { |
| + return e |
| + } |
| + out.ThreadPlan = &p |
| + } |
| out.Revision = page.Revision |
| if page.NextCursor != "" { |
| out.NextURL = "?cursor=" + url.QueryEscape(page.NextCursor) |
diff --git a/internal/equipo/conversation_handlers.go b/internal/equipo/conversation_handlers.go| index 9302e94e..98051bd0 100644 |
| --- a/internal/equipo/conversation_handlers.go |
| +++ b/internal/equipo/conversation_handlers.go |
| @@ -21,8 +21,13 @@ func (a *application) conversationHandler() *conversation.Handler { |
| a.failure(w, r, err) |
| return |
| } |
| - data.Conversation = v |
| - data.Live = v.Live |
| + if err := v.PrepareChat(data.Address, data.Specialists, func(id string) (planning.TaskViewData, error) { |
| + return a.store.TaskView(r.Context(), Actor{Address: data.Address}, id) |
| + }, copyText); err != nil { |
| + a.failure(w, r, err) |
| + return |
| + } |
| + data.Conversation, data.Live = v, v.Live |
| name := "conversation" |
| if v.ThreadID != "" { |
| name = "thread" |
diff --git a/internal/equipo/static/chat.js b/internal/equipo/static/chat.js| new file mode 100644 |
| index 00000000..bbf154a8 |
| --- /dev/null |
| +++ b/internal/equipo/static/chat.js |
| @@ -0,0 +1,88 @@ |
| +(function () { |
| + "use strict"; |
| + var chat = document.querySelector("[equipo-conversation]"); |
| + if (!chat) return; |
| + var scroll = chat.querySelector("[equipo-scroll]"); |
| + var announcements = chat.querySelector("[equipo-announcements]"); |
| + var seen = new Set(); |
| + var bottom = true, anchor = null, top = 0; |
| + var composer = document.getElementById("composer"); |
| + function remember() { |
| + bottom = scroll.scrollHeight - scroll.clientHeight - scroll.scrollTop < 48; |
| + top = scroll.scrollTop; |
| + anchor = null; |
| + var edge = scroll.getBoundingClientRect().top; |
| + scroll.querySelectorAll("[data-message],[data-entry]").forEach(function (el) { |
| + if (!anchor && el.getBoundingClientRect().bottom > edge) { |
| + var attribute = el.hasAttribute("data-message") ? "data-message" : "data-entry"; |
| + anchor = { attribute: attribute, key: el.getAttribute(attribute), offset: el.getBoundingClientRect().top - edge }; |
| + } |
| + }); |
| + } |
| + function messages(initial) { |
| + var added = []; |
| + chat.querySelectorAll("[data-message]").forEach(function (el) { |
| + var id = el.getAttribute("data-message"); |
| + if (!initial && !seen.has(id)) added.push(el.querySelector("strong").textContent + ": " + el.querySelector("[equipo-message-body]").textContent); |
| + seen.add(id); |
| + }); |
| + if (added.length) announcements.textContent = added.join("\n"); |
| + } |
| + function restore() { |
| + if (bottom) scroll.scrollTop = scroll.scrollHeight; |
| + else { |
| + scroll.scrollTop = top; |
| + if (anchor) { |
| + scroll.querySelectorAll("[data-message],[data-entry]").forEach(function (el) { |
| + if (el.getAttribute(anchor.attribute) === anchor.key) { |
| + scroll.scrollTop += el.getBoundingClientRect().top - scroll.getBoundingClientRect().top - anchor.offset; |
| + } |
| + }); |
| + } |
| + } |
| + remember(); |
| + } |
| + scroll.addEventListener("scroll", remember, { passive: true }); |
| + chat.addEventListener("keydown", function (e) { |
| + if (!e.target.matches("#chat-body") || e.key !== "Enter" || e.shiftKey || e.isComposing || e.keyCode === 229) return; |
| + e.preventDefault(); |
| + if (e.target.form.getAttribute("aria-busy") !== "true") e.target.form.requestSubmit(e.target.form.querySelector("button[type=submit]")); |
| + }); |
| + function retainHistory(changes) { |
| + var list = chat.querySelector("[equipo-feed]"); |
| + 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; |
| + old.querySelectorAll("[data-message]").forEach(function (el) { |
| + var sequence = Number(el.dataset.sequence); |
| + if (ids.has(el.dataset.message) || sequence >= first) return; |
| + var before = Array.from(list.children).find(function (item) { return Number(item.dataset.sequence) >= sequence; }); |
| + list.insertBefore(el, before || null); |
| + ids.add(el.dataset.message); |
| + }); |
| + }); |
| + }); |
| + } |
| + 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"; }); }); |
| + var next = document.getElementById("composer"); |
| + if (next && next !== composer) { |
| + var sent = composer && composer.getAttribute("aria-busy") === "true"; |
| + composer = next; |
| + if (sent) { bottom = true; composer.querySelector("textarea").focus({ preventScroll: true }); } |
| + } |
| + if (composer) { |
| + var busy = composer.getAttribute("aria-busy") === "true"; |
| + var input = composer.querySelector("textarea"); |
| + if (input.readOnly !== busy) input.readOnly = busy; |
| + } |
| + if (feedChanged) { retainHistory(changes); messages(false); restore(); } |
| + }); |
| + observer.observe(chat, { childList: true, subtree: true, attributes: true, attributeFilter: ["aria-busy"] }); |
| + messages(true); |
| + restore(); |
| + new ResizeObserver(restore).observe(scroll); |
| +})(); |
diff --git a/internal/equipo/static/equipo.css b/internal/equipo/static/equipo.css| index 5f6518a8..1ec67dd9 100644 |
| --- a/internal/equipo/static/equipo.css |
| +++ b/internal/equipo/static/equipo.css |
| @@ -60,3 +60,48 @@ |
| padding-inline: var(--rst-sp-1); |
| } |
| } |
| + |
| +[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); } |
| +#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-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-body] { margin: 0; } |
| +[equipo-message] details { margin-block-start: var(--rst-sp-2); font-size: var(--rst-fs-sm); } |
| +[equipo-feed-card] { min-width: 0; } |
| +[equipo-feed-card] > [equipo-card] { margin: 0; } |
| +[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; } |
| +@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] { 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); } |
| +} |
diff --git a/internal/equipo/templates/chrome.html b/internal/equipo/templates/chrome.html| index 504d2076..e5175ea9 100644 |
| --- a/internal/equipo/templates/chrome.html |
| +++ b/internal/equipo/templates/chrome.html |
| @@ -1,6 +1,6 @@ |
| {{define "rail-brand"}}{{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"}}">{{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}} |
| {{define "up-label"}}{{.TeamName}}{{end}} |
| {{define "brand"}}<a rst-shell-brand href="/work">{{icon "users"}}{{.TeamName}}</a>{{end}} |
diff --git a/internal/equipo/templates/conversation.html b/internal/equipo/templates/conversation.html| index f94640c4..0b4f79f1 100644 |
| --- a/internal/equipo/templates/conversation.html |
| +++ b/internal/equipo/templates/conversation.html |
| @@ -1,9 +1,11 @@ |
| {{define "title"}}{{copy "conversation.title"}}{{end}} |
| {{define "content"}} |
| <div equipo-conversation> |
| -<h1>{{copy "conversation.title"}}</h1><p equipo-muted>{{copy "conversation.private"}}</p> |
| +<header equipo-chat-header><h1>{{copy "conversation.title"}}</h1><p equipo-muted>{{copy "conversation.private"}}</p> |
| <a href="/settings/coordinator">{{copy "coordinator.settings"}}</a> |
| -{{template "region:conversation-feed" .}} |
| -{{template "conversation-composer" .}} |
| +</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" .}} |
| </div> |
| {{end}} |
diff --git a/internal/equipo/templates/conversation_card.html b/internal/equipo/templates/conversation_card.html| index b7c67520..da92c120 100644 |
| --- a/internal/equipo/templates/conversation_card.html |
| +++ b/internal/equipo/templates/conversation_card.html |
| @@ -1,33 +1,44 @@ |
| -{{define "conversation-composer"}} |
| -<form id="composer" equipo-form method="post" action="{{if .Conversation.ThreadID}}/tasks/{{.Conversation.ThreadID}}/thread{{else}}/conversation{{end}}"> |
| +{{define "region:chat-composer"}} |
| +<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 rst-input name="body" required maxlength="16384" rows="4"></textarea></label> |
| +<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> |
| </form> |
| +</div> |
| {{end}} |
| {{define "region:conversation-feed"}} |
| -<section id="conversation-feed" {{.Live.Attrs .Conversation.Topic}}> |
| -{{range .Conversation.Messages}} |
| -<article equipo-message data-message="{{.ID}}"><p equipo-secondary>{{if eq .AuthorKind "person"}}{{.AuthorID}}{{else if eq .AuthorKind "coordinator"}}{{copy "conversation.coordinator"}}{{else if eq .AuthorKind "specialist"}}{{.AuthorID}}{{else}}{{copy "brand"}}{{end}}</p><p equipo-message-body>{{.Body}}</p> |
| +<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}} |
| +{{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-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}} |
| {{end}} |
| -</article> |
| -{{else}}<p data-empty-state="conversation.empty">{{copy "conversation.empty"}}</p>{{end}} |
| -{{range .Conversation.Cards}}{{template "conversation-card" .}}{{end}} |
| -{{if .Conversation.NextURL}}<a href="{{.Conversation.NextURL}}">{{copy "conversation.more"}}</a>{{end}} |
| +</div></li> |
| +{{end}}{{else}}{{with .Card}}<li equipo-feed-card data-entry="{{.ID}}" data-sequence="{{.Sequence}}">{{template "conversation-card" .}}</li>{{end}}{{end}} |
| +{{else}}<li data-empty-state="conversation.empty">{{copy "conversation.empty"}}</li>{{end}} |
| +</ol> |
| </section> |
| {{end}} |
| {{define "conversation-card"}} |
| <article equipo-card data-card="{{.ID}}"> |
| -{{with .Plan}} |
| -<h2><a href="/tasks/{{.Task.ID}}/plan">{{.Task.Description}}</a></h2> |
| -<p equipo-secondary>{{copy "plan.project"}}: {{.Project}}</p> |
| -<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 .Plan.PlaybookID}}<p equipo-secondary>{{copy "plan.playbook"}}: {{.PlaybookName}} <span equipo-value>{{.Plan.PlaybookRevision}}</span></p>{{end}} |
| -<ol equipo-plan-steps>{{range .Steps}}<li equipo-plan-step><strong>{{if .Specialist}}{{copy (printf "nav.%s" .Specialist)}}{{else}}{{copy (printf "plan.action.%s" .Action)}}{{end}}</strong><span equipo-secondary>{{copy (printf "plan.action.%s" .Action)}}</span><span equipo-badge>{{copy (printf "step.%s" .State)}}</span><span equipo-value>{{.Model}} {{.Account}}</span>{{if .Pick}}<span equipo-value>{{.Pick.Model}} {{.Pick.Account}}</span><span equipo-secondary>{{copy .Pick.Reason}}</span>{{end}}{{if .SelectionReason}}<span equipo-secondary title="{{.SelectionReason}}">{{.SelectionReason}}</span>{{end}}{{if .Actual}}<span equipo-secondary>{{copy "task.actual"}}: {{.Actual}}</span>{{end}}</li>{{end}}</ol> |
| -<a href="/tasks/{{.Task.ID}}/plan#project">{{copy "plan.correct_project"}}</a> <a href="/tasks/{{.Task.ID}}/plan">{{copy "plan.edit"}}</a> <a href="/tasks/{{.Task.ID}}/thread">{{copy "conversation.thread_link"}}</a> |
| +{{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 .NativeQuestion}} |
| +<h2>{{copy "task.questions"}}</h2>{{if not .Fields}}<pre>{{.Text}}</pre>{{end}} |
| +<span equipo-badge>{{copy (printf "question.%s" .State)}}</span> |
| +{{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}} |
| {{end}} |
| {{with .Question}} |
| <h2>{{.Prompt}}</h2><span equipo-badge>{{copy (printf "question.%s" .State)}}</span> |
| @@ -43,3 +54,17 @@ |
| {{if eq .Kind "suggest_preference"}}<a href="/preferences">{{copy "preferences.title"}}</a>{{end}} |
| </article> |
| {{end}} |
| + |
| +{{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> |
| +{{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 .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}} |
| +</div> |
| +{{end}} |
diff --git a/internal/equipo/templates/thread.html b/internal/equipo/templates/thread.html| index 37fc17b8..5e816434 100644 |
| --- a/internal/equipo/templates/thread.html |
| +++ b/internal/equipo/templates/thread.html |
| @@ -3,9 +3,11 @@ |
| {{define "up"}}/tasks/{{.Conversation.ThreadID}}{{end}} |
| {{define "content"}} |
| <div equipo-conversation> |
| -<h1>{{copy "conversation.thread_link"}}</h1><p equipo-muted>{{copy "conversation.shared_thread"}}</p> |
| +<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> |
| -{{template "region:conversation-feed" .}} |
| -{{template "conversation-composer" .}} |
| +</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" .}} |
| </div> |
| {{end}} |
diff --git a/internal/equipotest/browser_test.go b/internal/equipotest/browser_test.go| index 4a90b655..b314a934 100644 |
| --- a/internal/equipotest/browser_test.go |
| +++ b/internal/equipotest/browser_test.go |
| @@ -56,14 +56,8 @@ func TestFoundationBrowserWalk(t *testing.T) { |
| return err |
| })) |
| t.Logf("scripts disabled: %t", noJS) |
| - c := signinClient(t, rig.Origin) |
| - signinEmail(t, c, rig.Origin, rig.Origin, mailer, ownerAddress) |
| - for _, cookie := range c.Jar.Cookies(mustURL(t, rig.Origin)) { |
| - rig.Run(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error { |
| - _, err := cdp.Call(ctx, target, network.SetCookie, network.SetCookieParams{Name: cookie.Name, Value: cookie.Value, URL: rig.Origin, Path: "/"}) |
| - return err |
| - })) |
| - } |
| + browserSignin(t, rig, mailer) |
| + |
| check := func(expression, reason string) { |
| t.Helper() |
| ok := harness.Evaluate[bool](rig, expression) |
| @@ -88,26 +82,13 @@ func TestFoundationBrowserWalk(t *testing.T) { |
| rig.Run(browserClick(selector), browserWait(fmt.Sprintf(`location.pathname + location.hash === %q`, path))) |
| screen(path) |
| } |
| - shot := func(name string) { |
| - t.Helper() |
| - dir := os.Getenv("EQUIPO_BROWSER_ARTIFACTS") |
| - if dir == "" { |
| - return |
| - } |
| - if err := os.MkdirAll(dir, 0700); err != nil { |
| - t.Fatal(err) |
| - } |
| - png := harness.Read(rig, chromedp.CaptureScreenshot()) |
| - if err := os.WriteFile(filepath.Join(dir, name+".png"), png, 0600); err != nil { |
| - t.Fatal(err) |
| - } |
| - } |
| + shot := func(name string) { browserScreenshot(t, rig, name) } |
| for _, width := range []int64{1280, 390} { |
| rig.Run(chromedp.EmulateViewport(width, 900)) |
| goTo("/conversation") |
| check(`!!document.querySelector('[data-empty-state]')`, "missing conversation empty state") |
| shot(fmt.Sprintf("empty-%d", width)) |
| - for i, path := range railPaths { |
| + for _, path := range railPaths { |
| if width == 390 { |
| goTo("/work") |
| } |
| @@ -135,7 +116,7 @@ func TestFoundationBrowserWalk(t *testing.T) { |
| })) |
| screen("specialist parent reloaded") |
| } |
| - if i == 0 { |
| + if path == "/conversation" { |
| check(`!!document.querySelector('[data-empty-state]')`, "empty destination missing") |
| } |
| } |
| @@ -224,3 +205,31 @@ func browserClick(selector string) chromedp.Action[chromedp.Void] { |
| 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) |
| + signinEmail(t, c, rig.Origin, rig.Origin, mailer, ownerAddress) |
| + for _, cookie := range c.Jar.Cookies(mustURL(t, rig.Origin)) { |
| + rig.Run(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error { |
| + _, err := cdp.Call(ctx, target, network.SetCookie, network.SetCookieParams{Name: cookie.Name, Value: cookie.Value, URL: rig.Origin, Path: "/"}) |
| + return err |
| + })) |
| + } |
| +} |
diff --git a/internal/equipotest/chat_browser_test.go b/internal/equipotest/chat_browser_test.go| new file mode 100644 |
| index 00000000..15509d7d |
| --- /dev/null |
| +++ b/internal/equipotest/chat_browser_test.go |
| @@ -0,0 +1,139 @@ |
| +//go:build browser |
| + |
| +package equipotest |
| + |
| +import ( |
| + "context" |
| + "fmt" |
| + "net/http" |
| + "os" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo" |
| + "amadan.net/rastrillo/rastrillo/harness" |
| + "github.com/chromedp/cdproto/cdp" |
| + "github.com/chromedp/cdproto/emulation" |
| + "github.com/chromedp/chromedp" |
| + "github.com/chromedp/chromedp/kb" |
| +) |
| + |
| +func TestChatBrowser(t *testing.T) { |
| + f, _ := questionFixture(t) |
| + task := f.a.TaskID |
| + 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} { |
| + for i, body := range []string{"The invoice total changes after adding delivery.", "I’ll trace the calculation and ask Engineering to reproduce it.", "Please keep the existing tax rules.", "The reproduction is ready. Delivery is being counted twice.", "Include a check for invoices without delivery too.", "Engineering is adding that check before the independent review."} { |
| + m, err := f.s.SendMessage(connectionContext, ownerActor, thread, body, equipo.Mutation{RequestID: fmt.Sprintf("seed-%s-%d", thread, i)}) |
| + executionMust(t, err) |
| + if i%2 == 1 { |
| + kind, author := "coordinator", "coordinator" |
| + if thread != "" { |
| + kind, author = "specialist", "engineering" |
| + } |
| + mustSQL(t, f.d, "UPDATE conversation_messages SET author_kind=?,author_id=? WHERE id=?", kind, author, m.ID) |
| + } |
| + mustSQL(t, f.d, "UPDATE conversation_messages SET created_at=? WHERE id=?", fmt.Sprintf("2026-11-05 10:%02d:00", i), m.ID) |
| + } |
| + } |
| + mustSQL(t, f.d, "INSERT INTO conversation_cards(id,stream_id,kind,resource_id,sequence,revision) SELECT 'chat-task',id,'task',?,2,1 FROM conversations WHERE person=?", task, ownerAddress) |
| + mailer := &capturingMailer{} |
| + var router http.Handler |
| + rig := harness.New(t, func(origin string) http.Handler { |
| + cfg := testConfig(origin) |
| + cfg.AlwaysOn = true |
| + var err error |
| + router, err = equipo.RouterWithStore(f.d, cfg, mailer, nil, f.s) |
| + executionMust(t, err) |
| + mux := http.NewServeMux() |
| + mux.Handle("/mockups/", http.StripPrefix("/mockups/", http.FileServer(http.Dir("../../docs/mockups")))) |
| + mux.Handle("/", equipo.Mux(router)) |
| + return mux |
| + }, harness.WithScrollbars()) |
| + t.Cleanup(func() { equipo.CloseLive(router) }) |
| + noJS := os.Getenv("EQUIPO_BROWSER_NO_JS") == "1" |
| + rig.Run(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error { |
| + _, err := cdp.Call(ctx, target, emulation.SetScriptExecutionDisabled, emulation.SetScriptExecutionDisabledParams{Value: noJS}) |
| + if err != nil { |
| + return err |
| + } |
| + _, err = cdp.Call(ctx, target, emulation.SetEmulatedMedia, emulation.SetEmulatedMediaParams{Features: []*emulation.MediaFeature{{Name: "prefers-reduced-motion", Value: "reduce"}}}) |
| + 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) } |
| + 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")`)) |
| + shot(fmt.Sprintf("%s-%d", screen.name, width)) |
| + if baseline { |
| + continue |
| + } |
| + check(`document.documentElement.scrollWidth<=innerWidth`, "horizontal overflow") |
| + 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") |
| + } |
| + 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`)) |
| + check(`document.querySelector('#conversation-feed').textContent.includes('Scriptless reply')`, "scriptless reply missing") |
| + continue |
| + } |
| + check(`document.querySelectorAll('[equipo-message="incoming"] .icon').length>=3`, "missing sender icons") |
| + harness.Evaluate[bool](rig, `(window.chatDocument=true)`) |
| + thread := "" |
| + if screen.name == "thread" { |
| + thread = task |
| + } |
| + liveText := fmt.Sprintf("Live reply %s %d", screen.name, width) |
| + 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))) |
| + 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`)) |
| + _, 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"))) |
| + 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')`)) |
| + 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") |
| + } |
| + if baseline { |
| + for _, name := range []string{"conversation", "nav", "journey", "native"} { |
| + rig.Run(chromedp.Navigate(rig.Origin + "/mockups/" + name + ".html")) |
| + shot(fmt.Sprintf("mockup-%s-%d", name, width)) |
| + } |
| + } |
| + } |
| + if !baseline && !noJS { |
| + 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')`)) |
| + } |
| + |
| +} |
diff --git a/internal/equipotest/task_browser_test.go b/internal/equipotest/task_browser_test.go| index 2477bf8d..d80cd471 100644 |
| --- a/internal/equipotest/task_browser_test.go |
| +++ b/internal/equipotest/task_browser_test.go |
| @@ -7,7 +7,6 @@ import ( |
| "fmt" |
| "net/http" |
| "os" |
| - "path/filepath" |
| "strings" |
| "testing" |
| @@ -15,7 +14,6 @@ import ( |
| "amadan.net/rastrillo/rastrillo/harness" |
| "github.com/chromedp/cdproto/cdp" |
| "github.com/chromedp/cdproto/emulation" |
| - "github.com/chromedp/cdproto/network" |
| "github.com/chromedp/chromedp" |
| "github.com/chromedp/chromedp/kb" |
| ) |
| @@ -46,14 +44,8 @@ func TestRunnerTaskBrowserWalk(t *testing.T) { |
| _, err := cdp.Call(ctx, target, emulation.SetEmulatedMedia, emulation.SetEmulatedMediaParams{Features: []*emulation.MediaFeature{{Name: "prefers-reduced-motion", Value: "no-preference"}}}) |
| return err |
| })) |
| - c := signinClient(t, rig.Origin) |
| - signinEmail(t, c, rig.Origin, rig.Origin, mailer, ownerAddress) |
| - for _, cookie := range c.Jar.Cookies(mustURL(t, rig.Origin)) { |
| - rig.Run(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error { |
| - _, err := cdp.Call(ctx, target, network.SetCookie, network.SetCookieParams{Name: cookie.Name, Value: cookie.Value, URL: rig.Origin, Path: "/"}) |
| - return err |
| - })) |
| - } |
| + browserSignin(t, rig, mailer) |
| + |
| check := func(expression, reason string) { |
| t.Helper() |
| if !harness.Evaluate[bool](rig, expression) { |
| @@ -69,10 +61,8 @@ func TestRunnerTaskBrowserWalk(t *testing.T) { |
| check(`document.querySelectorAll('[aria-current="page"]').length===1`, "one active destination") |
| } |
| rig.Screen("body", fmt.Sprintf("task16 %s %d", path, width)) |
| - if dir := os.Getenv("EQUIPO_BROWSER_ARTIFACTS"); dir != "" && path == "/journey" { |
| - executionMust(t, os.MkdirAll(dir, 0700)) |
| - png := harness.Read(rig, chromedp.CaptureScreenshot()) |
| - executionMust(t, os.WriteFile(filepath.Join(dir, fmt.Sprintf("task16-%d.png", width)), png, 0600)) |
| + if path == "/journey" { |
| + browserScreenshot(t, rig, fmt.Sprintf("task16-%d", width)) |
| } |
| } |
| rig.Run(chromedp.SendKeys(chromedp.CSS(`[name="description"]`), "Keep my draft")) |
diff --git a/internal/plan3test/conversation_layout_browser_test.go b/internal/plan3test/conversation_layout_browser_test.go| index 85c126be..b99d2600 100644 |
| --- a/internal/plan3test/conversation_layout_browser_test.go |
| +++ b/internal/plan3test/conversation_layout_browser_test.go |
| @@ -46,7 +46,7 @@ func TestConversationLayout(t *testing.T) { |
| for _, scale := range []int{100, 200} { |
| rig.Run(chromedp.EmulateViewport(width, 900), chromedp.Navigate(rig.Origin+"/conversation")) |
| harness.Evaluate[bool](rig, fmt.Sprintf(`(document.documentElement.style.fontSize='%d%%',true)`, scale)) |
| - if !harness.Evaluate[bool](rig, `document.documentElement.scrollWidth<=innerWidth && getComputedStyle(document.querySelector('[equipo-conversation]')).display==='block'`) { |
| + if !harness.Evaluate[bool](rig, `document.documentElement.scrollWidth<=innerWidth && getComputedStyle(document.querySelector('[equipo-conversation]')).flexDirection==='column'`) { |
| t.Fatal("conversation overflow or split screen") |
| } |
| if !harness.Evaluate[bool](rig, `Array.from(document.querySelectorAll('[equipo-value],[equipo-badge]')).every(e=>getComputedStyle(e).whiteSpace==='nowrap')`) { |
| @@ -69,6 +69,25 @@ func TestConversationLayout(t *testing.T) { |
| if !harness.Evaluate[bool](rig, `document.activeElement.matches('#composer textarea') && document.activeElement.value==='Keep this draft'`) { |
| t.Fatal("live invalidation lost composer draft or focus") |
| } |
| + |
| + if width == 390 && scale == 100 { |
| + for i := 0; i < 8; i++ { |
| + _, err = f.Store.SendMessage(ctx, owner, "", fmt.Sprintf("Warm history %d", i), equipo.Mutation{RequestID: fmt.Sprintf("warm-%d", i)}) |
| + must(t, err) |
| + } |
| + rig.Run(conversationBrowserWait(`document.querySelector('#conversation-feed').textContent.includes('Warm history 7') && document.querySelector('[equipo-scroll]').scrollHeight>document.querySelector('[equipo-scroll]').clientHeight`)) |
| + |
| + harness.Evaluate[bool](rig, `(()=>{const s=document.querySelector('[equipo-scroll]');s.scrollTop=0;s.dispatchEvent(new Event('scroll'));return true})()`) |
| + harness.Evaluate[bool](rig, fmt.Sprintf(`(window.readOffset=document.querySelector('[data-message="%s"]').getBoundingClientRect().top,true)`, msg.ID)) |
| + for i := 0; i < 55; i++ { |
| + _, err = f.Store.SendMessage(ctx, owner, "", fmt.Sprintf("History arrival %d", i), equipo.Mutation{RequestID: fmt.Sprintf("history-%d", i)}) |
| + must(t, err) |
| + } |
| + rig.Run(conversationBrowserWait(`document.querySelector('#conversation-feed').textContent.includes('History arrival 54')`)) |
| + if !harness.Evaluate[bool](rig, fmt.Sprintf(`!!document.querySelector('[data-message="%s"]') && Math.abs(document.querySelector('[data-message="%s"]').getBoundingClientRect().top-window.readOffset)<3`, msg.ID, msg.ID)) { |
| + t.Fatalf("live window discarded the message being read: %s", harness.Evaluate[string](rig, fmt.Sprintf(`JSON.stringify({present:!!document.querySelector('[data-message="%s"]'),before:window.readOffset,after:document.querySelector('[data-message="%s"]')?.getBoundingClientRect().top,top:document.querySelector('[equipo-scroll]').scrollTop,items:Array.from(document.querySelector('[equipo-feed]').children).slice(0,5).map(e=>[e.dataset.sequence,e.dataset.message,e.dataset.entry,e.getBoundingClientRect().top])})`, msg.ID, msg.ID))) |
| + } |
| + } |
| rig.Run(chromedp.Navigate(rig.Origin + "/tasks/" + p.TaskID + "/plan")) |
| harness.Evaluate[bool](rig, fmt.Sprintf(`(document.documentElement.style.fontSize='%d%%',true)`, scale)) |
| if !harness.Evaluate[bool](rig, `document.documentElement.scrollWidth<=innerWidth`) { |
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json| index 66acd09b..c63c27d7 100644 |
| --- a/scripts/runner-reference-allowlist.json |
| +++ b/scripts/runner-reference-allowlist.json |
| @@ -9385,5 +9385,33 @@ |
| "match": "equipo-runner", |
| "count": 2, |
| "reason": "Byte-identical hashed live-gate evidence; records provider observations and isolation restrictions, not an execution dependency." |
| + }, |
| + { |
| + "path": "docs/superpowers/plans/CODEX-BRIEF-chat-ui.md", |
| + "line_sha256": "0769b6ce2935c4da1306d6f6d8a4cc8e7826080a82725d8b1f5ff22f61379bd4", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Task dispatch names the directories excluded from this UI change." |
| + }, |
| + { |
| + "path": "internal/equipo/static/chat.js", |
| + "line_sha256": "afa951e086ad42e65bc51663cbac48c33ca713fd4bbe50a9bae7d755d842e2ec", |
| + "match": "Node", |
| + "count": 1, |
| + "reason": "Browser DOM addedNodes property used to detect a refreshed chat region." |
| + }, |
| + { |
| + "path": "internal/equipo/templates/conversation_card.html", |
| + "line_sha256": "af70ff17a569602411e59a3b483248febd8ae23d69b76e68ea725e2ca4041a39", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Reuse the existing isolation disclosure partial in the chat task card." |
| + }, |
| + { |
| + "path": "internal/equipo/static/chat.js", |
| + "line_sha256": "73f18843ca820217c888c60e5b37c62380e8fc49cb2f167614c923438a6b2441", |
| + "match": "Node", |
| + "count": 1, |
| + "reason": "Browser DOM removedNodes property retains older visible messages during live refresh." |
| } |
| ] |