Skip to content

fix(catalog): deduplicate variants in browser modal + increase page density#2582

Merged
mikib0 merged 3 commits into
developmentfrom
fix/catalog-variant-dedup-and-page-density
Jun 10, 2026
Merged

fix(catalog): deduplicate variants in browser modal + increase page density#2582
mikib0 merged 3 commits into
developmentfrom
fix/catalog-variant-dedup-and-page-density

Conversation

@mikib0

@mikib0 mikib0 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Browser modal variant dedup: Applied groupCatalogItems deduplication to CatalogBrowserModal — the paginated list, popular items, and recently used sections were all showing variants as separate repeated entries (same fix as PR fix(catalog): stable pagination + variant grouping #2572 which only covered CatalogItemsScreen)
  • Page density: Bumped useCatalogItemsInfinite limit from 20 → 80 on both the catalog tab and browser modal — at ~6–7 variants per unique product, 20 raw items was collapsing to ~3 visible groups per page and immediately re-triggering the infinite scroll loader
  • No API changes — client-side only, avoids the extra full-table sort that server-side DISTINCT ON would require on 1.79M rows

Test plan

  • Open catalog browser modal (from a pack) — verify no duplicate/variant items appear in the paginated list, popular, or recently used sections
  • Scroll through the catalog tab — verify ~12+ unique products appear before the infinite scroll loader triggers
  • Scroll to end of a page in the browser modal — verify the next page loads without immediately re-triggering
  • Search in the browser modal — verify search results are unaffected (still limit 20)
  • Tap a catalog item — verify detail screen still shows all variants as before

Summary by CodeRabbit

  • Improvements
    • Refined organization of recently used and popular items in the catalog browser.
    • Enhanced catalog browsing performance through optimized item loading and list rendering.

…ensity

Apply groupCatalogItems deduplication (already used in CatalogItemsScreen
since PR #2572) to CatalogBrowserModal — paginated list, popular items, and
recently used sections were all showing variants as separate repeated entries.

Bump paginated limit from 20 → 80 on both the catalog tab and browser modal.
With ~6–7 variants per unique product on average, 20 raw items was collapsing
to ~3 visible groups per page and immediately re-triggering the infinite scroll
loader. 80 items yields ~12+ unique groups per page without adding any extra
DB sort complexity (list projection, no embedding/fat JSONB columns).
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@mikib0, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 42 minutes and 32 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 422cf58e-32df-4b8e-a066-a1c22ffc719b

📥 Commits

Reviewing files that changed from the base of the PR and between 51a6c1b and e443d07.

📒 Files selected for processing (4)
  • apps/expo/features/catalog/components/ImageViewerModal.tsx
  • apps/expo/features/catalog/screens/CatalogItemDetailScreen.tsx
  • neon/monitor-query-performance.md
  • neon/pgstatementsextensiondoc.md

Walkthrough

CatalogBrowserModal and CatalogItemsScreen are updated to apply item grouping logic to catalog display sections. groupCatalogItems is now used for Recently Used, Popular, and paginated results. Pagination limits increase from 20 to 80 items. FlatList key extraction is simplified to use item ID only.

Changes

Catalog item grouping and pagination

Layer / File(s) Summary
Pagination configuration and grouping import
apps/expo/features/catalog/components/CatalogBrowserModal.tsx, apps/expo/features/catalog/screens/CatalogItemsScreen.tsx
groupCatalogItems utility is imported, and pagination limit is increased from 20 to 80 in both modal and screen components.
Apply grouping to Recently Used and Popular sections
apps/expo/features/catalog/components/CatalogBrowserModal.tsx
Recently Used and Popular quick-access sections use groupCatalogItems to compute representative items from hook results, memoized against raw data.
Apply grouping to paginated catalog and update key extraction
apps/expo/features/catalog/components/CatalogBrowserModal.tsx
Paginated catalog items are flattened and grouped via groupCatalogItems; representatives are rendered in the main list. FlatList keyExtractor is simplified to use only item.id.

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • PackRat-AI/PackRat#2572: Applies groupCatalogItems variant grouping to catalog list rendering with overlapping UI/data-shaping changes.

Suggested labels

mobile

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the two main changes: deduplicating variants in the browser modal and increasing page density via limit adjustment.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/catalog-variant-dedup-and-page-density

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 and usage tips.

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for packages/units (./packages/units)

Status Category Percentage Covered / Total
🔵 Lines 100% (🎯 100%) 35 / 35
🔵 Statements 100% (🎯 100%) 35 / 35
🔵 Functions 100% (🎯 100%) 6 / 6
🔵 Branches 100% (🎯 100%) 11 / 11
File CoverageNo changed files found.
Generated in workflow #237 for commit e443d07 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for packages/mcp (./packages/mcp)

Status Category Percentage Covered / Total
🔵 Lines 98.87% (🎯 95%) 176 / 178
🔵 Statements 98.87% (🎯 95%) 176 / 178
🔵 Functions 100% (🎯 95%) 13 / 13
🔵 Branches 98.38% (🎯 90%) 61 / 62
File CoverageNo changed files found.
Generated in workflow #237 for commit e443d07 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for packages/overpass (./packages/overpass)

Status Category Percentage Covered / Total
🔵 Lines 100% (🎯 80%) 155 / 155
🔵 Statements 100% (🎯 80%) 155 / 155
🔵 Functions 100% (🎯 80%) 13 / 13
🔵 Branches 95.65% (🎯 70%) 44 / 46
File CoverageNo changed files found.
Generated in workflow #237 for commit e443d07 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for packages/analytics (./packages/analytics)

Status Category Percentage Covered / Total
🔵 Lines 93.68% (🎯 80%) 697 / 744
🔵 Statements 93.68% (🎯 80%) 697 / 744
🔵 Functions 97.87% (🎯 85%) 46 / 47
🔵 Branches 85.8% (🎯 80%) 133 / 155
File CoverageNo changed files found.
Generated in workflow #237 for commit e443d07 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for packages/api (./packages/api)

Status Category Percentage Covered / Total
🔵 Lines 98.95% (🎯 95%) 1322 / 1336
🔵 Statements 98.95% (🎯 95%) 1322 / 1336
🔵 Functions 100% (🎯 97%) 74 / 74
🔵 Branches 95.62% (🎯 92%) 481 / 503
File CoverageNo changed files found.
Generated in workflow #237 for commit e443d07 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for apps/expo (./apps/expo)

Status Category Percentage Covered / Total
🔵 Lines 97.52% (🎯 95%) 590 / 605
🔵 Statements 97.52% (🎯 95%) 590 / 605
🔵 Functions 100% (🎯 97%) 51 / 51
🔵 Branches 95.3% (🎯 92%) 203 / 213
File CoverageNo changed files found.
Generated in workflow #237 for commit e443d07 by the Vitest Coverage Report Action

@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 `@apps/expo/features/catalog/components/CatalogBrowserModal.tsx`:
- Around line 390-394: The flattened paginatedRawItems is recreated every render
so groupedPaginatedItems' useMemo always sees a new dependency; fix by memoizing
the flattened array (paginatedRawItems) or combining the flatten+group into one
useMemo. Concretely, move the flatMap call into a useMemo that depends on
paginatedData?.pages (e.g. create paginatedRawItems via useMemo(() =>
paginatedData?.pages.flatMap(p => p.items) ?? [], [paginatedData?.pages])) and
then pass that memoized paginatedRawItems into the existing useMemo that calls
groupCatalogItems, or collapse both steps into a single useMemo that computes
and returns groupCatalogItems(paginatedData?.pages.flatMap(...)). Ensure you
reference paginatedRawItems, groupedPaginatedItems, paginatedData?.pages, and
groupCatalogItems when making the change.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: cb598b8b-567d-497c-8b1c-3fd647f46952

📥 Commits

Reviewing files that changed from the base of the PR and between 98cc32e and 51a6c1b.

📒 Files selected for processing (2)
  • apps/expo/features/catalog/components/CatalogBrowserModal.tsx
  • apps/expo/features/catalog/screens/CatalogItemsScreen.tsx

Comment on lines +390 to +394
const paginatedRawItems = paginatedData?.pages.flatMap((page) => page.items) ?? [];
const groupedPaginatedItems = useMemo(
() => groupCatalogItems(paginatedRawItems),
[paginatedRawItems],
);

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Unstable useMemo dependency causes unnecessary recomputation.

paginatedRawItems is computed inline on every render, creating a new array reference each time. This defeats useMemo for groupedPaginatedItems since the dependency always appears changed.

Memoize the flattened array or compute everything in a single useMemo:

Proposed fix
-  const paginatedRawItems = paginatedData?.pages.flatMap((page) => page.items) ?? [];
-  const groupedPaginatedItems = useMemo(
-    () => groupCatalogItems(paginatedRawItems),
-    [paginatedRawItems],
-  );
+  const groupedPaginatedItems = useMemo(
+    () => groupCatalogItems(paginatedData?.pages.flatMap((page) => page.items) ?? []),
+    [paginatedData],
+  );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const paginatedRawItems = paginatedData?.pages.flatMap((page) => page.items) ?? [];
const groupedPaginatedItems = useMemo(
() => groupCatalogItems(paginatedRawItems),
[paginatedRawItems],
);
const groupedPaginatedItems = useMemo(
() => groupCatalogItems(paginatedData?.pages.flatMap((page) => page.items) ?? []),
[paginatedData],
);
🤖 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 `@apps/expo/features/catalog/components/CatalogBrowserModal.tsx` around lines
390 - 394, The flattened paginatedRawItems is recreated every render so
groupedPaginatedItems' useMemo always sees a new dependency; fix by memoizing
the flattened array (paginatedRawItems) or combining the flatten+group into one
useMemo. Concretely, move the flatMap call into a useMemo that depends on
paginatedData?.pages (e.g. create paginatedRawItems via useMemo(() =>
paginatedData?.pages.flatMap(p => p.items) ?? [], [paginatedData?.pages])) and
then pass that memoized paginatedRawItems into the existing useMemo that calls
groupCatalogItems, or collapse both steps into a single useMemo that computes
and returns groupCatalogItems(paginatedData?.pages.flatMap(...)). Ensure you
reference paginatedRawItems, groupedPaginatedItems, paginatedData?.pages, and
groupCatalogItems when making the change.

…thumbnails in detail screen

- Delete neon/ directory (monitor-query-performance.md, pgstatementsextensiondoc.md)
- Add CatalogItemImage thumbnail to each VariantRow in CatalogItemDetailScreen
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jun 10, 2026
- Add ImageViewerModal: full-screen swipeable gallery with horizontal
  FlatList pagination, native pinch-to-zoom on iOS (ScrollView
  maximumZoomScale), dot indicator, and close button
- Tappable hero image on detail screen opens viewer at index 0;
  expand icon hint in corner when images are present
- Horizontal thumbnail strip below hero when item has multiple images;
  tapping any thumbnail opens viewer at that index
@mikib0 mikib0 merged commit a3bc379 into development Jun 10, 2026
19 of 21 checks passed
@mikib0 mikib0 deleted the fix/catalog-variant-dedup-and-page-density branch June 10, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation mobile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Repeated Items Displayed in “Add from Catalog” List in the pack section

1 participant