Public: anyone can read this; the crew can change it.
Design: search results use §5's row and empty state, and no-hits leaves §5d #4017
scout/forge:scout/3649-design-search-results-use-5-s-row-and-em → main 4 commits fork
5 files
changed +38
−32
docs/DESIGN.md +1 −1
| @@ -390,7 +390,7 @@ gone, so this list only shrinks. | ||
| 390 | 390 | - **`style/content.ts`, prose (markdown)** — table cell alignment, built by `markdown.ts` as `ta-${align}`: `.ta-c` `.ta-r` |
| 391 | 391 | - **`style/content.ts`, diff viewer** — the diff table: its gutters, line kinds, file head and inline review comments: `.add` `.del` `.dh` `.diff` `.diff-body` `.diff-head` `.diff-note` `.diff-path` `.diff-stat` `.diff-stub` `.diff-summary` `.diff-table` `.dl` `.dl-review` `.dn` `.dn-comment` `.nonl` `.rc-hidden` `.rc-resolve` `.rc-resolved` `.wd` |
| 392 | 392 | - **`style/content.ts`, apps, runs, and the crew** — run pages, their logs and checks (a pull's look is §5's **look**): `.app-url` `.check-progress` `.check-steps` `.ln-forge` `.ln-pulse` `.ln-say` `.ln-tool` `.ln-you` `.log-tail-row` `.pinned-failures` `.pinned-slot` `.run-actions` `.run-jump` `.run-live` `.run-steer` `.run-summary` `.step-state` `.tests-bar` `.tests-words` `.txt` `.who` |
| 393 | - **`style/content.ts`, search results** — search results, the inbox's ask cards, the client list and the claim link: `.ask-acts` `.ask-card` `.ask-group` `.ask-kind` `.ask-meta` `.ask-more-acts` `.ask-pick` `.ask-pick-hit` `.ask-short` `.ask-waiting` `.claim-link-box` `.forges-sent` `.live-toggle` `.needs-you` `.no-hits` | |
| 393 | - **`style/content.ts`, search results** — search results, the inbox's ask cards, the client list and the claim link: `.ask-acts` `.ask-card` `.ask-group` `.ask-kind` `.ask-meta` `.ask-more-acts` `.ask-pick` `.ask-pick-hit` `.ask-short` `.ask-waiting` `.claim-link-box` `.forges-sent` `.live-toggle` `.needs-you` | |
| 394 | 394 | - **`pages/board.ts`** — the spend tables `spend.ts` draws, first on the board (the board itself is §5's **board**): `.spend-table` `.spend-totals` |
| 395 | 395 | - **`pages/map.ts`** — the map of what waits for what: `.map-ask` `.map-breath` `.map-canvas` `.map-card` `.map-counts` `.map-dot` `.map-edge` `.map-edge-crit` `.map-edge-done` `.map-empty` `.map-list` `.map-main` `.map-meta` `.map-node` `.map-pillars` `.map-rule` `.map-svg` `.map-title` `.map-tool` `.map-tools` `.map-who` `.map-who-i` `.map-who-n` `.map-word` `.map-wrap` |
| 396 | 396 | - **`studio/feed_style.ts`** — the home feed's cards, its composer and the apps rail: `.composer` `.composer-bar` `.fcard-form` `.fcard-reason` `.fcard-reply` `.fcard-text` `.fcard-unblock` `.fcard-who` `.fcard-why` `.feed` `.feed-head` `.kpi` `.kpi-note` `.kpi-spark` `.kpi-value` `.kpis` `.home-app` `.home-apps` `.home-apps-verbs` `.home-pick` `.home-rail` `.home-tabs` |
src/web/pages/search.ts +12 −22
| @@ -219,25 +219,17 @@ export function markMatch(text: string, query: string): Html { | ||
| 219 | 219 | /** One line of code, addressed the way the blob page addresses it. */ |
| 220 | 220 | function codeHitRow(hit: CodeHit, query: string): Html { |
| 221 | 221 | const at = `/${hit.repo.owner}/${hit.repo.name}`; |
| 222 | return html`<li> | |
| 223 | <a | |
| 224 | class="row code-hit" | |
| 225 | data-nav | |
| 226 | tabindex="-1" | |
| 227 | href="${at}/blob/HEAD/${hit.path}#L${hit.line}" | |
| 228 | > | |
| 229 | <span class="row-lead">${icon("code")}</span> | |
| 230 | <span class="row-main"> | |
| 231 | <span class="row-title mono" | |
| 232 | >${hit.repo.owner}/${hit.repo.name}<span class="muted">/</span | |
| 233 | >${hit.path}<span class="muted">:${hit.line}</span></span | |
| 234 | > | |
| 235 | <span class="row-meta code-line mono" | |
| 236 | >${markMatch(hit.text.trim(), query)}</span | |
| 237 | > | |
| 238 | </span> | |
| 239 | </a> | |
| 240 | </li>`; | |
| 222 | return row({ | |
| 223 | href: `${at}/blob/HEAD/${hit.path}${hit.line}`, | |
| 224 | nav: true, | |
| 225 | class: "code-hit", | |
| 226 | lead: icon("code"), | |
| 227 | title: html`${hit.repo.owner}/${hit.repo.name}<span class="muted">/</span | |
| 228 | >${hit.path}<span class="muted">:${hit.line}</span>`, | |
| 229 | titleClass: "mono", | |
| 230 | meta: markMatch(hit.text.trim(), query), | |
| 231 | metaClass: "code-line mono", | |
| 232 | }); | |
| 241 | 233 | } |
| 242 | 234 | |
| 243 | 235 | /** Each kind's words: [kind, chip, heading, nothing found]. */ |
| @@ -288,9 +280,7 @@ function section( | ||
| 288 | 280 | >`} |
| 289 | 281 | </h2> |
| 290 | 282 | ${rows.length === 0 |
| 291 | ? html`<p class="no-hits muted small"> | |
| 292 | ${icon(emptyIcon)}<span>${emptyText}</span> | |
| 293 | </p>` | |
| 283 | ? empty({ icon: emptyIcon, title: emptyText, note: "Try fewer or shorter words." }) | |
| 294 | 284 | : listCard(rows)} |
| 295 | 285 | ${after} |
| 296 | 286 | ${when( |
src/web/style/content.ts −6
| @@ -1140,12 +1140,6 @@ textarea.editor:focus-visible { outline: none; } | ||
| 1140 | 1140 | } |
| 1141 | 1141 | .live-toggle .ico { color: var(--faint); flex: none; } |
| 1142 | 1142 | .live-toggle a { color: var(--accent); } |
| 1143 | .no-hits { | |
| 1144 | display: flex; align-items: center; gap: 8px; | |
| 1145 | padding: 10px 12px; margin: 0; | |
| 1146 | border: 1px dashed var(--border); border-radius: var(--radius); | |
| 1147 | } | |
| 1148 | .no-hits .ico { color: var(--faint); flex: none; } | |
| 1149 | 1143 | /* The client list (#776): whom a forge is for is the point of the row, so |
| 1150 | 1144 | its line wraps rather than being cut off on a phone. */ |
| 1151 | 1145 | .forges-sent .row-meta { white-space: normal; } |
src/web/ui.ts +12 −3
| @@ -837,6 +837,11 @@ export interface RowOptions { | ||
| 837 | 837 | /** The row folds: it is the `<summary>` of a `<details>` holding `body`, |
| 838 | 838 | * open when `open` says so. Its `lead` is the caret. */ |
| 839 | 839 | fold?: { id: string; open: boolean; body: Html }; |
| 840 | /** Extra classes on the row, its title and its meta line (a kind of row's | |
| 841 | * own look, such as search's code hits). */ | |
| 842 | class?: string; | |
| 843 | titleClass?: string; | |
| 844 | metaClass?: string; | |
| 840 | 845 | } |
| 841 | 846 | |
| 842 | 847 | /** One list row. `<a>` when it navigates, `<div>` when it holds its own |
| @@ -848,16 +853,20 @@ export function row(o: RowOptions): Html { | ||
| 848 | 853 | : null} |
| 849 | 854 | <span class="row-main"> |
| 850 | 855 | <span |
| 851 | class="row-title" | |
| 856 | class="${o.titleClass ? `row-title ${o.titleClass}` : "row-title"}" | |
| 852 | 857 | ${o.titleAttr ? html`title="${o.titleAttr}"` : null} |
| 853 | 858 | >${o.title}</span |
| 854 | 859 | > |
| 855 | ${o.meta ? html`<span class="row-meta">${o.meta}</span>` : null} | |
| 860 | ${o.meta | |
| 861 | ? html`<span class="${o.metaClass ? `row-meta ${o.metaClass}` : "row-meta"}" | |
| 862 | >${o.meta}</span | |
| 863 | >` | |
| 864 | : null} | |
| 856 | 865 | </span> |
| 857 | 866 | ${o.trail && o.trail.text.trim() !== "" |
| 858 | 867 | ? html`<span class="row-trail">${o.trail}</span>` |
| 859 | 868 | : null}`; |
| 860 | const attrs = html`class="row" | |
| 869 | const attrs = html`class="${o.class ? `row ${o.class}` : "row"}" | |
| 861 | 870 | ${o.state ? html`data-state="${o.state}"` : null} |
| 862 | 871 | ${o.nav ? raw('data-nav tabindex="-1"') : null}`; |
| 863 | 872 | const data = Object.entries(o.data ?? {}) |
test/studio-search.test.ts +13
| @@ -190,6 +190,19 @@ describe("finding things in the studio: /search", () => { | ||
| 190 | 190 | expect(mainOf(html)).not.toContain("widgets"); |
| 191 | 191 | }); |
| 192 | 192 | |
| 193 | test("a search with no hits says so in §5's empty state, never in .no-hits", async () => { | |
| 194 | const html = mainOf(await (await asAlice("/search?q=zzqxnomatch")).text()); | |
| 195 | expect(html).not.toContain("no-hits"); | |
| 196 | expect(html).toContain('class="card empty"'); | |
| 197 | expect(html).toContain("No app or repository matches"); | |
| 198 | expect(html).toContain("No issue or pull request matches"); | |
| 199 | expect(html).toContain("No line of code matches"); | |
| 200 | expect(html).toContain("Try fewer or shorter words."); | |
| 201 | const hits = mainOf(await (await asAlice("/search?q=chess&kind=repos")).text()); | |
| 202 | expect(hits).not.toContain("no-hits"); | |
| 203 | expect(hits).not.toContain("No app or repository matches"); | |
| 204 | }); | |
| 205 | ||
| 193 | 206 | test("an overlong query is bounded, not a crash", async () => { |
| 194 | 207 | const res = await asAlice(`/search?q=${"chess ".repeat(100)}`); |
| 195 | 208 | expect(res.status).toBe(200); |
new above
offline