Public: anyone can read this; the crew can change it.
The search page's live toggle draws §5's field and btn, and .live-toggle leaves the markup #4260
scout/forge:scout/4195-the-search-page-s-live-toggle-draws-5-s → main 9 commits fork 3 threads · 3 unresolved
4 files
changed +86
−23
docs/DESIGN.md +5
| @@ -398,8 +398,13 @@ gone, so this list only shrinks. | ||
| 398 | 398 | - **`style/content.ts`, code view** — the source view and the syntax-highlight token classes `highlight-html.ts` builds as `tok-${kind}`: `.blob-view` `.ln` `.tok-attribute` `.tok-comment` `.tok-constant` `.tok-decorator` `.tok-deleted` `.tok-emphasis` `.tok-function` `.tok-heading` `.tok-inserted` `.tok-keyword` `.tok-link` `.tok-meta` `.tok-number` `.tok-operator` `.tok-plain` `.tok-property` `.tok-punctuation` `.tok-regex` `.tok-string` `.tok-tag` `.tok-type` `.tok-variable` |
| 399 | 399 | - **`style/content.ts`, prose (markdown)** — table cell alignment, built by `markdown.ts` as `ta-${align}`: `.ta-c` `.ta-r` |
| 400 | 400 | - **`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` |
| 401 | <<<<<<< HEAD | |
| 402 | - **`style/content.ts`, apps, runs, and the crew** — run pages, their logs and checks (a pull's look is §5's **look**): `.ln-forge` `.ln-pulse` `.ln-say` `.ln-tool` `.ln-you` `.log-tail-row` `.pinned-failures` `.pinned-slot` `.run-jump` `.run-live` `.run-steer` `.txt` `.who` | |
| 403 | - **`style/content.ts`, search results** — search results, the inbox's ask cards: `.ask-acts` `.ask-card` `.ask-group` `.ask-kind` `.ask-meta` `.ask-more-acts` `.ask-pick` `.ask-pick-hit` `.ask-short` `.ask-waiting` | |
| 404 | ======= | |
| 401 | 405 | - **`style/content.ts`, apps, runs, and the crew** — run pages, their logs and checks (a pull's look is §5's **look**): `.ln-forge` `.ln-pulse` `.ln-say` `.ln-tool` `.ln-you` `.log-tail-row` `.pinned-failures` `.pinned-slot` `.txt` `.who` |
| 402 | 406 | - **`style/content.ts`, search results** — search results, the inbox's ask cards: `.ask-acts` `.ask-card` `.ask-group` `.ask-kind` `.ask-meta` `.ask-more-acts` `.ask-pick` `.ask-pick-hit` `.ask-short` `.ask-waiting` `.live-toggle` |
| 407 | >>>>>>> origin/main | |
| 403 | 408 | - **`pages/board.ts`** — the board itself is §5's **board**; the spend tables `spend.ts` draws wear §5's `.table` and `.stack`, no class of their own |
| 404 | 409 | - **`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-rule` `.map-svg` `.map-title` `.map-tool` `.map-tools` `.map-who` `.map-who-i` `.map-who-n` `.map-word` `.map-wrap` |
| 405 | 410 | - **`studio/feed_style.ts`** — the home feed's cards and its composer (the apps rail is §5's card, row and btn; an admin's tick boxes and Archive are always shown, deliberately, with no Select toggle): `.composer` `.composer-bar` `.fcard-form` `.fcard-reason` `.fcard-reply` `.fcard-text` `.fcard-unblock` `.fcard-who` `.fcard-why` `.feed` `.feed-head` `.home-tabs` |
src/web/pages/search.ts +22 −17
| @@ -425,26 +425,31 @@ export async function searchPage(ctx: Ctx): Promise<Response> { | ||
| 425 | 425 | })), |
| 426 | 426 | ); |
| 427 | 427 | |
| 428 | // §5 list row: a globe lead, the sentence as the title (`.break` keeps a | |
| 429 | // long origin name from widening the page), one `.btn` as the trail. | |
| 430 | // `.setting-list` lets both lines wrap beside the btn on a phone. | |
| 428 | 431 | const liveToggle = when( |
| 429 | 432 | ctx.auth.user !== undefined, |
| 430 | 433 | () => |
| 431 | html`<p class="live-toggle small"> | |
| 432 | ${icon("globe")} | |
| 433 | ${a.live | |
| 434 | ? html`<span | |
| 435 | >Asking every connected origin's own search, live. | |
| 436 | <a href="${searchHref(a, { live: false })}">Use the cache</a | |
| 437 | >.</span | |
| 438 | >` | |
| 439 | : html`<span | |
| 440 | >Origins are searched from the cache. | |
| 441 | <a href="${searchHref(a, { live: true })}" | |
| 442 | >Search live on origins</a | |
| 443 | > | |
| 444 | — a round trip to each connected origin, so it costs a | |
| 445 | moment.</span | |
| 446 | >`} | |
| 447 | </p>`, | |
| 434 | html`<div class="setting-list">${listCard( | |
| 435 | [row({ | |
| 436 | lead: icon("globe"), | |
| 437 | title: html`<span class="break" | |
outdated
The title span is |
||
| 438 | >${a.live | |
| 439 | ? "Asking every connected origin's own search, live." | |
| 440 | : "Origins are searched from the cache."}</span | |
| 441 | >`, | |
| 442 | ...(a.live | |
| 443 | ? {} | |
outdated
This meta is the cost warning and it is the line that gets ellipsized first on a narrow screen. It must stay readable; make it wrap. |
||
| 444 | : { meta: html`Live is a round trip to each connected origin, so it costs a moment.` }), | |
| 445 | trail: btn(a.live ? "Use the cache" : "Search live on origins", { | |
| 446 | href: searchHref(a, { live: !a.live }), | |
| 447 | variant: "outline", | |
| 448 | size: "sm", | |
| 449 | }), | |
| 450 | })], | |
| 451 | { extra: "mt" }, | |
| 452 | )}</div>`, | |
| 448 | 453 | ); |
| 449 | 454 | |
| 450 | 455 | const rows: Record<SearchKind, () => [Html[], boolean]> = { |
src/web/style/content.ts −6
| @@ -1029,12 +1029,6 @@ textarea.editor:focus-visible { outline: none; } | ||
| 1029 | 1029 | background: color-mix(in srgb, var(--attn) 35%, transparent); |
| 1030 | 1030 | color: var(--fg); border-radius: 2px; padding: 0 1px; |
| 1031 | 1031 | } |
| 1032 | .live-toggle { | |
| 1033 | display: flex; align-items: center; gap: 6px; | |
| 1034 | margin: 10px 0 0; color: var(--muted-fg); | |
| 1035 | } | |
| 1036 | .live-toggle .ico { color: var(--faint); flex: none; } | |
| 1037 | .live-toggle a { color: var(--accent); } | |
| 1038 | 1032 | |
| 1039 | 1033 | } |
| 1040 | 1034 | /* What needs you, pinned on the home: the bulk step's select as wide as |
test/search-live-toggle.test.ts added +59
| @@ -0,0 +1,59 @@ | ||
| 1 | /** The search page's live toggle is drawn with §5's row and btn, not `.live-toggle` (#4195). */ | |
| 2 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 3 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 4 | import { tmpdir } from "node:os"; | |
| 5 | import { join } from "node:path"; | |
| 6 | import { createApp } from "../src/app.ts"; | |
| 7 | import { serve } from "../src/http/server.ts"; | |
| 8 | import { adminCookie } from "./helpers/admin.ts"; | |
| 9 | ||
| 10 | let dir: string; | |
| 11 | let app: ReturnType<typeof createApp>; | |
| 12 | let servers: Awaited<ReturnType<typeof serve>>; | |
| 13 | let cookie: string; | |
| 14 | ||
| 15 | beforeAll(async () => { | |
| 16 | dir = await mkdtemp(join(tmpdir(), "forge-search-live-")); | |
| 17 | app = createApp({ dataDir: dir, port: 0 }); | |
| 18 | servers = await serve(app); | |
| 19 | cookie = await adminCookie(app, { | |
| 20 | username: "alice", email: "[email protected]", password: "a-good-passphrase", | |
| 21 | }); | |
| 22 | }, 60_000); | |
| 23 | ||
| 24 | afterAll(async () => { | |
| 25 | servers.stop(); | |
| 26 | app.close(); | |
| 27 | await rm(dir, { recursive: true, force: true }); | |
| 28 | }); | |
| 29 | ||
| 30 | const page = async (qs: string, signedIn = true) => | |
| 31 | (await fetch(`${servers.url}/search?${qs}`, { headers: signedIn ? { cookie } : {} })).text(); | |
| 32 | ||
| 33 | test("cache mode: a row with a btn link to live, no .live-toggle", async () => { | |
| 34 | const body = await page("q=zebra"); | |
| 35 | expect(body).not.toContain("live-toggle"); | |
| 36 | expect(body).toContain("Origins are searched from the cache."); | |
| 37 | expect(body).toContain("a round trip to each connected origin"); | |
| 38 | expect(body).toMatch(/href="\/search\?q=zebra&live=1"[^>]*class="btn"/); | |
| 39 | expect(body).toContain("Search live on origins"); | |
| 40 | expect(body).toContain('class="break"'); | |
| 41 | expect(body).toMatch(/class="setting-list"><div\s+class="card mt"/); | |
| 42 | }); | |
| 43 | ||
| 44 | test("live mode: the way back to the cache is a btn link without live=1", async () => { | |
| 45 | const body = await page("q=zebra&live=1"); | |
| 46 | expect(body).not.toContain("live-toggle"); | |
| 47 | expect(body).toContain("Asking every connected origin's own search, live."); | |
| 48 | expect(body).toMatch(/href="\/search\?q=zebra&live=1"/); // the filter chips carry it on | |
| 49 | expect(body).toMatch(/href="\/search\?q=zebra"[^>]*class="btn"/); | |
| 50 | expect(body).toContain("Use the cache"); | |
| 51 | expect(body).not.toContain("Search live on origins"); | |
| 52 | expect(body).toMatch(/class="setting-list"><div\s+class="card mt"/); | |
| 53 | }); | |
| 54 | ||
| 55 | test("signed out: no toggle at all", async () => { | |
| 56 | const body = await page("q=zebra", false); | |
| 57 | expect(body).not.toContain("Search live on origins"); | |
| 58 | expect(body).not.toContain("live-toggle"); | |
| 59 | }); |
new above
offline
Bare <ul class="list mt"> gives the row no card surface or border, unlike every other §5 row. Use listCard([row({...})], {}) with the mt spacing on the card, and drop data-live-search: nothing reads it.