Automatically backfill semantic embeddings after model installation#1382
Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughSemantic 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. ChangesSemantic indexing lifecycle
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
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
backend/app/routes/models.py (1)
32-46: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd 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 theget_statereturn value andsubmit_embedding_backfill_if_semanticparameters (e.g.,model_keys: list[str], executor: typing.Any).backend/app/routes/models.py#L211-L211: Add a type hint to theapp_stateparameter.backend/app/routes/models.py#L282-L282: Add a type hint to theapp_stateparameter.🤖 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
📒 Files selected for processing (12)
backend/app/routes/models.pybackend/tests/test_models.pyfrontend/src/App.tsxfrontend/src/components/BackgroundTasks/BackgroundTaskAlert.tsxfrontend/src/components/BackgroundTasks/LibraryProcessingIndicator.tsxfrontend/src/hooks/useLibraryProcessingStatus.tsfrontend/src/pages/ModelManager/AvailableTab.tsxfrontend/src/pages/SettingsPage/components/FolderManagementCard.tsxfrontend/src/types/FolderStatus.tssync-microservice/app/database/folders.pysync-microservice/app/routes/folders.pysync-microservice/app/schemas/folders.py
Add type hints to app_state/executor params; isolate test executor state via patch.object instead of leaking it across tests.
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
embedding_percentage).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:
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:
I have used the following AI models and tools: Claude Fabel 5
Checklist
Summary by CodeRabbit