Repository navigation
AI Mode toggle and overview in search - #522
Merged
Merged
Conversation
…ested in unit tests, checked in a browser)
…l (browser-checked; guard tests follow)
…scroll sideways (browser-checked)
…r-checked; guard tests follow)
Deploying nemar-website with
|
| Latest commit: |
fe41708
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1154e3e1.nemar-website.pages.dev |
| Branch Preview URL: | https://feature-issue-518-ai-mode-se.nemar-website.pages.dev |
…elds, add request parser and unexpected kind (tested)
…nses, retry, logged failure kinds) and aiLinkHref (tested)
…used follow-up; live region moves outside the hidden section (tested by source guards; type-checked)
…says why no overview (source guards; type-checked)
2 tasks
…der; ADR 0032 notes it and the privacy policy follow-up #523 (source guard)
…ggle (comment only)
Contributor
Author
|
Review round 1: outcome for each finding. Pushed as 837d503, 74b0026, 1592399, 9cd781d, 2cb8b89, 8da09e4. After the fixes:
|
…ooltip (source guards)
… px and below (browser-checked at 606 px; source guards)
…ng in the click handler (source guard)
Contributor
Author
|
Review round 2: outcomes. Pushed to this branch; lint, typecheck (0 errors), the full suite (175 files, 4834 tests) and the build pass.
|
Contributor
Author
|
PM verdict at f2a8355: not ready to merge yet, one check is red.
|
… instantly; no code change)
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the AI Mode toggle to the Discover search field (board D2) and the Home hero field (board D1), and the AI overview panel above Discover's results.
PUBLIC_OSA_OVERVIEW_URL, read insrc/lib/osa-overview.ts. It must be exactlyhttps://develop-widget.osc.earth/osa/nemar/overvieworhttps://widget.osc.earth/osa/nemar/overview(the hostsOSA_API_HOSTSalready allows inconnect-src;edge.osc.earthis refused until a release adds it to the CSP). Unset, blank or invalid means no toggle, no panel, no data island. Set indeploy-test.yml(the real value) andwrangler.test.toml(reference);wrangler.toml,middleware.tsand every production setting are untouched. ADR 0032 records the decision.buttonwitharia-pressed, hidden until the widget hasopenand the endpoint is set. 44 px pill with a 15 px label and a 22 px icon in the hero; 36 px with 13.5 px and 20 px in Discover's 44 px field. The magnifier-with-sparkle is the only AI mark in a field; the Search buttons keep their plain label. On: the field gets the Download headline's teal-to-purple ring. Colours are tokens with dark values.localStorage(nemar:ai-mode-search:v1, try/catch everywhere) andai=1in the address (replaceState);ai=1in the URL wins and is written back.aiis now aFilterStatefield, so it survives paging and filter links likeexact; a hiddenaiinput keeps it across search, filters and sort; the page's own/discoverlinks get it client-side (they are server-rendered and edge-cached for everyone).dataset.description, falling back to the snippet without its<mark>tags). The browser posts it when AI Mode is on. States: off, loading (aria-busy), answer (summary with ids as links to/dataset/<id>, up to 3 picks, "Written by AI from these search results", Ask a follow-up), error (Try again). Text is set withtextContent; an answer that cites an id outside the request is an error./discover?q=...&ai=1; the form markup is unchanged and the client adds theaiinput only while on. On: placeholder "Describe the data you need, in plain words" and a "Try" row of three example pills that fill the field and submit.OSAChatWidget.ask(text, {mode: 'center'})whenaskis a function, elseopen({mode: 'center'}); a throw is caught and warned.Refs #518
Refs #519
The issues stay open until the staging check passes on test.nemar.org (a built deploy, from an origin the service allows), as AGENTS.md describes for work that needs verification; close them by hand then.
Tests added
src/lib/osa-overview.test.ts: endpoint setting (vi.stubEnv), request builder overtest/fixtures/search-corrected-query.json, every limit, response parsing overtest/fixtures/osa-overview-response.json(the example in OSA's docs), the call with HTTP fixtures only (200, 403, 404, 422, 429, 500, 502, network, timeout, caller abort, foreign cited id).src/lib/osa-ai-mode.test.ts(extended): preference store, URL wins and is written back, off removesai, throwing store, availability needs widgetopenand the endpoint, follow-up helper.src/lib/ai-overview-panel.test.ts: pure state to view for off, loading, answer, error; follow-up text at most 1500 characters.src/lib/filters.test.ts:airound trip.test/ai-mode-search.test.ts: source-level guards (toggle markup and sizes, no sparkle elsewhere, panel live region, tokens with dark counterparts, Home form unchanged when off, setting in the two staging files and absent fromwrangler.toml).Commands run
Manual check
bun run devwith the staging env from the brief andPUBLIC_API_BASE_URL=https://api-test.nemar.org, in Chrome: toggling on and off (address,localStorage, panel, hidden input,/discoverlinks), a new search while on keepsai=1, Home submit on and off, a Try pill, and no horizontal scroll at 390 px on Home and Discover. With noPUBLIC_OSA_OVERVIEW_URLthe Home form and Discover have no toggle, panel or island.Caveats, stated plainly:
Origin: https://test.nemar.org) with a small request returned a real overview (summary, picks,cited_ids). Fromlocalhostit still answers 403, so the answer, loading and rate-limit screenshots remain intercepted ones; real-service screenshots need the staging deploy. Original note: develop-widget answered 502. A real POST of the island's request (staging idsxx099906,xx099905, and four more) tohttps://develop-widget.osc.earth/osa/nemar/overviewwithOrigin: https://test.nemar.orgreturned{"error":"error code: 502"}(twice; direct toapi.osc.earth/osa-dev/nemar/overviewit asks for a key, so the route exists on the backend). The worker route is presumably not deployed yet, as OSA's docs say it answers only after a maintainer deploys it. Fromlocalhostit answers 403 (origin not allowed), which the panel shows as its error state. So the answer, loading and rate-limit screenshots below were taken with that endpoint intercepted in the browser and answered with a response in the documented shape (ids from the real staging search); the 502 and 403 states are real. Re-check on test.nemar.org once the worker serves the route.wrangler pages dev, which needs the API service binding (AGENTS.md). The build is green.Screenshots
Notes for review
1fr, whose minimum is the filter chips' width). It is nowminmax(0, 1fr), its own commit, because the 390 px check could not pass without it.total_countis the count Discover shows (equal to the API'scountexcept when 2+ modalities or a participant range make Discover filter the best-100 window itself, where it is the filtered count).screenshots/ai-mode-search/(JPEG, about 1 MB) so the links do not depend on the branch.wrangler.toml, so no toggle. Enabling it there is a release-time decision (ADR 0032).