diff --git a/docs/kcl/KNOWN-ISSUES.md b/docs/kcl/KNOWN-ISSUES.md index 5dd7d9dec..0f37f35f7 100644 --- a/docs/kcl/KNOWN-ISSUES.md +++ b/docs/kcl/KNOWN-ISSUES.md @@ -17,4 +17,11 @@ once fixed in engine will just start working here with no language changes. currently move or transform the imported objects at all, once we have assemblies this will work. -- **Fillets**: Fillets cannot intersect, you will get an error. Only simple fillet cases work currently. +- **Fillets**: Fillets cannot intersect, you will get an error. Only simple fillet + cases work currently. + +- **Chamfers**: Chamfers cannot intersect, you will get an error. Only simple + chamfer cases work currently. + +- **Shell**: Shell is only working for `end` faces, not for `side` or `start` + faces. We are tracking the engine side bug on this. diff --git a/src/wasm-lib/Cargo.lock b/src/wasm-lib/Cargo.lock index 35c56b611..c0068cb5f 100644 --- a/src/wasm-lib/Cargo.lock +++ b/src/wasm-lib/Cargo.lock @@ -1375,7 +1375,7 @@ dependencies = [ [[package]] name = "kcl-lib" -version = "0.1.63" +version = "0.1.64" dependencies = [ "anyhow", "approx", diff --git a/src/wasm-lib/kcl/Cargo.toml b/src/wasm-lib/kcl/Cargo.toml index c68761677..b4e66cfe2 100644 --- a/src/wasm-lib/kcl/Cargo.toml +++ b/src/wasm-lib/kcl/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-lib" description = "KittyCAD Language implementation and tools" -version = "0.1.63" +version = "0.1.64" edition = "2021" license = "MIT" repository = "https://github.com/KittyCAD/modeling-app" diff --git a/src/wasm-lib/kcl/src/engine/mod.rs b/src/wasm-lib/kcl/src/engine/mod.rs index f408e5aea..e7b89eaec 100644 --- a/src/wasm-lib/kcl/src/engine/mod.rs +++ b/src/wasm-lib/kcl/src/engine/mod.rs @@ -216,6 +216,19 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static { } } WebSocketRequest::ModelingCmdReq { cmd: _, cmd_id } => { + // You are probably wondering why we can't just return the source range we were + // passed with the function. Well this is actually really important. + // If this is the last command in the batch and there is only one and we've reached + // the end of the file, this will trigger a flush batch function, but it will just + // send default or the end of the file as it's source range not the origin of the + // request so we need the original request source range in case the engine returns + // an error. + let source_range = id_to_source_range.get(&cmd_id).cloned().ok_or_else(|| { + KclError::Engine(KclErrorDetails { + message: format!("Failed to get source range for command ID: {:?}", cmd_id), + source_ranges: vec![], + }) + })?; let ws_resp = self .inner_send_modeling_cmd(cmd_id, source_range, final_req, id_to_source_range) .await?; diff --git a/src/wasm-lib/tests/executor/main.rs b/src/wasm-lib/tests/executor/main.rs index 105a5eefc..971ef7857 100644 --- a/src/wasm-lib/tests/executor/main.rs +++ b/src/wasm-lib/tests/executor/main.rs @@ -2245,3 +2245,27 @@ const baseExtrusion = extrude(width, sketch001) 1.0, ); } + +#[tokio::test(flavor = "multi_thread")] +async fn serial_test_engine_error_source_range_on_last_command() { + let code = r#"const sketch001 = startSketchOn('XZ') + |> startProfileAt([61.74, 206.13], %) + |> xLine(305.11, %, 'seg01') + |> yLine(-291.85, %) + |> xLine(-segLen('seg01', %), %) + |> lineTo([profileStartX(%), profileStartY(%)], %) + |> close(%) + |> extrude(40.14, %) + |> shell({ + faces: ["seg01"], + thickness: 3.14, + }, %) +"#; + + let result = execute_and_snapshot(code, UnitLength::Mm).await; + assert!(result.is_err()); + assert_eq!( + result.err().unwrap().to_string(), + r#"engine: KclErrorDetails { source_ranges: [SourceRange([262, 320])], message: "Modeling command failed: [ApiError { error_code: InternalEngine, message: \"Invalid brep after shell operation\" }]" }"# + ); +}