[REBASED → #482] fix(super-filtro): BUG-15 a BUG-22 + BUG-VOZ#480
[REBASED → #482] fix(super-filtro): BUG-15 a BUG-22 + BUG-VOZ#480adm01-debug wants to merge 9 commits into
Conversation
…m useCatalogState
…ersRef/onFilterChangeRef
…hasPersonalization/gender/sizes filtros ausentes + fuzzySearchQuery stale
…mo ao sortMap do voice agent
…er Filtro auditoria 26/05/2026
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Warning Review limit reached
More reviews will be available in 21 minutes and 56 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 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Corrige uma nova rodada de bugs do módulo “Super Filtro” (FiltersPage + hooks relacionados), garantindo que filtros antes apenas “contados/chipeados” passem a afetar de fato o pipeline de filtragem, além de ajustar thresholds de priceRange e um mapeamento de sort do voice agent.
Changes:
- Adiciona filtros faltantes no
useFiltersPageState(featured, isNew→newArrival, hasPersonalization, gender, sizes) e ajusta a origem da query do fuzzy search. - Corrige a ativação/contagem do filtro de preço no catálogo (
< 500→< 9999) e mitiga stale closure no debounce do painel de filtros via refs. - Inclui casos de ordenação faltantes no sortMap do voice agent e adiciona testes/documentação de auditoria.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/hooks/super-filtro-bugfix-15-22.test.ts | Adiciona testes de regressão para os bugs 15–22 e voice sorting. |
| src/types/product-catalog.ts | Inclui hasPersonalization no tipo Product. |
| src/pages/products/FiltersPage.tsx | Completa sortMap do voice agent com best-sellers. |
| src/pages/filters/useFiltersPageState.ts | Aplica filtros ausentes (featured/isNew/hasPersonalization/gender/sizes) e ajusta fuzzy query. |
| src/hooks/products/useCatalogState.ts | Corrige contagem de filtro ativo para priceRange (threshold). |
| src/hooks/products/useCatalogFiltering.ts | Corrige ativação do filtro priceRange (threshold). |
| src/components/filters/filter-panel/useFilterPanelState.ts | Evita stale closure no debounce de search via refs. |
| docs/bugs-super-filtro-audit-2026-05.md | Documenta auditoria e bugs corrigidos/TODOs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (filters.isNew) result = result.filter((product) => product.newArrival === true); | ||
| // BUG-15c FIX (parte 2): hasPersonalization — tipo corrigido em commit anterior; filtro aplicado aqui. | ||
| if (filters.hasPersonalization) | ||
| result = result.filter((product) => product.hasPersonalization === true); | ||
| // BUG-16 FIX: gender era contabilizado/chipeado mas sem bloco de filtro. |
| // BUG-20 FIX: usar filters.search como fonte primária (imediata) em vez de | ||
| // searchParams.get('search') que fica stale por 1 render frame após setFilters. | ||
| // O fallback para searchParams mantém compatibilidade com links diretos via URL. | ||
| const fuzzySearchQuery = filters.search || searchParams.get('search') || ''; | ||
| const { results: fuzzySearchResults, hasSearch: hasFuzzySearch } = useProductFuzzySearch( | ||
| realProducts, | ||
| searchQuery, | ||
| fuzzySearchQuery, | ||
| ); |
| /** BUG-15c: adicionado para suportar filtro hasPersonalization no Super Filtro e Catálogo. | ||
| * Mapeado do campo has_personalization na DB (via product mapper). */ |
| useEffect(() => { filtersRef.current = filters; }); | ||
| useEffect(() => { onFilterChangeRef.current = onFilterChange; }); |
| describe('BUG-15a — filtro featured', () => { | ||
| it('deve incluir apenas produtos com featured=true quando filtro ativo', () => { | ||
| const products = [ | ||
| makeProduct({ id: '1', featured: true }), | ||
| makeProduct({ id: '2', featured: false }), | ||
| makeProduct({ id: '3' }), // featured undefined → falsy | ||
| ]; | ||
|
|
||
| const result = products.filter((p) => p.featured === true); | ||
| expect(result).toHaveLength(1); |
| makeProduct({ | ||
| id: '1', | ||
| variations: [{ size_code: 'M', stock: 10 }] as never, | ||
| }), | ||
| makeProduct({ | ||
| id: '2', | ||
| variations: [{ size_code: 'G', stock: 5 }] as never, | ||
| }), |
| const products = [ | ||
| makeProduct({ id: '1', featured: true }), | ||
| makeProduct({ id: '2', featured: false }), | ||
| makeProduct({ id: '3' }), // featured undefined → falsy |
…ransition + BUG-CS-04/priceRange < 9999)
#485) Incorpora PR #480 (fix/super-filtro-audit-bugs-15-23) sobre HEAD atual do main. BUG-15a — featured: contabilizado/chipeado mas sem filtro no useMemo → adicionado BUG-15b — isNew: filtro usava product.isNew (inexistente) → product.newArrival BUG-15c — hasPersonalization: ausente do tipo Product → adicionado em product-catalog.ts BUG-16 — gender: contabilizado mas sem bloco de filtro → adicionado BUG-17 — sizes: contabilizado mas sem filtro via variations.size_code → adicionado BUG-19 — stale closure em debouncedSearch: filtersRef+onFilterChangeRef pattern BUG-20 — fuzzySearchQuery usava searchParams.get stale → usa filters.search BUG-21 — priceRange threshold < 500 → < 9999 em useCatalogFiltering BUG-22 — activeFiltersCount priceRange < 500 → < 9999 em useCatalogState BUG-VOZ — sortMap sem best-seller-supplier/promo → adicionados em FiltersPage.tsx fix(lint): != null → !== null (eqeqeq) em useFiltersPageState.ts linha 415 Testes: 27/27 passando (super-filtro-bugfix-15-22.test.ts) Co-authored-by: Claude <noreply@anthropic.com>
Fechado: branch rebased sobre HEAD atual do main em
rebase/480-super-filtro. PR substituto: #482 (aberto agora). Conflito causado por divergência de 33+ commits do Lovable. Os 8 arquivos únicos foram aplicados limpos, com fix adicional:!= null → !== null(eqeqeq lint) em useFiltersPageState.ts. Testes: 27/27 passando.