Send image embedding-plot selection as geometry#1587
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (22)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (21)
📝 WalkthroughWalkthroughFrontend embedding-plot selection is reworked to persist and consume lasso/rectangle region geometry (embedding_region) instead of resolved sample-id lists, for both images and annotations. New selection-count and region-visibility hooks drive chip visibility, and PlotPanel, AnnotationsGrid, filter hooks, query builders, and layout cleanup are updated accordingly. ChangesEmbedding region filter feature (frontend)
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a37412f2d4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
/review |
1 similar comment
|
/review |
commit dd81371 Merge: c03eca0 b24059a Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Wed Jul 8 13:11:04 2026 +0200 Merge branch 'main' into kondrat/lig-9903-4-images-frontend commit c03eca0 Author: Kondrat Shmoylov <kondrat.shmoylov@gmail.com> Date: Tue Jul 7 17:35:39 2026 +0200 Frontend: Filter annotations by embedding-plot region selection (#1588) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> commit 0393302 Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Tue Jul 7 13:52:36 2026 +0200 update commit 0e75379 Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Tue Jul 7 13:50:32 2026 +0200 show selected items in the plot as well commit 6848049 Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 18:21:12 2026 +0200 fix commit 6e398bf Merge: a37412f 7ba06d7 Author: Kondrat Shmoylov <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 17:11:02 2026 +0200 Merge branch 'kondrat/lig-9903-3-annotations-backend' into kondrat/lig-9903-4-images-frontend commit 7ba06d7 Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 16:48:45 2026 +0200 fix commit 2139ecc Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 16:47:35 2026 +0200 Extract the embedding-region predicate commit 2693590 Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 16:45:16 2026 +0200 mport SQLAlchemy functions through the module commit 34a2209 Merge: 3b79ec5 70fbd8a Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 16:42:09 2026 +0200 Merge branch 'kondrat/lig-9903-2-images-backend' into kondrat/lig-9903-3-annotations-backend commit 70fbd8a Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 16:32:44 2026 +0200 Import SQLAlchemy functions through the module commit 44c39db Merge: 6ac2bf8 6b18b5f Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 16:26:53 2026 +0200 Merge branch 'kondrat/lig-9903-1-shared-region-model' into kondrat/lig-9903-2-images-backend commit 6b18b5f Merge: 8db9535 1afef78 Author: Kondrat Shmoylov <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 16:22:00 2026 +0200 Merge branch 'main' into kondrat/lig-9903-1-shared-region-model commit 8db9535 Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 16:17:54 2026 +0200 move helper functions to bottom commit 9ae5cdf Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 16:15:38 2026 +0200 use float32 commit 95a27f4 Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 16:13:22 2026 +0200 update commit 7c44af9 Merge: 3401e5b b5e335e Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 16:05:22 2026 +0200 Merge branch 'kondrat/lig-9903-1-shared-region-model' of github.com:lightly-ai/lightly-studio into kondrat/lig-9903-1-shared-region-model commit 3401e5b Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 16:05:18 2026 +0200 fix the test commit b5e335e Merge: 77cda6e 3b4e509 Author: Kondrat Shmoylov <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 15:43:25 2026 +0200 Merge branch 'main' into kondrat/lig-9903-1-shared-region-model commit 77cda6e Merge: 06dd19c 3d1754d Author: Kondrat Shmoylov <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 15:36:33 2026 +0200 Merge branch 'main' into kondrat/lig-9903-1-shared-region-model commit 6ac2bf8 Merge: 41d3e9c 06dd19c Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 15:24:35 2026 +0200 Merge branch 'kondrat/lig-9903-1-shared-region-model' into kondrat/lig-9903-2-images-backend commit 06dd19c Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 15:21:38 2026 +0200 Add a tie-breaker to guarantee determinism on equal created_at. commit 065fd41 Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 15:17:32 2026 +0200 update commit dfb968d Merge: 702067b 502dc9d Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 15:15:55 2026 +0200 Merge branch 'kondrat/lig-9903-1-shared-region-model' of github.com:lightly-ai/lightly-studio into kondrat/lig-9903-1-shared-region-model commit 702067b Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 15:15:02 2026 +0200 Use keyword arguments for square bounds commit ff67f0a Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 15:13:02 2026 +0200 Declare the polygon length constraint in the field commit 56d19f5 Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 15:05:34 2026 +0200 Make embedding-model selection deterministic commit 502dc9d Merge: 60aa87f 054c7d4 Author: Kondrat Shmoylov <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 14:53:23 2026 +0200 Merge branch 'main' into kondrat/lig-9903-1-shared-region-model commit a37412f Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 14:43:50 2026 +0200 Send image embedding-plot selection as geometry (LIG-9903) Store the image lasso/rectangle selection as region geometry instead of a resolved sample-id list and send it to the backend. Adds the shared region-selection plumbing (useEmbeddingPlotSelection count store and useRegionFilterVisibility) plus updateEmbeddingRegion on the image filter store, and threads embedding_region through the request body, types, and external-filter sync. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> commit 3b79ec5 Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 14:42:49 2026 +0200 Filter annotations by embedding-plot region selection (LIG-9903) Mirror the image behaviour for the annotations grid: AnnotationsFilter gains an optional embedding_region resolved server-side to annotation sample ids, and the annotation resolvers plus the read-with-payload route wire in the resolver. An empty region matches nothing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> commit 41d3e9c Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 14:42:18 2026 +0200 Filter images by embedding-plot region selection (LIG-9903) Add an optional embedding_region to SampleFilter, resolved server-side to sample ids before the filter is applied. The image resolvers (get_all, get_sample_ids, annotation counts) call the resolver so a lasso/rectangle selection narrows the grid without the client sending the full selected sample-id list. An empty region matches nothing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> commit 60aa87f Author: ikondrat <kondrat.shmoylov@gmail.com> Date: Mon Jul 6 14:40:50 2026 +0200 Add embedding-region model and point-in-polygon core (LIG-9903) Shared foundation for filtering both images and annotations by an embedding-plot lasso/rectangle selection. The frontend sends the region geometry (a few vertices) instead of the full list of selected sample ids, and the backend resolves it to sample ids via a vectorized point-in-polygon test over the cached 2D projection. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dd81371 to
ff1d2f3
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lightly_studio_view/src/lib/hooks/useSelectAll/useSelectAll.ts (1)
84-97: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winKeep
filter_typeout of the raw annotation fetch filter.Line 92 stamps
filter_typeintofilter, and Line 97 then passes that same object tofetchSampleIdsForAnnotations. The function-level comment says onlysnapshotFiltershould receive the discriminant, so keep the raw fetch filter to annotation predicates only.Suggested fix
- const filter = + const filter = plotRegion !== null ? { ...get(annotationFilter), - filter_type: GRID_FILTER_TYPE.annotations, embedding_region: plotRegion } : get(annotationFilter);🤖 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 `@lightly_studio_view/src/lib/hooks/useSelectAll/useSelectAll.ts` around lines 84 - 97, The raw annotation fetch filter in useSelectAll should not be stamped with GRID_FILTER_TYPE.annotations; keep filter as only the annotation predicates and reserve the discriminant for snapshotFilter. Update the logic in useSelectAll so fetchIds still calls fetchSampleIdsForAnnotations with the unmodified annotation filter plus embedding_region, while snapshotFilter is the only object that adds filter_type. Locate the change around get(annotationFilter), plotRegion, and the returned snapshotFilter/fetchIds pair.
🤖 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 `@lightly_studio_view/src/lib/components/Images/syncFilterParams.ts`:
- Around line 18-49: `mergeExternalFilters` is carrying `embedding_region`
across a collection switch without updating the dependent plot-selection count,
so the active filter can survive while `useRegionFilterVisibility` hides its
chip. Update the merge logic in `syncFilterParams.ts` so when
`currentParams.filters.embedding_region` is preserved into `baseParams`, the
corresponding selection count is also seeded or recomputed for the new
collection, keeping `getPlotSelectionCount()` non-zero whenever that region
filter is still active.
---
Outside diff comments:
In `@lightly_studio_view/src/lib/hooks/useSelectAll/useSelectAll.ts`:
- Around line 84-97: The raw annotation fetch filter in useSelectAll should not
be stamped with GRID_FILTER_TYPE.annotations; keep filter as only the annotation
predicates and reserve the discriminant for snapshotFilter. Update the logic in
useSelectAll so fetchIds still calls fetchSampleIdsForAnnotations with the
unmodified annotation filter plus embedding_region, while snapshotFilter is the
only object that adds filter_type. Locate the change around
get(annotationFilter), plotRegion, and the returned snapshotFilter/fetchIds
pair.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 58e0a5f5-9213-418b-a732-c3834ed08e99
📒 Files selected for processing (29)
lightly_studio/src/lightly_studio/api/routes/api/annotation.pylightly_studio/src/lightly_studio/resolvers/annotation_resolver/get_all_with_payload.pylightly_studio/src/lightly_studio/resolvers/annotation_resolver/get_sample_ids.pylightly_studio/src/lightly_studio/resolvers/annotations/annotations_filter.pylightly_studio/src/lightly_studio/resolvers/sample_resolver/sample_filter.pylightly_studio/tests/resolvers/annotations/test_annotations_filters.pylightly_studio/tests/resolvers/sample_resolver/test_sample_filter.pylightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationsGrid.sveltelightly_studio_view/src/lib/components/Images/syncFilterParams.test.tslightly_studio_view/src/lib/components/Images/syncFilterParams.tslightly_studio_view/src/lib/components/PlotPanel/PlotPanel.sveltelightly_studio_view/src/lib/components/PlotPanel/PlotPanel.test.tslightly_studio_view/src/lib/components/PlotPanel/usePlotData/usePlotData.test.tslightly_studio_view/src/lib/components/PlotPanel/usePlotData/usePlotData.tslightly_studio_view/src/lib/hooks/useAnnotationsInfinite/createAnnotationsInfiniteOptions.test.tslightly_studio_view/src/lib/hooks/useAnnotationsInfinite/createAnnotationsInfiniteOptions.tslightly_studio_view/src/lib/hooks/useEmbeddingFilter/useEmbeddingFilter.test.tslightly_studio_view/src/lib/hooks/useEmbeddingFilter/useEmbeddingFilterForAnnotations.test.tslightly_studio_view/src/lib/hooks/useEmbeddingFilter/useEmbeddingFilterForAnnotations.tslightly_studio_view/src/lib/hooks/useEmbeddingFilter/useEmbeddingFilterForImages.tslightly_studio_view/src/lib/hooks/useEmbeddingFilter/useEmbeddingPlotSelection.test.tslightly_studio_view/src/lib/hooks/useEmbeddingFilter/useEmbeddingPlotSelection.tslightly_studio_view/src/lib/hooks/useEmbeddingFilter/useRegionFilterVisibility.tslightly_studio_view/src/lib/hooks/useImageFilters/useImageFilters.tslightly_studio_view/src/lib/hooks/useImagesInfinite/buildRequestBody.tslightly_studio_view/src/lib/hooks/useImagesInfinite/types.tslightly_studio_view/src/lib/hooks/useImagesInfinite/useImagesInfinite.test.tslightly_studio_view/src/lib/hooks/useSelectAll/useSelectAll.tslightly_studio_view/src/routes/datasets/[dataset_id]/[collection_type]/[collection_id]/+layout.svelte
What has changed and why?
Image embedding-plot lasso/rectangle selections are now stored and sent to the backend as region geometry (
embedding_region) instead of a resolved list ofsample_ids. The backend resolves the polygon to sample ids server-side, so the request body stays small and constant-size regardless of how many items are selected.Key pieces:
useEmbeddingPlotSelection(a per-collection selection-count store:setPlotSelectionCount/clearPlotSelectionCount/getPlotSelectionCount) anduseRegionFilterVisibility, which drives the sidebar chip's count/visibility from the plot-propagated count rather than a resolved id list. Clearing the filter removes the region entirely (geometry has no separate "hidden"/restore state).useImageFilters— addsupdateEmbeddingRegion(...)to set/clear only the region in the existing filter params, and threadsembedding_regioninto the derivedimageFiltersent to the API.embedding_regionis added toNormalModeFilters,buildRequestBody, and the external-filter sync (syncFilterParams) so the region is excluded from base-param comparison and carried forward across collections alongsidesample_ids.useEmbeddingFilterForImages— switched from thesample_ids-baseduseFilterVisibilityto the newuseRegionFilterVisibility.How has it been tested?
Unit tests updated/added:
useEmbeddingPlotSelection.test.ts— per-collection count isolation, defaults, set/clear.useEmbeddingFilter.test.ts— chip visibility/count now driven by propagated plot-selection count;setVisibility(false)/clearFilterclear the region and callsetRangeSelection.useImagesInfinite.test.ts—embedding_regiongeometry is propagated tosample_filter, and omitted when no region is selected.syncFilterParams.test.ts—embedding_regiontreated as an external filter and carried forward across collections.Did you update CHANGELOG.md?
Summary by CodeRabbit
New Features
Bug Fixes