fix cache multi-file (#6844)

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* bump kittycad.rs i need this for cli

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* bump the version so i can fix cli

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* clippy

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2025-05-12 07:07:18 -07:00
committed by GitHub
parent 5599a75dbd
commit 21b92f5f13
19 changed files with 107 additions and 33 deletions

1
package-lock.json generated
View File

@ -2492,6 +2492,7 @@
},
"node_modules/@clack/prompts/node_modules/is-unicode-supported": {
"version": "1.3.0",
"extraneous": true,
"inBundle": true,
"license": "MIT",
"engines": {

24
rust/Cargo.lock generated
View File

@ -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",

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -1,6 +1,6 @@
[package]
name = "kcl-language-server-release"
version = "0.1.68"
version = "0.1.69"
edition = "2021"
authors = ["KittyCAD Inc <kcl@kittycad.io>"]
publish = false

View File

@ -2,7 +2,7 @@
name = "kcl-language-server"
description = "A language server for KCL."
authors = ["KittyCAD Inc <kcl@kittycad.io>"]
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

View File

@ -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"

View File

@ -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");
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@ -559,7 +559,7 @@ impl From<KclError> 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")]

View File

@ -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);
}

View File

@ -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,13 +654,21 @@ 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 {
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,

View File

@ -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/*"]

View File

@ -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"

View File

@ -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"

View File

@ -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"