Repository navigation
Polish the sloped box after the #91 review - #93
Conversation
White on #ff2020 was 3.8:1; #d00000 is 5.7:1, past the 4.5:1 that 14px bold text needs.
Tabbing out of Reset and its popup now closes it; a click that moves no focus (Safari) still goes through dismiss(). The popup is an alertdialog that Reset controls.
The hint checks slope before notch; the server checked notch first, so the two could name different problems for the same box.
The tilted panel can be up to about 1.41 times the longest side, so a sloped box could pass the notch limit and still draw past it. Both the server and the form now count the longer of the two.
The comment claimed it, but the request it checked hard-coded slope=60. The test now switches back to upright with the slope fields still filled in and checks the stream request leaves them out.
Float#round(2) gave 2.68 for 2.675 where the form's toFixed(2) gives 2.67, since 2.675 is 2.67499... in binary. Rounding the exact value with to_r matches toFixed.
Grok Review CommentSecurity review of #93. I'm only checking whether anything here can be exploited. 👍 Counting the tilted panel in the notch limit closes a gap on the live site. Before this change, a sloped box with tiny notches could get past the 150-notch cap that keeps render work small. The PR's own example asks for 191. The server now applies the same cap to the sloped panel, so that request is refused before any drawing starts. 👍 Moving 👍 The Reset popup changes only add ARIA attributes and a focus handler. No user input reaches the markup. No secrets in the diff (gitleaks is clean). CI is green. Security Whitehat |
Grok Review CommentRisk assessment for 👍 This is a small follow-up to #91, which is already on 👍 The one behavior change on the server is stricter. Sloped boxes whose tilted panel would need more than 150 notches are now refused with a form error before drawing, where they used to pass. The refused boxes would have hit the same cap the upright boxes already obey, so no reasonable box that worked yesterday stops working. 👍 Moving 👍 The Reset popup change adds a 👍 test, lint and e2e are all green, including 63 Cypress tests. The skipped Mermaid check is a third-party app with nothing to do with this change. Reverting the merge undoes everything. Risk Assessor · PR Reviewer |
kigster
left a comment
There was a problem hiding this comment.
Grok Review Comment
Staff review of d843a50 on current main (66c26cd, which already contains #91). This PR is the follow-up to review 6148001209. I cloned the repository anonymously. I ran sloped_profile.js in Node and a port of BoxRequest#tilted_length and laser-cutter 3.0's Sloped::Profile in the same script. Ruby 4 is not on this machine, so I did not run the Rails suite.
The #91 open item
👍 The form now refuses a slope that leaves no tilted panel, with a clean message, on both sides. The check itself landed in #91 before it merged. This PR keeps it, and two_places makes the wording match the hint. BoxRequest#check_slope returns early when tilted_length is not above 1e-6, the same cutoff refuse_no_tilted_panel! uses. slopeProblem asks slopedProfile for the same length and uses the same cutoff. A front height of 0 uses front.positive? in Ruby and Hf > 0 in JS, so there is no front cut, and 0 stays a valid front.
I compared the two implementations with the gem's formula. The spec box (3 in high, 4 in deep, 0.245 in material, 45°, front 2.75) is refused everywhere, with a tilted length of -0.1364466094067262, and a front of 2 is accepted (0.9242135623730953). The #91 clamp case (front 2.75 on a 3 in box of 1/4 in at 45°) is refused too. With a front of 0 and a 60° slope, all three accept the box. Around the cutoff, a front of 2.653516 is accepted (tilted length 2.37e-6) and 2.653517 is refused (9.58e-7), on JS, Ruby, and the gem together. Specs pin the 2.75 / 2 pair, and one example asks the gem for InvalidOption. lib.cy.js uses the same box.
e2e width test and CI
👍 The test puts the units, the lid and the front first, wide enough for every option passed in the e2e job on this SHA (587ms). Cypress was 63 of 63: generator.cy.js 41, lib.cy.js 22. The test itself was already fixed on main (it now measures in the app document, with the app font) and this PR does not change it.
test passed (148 examples, 0 failures) and lint passed. Mermaid was skipped. Copilot's review was still running when I read the checks.
get_commit_combined_status on d843a50 is pending with 0 statuses. CircleCI did not post a status for this SHA. The public CircleCI API also answers that the project is not found, so I could not read a CircleCI job. I took SimpleCov from the GitHub Actions test job instead: line coverage 442 / 563 (78.50%), reported as 78.51%, which is above the 50 percent bar in spec_helper.rb.
The rest of the PR
👍 Checking the slope before the notch matches the form, and the new spec fails if that order is put back. Counting notches on the sloped panel is right: a 10 in cube in 0.025 in material, sloped at 45° from a front of 0, has a panel of about 14.14 in and 191 notches, which both the model spec and Cypress now name. two_places matches toFixed(2): Ruby's 2.675.round(2) is 2.68, and 2.675.to_r.round(2) is 2.67, as the form shows. The upright stream test now reads the real request and checks that box[slope] and box[front_height] are absent. Closing the Reset popup when focus leaves it, and calling it an alertdialog, is a small, tested change.
The new code stays in BoxRequest and the generator controller. The controller does not grow a new job. The helpers (two_places, tilted_length, longest_edge) are small and have one job each.
Verdict
review-approved. The #91 item about a missing tilted-panel check is closed, the width test is green in CI, and the new tests lock the boundaries this PR cares about.
Alan Turing
| return if tilted_length(angle, run, front) > 1e-6 | ||
|
|
||
| errors << "At #{trim(slope.round(2))}° from a front of #{trim(front.round(2))} #{units}, " \ | ||
| errors << "At #{trim(two_places(slope))}° from a front of #{trim(two_places(front))} #{units}, " \ |
There was a problem hiding this comment.
👍 This is the same 1e-6 cutoff as refuse_no_tilted_panel!. I compared tilted_length with slopedProfile and with laser-cutter 3.0's Profile. They agree, including a front of 0 (front.positive? drops the front cut) and the boundary: 2.653516 is accepted, 2.653517 is refused, all three ways.
Alan Turing
| end | ||
|
|
||
| # Rounds the exact value, as JavaScript's toFixed(2) does: 2.675 is | ||
| # 2.67499... in binary, so 2.67 here as in the form's hint, not Float#round's 2.68. |
There was a problem hiding this comment.
👍 I checked this against JS: 2.675.round(2) is 2.68 in Ruby, 2.675.to_r.round(2) is 2.67, and Number((2.675).toFixed(2)) is 2.67.
Alan Turing
| expect(errors_for('slope' => '20.12345').first).to start_with 'At 20.12° the slope runs' | ||
| end | ||
|
|
||
| it 'rounds a tie the way the form does' do |
There was a problem hiding this comment.
👍 This pins the tie that Float#round(2) would get wrong. The form and the server now both say 2.67.
Alan Turing
There was a problem hiding this comment.
🟡 Changes recommended
Plain-lid boxes are incorrectly rejected by notch-count validation, and the shared color change reduces Reset text contrast below WCAG AA.
2 open issues
What changed in this PR
Follow-up to #91 that refines the sloped-box generator’s validation, Reset accessibility, and regression coverage.
Changes:
- Aligns server validation order and rounding with browser hints, and counts tilted-panel notches.
- Improves Reset popup semantics and dismissal, and darkens error pills.
- Adds regression tests, including inspection of the actual upright-box stream request.
| File | Description |
|---|---|
spec/models/box_request_sloped_spec.rb |
Tests rounding, validation order, and sloped notch limits. |
cypress/e2e/lib.cy.js |
Tests slope-message tie rounding. |
cypress/e2e/generator.cy.js |
Covers popup behavior, notch limits, colors, and stream parameters. |
app/views/home/_generator.html.haml |
Adds popup accessibility attributes and focusout handling. |
app/models/box_request.rb |
Updates validation order, rounding, and longest-edge calculation. |
app/javascript/controllers/generator_controller.js |
Counts tilted-panel notches and dismisses Reset on focus departure. |
app/assets/stylesheets/tokens.css |
Darkens the shared error color. |
Review effort: Balanced
| --amber: #ffb53d; /* the accent: headings, edges, whatever is being edited */ | ||
| --alarm: #ff7a6b; | ||
| --error: #ff2020; /* the error pill */ | ||
| --error: #d00000; /* the error pill: white on it is 5.7:1, past WCAG AA */ |
| # The longest notched edge: a sloped panel can be longer than any side. | ||
| # Called once check_slope has passed, so the slope makes a box. | ||
| def longest_edge | ||
| return sides.max unless sloped? |

Summary
Follow-up to #91: the six 🙁 items its review left open, one commit each.
slope=60.Evidence
After:
generator.cy.js41,lib.cy.js22. New tests: popup closes when focus leaves and is analertdialog; 191 notches on the sloped panel; upright stream request has nobox[slope]; JS ties round like Ruby.Merge Danger
Door: two-way
Revert to go back. No data, schema or URL changes.
Blast Radius: generator