Skip to content

Comments

#5783 Only show axis planes when there are no errors#5799

Merged
pierremtb merged 49 commits intomainfrom
andrewvarga/5783/errors-can-cause-default-planes-to-show
Mar 21, 2025
Merged

#5783 Only show axis planes when there are no errors#5799
pierremtb merged 49 commits intomainfrom
andrewvarga/5783/errors-can-cause-default-planes-to-show

Conversation

@andrewvarga
Copy link
Contributor

@andrewvarga andrewvarga commented Mar 13, 2025

As described in #5783 we were showing the axis planes when the artifactGraph was empty, which also happened when there were errors on the current kcl content. Added a guard to only show planes when there are no errors.

There was one weird thing I found that I'm commenting on inline.

I'm looking into how testing works, it's a small fix but maybe worth adding a test to cover it.

I wonder if the failed tests are unrelated? Seems other PRs are failing with similar cases.

@qa-wolf
Copy link

qa-wolf bot commented Mar 13, 2025

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!

@vercel
Copy link

vercel bot commented Mar 13, 2025

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

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Mar 21, 2025 8:49am

'Has exportable geometry': () => false,
'has valid selection for deletion': () => false,
'no kcl errors': () => {
// Note: kclManager.hasErrors() seems always false!
Copy link
Contributor Author

Choose a reason for hiding this comment

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

kclManager.hasErrors() seemed to return with false here even if kclManager.errors had the kcl errors in it..
If that's a bug we could refactor hasErrors to return errors.lenght > 0 or if these refer to different things it could be worth making their names clearer.

Copy link
Contributor

Choose a reason for hiding this comment

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

that's gotta be a bug in hasErrors so I'm happy to see a fix there too.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could just make hasErrors be a getter that does return !!this.errors.length that way there can't be a bug?

Copy link
Contributor Author

@andrewvarga andrewvarga Mar 14, 2025

Choose a reason for hiding this comment

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

@Irev-Dev Yes I was thinking of doing exactly that, I looked at it again today and I want to make sure I'm not causing regressions by removing _hasErrors.

So in executeCode it seems safeParse() is invoked first, which sets _hasErrors to true if the AST parse failed. If the parse is successful then _hasErrors may still be set to true if the parse result has errors.

After this executeAst() is only called if the parsing is successful and has no errors.
If the parsing is successful and there are no errors then executeAst() is called which can have a new set of errors that the errors array is set to.
executeAst() may also be called individually without safeParse()

So there are multiple levels of errors:

  • _hasErrors, which is set to true if parsing fails or there is a parsing result but it has errors
  • _errors which is set from AST execution errors but is not updated when parsing has errors
  • to add a bit of confusion I found that some execution errors can be considered parse errors as per this line:
const parseErrors = kclManager.errors.filter((e) => e.kind !== 'engine')

It's a bit unclear to me what is exactly the difference between the parse result errors in safeParse and the AST execution errors, I would love to learn more about that.

Regardless, it seems possible to me that the errors array is empty but _hasErrors is true.

With that in mind what I would do is:

  • rename _hasErrors to something like _parseFailed
  • rename errors to executionErrors (or keep it errors but at least the flag should be renamed to avoid confusion I think)
  • hasErrors() would be implemented like: this.parseFailed || this._executionErrors.length > 0

@franknoirot @nrc I see you worked on these parts previously, just want to make sure I'm not going in a wrong direction.

Copy link
Contributor

Choose a reason for hiding this comment

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

So, for parsing and execution there are both fatal errors which immediately halt interpretation and are returned as the result of parsing or execution and there are non fatal errors (both errors and warnings) which do not cause an immediate halt (but except for warnings do halt proceeding to the next stage of interpretation). I think these are somewhat combined by the time the frontend sees them, but I don't recall exactly. There should really be no difference between a parsing and execution error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nrc thanks, so it sounds like it's probably a good idea treat all of these similarly so hasErrors() returns true if there was either a parsing or an execution error, there shouldn't really be a difference in how they are handled in the frontend.

@codecov
Copy link

codecov bot commented Mar 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.77%. Comparing base (06b35b7) to head (72631a4).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5799   +/-   ##
=======================================
  Coverage   85.77%   85.77%           
=======================================
  Files         113      113           
  Lines       44025    44025           
=======================================
  Hits        37762    37762           
  Misses       6263     6263           
Flag Coverage Δ
rust 85.77% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@andrewvarga andrewvarga requested a review from a team March 13, 2025 22:46
@andrewvarga andrewvarga changed the title #5783 Only show axis planes when there are no errors WIP: #5783 Only show axis planes when there are no errors Mar 13, 2025
@andrewvarga
Copy link
Contributor Author

Some snapshots have been modified by the github bot, @lee-at-zoo-corp @franknoirot is that something I should look at? They did seem to change visually.

@andrewvarga andrewvarga changed the title WIP: #5783 Only show axis planes when there are no errors #5783 Only show axis planes when there are no errors Mar 18, 2025
@pierremtb
Copy link
Contributor

Thank you @andrewvarga, that worked well here! Hitting merge.

@pierremtb pierremtb merged commit 869126e into main Mar 21, 2025
37 checks passed
@pierremtb pierremtb deleted the andrewvarga/5783/errors-can-cause-default-planes-to-show branch March 21, 2025 10:44
@jessfraz jessfraz mentioned this pull request Mar 24, 2025
1 task
andrewvarga added a commit that referenced this pull request Apr 4, 2025
…s" (#6007)

* first pass at adding test for Only showing axis planes when there are no errors

* fix test Only show axis planes when there are no errors

* PR feedback
modeling-app-github-app bot pushed a commit that referenced this pull request Apr 4, 2025
…e no errors" (#6007)

* first pass at adding test for Only showing axis planes when there are no errors

* fix test Only show axis planes when there are no errors

* PR feedback
modeling-app-github-app bot pushed a commit that referenced this pull request Apr 4, 2025
…e no errors" (#6007)

* first pass at adding test for Only showing axis planes when there are no errors

* fix test Only show axis planes when there are no errors

* PR feedback
modeling-app-github-app bot pushed a commit that referenced this pull request Apr 5, 2025
…e no errors" (#6007)

* first pass at adding test for Only showing axis planes when there are no errors

* fix test Only show axis planes when there are no errors

* PR feedback
modeling-app-github-app bot pushed a commit that referenced this pull request Apr 5, 2025
…e no errors" (#6007)

* first pass at adding test for Only showing axis planes when there are no errors

* fix test Only show axis planes when there are no errors

* PR feedback
modeling-app-github-app bot pushed a commit that referenced this pull request Apr 5, 2025
…e no errors" (#6007)

* first pass at adding test for Only showing axis planes when there are no errors

* fix test Only show axis planes when there are no errors

* PR feedback
modeling-app-github-app bot pushed a commit that referenced this pull request Apr 5, 2025
…e no errors" (#6007)

* first pass at adding test for Only showing axis planes when there are no errors

* fix test Only show axis planes when there are no errors

* PR feedback
modeling-app-github-app bot pushed a commit that referenced this pull request Apr 5, 2025
…e no errors" (#6007)

* first pass at adding test for Only showing axis planes when there are no errors

* fix test Only show axis planes when there are no errors

* PR feedback
modeling-app-github-app bot pushed a commit that referenced this pull request Apr 5, 2025
…e no errors" (#6007)

* first pass at adding test for Only showing axis planes when there are no errors

* fix test Only show axis planes when there are no errors

* PR feedback
modeling-app-github-app bot pushed a commit that referenced this pull request Apr 5, 2025
…e no errors" (#6007)

* first pass at adding test for Only showing axis planes when there are no errors

* fix test Only show axis planes when there are no errors

* PR feedback
modeling-app-github-app bot pushed a commit that referenced this pull request Apr 5, 2025
…e no errors" (#6007)

* first pass at adding test for Only showing axis planes when there are no errors

* fix test Only show axis planes when there are no errors

* PR feedback
modeling-app-github-app bot pushed a commit that referenced this pull request Apr 5, 2025
…e no errors" (#6007)

* first pass at adding test for Only showing axis planes when there are no errors

* fix test Only show axis planes when there are no errors

* PR feedback
modeling-app-github-app bot pushed a commit that referenced this pull request Apr 5, 2025
…e no errors" (#6007)

* first pass at adding test for Only showing axis planes when there are no errors

* fix test Only show axis planes when there are no errors

* PR feedback
modeling-app-github-app bot pushed a commit that referenced this pull request Apr 5, 2025
…e no errors" (#6007)

* first pass at adding test for Only showing axis planes when there are no errors

* fix test Only show axis planes when there are no errors

* PR feedback
jessfraz added a commit that referenced this pull request Apr 5, 2025
* origin/main: (26 commits)
  attempt to import win-ca on windows (#6136)
  Upgrade e2e-tests windows runner from 4 cores to 8 (#6166)
  Follow-up fixes after bearing sample rename (#6164)
  Add test for #5799: "Only showing axis planes when there are no errors" (#6007)
  Wait for export button to make test more reliable (#6143)
  sketching on a mirror2d thats been extruded fixed! (#6149)
  Bump vite from 5.4.16 to 5.4.17 in /packages/codemirror-lang-kcl in the security group (#6150)
  Bump vite from 5.4.16 to 5.4.17 in the security group (#6151)
  Update all KCL-Samples to be more ME friendly (#6132)
  Shorten feedback cycle for legitimate failures (#6146)
  Remove the camera projection toggle from the UI (#6077)
  Use all available CPUs to run tests on CI (#6138)
  [fix] Get rid of risky useEffect in restart onboarding flow (#6133)
  Feature: Traditional menu actions in desktop application part II (#6030)
  [Bug] fix some UI friction from imports (#6139)
  Use scene fixture to make test more reliable on macOS (#6140)
  Fix: function composition during playwright setup created a massive page.reload loop (#6137)
  Alternative way to make appMachine spawned children type safe (#5890)
  [BUG] mutate ast to keep comments for pipe split ast-mod (#6128)
  Rename the app to Zoo Design Studio (#5974)
  ...
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.

5 participants