Skip to content

add client-side embeddings cached in IndexedDB#2432

Open
Mbeaulne wants to merge 1 commit into
06-18-improve_component_search_relevance_and_ai_rerankingfrom
06-18-add_client-side_embeddings_cached_in_indexeddb
Open

add client-side embeddings cached in IndexedDB#2432
Mbeaulne wants to merge 1 commit into
06-18-improve_component_search_relevance_and_ai_rerankingfrom
06-18-add_client-side_embeddings_cached_in_indexeddb

Conversation

@Mbeaulne

@Mbeaulne Mbeaulne commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds embedding-based semantic search as a pre-processing step before LLM reranking. When an AI provider API base is configured, the component search now fetches text embeddings for both the search query and all indexed components, ranks them by cosine similarity, and merges those results with the top lexical matches before passing candidates to the LLM reranker. This improves the quality of candidates surfaced to the reranker, particularly for queries that don't share keywords with component names or descriptions.

A new componentSearchEmbeddings service handles embedding generation, cosine similarity scoring, and persistent caching of embeddings in IndexedDB (keyed by a FNV-1a hash of the text and model name) to avoid redundant API calls across searches. A mergeUniqueMatches helper deduplicates and merges lexical and embedding results by digest before reranking.

The embedding fetch is tracked with an isEmbeddingSearchPending flag, which gates the rerank active state and disables the AI search buttons while in progress, keeping the spinner and disabled states consistent with the existing reranking UX.

Related Issue and Pull requests

Type of Change

  • Bug fix
  • New feature
  • Improvement
  • Cleanup/Refactor
  • Breaking change
  • Documentation update

Checklist

  • I have tested this does not break current pipelines / runs functionality
  • I have tested the changes on staging

Screenshots (if applicable)

Test Instructions

  1. Configure an OpenAI-compatible API base (e.g. https://api.openai.com/v1) in AI provider settings.
  2. Open the component search panel and enter a query that is semantically related to a component but does not share exact keywords.
  3. Click the AI search (Sparkles) button and verify the spinner appears during both the embedding fetch and reranking phases.
  4. Confirm that results are ranked by semantic relevance.
  5. Repeat the same search and verify via network tooling that no additional embedding API calls are made (cache hit).
  6. Verify that searches still work correctly when no API base is configured (embedding step is skipped gracefully).

Additional Comments

The embedding model is hardcoded to text-embedding-3-small. If no apiBase is set, the embedding step is skipped entirely and behaviour is identical to before this change.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

🎩 Preview

A preview build has been created at: 06-18-add_client-side_embeddings_cached_in_indexeddb/1475699

Mbeaulne commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Mbeaulne Mbeaulne marked this pull request as ready for review June 18, 2026 18:20
@Mbeaulne Mbeaulne requested a review from a team as a code owner June 18, 2026 18:20
@Mbeaulne Mbeaulne force-pushed the 06-18-add_client-side_embeddings_cached_in_indexeddb branch from 626a971 to 60a4a12 Compare June 18, 2026 18:31
@Mbeaulne Mbeaulne mentioned this pull request Jun 18, 2026
8 tasks
Comment thread src/services/componentSearchEmbeddings.ts Outdated
Comment thread src/services/componentSearchEmbeddings.ts
Comment thread src/services/componentSearchEmbeddings.ts Outdated
Comment thread src/routes/Dashboard/DashboardComponentsV2View.tsx
Comment thread src/routes/Dashboard/DashboardComponentsV2View.tsx
@Mbeaulne Mbeaulne force-pushed the 06-18-add_client-side_embeddings_cached_in_indexeddb branch from 60a4a12 to f6d7ea7 Compare June 18, 2026 19:46
@Mbeaulne Mbeaulne force-pushed the 06-18-improve_component_search_relevance_and_ai_reranking branch 2 times, most recently from 6e2b2ae to d8565d2 Compare June 18, 2026 20:28
@Mbeaulne Mbeaulne force-pushed the 06-18-add_client-side_embeddings_cached_in_indexeddb branch from f6d7ea7 to 27a3952 Compare June 18, 2026 20:28
@Mbeaulne Mbeaulne force-pushed the 06-18-improve_component_search_relevance_and_ai_reranking branch from d8565d2 to 761f88a Compare June 18, 2026 20:49
@Mbeaulne Mbeaulne force-pushed the 06-18-add_client-side_embeddings_cached_in_indexeddb branch 2 times, most recently from 316495b to 89c4999 Compare June 18, 2026 21:02
@Mbeaulne Mbeaulne force-pushed the 06-18-improve_component_search_relevance_and_ai_reranking branch 2 times, most recently from 41a7bd9 to c379d9b Compare June 18, 2026 21:16
@Mbeaulne Mbeaulne force-pushed the 06-18-add_client-side_embeddings_cached_in_indexeddb branch from 89c4999 to 92a80e1 Compare June 18, 2026 21:16
Comment thread src/services/componentSearchEmbeddings.ts
Comment thread src/services/componentSearchEmbeddings.ts
Comment thread src/routes/v2/pages/Editor/hooks/useComponentSearchV2State.ts
Comment thread src/services/componentSearchEmbeddings.test.ts
@Mbeaulne Mbeaulne force-pushed the 06-18-add_client-side_embeddings_cached_in_indexeddb branch from f23785c to 4d1b974 Compare June 24, 2026 18:11
@Mbeaulne Mbeaulne force-pushed the 06-18-improve_component_search_relevance_and_ai_reranking branch from 93231fd to 1f37704 Compare June 24, 2026 18:11
@Mbeaulne Mbeaulne requested a review from camielvs June 24, 2026 18:20
@Mbeaulne Mbeaulne force-pushed the 06-18-improve_component_search_relevance_and_ai_reranking branch from 1f37704 to a2ca752 Compare June 24, 2026 19:52
@Mbeaulne Mbeaulne force-pushed the 06-18-add_client-side_embeddings_cached_in_indexeddb branch from 4d1b974 to 7f152b7 Compare June 24, 2026 19:52
@Mbeaulne Mbeaulne force-pushed the 06-18-improve_component_search_relevance_and_ai_reranking branch from a2ca752 to bb386b4 Compare June 25, 2026 15:55
@Mbeaulne Mbeaulne force-pushed the 06-18-add_client-side_embeddings_cached_in_indexeddb branch from 7f152b7 to a48133d Compare June 25, 2026 15:55
@Mbeaulne Mbeaulne force-pushed the 06-18-improve_component_search_relevance_and_ai_reranking branch from bb386b4 to c5d57f1 Compare June 25, 2026 19:38
@Mbeaulne Mbeaulne force-pushed the 06-18-add_client-side_embeddings_cached_in_indexeddb branch from a48133d to 5bcde1e Compare June 25, 2026 19:38
@Mbeaulne Mbeaulne force-pushed the 06-18-improve_component_search_relevance_and_ai_reranking branch from c5d57f1 to a212484 Compare June 25, 2026 19:43
@Mbeaulne Mbeaulne force-pushed the 06-18-add_client-side_embeddings_cached_in_indexeddb branch from 5bcde1e to 1475699 Compare June 25, 2026 19:43
Comment thread src/routes/v2/pages/Editor/hooks/useComponentSearchV2State.ts
Comment thread src/services/componentSearchEmbeddings.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants