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

Bring back multi profile #4828

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 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
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
52 changes: 29 additions & 23 deletions e2e/playwright/sketch-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,9 @@ test.describe('multi-profile sketching', () => {
await endLineStartTanArc({ delay: 544 })

await endArcStartLine()
await editor.expectEditor.toContain(`|> tangentialArcTo([16.61, 4.14], %)`)
await editor.expectEditor.toContain(
`|> tangentialArcTo([16.61, 4.14], %)`
)
await toolbar.lineBtn.click()
await page.waitForTimeout(300)
await endArcStartLine()
Expand Down Expand Up @@ -1461,15 +1463,16 @@ test.describe('multi-profile sketching', () => {
`profile005 = startProfileAt([5.63, 3.05], sketch001)`
)
await crnRect1point2()
await editor.expectEditor
.toContain(`|> angledLine([0, 2.37], %, $rectangleSegmentA001)
await editor.expectEditor.toContain(
`|> angledLine([0, 2.37], %, $rectangleSegmentA001)
|> angledLine([segAng(rectangleSegmentA001) - 90, 7.8], %)
|> angledLine([
segAng(rectangleSegmentA001),
-segLen(rectangleSegmentA001)
], %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)`.replaceAll("\n", ""))
|> close(%)`.replaceAll('\n', '')
)

await crnRect2point1()
await page.waitForTimeout(300)
Expand All @@ -1478,8 +1481,8 @@ test.describe('multi-profile sketching', () => {
)
await crnRect2point2()
await page.waitForTimeout(300)
await editor.expectEditor
.toContain(`|> angledLine([0, 5.49], %, $rectangleSegmentA002)
await editor.expectEditor.toContain(
`|> angledLine([0, 5.49], %, $rectangleSegmentA002)
|> angledLine([
segAng(rectangleSegmentA002) - 90,
4.14
Expand All @@ -1489,7 +1492,8 @@ test.describe('multi-profile sketching', () => {
-segLen(rectangleSegmentA002)
], %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)`.replaceAll("\n", ""))
|> close(%)`.replaceAll('\n', '')
)
})

await test.step('create two center rectangles in a row without unequip', async () => {
Expand All @@ -1502,8 +1506,8 @@ test.describe('multi-profile sketching', () => {
)
await cntrRect1point2()
await page.waitForTimeout(300)
await editor.expectEditor
.toContain(`|> angledLine([0, 7.06], %, $rectangleSegmentA003)
await editor.expectEditor.toContain(
`|> angledLine([0, 7.06], %, $rectangleSegmentA003)
|> angledLine([
segAng(rectangleSegmentA003) + 90,
4.34
Expand All @@ -1513,7 +1517,8 @@ test.describe('multi-profile sketching', () => {
-segLen(rectangleSegmentA003)
], %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)`.replaceAll("\n", ""))
|> close(%)`.replaceAll('\n', '')
)
await page.waitForTimeout(300)

await cntrRect2point1()
Expand All @@ -1523,8 +1528,8 @@ test.describe('multi-profile sketching', () => {
)
await cntrRect2point2()
await page.waitForTimeout(300)
await editor.expectEditor
.toContain(`|> angledLine([0, 3.12], %, $rectangleSegmentA004)
await editor.expectEditor.toContain(
`|> angledLine([0, 3.12], %, $rectangleSegmentA004)
|> angledLine([
segAng(rectangleSegmentA004) + 90,
6.24
Expand All @@ -1534,7 +1539,8 @@ test.describe('multi-profile sketching', () => {
-segLen(rectangleSegmentA004)
], %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)`.replaceAll("\n", ""))
|> close(%)`.replaceAll('\n', '')
)
})
})

Expand Down Expand Up @@ -1593,11 +1599,11 @@ profile003 = circle({ center = [6.92, -4.2], radius = 3.16 }, sketch001)
const [rectEnd] = scene.makeMouseHelpers(757, 395)

await test.step('enter sketch and setup', async () => {
await page.screenshot({ path: "toolbar1.png" })
await page.screenshot({ path: 'toolbar1.png' })
await pointOnSegment({ shouldDbClick: true })
await page.waitForTimeout(600)

await page.screenshot({ path: "toolbar2.png" })
await page.screenshot({ path: 'toolbar2.png' })
await toolbar.lineBtn.click()
await page.waitForTimeout(100)
})
Expand Down Expand Up @@ -1648,8 +1654,8 @@ profile003 = circle({ center = [6.92, -4.2], radius = 3.16 }, sketch001)
)
await page.waitForTimeout(100)
await rectEnd()
await editor.expectEditor
.toContain(`|> angledLine([180, 1.97], %, $rectangleSegmentA002)
await editor.expectEditor.toContain(
`|> angledLine([180, 1.97], %, $rectangleSegmentA002)
|> angledLine([
segAng(rectangleSegmentA002) + 90,
3.88
Expand All @@ -1659,7 +1665,8 @@ profile003 = circle({ center = [6.92, -4.2], radius = 3.16 }, sketch001)
-segLen(rectangleSegmentA002)
], %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> close(%)`.replaceAll("\n", ""))
|> close(%)`.replaceAll('\n', '')
)
})
})
test('Can delete a profile in the editor while is sketch mode, and sketch mode does not break, can ctrl+z to undo after constraint with variable was added', async ({
Expand Down Expand Up @@ -1952,7 +1959,9 @@ extrude001 = extrude(75, thePart)
})

await test.step('expect code to match initial conditions still', async () => {
await editor.expectEditor.toContain(`thePart = startSketchOn('XZ') |> startProfileAt([7.53, 10.51], %)`)
await editor.expectEditor.toContain(
`thePart = startSketchOn('XZ') |> startProfileAt([7.53, 10.51], %)`
)
})

await test.step('equiping the line tool should break up the pipe expression', async () => {
Expand Down Expand Up @@ -2290,10 +2299,7 @@ loft([profile001, profile002])
topProfileEdgeClickCoords.x,
topProfileEdgeClickCoords.y
)
const [sideProfileEdgeClick] = scene.makeMouseHelpers(
788,
188,
)
const [sideProfileEdgeClick] = scene.makeMouseHelpers(788, 188)

const [rect1Crn1] = scene.makeMouseHelpers(592, 283)
const [rect1Crn2] = scene.makeMouseHelpers(797, 268)
Expand Down
2 changes: 1 addition & 1 deletion e2e/playwright/testing-constraints.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ part002 = startSketchOn('XZ')

await editor.scrollToText('line([74.36, 130.4], %)', true)
await page.getByText('line([74.36, 130.4], %)').click()
await page.screenshot({ path: "ok.png" })
await page.screenshot({ path: 'ok.png' })
await page.getByRole('button', { name: 'Edit Sketch' }).click()

const line3 = await u.getSegmentBodyCoords(
Expand Down
2 changes: 1 addition & 1 deletion src/components/FileTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ const FileTreeItem = ({
await codeManager.writeToFile()

// Prevent seeing the model built one piece at a time when changing files
await kclManager.executeCode(true)
await kclManager.executeCode({ zoomToFit: true })
} else {
// Let the lsp servers know we closed a file.
onFileClose(currentFile?.path || null, project?.path || null)
Expand Down
2 changes: 1 addition & 1 deletion src/components/ModelingMachineProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export const ModelingMachineProvider = ({
store.videoElement?.pause()

return kclManager
.executeCode()
.executeCode({ isPartialExecution: true })
Copy link
Collaborator

Choose a reason for hiding this comment

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

With #5005, I think we determined this isn't partial execution.

.then(() => {
if (engineCommandManager.engineConnection?.idleMode) return

Expand Down
2 changes: 1 addition & 1 deletion src/components/SettingsAuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export const SettingsAuthProviderBase = ({
) {
// Unit changes requires a re-exec of code
// eslint-disable-next-line @typescript-eslint/no-floating-promises
kclManager.executeCode(true)
kclManager.executeCode({ zoomToFit: true })
} else {
// For any future logging we'd like to do
// console.log(
Expand Down
2 changes: 1 addition & 1 deletion src/components/Stream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const Stream = () => {
*/
function executeCodeAndPlayStream() {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
kclManager.executeCode(true).then(async () => {
kclManager.executeCode({ zoomToFit: true }).then(async () => {
await videoRef.current?.play().catch((e) => {
console.warn('Video playing was prevented', e, videoRef.current)
})
Expand Down
10 changes: 6 additions & 4 deletions src/lang/KclSingleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { Operation } from 'wasm-lib/kcl/bindings/Operation'
interface ExecuteArgs {
ast?: Node<Program>
zoomToFit?: boolean
isPartialExecution?: boolean
executionId?: number
zoomOnRangeAndType?: {
range: SourceRange
Expand Down Expand Up @@ -379,7 +380,8 @@ export class KclManager {
await this.engineCommandManager.updateArtifactGraph(
this.ast,
execState.artifactCommands,
execState.artifacts
execState.artifacts,
args.isPartialExecution,
)
this._executeCallback()
if (!isInterrupted)
Expand Down Expand Up @@ -483,18 +485,18 @@ export class KclManager {
this._cancelTokens.set(key, true)
})
}
async executeCode(zoomToFit?: boolean): Promise<void> {
async executeCode(opts?: { zoomToFit?: true, isPartialExecution?: true }): Promise<void> {
const ast = await this.safeParse(codeManager.code)

if (!ast) {
this.clearAst()
return
}

zoomToFit = this.tryToZoomToFitOnCodeUpdate(ast, zoomToFit)
zoomToFit = this.tryToZoomToFitOnCodeUpdate(ast, opts?.zoomToFit)

this.ast = { ...ast }
return this.executeAst({ zoomToFit })
return this.executeAst(opts)
}
/**
* This will override the zoom to fit to zoom into the model if the previous AST was empty.
Expand Down
12 changes: 10 additions & 2 deletions src/lang/std/engineConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2090,14 +2090,22 @@ export class EngineCommandManager extends EventTarget {
updateArtifactGraph(
ast: Node<Program>,
artifactCommands: ArtifactCommand[],
execStateArtifacts: ExecState['artifacts']
execStateArtifacts: ExecState['artifacts'],
isPartialExecution?: true,
) {
this.artifactGraph = createArtifactGraph({
const newGraphArtifacts = createArtifactGraph({
artifactCommands,
responseMap: this.responseMap,
ast,
execStateArtifacts,
})
if (isPartialExecution) {
for (let [id, artifact] of newGraphArtifacts) {
this.artifactGraph.set(id, artifact)
}
} else {
this.artifactGraph = newGraphArtifacts
}
// TODO check if these still need to be deferred once e2e tests are working again.
if (this.artifactGraph.size) {
this.deferredArtifactEmptied(null)
Expand Down
2 changes: 1 addition & 1 deletion src/routes/Onboarding/Introduction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function OnboardingWarningWeb(props: OnboardingResetWarningProps) {
codeManager.updateCodeStateEditor(bracket)
await codeManager.writeToFile()

await kclManager.executeCode(true)
await kclManager.executeCode({ zoomToFit: true })
props.setShouldShowWarning(false)
}, reportRejection)}
nextText="Overwrite code and continue"
Expand Down
2 changes: 1 addition & 1 deletion src/routes/Onboarding/Sketching.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function Sketching() {
async function clearEditor() {
// We do want to update both the state and editor here.
codeManager.updateCodeStateEditor('')
await kclManager.executeCode(true)
await kclManager.executeCode({ zoomToFit: true })
}

// eslint-disable-next-line @typescript-eslint/no-floating-promises
Expand Down
2 changes: 1 addition & 1 deletion src/routes/Onboarding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function useDemoCode() {
setTimeout(
toSync(async () => {
codeManager.updateCodeStateEditor(bracket)
await kclManager.executeCode(true)
await kclManager.executeCode({ zoomToFit: true })
await codeManager.writeToFile()
}, reportRejection)
)
Expand Down