Skip to content

Cache search index in query and show skeleton while typing#2471

Open
Mbeaulne wants to merge 1 commit into
masterfrom
06-29-fix_production_slowness
Open

Cache search index in query and show skeleton while typing#2471
Mbeaulne wants to merge 1 commit into
masterfrom
06-29-fix_production_slowness

Conversation

@Mbeaulne

@Mbeaulne Mbeaulne commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Description

Improves search responsiveness by showing a skeleton loading state immediately when the user starts typing, preventing the UI from performing expensive sorting and searching operations on keystrokes that haven't yet committed to a query transition.

A new isSearching flag is set as soon as the local input value diverges from the committed query. While isSearching is true, the active query is treated as empty, sorted index computation is skipped, and the results area renders a skeleton. Once the debounced commit fires, isSearching is cleared and the real results appear.

The pauseSearch option is threaded into useComponentSearchV2State so the editor-side component search panel gets the same behaviour.

The hydration query now builds and caches the search index (IndexEntry[]) alongside the hydrated references, so expensive index derivation is tied to the library fingerprint cache rather than recomputed on every render. The library fingerprint now includes source kind, id, and label so cache entries correctly invalidate when the source set changes.

Pre-computed token and phrase caches (searchableTokens, searchablePhrases) are stored on each IndexEntry at index-build time, eliminating repeated tokenization and regex work on every keystroke inside scoreEntry.

Search suggestions are now only computed when there are no lexical or collection matches and rerank is not active, avoiding unnecessary work when results are already present.

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. Open the component search panel or dashboard components view.
  2. Begin typing a search query and observe that a skeleton loading state appears immediately while typing.
  3. Stop typing and confirm that results appear correctly after the debounce period.
  4. Verify that source filter toggles still correctly filter results.
  5. Confirm that AI rerank and embedding search continue to function as expected.

Additional Comments

The buildSourcedHydratedReferences helper is no longer needed and has been removed. The hydration query now pairs each hydrated reference with its source directly, making the post-hydration join step unnecessary.

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

🎩 Preview

A preview build has been created at: 06-29-fix_production_slowness/7590eab

@Mbeaulne Mbeaulne marked this pull request as ready for review June 29, 2026 17:44
@Mbeaulne Mbeaulne requested a review from a team as a code owner June 29, 2026 17:44
@Mbeaulne Mbeaulne changed the base branch from 06-29-adds_a_toggle_on_and_off_of_component_libraries to graphite-base/2471 June 29, 2026 17:48
@Mbeaulne Mbeaulne changed the title Fix production slowness WIP: Fix production slowness Jun 29, 2026
@Mbeaulne Mbeaulne force-pushed the 06-29-fix_production_slowness branch from 94bf16a to 905bce9 Compare June 29, 2026 17:51
@Mbeaulne Mbeaulne force-pushed the graphite-base/2471 branch from 2e4cdd9 to 2c11f71 Compare June 29, 2026 17:51
@Mbeaulne Mbeaulne changed the base branch from graphite-base/2471 to 06-29-adds_a_toggle_on_and_off_of_component_libraries June 29, 2026 17:51
@Mbeaulne Mbeaulne force-pushed the 06-29-adds_a_toggle_on_and_off_of_component_libraries branch from 2c11f71 to f84f5fb Compare June 29, 2026 18:02
@Mbeaulne Mbeaulne force-pushed the 06-29-fix_production_slowness branch 2 times, most recently from 9db5c6e to c547aec Compare June 29, 2026 18:03
@Mbeaulne Mbeaulne changed the base branch from 06-29-adds_a_toggle_on_and_off_of_component_libraries to graphite-base/2471 June 29, 2026 18:06
@Mbeaulne Mbeaulne force-pushed the 06-29-fix_production_slowness branch from c547aec to 7c40739 Compare June 29, 2026 18:10
@Mbeaulne Mbeaulne force-pushed the graphite-base/2471 branch from f84f5fb to 7d9f4e2 Compare June 29, 2026 18:10
@Mbeaulne Mbeaulne changed the base branch from graphite-base/2471 to 06-29-adds_a_toggle_on_and_off_of_component_libraries June 29, 2026 18:10
@Mbeaulne Mbeaulne changed the base branch from 06-29-adds_a_toggle_on_and_off_of_component_libraries to graphite-base/2471 June 29, 2026 18:13
@Mbeaulne Mbeaulne force-pushed the graphite-base/2471 branch from 7d9f4e2 to 370138a Compare June 29, 2026 18:13
@Mbeaulne Mbeaulne force-pushed the 06-29-fix_production_slowness branch from 7c40739 to cdd3ff0 Compare June 29, 2026 18:13
@graphite-app graphite-app Bot changed the base branch from graphite-base/2471 to master June 29, 2026 18:14
@Mbeaulne Mbeaulne force-pushed the 06-29-fix_production_slowness branch 3 times, most recently from 84aa8ca to dbf3739 Compare June 29, 2026 18:38
@Mbeaulne Mbeaulne changed the title WIP: Fix production slowness Cache search index in query and show skeleton while typing Jun 29, 2026
@Mbeaulne Mbeaulne force-pushed the 06-29-fix_production_slowness branch from dbf3739 to 7590eab Compare June 29, 2026 19:41
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.

1 participant