Public: anyone can read this; the crew can change it.
A search with no results offers one next step: the same words across all repositories, or a tell to the crew #13149
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13143-a-search-with-no-results-offers-one-next → main 9 commits fork 3 threads · 3 unresolved
3 files
changed +44
−8
src/web/pages/search.ts +10 −4
| @@ -534,10 +534,16 @@ export async function searchPage(ctx: Ctx): Promise<Response> { | ||
| 534 | 534 | </p>`, |
| 535 | 535 | )} |
| 536 | 536 | ${nothing |
| 537 | ? html`<p class="muted"> | |
| 538 | Nothing matches “${a.query}”. Search reads app and repository names | |
| 539 | and descriptions, issues, pull requests and the code you can see. | |
| 540 | <a href="/explore">Explore</a> instead. | |
| 537 | ? html`<p class="muted next-step" data-next-step> | |
| 538 | Nothing matches “${a.query}”. Search reads names, descriptions, issues, | |
| 539 | pulls and the code you can see. <a href="/explore">Explore</a> | |
| 540 | ${when( | |
| 541 | a.query !== "", | |
| 542 | () => html`${when( | |
| 543 | a.live || a.codeAll, | |
| 544 | () => html`or <a href="${searchHref(a, { live: false, codeAll: false })}" data-widen>search all repositories</a>`, | |
| 545 | )} or <a href="/?${new URLSearchParams({ text: a.query }).toString()}" data-tell>tell the crew</a>`, | |
| 546 | )} | |
Non-blocking (principle 8, plain words): the two chained "or" read awkwardly. Try "Explore, search all repositories, or tell the crew." |
||
| 541 | 547 | </p>` |
| 542 | 548 | : WORDS |
| 543 | 549 | .filter( |
test/search-language.test.ts +2 −2
| @@ -50,8 +50,8 @@ test("results are sections of rows with no card", async () => { | ||
| 50 | 50 | test("an empty query is the bare form and no results are one plain sentence", async () => { |
| 51 | 51 | const empty = main(await get("/search?q=")); |
| 52 | 52 | expect(empty).not.toContain('class="card'); |
| 53 | expect(empty).not.toContain('<p class="muted">'); | |
| 53 | expect(empty).not.toContain("data-next-step"); | |
| 54 | 54 | const none = main(await get("/search?q=qqqnothingqqq")); |
| 55 | 55 | expect(none).not.toContain('class="card'); |
| 56 | expect(none).toContain('<p class="muted">'); | |
| 56 | expect(none).toContain("data-next-step"); | |
| 57 | 57 | }); |
test/search-page.test.ts +32 −2
| @@ -28,7 +28,10 @@ const post = (path: string, body: unknown) => | ||
| 28 | 28 | body: JSON.stringify(body), |
| 29 | 29 | }); |
| 30 | 30 | |
| 31 | /** The `app` phase of Server-Timing (the handler's own time, not the proxy's), or NaN. Reported, never judged (#4429). */ | |
| 31 | /** | |
| 32 | * The `app` phase of Server-Timing (the handler's own time, not the proxy's), or NaN. | |
| 33 | * Reported, never judged (#4429). | |
| 34 | */ | |
| 32 | 35 | function appMs(res: Response): number { |
| 33 | 36 | const part = (res.headers.get("server-timing") ?? "").split(",").map((p) => p.trim()).find((p) => p.startsWith("app;")); |
| 34 | 37 | return Number(/dur=([\d.]+)/.exec(part ?? "")?.[1] ?? "NaN"); |
| @@ -107,7 +110,10 @@ test("results are in the server's HTML with every script stripped", async () => | ||
| 107 | 110 | expect(hrefs.some((h) => h.startsWith("/alice/plain-repo/blob/"))).toBe(true); |
| 108 | 111 | }); |
| 109 | 112 | |
| 110 | /** The release probe's `/search?q=a` (#11120): one letter greps no code, says so, and is bounded work. */ | |
| 113 | /** | |
| 114 | * The release probe's `/search?q=a` (#11120): one letter greps no code, says so, and is | |
| 115 | * bounded work. | |
| 116 | */ | |
| 111 | 117 | test("a one-letter query greps nothing, says why, and runs a bounded number of statements", async () => { |
| 112 | 118 | const anon = (path: string) => fetch(servers.url + path); |
| 113 | 119 | for (const ask of [get, anon]) { |
| @@ -151,3 +157,27 @@ test("the API and the MCP search tool answer one letter the same: no code, and a | ||
| 151 | 157 | expect(text).toContain("2 or more characters"); |
| 152 | 158 | expectWork(grepCount() - ran, { max: 0 }); |
| 153 | 159 | }); |
| 160 | ||
| 161 | test("an empty result offers one tell, encoded; an empty query offers none", async () => { | |
outdated
Add a case for a narrowed search (kind or live set) where the widen link differs from the current URL, and assert it is absent on the plain page. As written, the test accepts a link that points at the current page. |
||
| 162 | const q = `zzz-none <b>&"x y`; | |
| 163 | const html = await (await get(`/search?q=${encodeURIComponent(q)}`)).text(); | |
| 164 | expect(html).toContain('data-next-step'); | |
| 165 | // The plain page is already the widest search: no link back to itself. | |
| 166 | expect(html).not.toContain("data-widen"); | |
| 167 | expect(html).toContain(`href="/?text=${encodeURIComponent(q).replace(/%20/g, "+")}"`); | |
| 168 | expect(html).not.toContain("<b>&"); | |
| 169 | expect(html).toContain("<b>"); | |
| 170 | const none = await (await get("/search?q=")).text(); | |
| 171 | expect(none).not.toContain('data-next-step'); | |
| 172 | const hit = await (await get("/search?q=flux")).text(); | |
| 173 | expect(hit).not.toContain('data-next-step'); | |
| 174 | }); | |
| 175 | ||
| 176 | test("a narrowed empty search offers a widen link that differs from the page", async () => { | |
| 177 | for (const narrow of ["live=1", "code=all"]) { | |
| 178 | const html = await (await get(`/search?q=zzz-none&${narrow}`)).text(); | |
| 179 | expect(html).toContain("data-widen"); | |
| 180 | expect(html).toContain('href="/search?q=zzz-none" data-widen'); | |
| 181 | expect(html).toContain("data-tell"); | |
| 182 | } | |
| 183 | }); |
new above
offline
Principle 1/7: this link goes to the same URL on an all-kinds search (verified on the preview). Show it only when a filter narrowed the search. Use two rows with spacing instead of a middle-dot run-on, and shorter plain words.