Skip to content

fix(super-filtro): auditoria round 2 — BUG-15a/b/c+16+17+19+20+VOZ (sem conflito)#487

Merged
adm01-debug merged 1 commit into
mainfrom
fix/super-filtro-bugfix-v2
May 27, 2026
Merged

fix(super-filtro): auditoria round 2 — BUG-15a/b/c+16+17+19+20+VOZ (sem conflito)#487
adm01-debug merged 1 commit into
mainfrom
fix/super-filtro-bugfix-v2

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

@adm01-debug adm01-debug commented May 26, 2026

Super Filtro — Auditoria Round 2 (26/05/2026)

Substitui PR #480 (fechada por conflito). Branch criada a partir do HEAD atual do main, sem conflito.

Continuação da PR #471 (BUG-01 a BUG-14). Fecha 8 bugs na camada de filtragem do Super Filtro.


🐛 Bugs corrigidos

Bug Severidade Arquivo Descrição
BUG-15a Crítico useFiltersPageState.ts featured contabilizado/chipeado mas sem filtro no filteredProducts useMemo
BUG-15b Crítico useFiltersPageState.ts isNew mapeia para campo inexistente — correto é product.newArrival
BUG-15c Crítico useFiltersPageState.ts hasPersonalization contabilizado mas sem filtro no useMemo
BUG-16 Crítico useFiltersPageState.ts gender contabilizado/chipeado mas sem bloco de filtro
BUG-17 Crítico useFiltersPageState.ts sizes contabilizado/chipeado mas sem filtro via variations.size_code
BUG-19 Crítico useFilterPanelState.ts Stale closure no debouncedSearch effect — filtros alterados durante os 500ms de debounce eram sobrescritos
BUG-20 Médio useFiltersPageState.ts fuzzySearchQuery usava searchParams.get('search') stale em vez de filters.search
BUG-VOZ Baixo FiltersPage.tsx sortMap no voice agent sem best-seller-supplier e best-seller-promo

Nota: BUG-21 (useCatalogFiltering: threshold < 9999) e BUG-22 (useCatalogState: threshold < 9999) já estavam presentes no main via PR #476/#481. BUG-18 (techniques/tags) permanece deferred (depende de query server-side).


📝 Commits

0be5c77  test: regressão BUG-15a/b/c+16+17+19+20+21+22+VOZ
16108ed  fix(super-filtro): BUG-15a/b/c+16+17+20 — filtros ausentes + fuzzySearchQuery
83f7ab9  fix(filter-panel): BUG-19 — stale closure em debouncedSearch via filtersRef/onFilterChangeRef
f7e2094  fix(voice): BUG-VOZ — adiciona best-seller-supplier e best-seller-promo ao sortMap

🔍 Detalhe técnico dos bugs críticos

BUG-15a/b/c — Filtros que nunca filtravam:
featured, isNew e hasPersonalization eram contados no badge, exibidos como chips removíveis, e serializados na URL — mas o filteredProducts useMemo não tinha blocos correspondentes. O campo isNew ainda mapeava para product.isNew (inexistente no tipo) em vez de product.newArrival.

BUG-16/17 — gender e sizes sem filtro:
O mesmo padrão: contabilizados e chipeados, sem bloco de filtro no useMemo. sizes foi corrigido filtrando por variations.size_code com fallback para String(v.size_code).

BUG-19 — Stale closure:
O useEffect do debouncedSearch capturava filters e onFilterChange na criação. Se o usuário alterasse uma cor durante os 500ms, o commit sobrescrevia o estado com a versão antiga. Fix: filtersRef + onFilterChangeRef com useEffect(() => { ref.current = val; }) sem deps.

BUG-20 — fuzzySearchQuery stale:
searchQuery = searchParams.get('search') || '' ficava desatualizado por 1 frame após setFilters. Corrigido para filters.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.

  • Bug Fixes
    • Apply missing filters: featured, isNew mapped to product.newArrival, hasPersonalization, gender, and sizes via variations.size_code with a nullish-safe check. (BUG-15a/b/c, BUG-16, BUG-17)
    • Use filters.search as the primary fuzzy search input to avoid stale URL reads. (BUG-20)
    • Fix debounced search stale closure with filtersRef and onFilterChangeRef to prevent overwriting changes made during the debounce window. (BUG-19)
    • Add voice sort keys best-seller-supplier and best-seller-promo to the sort map. (BUG-VOZ)

Written for commit c8690ab. Summary will update on new commits. Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Ajustado comportamento do filtro de tamanhos para garantir funcionamento correto na validação de opções disponíveis.

Review Change Stack

Copilot AI review requested due to automatic review settings May 26, 2026 21:35
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 26, 2026

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

Project Deployment Actions Updated (UTC)
we-dream-big Error Error May 27, 2026 2:08pm

@supabase
Copy link
Copy Markdown

supabase Bot commented May 26, 2026

This pull request has been ignored for the connected project doufsxqlfjyuvxuezpln because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b8f67528-1491-4130-b4ee-f737c3c17268

📥 Commits

Reviewing files that changed from the base of the PR and between 809ab8a and c8690ab.

📒 Files selected for processing (1)
  • src/pages/filters/useFiltersPageState.ts

Walkthrough

Uma linha ajustada no filtro de tamanhos: mudança de comparação estrita (!==) para solta (!=) na validação de v.size_code. Essa alteração permite que valores undefined passem pela verificação de nulidade antes de checar presença em sizeSet.

Changes

Ajuste de verificação de nulidade em filtro de tamanho

Layer / File(s) Resumo
Verificação de nulidade em filtro de tamanho
src/pages/filters/useFiltersPageState.ts
Condição alterada de v.size_code !== null para v.size_code != null, flexibilizando a validação para aceitar undefined além de null.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutos

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/super-filtro-bugfix-v2

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-supplier and best-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.

Comment on lines +282 to 288
// 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,
);
Comment on lines +18 to +22
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);
});
@adm01-debug adm01-debug force-pushed the fix/super-filtro-bugfix-v2 branch from f7e2094 to c8690ab Compare May 27, 2026 14:07
@adm01-debug adm01-debug merged commit 716a860 into main May 27, 2026
27 of 47 checks passed
@adm01-debug adm01-debug deleted the fix/super-filtro-bugfix-v2 branch May 27, 2026 14:10
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