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

@ -1,4 +1,8 @@
use kcl_lib::{ast::types::Program, errors::KclError, executor::ExecutorContext};
use kcl_lib::{
ast::types::Program,
errors::KclError,
executor::{ExecutorContext, IdGenerator},
};
macro_rules! gen_test {
($file:ident) => {
@ -22,12 +26,12 @@ macro_rules! gen_test_fail {
}
async fn run(code: &str) {
let (ctx, program) = setup(code).await;
let (ctx, program, id_generator) = setup(code).await;
ctx.run(&program, None).await.unwrap();
ctx.run(&program, None, id_generator).await.unwrap();
}
async fn setup(program: &str) -> (ExecutorContext, Program) {
async fn setup(program: &str) -> (ExecutorContext, Program, IdGenerator) {
let tokens = kcl_lib::token::lexer(program).unwrap();
let parser = kcl_lib::parser::Parser::new(tokens);
let program = parser.ast().unwrap();
@ -40,12 +44,12 @@ async fn setup(program: &str) -> (ExecutorContext, Program) {
settings: Default::default(),
context_type: kcl_lib::executor::ContextType::Mock,
};
(ctx, program)
(ctx, program, IdGenerator::default())
}
async fn run_fail(code: &str) -> KclError {
let (ctx, program) = setup(code).await;
let Err(e) = ctx.run(&program, None).await else {
let (ctx, program, id_generator) = setup(code).await;
let Err(e) = ctx.run(&program, None, id_generator).await else {
panic!("Expected this KCL program to fail, but it (incorrectly) never threw an error.");
};
e