fix(web): orthogonal float epsilon — flat edges no longer dive past target#100
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR addresses floating-point precision issues in orthogonal route layout by introducing an epsilon-based tolerance check. A new ChangesSub-pixel Epsilon Tolerance for Orthogonal Routes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/web/__tests__/flow-layout.test.ts`:
- Around line 288-324: The test currently calls inferPortAssignmentsFromRoutes
with a 2-point straight route which already biases horizontal dominance and
won't reproduce the pre-fix failure; update the test to run the route through
the orthogonalization step that used to insert the phantom corner (e.g., call
shiftRoutesAfterSnap or orthogonalizeRoutes on the noisyRoute for the
topology/displayEdges before calling inferPortAssignmentsFromRoutes) so the tiny
dy drift can create the intermediate corner and the regression is exercised;
locate the test's topology, edge (topology.displayEdges[0]), noisyRoute, and
replace the direct call to inferPortAssignmentsFromRoutes with the sequence that
orthogonalizes the route first and then infers port assignments.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 352aa593-c66d-4812-84a9-3904099ab069
📒 Files selected for processing (2)
packages/web/__tests__/flow-layout.test.tspackages/web/src/lib/flow-layout.ts
…hantom port After shiftRoutesAfterSnap, two route endpoints that should share a y coordinate can drift by ~1 ULP (~3e-15) due to float arithmetic. orthogonalizeRoutePoints used strict \!== for axis comparison, treated the segment as diagonal, and inserted a phantom vertical corner. inferPortAssignmentsFromRoutes then saw a tiny non-zero dy at the end and ran targetHandleFromSegment(0, -3e-15) → 'bottom' instead of the true 'left' entry. The road then dove past the target node into empty space (visible on claude-router → mongodb in the orion-main flow at flow/eIxRYAM39kwT). Tighten the orthogonality test with a 0.5px epsilon — anything below that is treated as already axis-aligned, so float noise no longer creates phantom corners or wrong port assignments. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
eb62f50 to
cb9296f
Compare
Summary
Reproduced on the orion-main flow at `/flow/eIxRYAM39kwT`: the `claude-router → mongodb` road entered the database from the top instead of the left, then dove out into empty space (the user-visible "dead end").
Root cause is sub-pixel float drift after `shiftRoutesAfterSnap`: two endpoints that should share `y` differed by ~1 ULP (3e-15). `orthogonalizeRoutePoints` used strict `!==`, declared the segment diagonal, and inserted a phantom vertical corner. `inferPortAssignmentsFromRoutes` then ran `targetHandleFromSegment(0, -3e-15)` and picked `bottom` (because `|dx|=0` is not `≥ |dy|=3e-15`), so `extendRouteToNodeCenters` shifted the endpoint upward away from the node — that's the dead-end.
Fix: 0.5px epsilon on the axis-equality test. Below that we treat the segment as already orthogonal, so float noise can't fabricate a corner.
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit