Skip to content

refactor(core): remove dead percent guard paths from stack layout#248

Merged
RtlZeroMemory merged 1 commit intomainfrom
refactor/remove-percent-guard-deadpaths
Mar 5, 2026
Merged

refactor(core): remove dead percent guard paths from stack layout#248
RtlZeroMemory merged 1 commit intomainfrom
refactor/remove-percent-guard-deadpaths

Conversation

@RtlZeroMemory
Copy link
Owner

@RtlZeroMemory RtlZeroMemory commented Mar 5, 2026

Summary

  • remove childHasPercentInMainAxis / childHasPercentInCrossAxis from layout guards
  • remove corresponding dead callsites in stack measure/layout passes
  • simplify stack auto-size finalize logic by dropping never-true percent fill branches

Why

  • percentage strings are intentionally rejected in current API (expr(...) is the replacement)
  • percent guard helpers were hardcoded false, so these branches were dead code
  • this reduces cognitive overhead without changing runtime behavior

Behavior

  • % strings remain rejected (unchanged)
  • flex/advanced constraint passes remain intact

Tests

  • npx tsx --test packages/core/src/layout/__tests__/layout.percentage.test.ts
  • npx tsx --test packages/core/src/layout/__tests__/layout.auto-sizing.test.ts
  • npx tsx --test packages/core/src/layout/__tests__/layout.edgecases.test.ts
  • node scripts/run-tests.mjs --filter "layout\.(percentage|auto-sizing|edgecases)"

Summary by CodeRabbit

  • Refactor
    • Simplified layout constraint logic by removing percentage-based sizing calculations from the layout engine.
    • Streamlined sizing computations by removing percent-driven constraint planning.

@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 19301eca-65a9-4f74-b351-c84a438be897

📥 Commits

Reviewing files that changed from the base of the PR and between 089115b and 5973e9b.

📒 Files selected for processing (2)
  • packages/core/src/layout/engine/guards.ts
  • packages/core/src/layout/kinds/stack.ts
💤 Files with no reviewable changes (1)
  • packages/core/src/layout/engine/guards.ts

📝 Walkthrough

Walkthrough

The changes remove percentage-based sizing detection from the layout engine. Two exported functions (childHasPercentInMainAxis and childHasPercentInCrossAxis) are deleted from guards.ts, and their usage is eliminated from stack.ts, simplifying constraint planning and final size computation in stack layout logic.

Changes

Cohort / File(s) Summary
Percentage-Based Sizing Removal
packages/core/src/layout/engine/guards.ts, packages/core/src/layout/kinds/stack.ts
Removed two public functions that detected percentage-based sizing hints in main and cross axes. Eliminated percent-based constraint consideration in both measureStack and layoutStack paths, including removal of hasPercentInMainAxis, fillMain, and fillCross computations. Simplified size calculations to derive from forced values and bounds constraints only.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Away with percentages, constraints now clear!
No more percent-math cluttering here,
Stack layouts dance with simplified grace,
Flex and forced values claim their rightful place. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing dead percent guard paths from stack layout code, which aligns with the actual deletions in guards.ts and simplifications in stack.ts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/remove-percent-guard-deadpaths

Comment @coderabbitai help to get the list of available commands and usage tips.

@RtlZeroMemory RtlZeroMemory merged commit 790f01f into main Mar 5, 2026
29 checks passed
@RtlZeroMemory RtlZeroMemory deleted the refactor/remove-percent-guard-deadpaths branch March 5, 2026 14:09
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.

1 participant