Public: anyone can read this; the crew can change it.
/search and `GET /api/v1/search` find guides too, as their own group above issues and code #13926
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13889-search-and-get-api-v1-search-find-guides → main 7 commits fork 6 threads · 6 unresolved
docs/design/attention-budget.json +5 −5
| @@ -137,16 +137,16 @@ | ||
| 137 | 137 | }, |
| 138 | 138 | "search results": { |
| 139 | 139 | "390": { |
| 140 | "words": 58, | |
| 141 | "blocks": 5, | |
| 140 | "words": 98, | |
| 141 | "blocks": 13, | |
| 142 | 142 | "colours": 1 |
| 143 | 143 | }, |
| 144 | 144 | "1280": { |
| 145 | "words": 58, | |
| 146 | "blocks": 5, | |
| 145 | "words": 98, | |
| 146 | "blocks": 13, | |
| 147 | 147 | "colours": 1 |
| 148 | 148 | }, |
| 149 | "note": "/search?q=forge, signed in as an admin." | |
| 149 | "note": "Raised from 58 words and 5 blocks for the Guides group (#13889): two guide rows, each a title and a 60-character snippet, only when a guide matches; the API and the terminal carry five." | |
| 150 | 150 | }, |
| 151 | 151 | "map": { |
| 152 | 152 | "390": { |
docs/features/README.md +1
| @@ -80,6 +80,7 @@ Read with the guide page [What a forge is](../guide-what-a-forge-is.md). | ||
| 80 | 80 | - [](page-help.md) |
| 81 | 81 | - [](palette-rows.md) |
| 82 | 82 | - [](search-is-palette.md) |
| 83 | - [](search-finds-guides.md) | |
| 83 | 84 | - [](pick-list.md) |
| 84 | 85 | - [](palette-recent.md) |
| 85 | 86 |
docs/features/search-finds-guides.md added +11
| @@ -0,0 +1,11 @@ | ||
| 1 | # Search finds guides | |
| 2 | ||
| 3 | `/search?q=fork` shows a **Guides** group: up to five guide pages whose title | |
| 4 | or text holds the query, each with its path and a snippet. When a guide's title | |
| 5 | holds every word asked, Guides leads the page; otherwise it follows | |
| 6 | repositories. | |
| 7 | ||
| 8 | The same group comes back from `GET /api/v1/search` (`docs`, all five) and the | |
| 9 | MCP `search` tool. The page shows the first two with a short snippet, to keep | |
outdated
Both doors: this sentence admits the terminal's search does not show guides. Build the terminal side in src/tui/ and document it here. |
||
| 10 | the first view small. The terminal's palette (`ctrl+p`) has a **Guides** | |
| 11 | section above Code: Enter reads the guide in the docs screen. |
src/actions/search.ts +13 −1
| @@ -31,11 +31,14 @@ import { | ||
| 31 | 31 | type IssueHit, |
| 32 | 32 | type RepoHit, |
| 33 | 33 | type CodeHit, |
| 34 | type DocsHit, | |
| 35 | MAX_DOC_HITS, | |
| 34 | 36 | type SearchKind, |
| 35 | 37 | type SearchResults, |
| 36 | 38 | } from "../core/search.ts"; |
| 37 | 39 | import type { Repo } from "../core/repos.ts"; |
| 38 | 40 | import type { User } from "../core/users.ts"; |
| 41 | import { searchDocs } from "../view/docs.ts"; | |
| 39 | 42 | import { providerForOrigin } from "../origins/credential.ts"; |
| 40 | 43 | |
| 41 | 44 | /** Default page size for each list. */ |
| @@ -130,6 +133,7 @@ export async function search( | ||
| 130 | 133 | repos: [], |
| 131 | 134 | issues: [], |
| 132 | 135 | code: [], |
| 136 | docs: [], | |
| 133 | 137 | truncated: { repos: false, issues: false, code: false }, |
| 134 | 138 | moreCode: false, |
| 135 | 139 | codeSkipped: false, |
| @@ -200,10 +204,18 @@ export async function search( | ||
| 200 | 204 | : { hits: [], truncated: false, more: false, skipped: false }; |
| 201 | 205 | if (wants("code")) phase("code", performance.now() - codeAt); |
| 202 | 206 | |
| 207 | // Guides are public and live in the one built index /docs reads: no file is | |
| 208 | // read per request. A search scoped to one repository has no guides. | |
| 209 | const docs: DocsHit[] = | |
| 210 | kind === "all" && input.repo === undefined | |
| 211 | ? searchDocs(q, MAX_DOC_HITS).map((h) => ({ title: h.title, path: `/docs/${h.name}`, snippet: h.snippet })) | |
| 212 | : []; | |
| 213 | ||
| 203 | 214 | return { |
| 204 | 215 | repos, |
| 205 | 216 | issues, |
| 206 | 217 | code: code.hits, |
| 218 | docs, | |
| 207 | 219 | truncated: { |
| 208 | 220 | repos: repos.length >= limit, |
| 209 | 221 | issues: localIssueCount >= limit, |
| @@ -308,5 +320,5 @@ export async function searchWithin( | ||
| 308 | 320 | const ms = spent[name]; |
| 309 | 321 | if (ms !== undefined) input.phase?.(name, ms); |
| 310 | 322 | } |
| 311 | return { ...hits, truncated, moreCode, codeSkipped }; | |
| 323 | return { ...hits, docs: [], truncated, moreCode, codeSkipped }; | |
| 312 | 324 | } |
src/contract/openapi/routes/getApiV1Search.ts +1 −1
| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | import { type Route, limitTo } from "../shared.ts"; |
| 2 | 2 | import { SEARCH_LIMIT_MAX } from "../../../actions/search.ts"; |
| 3 | 3 | |
| 4 | export const route: Route = { method: "get", path: "/api/v1/search", summary: "Search issues, pulls, repositories and code; `kind` narrows it", auth: false, role: "anonymous", query: { q: "string", kind: "string", limit: limitTo(SEARCH_LIMIT_MAX) }, refusals: { invalid_kind: "kind is not all, repos, issues or code (422)", invalid_limit: "limit is not a whole number from 1 to 100 (422)" }, reply: { repos: "array", issues: "array", code: "array", truncated: "object", moreCode: "boolean", codeSkipped: "boolean", note: "string, only when q is blank: what to send" } }; | |
| 4 | export const route: Route = { method: "get", path: "/api/v1/search", summary: "Search guides, issues, pulls, repositories and code; `kind` narrows it", auth: false, role: "anonymous", query: { q: "string", kind: "string", limit: limitTo(SEARCH_LIMIT_MAX) }, refusals: { invalid_kind: "kind is not all, repos, issues or code (422)", invalid_limit: "limit is not a whole number from 1 to 100 (422)" }, reply: { repos: "array", issues: "array", code: "array", docs: "array of { title, path, snippet }, at most 5, guides matching; only for kind all", truncated: "object", moreCode: "boolean", codeSkipped: "boolean", note: "string, only when q is blank: what to send" } }; |
src/core/search.ts +11
| @@ -155,10 +155,21 @@ export interface CodeHit { | ||
| 155 | 155 | readonly text: string; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | /** A guide that matched: its title, where to read it and a line around the match. */ | |
| 159 | export interface DocsHit { | |
| 160 | readonly title: string; | |
| 161 | readonly path: string; | |
| 162 | readonly snippet: string; | |
| 163 | } | |
| 164 | ||
| 165 | export const MAX_DOC_HITS = 5; | |
| 166 | ||
| 158 | 167 | export interface SearchResults { |
| 159 | 168 | readonly repos: readonly RepoHit[]; |
| 160 | 169 | readonly issues: readonly IssueHit[]; |
| 161 | 170 | readonly code: readonly CodeHit[]; |
| 171 | /** Guides matching, from the index /docs uses: at most `MAX_DOC_HITS`; only for kind `all`. */ | |
| 172 | readonly docs: readonly DocsHit[]; | |
| 162 | 173 | /** Which lists hit their ceiling — a client can say "and more". */ |
| 163 | 174 | readonly truncated: { |
| 164 | 175 | readonly repos: boolean; |
src/http/mcp/tools/search.ts +1 −1
| @@ -3,7 +3,7 @@ import { searchRun } from "../reads.ts"; | ||
| 3 | 3 | |
| 4 | 4 | export const tool: Tool = { |
| 5 | 5 | name: "search", |
| 6 | doc: "`{ q, kind?, limit?, repo?, all? }`: issues, pulls, repositories and code you can read, the same results as /search, drawn as the `ui://forge/search` card; `repo` keeps to one; `moreCode` says the code grep stopped at its budget, `all` greps the rest", | |
| 6 | doc: "`{ q, kind?, limit?, repo?, all? }`: guides (`docs`, kind all), issues, pulls, repositories and code you can read, the same results as /search, drawn as the `ui://forge/search` card; `repo` keeps to one; `moreCode` says the code grep stopped at its budget, `all` greps the rest", | |
| 7 | 7 | description: |
| 8 | 8 | "Find issues, pulls, repositories and code you can read; `kind` and `repo` narrow.", |
| 9 | 9 | inputSchema: { |
src/tui/app/palette.ts +9 −3
| @@ -173,12 +173,14 @@ export class Palette { | ||
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | 175 | * Everything drawable, headings included, in section order: search results |
| 176 | * first (they answer the question that was typed), commands last. | |
| 176 | * first (they answer the question that was typed), commands last. Guides | |
| 177 | * are the exception: they follow the commands, so a word that is both a | |
| 178 | * verb and a guide's title ("Queue") still puts the verb under Enter. | |
| 177 | 179 | */ |
| 178 | 180 | rows(): Row[] { |
| 179 | 181 | const out: Row[] = []; |
| 180 | 182 | let section = ""; |
| 181 | for (const item of this.results) { | |
| 183 | const push = (item: PaletteItem): void => { | |
| 182 | 184 | if (item.section !== section) { |
| 183 | 185 | section = item.section; |
| 184 | 186 | out.push({ kind: "header", label: section }); |
| @@ -189,7 +191,9 @@ export class Palette { | ||
| 189 | 191 | indices: item.indices ?? [], |
| 190 | 192 | mark: item.mark ?? "", |
| 191 | 193 | }); |
| 192 | } | |
| 194 | }; | |
| 195 | const guides = this.results.filter((i) => i.section === "Guides"); | |
| 196 | for (const item of this.results) if (item.section !== "Guides") push(item); | |
| 193 | 197 | const verbs = this.matches(); |
| 194 | 198 | if (verbs.length > 0) { |
| 195 | 199 | if (out.length > 0) out.push({ kind: "header", label: "Commands" }); |
| @@ -201,6 +205,8 @@ export class Palette { | ||
| 201 | 205 | mark: "", |
| 202 | 206 | }); |
| 203 | 207 | } |
| 208 | section = ""; | |
| 209 | for (const item of guides) push(item); | |
| 204 | 210 | return out; |
| 205 | 211 | } |
| 206 | 212 |
src/tui/forge.ts +16 −1
| @@ -103,7 +103,8 @@ import { noteRead, telemetryReader } from "../actions/telemetry.ts"; | ||
| 103 | 103 | import { queuesFor, systemFor } from "../system/telemetry.ts"; |
| 104 | 104 | import { apiScreen } from "./screens/api.ts"; |
| 105 | 105 | import { changelogScreen } from "./screens/changelog.ts"; |
| 106 | import { docsScreen } from "./screens/docs.ts"; | |
| 106 | import { docScreen, docsScreen } from "./screens/docs.ts"; | |
| 107 | import { anyDocEntry } from "../view/docs.ts"; | |
| 107 | 108 | import { keeperScreen } from "./screens/keeper.ts"; |
| 108 | 109 | import { releasesScreen } from "./screens/releases.ts"; |
| 109 | 110 | import { mayRead } from "../release/gate.ts"; |
| @@ -856,6 +857,20 @@ export function forgeSearch(session: Session): (ctx: Ctx) => PaletteSearch { | ||
| 856 | 857 | }); |
| 857 | 858 | } |
| 858 | 859 | |
| 860 | // Guides: public, from the index /docs reads; Enter reads the guide. | |
| 861 | for (const hit of found.docs) { | |
| 862 | const entry = anyDocEntry(hit.path.replace(/^\/docs\//, "")); | |
| 863 | if (entry === undefined) continue; | |
| 864 | items.push({ | |
| 865 | id: `doc:${entry.name}`, | |
| 866 | section: "Guides", | |
| 867 | mark: mark("file", G.dot), | |
| 868 | title: hit.title, | |
| 869 | hint: hit.snippet.slice(0, 60), | |
| 870 | run: () => ctx.push(docScreen(ctx, entry, sshOn(session.app.db))), | |
| 871 | }); | |
| 872 | } | |
| 873 | ||
| 859 | 874 | for (const hit of found.code) { |
| 860 | 875 | const where = `${hit.repo.owner}/${hit.repo.name}`; |
| 861 | 876 | items.push({ |
src/tui/screens/docs.ts +1 −1
| @@ -15,7 +15,7 @@ export function docRows(entries: readonly DocEntry[]): ListRow[] { | ||
| 15 | 15 | return entries.map((e) => ({ title: e.title })); |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | function docScreen(ctx: Ctx, entry: DocEntry, ssh: boolean): Screen { | |
| 18 | export function docScreen(ctx: Ctx, entry: DocEntry, ssh: boolean): Screen { | |
| 19 | 19 | const scroll = new Scroll(); |
| 20 | 20 | let cache: { w: number; lines: ReturnType<typeof renderMarkdown> } | undefined; |
| 21 | 21 | const text = docText(entry, ssh); |
src/web/pages/search.ts +31 −8
| @@ -31,6 +31,7 @@ import { | ||
| 31 | 31 | greppable, |
| 32 | 32 | searchKind, |
| 33 | 33 | type CodeHit, |
| 34 | type DocsHit, | |
| 34 | 35 | type IssueHit, |
| 35 | 36 | type RepoHit, |
| 36 | 37 | type SearchKind, |
| @@ -300,6 +301,25 @@ function searchHref( | ||
| 300 | 301 | return `/search?${params.toString()}`; |
| 301 | 302 | } |
| 302 | 303 | |
| 304 | /** Whether a guide's title holds every word asked: then guides lead the page. */ | |
| 305 | export function guideTitleMatches(query: string, docs: readonly DocsHit[]): boolean { | |
| 306 | const words = query.toLowerCase().split(/\s+/).filter((w) => w !== ""); | |
| 307 | return words.length > 0 && docs.some((d) => words.every((w) => d.title.toLowerCase().includes(w))); | |
| 308 | } | |
| 309 | ||
| 310 | /** Guide rows shown on the page; the API and the terminal carry all five. */ | |
| 311 | const PAGE_GUIDES = 2; | |
| 312 | /** A snippet the page shows: enough to tell the guides apart, no more. */ | |
outdated
Dead parameter: |
||
| 313 | const PAGE_SNIPPET = 60; | |
| 314 | ||
| 315 | /** The guides group: a heading over rows linking to /docs, no new class. */ | |
outdated
Principles 2/7: guide rows reuse icon("repo"), which reads as a repository. Use a guide/doc icon, and drop the count in the h2 (principle 1: nothing says things twice). |
||
| 316 | function docsSection(docs: readonly DocsHit[]): Html { | |
| 317 | return html`<section id="docs" aria-labelledby="h-docs"> | |
| 318 | <h2 class="mt" id="h-docs">Guides</h2> | |
| 319 | ${rowsUnderHeading(docs.slice(0, PAGE_GUIDES).map((d) => row({ href: d.path, nav: true, lead: icon("file"), title: d.title, meta: html`${d.snippet.slice(0, PAGE_SNIPPET)}` })))} | |
| 320 | </section>`; | |
| 321 | } | |
| 322 | ||
| 303 | 323 | function section( |
| 304 | 324 | a: Asked, |
| 305 | 325 | [kind, , title, emptyText]: Words, |
| @@ -513,7 +533,16 @@ export async function searchPage(ctx: Ctx): Promise<Response> { | ||
| 513 | 533 | |
| 514 | 534 | const nothing = |
| 515 | 535 | a.kind === "all" && |
| 516 | found.repos.length + found.issues.length + found.code.length === 0; | |
| 536 | found.repos.length + found.issues.length + found.code.length + found.docs.length === 0; | |
| 537 | const guides = found.docs.length === 0 ? null : docsSection(found.docs); | |
| 538 | const guidesFirst = guideTitleMatches(a.query, found.docs); | |
| 539 | const sections = WORDS | |
| 540 | .filter(([kind]) => kind !== "all" && (a.kind === "all" || a.kind === kind)) | |
| 541 | .map((w) => ({ kind: w[0], html: section(a, w, ...rows[w[0]](), w[0] === "code" ? moreCode : null) })); | |
| 542 | const ordered = [ | |
| 543 | ...(guidesFirst ? [guides] : []), | |
| 544 | ...sections.flatMap((s) => (s.kind === "repos" && !guidesFirst ? [s.html, guides] : [s.html])), | |
| 545 | ]; | |
| 517 | 546 | const body = html`<div data-search>${pageHead(html`Results for “${echoed(a.query)}”`)} ${form}${trimmed} |
| 518 | 547 | <div class="bar mb">${chips}</div> |
| 519 | 548 | ${liveToggle} |
| @@ -550,13 +579,7 @@ export async function searchPage(ctx: Ctx): Promise<Response> { | ||
| 550 | 579 | )} or <a href="/?${new URLSearchParams({ text: a.query }).toString()}" data-tell>tell the crew</a>`, |
| 551 | 580 | )} |
| 552 | 581 | </p>` |
| 553 | : WORDS | |
| 554 | .filter( | |
| 555 | ([kind]) => kind !== "all" && (a.kind === "all" || a.kind === kind), | |
| 556 | ) | |
| 557 | .map((w) => | |
| 558 | section(a, w, ...rows[w[0]](), w[0] === "code" ? moreCode : null), | |
| 559 | )}</div>`; | |
| 582 | : ordered}</div>`; | |
| 560 | 583 | const response = page({ ctx, title: `Search · ${echoed(a.query)}`, body, styleCss: SEARCH_CSS }); |
| 561 | 584 | notePhase(ctx.request, "render", performance.now() - rendering); |
| 562 | 585 | return response; |
test/search-docs.test.ts added +107
| @@ -0,0 +1,107 @@ | ||
| 1 | /** Search finds guides as their own `docs` group, from the index /docs reads (#13889). */ | |
| 2 | import { afterAll, beforeAll, expect, spyOn, test } from "bun:test"; | |
| 3 | import * as fs from "node:fs"; | |
| 4 | import { expectWork } from "./helpers/work.ts"; | |
| 5 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 6 | import { tmpdir } from "node:os"; | |
| 7 | import { join } from "node:path"; | |
| 8 | import { createApp } from "../src/app.ts"; | |
| 9 | import { search } from "../src/actions/search.ts"; | |
| 10 | import { guideTitleMatches } from "../src/web/pages/search.ts"; | |
| 11 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 12 | import { searchDocs } from "../src/view/docs.ts"; | |
| 13 | import { forgeSearch } from "../src/tui/forge.ts"; | |
| 14 | import { Session } from "../src/tui/session.ts"; | |
| 15 | import type { Ctx } from "../src/tui/app/app.ts"; | |
| 16 | ||
| 17 | let dir = ""; | |
| 18 | let app: ReturnType<typeof createApp>; | |
| 19 | let servers: Servers; | |
| 20 | ||
| 21 | beforeAll(async () => { | |
| 22 | dir = await mkdtemp(join(tmpdir(), "forge-search-docs-")); | |
| 23 | app = createApp({ dataDir: dir, port: 0 }); | |
| 24 | servers = await serve(app); | |
| 25 | }); | |
| 26 | afterAll(async () => { | |
| 27 | servers.stop(); | |
| 28 | await rm(dir, { recursive: true, force: true }); | |
| 29 | }); | |
| 30 | ||
| 31 | test("a guide is found by a title word, with title, path and snippet, at most 5", async () => { | |
| 32 | const found = await search(app, undefined, { q: "fork" }); | |
| 33 | expect(found.docs.length).toBeGreaterThan(0); | |
| 34 | expect(found.docs.length).toBeLessThanOrEqual(5); | |
| 35 | const first = found.docs[0]!; | |
| 36 | expect(first.path).toMatch(/^\/docs\/.+\.md$/); | |
| 37 | expect(first.title).not.toBe(""); | |
| 38 | expect(first.snippet).not.toBe(""); | |
| 39 | }); | |
| 40 | ||
| 41 | test("a guide is found by a body word that is in no title", async () => { | |
outdated
|
||
| 42 | // "ulid" is in the body of the feed-cursor note and in no title. | |
| 43 | const found = await search(app, undefined, { q: "ulid" }); | |
| 44 | const hit = found.docs.find((d) => d.path === "/docs/features/feed-cursor.md"); | |
| 45 | expect(hit).toBeDefined(); | |
| 46 | expect(hit!.title.toLowerCase()).not.toContain("ulid"); | |
| 47 | expect(hit!.snippet.toLowerCase()).toContain("ulid"); | |
| 48 | }); | |
| 49 | ||
| 50 | test("guides follow repositories when no title holds the query, and lead when one does", async () => { | |
| 51 | const body = await (await fetch(`${servers.url}/search?q=ulid`)).text(); | |
| 52 | expect(body).toContain('id="docs"'); | |
| 53 | expect(body.indexOf('id="repos"')).toBeLessThan(body.indexOf('id="docs"')); | |
| 54 | const lead = await (await fetch(`${servers.url}/search?q=fork`)).text(); | |
| 55 | expect(lead.indexOf('id="docs"')).toBeLessThan(lead.indexOf('id="repos"')); | |
| 56 | }); | |
| 57 | ||
| 58 | test("the page shows two guides and no count; the index is built once and a search reads no file", async () => { | |
| 59 | const page = await (await fetch(`${servers.url}/search?q=fork`)).text(); | |
| 60 | const docs = page.slice(page.indexOf('id="docs"'), page.indexOf('id="repos"')); | |
| 61 | expect(docs.match(/href="\/docs\//g)?.length).toBe(2); | |
| 62 | expect(docs).toMatch(/<h2[^>]*>Guides<\/h2>/); | |
| 63 | searchDocs("fork", 5); // warm | |
| 64 | const reads = spyOn(fs, "readFileSync"); | |
| 65 | try { | |
| 66 | for (let i = 0; i < 10; i++) await search(app, undefined, { q: "fork" }); | |
| 67 | expectWork(reads.mock.calls.filter((c) => String(c[0]).includes("/docs/")).length, { max: 0 }); | |
| 68 | } finally { | |
| 69 | reads.mockRestore(); | |
| 70 | } | |
| 71 | }); | |
| 72 | ||
| 73 | test("an empty q answers as before, with an empty docs group; kind repos has none", async () => { | |
| 74 | const empty = await search(app, undefined, { q: " " }); | |
| 75 | expect(empty.docs).toEqual([]); | |
| 76 | expect(empty.repos).toEqual([]); | |
| 77 | expect((await search(app, undefined, { q: "fork", kind: "repos" })).docs).toEqual([]); | |
| 78 | }); | |
| 79 | ||
| 80 | test("the API and the page carry the group; guides lead when a title matches", async () => { | |
| 81 | const api = (await (await fetch(`${servers.url}/api/v1/search?q=fork`)).json()) as { docs: { title: string }[] }; | |
| 82 | expect(api.docs.length).toBeGreaterThan(0); | |
| 83 | const page = await (await fetch(`${servers.url}/search?q=fork`)).text(); | |
| 84 | expect(page).toContain('id="docs"'); | |
| 85 | expect(page.indexOf('id="docs"')).toBeLessThan(page.indexOf('id="repos"')); | |
| 86 | const body = await (await fetch(`${servers.url}/search?q=zzzqqqxx`)).text(); | |
| 87 | expect(body).not.toContain('id="docs"'); | |
| 88 | }); | |
| 89 | ||
| 90 | test("guideTitleMatches wants every word in a title", () => { | |
| 91 | const docs = [{ title: "Forking an app", path: "/docs/x.md", snippet: "" }]; | |
| 92 | expect(guideTitleMatches("fork", docs)).toBe(true); | |
| 93 | expect(guideTitleMatches("fork zebra", docs)).toBe(false); | |
| 94 | expect(guideTitleMatches("", docs)).toBe(false); | |
| 95 | }); | |
| 96 | ||
| 97 | test("the terminal's palette search has a Guides section; Enter opens the guide", async () => { | |
| 98 | const guest = new Session(app, { sshUsername: "anyone", remoteAddress: "198.51.100.7", fingerprint: "SHA256:none" }); | |
| 99 | const pushed: { title: string }[] = []; | |
| 100 | const ctx = { icons: "plain", toast: () => {}, push: (s: { title: string }) => pushed.push(s), invalidate: () => {} } as unknown as Ctx; | |
| 101 | const items = await forgeSearch(guest)(ctx)("ulid", false, new AbortController().signal); | |
| 102 | const guide = items.find((i) => i.id === "doc:features/feed-cursor.md"); | |
| 103 | expect(guide?.section).toBe("Guides"); | |
| 104 | guide!.run(); | |
| 105 | expect(pushed.length).toBe(1); | |
| 106 | expect(pushed[0]!.title).not.toBe(""); | |
| 107 | }); |
test/search.test.ts +2
| @@ -32,6 +32,7 @@ interface Results { | ||
| 32 | 32 | note?: string; |
| 33 | 33 | moreCode?: boolean; |
| 34 | 34 | codeSkipped?: boolean; |
| 35 | docs?: { title: string; path: string; snippet: string }[]; | |
| 35 | 36 | repos: ( |
| 36 | 37 | | { |
| 37 | 38 | source: "local"; |
| @@ -396,6 +397,7 @@ describe("search: one query, four sources", () => { | ||
| 396 | 397 | expect({ ...results, note: undefined }).toEqual({ |
| 397 | 398 | note: undefined, |
| 398 | 399 | repos: [], |
| 400 | docs: [], | |
| 399 | 401 | issues: [], |
| 400 | 402 | code: [], |
| 401 | 403 | moreCode: false, |
A rise from 58 to 246 words is more than four times the first-view budget of this page (principles 1 and 3). Trim the snippets or the group to land nearer the old figure, or state why it must be this large.