diff --git a/package-lock.json b/package-lock.json index 20e075f06..b2cb9144b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2492,6 +2492,7 @@ }, "node_modules/@clack/prompts/node_modules/is-unicode-supported": { "version": "1.3.0", + "extraneous": true, "inBundle": true, "license": "MIT", "engines": { diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 585f59c2f..0d7ec37ca 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1815,7 +1815,7 @@ dependencies = [ [[package]] name = "kcl-bumper" -version = "0.1.68" +version = "0.1.69" dependencies = [ "anyhow", "clap", @@ -1826,7 +1826,7 @@ dependencies = [ [[package]] name = "kcl-derive-docs" -version = "0.1.68" +version = "0.1.69" dependencies = [ "Inflector", "anyhow", @@ -1845,7 +1845,7 @@ dependencies = [ [[package]] name = "kcl-directory-test-macro" -version = "0.1.68" +version = "0.1.69" dependencies = [ "proc-macro2", "quote", @@ -1854,7 +1854,7 @@ dependencies = [ [[package]] name = "kcl-language-server" -version = "0.2.68" +version = "0.2.69" dependencies = [ "anyhow", "clap", @@ -1875,7 +1875,7 @@ dependencies = [ [[package]] name = "kcl-language-server-release" -version = "0.1.68" +version = "0.1.69" dependencies = [ "anyhow", "clap", @@ -1895,7 +1895,7 @@ dependencies = [ [[package]] name = "kcl-lib" -version = "0.2.68" +version = "0.2.69" dependencies = [ "anyhow", "approx 0.5.1", @@ -1970,7 +1970,7 @@ dependencies = [ [[package]] name = "kcl-python-bindings" -version = "0.3.68" +version = "0.3.69" dependencies = [ "anyhow", "kcl-lib", @@ -1985,7 +1985,7 @@ dependencies = [ [[package]] name = "kcl-test-server" -version = "0.1.68" +version = "0.1.69" dependencies = [ "anyhow", "hyper 0.14.32", @@ -1998,7 +1998,7 @@ dependencies = [ [[package]] name = "kcl-to-core" -version = "0.1.68" +version = "0.1.69" dependencies = [ "anyhow", "async-trait", @@ -2012,7 +2012,7 @@ dependencies = [ [[package]] name = "kcl-wasm-lib" -version = "0.1.68" +version = "0.1.69" dependencies = [ "anyhow", "bson", @@ -2042,9 +2042,9 @@ dependencies = [ [[package]] name = "kittycad" -version = "0.3.36" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a345fd2a4cb16205f32bd1aa41715045830c59d78c59927fca6580e2a651ac9" +checksum = "b48a9698d68c791df76aa020b596c324177a614e38ff3dd67eedd04db76e222f" dependencies = [ "anyhow", "async-trait", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 7787267d8..4a7e29e12 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -35,7 +35,7 @@ console_error_panic_hook = "0.1.7" dashmap = { version = "6.1.0" } http = "1" indexmap = "2.9.0" -kittycad = { version = "0.3.36", default-features = false, features = ["js", "requests"] } +kittycad = { version = "0.3.37", default-features = false, features = ["js", "requests"] } kittycad-modeling-cmds = { version = "0.2.117", features = ["ts-rs", "websocket"] } lazy_static = "1.5.0" miette = "7.5.0" diff --git a/rust/kcl-bumper/Cargo.toml b/rust/kcl-bumper/Cargo.toml index f0f992370..c07963a79 100644 --- a/rust/kcl-bumper/Cargo.toml +++ b/rust/kcl-bumper/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-bumper" -version = "0.1.68" +version = "0.1.69" edition = "2021" repository = "https://github.com/KittyCAD/modeling-api" rust-version = "1.76" diff --git a/rust/kcl-derive-docs/Cargo.toml b/rust/kcl-derive-docs/Cargo.toml index e6cd768f1..c19f7fcd6 100644 --- a/rust/kcl-derive-docs/Cargo.toml +++ b/rust/kcl-derive-docs/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-derive-docs" description = "A tool for generating documentation from Rust derive macros" -version = "0.1.68" +version = "0.1.69" edition = "2021" license = "MIT" repository = "https://github.com/KittyCAD/modeling-app" diff --git a/rust/kcl-directory-test-macro/Cargo.toml b/rust/kcl-directory-test-macro/Cargo.toml index cfc680286..42277f976 100644 --- a/rust/kcl-directory-test-macro/Cargo.toml +++ b/rust/kcl-directory-test-macro/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-directory-test-macro" description = "A tool for generating tests from a directory of kcl files" -version = "0.1.68" +version = "0.1.69" edition = "2021" license = "MIT" repository = "https://github.com/KittyCAD/modeling-app" diff --git a/rust/kcl-language-server-release/Cargo.toml b/rust/kcl-language-server-release/Cargo.toml index 382587747..cb1f0bc07 100644 --- a/rust/kcl-language-server-release/Cargo.toml +++ b/rust/kcl-language-server-release/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kcl-language-server-release" -version = "0.1.68" +version = "0.1.69" edition = "2021" authors = ["KittyCAD Inc "] publish = false diff --git a/rust/kcl-language-server/Cargo.toml b/rust/kcl-language-server/Cargo.toml index a3e481c54..177dff001 100644 --- a/rust/kcl-language-server/Cargo.toml +++ b/rust/kcl-language-server/Cargo.toml @@ -2,7 +2,7 @@ name = "kcl-language-server" description = "A language server for KCL." authors = ["KittyCAD Inc "] -version = "0.2.68" +version = "0.2.69" edition = "2021" license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/rust/kcl-lib/Cargo.toml b/rust/kcl-lib/Cargo.toml index 7297243e9..1138e3f02 100644 --- a/rust/kcl-lib/Cargo.toml +++ b/rust/kcl-lib/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-lib" description = "KittyCAD Language implementation and tools" -version = "0.2.68" +version = "0.2.69" edition = "2021" license = "MIT" repository = "https://github.com/KittyCAD/modeling-app" diff --git a/rust/kcl-lib/e2e/executor/cache.rs b/rust/kcl-lib/e2e/executor/cache.rs index 8a923c9ff..1e757aeea 100644 --- a/rust/kcl-lib/e2e/executor/cache.rs +++ b/rust/kcl-lib/e2e/executor/cache.rs @@ -3,6 +3,7 @@ use kcl_lib::{bust_cache, ExecError, ExecOutcome}; use kcmc::{each_cmd as mcmd, ModelingCmd}; use kittycad_modeling_cmds as kcmc; +use pretty_assertions::assert_eq; #[derive(Debug)] struct Variation<'a> { @@ -247,8 +248,11 @@ extrude(profile001, length = 100)"# ) .await; - result.first().unwrap(); - result.last().unwrap(); + let first = result.first().unwrap(); + let last = result.last().unwrap(); + + assert!(first.1 == last.1, "The images should be the same"); + assert_eq!(first.2, last.2, "The outcomes should be the same"); } #[cfg(feature = "artifact-graph")] @@ -550,3 +554,64 @@ extrude(profile001, length = 100) "The outcomes artifact graphs should be different" ); } + +#[tokio::test(flavor = "multi_thread")] +async fn kcl_test_cache_multi_file_same_code_dont_reexecute_settings_only_change() { + let code = r#"import "toBeImported.kcl" as importedCube + +importedCube + +sketch001 = startSketchOn(XZ) +profile001 = startProfile(sketch001, at = [-134.53, -56.17]) + |> angledLine(angle = 0, length = 79.05, tag = $rectangleSegmentA001) + |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 76.28) + |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001), tag = $seg01) + |> line(endAbsolute = [profileStartX(%), profileStartY(%)], tag = $seg02) + |> close() +extrude001 = extrude(profile001, length = 100) +sketch003 = startSketchOn(extrude001, face = seg02) +sketch002 = startSketchOn(extrude001, face = seg01) +"#; + + let other_file = ( + std::path::PathBuf::from("toBeImported.kcl"), + r#"sketch001 = startSketchOn(XZ) +profile001 = startProfile(sketch001, at = [281.54, 305.81]) + |> angledLine(angle = 0, length = 123.43, tag = $rectangleSegmentA001) + |> angledLine(angle = segAng(rectangleSegmentA001) - 90, length = 85.99) + |> angledLine(angle = segAng(rectangleSegmentA001), length = -segLen(rectangleSegmentA001)) + |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) + |> close() +extrude(profile001, length = 100)"# + .to_string(), + ); + + let result = cache_test( + "multi_file_same_code_dont_reexecute_settings_only_change", + vec![ + Variation { + code, + other_files: vec![other_file.clone()], + settings: &kcl_lib::ExecutorSettings { + show_grid: false, + ..Default::default() + }, + }, + Variation { + code, + other_files: vec![other_file], + settings: &kcl_lib::ExecutorSettings { + show_grid: true, + ..Default::default() + }, + }, + ], + ) + .await; + + let first = result.first().unwrap(); + let last = result.last().unwrap(); + + assert!(first.1 != last.1, "The images should be different for the grid"); + assert_eq!(first.2, last.2, "The outcomes should be the same"); +} diff --git a/rust/kcl-lib/e2e/executor/outputs/cache_multi_file_same_code_dont_reexecute_settings_only_change_0.png b/rust/kcl-lib/e2e/executor/outputs/cache_multi_file_same_code_dont_reexecute_settings_only_change_0.png new file mode 100644 index 000000000..822437343 Binary files /dev/null and b/rust/kcl-lib/e2e/executor/outputs/cache_multi_file_same_code_dont_reexecute_settings_only_change_0.png differ diff --git a/rust/kcl-lib/e2e/executor/outputs/cache_multi_file_same_code_dont_reexecute_settings_only_change_1.png b/rust/kcl-lib/e2e/executor/outputs/cache_multi_file_same_code_dont_reexecute_settings_only_change_1.png new file mode 100644 index 000000000..3d47b72c6 Binary files /dev/null and b/rust/kcl-lib/e2e/executor/outputs/cache_multi_file_same_code_dont_reexecute_settings_only_change_1.png differ diff --git a/rust/kcl-lib/src/errors.rs b/rust/kcl-lib/src/errors.rs index 4fd038ee6..6ab2dc277 100644 --- a/rust/kcl-lib/src/errors.rs +++ b/rust/kcl-lib/src/errors.rs @@ -559,7 +559,7 @@ impl From for pyo3::PyErr { } /// An error which occurred during parsing, etc. -#[derive(Debug, Clone, Serialize, Deserialize, ts_rs::TS)] +#[derive(Debug, Clone, Serialize, Deserialize, ts_rs::TS, PartialEq, Eq)] #[ts(export)] pub struct CompilationError { #[serde(rename = "sourceRange")] diff --git a/rust/kcl-lib/src/execution/cache.rs b/rust/kcl-lib/src/execution/cache.rs index 2c794561e..ed265baa0 100644 --- a/rust/kcl-lib/src/execution/cache.rs +++ b/rust/kcl-lib/src/execution/cache.rs @@ -118,7 +118,6 @@ pub(super) async fn get_changed_program(old: CacheInformation<'_>, new: CacheInf // We know they have the same imports because the ast is the same. // If we have no imports, we can skip this. if !old.ast.has_import_statements() { - println!("No imports, no need to check."); return CacheResult::NoAction(reapply_settings); } diff --git a/rust/kcl-lib/src/execution/mod.rs b/rust/kcl-lib/src/execution/mod.rs index 8496bdf29..1af60951c 100644 --- a/rust/kcl-lib/src/execution/mod.rs +++ b/rust/kcl-lib/src/execution/mod.rs @@ -64,7 +64,7 @@ pub mod typed_path; pub(crate) mod types; /// Outcome of executing a program. This is used in TS. -#[derive(Debug, Clone, Serialize, ts_rs::TS)] +#[derive(Debug, Clone, Serialize, ts_rs::TS, PartialEq)] #[ts(export)] #[serde(rename_all = "camelCase")] pub struct ExecOutcome { @@ -385,6 +385,7 @@ impl ExecutorContext { let (ws, _headers) = client .modeling() .commands_ws( + None, None, None, if settings.enable_ssao { @@ -653,14 +654,22 @@ impl ExecutorContext { keys.sort(); for key in keys { let (_, id, _, _) = &new_universe[key]; - let old_source = old_state.get_source(*id); - let new_source = new_exec_state.get_source(*id); - if old_source != new_source { - clear_scene = true; - break; + if let (Some(source0), Some(source1)) = + (old_state.get_source(*id), new_exec_state.get_source(*id)) + { + if source0.source != source1.source { + clear_scene = true; + break; + } } } + if !clear_scene { + // Return early we don't need to clear the scene. + let outcome = old_state.to_exec_outcome(result_env).await; + return Ok(outcome); + } + ( clear_scene, crate::Program { diff --git a/rust/kcl-python-bindings/Cargo.toml b/rust/kcl-python-bindings/Cargo.toml index c84a519ae..0135a4e83 100644 --- a/rust/kcl-python-bindings/Cargo.toml +++ b/rust/kcl-python-bindings/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kcl-python-bindings" -version = "0.3.68" +version = "0.3.69" edition = "2021" repository = "https://github.com/kittycad/modeling-app" exclude = ["tests/*", "files/*", "venv/*"] diff --git a/rust/kcl-test-server/Cargo.toml b/rust/kcl-test-server/Cargo.toml index 305748331..706850ee2 100644 --- a/rust/kcl-test-server/Cargo.toml +++ b/rust/kcl-test-server/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-test-server" description = "A test server for KCL" -version = "0.1.68" +version = "0.1.69" edition = "2021" license = "MIT" diff --git a/rust/kcl-to-core/Cargo.toml b/rust/kcl-to-core/Cargo.toml index 62945e07f..8f76c7baa 100644 --- a/rust/kcl-to-core/Cargo.toml +++ b/rust/kcl-to-core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-to-core" description = "Utility methods to convert kcl to engine core executable tests" -version = "0.1.68" +version = "0.1.69" edition = "2021" license = "MIT" repository = "https://github.com/KittyCAD/modeling-app" diff --git a/rust/kcl-wasm-lib/Cargo.toml b/rust/kcl-wasm-lib/Cargo.toml index 3ed46dd5e..818c705fd 100644 --- a/rust/kcl-wasm-lib/Cargo.toml +++ b/rust/kcl-wasm-lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kcl-wasm-lib" -version = "0.1.68" +version = "0.1.69" edition = "2021" repository = "https://github.com/KittyCAD/modeling-app" rust-version = "1.83"