Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selection dry-run validation for Shell #4775

Conversation

pierremtb
Copy link
Collaborator

@pierremtb pierremtb commented Dec 12, 2024

Fixes #4711. Adds playwright test too for the failure case.

Copy link

qa-wolf bot commented Dec 12, 2024

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Jan 16, 2025 6:55pm

@pierremtb pierremtb changed the title WIP: shell and loft dry run validation Add dry-run validation to Loft and Shell Dec 13, 2024
@pierremtb pierremtb marked this pull request as ready for review January 16, 2025 15:47

const shellCommand = async () => {
// TODO: figure out something better than an arbitrarily small value
const DEFAULT_THICKNESS: Models['LengthUnit_type'] = 1e-9
Copy link
Contributor

Choose a reason for hiding this comment

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

Ooof, yeah that's a tough one. I would have done this as a scale of the volume of the model's bounding box as a 1st attempt, but we don't have that information easily accessible.

.find((v) => v.type === 'sweep')?.pathId

if (!object_id) {
return "Unable to shell, couldn't find the solid"
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't want to return Promise.reject?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, the arg configuration for validation takes a function that looks like

async function validator ({context, data})  : string | boolean {} 

If you return true passes validation
If you return false fails validation but you don't get an error message
If you return string it fails validation but you get to see that message within the failure case.

This function is implemented correctly

Copy link
Collaborator

Choose a reason for hiding this comment

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

Here is the usage of the validator function

Copy link
Collaborator

Choose a reason for hiding this comment

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

Now that I think of this I could have probably have thrown a new Error object with a string instead of saying "success" and returning a string with an error message...

It really isn't any error in the sense of the JS code.. I just need to know if an operation failed or passed then why it failed or passed.

The JS code is just proxying the engine result.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup, thanks for the added context @nadr0!

Copy link
Contributor

Choose a reason for hiding this comment

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

Right I was suggesting changing the type x) All good

@nadr0
Copy link
Collaborator

nadr0 commented Jan 16, 2025

Do we need this submodule commit?

Submodule kcl-samples added at 76d4a2

@pierremtb
Copy link
Collaborator Author

@nadr0 I was just looking at this on another branch. I have no idea what this is sorry, good catch!

@pierremtb
Copy link
Collaborator Author

@nadr0 should be gone now

Copy link
Collaborator

@nadr0 nadr0 left a comment

Choose a reason for hiding this comment

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

Addressing some comments.

.find((v) => v.type === 'sweep')?.pathId

if (!object_id) {
return "Unable to shell, couldn't find the solid"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here is the usage of the validator function

src/lib/commandBarConfigs/validators.ts Show resolved Hide resolved
.find((v) => v.type === 'sweep')?.pathId

if (!object_id) {
return "Unable to shell, couldn't find the solid"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now that I think of this I could have probably have thrown a new Error object with a string instead of saying "success" and returning a string with an error message...

It really isn't any error in the sense of the JS code.. I just need to know if an operation failed or passed then why it failed or passed.

The JS code is just proxying the engine result.

src/lib/commandBarConfigs/validators.ts Show resolved Hide resolved
@nadr0
Copy link
Collaborator

nadr0 commented Jan 16, 2025

I have been manually testing this to trigger the validation. I found an awesome shell result

# main.kcl
sketch001 = startSketchOn('XZ')
  |> startProfileAt([-0.12, -0.07], %)
  |> line([-0.04, 0.2], %, $seg02)
  |> line([0.32, 0.03], %, $seg01)
  |> yLine(-0.26, %)
  |> line([-0.14, -0.02], %)
  |> lineTo([profileStartX(%), profileStartY(%)], %)
  |> close(%)
extrude001 = extrude(5, sketch001)

image
Select this face and do the shell and you can see the result.

image

Copy link
Collaborator

@nadr0 nadr0 left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the comments, looks good.

@pierremtb pierremtb merged commit 0592d3b into main Jan 17, 2025
30 of 31 checks passed
@pierremtb pierremtb deleted the pierremtb/issue4711-Improve-shell-selection-guards-for-circular-shapes branch January 17, 2025 15:16
@pierremtb pierremtb linked an issue Jan 17, 2025 that may be closed by this pull request
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.

Click UI - Shell doesn't work on a revolved surface Add dry-run validation to Loft and Shell
4 participants