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

Add Delete to right-click context menu of feature tree operations #5302

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
1e9cf6f
Revert "Revert multi-profile (#4812)"
Irev-Dev Dec 17, 2024
e60cabb
fix poor 1000ms wait UX
Irev-Dev Dec 17, 2024
30edf2a
Merge remote-tracking branch 'origin' into kurt-bring-back-multi-profile
Irev-Dev Dec 17, 2024
c696f08
A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
github-actions[bot] Dec 17, 2024
2c40e8a
trigger CI
Irev-Dev Dec 17, 2024
3865637
Add Rust side artifacts for startSketchOn face or plane (#4834)
jtran Dec 19, 2024
1b9f5f2
Merge remote-tracking branch 'origin' into kurt-bring-back-multi-profile
Irev-Dev Dec 20, 2024
9f93346
lint
Irev-Dev Dec 20, 2024
e9086c5
lint
Irev-Dev Dec 20, 2024
913f264
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-macos…
github-actions[bot] Dec 20, 2024
7197b6c
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubunt…
github-actions[bot] Dec 20, 2024
9f323c2
A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-16-cores)
github-actions[bot] Dec 20, 2024
68c8974
trigger CI
Irev-Dev Dec 20, 2024
6add1d7
chore: disabled file watcher which prevents faster file write (#4835)
nadr0 Dec 20, 2024
0642e49
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubunt…
github-actions[bot] Dec 20, 2024
6c9d14a
partial fixes
Irev-Dev Dec 20, 2024
b09c240
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubunt…
github-actions[bot] Dec 20, 2024
2bb548c
Trigger CI
pierremtb Dec 20, 2024
d3e4b12
Merge branch 'main' into kurt-bring-back-multi-profile
jtran Jan 9, 2025
fcf3272
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubunt…
github-actions[bot] Jan 9, 2025
3344208
Trigger CI
jtran Jan 9, 2025
30397ba
Fix up all the tests
lf94 Jan 9, 2025
5fe3023
Fix partial execution
lf94 Jan 10, 2025
482487c
Merge branch 'main' into lf94/kurt-bring-back-multi-profile
lf94 Jan 15, 2025
648616c
Merge branch 'main' into lf94/kurt-bring-back-multi-profile
lf94 Jan 16, 2025
32e8975
wip
lf94 Jan 17, 2025
9008648
WIP
lf94 Jan 24, 2025
b3467bb
wip
lf94 Jan 27, 2025
33468c4
rust changes to make three point confrom to same as others since we'r…
Irev-Dev Jan 31, 2025
5a5138a
most of the fix for 3 point circle
Irev-Dev Jan 31, 2025
84d1745
get overlays working for circle three point
Irev-Dev Feb 3, 2025
d2f0865
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 3, 2025
4ec4469
fmt
Irev-Dev Feb 3, 2025
774e3ef
fix types
Irev-Dev Feb 3, 2025
1a67d34
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 3, 2025
481bef8
cargo fmt
Irev-Dev Feb 3, 2025
f2c76b0
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 3, 2025
663076f
add face codef ref for walls and caps
Irev-Dev Feb 4, 2025
40e4f22
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 4, 2025
87eabef
fix sketch on face after updates to rust side artifact graph
Irev-Dev Feb 4, 2025
d8dc49b
some things needed for multi-profile tests
Irev-Dev Feb 4, 2025
5ef0a1e
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 5, 2025
72272d5
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 5, 2025
4bb23bc
bad attempts at fixing rust
Irev-Dev Feb 5, 2025
42178fa
more
Irev-Dev Feb 5, 2025
e063622
more
Irev-Dev Feb 5, 2025
ced49f8
fix rust
Irev-Dev Feb 5, 2025
4ce6054
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 5, 2025
36d4830
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 5, 2025
0fd18c1
more rust fixes
Irev-Dev Feb 5, 2025
d8a9abb
overlay fix
Irev-Dev Feb 6, 2025
d70ebca
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 6, 2025
bcf3790
remove duplicate test
Irev-Dev Feb 6, 2025
f94671f
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 6, 2025
84ae567
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubunt…
github-actions[bot] Feb 6, 2025
ee54cdd
lint and typing
Irev-Dev Feb 6, 2025
45416df
maybe fix a unit test
Irev-Dev Feb 6, 2025
d3afa38
small thing
Irev-Dev Feb 6, 2025
a11d72e
WIP: Add Delete right click menu item to Feature Tree
pierremtb Feb 6, 2025
89975f7
I don't know why it works
pierremtb Feb 6, 2025
b46f4c5
WIP
pierremtb Feb 6, 2025
a7f4b0f
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 7, 2025
3190292
fix circ dep
Irev-Dev Feb 7, 2025
09cfbc1
fix unit test
Irev-Dev Feb 7, 2025
235e6a1
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 7, 2025
1f5f429
fix some tests
Irev-Dev Feb 7, 2025
99d0d49
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubunt…
github-actions[bot] Feb 7, 2025
9ed44b0
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubunt…
github-actions[bot] Feb 7, 2025
d028c77
Merge branch 'main' into pierremtb/issue5090-Add-Delete-right-click-m…
pierremtb Feb 7, 2025
bc4851b
Merge branch 'main' into pierremtb/issue5090-Add-Delete-right-click-m…
pierremtb Feb 7, 2025
13abdd0
Working deletion machine loo
pierremtb Feb 7, 2025
6a776f0
Working helix deletion
pierremtb Feb 7, 2025
b725ccc
Extend deletion to more things
pierremtb Feb 7, 2025
2353e2d
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubunt…
github-actions[bot] Feb 7, 2025
1200d9b
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubunt…
github-actions[bot] Feb 7, 2025
7a79292
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 9, 2025
e075622
fix sweep point-and-click test
Irev-Dev Feb 9, 2025
064a41d
fix more tests and add a fix me
Irev-Dev Feb 9, 2025
6360b8a
fix more tests
Irev-Dev Feb 10, 2025
f4f0533
fix electron specific test
Irev-Dev Feb 10, 2025
6a16e47
tsc
Irev-Dev Feb 10, 2025
6b1cc36
more test tweaks
Irev-Dev Feb 10, 2025
6df5e70
update docs
Irev-Dev Feb 10, 2025
ab6995b
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 10, 2025
a8b7328
commint snaps?
Irev-Dev Feb 10, 2025
3379cc4
is clippy happy now?
Irev-Dev Feb 10, 2025
e60b0e6
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 10, 2025
2501a98
clippy again
Irev-Dev Feb 10, 2025
3e1f858
test works now without me changing anything big-fixed-itself
Irev-Dev Feb 10, 2025
db895d6
small bug
Irev-Dev Feb 10, 2025
77902d5
make three point have cross hair to make it consistent with othe rtools
Irev-Dev Feb 10, 2025
5713bfd
fix up state diagram
Irev-Dev Feb 10, 2025
40fb6a4
fmt
Irev-Dev Feb 10, 2025
680fc30
add draft point for first click of three point circ
Irev-Dev Feb 10, 2025
2227287
1 test for three point circle
Irev-Dev Feb 10, 2025
1d8348c
2 test for three point circle
Irev-Dev Feb 10, 2025
b213834
clean up
Irev-Dev Feb 10, 2025
4a0d852
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubunt…
github-actions[bot] Feb 10, 2025
e1494c9
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubunt…
github-actions[bot] Feb 10, 2025
5580631
remove bad doc comment
Irev-Dev Feb 10, 2025
5d22308
remove test skip
Irev-Dev Feb 10, 2025
89b0ccb
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 10, 2025
8f0a40b
remove onboarding test changes
Irev-Dev Feb 10, 2025
22c0003
Update src/lang/modifyAst.ts
Irev-Dev Feb 10, 2025
11a678d
Update output from simulation tests
jtran Feb 10, 2025
11eceef
Fix to use correct source ranges
jtran Feb 10, 2025
8c1f5e1
Merge branch 'main' into pierremtb/issue5090-Add-Delete-right-click-m…
pierremtb Feb 10, 2025
58ec610
Change back to skipping face cap none and both
jtran Feb 11, 2025
508e1c9
Update output after changing back to skipping none and both
jtran Feb 11, 2025
ad8e306
Fix clippy warning
jtran Feb 11, 2025
5ae92bc
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 11, 2025
cba2349
fix profile start snap bug
Irev-Dev Feb 11, 2025
a686fe9
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 11, 2025
acc8493
Merge branch 'main' into pierremtb/issue5090-Add-Delete-right-click-m…
pierremtb Feb 11, 2025
83f458f
Merge branch 'main' into kurt-multi-profile-again
jtran Feb 11, 2025
ceab2ea
WIP: migrate to actor
pierremtb Feb 11, 2025
4a8897b
Merge branch 'main' into kurt-multi-profile-again
jtran Feb 12, 2025
1854064
add path ids to cap
Irev-Dev Feb 12, 2025
4a8e582
fix going into edit sketch
Irev-Dev Feb 12, 2025
de526ae
make other startSketchOn's work
Irev-Dev Feb 12, 2025
a78ec6c
fix snapshot test
Irev-Dev Feb 12, 2025
41340c8
explain function name
Irev-Dev Feb 12, 2025
520f899
Update src/lib/rectangleTool.ts
Irev-Dev Feb 12, 2025
60dcf9d
rename error
Irev-Dev Feb 12, 2025
dc7b901
remove file tree from diff
Irev-Dev Feb 12, 2025
5f8ae22
Update src/clientSideScene/segments.ts
Irev-Dev Feb 12, 2025
c1db093
nit
Irev-Dev Feb 12, 2025
01bf804
Continue actor migration
pierremtb Feb 12, 2025
8a920b6
Prevent double write to KCL code on revolve
franknoirot Feb 12, 2025
57c75b2
Merge branch 'main' into pierremtb/issue5090-Add-Delete-right-click-m…
pierremtb Feb 12, 2025
4e165e7
Clean up
pierremtb Feb 12, 2025
039092e
Update output after adding cap-to-path graph edge
jtran Feb 12, 2025
34f38df
Merge branch 'main' into pierremtb/issue5090-Add-Delete-right-click-m…
pierremtb Feb 12, 2025
473443e
Clean up
pierremtb Feb 12, 2025
f29bd5b
Update machine diag
pierremtb Feb 12, 2025
d46f563
Update context menu hotkey class
pierremtb Feb 12, 2025
bd10c65
Fix edit/select sketch-on-cap via feature tree
franknoirot Feb 12, 2025
500d92d
Merge branch 'main' into kurt-multi-profile-again
jtran Feb 12, 2025
d7f834f
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 13, 2025
9a89926
clean up for face codeRef
Irev-Dev Feb 13, 2025
b390e3e
Merge remote-tracking branch 'origin' into kurt-multi-profile-again
Irev-Dev Feb 13, 2025
9999e4e
fix changing tools part way through circle/rect tools
Irev-Dev Feb 13, 2025
0208eec
fix delete of circle profile
Irev-Dev Feb 13, 2025
b937934
fix close profiles
Irev-Dev Feb 13, 2025
b4d1a36
fix closing profile bug (tangentArcTo being ignored)
Irev-Dev Feb 13, 2025
bf1a42f
remove stale comment
Irev-Dev Feb 13, 2025
3747db0
Delete paths associated with sketch when the sketch plane is deleted
franknoirot Feb 12, 2025
09f3e6e
Add support for deleting sketches on caps (not walls)
franknoirot Feb 13, 2025
42016b7
get delet working for walls
Irev-Dev Feb 13, 2025
df89774
make delet of extrusions work for multi profile
Irev-Dev Feb 13, 2025
4ea1338
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubunt…
github-actions[bot] Feb 13, 2025
acb399a
Delete the sketch statement too on the cap and wall cases
franknoirot Feb 13, 2025
4acf74f
Don't write to file in `split-sketch-pipe-if-needed` unless necessary
franknoirot Feb 13, 2025
18d5bb3
Don't wait for file write to complete within `updateEditorWithAstAndW…
franknoirot Feb 13, 2025
be65086
Merge branch 'kurt-multi-profile-again' into pierremtb/issue5090-Add-…
pierremtb Feb 13, 2025
19cd4eb
Merge branch 'main' into pierremtb/issue5090-Add-Delete-right-click-m…
pierremtb Feb 14, 2025
9b89d89
Fix bad conflict resolution
pierremtb Feb 14, 2025
c95e309
Fix a few things post merge
pierremtb Feb 14, 2025
6c14b2b
Merge branch 'main' into pierremtb/issue5090-Add-Delete-right-click-m…
pierremtb Feb 14, 2025
401b869
Add guard back, fixing tests
pierremtb Feb 15, 2025
1126bf0
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubunt…
github-actions[bot] Feb 15, 2025
9aee967
A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubunt…
github-actions[bot] Feb 15, 2025
5e06ffa
Add e2e test
pierremtb Feb 15, 2025
1a6c54f
Merge branch 'main' into pierremtb/issue5090-Add-Delete-right-click-m…
pierremtb Feb 16, 2025
c1ffde2
Merge branch 'main' into pierremtb/issue5090-Add-Delete-right-click-m…
pierremtb Feb 17, 2025
d48ff15
Working tests on ubuntu
pierremtb Feb 18, 2025
a9deea8
Another one
pierremtb Feb 18, 2025
b8e06d6
Merge branch 'main' into pierremtb/issue5090-Add-Delete-right-click-m…
pierremtb Feb 18, 2025
c1f2ecc
Merge branch 'main' into pierremtb/issue5090-Add-Delete-right-click-m…
pierremtb Feb 19, 2025
e08b217
Update src/machines/featureTreeMachine.ts
pierremtb Feb 19, 2025
b63806c
Fix sketch test
pierremtb Feb 19, 2025
bc3d843
Merge branch 'pierremtb/adhoc/fix-sketch-test' into pierremtb/issue50…
pierremtb Feb 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions e2e/playwright/point-click.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ToolbarFixture } from './fixtures/toolbarFixture'
import fs from 'node:fs/promises'
import path from 'node:path'
import { getUtils } from './test-utils'
import { Locator } from '@playwright/test'

// test file is for testing point an click code gen functionality that's not sketch mode related

Expand Down Expand Up @@ -2506,6 +2507,94 @@ extrude002 = extrude(sketch002, length = 50)
})
})

const shellPointAndClickDeletionCases = [
{ shouldUseKeyboard: true },
{ shouldUseKeyboard: false },
]
shellPointAndClickDeletionCases.forEach(({ shouldUseKeyboard }) => {
test(`Shell point-and-click deletion (shouldUseKeyboard: ${shouldUseKeyboard})`, async ({
context,
page,
homePage,
scene,
editor,
toolbar,
cmdBar,
}) => {
const sketchCode = `sketch001 = startSketchOn('XY')
profile001 = startProfileAt([-20, 20], sketch001)
|> xLine(40, %)
|> yLine(-60, %)
|> xLine(-40, %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()
`
const extrudeCode = `extrude001 = extrude(profile001, length = 40)
`
const shellCode = `shell001 = shell(extrude001, faces = ['end'], thickness = 5)
`
const initialCode = sketchCode + extrudeCode + shellCode
await context.addInitScript((initialCode) => {
localStorage.setItem('persistCode', initialCode)
}, initialCode)
await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene()
await scene.waitForExecutionDone()
await toolbar.openPane('feature-tree')

// One dumb hardcoded screen pixel value
const testPoint = { x: 590, y: 400 }
const extrudeColor: [number, number, number] = [100, 100, 100]
const sketchColor: [number, number, number] = [140, 140, 140]
const defaultPlaneColor: [number, number, number] = [50, 50, 100]

const deleteOperation = async (operationButton: Locator) => {
if (shouldUseKeyboard) {
await operationButton.click({ button: 'left' })
await page.keyboard.press('Backspace')
} else {
await operationButton.click({ button: 'right' })
const editButton = page.getByTestId('context-menu-delete')
await editButton.click()
Comment on lines +2556 to +2558
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit]
This is something you could consider rolling into the toolbar fixture
Not exactly sure of what API we'd want @franknoirot might have some thoughts since I think he added the getFeatureTreeOperation it could be rolling into that maybe, but I'm not sure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah agreed that we'll definitely more of that type of testing. Let me create an issue for this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

}
}

await test.step(`Look for the grey of the extrude shape`, async () => {
await scene.expectPixelColor(extrudeColor, testPoint, 20)
})

await test.step('Delete shell and confirm deletion', async () => {
const operationButton = await toolbar.getFeatureTreeOperation(
'Shell',
0
)
await deleteOperation(operationButton)
await scene.expectPixelColor(extrudeColor, testPoint, 20)
await editor.expectEditor.not.toContain(shellCode)
})

await test.step('Delete extrude and confirm deletion', async () => {
const operationButton = await toolbar.getFeatureTreeOperation(
'Extrude',
0
)
await deleteOperation(operationButton)
await editor.expectEditor.not.toContain(extrudeCode)
await scene.expectPixelColor(sketchColor, testPoint, 20)
})

await test.step('Delete sketch and confirm empty scene', async () => {
const operationButton = await toolbar.getFeatureTreeOperation(
'Sketch',
0
)
await deleteOperation(operationButton)
await editor.expectEditor.toContain('')
await scene.expectPixelColor(defaultPlaneColor, testPoint, 20)
})
})
})

test(`Shell dry-run validation rejects sweeps`, async ({
context,
page,
Expand Down
3 changes: 0 additions & 3 deletions e2e/playwright/sketch-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2029,9 +2029,6 @@ profile003 = circle({ center = [6.92, -4.2], radius = 3.16 }, sketch001)
await moveToClearToolBarPopover()
await pointOnSegment({ shouldDbClick: true })
await page.waitForTimeout(600)

await toolbar.lineBtn.click()
await page.waitForTimeout(100)
Comment on lines -2032 to -2034
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's the fix we talked about, also done separately at #5425

})

await test.step('select and delete code for a profile', async () => {})
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions public/kcl-samples-manifest-fallback.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
"title": "Car Wheel Assembly",
"description": "A car wheel assembly with a rotor, tire, and lug nuts."
},
{
"file": "main.kcl",
"pathFromProjectDirectoryToFirstFile": "color-cube/main.kcl",
"multipleFiles": false,
"title": "Color Cube",
"description": "This is a color cube centered about the origin. It is used to help determine orientation in the scene."
},
{
"file": "main.kcl",
"pathFromProjectDirectoryToFirstFile": "cycloidal-gear/main.kcl",
Expand Down
13 changes: 5 additions & 8 deletions src/components/ContextMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import toast from 'react-hot-toast'
import { ActionIcon, ActionIconProps } from './ActionIcon'
import {
MouseEvent,
RefObject,
useCallback,
useEffect,
Expand Down Expand Up @@ -148,24 +147,22 @@ interface ContextMenuItemProps {
onClick?: () => void
hotkey?: string
'data-testid'?: string
disabled?: boolean
}

export function ContextMenuItem(props: ContextMenuItemProps) {
const { children, icon, onClick, hotkey } = props
const { children, icon, onClick, hotkey, disabled } = props

return (
<button
disabled={disabled}
data-testid={props['data-testid']}
className="flex items-center gap-2 py-1 px-2 cursor-pointer hover:bg-chalkboard-20 dark:hover:bg-chalkboard-80 border-none text-left"
onClick={onClick}
onClick={disabled ? undefined : onClick}
>
{icon && <ActionIcon icon={icon} bgClassName="!bg-transparent" />}
<div className="flex-1">{children}</div>
{hotkey && (
<kbd className="px-1.5 py-0.5 rounded bg-primary/10 text-primary dark:bg-chalkboard-80 dark:text-chalkboard-40">
{hotkey}
</kbd>
)}
{hotkey && <kbd className="hotkey">{hotkey}</kbd>}
</button>
)
}
Expand Down
32 changes: 28 additions & 4 deletions src/components/ModelingSidebar/ModelingPanes/FeatureTreePane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,20 @@ const OperationItem = (props: {
}
}

function deleteOperation() {
if (
props.item.type === 'StdLibCall' ||
props.item.type === 'UserDefinedFunctionCall'
) {
props.send({
type: 'deleteOperation',
data: {
targetSourceRange: sourceRangeFromRust(props.item.sourceRange),
},
})
}
}

const menuItems = useMemo(
() => [
<ContextMenuItem
Expand Down Expand Up @@ -364,14 +378,24 @@ const OperationItem = (props: {
</ContextMenuItem>,
]
: []),
...(props.item.type === 'StdLibCall' &&
stdLibMap[props.item.name]?.prepareToEdit
...(props.item.type === 'StdLibCall'
? [
<ContextMenuItem onClick={enterEditFlow}>
Edit {name}
<ContextMenuItem
disabled={!stdLibMap[props.item.name]?.prepareToEdit}
onClick={enterEditFlow}
hotkey="Double click"
>
Edit
</ContextMenuItem>,
]
: []),
<ContextMenuItem
onClick={deleteOperation}
hotkey="Delete"
data-testid="context-menu-delete"
>
Delete
</ContextMenuItem>,
],
[props.item, props.send]
)
Expand Down
38 changes: 38 additions & 0 deletions src/lang/modifyAst/deleteSelection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Selection } from 'lib/selections'
import { getFaceDetails } from 'clientSideScene/sceneEntities'
import { deleteFromSelection } from 'lang/modifyAst'
import { codeManager, engineCommandManager, kclManager } from 'lib/singletons'
import { err } from 'lib/trap'
import { executeAst } from 'lang/langHelpers'

export const deletionErrorMessage =
'Unable to delete selection. Please edit manually in code pane.'

export async function deleteSelectionPromise(
selection: Selection
): Promise<Error | void> {
Comment on lines +11 to +13
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This replaces the old AST delete selection action

let ast = kclManager.ast

const modifiedAst = await deleteFromSelection(
ast,
selection,
kclManager.variables,
engineCommandManager.artifactGraph,
getFaceDetails
)
if (err(modifiedAst)) {
return new Error(deletionErrorMessage)
}

const testExecute = await executeAst({
ast: modifiedAst,
engineCommandManager,
isMock: true,
})
if (testExecute.errors.length) {
return new Error(deletionErrorMessage)
}

await kclManager.updateAst(modifiedAst, true)
await codeManager.updateEditorWithAstAndWriteToFile(modifiedAst)
}
1 change: 1 addition & 0 deletions src/lib/commandBarConfigs/modelingCommandConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export type ModelingCommandSchema = {
prompt: string
selection: Selections
}
'Delete selection': {}
}

export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
Expand Down
113 changes: 110 additions & 3 deletions src/machines/featureTreeMachine.ts

Large diffs are not rendered by default.

Loading
Loading