Skip to content

FE: thread categorical metadata values through all filter hooks - #1747

Merged
ikondrat merged 2 commits into
mainfrom
kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p6
Jul 28, 2026
Merged

FE: thread categorical metadata values through all filter hooks#1747
ikondrat merged 2 commits into
mainfrom
kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p6

Conversation

@ikondrat

@ikondrat ikondrat commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Stacked on p5.

Adds the optional categorical_metadata_values parameter to the four filter hooks so that active categorical selections are included in every sample-list request:

  • useImageFilters
  • useVideoFilters
  • useFramesFilter
  • useImagesInfinite (via buildRequestBody and createImagesInfiniteOptions)

No UI changes — the parameter defaults to undefined so existing callers are unaffected.

Test plan

  • make static-checks (frontend) passes
  • npm run test:unit passes (new parametrised tests in all four hooks)

Part of LIG-9585.

Summary by CodeRabbit

  • New Features
    • Added support for filtering images, videos, and video frames using categorical metadata values.
    • Combined standard and categorical metadata filters for more comprehensive search results.
    • Updated filtering and caching behavior to reflect categorical metadata selections.

@ikondrat
ikondrat requested a review from a team as a code owner July 22, 2026 16:18
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Image, frame, video, and infinite image filtering now accepts categorical metadata values, passes them to metadata filter creation, and includes them in infinite-query cache keys.

Changes

Categorical metadata filtering

Layer / File(s) Summary
Categorical filter inputs and contracts
lightly_studio_view/src/lib/hooks/useFramesFilter/frameFilter.ts, lightly_studio_view/src/lib/hooks/useVideoFilters/useVideoFilters.ts, lightly_studio_view/src/lib/hooks/useImagesInfinite/types.ts
Filter parameter types now expose optional categorical_metadata_values fields.
Metadata filter construction
lightly_studio_view/src/lib/hooks/useFramesFilter/frameFilter.ts, lightly_studio_view/src/lib/hooks/useImageFilters/useImageFilters.ts, lightly_studio_view/src/lib/hooks/useVideoFilters/useVideoFilters.ts, lightly_studio_view/src/lib/hooks/useImagesInfinite/buildRequestBody.ts
Metadata filters are built from standard and/or categorical metadata values, defaulting missing inputs to empty objects.
Infinite query cache identity
lightly_studio_view/src/lib/hooks/useImagesInfinite/createImagesInfiniteOptions.ts
Categorical metadata values are added to the infinite query key metadata object.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant FilterHook
  participant createMetadataFilters
  participant buildRequestBody
  participant InfiniteQuery
  FilterHook->>createMetadataFilters: provide metadata_values and categorical_metadata_values
  createMetadataFilters-->>FilterHook: return metadata_filters
  buildRequestBody->>createMetadataFilters: provide metadata_values and categorical_metadata_values
  createMetadataFilters-->>buildRequestBody: return metadata_filters
  InfiniteQuery->>InfiniteQuery: include categorical_metadata_values in queryKey
Loading

Possibly related PRs

Suggested reviewers: leonardorosaa, igorsusmelj, michal-lightly

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: threading categorical metadata values through the filter hooks.
Description check ✅ Passed The description covers the change summary and test plan, and is mostly complete despite omitting the changelog checkbox.
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.
✨ 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 kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p6

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: 8788416d40

ℹ️ 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/hooks/useImageFilters/useImageFilters.test.ts Outdated
Comment thread lightly_studio_view/src/lib/hooks/useImagesInfinite/types.ts Outdated
@lightly-fast-track-bot

lightly-fast-track-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

❌  Fast Track: checks did not pass

Guardrail Result Message
dummy Always passes.
frontend/complexity lightly_studio_view/src/lib/hooks/useFramesFilter/frameFilter.ts:24 — Arrow function has a complexity of 25. Maximum allowed is 10. lightly_studio_view/src/lib/hooks/useImageFilters/useImageFilters.ts:51 — Arrow function has a complexity of 31. Maximum allowed is 10. lightly_studio_view/src/lib/hooks/useImagesInfinite/buildRequestBody.ts:39 — Arrow function has a complexity of 11. Maximum allowed is 10. lightly_studio_view/src/lib/hooks/useVideoFilters/useVideoFilters.ts:26 — Arrow function has a complexity of 30. Maximum allowed is 10.
backend/complexity 0 file(s) checked.
backend/coverage 0 file(s) checked.
diff-size PR adds 33 line(s) (limit: 215).
frontend/coverage [FAIL] lightly_studio_view/src/lib/hooks/useImagesInfinite/types.ts: no test file found [FAIL] lightly_studio_view/src/lib/hooks/useFramesFilter/frameFilter.ts: coverage data not found [FAIL] lightly_studio_view/src/lib/hooks/useImageFilters/useImageFilters.ts: coverage data not found [FAIL] lightly_studio_view/src/lib/hooks/useImagesInfinite/buildRequestBody.ts: coverage data not found [FAIL] lightly_studio_view/src/lib/hooks/useImagesInfinite/createImagesInfiniteOptions.ts: coverage data not found [FAIL] lightly_studio_view/src/lib/hooks/useVideoFilters/useVideoFilters.ts: coverage data not found

View the guardrail run

To run the guardrails locally, from fast_track/ run make install once, then make run-guardrails (or GUARDRAILS=<name1>,<name2> make run-guardrails for some guardrails).

Reflects 59ca5be.

@ikondrat
ikondrat force-pushed the kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p5 branch from d54a61f to 8d4e752 Compare July 22, 2026 17:06
@ikondrat
ikondrat force-pushed the kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p6 branch from 8788416 to aaeaf8a Compare July 22, 2026 17:06
Base automatically changed from kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p5 to main July 27, 2026 10:38
@ikondrat
ikondrat force-pushed the kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p6 branch from 71797b1 to c7d0aab Compare July 27, 2026 15:26

@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 (1)
lightly_studio_view/src/lib/hooks/useImagesInfinite/buildRequestBody.ts (1)

17-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression coverage for categorical filters.

Please add tests for categorical-only and combined numeric/categorical metadata values in buildRequestBody.test.ts, asserting that the generated request contains the expected in filters and preserves range filters.

🤖 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/useImagesInfinite/buildRequestBody.ts`
around lines 17 - 23, Add regression tests in buildRequestBody.test.ts for
categorical-only metadata values and combined numeric/categorical values. Assert
categorical filters produce the expected “in” conditions, and combined input
preserves the existing numeric range filters alongside them.
🤖 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/hooks/useImagesInfinite/buildRequestBody.ts`:
- Around line 17-23: Add regression tests in buildRequestBody.test.ts for
categorical-only metadata values and combined numeric/categorical values. Assert
categorical filters produce the expected “in” conditions, and combined input
preserves the existing numeric range filters alongside them.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8654c8e9-d6d4-47cb-a4ca-95bbf07a735c

📥 Commits

Reviewing files that changed from the base of the PR and between 71797b1 and c7d0aab.

📒 Files selected for processing (5)
  • lightly_studio_view/src/lib/hooks/useImageFilters/useImageFilters.ts
  • lightly_studio_view/src/lib/hooks/useImagesInfinite/buildRequestBody.ts
  • lightly_studio_view/src/lib/hooks/useImagesInfinite/createImagesInfiniteOptions.ts
  • lightly_studio_view/src/lib/hooks/useImagesInfinite/types.ts
  • lightly_studio_view/src/routes/datasets/[dataset_id]/[collection_type]/[collection_id]/videos/+page.svelte
🚧 Files skipped from review as they are similar to previous changes (4)
  • lightly_studio_view/src/routes/datasets/[dataset_id]/[collection_type]/[collection_id]/videos/+page.svelte
  • lightly_studio_view/src/lib/hooks/useImagesInfinite/createImagesInfiniteOptions.ts
  • lightly_studio_view/src/lib/hooks/useImagesInfinite/types.ts
  • lightly_studio_view/src/lib/hooks/useImageFilters/useImageFilters.ts

@ikondrat

Copy link
Copy Markdown
Contributor Author

/review

@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

🤖 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/Images.svelte`:
- Line 70: Update the filterHash derivation used by initialScrollPosition and
scrollResetKey to include $categoricalMetadataValues, ensuring categorical
selection changes produce a distinct scroll-restoration hash and reset behavior.
🪄 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 Plus

Run ID: 3c7ed7e9-522f-4277-8722-4a57b3cfbe05

📥 Commits

Reviewing files that changed from the base of the PR and between c7d0aab and 12fbfe3.

📒 Files selected for processing (3)
  • lightly_studio_view/src/lib/components/Images/Images.svelte
  • lightly_studio_view/src/lib/hooks/useImageFilters/useImageFilters.ts
  • lightly_studio_view/src/lib/hooks/useImagesInfinite/buildRequestBody.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • lightly_studio_view/src/lib/hooks/useImageFilters/useImageFilters.ts
  • lightly_studio_view/src/lib/hooks/useImagesInfinite/buildRequestBody.ts

Comment thread lightly_studio_view/src/lib/components/Images/Images.svelte Outdated
@ikondrat
ikondrat force-pushed the kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p6 branch from 6268968 to 6ba47ca Compare July 28, 2026 18:07
@ikondrat
ikondrat enabled auto-merge July 28, 2026 18:08

@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 (1)
lightly_studio_view/src/lib/hooks/useFramesFilter/frameFilter.ts (1)

65-69: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression coverage for categorical metadata filtering.

  • lightly_studio_view/src/lib/hooks/useFramesFilter/frameFilter.ts#L65-L69: test categorical-only and combined metadata inputs.
  • lightly_studio_view/src/lib/hooks/useVideoFilters/useVideoFilters.ts#L74-L81: test categorical-only and combined metadata inputs.
🤖 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/useFramesFilter/frameFilter.ts` around
lines 65 - 69, The metadata filtering logic around createMetadataFilters in
lightly_studio_view/src/lib/hooks/useFramesFilter/frameFilter.ts (lines 65-69)
requires regression tests for categorical-only and combined
metadata_values/categorical_metadata_values inputs. Add equivalent coverage
around the metadata handling in
lightly_studio_view/src/lib/hooks/useVideoFilters/useVideoFilters.ts (lines
74-81), verifying both input combinations produce the expected filters; no
production logic change is requested.
🤖 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/hooks/useFramesFilter/frameFilter.ts`:
- Around line 65-69: The metadata filtering logic around createMetadataFilters
in lightly_studio_view/src/lib/hooks/useFramesFilter/frameFilter.ts (lines
65-69) requires regression tests for categorical-only and combined
metadata_values/categorical_metadata_values inputs. Add equivalent coverage
around the metadata handling in
lightly_studio_view/src/lib/hooks/useVideoFilters/useVideoFilters.ts (lines
74-81), verifying both input combinations produce the expected filters; no
production logic change is requested.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3401a257-0d3a-42a8-b84a-986d73c5ebc5

📥 Commits

Reviewing files that changed from the base of the PR and between 12fbfe3 and 59ca5be.

📒 Files selected for processing (6)
  • lightly_studio_view/src/lib/hooks/useFramesFilter/frameFilter.ts
  • lightly_studio_view/src/lib/hooks/useImageFilters/useImageFilters.ts
  • lightly_studio_view/src/lib/hooks/useImagesInfinite/buildRequestBody.ts
  • lightly_studio_view/src/lib/hooks/useImagesInfinite/createImagesInfiniteOptions.ts
  • lightly_studio_view/src/lib/hooks/useImagesInfinite/types.ts
  • lightly_studio_view/src/lib/hooks/useVideoFilters/useVideoFilters.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • lightly_studio_view/src/lib/hooks/useImageFilters/useImageFilters.ts
  • lightly_studio_view/src/lib/hooks/useImagesInfinite/types.ts
  • lightly_studio_view/src/lib/hooks/useImagesInfinite/buildRequestBody.ts
  • lightly_studio_view/src/lib/hooks/useImagesInfinite/createImagesInfiniteOptions.ts

@ikondrat
ikondrat added this pull request to the merge queue Jul 28, 2026
Merged via the queue into main with commit 60e1646 Jul 28, 2026
22 checks passed
@ikondrat
ikondrat deleted the kondrat-lig-9585-frontend-categorical-metadata-bar-chart-filter-ui-8-sp.p6 branch July 28, 2026 18:39
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