Skip to content

fix(hooks): Auditoria Round 2 — stock BUG-01/02/03 + gravacao BUG-01/02 + docs#481

Merged
adm01-debug merged 3 commits into
mainfrom
fix/hooks-audit-round2-2026-05-26
May 26, 2026
Merged

fix(hooks): Auditoria Round 2 — stock BUG-01/02/03 + gravacao BUG-01/02 + docs#481
adm01-debug merged 3 commits into
mainfrom
fix/hooks-audit-round2-2026-05-26

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

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

Auditoria de Hooks — Round 2

Continuação da auditoria iniciada no PR #476. Esta rodada cobre bugs em stock/ e gravacao/, além de atualizar a documentação.

Nota: BUG-CS-01..06, BUG-AF-01, BUG-LOADING-01 e BUG-STAT-01 já foram incorporados ao main pelo Lovable após o merge do PR #476.


Bugs corrigidos neste PR

src/hooks/stock/stockFetcher.ts

BUG-STOCK-01buildFutureEntries: if (q && d) ignorava entradas com q=0
Corrigido para if (q != null && q > 0 && d)

BUG-STOCK-02min_quantity || 10 colapsa zero intencional para 10 (3 ocorrências)
Corrigido para min_quantity ?? 10 — preserva min_quantity=0, evita alertas falsos

BUG-STOCK-03 — Loop de paginação não encerrava em página parcial sem count
Adicionado if (totalCount === null && records.length < pageSize) break

src/hooks/gravacao/useTecnicasGravacao.ts

BUG-GRAVACAO-01 — Mensagem de erro usava variantesResult.count (pode ser null)
${variantesResult.count}${variantesResult.count ?? 'algumas'}

BUG-GRAVACAO-02toggleStatus expunha mutate (fire-and-forget) em vez de mutateAsync
Inconsistência com create/update/delete. Padronizado para mutateAsync.

docs/HOOKS_AUDIT.md

Documento atualizado: todos os 30 tasks, bugs das 2 rodadas, resumo de commits, backlog.


Backlog (próximo PR)

  • BUG-KBD-01 — keyboard handler com handleFavoriteProduct instável nas deps

Commits

SHA Descrição
8e914c32 fix(stock): stockFetcher BUG-STOCK-01/02/03
fa702127 fix(gravacao): useTecnicasGravacao BUG-GRAVACAO-01/02
d1ac302c docs: HOOKS_AUDIT.md Round 2

Summary by cubic

Round 2 da auditoria de hooks: corrige 3 bugs em stock e 2 em gravação para cálculos/loop de paginação mais confiáveis e uma API de mutação consistente. Documentação atualizada com o status final da rodada.

  • Bug Fixes

    • stock/stockFetcher.ts
      • Evita checagem “falsy” em entradas futuras; considera quantidade definida e positiva.
      • Substitui min_quantity || 10 por min_quantity ?? 10 (3 pontos) para preservar 0 intencional e evitar alertas falsos.
      • Encerra paginação quando não há count e a página vem parcial, evitando chamadas extras.
    • gravacao/useTecnicasGravacao.ts
      • Mensagem de erro usa count ?? 'algumas' para evitar “null variante(s)”.
      • toggleStatus passa a expor mutateAsync, alinhado com create/update/delete.
  • Docs

    • Atualiza docs/HOOKS_AUDIT.md com os bugs da Round 2, status das 30 tarefas e backlog.

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

BUG-STOCK-01: buildFutureEntries `if (q && d)` → `if (q != null && q > 0 && d)`
  Evita ignorar entradas com quantidade explicitamente zero

BUG-STOCK-02: `min_quantity || 10` → `min_quantity ?? 10` (3 ocorrencias)
  Preserva min_quantity=0 intencional; evita alertas falsos de estoque baixo

BUG-STOCK-03: loop sem break em pagina parcial sem count
  Adiciona `if (totalCount === null && records.length < pageSize) break`"
BUG-GRAVACAO-01: mensagem de erro usava variantesResult.count diretamente
  (pode ser null) → usa `count ?? 'algumas'` para evitar "existem null variante(s)"

BUG-GRAVACAO-02: toggleStatus expunha mutate (fire-and-forget) enquanto
  create/update/delete expunham mutateAsync (awaitable) — inconsistencia de API
  → padronizado para mutateAsync"
Copilot AI review requested due to automatic review settings May 26, 2026 20:51
@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 26, 2026 8:51pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 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 53 minutes and 53 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: d9eb7304-c827-43ea-bc45-706a38f92d38

📥 Commits

Reviewing files that changed from the base of the PR and between 15e76e8 and d1ac302.

📒 Files selected for processing (3)
  • docs/HOOKS_AUDIT.md
  • src/hooks/gravacao/useTecnicasGravacao.ts
  • src/hooks/stock/stockFetcher.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/hooks-audit-round2-2026-05-26

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

@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 ↗︎.

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

Este PR é a 2ª rodada da auditoria de hooks, focando em corrigir comportamentos incorretos no pipeline de estoque (stockFetcher) e em padronizações/correções no CRUD de técnicas de gravação (useTecnicasGravacao), além de atualizar o documento de auditoria.

Changes:

  • Ajusta regras de paginação e processamento de estoque (incluindo min_quantity ?? 10 e geração de previsões).
  • Corrige/padroniza comportamento e mensagens no hook de técnicas de gravação (incluindo toggleStatus assíncrono).
  • Atualiza docs/HOOKS_AUDIT.md com o status consolidado das rodadas.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/hooks/stock/stockFetcher.ts Correções no fetch/paginação e no processamento de dados de estoque/previsão.
src/hooks/gravacao/useTecnicasGravacao.ts Ajustes no CRUD e padronização de mutateAsync + mensagens/erros.
docs/HOOKS_AUDIT.md Atualização do relatório de auditoria e status de bugs/tarefas.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +128 to +130
// BUG-STOCK-03 FIX: if no count available, break on partial page to avoid extra call.
// A partial page (<pageSize) means we've reached the end of the dataset.
if (totalCount === null && records.length < pageSize) break;
variantSku: pv.sku || `${product.sku}-${pv.color_code || 'VAR'}`,
colorId: pv.color_id,
colorName: pv.color_name || 'Padrão',
colorName: pv.color_name || 'Padrao',
Comment on lines 362 to 366
productId: product.id,
variantId: product.id,
variantSku: product.sku || 'PROD',
colorName: 'Padrão',
colorName: 'Padrao',
currentStock,
Comment on lines 115 to +120
if ((variantesResult.count ?? 0) > 0) {
// BUG-GRAVACAO-01 FIX: variantesResult.count pode ser null quando a query
// nao suporta countMode. Usar nullish coalescing evita "existem null variante(s)".
const numVariantes = variantesResult.count ?? 'algumas';
throw new Error(
`Não é possível excluir: existem ${variantesResult.count} variante(s) vinculada(s)`,
`Nao e possivel excluir: existem ${numVariantes} variante(s) vinculada(s)`,
Comment on lines 70 to 73
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: [QUERY_KEY] });
toast.success('Técnica criada com sucesso!');
toast.success('Tecnica criada com sucesso!');
},
Comment thread docs/HOOKS_AUDIT.md
Comment on lines +151 to +155
| T14 | Fix A | BUG-CS-03 prefetch guard | Concluido (este PR) |
| T15 | Fix A | BUG-CS-04 priceRange threshold | Concluido (este PR) |
| T16 | Fix A | BUG-CS-05 useTransition | Concluido (este PR) |
| T17 | Fix M | BUG-CS-06 flash empty state | Concluido (este PR) |
| T18 | Fix M | BUG-AF-01 useAdvancedFilters deps | Concluido (este PR) |
@adm01-debug adm01-debug merged commit e009bd1 into main May 26, 2026
41 of 49 checks passed
@adm01-debug adm01-debug deleted the fix/hooks-audit-round2-2026-05-26 branch May 26, 2026 20:57
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