Multi-profile sweeps and more robust edit flows in point-and-click#6437
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
QA Wolf here! As you write new code it's important that your test coverage is keeping up. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6437 +/- ##
==========================================
- Coverage 85.36% 85.35% -0.02%
==========================================
Files 107 108 +1
Lines 47219 47355 +136
==========================================
+ Hits 40309 40420 +111
- Misses 6910 6935 +25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…dit-flows-to-non-variable-sweep-declarations
…dit-flows-to-non-variable-sweep-declarations
…dit-flows-to-non-variable-sweep-declarations
…dit-flows-to-non-variable-sweep-declarations
| if (!isSelections(context.argumentsToSubmit.sketches)) { | ||
| return 'Unable to revolve, selections are missing' | ||
| } | ||
| // Gotcha: this validation only works for the first sketch |
There was a problem hiding this comment.
Didn't want to rotate on this any more than what was necessary to not break the existing, since dry run validations aren't really something we're sure have a future atm
| ) { | ||
| return baseCommand | ||
| } | ||
| const prepareToEditExtrude: PrepareToEditCallback = async ({ operation }) => { |
There was a problem hiding this comment.
Cleaned up all three below with an inverse util function to go from the sketches in the operation object to graph selections. Trying to make things as consistent as possible but still allowing for specific needs of each
| } | ||
|
|
||
| const pathToNode = getNodePathFromSourceRange( | ||
| if (!input) return Promise.reject(new Error('No input provided')) |
There was a problem hiding this comment.
And finally modelingMachine.ts, the code mods here are much shorter and follow the same pattern for all four. Including the use of Promise.reject to make sure the errors aren't silent, which is something we haven't been consistent about in the past
- unpack args
- call function from
addSweep - if no error, call
updateModelingState
franknoirot
left a comment
There was a problem hiding this comment.
Wow so much cleanup along with these UX improvements. Big PR forgiven 😄
| await toolbar.extrudeButton.click() | ||
| await cmdBar.expectState({ | ||
| stage: 'arguments', | ||
| commandName: 'Extrude', | ||
| currentArgKey: 'sketches', | ||
| currentArgValue: '', | ||
| headerArguments: { | ||
| Sketches: '', | ||
| Length: '', | ||
| }, | ||
| highlightedHeaderArg: 'sketches', | ||
| }) | ||
| await cmdBar.progressCmdBar() | ||
| await cmdBar.progressCmdBar() | ||
| await cmdBar.expectState({ | ||
| stage: 'review', | ||
| commandName: 'Extrude', | ||
| headerArguments: { | ||
| Sketches: '1 segment', | ||
| Length: '5', | ||
| }, | ||
| }) | ||
| await cmdBar.progressCmdBar() |
| KCL_DEFAULT_CONSTANT_PREFIXES.EXTRUDE | ||
| ) | ||
| const declaration = createVariableDeclaration(name, call) | ||
| modifiedAst.body.push(declaration) |
There was a problem hiding this comment.
Nah do it haha I'm sick of dumb "smart" insertion
| import type { Selections } from '@src/lib/selections' | ||
| import { err } from '@src/lib/trap' | ||
|
|
||
| export function addExtrude({ |
There was a problem hiding this comment.
These seem like they might be good as comments around the code itself as well.
src/lang/modifyAst/addSweep.ts
Outdated
| return sketchesExpr | ||
| } | ||
|
|
||
| function insertVariable( |
There was a problem hiding this comment.
For future reference there is already a very similar function in modifyAst called insertVariableAndOffsetPathToNode. Might be good to flag a TODO to unify since they both look pretty generic?
There was a problem hiding this comment.
Oh good call I remember that now let me look quick
There was a problem hiding this comment.
This works perfectly!
There was a problem hiding this comment.
@Irev-Dev might want eyes on these AST helpers here and in addSweep. I'm trying to get in the right headspace for reviewing them 😅
| // KCL stdlib arguments | ||
| sketches: Selections | ||
| path: Selections | ||
| sectional?: boolean |
| // KCL stdlib arguments | ||
| sketches: Selections | ||
| path: Selections | ||
| sectional?: boolean |
| // })), | ||
| // }, | ||
| distance: { | ||
| length: { |
There was a problem hiding this comment.
I 100% agree this is good though. One of our goals for the UX is for the point-and-click experience to provide a smooth learning curve into KCL and more "power user" things. Making things match across that divide is lowkey important for supporting that
There was a problem hiding this comment.
I really like this cleanup here
…dit-flows-to-non-variable-sweep-declarations
pierremtb
left a comment
There was a problem hiding this comment.
Thanks so much for reviewing @franknoirot! Made two changes based on your suggestions in addSweep about comments and using an existing utility. Let's see if I didn't break anything!
| import type { Selections } from '@src/lib/selections' | ||
| import { err } from '@src/lib/trap' | ||
|
|
||
| export function addExtrude({ |
There was a problem hiding this comment.
You're totally right, added them!
| KCL_DEFAULT_CONSTANT_PREFIXES.EXTRUDE | ||
| ) | ||
| const declaration = createVariableDeclaration(name, call) | ||
| modifiedAst.body.push(declaration) |
There was a problem hiding this comment.
Alright hahaha let's do this
src/lang/modifyAst/addSweep.ts
Outdated
| return sketchesExpr | ||
| } | ||
|
|
||
| function insertVariable( |
There was a problem hiding this comment.
This works perfectly!
| // KCL stdlib arguments | ||
| sketches: Selections | ||
| path: Selections | ||
| sectional?: boolean |
| // })), | ||
| // }, | ||
| distance: { | ||
| length: { |
| variable: KclCommandValue, | ||
| modifiedAst: Node<Program>, | ||
| pathToNode: PathToNode | ||
| pathToNode?: PathToNode |
There was a problem hiding this comment.
@franknoirot @Irev-Dev this way I can use it in addSweep.ts. Doesn't seem like a big change since we had the typeof check already
| nodeToEdit?: PathToNode | ||
| ): Error | Expr[] { | ||
| const sketches: Expr[] = selection.graphSelections.flatMap((s) => { | ||
| const path = getNodePathFromSourceRange(ast, s?.codeRef.range) |
There was a problem hiding this comment.
I think this fine for this PR, but we should probably get in the habit of using codeRef.pathToNode directly. As since #6632 it should be more reliable than range (range does not update under circumstances like comments or white space changes which can really mess things up)
But there's an argument for me or Jon to go through and banish ranges from the app entirely one we're able to come up for air, so just socialising it at this point.
There was a problem hiding this comment.
Oh nice yeah, thank you! Might do a follow up if that's quick and easy

Fixes #6434
This turned into a huge PR, sorry that wasn't the intent 😢
The goal of this refactor is to ensure a consistent order of operations across the different sweep calls and allow edit flows to be more robust to non-standard ways of creating these operations, namely:
This includes the following codemods, and move their implementation in a
modifyAst/addSweep.tsfile along with utility functions:This doesn't include Shell and others that have different argument flows and potentially need to be treated differently.
While I was building that, supporting multi-profile selections for this was straightforward to add so I took the chance to do it, since KCL supports it and it was an easy lift. This also ensures command bar argument to kcl argument naming consistency, biggest one being swapping
selectionforsketches.Demo
Screenshare.-.2025-04-28.7_44_04.PM.mp4