Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
nickvigilante
left a comment
There was a problem hiding this comment.
I read the full diff (semantic-search.ts, hybrid-search.tsx, semantic-index.mjs, the tests and the ARCHITECTURE.md changes). I did not build the branch or run the tests, so everything below comes from reading the code and the PR body.
The approach is sound. Fusing by section URL instead of page, ranking a page by its strongest section, and weighting embeddings by page frequency each address a real failure in the old fuse. The new tests are the right shape: they cover the anchor-level fusion, the exact-title tiers, the once-per-page weighting and the dialog's multi-match rendering. The ## Upstream answer is reasonable.
Blocking
-
The branch conflicts with
main. GitHub shows it as conflicting and the PR says it was rebased onto9525cd4, which is weeks old. The benchmark numbers (463 pages, 4,012 sections, saved October 28 corpus) also predate that rebase and the current corpus. Please rebase and rebenchmark on the rebuilt corpus, since the PR itself says that has not been done. -
The QA section no longer matches how this repo previews. The "Pages to compare" table uses
coder.com/beta-docs/...and the router branch alias. Production is nowhttps://coder.com/docs/<path>/, and the PR itself says the router preview does not exercise the rebuilt search bundle. Docs-site changes are previewed throughengine-pr-preview.yml, which comments a URL once adocs-previewreviewer approves the deploy. The steps also need a build withDOCS_SEMANTIC_SEARCH=1, so please say how a reviewer gets that preview. The Chrome and Firefox pass is still marked pending, andAGENTS.mdsays the PR gets merged after it is checked in a browser, so it needs to happen before merge.
Worth fixing or answering
-
Keyword recall when the semantic index is not available.
keywordSearchClientsetsthreshold: 0, which in Orama means every remaining query word must match.hybridSearchClientstill returns the keyword-only result before the semantic index has loaded, and permanently if that download fails (the 30 second timeout path). In that window a natural-language query such ashow do I expire my logincan return no results, where the old default matched any term. With vectors loaded the fuse masks this, but the PR only measures that case. Either keep the default threshold for the keyword-only path and apply the all-terms requirement only when fusing, or add a test that pins the no-vector behaviour and say in the PR that the narrower result is intended. -
expandingref inHybridSearchDialog. The dialog only stays open after "Show N more matches" becauseonOpenChangeswallows exactly one call after the action sets the ref. If Fumadocs ever callsonOpenChangezero times after an action'sonSelect, the ref staystrueand the next real close, such as Escape, is ignored once. If it calls it twice, the dialog closes anyway. The dialog test covers the expansion, but nothing covers Escape after an expansion. A test for that would pin the assumption, or the ref could be cleared on a timer or effect. -
Evaluation confidence. The ranking tiers, the 0.75 and 0.25 weights and the stop-word list were tuned against the 36-query set, and the separate 20-query check moved only from 9/20 to 10/20. The top-five parity with Algolia is encouraging, but I would describe the result as "no regressions found" rather than a general improvement, and I'd add more queries before the next round of tuning. It would also help to say how the two expected URLs were corrected, since the corrected metric is the headline number.
Nits, not blocking
createCorpusEmbeddingModelre-quantizes an already int8 table with one global scale. Rows for corpus-wide tokens, whose weight is nearlog 2against a maximum nearlog N, keep only a few bits. The benchmark already includes that cost, but it is worth a line inARCHITECTURE.md.QUERY_STOP_WORDSis English only and compares the raw whitespace-separated word, sohow?is not removed. That is probably fine for these docs, but say so.
I'm not approving, so this review can't count toward merging.
🤖 Built with AI assistance.
4687c2a to
63844a7
Compare
Docs preview deploymentRendered with docs-engine f002c04 from coder/coder at b911ed9782c807d521a21f6990697723b3562351: https://coder-docs-2sx6paiey.coderite.app The preview is behind Vercel authentication; sign in with your Coder Vercel account. |
nickvigilante
left a comment
There was a problem hiding this comment.
Cedric, thanks for this. I read the diff at 63844a7 first and formed a view from the code, then checked it against the preview notes from a manual pass in Chrome. Nobody has run the branch in a browser for this review, so anything about live behaviour below is read from the code and marked as inferred. packages/docs-next/src/semantic-search.test.ts passes on its own (22 of 22), and the workflow change is one added env: line that touches no trigger, environment, secret or permission.
The section-level model is a good shape: fusing by section URL, keeping a page's position equal to its best section, and fetching both the strongest sections and the best section per leading page all do what ARCHITECTURE.md says, and the ranking is deterministic. I would not merge it until the three P1s below are dealt with.
Why STUN and "login expires" come out that way
STUN is a tuning limit. exactResultMatch in packages/docs-next/src/semantic-search.ts gives tier 3 to any page whose title contains every query word, so for the one-word query STUN, "Self-host a STUN server" and "STUN and NAT" are both tier 3 and the fused score decides the order. I reproduced it with fuseResults on synthetic inputs: whichever page the vectors prefer leads. No test puts two tier-3 titles in play, and the QA step that promises "STUN and NAT leads" is not guaranteed by the code. A cheap tie-break inside tier 3, such as the fraction of title words that are query words, plus a test with both titles present, would fix it.
"Login expires" is a defect, and it predates this PR. After the tiers, fuseResults pins the page of the top vector section first and the first keyword page second, whatever their fused scores. In my reproduction a page that appears in both lists scores about 0.0162 and loses to a vector-only page at about 0.0123, which matches the order the preview shows. ARCHITECTURE.md now says "the fused section ranks determine the remaining page order", which is only true after those two pins. I reproduced this on synthetic inputs and could not confirm it against the preview's real corpus.
P1
The vector pin defeats the fusion for non-literal queries. semantic-search.ts around lines 1080-1089, where order is built from exactPages, firstVector, firstKeyword and groups.keys(). login expires puts a CLI reference page first because it holds the top vector section, ahead of the page both sources agree on. I would pin only when no source agrees, or drop the vector pin and keep firstKeyword only for a keyword hit the vectors did not return, and add a test with an agreeing and a disagreeing page.
threshold: 0 makes the keyword-only path return nothing for many natural-language queries. packages/docs-next/src/hybrid-search.tsx lines 407-415. The old call used the library default, which in this Orama fork is threshold 1 (any term). With 0, every term has to appear in a single record, and a record is one page title, one heading or one paragraph. The stop-word list is short, so what is a workspace, why does my build fail and tokens that expire still need what, why or that in the same paragraph. The semantic path masks this once the index has loaded, but hybridSearchClient returns the raw keyword results whenever the index is empty, which is the case while the download is in flight, after a failure, and after the 30 second timeout. After a failure the cached promise is deleted, so every later keystroke starts a new download. In that state those queries show "No results found" where they used to show partial matches. This is the keyword-only regression I was worried about, it is inferred from the code and not run, and no test calls the client with the index missing and a multi-word query. I would use threshold: 0 only when the semantic index is ready, or fall back to the default threshold when the strict search returns nothing.
Textual and semantic conflict with #407. #407 (product-scoped search) changes hybridSearchClient(from, product?, keyword = staticClient({ from, tag: product })) and vectorSearch(query, index, product?), and deletes ProductLabelsContext. This PR rewrites the same signature to default to keywordSearchClient(from), rewrites the body of vectorSearch that #407 edits, and keeps ProductLabelsContext. The merge will conflict, and a careless resolution loses scoping silently: keywordSearchClient(from) takes no tag, so the keyword side would stop filtering by product while the vector side still does, and a code-server reader would get Coder keyword hits. Whichever PR lands second needs keywordSearchClient(from, tag), the product filter applied before candidates are pushed in the new vectorSearch, and a test that searches under a product and asserts no foreign-product row appears.
P2
The expand control has no context for assistive technology and resets the active row. hybrid-search.tsx lines 455-471. The action row is a listbox option whose only text is Show 3 more matches, repeated for every group, so a screen-reader user cannot tell which page it expands, and nothing announces the change. When expanded changes, items changes identity and SearchDialogList in fumadocs-ui 16.19.0 runs setActive(items[0].id) in a layout effect (dialog/search.js around line 224), so after Enter on the expander the active descendant jumps back to the first result. This is inferred from the library source, and a keyboard pass that only watches the dialog stay open would not show it. I would name the page in the label (for example Show 3 more matches in Port forwarding), keep the active id on the first newly revealed row, and add a polite live region. This is the accessible-name rule in AGENTS.md.
The expanding ref guards the close handler with a flag instead of the event. hybrid-search.tsx lines 438 and 482-486. It works today because fumadocs calls onOpenChange(false) synchronously after item.onSelect(), and Escape goes through the same wrapper with the flag false, which matches the Escape result in the manual pass. If the library ever skips the close call for an action, the flag stays true and the next real Escape or overlay click is swallowed once. Handing the dialog its own onSelect that does not call onOpenChange, or resetting the flag in a microtask, would be sturdier. Related: #340 passes onSelect={sendSearchGoal}, and the library calls onSelectProp(item) after an action too, so each "Show more" click would send a search goal unless that handler filters item.type === "action". That is worth deciding before both land.
The exact tier overrides the fusion for any common single word. semantic-search.ts lines 953-955 and the sort at line 1053 (b.exact - a.exact || b.score - a.score). Any page whose title contains the query word is tier 3 and beats every non-title result regardless of score, so for workspace, template or agents every page with the word in its title outranks every section result. Matching is also exact-token: the title is split on non-word characters but the query only on whitespace, so self host will not match self-host, workspaces will not match workspace, and STUN? will not match stun. These are tuning limits and not crashes, and ARCHITECTURE.md does not say that tier 3 is flat or that the keyword-only path is now strict.
Not verified
I did not open a browser, so the keyboard flow, focus, announcements and section landing are from the manual pass and the fumadocs source. I did not run the slow-network or timeout path, so the threshold: 0 finding is from reading hybridSearchClient, preloadSemanticIndex and the Orama threshold rule. I did not run hybrid-search.test.tsx, because a failing jsdom assertion can exhaust memory in this environment. The 36-query benchmark and its expected URLs were not available, so the 17/23, 21/30, 27/32 and 28/34 figures are taken from the PR text. I did not measure layout shift or run axe.
🤖 Built with AI assistance.
Preserve distinct section matches while keeping long pages from crowding the initial results. Prioritize exact matches, require informative keyword terms, and weight semantic tokens by page frequency to improve retrieval. Cover section ranking, group expansion, and build/browser embedding consistency with regression tests. Assisted-by: AI
Promote page titles containing every query word ahead of exact section matches. Let fused rankings order keyword pages for literal queries so keyword-only hits do not displace results supported by both sources. Improve corrected top-five coverage from 28/36 to 30/36 on the saved corpus without regressing labeled queries. Add regression tests and document the ranking order. Assisted-by: AI
Fumadocs 16.17 highlights matches with the CSS Custom Highlight API and no longer wraps them in <mark>, so exact-match comparison has nothing to strip. Update the ranking tests to the plain record content the index now returns. Assisted-by: AI Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
publish-version.yml passes DOCS_SEMANTIC_SEARCH from the repository variable, but the preview build did not, so previews only exercised keyword search. Assisted-by: AI Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #407 the keyword side searches only the active product's tag, so the fixture needs one for its keyword hits to count. Assisted-by: AI Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63844a7 to
ea76509
Compare
- Without the semantic index, a query that matches no record with every word falls back to matching any word, so natural-language questions aren't empty while vectors load or after they fail. Fused rankings are unchanged. - The expansion row names its page, moves the active row to the first revealed match and announces it. The flag that keeps the dialog open resets in a microtask, so it can't swallow a later close. - ARCHITECTURE.md now says the pins precede the fused order, that titles with every query word form one tier, and how word matching works. Assisted-by: AI Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, Nick. Addressed in P1 P1 #407 conflict: handled in the rebase. P1 vector pin: pushing back on this one. On the real corpus, P2 expand control: fixed. The row reads "Show 3 more matches in ", the active row moves to the first revealed match, and a polite live region announces it. P2 P2 title tier: pushing back. I tried breaking ties by how much of the title the query covers, plus splitting on hyphens. It fixed 🤖 Generated with Claude Code |
|
Hi Cedric, thanks for the quick turnaround. I ran the preview on 9103c7f in Chrome, and the expand control checks all pass: the row names its page, the active row moves to the first revealed match without the list jumping, the live region announces it, Escape closes, and selecting a revealed match closes the dialog. The top results for the queries we had a baseline for are unchanged. Two things I'd like your view on before this merges.
The part I could not check in a browser is the keyword-only fallback (blocking the semantic files and searching a question). I'll try that myself. Everything else I'd approve as it is. 🤖 Built with AI assistance. |
Merge order
No dependencies. Rebased onto
mainat9525cd4.Summary
Search preserves distinct matching sections while keeping long pages from filling the initial results. Each page initially shows two matches; an expansion control reveals the rest without closing the dialog. Matching page titles and sections rank ahead of loosely related results.
On the saved 36-query benchmark, corrected top-five coverage improves from 21/36 to 30/36, matching the recorded Algolia result. Fifteen queries improve their expected-page rank; none regress.
Fix
Fuse keyword and semantic evidence by section URL, retain the strongest keyword representative and its highlights, and rank each page by its strongest section. Retrieve both the strongest semantic sections and the best section from each leading page. Require informative keyword terms and weight embeddings by corpus page frequency. Prefer exact page titles, then titles containing all query words, before exact headings and snippets; literal queries let fused rankings order keyword pages.
QA
Browser verification in Chrome and Firefox remains pending; automated dialog coverage uses jsdom. Use a docs preview built with
DOCS_SEMANTIC_SEARCH=1for these steps.STUN. Check that the “STUN and NAT” page leads incidental snippets mentioning STUN. Repeat withcode-serverand check that its workspace-access guide leads.port forwarding. Find a page with a “Show … more matches” control. Select it with the keyboard and confirm the dialog stays open and exposes the remaining matching sections.Claude Code; confirm groups collapse again and the matching client guide is easy to find.Pages to compare
The URLs below are the automatic branch router preview, which serves published docs and does not yet exercise this branch's rebuilt search bundle. A docs preview with semantic search enabled is still required for browser QA. Branch aliases serve the latest deployment and require a Vercel login.
Testing
Largest gains include
workspace files(52 → 5),local browser app(46 → 2),login expires(27 → 1),MCP tools(12 → 1), andSTUN(9 → 1). Without URL corrections, top-five coverage improves from 20/36 to 29/36, also matching recorded Algolia. The final refinement improves a separate 20-query set from 9/20 to 10/20 at five rows without worsening any expected-page ranks. Remaining gaps includeencrypted database,inject user credentials,deploy offline,choose instance size,shell customization, andkeep disk.Upstream
No. This is the engine's custom hybrid retrieval and grouped-results behavior, composed through existing Fumadocs extension points.
Linear: no issue linked.
🤖 Built with AI assistance.