Repository navigation
Discover: show results for the corrected query - #520
Merged
Merged
Conversation
Deploying nemar-website with
|
| Latest commit: |
cf9c3b8
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6bbdb6ba.nemar-website.pages.dev |
| Branch Preview URL: | https://feature-issue-516-corrected.nemar-website.pages.dev |
Contributor
Author
|
Review round 1 outcomes (pushed to the branch;
|
Contributor
Author
|
Review round 2 outcomes (no code change; the branch head is unchanged,
|
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.
Part of OpenScience-Collective/osa#652, E6.4 first step (no AI).
Closes #516 (GitHub will not close it: staging is not the default branch, so close it by hand after the merge, naming this PR).
Summary
When
GET /datasets/searchanswers withcorrected_query, /discover prints "Showing results for bilingual." under the search box (board D2: 13px-class muted text, the corrected words in strong and the foreground color), followed by "Search for bilinugual instead", which searches the reader's own words. Nothing else from D2 is touched.DatasetSearchResponse.corrected_queryis typed (src/lib/types.ts).correctionNotice(state, res)insrc/lib/discover-search.tsis pure and returns{corrected, originalHref}or null. Null when the field is absent, not a string, blank, or equal to the query after trim, space collapse, case fold and accent fold (the API folds accents before it corrects).originalHrefis/discoverwith the current filters, nopage,qset to the original words, andexact=1.pageSearchincludes it inSearchPageascorrection.src/components/CorrectedQueryNote.astro: scoped styles from tokens only (--fs-sm,--color-fg-muted,--color-fg), no hex, text interpolated (neverset:html). Rendered in.discover__headafterSearchBarwhen!fetchError && isSearch && correction. Caching is unchanged (the page is already keyed on the full URL).The known trap, and what this PR does about it
The API cannot turn correction off:
analyzeQuerycorrects the original words again, so a plain link would reload the same results (checked against production:q=bilinugual&correct=0still answerscorrected_query: "bilingual").correct=0parameter: Search: accept correct=0 to turn off spelling correction nemar-cli#2132. nemar-cli is not changed here.FilterState.exact(URLexact=1) is added, carried by paging and by filter changes (a hidden field in the filter form), and dropped when the reader types other words (isStaleExact).searchDatasetssendscorrect=0in exact mode only. An unknown parameter is ignored by today's API, so this is safe now.corrected_querybecause the backend predates the parameter, the same line is shown without the link, so the page never claims words it did not search.The link works end to end only after nemar-cli#2132 ships. Until then, following it lands on the same results with the line and no link.
Staging limitation
The correction runs only in a catalog of at least 100 datasets (
MIN_CORPUS_FOR_DF, nemar-clisearch-query.ts). Staging holds only thexx0999NNtest datasets, so test.nemar.org can never show the line. Its check is that/discover?q=<anything>still renders with no line and no error. That check is for after a human merges (curl -s https://test.nemar.org/version.jsonfirst); not done here.Verification
bun run typecheck: 0 errors, 0 warnings (18 existing hints)bun run lint: cleanbun run test: 170 files passed, 4687 tests passed, 14 skipped (skip count varies by environment; green is the criterion)bun run build: completePUBLIC_API_BASE_URL=https://api.nemar.org bun run dev, production search answering:/discover?q=bilinugual&modality=EEGshows "Showing results for bilingual." and a link to/discover?q=bilinugual&modality=EEG&exact=1/discover?q=bilinugual&exact=1&modality=EEGshows the line with no link (today's API ignorescorrect=0), and the filter form carriesexact=1/discover?q=bilingualand?q=zzzzshow no linetest/fixtures/search-corrected-query.jsonis a recorded production answer forq=bilinugual&limit=3; the unit tests use it. No mocks.Tests added:
src/lib/discover-search.test.ts(present, absent, empty and whitespace, equal after normalization, exact mode,pageSearch),src/lib/filters.test.ts(exactround trip),src/lib/filter-form.test.ts(isStaleExact),src/lib/api.test.ts(correct=0only in exact mode),test/discover-corrected-query.test.ts(source-level guard).Out of scope
AI Mode toggle, overview panel,
ai=1,rerankedandmodality_boostdisplay, sidebar changes beyond carryingexact, the nemar-cli change, version bump, merge.