fix(super-filtro): auditoria exaustiva — 12 bugs corrigidos + BUG-14 base64#471
Conversation
… → best-seller-promo
… BUG-06+13 keep popularity alias BUG-14 (🔴 CRÍTICO): previous commit stored base64 text as file content instead of actual TypeScript. Re-commit with proper source. BUG-06+13 (🟡 MÉDIO): alias case 'popularity' → falls through to best-seller-promo so voice agent sort command works end-to-end.
…[0,9999] BUG-11 (🟢 BAIXO): defaultAdvancedFilters used [0,1000] while the main defaultFilters and all filter logic used 9999 as the "no upper limit" sentinel. Inconsistency could cause unexpected filtering when AdvancedFilterState is applied to the Super Filtro pipeline.
BUG-07 (🟡 MÉDIO): FilterPanel imported SORT_OPTIONS from "@/hooks/products" which could expose a different (stale/partial) list than the header's Select dropdown. Single source of truth: @/constants/filters — same module consumed by FiltersPage.tsx.
BUG-01 (🔴 CRÍTICO): fuzzy search double-filter — substring filter now
guarded by !hasFuzzySearch. Queries like "sqz" matching "Squeeze" via
fuzzy were being dropped by the subsequent exact .includes() pass.
BUG-02 (🔴 CRÍTICO): clearSingleFilter('priceRange') set [] instead of
[0,9999]. Added explicit branch before the generic Array.isArray fallback.
Also added explicit branch for 'search' (string, not boolean/array).
Added number fallback (→ 0) for minStock.
BUG-03 (🟠 ALTO): inStock filter only checked product.stock aggregate;
products with stock=0 but variations in stock were incorrectly excluded.
Now mirrors minStock logic: checks variations first.
BUG-04 (🟠 ALTO): parseInt truncated decimal prices from URL params
(e.g. "15.99" → 15). Changed to parseFloat for priceRange parsing.
minStock stays parseInt since stock is always an integer.
BUG-05 (🟠 ALTO): activeFiltersSummary missing 11 filter types. Chips in
the header bar were invisible for: techniques, tags, priceRange, minStock,
inStock, isKit, featured, isNew, hasPersonalization,
hasCommercialPackaging, search.
BUG-12 (🟢 BAIXO): appliedFilters/setAppliedFilters removed — state was
declared, exported, but never read by any consumer, causing unnecessary
re-renders on every filter change.
…IT; atualiza com 14 bugs e KPIs
|
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 39 minutes and 39 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 (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR performs an “exhaustive audit” of the Super Filtro module (/filtros) and applies a set of fixes aimed at correcting filtering/sorting behavior, preventing state corruption when clearing filters, and restoring consistency across UI filter chips and sort options.
Changes:
- Fixes filtering logic issues (URL price parsing with decimals,
inStockconsidering variations, avoiding fuzzy + substring double-filtering, safer single-filter clearing). - Fixes sorting issues (restores readable
product-sorting.ts, addspopularityalias handling, and unifiesSORT_OPTIONSsource). - Adds documentation of the audit and fixes.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/product-sorting.ts | Adds popularity alias handling for sorting (voice agent compatibility) and restores readable TS content. |
| src/pages/filters/useFiltersPageState.ts | Fixes several filter behaviors: URL parsing for price decimals, fuzzy/substr interaction, in-stock filtering for variations, active filter chips, and clearSingleFilter sentinels. |
| src/constants/filters.ts | Aligns advanced default priceRange sentinel to [0, 9999] for consistency with filtering logic. |
| src/components/filters/FilterPanel.tsx | Switches SORT_OPTIONS import to @/constants/filters to keep a single source of truth. |
| docs/SUPER_FILTRO_BUG_AUDIT_2026-05-26.md | Adds a detailed audit write-up and bug fix record. |
Comments suppressed due to low confidence (1)
src/utils/product-sorting.ts:76
- Foi adicionado suporte a
sortBy="popularity"(alias debest-seller-promo), mas os testes existentes desortProducts(Vitest) parecem cobrir apenas as opções expostas emSORT_OPTIONS. Para evitar regressão futura (ex: alguém alterarbest-seller-promoe esquecer o alias), vale adicionar um teste unitário específico garantindo quepopularityordena igual ao modo esperado.
// FIX-06+13: "popularity" era mapeado no voice agent mas nao tinha case aqui.
// Adicionado alias para best-seller-promo (semanticamente equivalente).
case "best-seller-promo":
case "popularity":
products.sort((a, b) => {
const map = options?.promoSalesMap;
const aCount = map?.get(a.id) || 0;
const bCount = map?.get(b.id) || 0;
if (bCount !== aCount) return bCount - aCount;
return a.name.localeCompare(b.name);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const pMin = get('priceMin'); | ||
| const pMax = get('priceMax'); | ||
| if (pMin || pMax) f.priceRange = [pMin ? parseInt(pMin) : 0, pMax ? parseInt(pMax) : 9999]; | ||
| // FIX-04: usar parseFloat para preservar centavos (ex: "15.99" → 15.99, não 15) | ||
| if (pMin || pMax) f.priceRange = [pMin ? parseFloat(pMin) : 0, pMax ? parseFloat(pMax) : 9999]; | ||
| const ms = get('minStock'); | ||
| if (ms) f.minStock = parseInt(ms); | ||
| if (ms) f.minStock = parseInt(ms); // minStock é sempre inteiro — parseInt ok |
| // FIX-01: filtro de busca substring só aplica quando NÃO há fuzzy search ativo. | ||
| // Antes, o substring filter rodava SEMPRE, eliminando resultados fuzzy corretos | ||
| // (ex: "sqz" encontrava "Squeeze" via fuzzy, mas .includes("sqz") === false matava o item). | ||
| if (filters.search && !hasFuzzySearch) { | ||
| const s = filters.search.toLowerCase(); |
| // FIX-02: priceRange precisa de valor sentinela [0,9999], não [] (que causaria crash downstream). | ||
| else if (key === 'priceRange') | ||
| setFilters({ ...filters, priceRange: [0, 9999] }); | ||
| // FIX-02 (cont): search é string, não boolean nem array. | ||
| else if (key === 'search') | ||
| setFilters({ ...filters, search: '' }); | ||
| else if (Array.isArray(filters[key])) setFilters({ ...filters, [key]: [] }); | ||
| else if (typeof filters[key] === 'boolean') setFilters({ ...filters, [key]: false }); | ||
| else if (typeof filters[key] === 'number') setFilters({ ...filters, [key]: 0 }); |
Auditoria Exaustiva — Super Filtro
Varredura minuciosa de 20 tarefas nos 6 arquivos do modulo Super Filtro (
/filtros).12 bugs corrigidos + 1 bug emergencial (BUG-14 base64 corrompido).
Resumo dos Bugs
Arquivos Alterados
src/utils/product-sorting.ts— BUG-06, BUG-13, BUG-14src/constants/filters.ts— BUG-11src/components/filters/FilterPanel.tsx— BUG-07src/pages/filters/useFiltersPageState.ts— BUG-01, BUG-02, BUG-03, BUG-04, BUG-05, BUG-12docs/SUPER_FILTRO_BUG_AUDIT_2026-05-26.md— documentacao completaKPIs Antes x Depois
Checklist de Review
Documentacao completa:
docs/SUPER_FILTRO_BUG_AUDIT_2026-05-26.mdSummary by cubic
Fixed 12 Super Filtro bugs and recovered a corrupted sorting file, making search, filters, and sorting reliable again.
clearSingleFilter('priceRange')resets to[0, 9999]with type‑safe resets forsearch/numbers;inStockchecks variations; header chips include 11 missing types; default advancedpriceRangealigned to[0, 9999]; removed unusedappliedFiltersstate.src/utils/product-sorting.tsfrom base64; added"popularity"alias tobest-seller-promo;FilterPanelnow importsSORT_OPTIONSfrom@/constants/filters.Written for commit 9c69470. Summary will update on new commits. Review in cubic