fix(super-filtro): auditoria round 2 — BUG-15a/b/c+16+17+19+20+VOZ (sem conflito)#487
Conversation
|
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. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughUma linha ajustada no filtro de tamanhos: mudança de comparação estrita ( ChangesAjuste de verificação de nulidade em filtro de tamanho
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutos ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR continues the “Super Filtro” audit by closing several filtering gaps (filters counted/serialized but not applied), fixing a debounced-search stale-closure issue in the filter panel, and updating the voice-agent sort mapping to recognize best-seller sorts.
Changes:
- Apply missing filters in
filteredProducts(featured, isNew→newArrival, hasPersonalization, gender, sizes). - Fix debounced search overwriting newer filter changes using refs (stale-closure mitigation).
- Extend voice sortMap to include
best-seller-supplierandbest-seller-promo, and add regression tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/hooks/super-filtro-bugfix-15-22.test.ts | Adds regression tests for Super Filtro bug fixes and voice sort mapping. |
| src/pages/products/FiltersPage.tsx | Updates voice-agent sort mapping to include best-seller sort keys. |
| src/pages/filters/useFiltersPageState.ts | Implements missing filter blocks and adjusts fuzzy search query source. |
| src/components/filters/filter-panel/useFilterPanelState.ts | Fixes debounced search stale-closure via refs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // 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. | ||
| const fuzzySearchQuery = filters.search || searchParams.get('search') || ''; | ||
| const { results: fuzzySearchResults, hasSearch: hasFuzzySearch } = useProductFuzzySearch( | ||
| realProducts, | ||
| searchQuery, | ||
| fuzzySearchQuery, | ||
| ); |
| describe('BUG-15a — featured filter', () => { | ||
| it('inclui só featured=true', () => { | ||
| const products = [makeProduct({ id: '1', featured: true }), makeProduct({ id: '2', featured: false })]; | ||
| expect(products.filter((p) => p.featured === true)).toHaveLength(1); | ||
| }); |
…zation/gender/sizes + fuzzySearchQuery
f7e2094 to
c8690ab
Compare
Super Filtro — Auditoria Round 2 (26/05/2026)
Continuação da PR #471 (BUG-01 a BUG-14). Fecha 8 bugs na camada de filtragem do Super Filtro.
🐛 Bugs corrigidos
useFiltersPageState.tsfeaturedcontabilizado/chipeado mas sem filtro nofilteredProductsuseMemouseFiltersPageState.tsisNewmapeia para campo inexistente — correto éproduct.newArrivaluseFiltersPageState.tshasPersonalizationcontabilizado mas sem filtro no useMemouseFiltersPageState.tsgendercontabilizado/chipeado mas sem bloco de filtrouseFiltersPageState.tssizescontabilizado/chipeado mas sem filtro viavariations.size_codeuseFilterPanelState.tsdebouncedSearcheffect — filtros alterados durante os 500ms de debounce eram sobrescritosuseFiltersPageState.tsfuzzySearchQueryusavasearchParams.get('search')stale em vez defilters.searchFiltersPage.tsxsortMapno voice agent sembest-seller-supplierebest-seller-promo📝 Commits
🔍 Detalhe técnico dos bugs críticos
BUG-15a/b/c — Filtros que nunca filtravam:
featured,isNewehasPersonalizationeram contados no badge, exibidos como chips removíveis, e serializados na URL — mas ofilteredProductsuseMemo não tinha blocos correspondentes. O campoisNewainda mapeava paraproduct.isNew(inexistente no tipo) em vez deproduct.newArrival.BUG-16/17 — gender e sizes sem filtro:
O mesmo padrão: contabilizados e chipeados, sem bloco de filtro no useMemo.
sizesfoi corrigido filtrando porvariations.size_codecom fallback paraString(v.size_code).BUG-19 — Stale closure:
O
useEffectdodebouncedSearchcapturavafilterseonFilterChangena criação. Se o usuário alterasse uma cor durante os 500ms, o commit sobrescrevia o estado com a versão antiga. Fix:filtersRef + onFilterChangeRefcomuseEffect(() => { ref.current = val; })sem deps.BUG-20 — fuzzySearchQuery stale:
searchQuery = searchParams.get('search') || ''ficava desatualizado por 1 frame apóssetFilters. Corrigido parafilters.search || searchParams.get('search') || ''.✅ Testes
tests/hooks/super-filtro-bugfix-15-22.test.ts— testes unitários cobrindo todos os bugs, incluindo casos que demonstram o comportamento bugado original.Summary by cubic
Fixes Super Filtro filtering gaps and stale search behavior. Missing filters now apply, debounced search no longer overwrites newer changes, and voice sorting recognizes best-seller options. Addresses BUG-15a/b/c, BUG-16, BUG-17, BUG-19, BUG-20, and BUG-VOZ.
featured,isNewmapped toproduct.newArrival,hasPersonalization,gender, andsizesviavariations.size_codewith a nullish-safe check. (BUG-15a/b/c, BUG-16, BUG-17)filters.searchas the primary fuzzy search input to avoid stale URL reads. (BUG-20)filtersRefandonFilterChangeRefto prevent overwriting changes made during the debounce window. (BUG-19)best-seller-supplierandbest-seller-promoto the sort map. (BUG-VOZ)Written for commit c8690ab. Summary will update on new commits. Review in cubic
Summary by CodeRabbit