web: one Build per option, labelled captures, directions shown
Design feedback 1, Task 5 (spec 8.1 to 8.4, web side).
- galleryOf(taskID, rounds, open, cardID, revision) builds the gallery
from wire.DirectionRound, newest first. Each option carries Label,
Direction, Step, Index (from 0, as wire.OptionRef) and Live (Task 12
fills it).
- On an open direction card, and in the task page's decision, every
option whose round names its maker step gets a scriptless form that
posts choice=build or choice=like with option_step and option_index
to the card-answer route. More like this posts straight away with no
note, and shows only when the card's Options list "like".
- Card-level answers: More options (choice=more) is one submit button
on the card. On the task page it shares the decision's optional note.
Try again and Drop it are unchanged. When options have their own
Build, the card's Build button is left out. The
<details data-direction-build> note composer is gone from the web
card.
- The card shows only the newest round, plus a quiet link to the task
page when earlier rounds exist. The task page lists every round,
newest first, with a rule between rounds.
- Captions: "Dashboard, desktop" and "Dashboard, phone, full page".
With no label but a known viewport, "Desktop"; with neither, the tree
caption as before. Alt text is "<option name>: <caption>".
- The direction (Design's words) appears as escaped plain text under
the option's name, in a quiet style. All styling is in equipo.css and
uses existing tokens; there are no left borders.
- Directions recorded before rounds show as one round. No answer can
name those options, so the card keeps its plain Build.
- Copy, all marked pending with copy-status.py: work.captures.caption,
.full_page, .viewport.{phone,tablet,desktop}, .earlier,
chat.card.like, and chat.card.more_options. That last one is not
chat.card.more, which already exists ("More", the receipt menu's
label). work.captures.alt changes to "%s: %s".
TDD evidence
- Test command:
go test ./internal/equipo/ -run 'TestCaption|TestCard|TestDirectionShown|TestTaskPageRounds'
- Red: before the views existed, the build failed (galleryOf had too
many arguments; no Rounds or Caption field). With the views in place
and the templates still old, it failed for these reasons:
TestCardPerOptionBuild found 0 option forms, want 3.
TestCardMoreButtons found 1 More like this, want 3.
TestDirectionShown: the direction was not under the name.
TestTaskPageRounds found 0 option forms, want 6.
- Green: those tests pass, and so do the whole internal/equipo package
and go vet.
- Mutations (each applied, the test run, then reverted):
full-page suffix dropped: TestCaptionLabelViewport and
TestDirectionShown fail
sentenceCase dropped: TestCaptionOldReport fails
label+viewport case removed: TestCaptionLabelViewport fails
alt built without the caption: six capture tests fail
viewport word replaced by the raw value: TestCaptionOldReport fails
("watch")
newest() made a no-op: TestCardPerOptionBuild and TestCardMoreButtons
fail
perOption() never true: TestCardPerOptionBuild and TestTaskPageRounds
fail
answered card given a gallery: TestCardPerOptionBuild fails
Like always true: TestCardMoreButtons fails
decision keeps "like": TestTaskPageRounds fails
decision keeps "build": TestTaskPageRounds fails
BuildNote ignores per-option Build: TestTaskPageRounds fails
(note required)
decision built from legacy Options: TestTaskPageRounds fails
template drops the direction: TestDirectionShown fails
template ignores the Step guard: TestConversationDirectionCardOptions
fails
Earlier link hidden: TestCardPerOptionBuild fails
card keeps its Build: TestCardPerOptionBuild fails
More options value changed: TestCardMoreButtons fails
One redundant guard was found and removed: a viewport whitelist
switch, whose mutation passed because unknown viewports have no copy
key.
- Browser: TestBrowserDirectionCard (build tag browser) serves the card
and the task decision on httptest at 127.0.0.1 with the app's CSS,
using headless chromium through chromedp. It checks for no horizontal
overflow and for every Build being visible at 390x844 and 1280x900.
It passes. Screenshots (EQUIPO_DIRECTION_SHOTS) are in the SDD
workspace:
.superpowers/sdd/2026-11-30-design-feedback-1/task-5-shots/
direction-card-phone.png, direction-card-desktop.png,
direction-task-phone.png, direction-task-desktop.png
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 files changed,
+582
−57
docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+9 −1internal/equipo/chat_page.go+15 −5internal/equipo/copy.go+12 −1internal/equipo/design_views.go+126 −30internal/equipo/design_views_test.go+54 −13internal/equipo/direction_card_browser_test.go+132 −0internal/equipo/direction_card_test.go+195 −0internal/equipo/static/equipo.css+11 −0internal/equipo/templates/chat.html+1 −1internal/equipo/templates/work_parts.html+5 −3internal/equipo/work_views.go+22 −3
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index fe8e3715..a6706513 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -7209,7 +7209,7 @@ records remain unchanged. |
| | `work.design.design_renderer` | Waiting for the runner’s page renderer. Updating the runner fixes it. | Task page, waiting step line (renderer status) (dynamic specialists slice 1, 2026-11-29) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) | |
| | `work.design.design_no_claude` | Waiting for a Claude connection on the runner. Design works only with Claude. | Task page, waiting step line (renderer status) (dynamic specialists slice 1, 2026-11-29) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) | |
| | `work.captures.option` | Option %d: %s | Task page and direction card, Design's screenshots (dynamic specialists slice 1, 2026-11-29) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) | |
| -| `work.captures.alt` | %s, screenshot %d | Task page and direction card, Design's screenshots (dynamic specialists slice 1, 2026-11-29) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) | |
| +| `work.captures.alt` | %s: %s | Copy specialist | COPY REVIEW PENDING | |
| | `work.captures.none` | No screenshots of this option. | Task page and direction card, Design's screenshots (dynamic specialists slice 1, 2026-11-29) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) | |
| | `work.captures.tree.work` | Mockup | Task page and direction card, Design's screenshots (dynamic specialists slice 1, 2026-11-29) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) | |
| | `work.captures.tree.base` | Before | Task page and direction card, Design's screenshots (dynamic specialists slice 1, 2026-11-29) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) | |
| @@ -7220,6 +7220,14 @@ records remain unchanged. |
| | `api.direction_note` | Say which option to build. Open this card on the web to add your note. | Direction card (dynamic specialists slice 1, 2026-11-29) | COPY APPROVED (Paul, 2026-11-29, copy-review v4fsltihakfhehduzju7dgu47m, unchanged) | |
| | `work.explore.build_note` | %s said which option to build in their own words: %s | Build task brief (dynamic specialists slice 1, 2026-11-29) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) | |
| | `chat.activity.ask_design_taste` | Asking about the look you want… | Copy specialist | COPY REVIEW PENDING | |
| +| `work.captures.caption` | %s, %s | Copy specialist | COPY REVIEW PENDING | |
| +| `work.captures.full_page` | , full page | Copy specialist | COPY REVIEW PENDING | |
| +| `work.captures.viewport.phone` | phone | Copy specialist | COPY REVIEW PENDING | |
| +| `work.captures.viewport.tablet` | tablet | Copy specialist | COPY REVIEW PENDING | |
| +| `work.captures.viewport.desktop` | desktop | Copy specialist | COPY REVIEW PENDING | |
| +| `work.captures.earlier` | Earlier options are on the task page | Copy specialist | COPY REVIEW PENDING | |
| +| `chat.card.more_options` | More options | Copy specialist | COPY REVIEW PENDING | |
| +| `chat.card.like` | More like this | Copy specialist | COPY REVIEW PENDING | |
| ## Task 21 |
diff --git a/internal/equipo/chat_page.go b/internal/equipo/chat_page.go| index e79fe688..1ea0b18b 100644 |
| --- a/internal/equipo/chat_page.go |
| +++ b/internal/equipo/chat_page.go |
| @@ -6,6 +6,7 @@ import ( |
| "errors" |
| "fmt" |
| "net/http" |
| + "slices" |
| "strconv" |
| "strings" |
| "time" |
| @@ -113,10 +114,11 @@ type chatCard struct { |
| // PlaceChoices are a place card's candidates in the card's order, each |
| // labelled from code-derived console and account words. |
| PlaceChoices []placeChoice |
| - // Gallery is an open direction card's kept Design captures, by |
| - // option; with more than one, BuildNote: Build this takes a note. |
| - Gallery *designGallery |
| - BuildNote bool |
| + // Gallery is an open direction card's newest kept Design round, by |
| + // option; OptionBuild: each option has its own Build this one, so |
| + // the card's answers leave theirs out. |
| + Gallery *designGallery |
| + OptionBuild bool |
| } |
| // placeChoice is one button of a place card. |
| @@ -255,7 +257,12 @@ func cardView(c wire.Card, choices []string, tasks map[string]wire.Task) chatCar |
| case wire.CardDirection: |
| v.Line, v.Open = c.Question, c.State == wire.CardOpen |
| if t, ok := tasks[c.TaskID]; ok && v.Open && t.Direction != nil { |
| - v.Gallery, v.BuildNote = galleryOf(c.TaskID, t.Direction.Options), t.Direction.NoteNeeded |
| + v.Gallery = galleryOf(c.TaskID, directionRounds(t.Direction), true, c.ID, c.Revision) |
| + v.Gallery.newest(c.TaskID) |
| + if v.Gallery != nil { |
| + v.Gallery.Answer.Like = slices.Contains(c.Options, wire.ChoiceLike) |
| + } |
| + v.OptionBuild = v.Gallery.perOption() |
| } |
| switch { |
| case c.State == wire.CardAnswered: |
| @@ -635,6 +642,9 @@ func (a *application) jobPage(w http.ResponseWriter, r *http.Request) { |
| for _, cards := range [][]chatCard{view.Messages[i].Cards, view.Messages[i].Receipts} { |
| for k := range cards { |
| cards[k].Job = id |
| + if g := cards[k].Gallery; g != nil && g.Answer != nil { |
| + g.Answer.Job = id |
| + } |
| } |
| } |
| } |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index 9d1e2d49..2e45751f 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -2053,7 +2053,7 @@ var pageCopy = map[string]string{ |
| // Dynamic specialists slice 1, task 19: Design's captures on the task |
| // page and the direction card, and Build this's note. |
| "work.captures.option": "Option %d: %s", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) |
| - "work.captures.alt": "%s, screenshot %d", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) |
| + "work.captures.alt": "%s: %s", // COPY REVIEW PENDING |
| "work.captures.none": "No screenshots of this option.", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) |
| "work.captures.tree.work": "Mockup", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) |
| "work.captures.tree.base": "Before", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) |
| @@ -2064,6 +2064,17 @@ var pageCopy = map[string]string{ |
| "api.direction_note": "Say which option to build. Open this card on the web to add your note.", // COPY APPROVED (Paul, 2026-11-29, copy-review v4fsltihakfhehduzju7dgu47m, unchanged) |
| "work.explore.build_note": "%s said which option to build in their own words: %s", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-29) |
| + // Design feedback 1, task 5: capture captions, a link to earlier |
| + // rounds, and More options and More like this on the direction card. |
| + "work.captures.caption": "%s, %s", // COPY REVIEW PENDING |
| + "work.captures.full_page": ", full page", // COPY REVIEW PENDING |
| + "work.captures.viewport.phone": "phone", // COPY REVIEW PENDING |
| + "work.captures.viewport.tablet": "tablet", // COPY REVIEW PENDING |
| + "work.captures.viewport.desktop": "desktop", // COPY REVIEW PENDING |
| + "work.captures.earlier": "Earlier options are on the task page", // COPY REVIEW PENDING |
| + "chat.card.more_options": "More options", // COPY REVIEW PENDING |
| + "chat.card.like": "More like this", // COPY REVIEW PENDING |
| + |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): preferences.title |
| "preferences.title": "Preferences", |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): preferences.confirmed |
diff --git a/internal/equipo/design_views.go b/internal/equipo/design_views.go| index 518a0329..2495b656 100644 |
| --- a/internal/equipo/design_views.go |
| +++ b/internal/equipo/design_views.go |
| @@ -7,50 +7,146 @@ import ( |
| ) |
| // A Design attempt's kept captures as the task page and the direction |
| -// card show them (dynamic specialists spec, sections 3 and 5): grouped by |
| -// option in the report's order, each loaded only from this instance's |
| -// authenticated task-file route. Option names are the specialist's |
| -// labels; the page escapes them like any text. |
| +// card show them (dynamic specialists spec, sections 3, 5 and 8): by |
| +// round, newest first, then by option in the report's order, each |
| +// capture loaded only from this instance's authenticated task-file |
| +// route. Option names, directions and capture labels are Design's words; |
| +// the page escapes them like any text. |
| -// designGallery is what one Design attempt kept, by option. |
| +// designGallery is what Design kept, by round. Earlier, on a direction |
| +// card that shows only the newest round, links the task page, which |
| +// lists them all. Answer, on an open direction card, makes each option |
| +// that names its maker step a form of its own (Build this one, and More |
| +// like this when the card takes it). |
| type designGallery struct { |
| + Rounds []designRoundView |
| + Earlier string |
| + Answer *designAnswer |
| +} |
| + |
| +// designRoundView is one kept round: its maker step and its options. |
| +type designRoundView struct { |
| + Step string |
| Options []designOptionView |
| } |
| -// designOptionView is one option: its label ("Option 1: Calm") and its |
| +// designAnswer is where an option's form posts: the card and its |
| +// revision, the page to return to (From and Task on the task page, Job |
| +// on a job thread), and whether the card takes More like this. |
| +type designAnswer struct { |
| + CardID string |
| + Revision int64 |
| + From, Task, Job string |
| + Like bool |
| +} |
| + |
| +// designOptionView is one option: its label ("Option 1: Calm"), its |
| +// direction (Design's words, "" before protocol 39), the maker step and |
| +// index (from 0, as wire.OptionRef) an answer names it by, its Open live |
| +// link when its round is the deployed preview (Task 12), and its |
| // captures; none when it named none or none was kept. |
| type designOptionView struct { |
| - Label string |
| - Captures []designCaptureView |
| + Label, Direction, Step string |
| + Index int |
| + Live string |
| + Captures []designCaptureView |
| } |
| -// designCaptureView is one kept capture: Src is the task-file route, Alt |
| -// names its option, Tree says which tree it shows. |
| +// designCaptureView is one kept capture: Src is the task-file route, |
| +// Caption says what it shows, Alt names its option too. |
| type designCaptureView struct { |
| - ID, Src, Alt, Tree string |
| - Width, Height int |
| + ID, Src, Alt, Caption string |
| + Width, Height int |
| } |
| -// galleryOf is the gallery of a task's kept options; nil when there are |
| -// none. |
| -func galleryOf(taskID string, opts []wire.StepDesignOption) *designGallery { |
| - if len(opts) == 0 { |
| - return nil |
| - } |
| +// galleryOf is the gallery of a task's kept rounds, newest first as |
| +// given; nil when none kept an option. When open, each option of a round |
| +// that names its step gets its answer form, posting to cardID at |
| +// revision. |
| +func galleryOf(taskID string, rounds []wire.DirectionRound, open bool, cardID string, revision int64) *designGallery { |
| g := &designGallery{} |
| - for i, o := range opts { |
| - ov := designOptionView{Label: fmt.Sprintf(copyText("work.captures.option"), i+1, o.Name)} |
| - for n, c := range o.Captures { |
| - ov.Captures = append(ov.Captures, designCaptureView{ |
| - ID: c.ID, |
| - Src: "/tasks/" + taskID + "/files/" + c.ID, |
| - Alt: fmt.Sprintf(copyText("work.captures.alt"), o.Name, n+1), |
| - Tree: copyText("work.captures.tree." + wire.CaptureTree(c.CaptureID)), |
| - Width: c.Width, |
| - Height: c.Height, |
| - }) |
| + for _, r := range rounds { |
| + if len(r.Options) == 0 { |
| + continue |
| + } |
| + rv := designRoundView{Step: r.Step} |
| + for i, o := range r.Options { |
| + ov := designOptionView{Label: fmt.Sprintf(copyText("work.captures.option"), i+1, o.Name), Direction: o.Direction, Step: r.Step, Index: i} |
| + for _, c := range o.Captures { |
| + caption := captionOf(c) |
| + ov.Captures = append(ov.Captures, designCaptureView{ |
| + ID: c.ID, |
| + Src: "/tasks/" + taskID + "/files/" + c.ID, |
| + Alt: fmt.Sprintf(copyText("work.captures.alt"), o.Name, caption), |
| + Caption: caption, |
| + Width: c.Width, |
| + Height: c.Height, |
| + }) |
| + } |
| + rv.Options = append(rv.Options, ov) |
| } |
| - g.Options = append(g.Options, ov) |
| + g.Rounds = append(g.Rounds, rv) |
| + } |
| + if len(g.Rounds) == 0 { |
| + return nil |
| + } |
| + if open && cardID != "" { |
| + g.Answer = &designAnswer{CardID: cardID, Revision: revision} |
| } |
| return g |
| } |
| + |
| +// directionRounds are a direction's kept rounds; a direction from before |
| +// they were recorded shows its options as one round no answer can name. |
| +func directionRounds(d *wire.TaskDirection) []wire.DirectionRound { |
| + if len(d.Rounds) > 0 || len(d.Options) == 0 { |
| + return d.Rounds |
| + } |
| + return []wire.DirectionRound{{Options: d.Options}} |
| +} |
| + |
| +// newest keeps only the newest round, for the direction card; Earlier |
| +// then links the task page, which lists every round. |
| +func (g *designGallery) newest(taskID string) { |
| + if g != nil && len(g.Rounds) > 1 { |
| + g.Rounds, g.Earlier = g.Rounds[:1], "/tasks/"+taskID |
| + } |
| +} |
| + |
| +// perOption says each option has its own Build this one, so the card's |
| +// answers leave theirs out. |
| +func (g *designGallery) perOption() bool { |
| + if g == nil || g.Answer == nil { |
| + return false |
| + } |
| + for _, r := range g.Rounds { |
| + if r.Step != "" { |
| + return true |
| + } |
| + } |
| + return false |
| +} |
| + |
| +// captionOf says what a capture shows: its label and viewport, then |
| +// ", full page" when it is one ("Dashboard, phone, full page"). A report |
| +// from before labels shows its viewport when known ("Desktop"), else |
| +// which tree the capture is of, as before. |
| +func captionOf(c wire.StepCapture) string { |
| + // A viewport the runner never records has no word, so it is unknown. |
| + view := copyText("work.captures.viewport." + c.Viewport) |
| + var s string |
| + switch { |
| + case c.Label != "" && view != "": |
| + s = fmt.Sprintf(copyText("work.captures.caption"), c.Label, view) |
| + case c.Label != "": |
| + s = c.Label |
| + case view != "": |
| + s = sentenceCase(view) |
| + default: |
| + return copyText("work.captures.tree." + wire.CaptureTree(c.CaptureID)) |
| + } |
| + if c.FullPage { |
| + s += copyText("work.captures.full_page") |
| + } |
| + return s |
| +} |
diff --git a/internal/equipo/design_views_test.go b/internal/equipo/design_views_test.go| index fd0e5c32..7059353a 100644 |
| --- a/internal/equipo/design_views_test.go |
| +++ b/internal/equipo/design_views_test.go |
| @@ -27,7 +27,7 @@ func galleryWants(task string) []string { |
| return []string{ |
| "Option 1: Calm", "Option 2: Bold", "Option 3: Plain", copyText("work.captures.none"), |
| `src="/tasks/` + task + `/files/tf_calm1"`, `src="/tasks/` + task + `/files/tf_bold"`, |
| - `alt="Calm, screenshot 2"`, `width="1440" height="900"`, |
| + `alt="Calm: What changed"`, `width="1440" height="900"`, |
| "<figcaption>" + copyText("work.captures.tree.work") + "</figcaption>", "<figcaption>" + copyText("work.captures.tree.diff") + "</figcaption>", |
| } |
| } |
| @@ -101,11 +101,12 @@ func TestDirectionDecisionShowsOptions(t *testing.T) { |
| } |
| } |
| -// TestConversationDirectionCardBuildNote: the conversation's direction |
| -// card shows the captures; with more than one option Build this is a |
| -// form of its own whose note is required, and the card has no bare |
| -// Build button. |
| -func TestConversationDirectionCardBuildNote(t *testing.T) { |
| +// TestConversationDirectionCardOptions: the conversation's direction |
| +// card shows the captures. A direction without kept rounds (from before |
| +// they were recorded) shows its options with no answer naming one; the |
| +// Build note composer is gone either way (Build this one is per option, |
| +// direction_card_test.go). |
| +func TestConversationDirectionCardOptions(t *testing.T) { |
| render := func(task wire.Task, card *wire.Card) string { |
| t.Helper() |
| v := cardView(*card, nil, map[string]wire.Task{task.ID: task}) |
| @@ -117,18 +118,58 @@ func TestConversationDirectionCardBuildNote(t *testing.T) { |
| } |
| html := render(directionTask(true, designOptions())) |
| mustContain(t, html, galleryWants("tk1")...) |
| - mustContain(t, html, "data-direction-build", `<input type="hidden" name="choice" value="build">`, `<textarea name="note" required maxlength="1000" rows="1" aria-label="`+copyText("chat.card.build_note")+`"`) |
| - if strings.Contains(html, `name="choice" value="build" type="submit"`) { |
| - t.Fatalf("a Build button without the note: %s", html) |
| + if strings.Contains(html, "data-direction-build") || strings.Contains(html, `name="option_step"`) { |
| + t.Fatalf("legacy options: %s", html) |
| } |
| html = render(directionTask(false, designOptions()[:1])) |
| mustContain(t, html, `name="choice" value="build" type="submit"`, "Option 1: Calm") |
| - if strings.Contains(html, "data-direction-build") { |
| - t.Fatalf("one option asks for a note: %s", html) |
| - } |
| // No Design: the card as it was. |
| html = render(directionTask(false, nil)) |
| - if strings.Contains(html, "equipo-captures") || strings.Contains(html, "data-direction-build") { |
| + if strings.Contains(html, "equipo-captures") || strings.Contains(html, "data-direction-build") || !strings.Contains(html, `name="choice" value="build" type="submit"`) { |
| t.Fatalf("no options: %s", html) |
| } |
| } |
| + |
| +// Design feedback 1, Task 5 (spec 8.2): a capture's caption is its label |
| +// and viewport, ", full page" when it is one; an older report shows its |
| +// viewport when known, else the tree caption as before. |
| + |
| +func captionOfCapture(t *testing.T, c wire.StepCapture) designCaptureView { |
| + t.Helper() |
| + g := galleryOf("tk1", []wire.DirectionRound{{Step: "st1", Options: []wire.StepDesignOption{{Name: "Writing desk", Captures: []wire.StepCapture{c}}}}}, false, "", 0) |
| + if g == nil || len(g.Rounds) != 1 || len(g.Rounds[0].Options) != 1 || len(g.Rounds[0].Options[0].Captures) != 1 { |
| + t.Fatalf("gallery %+v", g) |
| + } |
| + return g.Rounds[0].Options[0].Captures[0] |
| +} |
| + |
| +func TestCaptionLabelViewport(t *testing.T) { |
| + c := captionOfCapture(t, wire.StepCapture{ID: "tf_a", CaptureID: "1-work-1.png", Label: "Dashboard", Viewport: "desktop", Path: "/writing-desk/"}) |
| + if c.Caption != "Dashboard, desktop" || c.Alt != "Writing desk: Dashboard, desktop" { |
| + t.Fatalf("caption %q alt %q", c.Caption, c.Alt) |
| + } |
| + c = captionOfCapture(t, wire.StepCapture{ID: "tf_b", CaptureID: "1-work-2.png", Label: "Dashboard", Viewport: "phone", FullPage: true}) |
| + if c.Caption != "Dashboard, phone, full page" || c.Alt != "Writing desk: Dashboard, phone, full page" { |
| + t.Fatalf("full page caption %q alt %q", c.Caption, c.Alt) |
| + } |
| + c = captionOfCapture(t, wire.StepCapture{ID: "tf_c", CaptureID: "1-work-3.png", Label: "Empty inbox", Viewport: "tablet"}) |
| + if c.Caption != "Empty inbox, tablet" { |
| + t.Fatalf("tablet caption %q", c.Caption) |
| + } |
| +} |
| + |
| +func TestCaptionOldReport(t *testing.T) { |
| + if c := captionOfCapture(t, wire.StepCapture{ID: "tf_a", CaptureID: "1-work-1.png", Viewport: "desktop"}); c.Caption != "Desktop" { |
| + t.Fatalf("viewport only: %q", c.Caption) |
| + } |
| + if c := captionOfCapture(t, wire.StepCapture{ID: "tf_a", CaptureID: "1-work-1.png"}); c.Caption != "Mockup" || c.Alt != "Writing desk: Mockup" { |
| + t.Fatalf("nothing known: %q alt %q", c.Caption, c.Alt) |
| + } |
| + if c := captionOfCapture(t, wire.StepCapture{ID: "tf_a", CaptureID: "1-diff-1.png"}); c.Caption != copyText("work.captures.tree.diff") { |
| + t.Fatalf("diff tree: %q", c.Caption) |
| + } |
| + // A viewport the runner never records is not shown as one. |
| + if c := captionOfCapture(t, wire.StepCapture{ID: "tf_a", CaptureID: "1-work-1.png", Viewport: "watch"}); c.Caption != "Mockup" { |
| + t.Fatalf("unknown viewport: %q", c.Caption) |
| + } |
| +} |
diff --git a/internal/equipo/direction_card_browser_test.go b/internal/equipo/direction_card_browser_test.go| new file mode 100644 |
| index 00000000..3e4cf932 |
| --- /dev/null |
| +++ b/internal/equipo/direction_card_browser_test.go |
| @@ -0,0 +1,132 @@ |
| +//go:build browser |
| + |
| +package equipo |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "fmt" |
| + "image" |
| + "image/color" |
| + "image/png" |
| + "net/http" |
| + "net/http/httptest" |
| + "os" |
| + "path/filepath" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| + "amadan.net/rastrillo/rastrillo/harness" |
| + "github.com/chromedp/chromedp" |
| +) |
| + |
| +// TestBrowserDirectionCard renders the direction card and the task |
| +// page's direction decision (Design feedback 1, Task 5) with the app's |
| +// own stylesheets, at phone and desktop width: every option's Build this |
| +// one shows, and nothing is wider than the screen. With |
| +// EQUIPO_DIRECTION_SHOTS set, it saves a screenshot of each there. |
| +func TestBrowserDirectionCard(t *testing.T) { |
| + c := feedbackTask(feedbackRounds()) |
| + var card, decision bytes.Buffer |
| + if err := pages["chat"].ExecuteTemplate(&card, "chat-card", cardView(*c.card, nil, map[string]wire.Task{c.task.ID: c.task})); err != nil { |
| + t.Fatal(err) |
| + } |
| + d := decisionOf(c.task, taskLine{Task: c.task, Card: c.card}) |
| + if err := pages["work_task"].ExecuteTemplate(&decision, "decision", map[string]any{"Task": taskLine{Task: c.task, Decision: d}, "Head": false, "From": "task"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + head := fmt.Sprintf(`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><link rel="stylesheet" href="%s"><link rel="stylesheet" href="%s"><link rel="stylesheet" href="%s"></head><body>`, |
| + assets.Path("static/tokens.css"), assets.Path("static/theme.css"), assets.Path("static/equipo.css")) |
| + docs := map[string]string{ |
| + "/card": head + `<main style="max-inline-size: 48rem; margin-inline: auto; padding: 1rem"><div equipo-conversation><div equipo-scroll><ol equipo-feed>` + card.String() + `</ol></div></div></main></body></html>`, |
| + "/task": head + `<main style="max-inline-size: 64rem; margin-inline: auto; padding: 1rem">` + decision.String() + `</main></body></html>`, |
| + } |
| + shades := []color.RGBA{{0xe8, 0xdf, 0xd0, 0xff}, {0x2b, 0x2f, 0x3a, 0xff}, {0xd9, 0xe4, 0xd6, 0xff}, {0xf1, 0xe6, 0xe9, 0xff}} |
| + sizes := map[string]image.Point{} |
| + for _, r := range feedbackRounds() { |
| + for _, o := range r.Options { |
| + for _, cp := range o.Captures { |
| + sizes[cp.ID] = image.Pt(cp.Width, cp.Height) |
| + } |
| + } |
| + } |
| + mux := http.NewServeMux() |
| + mux.Handle("GET /static/", assets.Handler()) |
| + mux.HandleFunc("GET /tasks/tk1/files/{id}", func(w http.ResponseWriter, r *http.Request) { |
| + size, ok := sizes[r.PathValue("id")] |
| + if !ok { |
| + http.NotFound(w, r) |
| + return |
| + } |
| + img := image.NewRGBA(image.Rect(0, 0, size.X, size.Y)) |
| + id := r.PathValue("id") |
| + shade := shades[int(id[len(id)-1]+id[3])%len(shades)] |
| + for y := range size.Y { |
| + for x := range size.X { |
| + img.Set(x, y, shade) |
| + if y < size.Y/8 { |
| + img.Set(x, y, color.RGBA{0x55, 0x55, 0x55, 0xff}) |
| + } |
| + } |
| + } |
| + w.Header().Set("Content-Type", "image/png") |
| + _ = png.Encode(w, img) |
| + }) |
| + for path, doc := range docs { |
| + mux.HandleFunc("GET "+path, func(w http.ResponseWriter, r *http.Request) { |
| + w.Header().Set("Content-Type", "text/html; charset=utf-8") |
| + fmt.Fprint(w, doc) |
| + }) |
| + } |
| + server := httptest.NewServer(mux) // 127.0.0.1 |
| + defer server.Close() |
| + |
| + opts := append(chromedp.DefaultExecAllocatorOptions[:], chromedp.ExecPath(harness.ChromePath(t)), chromedp.NoSandbox, chromedp.UserDataDir(t.TempDir())) |
| + alloc, stop := chromedp.NewExecAllocator(context.Background(), opts...) |
| + defer stop() |
| + ctx, cancel := chromedp.NewContext(alloc) |
| + defer cancel() |
| + ctx, timeout := context.WithTimeout(ctx, 60*time.Second) |
| + defer timeout() |
| + for _, page := range []string{"card", "task"} { |
| + for _, vp := range []struct { |
| + name string |
| + width, height int64 |
| + }{{"phone", 390, 844}, {"desktop", 1280, 900}} { |
| + if _, err := chromedp.Run(ctx, chromedp.EmulateViewport(vp.width, vp.height)); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := chromedp.Run(ctx, chromedp.Navigate(server.URL+"/"+page)); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := chromedp.Run(ctx, chromedp.Evaluate[bool](`Promise.all([...document.images].map(i => i.decode().catch(() => {}))).then(() => true)`, chromedp.EvalAwaitPromise)); err != nil { |
| + t.Fatal(err) |
| + } |
| + wide, err := chromedp.Run(ctx, chromedp.Evaluate[bool](`document.documentElement.scrollWidth > window.innerWidth`)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + builds, err := chromedp.Run(ctx, chromedp.Evaluate[int](`[...document.querySelectorAll('[data-option-choice="build"]')].filter(b => b.getBoundingClientRect().width > 0).length`)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + want := 3 |
| + if page == "task" { |
| + want = 6 |
| + } |
| + if wide || builds != want { |
| + t.Errorf("%s at %s: wider than the screen %v, %d Build buttons shown, want %d", page, vp.name, wide, builds, want) |
| + } |
| + if dir := os.Getenv("EQUIPO_DIRECTION_SHOTS"); dir != "" { |
| + shot, err := chromedp.Run(ctx, chromedp.FullScreenshot(90)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(filepath.Join(dir, "direction-"+page+"-"+vp.name+".png"), shot, 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + } |
| + } |
| +} |
diff --git a/internal/equipo/direction_card_test.go b/internal/equipo/direction_card_test.go| new file mode 100644 |
| index 00000000..a56dc590 |
| --- /dev/null |
| +++ b/internal/equipo/direction_card_test.go |
| @@ -0,0 +1,195 @@ |
| +package equipo |
| + |
| +import ( |
| + "bytes" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// Design feedback 1, Task 5 (spec 8.1, 8.3, 8.4): each option on the |
| +// direction card and the task page has its own Build this one and More |
| +// like this, scriptless forms naming the option by its maker step and |
| +// its index (from 0, as wire.OptionRef); the card keeps More options, Try |
| +// again and Drop it once. Each option shows its direction, Design's |
| +// words, under its name. The card shows the newest round and says when |
| +// earlier ones exist; the task page lists every round, newest first. |
| + |
| +const directionText = `Warm paper tones, a <b>serif</b> & quiet margins` |
| + |
| +// feedbackRounds are two kept rounds, newest first. |
| +func feedbackRounds() []wire.DirectionRound { |
| + return []wire.DirectionRound{ |
| + {Step: "stnew", Candidate: strings.Repeat("b", 40), Options: []wire.StepDesignOption{ |
| + {Name: "Writing desk", Direction: directionText, Page: "writing-desk", Captures: []wire.StepCapture{ |
| + {ID: "tf_w1", CaptureID: "1-work-1.png", Width: 1440, Height: 900, Label: "Dashboard", Viewport: "desktop", Path: "/writing-desk/"}, |
| + {ID: "tf_w2", CaptureID: "1-work-2.png", Width: 390, Height: 844, Label: "Dashboard", Viewport: "phone", Path: "/writing-desk/", FullPage: true}, |
| + }}, |
| + {Name: "Night shift", Direction: "Dark and dense.", Page: "night-shift", Captures: []wire.StepCapture{{ID: "tf_n1", CaptureID: "2-work-1.png", Width: 1440, Height: 900, Label: "Dashboard", Viewport: "desktop"}}}, |
| + {Name: "Field notes", Direction: "Loose and handwritten.", Page: "field-notes", Captures: []wire.StepCapture{{ID: "tf_f1", CaptureID: "3-work-1.png", Width: 1440, Height: 900, Label: "Dashboard", Viewport: "desktop"}}}, |
| + }}, |
| + {Step: "stold", Candidate: strings.Repeat("a", 40), Options: []wire.StepDesignOption{ |
| + {Name: "Calm", Direction: "Soft.", Page: "calm", Captures: []wire.StepCapture{{ID: "tf_c1", CaptureID: "1-work-1.png", Width: 1440, Height: 900, Label: "Home", Viewport: "desktop"}}}, |
| + {Name: "Bold", Direction: "Loud.", Page: "bold", Captures: []wire.StepCapture{{ID: "tf_b1", CaptureID: "2-work-1.png", Width: 1440, Height: 900, Label: "Home", Viewport: "desktop"}}}, |
| + {Name: "Plain", Direction: "Quiet.", Page: "plain", Captures: []wire.StepCapture{}}, |
| + }}, |
| + } |
| +} |
| + |
| +// feedbackTask is an exploration waiting on its direction card, whose |
| +// answers include More options and More like this. |
| +type directionCase struct { |
| + task wire.Task |
| + card *wire.Card |
| +} |
| + |
| +func feedbackTask(rounds []wire.DirectionRound) directionCase { |
| + card := &wire.Card{ID: "c1", Kind: wire.CardDirection, State: wire.CardOpen, Revision: 2, TaskID: "tk1", Options: []string{wire.ChoiceBuild, wire.ChoiceAgain, wire.ChoiceDrop, wire.ChoiceMore, wire.ChoiceLike}} |
| + opts := rounds[0].Options |
| + return directionCase{wire.Task{ID: "tk1", Creator: "owner@example.com", Stage: wire.StageInReview, Kind: wire.KindExplore, NeedsYou: wire.NeedsDirection, Direction: &wire.TaskDirection{BranchURL: "https://amadan.net/x?branch=y", Options: opts, NoteNeeded: len(opts) > 1, Rounds: rounds}}, card} |
| +} |
| + |
| +func renderDirectionCard(t *testing.T, c directionCase) string { |
| + t.Helper() |
| + task, card := c.task, c.card |
| + v := cardView(*card, nil, map[string]wire.Task{task.ID: task}) |
| + var b bytes.Buffer |
| + if err := pages["chat"].ExecuteTemplate(&b, "chat-card", v); err != nil { |
| + t.Fatal(err) |
| + } |
| + return b.String() |
| +} |
| + |
| +func renderDirectionDecision(t *testing.T, c directionCase) string { |
| + t.Helper() |
| + task, card := c.task, c.card |
| + d := decisionOf(task, taskLine{Task: task, Card: card}) |
| + if d == nil { |
| + t.Fatal("no decision") |
| + } |
| + var b bytes.Buffer |
| + if err := pages["work_task"].ExecuteTemplate(&b, "decision", map[string]any{"Task": taskLine{Task: task, Decision: d}, "Head": false, "From": "task"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + return b.String() |
| +} |
| + |
| +// optionForms are the rendered forms that name an option. |
| +func optionForms(html string) []string { |
| + var out []string |
| + for _, f := range strings.Split(html, "<form")[1:] { |
| + f, _, _ = strings.Cut(f, "</form>") |
| + if strings.Contains(f, `name="option_step"`) { |
| + out = append(out, f) |
| + } |
| + } |
| + return out |
| +} |
| + |
| +func TestCardPerOptionBuild(t *testing.T) { |
| + html := renderDirectionCard(t, feedbackTask(feedbackRounds())) |
| + forms := optionForms(html) |
| + if len(forms) != 3 { |
| + t.Fatalf("%d option forms, want 3 (the newest round's): %s", len(forms), html) |
| + } |
| + for i, f := range forms { |
| + mustContain(t, f, ` method="post" action="/conversation/cards/c1/answer"`, `name="revision" value="2"`, |
| + `name="option_step" value="stnew"`, `name="option_index" value="`+string(rune('0'+i))+`"`, |
| + `name="choice" value="build"`, ">"+copyText("chat.card.build")+"<") |
| + } |
| + if strings.Contains(html, "data-direction-build") || strings.Contains(html, copyText("chat.card.build_note")) { |
| + t.Fatalf("the Build note composer is still there: %s", html) |
| + } |
| + if n := strings.Count(html, `value="build"`); n != 3 { |
| + t.Fatalf("%d Build answers, want one per option and none for the card: %s", n, html) |
| + } |
| + // The card shows the newest round only, and says earlier ones exist. |
| + if strings.Contains(html, "Calm") || strings.Contains(html, "stold") { |
| + t.Fatalf("the card shows an earlier round: %s", html) |
| + } |
| + mustContain(t, html, `href="/tasks/tk1"`, copyText("work.captures.earlier")) |
| + one := feedbackRounds()[:1] |
| + if html := renderDirectionCard(t, feedbackTask(one)); strings.Contains(html, copyText("work.captures.earlier")) { |
| + t.Fatalf("one round says earlier ones exist: %s", html) |
| + } |
| + // An answered card offers nothing. |
| + answered := feedbackTask(feedbackRounds()) |
| + answered.card.State, answered.card.Choice = wire.CardAnswered, wire.ChoiceBuild |
| + if html := renderDirectionCard(t, answered); len(optionForms(html)) != 0 { |
| + t.Fatalf("an answered card has option forms: %s", html) |
| + } |
| +} |
| + |
| +func TestCardMoreButtons(t *testing.T) { |
| + html := renderDirectionCard(t, feedbackTask(feedbackRounds())) |
| + forms := optionForms(html) |
| + for _, f := range forms { |
| + mustContain(t, f, `name="choice" value="like"`, ">"+copyText("chat.card.like")+"<") |
| + } |
| + if n := strings.Count(html, `value="like"`); n != 3 { |
| + t.Fatalf("%d More like this, want one per option: %s", n, html) |
| + } |
| + if n := strings.Count(html, `value="more"`); n != 1 { |
| + t.Fatalf("%d More options, want one: %s", n, html) |
| + } |
| + mustContain(t, html, ">"+copyText("chat.card.more_options")+"<", `name="choice" value="drop"`, "data-direction-thread") |
| + for _, f := range forms { |
| + if strings.Contains(f, `value="more"`) || strings.Contains(f, `value="drop"`) { |
| + t.Fatalf("a card answer inside an option's form: %s", f) |
| + } |
| + } |
| + // A card that does not take them shows neither. |
| + plain := feedbackTask(feedbackRounds()) |
| + plain.card.Options = []string{wire.ChoiceBuild, wire.ChoiceAgain, wire.ChoiceDrop} |
| + html = renderDirectionCard(t, plain) |
| + if strings.Contains(html, `value="like"`) || strings.Contains(html, `value="more"`) || len(optionForms(html)) != 3 { |
| + t.Fatalf("answers the card does not take: %s", html) |
| + } |
| +} |
| + |
| +func TestDirectionShown(t *testing.T) { |
| + escaped := `Warm paper tones, a <b>serif</b> & quiet margins` |
| + for name, html := range map[string]string{ |
| + "card": renderDirectionCard(t, feedbackTask(feedbackRounds())), |
| + "task": renderDirectionDecision(t, feedbackTask(feedbackRounds())), |
| + } { |
| + if strings.Contains(html, "<b>serif") { |
| + t.Fatalf("%s: direction not escaped: %s", name, html) |
| + } |
| + heading, direction, capture := strings.Index(html, "Option 1: Writing desk"), strings.Index(html, escaped), strings.Index(html, "tf_w1") |
| + if heading < 0 || direction < heading || capture < direction { |
| + t.Fatalf("%s: the direction is not under the name (%d, %d, %d): %s", name, heading, direction, capture, html) |
| + } |
| + mustContain(t, html, `<p equipo-direction>`+escaped+`</p>`, "<figcaption>Dashboard, phone, full page</figcaption>", `alt="Writing desk: Dashboard, desktop"`) |
| + } |
| +} |
| + |
| +func TestTaskPageRounds(t *testing.T) { |
| + html := renderDirectionDecision(t, feedbackTask(feedbackRounds())) |
| + newest, earlier := strings.Index(html, "Option 1: Writing desk"), strings.Index(html, "Option 1: Calm") |
| + if newest < 0 || earlier < newest { |
| + t.Fatalf("rounds not newest first (%d, %d): %s", newest, earlier, html) |
| + } |
| + forms := optionForms(html) |
| + if len(forms) != 6 { |
| + t.Fatalf("%d option forms, want 6: %s", len(forms), html) |
| + } |
| + for i, f := range forms { |
| + step, index := "stnew", i |
| + if i >= 3 { |
| + step, index = "stold", i-3 |
| + } |
| + mustContain(t, f, `action="/conversation/cards/c1/answer"`, `name="revision" value="2"`, `name="from" value="task"`, `name="task" value="tk1"`, |
| + `name="option_step" value="`+step+`"`, `name="option_index" value="`+string(rune('0'+index))+`"`, `name="choice" value="build"`, `name="choice" value="like"`) |
| + } |
| + // The decision's own answers: More options with the optional note, no |
| + // Build of its own, nothing that needs an option. |
| + if strings.Contains(html, `data-merge-choice="build"`) || strings.Contains(html, `data-merge-choice="like"`) || strings.Contains(html, `name="note" required`) { |
| + t.Fatalf("decision answers: %s", html) |
| + } |
| + mustContain(t, html, `data-merge-choice="more"`, `data-merge-choice="again"`, `data-merge-choice="drop"`, `data-direction-note`) |
| + if strings.Contains(html, copyText("work.captures.earlier")) { |
| + t.Fatalf("the task page points at itself: %s", html) |
| + } |
| +} |
diff --git a/internal/equipo/static/equipo.css b/internal/equipo/static/equipo.css| index a7f57486..d1d46292 100644 |
| --- a/internal/equipo/static/equipo.css |
| +++ b/internal/equipo/static/equipo.css |
| @@ -1250,6 +1250,17 @@ a[equipo-source]:hover, a[equipo-source]:focus-visible { color: var(--rst-text); |
| [equipo-captures] [equipo-kept] img { block-size: 10rem; object-fit: cover; object-position: top; } |
| [equipo-captures] [equipo-kept] a { display: block; color: inherit; text-decoration: none; border-radius: var(--rst-radius); } |
| [equipo-captures] [equipo-kept] a:focus-visible { outline: 2px solid var(--rst-focus-edge, var(--rst-accent)); outline-offset: 2px; } |
| +/* Rounds of options, newest first: a rule between rounds; each option's |
| + direction (Design's words) under its name, and its own answers. */ |
| +[equipo-capture-round] { display: grid; gap: var(--rst-sp-4); } |
| +[equipo-capture-round] + [equipo-capture-round] { border-block-start: 1px solid var(--rst-line); padding-block-start: var(--rst-sp-3); } |
| +[equipo-capture-option] [equipo-direction] { margin: 0 0 var(--rst-sp-2); max-inline-size: 65ch; font-size: var(--rst-fs-sm); color: var(--rst-text-muted); overflow-wrap: anywhere; white-space: pre-line; } |
| +[equipo-option-actions] { display: flex; flex-wrap: wrap; gap: var(--rst-sp-2); margin-block-start: var(--rst-sp-2); } |
| +[equipo-captures] [data-earlier] { margin: 0; font-size: var(--rst-fs-sm); } |
| +@container roster (max-width:500px) { |
| + [equipo-option-actions] { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); } |
| + [equipo-option-actions] [rst-btn] { min-block-size: 2.75rem; min-inline-size: 0; white-space: normal; text-align: center; justify-content: center; padding-inline: var(--rst-sp-2); } |
| +} |
| [equipo-fetch-log] { margin: var(--rst-sp-2) 0 0; padding-inline-start: var(--rst-sp-5); display: grid; gap: var(--rst-sp-1); font-size: var(--rst-fs-xs); color: var(--rst-text-muted); font-variant-numeric: tabular-nums; } |
| [equipo-fetch-log] li { overflow-wrap: anywhere; } |
| [equipo-fetch-log] [data-reason] { color: var(--rst-tone-negative-fg); } |
diff --git a/internal/equipo/templates/chat.html b/internal/equipo/templates/chat.html| index ad226825..40509daa 100644 |
| --- a/internal/equipo/templates/chat.html |
| +++ b/internal/equipo/templates/chat.html |
| @@ -12,7 +12,7 @@ |
| <div equipo-thread-list role="log" aria-live="polite"><div equipo-thread-turn data-first><span equipo-thread-avatar>{{if eq .AuthorIcon "sparkles"}}{{template "roster-mark" .}}{{else}}{{icon .AuthorIcon}}{{end}}</span><div equipo-thread-bubble><div equipo-thread-who>{{.Author}}</div><div equipo-thread-text>{{.Line}}</div></div></div>{{template "roster-thread-turns" .}}</div> |
| {{if .Open}}{{if .Options}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{template "project-name-confirm" .}}{{range .Options}}<button rst-btn name="choice" value="{{.}}" type="submit">{{.}}</button>{{end}}</form>{{else}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-mini-composer><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{template "project-name-confirm" .}}<div equipo-mini-pill><textarea name="choice" required maxlength="2000" rows="1" aria-label="{{copy "chat.card.answer"}}" placeholder="{{copy "chat.card.answer"}}"></textarea><button type="submit" data-thread-send aria-label="{{copy "conversation.send_short"}}" data-busy-label="{{copy "roster.sending"}}">{{icon "arrow-up"}}</button></div></form>{{end}}{{else if not .Presentation.Waiting}}<form method="post" action="/conversation/cards/{{.ID}}/reply" data-card-form equipo-mini-composer><input type="hidden" name="request_id" value="{{.ReplyKey}}">{{template "card-job" .}}<div equipo-mini-pill><textarea name="body" required maxlength="2000" rows="1" aria-label="{{copy "roster.reply"}}" placeholder="{{copy "roster.reply"}}"></textarea><button type="submit" data-thread-send aria-label="{{copy "conversation.send_short"}}" data-busy-label="{{copy "roster.sending"}}">{{icon "arrow-up"}}</button></div></form>{{end}}</div> |
| {{else if eq .Kind "home"}}<p equipo-card-line>{{icon "folder"}}<span>{{.Line}}</span></p><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<button rst-btn="primary" name="choice" value="confirm" type="submit">{{copy "chat.card.confirm"}}</button></form> |
| -{{else if eq .Kind "direction"}}<p equipo-card-line>{{.Line}}</p>{{template "design-gallery" .Gallery}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{template "project-name-confirm" .}}{{range .Options}}{{if eq . "again"}}<button type="button" rst-btn data-thread-open>{{copy "chat.card.again"}}</button>{{else if and (eq . "build") $.BuildNote}}{{else}}<button rst-btn="{{if eq . "build"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-direction-choice="{{.}}"{{if eq . "build"}} data-busy-label="{{copy "roster.building"}}"{{end}}>{{copy (printf "chat.card.%s" .)}}</button>{{end}}{{end}}</form>{{if .BuildNote}}<details equipo-subchat data-direction-build><summary equipo-thread-open>{{copy "chat.card.build"}}</summary><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-mini-composer><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="choice" value="build">{{template "card-job" .}}<div equipo-mini-pill><textarea name="note" required maxlength="1000" rows="1" aria-label="{{copy "chat.card.build_note"}}" placeholder="{{copy "chat.card.build_note"}}"></textarea><button type="submit" data-thread-send data-direction-choice="build" aria-label="{{copy "chat.card.build"}}" data-busy-label="{{copy "roster.building"}}">{{icon "arrow-up"}}</button></div></form></details>{{end}}<details equipo-subchat data-direction-thread><summary equipo-thread-open>{{copy "chat.card.again"}}</summary><div equipo-thread-list role="log" aria-live="polite"><div equipo-thread-turn><span equipo-thread-avatar>{{icon .AuthorIcon}}</span><div equipo-thread-bubble><div equipo-thread-who>{{.Author}}</div><div equipo-thread-text>{{copy "roster.change"}}</div></div></div></div><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-mini-composer><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="choice" value="again">{{template "card-job" .}}<div equipo-mini-pill><textarea name="note" required maxlength="1000" rows="1" aria-label="{{copy "roster.reply"}}" placeholder="{{copy "roster.reply"}}"></textarea><button type="submit" data-thread-send data-direction-choice="again" aria-label="{{copy "conversation.send_short"}}" data-busy-label="{{copy "roster.sending"}}">{{icon "arrow-up"}}</button></div></form></details>{{else}}{{with .Note}}<p equipo-card-done role="status">{{.}}</p>{{end}}{{if .Presentation.Thread}}<div equipo-subchat data-roster-step="{{.Presentation.StepID}}"><div equipo-thread-list role="log" aria-live="polite">{{template "roster-thread-turns" .}}</div></div>{{end}}{{end}} |
| +{{else if eq .Kind "direction"}}<p equipo-card-line>{{.Line}}</p>{{template "design-gallery" .Gallery}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{template "project-name-confirm" .}}{{range .Options}}{{if eq . "again"}}<button type="button" rst-btn data-thread-open>{{copy "chat.card.again"}}</button>{{else if or (eq . "like") (and (eq . "build") $.OptionBuild)}}{{else if eq . "more"}}<button rst-btn name="choice" value="more" type="submit" data-direction-choice="more" data-busy-label="{{copy "roster.sending"}}">{{copy "chat.card.more_options"}}</button>{{else}}<button rst-btn="{{if eq . "build"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-direction-choice="{{.}}"{{if eq . "build"}} data-busy-label="{{copy "roster.building"}}"{{end}}>{{copy (printf "chat.card.%s" .)}}</button>{{end}}{{end}}</form><details equipo-subchat data-direction-thread><summary equipo-thread-open>{{copy "chat.card.again"}}</summary><div equipo-thread-list role="log" aria-live="polite"><div equipo-thread-turn><span equipo-thread-avatar>{{icon .AuthorIcon}}</span><div equipo-thread-bubble><div equipo-thread-who>{{.Author}}</div><div equipo-thread-text>{{copy "roster.change"}}</div></div></div></div><form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-mini-composer><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="choice" value="again">{{template "card-job" .}}<div equipo-mini-pill><textarea name="note" required maxlength="1000" rows="1" aria-label="{{copy "roster.reply"}}" placeholder="{{copy "roster.reply"}}"></textarea><button type="submit" data-thread-send data-direction-choice="again" aria-label="{{copy "conversation.send_short"}}" data-busy-label="{{copy "roster.sending"}}">{{icon "arrow-up"}}</button></div></form></details>{{else}}{{with .Note}}<p equipo-card-done role="status">{{.}}</p>{{end}}{{if .Presentation.Thread}}<div equipo-subchat data-roster-step="{{.Presentation.StepID}}"><div equipo-thread-list role="log" aria-live="polite">{{template "roster-thread-turns" .}}</div></div>{{end}}{{end}} |
| {{else if eq .Kind "specialist"}}<p equipo-card-line>{{.Line}}</p>{{with .Specialist}}{{range .Capabilities}}<p equipo-card-note data-capability="{{.ID}}">{{.Words}}</p>{{end}}<p equipo-card-note data-specialist-brief>{{printf (copy "chat.card.specialist_brief") .Brief}}</p>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{template "project-name-confirm" .}}{{range .Options}}<button rst-btn="{{if eq . "add"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-specialist-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}} |
| {{else if eq .Kind "research_sources"}}<p equipo-card-line>{{.Line}}</p>{{with .Name}}<p equipo-card-note data-research-task>{{printf (copy "chat.card.research_for") .}}</p>{{end}}{{with .Research}}<p equipo-card-note data-research-question>{{printf (copy "chat.card.research_looks_for") .Question}}</p><ul equipo-card-list data-research-urls>{{range .URLs}}<li><code>{{.}}</code></li>{{end}}</ul>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}{{template "project-name-confirm" .}}{{range .Options}}<button rst-btn="{{if eq . "allow"}}primary{{end}}" name="choice" value="{{.}}" type="submit" data-research-choice="{{.}}">{{copy (printf "chat.card.%s" .)}}</button>{{end}}</form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}} |
| {{else if eq .Kind "instance_inventory"}}<p equipo-card-line>{{.Line}}</p>{{with .Inventory}}<ul equipo-card-list data-instance-addresses>{{range .Addresses}}<li><code>{{.}}</code></li>{{end}}</ul>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}"><button rst-btn="primary" name="choice" value="confirm" type="submit" data-instance-confirm>{{copy "services.inventory.confirm"}}</button></form>{{end}}{{else if eq .Kind "research_inventory"}}<p equipo-card-line>{{.Line}}</p>{{with .Inventory}}<ul equipo-card-list data-research-addresses>{{range .Addresses}}<li><code>{{.}}</code></li>{{end}}</ul>{{end}}{{if .Open}}<form method="post" action="/conversation/cards/{{.ID}}/answer" data-card-form equipo-actions><input type="hidden" name="revision" value="{{.Revision}}">{{template "card-job" .}}<button rst-btn="primary" name="choice" value="confirm" type="submit" data-inventory-confirm>{{copy "chat.card.inventory_confirm"}}</button></form>{{else}}{{with .Note}}<p equipo-card-note>{{.}}</p>{{end}}{{end}} |
diff --git a/internal/equipo/templates/work_parts.html b/internal/equipo/templates/work_parts.html| index dd2b5f27..a8306cb0 100644 |
| --- a/internal/equipo/templates/work_parts.html |
| +++ b/internal/equipo/templates/work_parts.html |
| @@ -53,6 +53,8 @@ |
| <noscript><button equipo-btn data-primary type="submit">{{copy "thinking.use"}}</button></noscript> |
| </form> |
| </div>{{end}}{{end}} |
| -{{/* A Design attempt's kept captures, by option, from this instance's |
| - task-file route only (the task page and the direction card). */}} |
| -{{define "design-gallery"}}{{with .}}<div equipo-captures data-captures>{{range .Options}}<section equipo-capture-option data-option><h3>{{.Label}}</h3>{{if .Captures}}<ul equipo-kept>{{range .Captures}}<li><a href="{{.Src}}" target="_blank" rel="noopener" data-capture="{{.ID}}"><figure><img src="{{.Src}}" alt="{{.Alt}}" width="{{.Width}}" height="{{.Height}}" loading="lazy" decoding="async"><figcaption>{{.Tree}}</figcaption></figure></a></li>{{end}}</ul>{{else}}<p equipo-quiet>{{copy "work.captures.none"}}</p>{{end}}</section>{{end}}</div>{{end}}{{end}} |
| +{{/* Design's kept rounds, newest first, by option, captures from this |
| + instance's task-file route only (the task page and the direction |
| + card). On an open direction card each option is a form of its own: |
| + Build this one and More like this name it by step and index. */}} |
| +{{define "design-gallery"}}{{with .}}{{$a := .Answer}}<div equipo-captures data-captures>{{range .Rounds}}<div equipo-capture-round data-round="{{.Step}}">{{range .Options}}<section equipo-capture-option data-option><h3>{{.Label}}</h3>{{with .Direction}}<p equipo-direction>{{.}}</p>{{end}}{{if .Captures}}<ul equipo-kept>{{range .Captures}}<li><a href="{{.Src}}" target="_blank" rel="noopener" data-capture="{{.ID}}"><figure><img src="{{.Src}}" alt="{{.Alt}}" width="{{.Width}}" height="{{.Height}}" loading="lazy" decoding="async"><figcaption>{{.Caption}}</figcaption></figure></a></li>{{end}}</ul>{{else}}<p equipo-quiet>{{copy "work.captures.none"}}</p>{{end}}{{if and $a .Step}}<form method="post" action="/conversation/cards/{{$a.CardID}}/answer"{{if not $a.Task}} data-card-form{{end}} equipo-option-actions><input type="hidden" name="revision" value="{{$a.Revision}}">{{with $a.From}}<input type="hidden" name="from" value="{{.}}">{{end}}{{with $a.Task}}<input type="hidden" name="task" value="{{.}}">{{end}}{{with $a.Job}}<input type="hidden" name="from" value="job"><input type="hidden" name="job" value="{{.}}">{{end}}<input type="hidden" name="option_step" value="{{.Step}}"><input type="hidden" name="option_index" value="{{.Index}}">{{if $a.Task}}<button equipo-btn data-primary type="submit" name="choice" value="build" data-option-choice="build">{{copy "chat.card.build"}}</button>{{if $a.Like}}<button equipo-btn type="submit" name="choice" value="like" data-option-choice="like">{{copy "chat.card.like"}}</button>{{end}}{{else}}<button rst-btn="primary" type="submit" name="choice" value="build" data-option-choice="build" data-busy-label="{{copy "roster.building"}}">{{copy "chat.card.build"}}</button>{{if $a.Like}}<button rst-btn type="submit" name="choice" value="like" data-option-choice="like" data-busy-label="{{copy "roster.sending"}}">{{copy "chat.card.like"}}</button>{{end}}{{end}}</form>{{end}}</section>{{end}}</div>{{end}}{{with .Earlier}}<p equipo-quiet data-earlier><a equipo-link href="{{.}}">{{copy "work.captures.earlier"}}</a></p>{{end}}</div>{{end}}{{end}} |
diff --git a/internal/equipo/work_views.go b/internal/equipo/work_views.go| index 8b049cf2..df573c55 100644 |
| --- a/internal/equipo/work_views.go |
| +++ b/internal/equipo/work_views.go |
| @@ -802,14 +802,33 @@ func decisionOf(t wire.Task, v taskLine) *decisionView { |
| default: |
| d.LinkText, d.Link, d.LinkLabel = copyText("work.direction.no_preview"), dir.BranchURL, copyText("work.direction.branch") |
| } |
| - d.Gallery, d.BuildNote = galleryOf(t.ID, dir.Options), dir.NoteNeeded |
| + // Every kept round, newest first, each option with its own |
| + // Build this one; a direction from before rounds were kept |
| + // takes the person's note saying which option, as before. |
| + cardID, revision := "", int64(0) |
| + if d.Card != nil { |
| + cardID, revision = d.Card.ID, d.Card.Revision |
| + } |
| + d.Gallery = galleryOf(t.ID, directionRounds(dir), d.Card != nil, cardID, revision) |
| + if g := d.Gallery; g != nil && g.Answer != nil { |
| + g.Answer.From, g.Answer.Task, g.Answer.Like = "task", t.ID, slices.Contains(d.Card.Options, wire.ChoiceLike) |
| + } |
| + d.BuildNote = dir.NoteNeeded && !d.Gallery.perOption() |
| if d.BuildNote { |
| d.Ask = copyText("work.decide.direction_ask_options") |
| } |
| } |
| if d.Card != nil { |
| for _, o := range d.Card.Options { |
| - d.Choices = append(d.Choices, decisionChoice{Value: o, Label: copyText("chat.card." + o), Primary: o == wire.ChoiceBuild}) |
| + // More like this and, with options, Build this one are |
| + // each option's own; More options is the whole set's. |
| + switch { |
| + case o == wire.ChoiceLike, o == wire.ChoiceBuild && d.Gallery.perOption(): |
| + case o == wire.ChoiceMore: |
| + d.Choices = append(d.Choices, decisionChoice{Value: o, Label: copyText("chat.card.more_options")}) |
| + default: |
| + d.Choices = append(d.Choices, decisionChoice{Value: o, Label: copyText("chat.card." + o), Primary: o == wire.ChoiceBuild}) |
| + } |
| } |
| } |
| case wire.NeedsMacRunner: |
| @@ -1212,7 +1231,7 @@ func timelineOf(t wire.Task, v taskLine) []timelineItem { |
| case wire.SpecialistEngineering: |
| it := timelineItem{Kind: "step", What: title, Took: took(s), Headline: headline(s.Headline, s.Summary), Markdown: s.Summary, At: s.FinishedAt} |
| if s.Design != nil { |
| - it.Design = galleryOf(t.ID, s.Design.Options) |
| + it.Design = galleryOf(t.ID, []wire.DirectionRound{{Step: s.ID, Options: s.Design.Options}}, false, "", 0) |
| } |
| if s.Pushed { |
| it.Text = append(it.Text, fmt.Sprintf(copyText("work.tl.pushed"), short(s.CandidateSHA))) |