← Back to Pull requests

feat(kit-builder): backup completo no beforeunload + restore real (FT-119) #3367

Open
unknown opened this pull request with 204 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 09, 2026 20:49 UTC
Author

O que muda

Restauração automática de estado completo do Kit Maker após fechamento acidental da aba.

Antes: backup salvo no beforeunload continha apenas kitId + snapshot (string). Ao reabrir, o usuário via apenas um toast pedindo para navegar de volta ao kit — sem restaurar o estado local que ainda não tinha sido salvo no banco.

Depois: o backup também inclui fullState (caixa, itens, personalização, identidade, notas, quantidade). Na próxima visita:

  • Mesmo kit (ou kit novo não salvo): estado restaurado automaticamente, toast informativo.

  • Kit diferente carregado: toast com botão "Restaurar edições" para o usuário decidir.

  • Backup legado sem fullState: comportamento anterior (navegar ao kit pelo banco).
  • Arquivos tocados

    | Arquivo | Mudança |
    |---|---|
    | src/hooks/kit-builder/useKitAutoSave.ts | Exporta BackupFullState; salva fullState no beforeunload; retorna fullState no consumeUnloadBackup |
    | src/hooks/kit-builder/useKitBuilderPageState.ts | Adiciona restoreFromBackup + expõe consumeUnloadBackup nos actions |
    | src/pages/kit-builder/KitBuilderPage.tsx | checkedBackupRef + useEffect de restore após hidratação; importa useRef e toast |

    Verificação

  • Branch criada a partir de e70479b (main HEAD) — zero divergência de histórico

  • Apenas 3 arquivos src/ — nenhum arquivo de governance, migration ou workflow

  • Substitui PR #3305 (fechada) que tinha mergeable_state: dirty por divergência em commits de docs antigos
  • 🤖 Generated with Claude Code

    https://claude.ai/code/session_01VXkRxafXhqqt3j3oxCDguY

    Diff: 204 lines (+153 / -51) across 2 files Reviewer: adm01-debug Review duration: 583m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 204 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.318
    Real PR Conversation Timeline
    1 comments
    "Review active on #3367"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.3% (MEDIUM) · Higher = larger blast radius
    36.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.4% · Safe to merge
    19.4%