Public: anyone can read this; the crew can change it.

The /search page keeps to the repository repo:owner/name names in q, as /api/… #17931

shipped production is serving it opened this has it

Landed in pull #17932 · run

opened this

The /search page keeps to the repository repo:owner/name names in q, as /api/v1/search and the MCP tool do

Live: /search?q=repo%3Atrevato%2Fforge+Modrinth says "Nothing matches" though #17865/#17867 are titled Modrinth. #17906 fixed the API; src/web/pages/search.ts still searches the literal "repo:…" text over the first 50 visible repos.

Patch, src/web/pages/search.ts only:

  1. core/search.ts import: add repoQualifier,. core/repos.ts import: add canRead and type Repo.
  2. interface Asked, after query:
  /** What is searched for: `query` less its `repo:owner/name`, which is the scope (#16463). */
  readonly words: string;
  1. Above find:
/** The repository `repo:` names if the viewer may read it; undefined alike for malformed, missing or unreadable, so a private one is never told. */
function readableRepo(ctx: Ctx, named: string): Repo | undefined {
  const [owner, name, ...rest] = named.split("/");
  if (!owner || !name || rest.length > 0) return undefined;
  const repo = getRepo(ctx.app.db, owner, name);
  return repo !== undefined && canRead(ctx.app.db, repo, ctx.auth.user) ? repo : undefined;
}
  1. find(ctx, a, only: Repo | undefined): greppable(a.query) -> greppable(a.words); search input q: a.words, plus ...(only === undefined ? {} : { repo: only }),.
  2. searchPage:
  const typed = cleanQuery(cappedQuery(params.get("q")));
  // `repo:owner/name` keeps the search to that repository, as on the API and the MCP tool (#16463).
  const qualified = repoQualifier(typed);
  const a: Asked = {
    query: typed,
    words: qualified.q,

(rest unchanged). After the if (a.query === "") branch:

  const named = qualified.repo;
  const only = named === undefined ? undefined : readableRepo(ctx, named);
  if (named !== undefined && only === undefined) {
    const rendering = performance.now();
    const none = page({
      ctx,
      title: `Search · ${echoed(a.query)}`,
      styleCss: SEARCH_CSS,
      body: html`<div data-search>${pageHead(html`Results for “${echoed(a.query)}”`)} ${form}${trimmed}
        <p class="muted" role="status" data-repo-unknown>No repository you can read is called “${echoed(named)}”; repo: takes owner/name.</p>
      </div>`,
    });
    notePhase(ctx.request, "render", performance.now() - rendering);
    return none;
  }

then find(ctx, a) -> find(ctx, a, only); codeHitRow(hit, a.query), !greppable(a.query) and guideTitleMatches(a.query, …) take a.words. Links, form value and title keep a.query, so chips stay scoped.

Test, test/mcp-search.test.ts, in describe("MCP search") after "/api/v1/search takes the same scope…" (reuses pebble, secretpebble, noisy):

  test("/search, the page, keeps to the repository repo: names in q; an unreadable one reads as a missing one", async () => {
    const page = async (q: string) => (await fetch(`${servers.url}/search?${new URLSearchParams({ q, kind: "issues" })}`)).text();
    expect(await page("glow")).not.toContain("alice/pebble #");
    const scoped = await page("glow repo:alice/pebble");
    expect(scoped).toContain("alice/pebble #1");
    expect(scoped).not.toContain("alice/noisy #");
    expect(await page("REPO:alice/pebble glow")).toContain("alice/pebble #1");
    const secret = await page("glow repo:alice/secretpebble");
    expect(secret).not.toContain("secretpebble #");
    const said = (text: string) => /<p[^>]*data-repo-unknown[^>]*>([\s\S]*?)<\/p>/.exec(text)?.[1]?.replace(/secretpebble|nothing-here/, "X");
    expect(said(secret)).toBeDefined();
    expect(said(secret)).toBe(said(await page("glow repo:alice/nothing-here")));
    expect(await page("glow repo:pebble")).toContain("data-repo-unknown");
  });

On main it fails at toContain("alice/pebble #1"). No change to a query without repo:. Not here: the TUI palette's same gap.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs