Skip to content

fix(filters): onSale chip gap + ESLint regressions from main#662

Merged
adm01-debug merged 3 commits into
mainfrom
claude/magical-archimedes-obX51
Jun 5, 2026
Merged

fix(filters): onSale chip gap + ESLint regressions from main#662
adm01-debug merged 3 commits into
mainfrom
claude/magical-archimedes-obX51

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

@adm01-debug adm01-debug commented Jun 5, 2026

Summary

Bugs found during exhaustive testing of the quick-wins implemented in #644.

  • Bug fix (useFiltersPageState.ts): onSale was counted in activeFiltersCount (+1 to the badge) but had no entry in activeFiltersSummary — users could not remove the "Em Oferta" filter via the removable-chip UI. Added the missing chip entry.
  • ESLint cleanup (4 files): 8 warnings introduced by main-branch commits after the ESLint baseline was generated. All suppressions are intentional patterns (test mock casts with as any, and react-hooks/exhaustive-deps where the omission is deliberate and documented).

What was exhaustively tested (and found OK)

Fix Result
fetchProductImagesBatch — chunked IN() ✅ Map-building correct; chunks align with CHUNK_SIZE=80; deduplication works
Intl.Collator('pt-BR', { numeric, sensitivity:'base' }) ✅ Verified in Node.js: Caneta 1 < Caneta 2 < Caneta 10; Abacaxi < Açaí < Água
compareNamePtBR null/undefined safety ✅ All 3 cases correct
name-asc / name-desc switch cases ✅ No longer fall through to no-op default
byNameThenId / withIdTiebreak ✅ Deterministic lexicographic id tiebreak
URL priceRange validation (NaN, negative, min>max) ✅ All edge cases handled
URL sortBy whitelist (VALID_SORT_VALUES) ✅ 11 values accepted, invalid rejected
techniquesDataAvailable guard ✅ All 3 usages (count, filter, chip) correctly gated + in dep arrays
Migration indexes — no conflict ✅ IF NOT EXISTS, different names from 20260604000003_*

Test plan

  • Apply ?onSale=1 in URL on Filtros page → verify "Em Oferta" chip appears and is removable
  • Verify filter count badge matches number of visible chips
  • CI gates: ESLint 0 regressions, TypeScript 0 regressions

https://claude.ai/code/session_01E14WrLRzQUQpeRs9sFV2uk


Generated by Claude Code


Summary by cubic

Fixes the missing on-sale removable chip and hardens filter URL parsing, while making sorting correct and stable. Also speeds up catalog queries with chunked image fetching and new partial DB indexes.

  • Bug Fixes

    • Filters: add "Em Oferta" chip for onSale; validate priceRange/minStock from URL (NaN, negatives, min>max); accept only known sortBy; show/count Techniques only when product data actually has techniques.
    • Sorting: use pt-BR collator with natural numeric order; implement name-asc/name-desc; add deterministic id tiebreak across modes; align productService orderBy for name asc/desc.
    • ESLint: add targeted suppressions for intentional test casts and react-hooks/exhaustive-deps cases.
  • Performance

    • Batch product images with IN(product_id) in chunks of 80 instead of fetching and filtering the full table.
    • Add partial indexes for active products on sale_price, created_at DESC, and stock_quantity DESC to accelerate catalog sorts.

Written for commit d762b01. Summary will update on new commits.

Review in cubic

claude added 3 commits June 4, 2026 21:13
Auditoria exaustiva do módulo de catálogo — correções seguras e isoladas:

1. useProductImages.fetchProductImagesBatch: usa filtro IN(product_id) em
   chunks (80) em vez de baixar a tabela product_images inteira (limit 5000)
   e filtrar em memória — evita transferir milhares de linhas e o
   truncamento silencioso pelo teto de limit.

2/14/26. product-sorting: comparador único compareNamePtBR (Intl.Collator
   pt-BR, numeric + sensitivity base) — "Caneta 2" antes de "Caneta 10",
   acentuação consistente. Tie-break por id em todos os modos → ordem
   determinística entre páginas no infinite scroll. Aliases name-asc/
   name-desc tratados explicitamente (antes caíam no no-op default), tanto
   no sorter quanto no orderBy server-side do productService.

4/28. useFiltersPageState: valida priceRange e minStock vindos da URL
   (NaN guard + clamp min<=max) — antes ?priceMin=abc zerava a lista sem
   feedback. sortBy da URL só é aceito se for um valor conhecido.

20. useFiltersPageState: filtro de Técnicas só conta como ativo / exibe
   chip / filtra quando há metadata.techniques nos produtos. Antes era um
   no-op que ainda contava no badge e mostrava chip (falso positivo).

5/10. Migração add_catalog_sort_indexes: índices parciais (WHERE active)
   para sale_price, created_at DESC e stock_quantity DESC — colunas de
   ordenação do catálogo que não tinham índice. Já aplicada no projeto.

Testes unitários adicionados para o collator pt-BR, aliases de nome e
tie-break determinístico. Gates TSC (0 erros) e ESLint baseline (0) verdes.

https://claude.ai/code/session_01E14WrLRzQUQpeRs9sFV2uk
…rom main

- useFiltersPageState: onSale was counted in activeFiltersCount but had no
  corresponding chip in activeFiltersSummary — users could not remove it via
  the removable-filter UI. Added "Em Oferta / Sim" summary entry.
- ProductCard, useMobileSidebarFix: add eslint-disable-next-line for
  react-hooks/exhaustive-deps where omission is intentional (granular deps
  vs whole object; route-change-only trigger).
- ThemeInitializer.test, useCatalogPrefetch.test: add eslint-disable-next-line
  for no-explicit-any on vitest mock casts (standard test-mocking pattern).
  All 4 files were introduced by main-branch commits after the baseline was
  generated; these suppress the regressions without changing runtime behavior.

https://claude.ai/code/session_01E14WrLRzQUQpeRs9sFV2uk
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
we-dream-big Ready Ready Preview, Comment Jun 5, 2026 1:11am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Warning

Review limit reached

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

More reviews will be available in 34 minutes and 16 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: CHILL

Plan: Pro

Run ID: 0f9bd397-c9b5-4903-a66e-53ea5bde7e9e

📥 Commits

Reviewing files that changed from the base of the PR and between a19ed74 and d762b01.

📒 Files selected for processing (10)
  • src/components/ThemeInitializer.test.tsx
  • src/components/products/ProductCard.tsx
  • src/hooks/products/useCatalogPrefetch.test.ts
  • src/hooks/products/useProductImages.ts
  • src/hooks/ui/useMobileSidebarFix.ts
  • src/pages/filters/useFiltersPageState.ts
  • src/services/productService.ts
  • src/utils/product-sorting.ts
  • supabase/migrations/20260604120000_add_catalog_sort_indexes.sql
  • tests/utils/product-sorting.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/magical-archimedes-obX51

Comment @coderabbitai help to get the list of available commands and usage tips.

@supabase
Copy link
Copy Markdown

supabase Bot commented Jun 5, 2026

This pull request has been ignored for the connected project doufsxqlfjyuvxuezpln due to reaching the limit of concurrent preview branches.
Go to Project Integrations Settings ↗︎ if you wish to update this limit.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@adm01-debug adm01-debug marked this pull request as ready for review June 5, 2026 01:22
Copilot AI review requested due to automatic review settings June 5, 2026 01:22
@adm01-debug adm01-debug merged commit 7aae5ff into main Jun 5, 2026
29 of 37 checks passed
@adm01-debug adm01-debug deleted the claude/magical-archimedes-obX51 branch June 5, 2026 01:22
@adm01-debug adm01-debug review requested due to automatic review settings June 5, 2026 01:43
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