Repository navigation
Filter the cheap searches as the term is typed - #293
Conversation
The search boxes of a sample's page, the family and sample lists and a family's page now update their table once typing pauses. live_search.js fetches the page the form would load and swaps in its table, pagination and flashed messages; Enter still loads the page, and anything that is not that page (an expired session, an error) loads it too. The function list and the combined search page keep waiting for Enter: an unscoped function search can take tens of seconds on the backend, and aborting the request in the browser does not stop it (ADR-0016). Following ADR-0014, the row clicks of the function, sample and family tables and the edit modals' listeners are delegated, so rows swapped in later behave like the ones loaded with the page, and the family-name type-ahead also attaches to a modal on first focus. On a sample's page a term that is only a hex number, like 0x6840, is searched as offset:0x6840. It used to be matched against function names and found nothing.
mcrit 1.15.0, which CI now installs, makes McritClient send through a requests.Session() it opens in its constructor. The test swaps the client's requests module for a stub with get and post only, so creating the client raised AttributeError and all eight tests in the file errored. The stub now hands itself back as the session. Same change as in #285; it works with 1.13 and 1.15.
|
@danielplohmann a note on CI before this is merged: please merge #297 first. The green run here is from 13 October, when CI installed mcrit 1.15.0. mcrit 1.16.0 came out on 16 October, and its #297 fixes the stub for both 1.15 and 1.16. Once it is on master, this PR needs no change; I have left the fix out of it on purpose, so it stays in one place. This branch was also checked against master after the security batch (1db3833): the full suite passes on the merge, 1409 passed and 7 skipped, with mcrit 1.15.0. |
Master brings #244, #136 and #119 into the pages this branch swaps. - README: the unreleased lines this branch carried were folded into 1.6.0; only the live search line stays above it. - single_sample.html: #244's h2 headings and #119's empty message and #136's highlighting go inside the swapped region, next to this branch's form and status line. - family_row.html, sample_row.html: #244 made the modal lookups null-safe with ?.; the delegated listener here already covers a page without the modal, and also a modal a search brings in, so it stays. - testSubmitMetadata.py: master's fix from #297, in place of the port.
No conflicts. #174's search adapter now runs the sample page's function search; the query it is given is still built by sample_function_query(), so a bare hex number reaches the backend as offset:<term>.
#293 loads live_search.js with a plain script tag on the four listing pages, so it was fetched before the first paint, which this branch moves every page script past (ADR-0021). It is queued with later() now. The search box has autofocus, so a term can be typed before the queue has run: the script takes the term the page was rendered for as the one on screen and searches what the box holds by the time it runs.
Master's #293 loads live_search.js with a plain script tag on the four listing pages, so it was fetched before the first paint, which this branch moves every page script past (ADR-0021). It is queued with later() now. The search box has autofocus, so a term can be typed before the queue has run: the script takes the term the page was rendered for as the one on screen and searches what the box holds by the time it runs.
Bumps setup.py and adds the version history entry, folding in the five "unreleased" lines (familiary#263, familiary#262, familiary#261, familiary#293, familiary#254). 48 PRs since 1.6.0: batches C1 (familiary#298), C2 (familiary#299), security E (familiary#318), UI F (familiary#339) and fixes G (familiary#340). No dependency changes. The entry leads with the three things that affect existing deployments: instance/ backups under WAL mode, the bounded result cache, and the optional retirement of pre-1.5.0 API tokens. Test count measured on the batch G tree, which master 30cbc8a is identical to: 2428 passed, 19 skipped against mcrit 1.16.0, 2447 collected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HERmVhHo4ibp7HSTXr3Ya8
Looking a function up on a sample's page meant typing
offset:0x6840and pressing Enter, and every change to the term reloaded the whole page. Four search boxes now filter their table as you type: a sample's functions, the sample list, the family list and a family's samples. On a sample's page a bare hex number is taken as an offset, so0x6840finds the function at 0x6840 and a part of a name finds the functions with that name.Change.
mcritweb/static/live_search.jshandles any search form markeddata-live-search="<id>".query, and the cursor dropped so the results start from the first page. Sort and page size stay; a chosen page size getspage=1along with it, since the pagination reads a size only with a page number (mcritweb/views/cursor_pagination.py:163-168).history.replaceState, so the URL can be reloaded or shared.toggle_delete_familyandtoggle_delete_sample).role="status"line says how many rows are on the page, or that the search failed, for screen readers, without the table being read out.divwith that id:single_sample.html,samples.html,families.htmlandsingle_family.html. The sample page's placeholder says the box takes a name or an offset.sample_function_query()(mcritweb/views/explore.py:630) turns a term that is only a hex number (0xor0Xand hex digits) intooffset:<term>; mcrit reads the value withint(value, 0). Anything else is passed as typed. Before, such a term was matched as a substring of the function names and found nothing. An offset of 2^63 or more fails in mcrit's search, with or without the shortcut (offset:0xffffffff81000000answers 500 on mcrit 1.13.0), because MongoDB stores such an offset as a signed value. Answer bad search input with 400, keep minhashes a recalculation can't rebuild mcrit#276 makes that search find the function.document. ADR-0014 names that as the precondition for swapping a table: bindings made on load stay with the rows that were there. The edit modals'show.bs.modallisteners are delegated too, since a list that loaded without rows had no modal to bind to. Before Fix the accessibility and SEO audits Lighthouse fails across the app (#243) #244,/explore/samples?query=zzzzqqthrew "Cannot read properties of null (reading 'addEventListener')" at load; Fix the accessibility and SEO audits Lighthouse fails across the app (#243) #244's?.stops the throw, but a modal a search brings in later would still get no listener, so the delegated listener replaces it.ac_family_names.htmlalso attaches the family-name type-ahead on first focus, for a modal that a search brings in.Half-typed terms. On mcrit 1.13.0, a term cut off mid-way (
offset:,offset:0x,function_name:, an unclosed") answers no rows. One that does not parse (an unclosed(, a trailingAND) is refused, and the page shows its existing "Could not search MCRIT's functions" message until the term is complete again.Where it is not used.
docs/adr/0016-slow-function-search-is-mcrits.md), and aborting the request in the browser does not stop the query in mcrit. Bound what search and function listing can make the server do mcrit#271 caps a search at 30 s on mongod, still far too long to run on every pause.Verification. On the testbed (mcrit 1.13.0), a side instance of this branch against the live backend, in headless Chromium:
pre_cpre_c_init,pre_cpp_init), one request, no page load, address?query=pre_c0x401010fastlistlauncherzzzzClicking a swapped-in row opens its function, sample or family. Enter still loads the page. No script errors. A sample page with a search answers in 30 to 55 ms on the testbed, its job queue read included (master,
/explore/samples/23, three runs each, best of three), so a request per pause is cheap there. Only GET requests were sent. After merging master (6564602), on a side instance of 916d701:pre_con sample 18 narrows 100 rows to 2 and markspre_cin both,0x401010gives 1 row,fastliston the sample list 2 rows with the term marked,launcheron the family list 3, each without a page load and with no script errors. An independent browser review also found the page at rest unchanged against master at 1280 and 375 px, and back, forward and reload of a replaced address restoring the term and rows.Tests.
tests/testLiveSearch.py:offset:(4 cases);tests/testLiveSearchBrowser.py, in Chromium on the offline corpus:They skip without Playwright, as in CI.
21 of the 30 new tests fail on master (6564602). Each guard was checked by taking it out: making the family or sample row binding direct again, the modal listener direct, dropping the script re-run, the focus hook, the abort, the page size, the open-modal check, the fallback or the offset rule fails at least one test. Full suite with Chromium on 916d701: 2109 passed, 11 skipped, none of them in this branch's files.
ruff check .clean.Relation to open PRs.
h2headings, Let each table say what is actually missing (#65) #119's empty messages and Mark the search term in the rows that matched it (#45) #136's marks; a search on a sample's page goes through Consume searches as entry objects through one adapter #174'ssearch_page(), with the querysample_function_query()builds. Fix the accessibility and SEO audits Lighthouse fails across the app (#243) #244's?.on the modal lookups gives way to the delegated listener, which covers a page without the modal too.git merge-tree). Whichever lands later moves its handlers onto the delegated form.jobs.htmlsince batch C2; this branch adds no conflict with it.