Expose PCB viewer view toggles as props for runframe#678
Expose PCB viewer view toggles as props for runframe#678rushabhcodes wants to merge 6 commits intotscircuit:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds prop-driven view setting toggles to PCBViewer so runframe (and fixtures) can control visibility of several PCB features at runtime, with plumbing through the viewer’s context/store.
Changes:
- Added new optional boolean props to
PCBViewerto control visibility of rats nest, traces length, autorouting, DRC errors, copper pours, PCB groups, group anchor offsets, and solder mask. - Propagated these settings through
ContextProviders, updating the global store when props change. - Added a
ViewSettingsTogglefixture with checkbox controls demonstrating the new props.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/PCBViewer.tsx | Introduces new view-toggle props and merges them into initial state before wiring into providers. |
| src/components/ContextProviders.tsx | Accepts new props and syncs them into the zustand store via useEffect. |
| src/examples/2026/view-settings-toggle.fixture.tsx | New fixture showcasing runtime toggling of all new view settings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
seveibar
left a comment
There was a problem hiding this comment.
Messy. Why is this not part of initialState? Looks like someone else messed up this pattern
|
Why would you introduce overrides? Just set the initial state no? |
…handling in ContextProviders
|
i am such a dummy 🥹 |
seveibar
left a comment
There was a problem hiding this comment.
antipattern, you should avoid useEffect and it can never be a dep
…he store with new initial values when props change 2. Removed the anti-pattern useEffect that was trying to sync state after mount
| const store = useMemo( | ||
| () => createStore(initialState, disablePcbGroups), | ||
| [disablePcbGroups], | ||
| [initialState, disablePcbGroups], |
There was a problem hiding this comment.
@seveibar Wouldn't this cause the store to re-render again and again?
There was a problem hiding this comment.
so how should i implement this, i am confused now
There was a problem hiding this comment.
I am not sure what this feature is mean't to do or what should be done exactly. I am just trying to confirm with Seve that, will this cause re-rending when you pass an inline object to the <PcbViewer initialState={{ something...}} />
This pull request adds new view settings to the PCB viewer component, allowing users to toggle visibility for several PCB features such as rats nest, multiple traces length, autorouting, DRC errors, copper pours, PCB groups, group anchor offsets, and solder mask. The changes introduce new props to
PCBViewer, propagate them through context providers, and provide a fixture example with UI controls for easy testing.New PCB view settings and toggles:
PCBViewerfor toggling visibility ofrats nest,multiple traces length,autorouting,DRC errors,copper pours,PCB groups,group anchor offsets, andsolder mask. [1] [2]PCBViewer's initial state merging logic to support the new view settings, ensuring their values are correctly initialized and tracked.ContextProviders, so that the context can react to changes in the view settings.Context provider enhancements:
ContextProvidersto accept the new props and useuseEffecthooks to update the global store state when any of the view settings change, ensuring the PCB viewer responds dynamically.Fixture and testing:
ViewSettingsToggle, which demonstrates all the new view toggles with checkboxes and a sample circuit, making it easy to test the new functionality.Provide a fixture that showcases runtime toggling of the new view settings to exercise the props from runframe in future
https://discord.com/channels/1233487248129921135/1473936938145681460