Ask: draw a lookup's answer and sources under the reply
chat.html draws each lookup after the reply's words: the answer through lookupMarkdown (lists, bold and italics, never a link: a Markdown link shows its words, bare URLs and autolinks stay text), then a quiet Sources line with each source's title as a link in a new tab (noopener noreferrer nofollow) and its host after it. Sources must have an ASCII host so every client shows it alike. Copy rows ask.sources and ask.fallback_sources, approved by Paul 2026-11-28.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 files changed,
+222
−11
docs/copy-pending.md+7 −0internal/equipo/equipotest/chat.go+16 −0internal/equipo/lookups.go+10 −3internal/equipo/lookups_test.go+1 −1internal/look/static/app.css+8 −0internal/web/app.go+1 −1internal/web/ask_cards.go+40 −5internal/web/templates/partials/chat.html+3 −1internal/webtest/ask_lookup_test.go+136 −0
diff --git a/docs/copy-pending.md b/docs/copy-pending.md| index b917e6d..2379a5b 100644 |
| --- a/docs/copy-pending.md |
| +++ b/docs/copy-pending.md |
| @@ -448,3 +448,10 @@ Review 13 (reviewed by Luna, 2026-11-26; Luna's verdicts are the review, as Paul |
| | ask.turn.no_room | ask.go, ask.js | REVIEWED (Luna, 2026-11-26): status line: the runner had no room for the files (runner_storage_full) | There’s no room left for these files. Try fewer or smaller ones. | |
| | ask.turn.runner_too_old | ask.go, ask.js | REVIEWED (Luna, 2026-11-26): status line: the turn with files was failed when an older runner connected (runner_too_old) | Files can’t be read right now. Send it again without them. | |
| | ask.files_line_a11y | native Thread.swift (Localizable.xcstrings) | REVIEWED (Luna, 2026-11-26): VoiceOver: the plain line of a person's files' names under their words in the Mac and iPhone apps, until slice 2 draws files; {names} comma-separated | Attached: {names} | |
| + |
| +Review 14 (approved, Paul, 2026-11-28, copy review mi3kgi7nubnsf7kxn235tqwrbu, every string unchanged): the Assistant's abilities (spec 2026-11-26-assistant-abilities, plan 2026-11-27). When the Assistant looks something up on the web, the answer shows under its reply with the pages it came from. The answer's own words come from the instance; Base draws them with its little Markdown, never as links. Phase 1 uses the two rows below; the person page and Settings strings of the same review land with phase 4. |
| + |
| +| Id | File | Context | Text | |
| +|---|---|---|---| |
| +| ask.sources | partials/chat.html, ask.js, native Thread.swift (Localizable.xcstrings) | APPROVED (Paul, 2026-11-28): the quiet line under a lookup's answer, before each source's title (a link) and host | Sources | |
| +| ask.fallback_sources | internal/equipo/lookups.go | APPROVED (Paul, 2026-11-28): in the plain text an app that can't draw lookups gets instead: the reply's words, the answer, then this line and the sources' addresses | Sources: | |
diff --git a/internal/equipo/equipotest/chat.go b/internal/equipo/equipotest/chat.go| index 3c5514b..51ad915 100644 |
| --- a/internal/equipo/equipotest/chat.go |
| +++ b/internal/equipo/equipotest/chat.go |
| @@ -395,6 +395,22 @@ func (f *Fake) Say(text string) { |
| f.emit("message", "message", m.ID, 1, "", m) |
| } |
| +// LastTurn is the id of the newest turn ("" when there is none). |
| +func (f *Fake) LastTurn() string { |
| + f.cmu.Lock() |
| + defer f.cmu.Unlock() |
| + var last *turn |
| + for _, t := range f.turns { |
| + if last == nil || t.CreatedAt.After(last.CreatedAt) || t.CreatedAt.Equal(last.CreatedAt) && t.ID > last.ID { |
| + last = t |
| + } |
| + } |
| + if last == nil { |
| + return "" |
| + } |
| + return last.ID |
| +} |
| + |
| // Turn is the state of the turn with id ("" when there is none). |
| func (f *Fake) Turn(id string) string { |
| f.cmu.Lock() |
diff --git a/internal/equipo/lookups.go b/internal/equipo/lookups.go| index 90f3da8..ad98b99 100644 |
| --- a/internal/equipo/lookups.go |
| +++ b/internal/equipo/lookups.go |
| @@ -78,16 +78,23 @@ func cleanLookups(role string, lookups []Lookup) []Lookup { |
| return out |
| } |
| -// sourceURL is raw if it is an absolute https address with a host and no |
| -// user info, of at most maxSourceURL bytes, else "". |
| +// sourceURL is raw if it is an absolute https address with a host of |
| +// ASCII alone (so every client shows the host alike) and no user info, |
| +// of at most maxSourceURL bytes, else "". |
| func sourceURL(raw string) string { |
| if len(raw) > maxSourceURL { |
| return "" |
| } |
| u := WebURL(raw) |
| - if p, err := url.Parse(u); u == "" || err != nil || p.Scheme != "https" { |
| + p, err := url.Parse(u) |
| + if u == "" || err != nil || p.Scheme != "https" { |
| return "" |
| } |
| + for i := 0; i < len(p.Host); i++ { |
| + if p.Host[i] >= utf8.RuneSelf { |
| + return "" |
| + } |
| + } |
| return u |
| } |
diff --git a/internal/equipo/lookups_test.go b/internal/equipo/lookups_test.go| index a693e09..3f9a2e4 100644 |
| --- a/internal/equipo/lookups_test.go |
| +++ b/internal/equipo/lookups_test.go |
| @@ -59,7 +59,7 @@ func TestCleanLookupBounds(t *testing.T) { |
| func TestCleanLookupHTTPSOnly(t *testing.T) { |
| m := equipo.Message{Role: "assistant", Lookups: []equipo.Lookup{ |
| {Answer: "Kept", Sources: []equipo.Source{{URL: "http://plain.test/", Title: "a"}, {URL: "javascript:alert(1)", Title: "b"}, |
| - {URL: "/relative", Title: "c"}, {URL: "https://user:pw@x.test/", Title: "d"}, {URL: "https://ok.test/a?b=1", Title: "e"}}}, |
| + {URL: "/relative", Title: "c"}, {URL: "https://user:pw@x.test/", Title: "d"}, {URL: "https://café.test/", Title: "idn"}, {URL: "https://ok.test/a?b=1", Title: "e"}}}, |
| {Answer: "No sources", Sources: []equipo.Source{{URL: "http://plain.test/"}}}, |
| {Answer: " ", Sources: []equipo.Source{src(1)}}, |
| }}.Clean() |
diff --git a/internal/look/static/app.css b/internal/look/static/app.css| index 3510975..39e6c0f 100644 |
| --- a/internal/look/static/app.css |
| +++ b/internal/look/static/app.css |
| @@ -569,6 +569,14 @@ aside.ask-panel { position: absolute; top: 16px; right: 16px; bottom: 16px; widt |
| .choices { display: flex; flex-wrap: wrap; gap: 8px; } |
| .msg.card p + p { margin-top: -4px; } |
| .card-link, .msg.coordinator a { color: var(--focus); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; } |
| +/* A lookup under the Assistant's words (ask-lookup): the answer, then a |
| + quiet Sources line, each source's title a link with its host after it. */ |
| +.msg .lookup { margin-top: 10px; } |
| +.msg .lookup-answer { margin: 0; } |
| +.msg .lookup-sources { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 2px 12px; white-space: normal; color: var(--haze); font-size: 13.5px; line-height: 1.4; } |
| +.msg .lookup-label { font-weight: 500; } |
| +.msg .lookup-sources .source { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; min-width: 0; } |
| +.msg .lookup-sources .source-host { color: var(--haze); font-size: 12.5px; } |
| /* The person's links keep their bubble's ink, underlined. */ |
| .msg.person a { color: inherit; text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; } |
| /* A person's files above their words (ask-files): thumbnails, then a pill |
diff --git a/internal/web/app.go b/internal/web/app.go| index 998977d..28ace58 100644 |
| --- a/internal/web/app.go |
| +++ b/internal/web/app.go |
| @@ -85,7 +85,7 @@ func App(d *db.DB, cfg config.Config, mailer mail.Sender, inst Installer, logger |
| } |
| // newKey gives each chat form its own request key when the page is |
| // drawn; startedText says when a job started, as of then. |
| - pages, err := look.NewRenderer(sub, template.FuncMap{"newKey": equipo.NewKey, "fileSize": fileSize, |
| + pages, err := look.NewRenderer(sub, template.FuncMap{"newKey": equipo.NewKey, "fileSize": fileSize, "lookupAnswer": lookupMarkdown, "sourceHost": sourceHost, |
| "startedText": func(at *time.Time) string { return startedText(*at, time.Now(), cfg.Timezone) }}) |
| if err != nil { |
| return nil, err |
diff --git a/internal/web/ask_cards.go b/internal/web/ask_cards.go| index e20f534..437224e 100644 |
| --- a/internal/web/ask_cards.go |
| +++ b/internal/web/ask_cards.go |
| @@ -3,6 +3,7 @@ package web |
| import ( |
| "html" |
| "html/template" |
| + "net/url" |
| "regexp" |
| "strconv" |
| "strings" |
| @@ -32,7 +33,24 @@ func richText(text string) template.HTML { return richMarkdown(text, false) } |
| // same. |
| func personText(text string) template.HTML { return richMarkdown(text, true) } |
| -func richMarkdown(text string, strict bool) template.HTML { |
| +func richMarkdown(text string, strict bool) template.HTML { return markdown(text, strict, true) } |
| + |
| +// mdLinkRE is a Markdown link, [label](target). |
| +var mdLinkRE = regexp.MustCompile(`\[([^\[\]\n]{1,300})\]\(([^()\s]{1,1000})\)`) |
| + |
| +// lookupMarkdown is a lookup's answer as HTML: personText's Markdown |
| +// (lists, and bold and italics at word boundaries) with no links at all, |
| +// since the only links under a reply are the sources Equipo recorded |
| +// (spec 2026-11-26-assistant-abilities §4.6). A Markdown link shows as |
| +// its words; a bare URL or an autolink stays as text. ask.js |
| +// (lookupMarkdown) and the app (LookupMarkdown) do the same. |
| +func lookupMarkdown(text string) template.HTML { |
| + return markdown(mdLinkRE.ReplaceAllString(asPageReads.Replace(text), "$1"), true, false) |
| +} |
| + |
| +// markdown is richMarkdown, with links drawn only when links is set |
| +// (otherwise every address is text). |
| +func markdown(text string, strict, links bool) template.HTML { |
| var b strings.Builder |
| lines := strings.Split(asPageReads.Replace(text), "\n") |
| for i := 0; i < len(lines); { |
| @@ -42,7 +60,7 @@ func richMarkdown(text string, strict bool) template.HTML { |
| for j < len(lines) && !isListLine(lines[j]) { |
| j++ |
| } |
| - inline(&b, strings.Join(lines[i:j], "\n"), strict) |
| + inline(&b, strings.Join(lines[i:j], "\n"), strict, links) |
| i = j |
| continue |
| } |
| @@ -57,7 +75,7 @@ func richMarkdown(text string, strict bool) template.HTML { |
| break |
| } |
| b.WriteString("<li>") |
| - inline(&b, item, strict) |
| + inline(&b, item, strict, links) |
| b.WriteString("</li>") |
| } |
| b.WriteString("</" + kind + ">") |
| @@ -87,8 +105,9 @@ func listLine(line string) (kind string, n int, item string) { |
| func isListLine(line string) bool { k, _, _ := listLine(line); return k != "" } |
| // inline writes text with its safe links, and bold and italics between |
| -// them. |
| -func inline(b *strings.Builder, text string, strict bool) { |
| +// them. Without links, each address is written as text, untouched by |
| +// emphasis. |
| +func inline(b *strings.Builder, text string, strict, links bool) { |
| emphasis := emphasis |
| if strict { |
| emphasis = strictEmphasis |
| @@ -107,6 +126,11 @@ func inline(b *strings.Builder, text string, strict bool) { |
| continue |
| } |
| emphasis(b, text[last:m[0]]) |
| + if !links { |
| + b.WriteString(html.EscapeString(text[m[0]:end])) |
| + last = end |
| + continue |
| + } |
| b.WriteString(`<a href="` + html.EscapeString(href) + `" target="_blank" rel="noopener">` + html.EscapeString(label) + `</a>`) |
| last = end |
| } |
| @@ -206,5 +230,16 @@ func wordByte(c byte) bool { |
| // Rich is an Assistant's line with its links (richText), for templates. |
| func (v askView) Rich(text string) template.HTML { return richText(text) } |
| +// sourceHost is u's host name as a source line shows it after the |
| +// source's title, without a leading "www.". ask.js has the same |
| +// (sourceHost). |
| +func sourceHost(u string) string { |
| + p, err := url.Parse(u) |
| + if err != nil { |
| + return "" |
| + } |
| + return strings.TrimPrefix(strings.ToLower(p.Hostname()), "www.") |
| +} |
| + |
| // RichPerson is the person's own message (personText), for templates. |
| func (v askView) RichPerson(text string) template.HTML { return personText(text) } |
diff --git a/internal/web/templates/partials/chat.html b/internal/web/templates/partials/chat.html| index 265ca91..101a139 100644 |
| --- a/internal/web/templates/partials/chat.html |
| +++ b/internal/web/templates/partials/chat.html |
| @@ -30,6 +30,8 @@ |
| {{define "ask-files"}}<div class="files" role="group" aria-label="Attached files">{{range .}}{{if eq .Kind "image"}}<a class="thumb" href="/ask/attachments/{{.ID}}" data-attachment="{{.ID}}"><img loading="lazy" src="/ask/attachments/{{.ID}}/preview" alt="{{.Name}}"{{if and .Width .Height}} width="{{.Width}}" height="{{.Height}}"{{end}}></a>{{end}}{{end}}{{range .}}{{if ne .Kind "image"}}<a class="file" href="/ask/attachments/{{.ID}}" download aria-label="{{.Name}}, {{fileSize .Size}}. Download">{{template "ask-file-mark"}}<span class="file-name">{{.Name}}</span><span class="file-size">{{fileSize .Size}}</span></a>{{end}}{{end}}</div>{{end}} |
| {{/* A file's mark: a page with its corner folded. ask-attach.js has the same path (fileMark). */}} |
| {{define "ask-file-mark"}}<svg class="file-mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3.5H7.5a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2V8zM14 3.5V8h4.5"/></svg>{{end}} |
| +{{/* A lookup under the Assistant's reply: its answer (lookupMarkdown: lists, bold and italics, never a link), then a quiet Sources line (copy ask.sources) with each source's title as a link opening in a new tab, and its host after it. The panel's script draws the same (ask.js, addLookup), and so does the app. */}} |
| +{{define "ask-lookup"}}<div class="lookup"><div class="lookup-answer">{{lookupAnswer .Answer}}</div><p class="lookup-sources"><span class="lookup-label">Sources</span>{{range .Sources}}<span class="source"><a href="{{.URL}}" target="_blank" rel="noopener noreferrer nofollow">{{or .Title (sourceHost .URL)}}</a><span class="source-host">{{sourceHost .URL}}</span></span>{{end}}</p></div>{{end}} |
| {{define "ask-body"}}<div class="ask-note" data-when="connect"{{if not (.Shows "connect")}} hidden{{end}}> |
| <p>Set up Ask Base to start asking.</p> |
| <form method="post" action="/ask/connect"><input type="hidden" name="next" value="{{.Next}}"><button class="btn" type="submit">Set up Ask Base</button></form> |
| @@ -47,7 +49,7 @@ |
| </div> |
| <div class="ask-chat" data-when="ready norunner oldrunner"{{if not (.Shows "ready norunner oldrunner")}} hidden{{end}}> |
| <div class="log"><ol class="thread" role="log" aria-label="Conversation"{{with .Zone}} data-zone="{{.}}"{{end}} data-mark="{{asset "static/oficina/equipo.svg"}}"> |
| -{{range .Messages}}{{if eq .Role "person"}}<li class="msg person" data-id="{{.ID}}">{{with .Attachments}}{{template "ask-files" .}}{{end}}{{with .Text}}{{$.RichPerson .}}{{end}}</li>{{else}}<li class="msg coordinator" data-id="{{.ID}}">{{$.Rich .Text}}{{range $.OffersAt .ID}}<div class="connect-offer" data-card="{{.ID}}" data-revision="{{.Revision}}">{{template "ask-offer" .}}</div>{{end}}</li>{{end}} |
| +{{range .Messages}}{{if eq .Role "person"}}<li class="msg person" data-id="{{.ID}}">{{with .Attachments}}{{template "ask-files" .}}{{end}}{{with .Text}}{{$.RichPerson .}}{{end}}</li>{{else}}<li class="msg coordinator" data-id="{{.ID}}">{{$.Rich .Text}}{{range .Lookups}}{{template "ask-lookup" .}}{{end}}{{range $.OffersAt .ID}}<div class="connect-offer" data-card="{{.ID}}" data-revision="{{.Revision}}">{{template "ask-offer" .}}</div>{{end}}</li>{{end}} |
| {{end}}{{with .Notice}}<li class="ask-notice" data-after="{{$.NoticeAfter}}">{{.}}</li> |
| {{end}}{{range .Jobs}}{{template "ask-job" .}} |
| {{end}}{{range .LooseCards}}{{template "ask-card" .}} |
diff --git a/internal/webtest/ask_lookup_test.go b/internal/webtest/ask_lookup_test.go| new file mode 100644 |
| index 0000000..1e1af6e |
| --- /dev/null |
| +++ b/internal/webtest/ask_lookup_test.go |
| @@ -0,0 +1,136 @@ |
| +package webtest |
| + |
| +import ( |
| + "encoding/json" |
| + "net/http" |
| + "net/url" |
| + "regexp" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/base/internal/equipo" |
| + "amadan.net/oficina/base/internal/equipo/equipotest" |
| +) |
| + |
| +// replyWithLookups has the owner ask something and the fake answer it with |
| +// lookups, and returns /ask as the page draws it (scripts off). |
| +func replyWithLookups(t *testing.T, a *testApp, f *equipotest.Fake, text string, lookups ...equipo.Lookup) string { |
| + t.Helper() |
| + f.Hold = true |
| + r := a.post("/ask/messages", url.Values{"text": {"What's the weather in Dublin?"}, "key": {"lookup-" + text[:3]}}) |
| + if r.Code != 303 { |
| + t.Fatalf("send: %d %s", r.Code, r.Body) |
| + } |
| + var id string |
| + for i := 0; i < 400 && id == ""; i++ { |
| + id = f.LastTurn() |
| + if id == "" || f.Turn(id) != "running" { |
| + id = "" |
| + time.Sleep(5 * time.Millisecond) |
| + } |
| + } |
| + if id == "" { |
| + t.Fatal("no running turn") |
| + } |
| + f.ReplyWithLookups(id, text, lookups...) |
| + page := a.get("/ask") |
| + if page.Code != 200 { |
| + t.Fatalf("/ask: %d", page.Code) |
| + } |
| + return page.Body |
| +} |
| + |
| +// replyOf is the Assistant's last line in a page: its <li> and what is in it. |
| +var replyRE = regexp.MustCompile(`(?s)<li class="msg coordinator" data-id="[^"]+">(.*?)</li>\n`) |
| + |
| +func lastReply(t *testing.T, body string) string { |
| + t.Helper() |
| + all := replyRE.FindAllStringSubmatch(body, -1) |
| + if len(all) == 0 { |
| + t.Fatalf("no reply in:\n%s", body) |
| + } |
| + return all[len(all)-1][1] |
| +} |
| + |
| +// The answer is drawn after the reply's words, escaped, with a Markdown |
| +// link in it shown as its words; then the quiet Sources line, each source |
| +// a link opening in a new tab, with its host after it. |
| +func TestLookupDrawn(t *testing.T) { |
| + a, f := newAskApp(t) |
| + a.approveEquipo(f) |
| + body := replyWithLookups(t, a, f, "Here it is.", equipo.Lookup{ |
| + Answer: "**Rain** later, see [Met](https://met.test/x) & <b>more</b>.", |
| + Sources: []equipo.Source{{URL: "https://www.met.test/dublin?d=1", Title: "Met Éireann"}, {URL: "https://b.test/", Title: ""}}, |
| + }) |
| + reply := lastReply(t, body) |
| + if !strings.HasPrefix(reply, "Here it is.") { |
| + t.Errorf("the reply's own words come first: %q", reply) |
| + } |
| + answer := `<div class="lookup"><div class="lookup-answer"><strong>Rain</strong> later, see Met & <b>more</b>.</div>` |
| + if !strings.Contains(reply, answer) { |
| + t.Errorf("answer not drawn as %s in:\n%s", answer, reply) |
| + } |
| + sources := `<p class="lookup-sources"><span class="lookup-label">Sources</span>` + |
| + `<span class="source"><a href="https://www.met.test/dublin?d=1" target="_blank" rel="noopener noreferrer nofollow">Met Éireann</a><span class="source-host">met.test</span></span>` + |
| + `<span class="source"><a href="https://b.test/" target="_blank" rel="noopener noreferrer nofollow">b.test</a><span class="source-host">b.test</span></span></p></div>` |
| + if !strings.Contains(reply, sources) { |
| + t.Errorf("sources not drawn as\n%s\nin:\n%s", sources, reply) |
| + } |
| + if strings.Index(reply, "Here it is.") > strings.Index(reply, `class="lookup"`) { |
| + t.Errorf("the answer came before the reply's words") |
| + } |
| +} |
| + |
| +// Two lookups are drawn in the order they were made, each with its own |
| +// sources. |
| +func TestTwoLookupsDrawnInOrder(t *testing.T) { |
| + a, f := newAskApp(t) |
| + a.approveEquipo(f) |
| + reply := lastReply(t, replyWithLookups(t, a, f, "Both.", |
| + equipo.Lookup{Answer: "First answer.", Sources: []equipo.Source{{URL: "https://one.test/", Title: "One"}}}, |
| + equipo.Lookup{Answer: "Second answer.", Sources: []equipo.Source{{URL: "https://two.test/", Title: "Two"}}})) |
| + i1, s1, i2, s2 := strings.Index(reply, "First answer."), strings.Index(reply, "https://one.test/"), |
| + strings.Index(reply, "Second answer."), strings.Index(reply, "https://two.test/") |
| + if i1 < 0 || !(i1 < s1 && s1 < i2 && i2 < s2) || strings.Count(reply, `class="lookup"`) != 2 { |
| + t.Errorf("order %d %d %d %d in:\n%s", i1, s1, i2, s2, reply) |
| + } |
| +} |
| + |
| +// An answer is never a way to put a link in front of the person: a |
| +// Markdown link, a bare URL, an autolink and a script are all text. Only |
| +// the sources are links. |
| +func TestLookupMarkdownNoLinks(t *testing.T) { |
| + a, f := newAskApp(t) |
| + a.approveEquipo(f) |
| + reply := lastReply(t, replyWithLookups(t, a, f, "Look.", equipo.Lookup{ |
| + Answer: "- [Click](https://evil.test/a)\n- https://evil.test/b\n- <https://evil.test/c>\n- <script>alert(1)</script>", |
| + Sources: []equipo.Source{{URL: "https://good.test/", Title: "Good"}}, |
| + })) |
| + answer := `<div class="lookup-answer"><ul><li>Click</li><li>https://evil.test/b</li><li><https://evil.test/c></li><li><script>alert(1)</script></li></ul></div>` |
| + if !strings.Contains(reply, answer) { |
| + t.Errorf("answer not drawn as %s in:\n%s", answer, reply) |
| + } |
| + if strings.Contains(reply, `href="https://evil.test`) || !strings.Contains(reply, `href="https://good.test/"`) { |
| + t.Errorf("links in:\n%s", reply) |
| + } |
| +} |
| + |
| +// /ask/state carries a message's lookups for scripts to draw. |
| +func TestLookupInState(t *testing.T) { |
| + a, f := newAskApp(t) |
| + a.approveEquipo(f) |
| + replyWithLookups(t, a, f, "Here.", equipo.Lookup{Answer: "Sunny.", Sources: []equipo.Source{{URL: "https://met.test/", Title: "Met"}}}) |
| + var s struct { |
| + Messages []equipo.Message `json:"messages"` |
| + } |
| + req, _ := http.NewRequest(http.MethodGet, a.base+"/ask/state", nil) |
| + req.Header.Set("Accept", "application/json") |
| + r := a.do(req) |
| + if err := json.Unmarshal([]byte(r.Body), &s); err != nil || len(s.Messages) == 0 { |
| + t.Fatalf("/ask/state: %s", r.Body) |
| + } |
| + if l := s.Messages[len(s.Messages)-1].Lookups; len(l) != 1 || l[0].Answer != "Sunny." { |
| + t.Errorf("lookups %+v", l) |
| + } |
| +} |