Skip to content

AI Mode search: natural-language placeholder; overview reads the top 20 and lists up to 10 picks - #532

Merged
neuromechanist merged 11 commits into
stagingfrom
feature/531-overview-top-20
Nov 13, 2026
Merged

neuromechanist merged 11 commits into
stagingfrom
feature/531-overview-top-20

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Refs #531

Feedback from a NEMAR maintainer on AI Mode search, website side. The OSA side is OpenScience-Collective/osa#748.

What changed

  • Placeholder. The Home field's AI Mode placeholder reads "Describe the data you need, in natural language" (was "in plain words").
  • The overview reads the top 20. planSearch takes an overviewRows option: on page 1 of a search with the overview endpoint set, the endpoint is asked for max(pageSize, 20) hits. pageSearch returns the visible slice (still pageSize cards) and overviewHits (the first 20 of the ranked list; from the filtered window in window mode). overviewRequestForPage reads the hydrated cards, then the hits past them, with hitDescription (snippet without <mark>, else Tasks: ..., else empty). No extra getDataset calls. OVERVIEW_LIMITS.rowsMax is 20.
  • The answer. PICKS_MAX is 10. parseOverviewResponse reads the new optional suggestion (same id rule as the summary; absent on an older server, and a suggestion with no words is shown as none). It takes the request rows, so each pick carries its dataset title, cut to 90 characters.
  • The panel. Lead-in, then the picks (id chip, semibold title, reason), then the suggestion paragraph, then the footnote and "Ask a follow-up". All text is set with textContent; styles use the existing tokens.
  • The follow-up seed. Head, lead-in, **Top picks**, suggestion. Within the 2000-character limit, picks are dropped from the end with their reasons kept, then listed without reasons, then dropped; the suggestion stays unless the lead-in and it cannot fit together; the last resort is cutting the lead-in at a sentence, as before. Picks carry no title in the seed, to leave room for up to ten.
  • CHANGELOG entry under [Unreleased].

Testing

  • bun run test: 178 files, 4935 tests pass (new: search planning for 20 rows, hits past the cards, picks up to ten with titles, suggestion parsing, render order guard, seed order and limits across 10 picks and suggestions)
  • bun run lint (Biome) clean
  • bun run typecheck (astro check): 0 errors
  • bun run build completes
  • QA on test.nemar.org once OSA#748 is on the dev server

Rollout

OSA#748 must reach the dev server (develop-widget.osc.earth) before this merges to staging, and the OSA release must reach production before this reaches main: an older OSA refuses 20 rows with a 422, and the panel would stay hidden behind the "three or more words" note. The reverse is safe: an older website against the new OSA still sends 10 rows, shows 3 picks and ignores suggestion.

Review (round 1, two Sonnet reviewers)

Fixed:

  • A web address glued to a word (see2https://...) was not broken in the follow-up message, and the widget links any https?:// run: WEB_SCHEME has no word boundary now; tested in the lead-in, a reason, the suggestion and the typed query.
  • A | in prose could turn a line of the follow-up message into a table row: | is blanked in prose; tested.
  • The picks list lost its list semantics in Safari and had no name: role="list" and aria-label="Top picks"; each chip is named by id and title; a visually hidden ": " separates a title from its reason.
  • The suggestion was dropped before the lead-in shrank: the lead-in is now cut at a sentence (keeping at least 120 characters) so the suggestion stays whole; a suggestion too long for that still goes. Tests for both paths and the 2000 bound.
  • A null hit or a non-string name among ranks 11 to 20 threw and dropped the panel: non-objects are skipped and non-text fields read as empty; tested.
  • A card with an unusable id pushed its hit behind lower-ranked hits: rows now follow the hits in ranking order, reading a hit that has a card as the card; tested.
  • "suggestion": null failed the overview: it now reads as none; tested.
  • A repeated pick was listed twice: picks are deduped (first wins) before the cap of ten; tested.
  • ADR 0032 said ten rows and a single summary: a dated amendment records the top 20, the lead-in, the picks and the suggestion. The CHANGELOG lines for Discover: AI Mode toggle in the search field and the AI overview panel #518 and Home: AI Mode toggle in the hero search field #519 sit in the released 0.2.38 section and stay as history; the [Unreleased] entry now covers these fixes.

Rejected:

  • A DOM-level test of the panel order: the repo has no DOM library, and the source-order test matches the existing style.
  • Treating a 422 from an older OSA as a generic error: deploys are sequenced (OSA#749 reaches dev first), and the 422-to-hint mapping is the deliberate handling of a word-count disagreement.

Checks after the fixes: bun run test 178 files and 4947 tests pass; bun run lint and bun run typecheck clean; astro build completes. (bun run build stopped in its first step, generate:og, because the live catalog API answered 500; that step only regenerates OG images and is unrelated to this change.)

Review (round 2, one Sonnet reviewer, fix commits only)

The fixes came to about 150 non-test lines and touched the seed's link neutralising, so a delta review ran.

Fixed (d94b720):

  • A web address split across two text segments ("see https:" then "//x") was neutralised per segment and joined into a live link. Adjacent text segments are now neutralised as one run.
  • A ! right before a dataset link made ![id](...), an image. A space now separates them.

Fixes 2 to 8 of round 1 were confirmed correct with no new defect. bun run test: 4949 pass; lint and typecheck clean.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Deploying nemar-website with  Cloudflare Pages  Cloudflare Pages

Latest commit: d94b720
Status: ✅  Deploy successful!
Preview URL: https://1c890288.nemar-website.pages.dev
Branch Preview URL: https://feature-531-overview-top-20.nemar-website.pages.dev

View logs

…nd title (#531)

role=list and aria-label on the ordered list (Safari drops list semantics
under list-style none), an accessible name of id and title on each chip, and
a visually hidden separator between a title and its reason. The panel and the
follow-up message share the Top picks label. Source-order test added.
…keeps the suggestion (#531)

A scheme glued to a word (see2https://...) is now broken, since the widget
links any https?:// run with no word boundary, and | becomes a space so no
line turns into a table row. When the lead-in and the suggestion do not fit,
the lead-in is cut at a sentence (at least SEED_MIN_LEAD_IN_CHARS) to keep the
suggestion whole; only a suggestion too long for that is dropped. Tests for
each path; the 2000-character bound holds throughout.
…panel (#531)

The request walks the hits in ranking order and reads a hit that has a card
as the card, so a card with an unusable id no longer falls behind lower hits.
A hit or card that is not an object is skipped, and a title, description or
modality that is not text reads as empty. The parser lists a repeated pick
once, caps distinct picks at ten, and reads a null suggestion as none.
…age marker before a dataset link (#531)

Round-2 review: a web address split across two text segments, or a '!'
right before [id](...), still reached the widget as a link or an image.
Tests added for both.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant