Skip to content

feat(novelties+stock): paginated grid, a11y, error handling — resolves Lovable PRs #547-#552#553

Merged
adm01-debug merged 3 commits into
mainfrom
claude/exciting-wright-xA6by
May 31, 2026
Merged

feat(novelties+stock): paginated grid, a11y, error handling — resolves Lovable PRs #547-#552#553
adm01-debug merged 3 commits into
mainfrom
claude/exciting-wright-xA6by

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

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

Summary

Resolves all features introduced by Lovable PRs #547, #549, #550, #551, #552, applied cleanly on current main with three critical bugs fixed before landing.

Critical bugs fixed (not in any Lovable PR)

Bug Location Impact
React Rules of Hooks violation VariantStockTable.tsx Early return placed between hook calls — throws in dev, corrupts state in prod
Pagination trapped inside isFetching overlay NoveltyProductGrid.tsx Pagination block was inside the motion.div that only mounts during refetch — invisible during normal browsing
Ellipsis replaces navigable pages NoveltyProductGrid.tsx page === 2 || page === totalPages - 1 collapsed navigable pages unconditionally; fixed to page === currentPage ± 2

Features included

  • Novidades pagination: client-side, 20 items/page, page resets on filter/sort change, paginator hidden when ≤ 1 page
  • NoveltyCards a11y: role="article", aria-label, aria-selected, tabIndex, onKeyDown (Enter/Space)
  • VariantStockTable: isLoading prop with animate-pulse skeleton rows (hooks-safe placement)
  • StockDashboard: error UI (AlertCircle + retry button) + passes isFetching → table skeleton
  • useVariantStock: exposes error; retry ×3 with exponential backoff (1 s → 2 s → 4 s, cap 10 s)
  • stockFetcher: throws on Supabase error (was silently breaking); detects 410/Gone and surfaces Portuguese user-facing message
  • ModernSkeletons: updated title min-height + new price-area skeleton (min-h-[3.25rem])
  • CI: Playwright sharding 2× in visual-tests.yml; workers: 2 in playwright.config.ts
  • E2E: novelty-grid-visual.spec.ts expanded (4 viewports × 5 tests + 3 global); novelty-card-variations.spec.ts (new); tests/e2e/stock-regression.spec.ts (new)

Not included (already applied)

rest-native.ts additions (variant_supplier_sources, supplier_branches, categories) were committed in Phase 1 (kill-switch) and Phase 2 (ghost aliases) sessions — skipped here to avoid double-application.

Test plan

  • /novidades — scroll through paginated grid, verify page nav shows/hides correctly
  • /novidades — apply filter, confirm page resets to 1
  • /novidades — keyboard Tab to card, Enter/Space to open — verify focus ring and activation
  • /estoque — with kill-switch OFF (current state), verify error UI renders if bridge fails with 410
  • /estoque — verify isFetching state shows skeleton rows in table without Rules of Hooks error in console
  • Run npx playwright test e2e/routes/app/novelty-card-variations.spec.ts — 3 cards render
  • Run npx playwright test e2e/routes/app/novelty-grid-visual.spec.ts — 4 viewports pass
  • CI visual-tests workflow — confirm shards 1/2 and 2/2 both upload artifacts

https://claude.ai/code/session_015DVTnofjTd3PtzU2kGvYtV


Generated by Claude Code


Summary by cubic

Adds client-side pagination to the novelties grid with improved a11y, and hardens the stock dashboard with error handling and loading skeletons. Resolves Lovable PRs #547#552 and fixes three critical issues in pagination and hook usage.

  • New Features

    • Novelties: client-side pagination (20/page) with reset on filter/sort and auto-hide when ≤1 page; cards get role/labels/focus and Enter/Space activation.
    • Stock: error state with retry in the dashboard; VariantStockTable supports isLoading with pulse skeleton rows.
    • Data fetching: useVariantStock exposes error and retries x3 with exponential backoff (cap 10s); stockFetcher throws on Supabase errors and surfaces a 410/Gone message in Portuguese.
    • Skeletons: increased title min-height and added price-area skeleton to stabilize card layout.
    • CI/E2E: Playwright sharded 2× in visual-tests.yml with workers: 2; added novelty-card-variations and expanded novelty-grid-visual; new stock-regression spec.
  • Bug Fixes

    • Fixed React Rules of Hooks violation in VariantStockTable (removed early return between hooks).
    • Fixed novelties pagination being hidden under the isFetching overlay.
    • Corrected pagination ellipsis logic so pages near the current page remain clickable.
    • Cleaned up PriceFreshnessBadge unused helper and improved rpc-native dispatch with safer fallbacks and clearer errors.

Written for commit f1116b7. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

Release Notes

  • New Features

    • Adicionada paginação na grade de produtos de novidade
    • Navegação por teclado com melhor acessibilidade nos cards de novidade
  • Bug Fixes

    • Tratamento melhorado de erros ao carregar dados de estoque
    • Tentativas automáticas de reconexão para requisições
    • Mensagens de erro mais informativas
  • Style

    • Estados de carregamento visualmente mais estáveis
  • Tests

    • Testes E2E adicionados para estoque e variações de novelty cards

@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

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

Project Deployment Actions Updated (UTC)
we-dream-big Error Error May 31, 2026 8:42pm

@supabase
Copy link
Copy Markdown

supabase Bot commented May 31, 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 31, 2026

Review Change Stack

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: 1956e15f-a75b-4afd-a8f3-528dfd65cf9a

📥 Commits

Reviewing files that changed from the base of the PR and between 960920c and f1116b7.

📒 Files selected for processing (14)
  • .github/workflows/visual-tests.yml
  • e2e/routes/app/novelty-card-variations.spec.ts
  • e2e/routes/app/novelty-grid-visual.spec.ts
  • playwright.config.ts
  • src/components/inventory/StockDashboard.tsx
  • src/components/inventory/VariantStockTable.tsx
  • src/components/loading/ModernSkeletons.tsx
  • src/components/novelties/NoveltyCards.tsx
  • src/components/novelties/NoveltyProductGrid.tsx
  • src/components/products/PriceFreshnessBadge.tsx
  • src/hooks/products/useVariantStock.ts
  • src/hooks/stock/stockFetcher.ts
  • src/lib/external-db/rpc-native.ts
  • tests/e2e/stock-regression.spec.ts

Walkthrough

PR expande a resiliência da dashboard de estoque com tratamento de erro e carregamento explícito, implementa paginação na grade de novidades com navegação por teclado, adiciona cobertura E2E com sharding de CI, e refatora o wrapper RPC com logging estruturado e fallbacks defensivos.

Changes

Stock Dashboard Error Handling & Loading States

Layer / File(s) Summary
useVariantStock error exposure & retry policy
src/hooks/products/useVariantStock.ts
Hook expõe error do useQuery e adiciona retry: 3 com retryDelay de backoff exponencial (máx 10s).
StockDashboard error boundary and retry UI
src/components/inventory/StockDashboard.tsx
Renderização condicional de error Card com mensagem e botão "Tentar novamente" (fetchStockData) quando error está presente.
VariantStockTable loading state with skeleton placeholders
src/components/inventory/VariantStockTable.tsx
Prop isLoading renderiza skeleton rows ao invés de conteúdo; StockDashboard passa isFetching.
ProductCardSkeleton layout stabilization
src/components/loading/ModernSkeletons.tsx
Ajuste de min-height, justify-end, dimensões e separador (border-t) nas seções de título, preço e rodapé.
Stock fetcher HTTP 410 error handling
src/hooks/stock/stockFetcher.ts
Detecção de "410"/"Gone" em fetchPaginatedFromBridge; mensagem contextualizada "serviço de ponte legado desativado" é registrada e erro lançado.

Novelty Grid Pagination & Keyboard Navigation

Layer / File(s) Summary
Pagination state and product slicing
src/components/novelties/NoveltyProductGrid.tsx
Introdução de currentPage e pageSize (20); reset de página ao filtrar/buscar; cálculo de totalPages e paginatedProducts.
Pagination UI and virtualized grid integration
src/components/novelties/NoveltyProductGrid.tsx
VirtualizedNoveltyGrid renderiza paginatedProducts; seção de controles numerados, elipses e anterior/próximo (visível se totalPages > 1).
Keyboard navigation and ARIA attributes
src/components/novelties/NoveltyCards.tsx
NoveltyGridCard adiciona role="article", aria-label, aria-selected, tabIndex=0 e onKeyDown para Enter/Space com handleClick memoizado.

E2E Tests & CI Sharding Configuration

Layer / File(s) Summary
Playwright CI sharding and worker parallelism
.github/workflows/visual-tests.yml, playwright.config.ts
Estratégia matrix com shardIndex (1..2) / shardTotal (2); --shard no comando; artefato indexado por shard; workers: 2 em CI.
Novelty card edge cases E2E test
e2e/routes/app/novelty-card-variations.spec.ts
Mock de /functions/v1/novelties com 3 itens (título longo, base_price 0, image nula); navegação, screenshot e validação de alturas h3/preço.
Novelty grid visual regression and accessibility E2E
e2e/routes/app/novelty-grid-visual.spec.ts
Header rendering, visual grid+scroll, scan a11y Axe, compatibilidade navegador, keyboard tab/foco, skeleton state com delay, paginação 45 itens, card variations.
Stock dashboard regression E2E test
tests/e2e/stock-regression.spec.ts
Validação de /estoque: carregamento, ausência de "Gone"/"410", listagem/vazio, filtros, busca, ordenação, paginação, console logs.

RPC Client & External DB Wrapper Improvements

Layer / File(s) Summary
RPC client types and error logging
src/lib/external-db/rpc-native.ts
Tipo RpcClient multi-linha; callRpc expande logging com error.message/error.code; CustomizationPriceParams com anotações.
Customization price enrichment with query builder
src/lib/external-db/rpc-native.ts
enrichCustomizationPrice reescrita: tipagem local, query encadeada em tabela_preco_gravacao_oficial, mapeamento granular; erro não-fatal.
RPC public endpoints with fallback safety
src/lib/external-db/rpc-native.ts
getProductCustomizationOptions, getCategoryDescendants com payloads multi-linha; stubs getProductPrintAreas, linkProductPrintAreas, backfillProductPrintAreas com retornos seguros e warnings NOT_IN_DB.
RPC dispatch table and error handling
src/lib/external-db/rpc-native.ts
RPC_DISPATCH retorna valores seguros para RPCs "NOT_IN_DB"; dispatchRpc lança erro com lista de chaves permitidas quando rpcName não existe.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

codex

✨ 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 claude/exciting-wright-xA6by

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

claude added 3 commits May 31, 2026 20:30
Implements all features from Lovable PRs #547-#552 on a clean base,
fixing three critical bugs before merge:

BUGS FIXED
- Rules of Hooks violation in VariantStockTable: Lovable placed early
  return BEFORE remaining hook calls; moved isLoading guard after all
  hooks to comply with React invariant.
- Pagination rendered inside AnimatePresence overlay (isFetching branch
  only): the pagination block was trapped inside the refetch motion.div,
  making it invisible during normal browsing. Moved outside the relative
  container entirely.
- Ellipsis logic replaced navigable page buttons: Lovable used
  `page === 2 || page === totalPages - 1` which collapsed pages 2 and
  penultimate into ellipsis unconditionally. Fixed to use
  `page === currentPage ± 2` as boundary.

FEATURES
- NoveltyProductGrid: client-side pagination (20 items/page), page
  reset on filter/sort change, hides paginator when ≤1 page.
- NoveltyCards: ARIA attributes (role, aria-label, aria-selected,
  tabIndex, onKeyDown) + useCallback for handler stability.
- VariantStockTable: inline loading skeleton (isLoading prop) with
  animate-pulse rows; prop forwarded from StockDashboard.
- StockDashboard: error UI with AlertCircle + retry button surfaced
  from useVariantStock; passes isFetching → isLoading to table.
- useVariantStock: exposes `error`; adds retry×3 with exponential
  backoff (1s→2s→4s capped at 10s).
- stockFetcher: throws instead of silently breaking on Supabase error;
  detects 410/Gone and emits Portuguese user-facing message.
- ModernSkeletons: increased title min-height and added price-area
  skeleton with min-h-[3.25rem] to match card layout.
- CI: parallel Playwright shards (2×) in visual-tests.yml; workers=2
  in playwright.config.ts.
- E2E: novelty-grid-visual.spec.ts expanded to 4 viewports × 5 tests
  + 3 global tests; novelty-card-variations.spec.ts (new); stock
  regression spec in tests/e2e/.

SKIPPED (already applied in Phase 1/2)
- rest-native.ts additions (variant_supplier_sources, supplier_branches,
  categories) were committed in the Phase 1 kill-switch and Phase 2
  ghost-aliases sessions.

https://claude.ai/code/session_015DVTnofjTd3PtzU2kGvYtV
PriceFreshnessBadge.tsx: formatExactDateTime → _formatExactDateTime
rpc-native.ts: NOT_IN_DB → _NOT_IN_DB (superseded by inline stubs)

https://claude.ai/code/session_015DVTnofjTd3PtzU2kGvYtV
…ssBadge

Function was never called; removing avoids both unused-vars and naming-convention violations.

https://claude.ai/code/session_015DVTnofjTd3PtzU2kGvYtV
@adm01-debug adm01-debug force-pushed the claude/exciting-wright-xA6by branch from 6983f98 to f1116b7 Compare May 31, 2026 20:40
@adm01-debug adm01-debug marked this pull request as ready for review May 31, 2026 20:41
Copilot AI review requested due to automatic review settings May 31, 2026 20:41
@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.

@adm01-debug adm01-debug merged commit df1f4ae into main May 31, 2026
25 of 34 checks passed
@adm01-debug adm01-debug deleted the claude/exciting-wright-xA6by branch May 31, 2026 20:41
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

3 participants