Skip to content

Fix: lazy load embedding pipeline to eliminate cold start flash#9

Merged
daveshenal merged 2 commits into
mainfrom
fix/service-worker-cold-start-flash
Jul 1, 2026
Merged

Fix: lazy load embedding pipeline to eliminate cold start flash#9
daveshenal merged 2 commits into
mainfrom
fix/service-worker-cold-start-flash

Conversation

@daveshenal

Copy link
Copy Markdown
Owner

What changed

  • background.js: Extracted ensureEmbedder() helper that lazily loads
    the embedding pipeline only when actually needed. initialize() now
    checks the cache fingerprint first - on a cache hit cold start the popup
    reaches "ready" in ~20ms without touching the model at all. search()
    calls ensureEmbedder() before embedding the query, so the model loads
    on first search rather than on every worker respawn.

  • popup.js: Added 150ms debounce before showing "Loading AI model…".
    If the background responds ready within that window the user never
    sees the loading pane. Only shown when there's genuinely something to wait for.

Tested

  • Cold start with fresh cache → popup instant, no loading flash ✓
  • First search after cold start → pipeline loads lazily (~300ms), results returned ✓
  • Chrome restart → loading pane shows correctly ✓
  • Stale cache / no cache → loading pane shows correctly ✓

daveshenal and others added 2 commits July 1, 2026 08:13
Co-Authored-By: PEPLOR <223156220+peplor@users.noreply.github.com>
Co-Authored-By: Copilot <198982749+Copilot@users.noreply.github.com>

@peplor peplor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@daveshenal daveshenal merged commit b8d1209 into main Jul 1, 2026
1 check passed
@daveshenal daveshenal deleted the fix/service-worker-cold-start-flash branch July 1, 2026 05:26
@daveshenal daveshenal mentioned this pull request Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Service worker eviction causes occasional model reload flash after idle periods

2 participants