Skip to content

Conversation

@7908837174
Copy link

@7908837174 7908837174 commented Oct 23, 2025

Overview

This PR implements GitHub issue #1391 by adding support for constraint components between groups in relative layout mode.

Key Features

  • Group-to-group constraints: Support for constraint components between groups
  • Distance constraints: xDist and yDist properties for spacing between groups
  • Center positioning: centerX and centerY properties for alignment
  • Mathematical solver: Integration with Kiwi constraint solver for precise positioning
  • Comprehensive testing: 5 test cases covering various constraint scenarios

Implementation Details

Core Changes

  1. Board.ts: Enhanced with doInitialPcbLayout() override that detects and applies group constraints using the Kiwi solver
  2. applyComponentConstraintClusters.ts: Modified getIdFromSelector() to support both component and group selectors
  3. Test Suite: Added comprehensive tests in tests/features/group-constraints/

Technical Approach

  • Detects constraint components that reference groups (selectors starting with .)
  • Uses Kiwi constraint solver for mathematical constraint resolution
  • Supports both distance constraints (xDist, yDist) and center positioning (centerX, centerY)
  • Maintains backward compatibility with existing component constraints

Fixes #1391

Implements GitHub issue tscircuit#1391 - adds support for constraint components
between groups with xDist, yDist, centerX, and centerY properties.

Key features:
- Group-to-group constraint detection in Board component
- Kiwi solver integration for mathematical constraint solving
- Support for distance and center positioning constraints
- Comprehensive test suite with 5 test cases
- Backward compatibility maintained

Changes:
- Enhanced Board.ts with doInitialPcbLayout override
- Modified applyComponentConstraintClusters.ts for group selector support
- Added comprehensive test suite in tests/features/group-constraints/
- Added documentation in GROUP_CONSTRAINTS_README.md

Fixes tscircuit#1391
@vercel
Copy link

vercel bot commented Oct 23, 2025

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

Project Deployment Preview Comments Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview Comment Oct 23, 2025 4:09am

Comment on lines 454 to 456
return selectors.some(selector => {
if (!selector.startsWith(".")) return false
const name = selector.slice(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a null/undefined check before calling startsWith() to prevent potential runtime errors:

if (!selector || !selector.startsWith(".")) return false

This defensive check ensures the code handles cases where a selector might be undefined or null, which could happen with optional constraint properties.

Suggested change
return selectors.some(selector => {
if (!selector.startsWith(".")) return false
const name = selector.slice(1)
return selectors.some(selector => {
if (!selector || !selector.startsWith(".")) return false
const name = selector.slice(1)

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

- Fix TypeScript type narrowing error in Board.ts filter callback
- Add null check for selector.startsWith() to prevent runtime errors
- Add comprehensive ConstraintProps type extensions for centerX/centerY
- Include all missing constraint properties in type declarations
- Fix formatting issues with Biome formatter

Resolves CI failures in type-check, format, and smoke-test jobs.
@7908837174
Copy link
Author

Hi sir @abimaelmartell , @seveibar , @ricohageman , @imrishabh18 .. ready for 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.

Implement relative-layout-mode <constraint /> between groups

1 participant