Repository navigation
ENG-1734 Add Roam semantic search to Advanced Node Search #1186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
trangdoan982
merged 18 commits into
main
from
eng-1734-add-semantic-search-for-sync-enabled-graphs
Sep 27, 2026
+595
−61
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e289dd9
ENG-1734 Add Roam semantic search to Advanced Node Search
trangdoan982 9c80e1e
ENG-1734 Remove discourseNodeSemanticSearch unit tests from PR scope.
trangdoan982 894901f
ENG-1734 Fix docked search snapshot with async semantic search.
trangdoan982 3b97b9b
ENG-1734 Simplify dock handling and fix sort reactivity.
trangdoan982 aebb862
Revert AGENTS.md changes from ENG-1734 branch.
trangdoan982 1bf4f21
ENG-1734 Unify semantic and keyword search on ScoredSearchHit.
trangdoan982 dccf234
ENG-1734 Rename discourse node search modules and APIs for clarity.
trangdoan982 053d5da
ENG-1734 Clarify unsorted vs sorted search result state in hook.
trangdoan982 2339198
ENG-1734 Add temporary debug logs for semantic vs miniSearch results.
trangdoan982 3286231
Merge branch 'main' into eng-1734-add-semantic-search-for-sync-enable…
trangdoan982 7acc534
ENG-1734 Remove debug logs and address review feedback.
trangdoan982 ff8cd08
ENG-1734 Preserve Roam's semantic result order in relevance sort
trangdoan982 49ef8af
ENG-1734 Keep provider order for relevance sort instead of re-sorting
trangdoan982 58bfcd5
ENG-1734 Cap search results and stop the docked panel latching empty
trangdoan982 8e1b146
ENG-1734 Show the indexing state while an async search is in flight
trangdoan982 c4052a0
Merge remote-tracking branch 'origin/main' into eng-1734-add-semantic…
trangdoan982 85f1a0e
ENG-1734 Test the result cap where it is applied
trangdoan982 7591049
ENG-1734 Inline the search back into searchDiscourseNodes
trangdoan982 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,9 +9,19 @@ import { | |
| getPulledDiscourseNodeUid, | ||
| queryDiscourseNodesByFormat, | ||
| } from "~/utils/discourseNodeSearch"; | ||
| import { | ||
| MAX_RESULTS, | ||
| type ScoredSearchResult, | ||
| type SearchResult, | ||
| } from "~/utils/discourseNodeSearchTypes"; | ||
|
|
||
| export type { | ||
| ScoredSearchResult, | ||
| SearchResult, | ||
| } from "~/utils/discourseNodeSearchTypes"; | ||
|
|
||
| export const DEBOUNCE_MS = 250; | ||
| export const MAX_RESULTS = 50; | ||
| export { MAX_RESULTS }; | ||
|
|
||
| export const getSearchKeywords = (searchTerm: string): string[] => | ||
| searchTerm.split(/\s+/).filter(Boolean); | ||
|
|
@@ -36,17 +46,6 @@ export const SORT_FIELD_LABELS: Record<SortField, string> = { | |
| author: "Author", | ||
| }; | ||
|
|
||
| export type SearchResult = { | ||
| uid: string; | ||
| title: string; | ||
| type: string; | ||
| nodeTypeLabel: string; | ||
| excerpt: string; | ||
| createdAt: string; | ||
| lastModified: string; | ||
| authorName: string; | ||
| }; | ||
|
|
||
| export type DockedSearchState = { | ||
| query: string; | ||
| results: SearchResult[]; | ||
|
|
@@ -56,11 +55,6 @@ export type DockedSearchState = { | |
| dgSearchId?: string; | ||
| }; | ||
|
|
||
| export type ScoredSearchHit = { | ||
| result: SearchResult; | ||
| score: number; | ||
| }; | ||
|
|
||
| type MiniSearchDocument = SearchResult & { | ||
| id: string; | ||
| }; | ||
|
|
@@ -214,23 +208,28 @@ export const isNonDefaultSort = (sort: SortConfig): boolean => | |
| sort.direction !== DEFAULT_SORT_CONFIG.direction; | ||
|
|
||
| export const sortSearchResults = ({ | ||
| hits, | ||
| scoredResults, | ||
| sort, | ||
| }: { | ||
| hits: ScoredSearchHit[]; | ||
| scoredResults: ScoredSearchResult[]; | ||
| sort: SortConfig; | ||
| }): SearchResult[] => { | ||
| const sorted = [...hits]; | ||
| // Semantic and MiniSearch results already arrive in their provider's relevance | ||
| // order, so relevance sorting only has to reverse it for ascending. | ||
| if (sort.field === "relevance") { | ||
| const ordered = | ||
| sort.direction === "asc" ? [...scoredResults].reverse() : scoredResults; | ||
| return ordered.map((entry) => entry.result); | ||
| } | ||
|
|
||
| sorted.sort((aHit, bHit) => { | ||
| const a = aHit.result; | ||
| const b = bHit.result; | ||
| const sorted = [...scoredResults]; | ||
|
|
||
| sorted.sort((aEntry, bEntry) => { | ||
| const a = aEntry.result; | ||
| const b = bEntry.result; | ||
| let comparison = 0; | ||
|
|
||
| switch (sort.field) { | ||
| case "relevance": | ||
| comparison = compareNumbers(aHit.score, bHit.score, sort.direction); | ||
| break; | ||
| case "alphabetical": | ||
| comparison = compareStrings( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| getSortableTitle(a), | ||
|
|
@@ -259,10 +258,10 @@ export const sortSearchResults = ({ | |
| return comparison || a.uid.localeCompare(b.uid); | ||
| }); | ||
|
|
||
| return sorted.map((hit) => hit.result); | ||
| return sorted.map((entry) => entry.result); | ||
| }; | ||
|
|
||
| export const searchIndexedNodes = ({ | ||
| export const searchDiscourseNodesWithMiniSearch = ({ | ||
| miniSearch, | ||
| allResults, | ||
| searchTerm, | ||
|
|
@@ -272,7 +271,7 @@ export const searchIndexedNodes = ({ | |
| allResults: SearchResult[]; | ||
| searchTerm: string; | ||
| typeFilter?: string[]; | ||
| }): ScoredSearchHit[] => { | ||
| }): ScoredSearchResult[] => { | ||
| const resultsByUid = new Map( | ||
| allResults.map((result) => [result.uid, result]), | ||
| ); | ||
|
|
@@ -291,7 +290,11 @@ export const searchIndexedNodes = ({ | |
| .map((result) => { | ||
| const searchResult = resultsByUid.get(String(result.id)); | ||
| if (!searchResult) return null; | ||
| return { result: searchResult, score: result.score }; | ||
| return { | ||
| result: searchResult, | ||
| score: result.score, | ||
| source: "miniSearch", | ||
| }; | ||
| }) | ||
| .filter((hit): hit is ScoredSearchHit => !!hit); | ||
| .filter((entry): entry is ScoredSearchResult => !!entry); | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
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.


Uh oh!
There was an error while loading. Please reload this page.