Change artifact IDs to be stable across KCL executions (#4101)

* Add ID generator to ExecState

* Change default plane IDs to be hardcoded

* Fix lint warning

* Add exposing ID generator as output of executor

* Change to use generated definition of ExecState in TS

* Fix IdGenerator to use camel case in TS

* Fix TS type errors

* Add exposing id_generator parameter

* Add using the previously generated ID generator

* wip: Add display of feature tree in debug pane

* Remove artifact graph augmentation

* Change default planes to use id generator instead of hardcoded UUIDs

* Fix to reuse previously generated IDs

* Add e2e test

* Change feature tree to be collapsed by default

* Remove debug prints

* Fix unit test to use execState

* Fix type to be more general

* Remove outdated comment

* Update derive-docs output

* Fix object display component to be more general

* Remove unused ArtifactId type

* Fix test to be less brittle

* Remove codeRef and pathToNode from display

* Fix to remove test.only

Co-authored-by: Frank Noirot <frank@zoo.dev>

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)

* Move plane conversion code to be next to type

* Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)"

This reverts commit 3455cc951b.

* Rename file

* Rename components and add doc comments

* Revive the collapse button

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)

* Confirm

* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)

* Confirm

* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)

* Confirm

---------

Co-authored-by: Frank Noirot <frank@zoo.dev>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Jonathan Tran
2024-10-09 19:38:40 -04:00
committed by GitHub
parent e525b319d0
commit 0fb5ff7f10
66 changed files with 961 additions and 400 deletions

View File

@ -34,7 +34,7 @@ async function testingSwapSketchFnCall({
const ast = parse(inputCode)
if (err(ast)) return Promise.reject(ast)
const programMemory = await enginelessExecutor(ast)
const execState = await enginelessExecutor(ast)
const selections = {
codeBasedSelections: [range],
otherSelections: [],
@ -45,7 +45,7 @@ async function testingSwapSketchFnCall({
return Promise.reject(new Error('transformInfos undefined'))
const ast2 = transformAstSketchLines({
ast,
programMemory,
programMemory: execState.memory,
selectionRanges: selections,
transformInfos,
referenceSegName: '',
@ -360,10 +360,10 @@ part001 = startSketchOn('XY')
|> line([2.14, 1.35], %) // normal-segment
|> xLine(3.54, %)`
it('normal case works', async () => {
const programMemory = await enginelessExecutor(parse(code))
const execState = await enginelessExecutor(parse(code))
const index = code.indexOf('// normal-segment') - 7
const sg = sketchFromKclValue(
programMemory.get('part001'),
execState.memory.get('part001'),
'part001'
) as Sketch
const _segment = getSketchSegmentFromSourceRange(sg, [index, index])
@ -377,10 +377,10 @@ part001 = startSketchOn('XY')
})
})
it('verify it works when the segment is in the `start` property', async () => {
const programMemory = await enginelessExecutor(parse(code))
const execState = await enginelessExecutor(parse(code))
const index = code.indexOf('// segment-in-start') - 7
const _segment = getSketchSegmentFromSourceRange(
sketchFromKclValue(programMemory.get('part001'), 'part001') as Sketch,
sketchFromKclValue(execState.memory.get('part001'), 'part001') as Sketch,
[index, index]
)
if (err(_segment)) throw _segment