Skip to content

Display classification annotations in the annotations grid#1704

Merged
LeonardoRosaa merged 12 commits into
mainfrom
leonardo-lig-10112-classification-grid-view-editing-annotation-grid-item-view-list
Jul 21, 2026
Merged

Display classification annotations in the annotations grid#1704
LeonardoRosaa merged 12 commits into
mainfrom
leonardo-lig-10112-classification-grid-view-editing-annotation-grid-item-view-list

Conversation

@LeonardoRosaa

@LeonardoRosaa LeonardoRosaa commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What has changed and why?

Classification annotations were previously filtered out of the annotations grid. This PR removes that filter and renders classification annotations using the existing AnnotationClassificationGridItem component.

Screenshot 2026-07-21 at 08 03 44

How has it been tested?

Unit tests

Manual test:

  1. Add any classification annotation.
  2. Go to the annotation grid - the classification annotation should be displayed.

Did you update CHANGELOG.md?

  • Yes
  • Not needed (internal change)

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Classification annotations are now shown in the annotations grid with dedicated classification tiles.
    • Classification tiles support selection, drag-and-drop into image-based search, and bulk relabeling with undo.
  • Bug Fixes

    • Classification label pills now render consistently in tiles, while still honoring the active collection filter.
  • Tests

    • Added/updated Vitest coverage for grid rendering, tile interactions, classification drag payloads, and bulk relabeling/undo flows.

@LeonardoRosaa
LeonardoRosaa requested a review from a team as a code owner July 21, 2026 10:57
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Classification annotations are now included in the annotations grid. They render through a dedicated tile with always-visible classification pills, support thumbnail-based drag-to-search, and are covered by tests for rendering, selection, bulk relabeling, and undo handling.

Classification grid support

Layer / File(s) Summary
Classification tile rendering
lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationClassificationGridItem/*, lightly_studio_view/src/lib/components/SampleClassificationPills/SampleClassificationPills.svelte
Classification pills render unconditionally, with an optional collection filter override.
Grid inclusion and interactions
lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationsGrid.svelte, lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationsGrid.helpers.ts
The grid includes classification annotations, selects classification-specific tiles, and creates thumbnail-based drag payloads.
Grid test coverage and mocks
lightly_studio_view/src/lib/components/AnnotationsGrid/*, lightly_studio_view/src/lib/components/{Grid,GridContainer,GridItem,SelectableBox}/*.mock.svelte, CHANGELOG.md
Component tests and mocks cover classification rendering, selection, relabeling, undo behavior, drag-data construction, and the unreleased changelog entry.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AnnotationsGrid
  participant AnnotationClassificationGridItem
  participant SampleClassificationPills
  participant SearchDropHandler
  AnnotationsGrid->>AnnotationClassificationGridItem: render classification annotation tile
  AnnotationClassificationGridItem->>SampleClassificationPills: pass classification sample and collection override
  AnnotationsGrid->>SearchDropHandler: pass thumbnail URL and crop-derived filename
Loading

Possibly related PRs

Suggested reviewers: horatiualmasan

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely summarizes the main change: showing classification annotations in the annotations grid.
Description check ✅ Passed The description covers the required sections with change summary, testing details, and confirmation that CHANGELOG.md was updated.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch leonardo-lig-10112-classification-grid-view-editing-annotation-grid-item-view-list

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf780aa1b1

ℹ️ 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".

Comment thread lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationsGrid.helpers.ts Outdated

@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.

🧹 Nitpick comments (3)
lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationsGrid.svelte (2)

316-327: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

P2: Extract the dragData ternary into a small helper for readability.

The inline isClassification ? buildClassificationDragData(...) : buildAnnotationDragData(...) ternary is a bit dense inside the template. A tiny local helper (e.g. getDragData(ann, annotationId)) would read more clearly.

As per path instructions, prioritize style/readability fixes as succinct "P2" comments.

🤖 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/components/AnnotationsGrid/AnnotationsGrid.svelte`
around lines 316 - 327, The inline dragData ternary in the AnnotationsGrid
template is too dense. Add a small local helper such as getDragData that accepts
the annotation data and annotationId, selects the appropriate classification or
regular builder, and reuse it for the dragData prop while preserving the
existing arguments and behavior.

Source: Path instructions


316-327: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Classification drag preview re-renders the full image via canvas unnecessarily.

For classification tiles, cropWindow covers the entire image (windowX/Y=0, full width/height per AnnotationClassificationGridItem.svelte), so handleAnnotationDragStartrenderCropObjectUrl produces a canvas-rendered blob that's pixel-identical to the already-available cropWindow.sourceUrl. Since buildClassificationDragData already falls back to cropWindow.sourceUrl when cropUrl isn't set, this canvas render is wasted work on every classification drag-start, and gets more costly with large source images.

Consider short-circuiting handleAnnotationDragStart (or skipping the onDragStart call) for classification tiles so the drag payload uses cropWindow.sourceUrl directly without the canvas round-trip.

Also applies to: 97-108

🤖 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/components/AnnotationsGrid/AnnotationsGrid.svelte`
around lines 316 - 327, Update the classification path around
handleAnnotationDragStart and the onDragStart binding so classification tiles do
not invoke renderCropObjectUrl or perform a canvas render. Skip the drag-start
handler for classification annotations, allowing buildClassificationDragData to
use cropWindow.sourceUrl directly, while preserving the existing drag behavior
for non-classification annotations.
lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationsGrid.test.ts (1)

237-249: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

P2: Redundant mockResolvedValue('v1') call.

renderGrid() sets mocks.getCollectionVersion.mockResolvedValue('v1') (line 238), but beforeEach already does this after vi.clearAllMocks() (line 246). The call in renderGrid() is dead duplication.

As per path instructions, prioritize style/readability fixes as succinct "P2" comments.

🤖 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/components/AnnotationsGrid/AnnotationsGrid.test.ts`
around lines 237 - 249, Remove the redundant
mocks.getCollectionVersion.mockResolvedValue('v1') call from renderGrid(),
relying on the existing setup in the describe block’s beforeEach while
preserving renderGrid()’s rendering behavior.

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.

Nitpick comments:
In
`@lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationsGrid.svelte`:
- Around line 316-327: The inline dragData ternary in the AnnotationsGrid
template is too dense. Add a small local helper such as getDragData that accepts
the annotation data and annotationId, selects the appropriate classification or
regular builder, and reuse it for the dragData prop while preserving the
existing arguments and behavior.
- Around line 316-327: Update the classification path around
handleAnnotationDragStart and the onDragStart binding so classification tiles do
not invoke renderCropObjectUrl or perform a canvas render. Skip the drag-start
handler for classification annotations, allowing buildClassificationDragData to
use cropWindow.sourceUrl directly, while preserving the existing drag behavior
for non-classification annotations.

In
`@lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationsGrid.test.ts`:
- Around line 237-249: Remove the redundant
mocks.getCollectionVersion.mockResolvedValue('v1') call from renderGrid(),
relying on the existing setup in the describe block’s beforeEach while
preserving renderGrid()’s rendering behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5d6f3c14-115c-496f-9cd5-7c5213d24161

📥 Commits

Reviewing files that changed from the base of the PR and between e3d13e7 and bf780aa.

📒 Files selected for processing (14)
  • CHANGELOG.md
  • lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationClassificationGridItem/AnnotationClassificationGridItem.mock.svelte
  • lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationClassificationGridItem/AnnotationClassificationGridItem.svelte
  • lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationClassificationGridItem/AnnotationClassificationGridItem.test.ts
  • lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationsGrid.helpers.ts
  • lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationsGrid.svelte
  • lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationsGrid.test.ts
  • lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationsGridItem/AnnotationsGridItem.mock.svelte
  • lightly_studio_view/src/lib/components/AnnotationsGrid/SelectedAnnotations/SelectedAnnotations.mock.svelte
  • lightly_studio_view/src/lib/components/Grid/Grid.mock.svelte
  • lightly_studio_view/src/lib/components/GridContainer/GridContainer.mock.svelte
  • lightly_studio_view/src/lib/components/GridItem/GridItem.mock.svelte
  • lightly_studio_view/src/lib/components/SampleClassificationPills/SampleClassificationPills.svelte
  • lightly_studio_view/src/lib/components/SelectableBox/SelectableBox.mock.svelte

@LeonardoRosaa

Copy link
Copy Markdown
Contributor Author

/review

@ikondrat ikondrat 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.

The rendering branch looks reasonable, but several tests currently mock away the behavior they claim to cover. The inline comments focus on making those contracts observable without broadening the production change.

Comment thread lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationsGrid.test.ts Outdated
Comment thread lightly_studio_view/src/lib/components/AnnotationsGrid/AnnotationsGrid.test.ts Outdated
@LeonardoRosaa
LeonardoRosaa enabled auto-merge July 21, 2026 15:40
@LeonardoRosaa
LeonardoRosaa added this pull request to the merge queue Jul 21, 2026
Merged via the queue into main with commit 183fbe3 Jul 21, 2026
21 of 22 checks passed
@LeonardoRosaa
LeonardoRosaa deleted the leonardo-lig-10112-classification-grid-view-editing-annotation-grid-item-view-list branch July 21, 2026 16:05
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.

2 participants