Skip to content

Expose PCB viewer view toggles as props for runframe#678

Open
rushabhcodes wants to merge 6 commits intotscircuit:mainfrom
rushabhcodes:expose-view-toggle
Open

Expose PCB viewer view toggles as props for runframe#678
rushabhcodes wants to merge 6 commits intotscircuit:mainfrom
rushabhcodes:expose-view-toggle

Conversation

@rushabhcodes
Copy link
Copy Markdown
Contributor

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:

  • Added new boolean props to PCBViewer for toggling visibility of rats nest, multiple traces length, autorouting, DRC errors, copper pours, PCB groups, group anchor offsets, and solder mask. [1] [2]
  • Updated PCBViewer's initial state merging logic to support the new view settings, ensuring their values are correctly initialized and tracked.
  • Passed the new props through to ContextProviders, so that the context can react to changes in the view settings.

Context provider enhancements:

  • Modified ContextProviders to accept the new props and use useEffect hooks to update the global store state when any of the view settings change, ensuring the PCB viewer responds dynamically.

Fixture and testing:

  • Added a new fixture example, 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

image

Copilot AI review requested due to automatic review settings February 22, 2026 10:24
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 22, 2026

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

Project Deployment Actions Updated (UTC)
pcb-viewer Ready Ready Preview, Comment Feb 23, 2026 9:20am

Request Review

Copy link
Copy Markdown

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

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 PCBViewer to 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 ViewSettingsToggle fixture 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.

Copy link
Copy Markdown
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Messy. Why is this not part of initialState? Looks like someone else messed up this pattern

Copy link
Copy Markdown
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the right pattern

@seveibar
Copy link
Copy Markdown
Contributor

Why would you introduce overrides? Just set the initial state no?

@rushabhcodes
Copy link
Copy Markdown
Contributor Author

i am such a dummy 🥹

Copy link
Copy Markdown
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seveibar Wouldn't this cause the store to re-render again and again?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so how should i implement this, i am confused now

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...}} />

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.

4 participants