Skip to content

Automatically backfill semantic embeddings after model installation#1382

Merged
rohan-pandeyy merged 4 commits into
AOSSIE-Org:mainfrom
rohan-pandeyy:fix/post-tagging-semantic-search
Jul 17, 2026
Merged

Automatically backfill semantic embeddings after model installation#1382
rohan-pandeyy merged 4 commits into
AOSSIE-Org:mainfrom
rohan-pandeyy:fix/post-tagging-semantic-search

Conversation

@rohan-pandeyy

@rohan-pandeyy rohan-pandeyy commented Jul 17, 2026

Copy link
Copy Markdown
Member

Fixes a bug regarding the newly added Semantic Searching feature.
Resolves #1376

Summary

This PR improves the Semantic Search indexing workflow by automatically generating SigLIP2 embeddings for existing images when the Semantic Search model is installed after AI Tagging has already completed.

It also adds progress visibility for semantic indexing, allowing users to track indexing progress after installation.

Changes

  • Automatically trigger SigLIP2 embedding backfill after Semantic Search model installation.
  • Reuse the existing folder status polling to expose semantic indexing progress (embedding_percentage).
  • Add a Semantic Search indexing progress bar in Settings → Folder Management.
  • Show an informational dialog after Semantic Search installation explaining that background indexing has started.
  • Display a global indexing indicator while semantic embeddings are being generated.
  • Add backend and frontend test coverage for the new functionality.

Fixes

Before this change, installing the Semantic Search model after AI Tagging had already finished left existing images without embeddings, causing Semantic Search to return no results until another processing pipeline was triggered.

The application now automatically indexes existing assets after installation and provides clear progress feedback until Semantic Search is ready.

Screenshots/Recordings:

image image

AI Usage Disclosure:

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.

Check one of the checkboxes below:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: Claude Fabel 5

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

Summary by CodeRabbit

  • New Features
    • Added library-wide alerts for tagging and semantic indexing progress.
    • Added folder-level semantic indexing progress (including completion check, image counts, and semantic availability gating) in Settings.
    • Added background semantic embedding backfill scheduling after semantic model install/download.
    • Added an informational message when semantic processing starts.
  • Bug Fixes
    • Improved folder progress reporting with embedding percentages and division-by-zero-safe calculations.
  • Tests
    • Added coverage to verify semantic backfill triggers for setup/download and does not trigger for non-semantic tiers.

Images tagged before the models were installed stayed unembedded until
the next folder event, so semantic search returned nothing.
Adds a reusable BackgroundTaskAlert with a phase-aware indicator
(tagging then indexing), a per-folder indexing bar in Settings, and a
post-install info dialog.
@github-actions github-actions Bot added GSoC 2026 enhancement New feature or request labels Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: af2a5d87-88f8-4cef-ae54-1872c7e22cf9

📥 Commits

Reviewing files that changed from the base of the PR and between 392f4ac and 4ec31a4.

📒 Files selected for processing (2)
  • backend/app/routes/models.py
  • backend/tests/test_models.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • backend/tests/test_models.py
  • backend/app/routes/models.py

Walkthrough

Semantic model installation schedules embedding backfill work. Folder APIs expose tagging and embedding progress, while the frontend polls processing status and displays library-wide and per-folder indexing indicators.

Changes

Semantic indexing lifecycle

Layer / File(s) Summary
Extended folder progress contract
sync-microservice/app/schemas/folders.py, sync-microservice/app/database/folders.py, sync-microservice/app/routes/folders.py, frontend/src/types/FolderStatus.ts
Folder progress responses now include embedding percentages, image counts, and AI-tagging state.
Semantic download backfill
backend/app/routes/models.py, backend/tests/test_models.py
Semantic setup and model downloads submit image_util_process_unembedded_images to the application executor, with tests covering semantic and non-semantic flows.
Library processing status and alerts
frontend/src/hooks/useLibraryProcessingStatus.ts, frontend/src/components/BackgroundTasks/*, frontend/src/App.tsx
The frontend aggregates tagging and indexing progress and renders a dismissible application-wide processing alert.
Settings progress and installation feedback
frontend/src/pages/SettingsPage/components/FolderManagementCard.tsx, frontend/src/pages/ModelManager/AvailableTab.tsx
Settings shows per-folder semantic indexing progress, and semantic installation displays an informational dialog.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ModelManager
  participant ModelsRoute
  participant Executor
  participant FolderProgressAPI
  participant LibraryProcessingIndicator
  User->>ModelManager: Install semantic model
  ModelManager->>ModelsRoute: Start model setup/download
  ModelsRoute->>Executor: Submit embedding backfill
  Executor->>FolderProgressAPI: Update embedding progress
  FolderProgressAPI->>LibraryProcessingIndicator: Return tagging/indexing status
  LibraryProcessingIndicator->>User: Display processing status
Loading

Possibly related PRs

Suggested labels: Python, TypeScript/JavaScript

Suggested reviewers: rahulharpal1603

Poem

I’m a rabbit with embeddings to sow,
Backfilling pictures in orderly flow.
Tagging turns green,
Indexing is seen,
While semantic carrots now grow! 🐇

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR covers embedding backfill and UI/status updates, but it does not implement the issue’s core semantic search flow, query embeddings, or ranking. Implement the semantic search pipeline from #1376: text embeddings, cosine similarity ranking, result integration, and curated vocabulary fallback.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: automatic semantic embedding backfill after model installation.
Out of Scope Changes check ✅ Passed The changes all support semantic embedding backfill or related user feedback; no clearly unrelated code changes are present.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rohan-pandeyy rohan-pandeyy added bug Something isn't working and removed enhancement New feature or request labels Jul 17, 2026
@github-actions github-actions Bot added the enhancement New feature or request label Jul 17, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
backend/app/routes/models.py (1)

32-46: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add explicit type hints.

As per path instructions, ensure proper use of type hints. The dependency injected variables and newly added helper functions lack explicit type annotations.

  • backend/app/routes/models.py#L32-L46: Add type hints to the get_state return value and submit_embedding_backfill_if_semantic parameters (e.g., model_keys: list[str], executor: typing.Any).
  • backend/app/routes/models.py#L211-L211: Add a type hint to the app_state parameter.
  • backend/app/routes/models.py#L282-L282: Add a type hint to the app_state parameter.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/app/routes/models.py` around lines 32 - 46, Add explicit type
annotations to get_state’s return value and
submit_embedding_backfill_if_semantic’s model_keys and executor parameters,
using the appropriate existing state type and dependency type. Also annotate the
app_state parameters at backend/app/routes/models.py lines 211 and 282 with the
same appropriate state type; keep behavior unchanged.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/tests/test_models.py`:
- Around line 144-152: Prevent global executor state leakage in
backend/tests/test_models.py at lines 144-152 and 162-170. In _run_setup and
test_single_model_download_of_semantic_model_triggers_backfill, replace direct
app.state.executor assignments with patch.object(app.state, "executor",
executor, create=True), nesting the existing patches and test operations within
each context so teardown restores the original state.

---

Nitpick comments:
In `@backend/app/routes/models.py`:
- Around line 32-46: Add explicit type annotations to get_state’s return value
and submit_embedding_backfill_if_semantic’s model_keys and executor parameters,
using the appropriate existing state type and dependency type. Also annotate the
app_state parameters at backend/app/routes/models.py lines 211 and 282 with the
same appropriate state type; keep behavior unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8285d505-f914-4b87-9720-cd743614ae7a

📥 Commits

Reviewing files that changed from the base of the PR and between 4925a38 and 392f4ac.

📒 Files selected for processing (12)
  • backend/app/routes/models.py
  • backend/tests/test_models.py
  • frontend/src/App.tsx
  • frontend/src/components/BackgroundTasks/BackgroundTaskAlert.tsx
  • frontend/src/components/BackgroundTasks/LibraryProcessingIndicator.tsx
  • frontend/src/hooks/useLibraryProcessingStatus.ts
  • frontend/src/pages/ModelManager/AvailableTab.tsx
  • frontend/src/pages/SettingsPage/components/FolderManagementCard.tsx
  • frontend/src/types/FolderStatus.ts
  • sync-microservice/app/database/folders.py
  • sync-microservice/app/routes/folders.py
  • sync-microservice/app/schemas/folders.py

Comment thread backend/tests/test_models.py
Add type hints to app_state/executor params; isolate test executor
state via patch.object instead of leaking it across tests.
@rohan-pandeyy rohan-pandeyy removed the enhancement New feature or request label Jul 17, 2026
@rohan-pandeyy
rohan-pandeyy merged commit 6517bb6 into AOSSIE-Org:main Jul 17, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working GSoC 2026

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Natural Language Semantic Search for Images

1 participant