Skip to content

feat(viewer): generate circuitJsonKey from per-element bounds and refactor into util #356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

abimaelmartell
Copy link
Member

@abimaelmartell abimaelmartell commented Aug 19, 2025

Summary

This PR refactors how the circuitJsonKey is computed in PCBViewer.
Instead of relying on the array length and editCount, we now generate a stable, content-based key using a new utility: calculateCircuitJsonKey.

Changes

  • Added lib/calculate-circuit-json-key.ts:
    • Computes a signature for all pcb_ elements in the circuit JSON.
    • Uses bounding box values (rounded to 4 decimal places) and element IDs.
    • Produces a deterministic hash to ensure keys change only when PCB content meaningfully changes.
  • Updated PCBViewer.tsx:
    • Replaced inline circuitJsonKey calculation with useMemo(calculateCircuitJsonKey).
    • Ensures memoization only recomputes when circuitJson changes.

Copy link

vercel bot commented Aug 19, 2025

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

Project Deployment Preview Comments Updated (UTC)
pcb-viewer Ready Ready Preview Comment Aug 19, 2025 11:17pm

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