From 4d266cd0098c77e8151b9768220d5fef7c3560a0 Mon Sep 17 00:00:00 2001 From: Adam Chalmers Date: Wed, 12 Aug 2026 13:23:28 -0500 Subject: [PATCH 1/2] Execute KCL on engine by default Opt out by passing ENGINE_EXECUTION=0 --- src/context.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/context.rs b/src/context.rs index 61e23a95..f11ab25e 100644 --- a/src/context.rs +++ b/src/context.rs @@ -295,9 +295,12 @@ impl<'a> Context<'a> { /// Should KCL be executed on the server (true)? /// Or locally (false)? pub(crate) fn use_server_kcl_execution() -> bool { - std::env::var(ENGINE_EXECUTION_ENV) - .map(|value| !value.is_empty()) - .unwrap_or_default() + // Default to true. + let Ok(engine_exec) = std::env::var(ENGINE_EXECUTION_ENV) else { + return true; + }; + // Opt out if set to 0. + engine_exec != "0" } async fn engine_ws_with_settings( From 8120236c2784e6c162841bcc08556a5d8da67083 Mon Sep 17 00:00:00 2001 From: Adam Chalmers Date: Fri, 28 Aug 2026 22:29:00 -0500 Subject: [PATCH 2/2] Fix formatting, error messages --- src/context.rs | 23 +++++++++++++++++++---- src/tests.rs | 21 +++++---------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/context.rs b/src/context.rs index f11ab25e..b50bc407 100644 --- a/src/context.rs +++ b/src/context.rs @@ -409,8 +409,14 @@ impl<'a> Context<'a> { match result { Ok(_) => break, Err(err) => { - check_server_compilation_issues(&mut self.io.err_out, &err.non_fatal, issue_check) - .map_err(|e| anyhow!("KCL execution had errors: {e}"))?; + check_server_compilation_issues( + &mut self.io.err_out, + filepath.as_str(), + code, + &err.non_fatal, + issue_check, + ) + .map_err(|e| anyhow!("KCL execution had errors: {e}"))?; if let Some(error) = err.error { return Err(anyhow!("KCL execution failed: {}", error.get_message())); } @@ -872,6 +878,8 @@ pub(crate) fn reasoning_to_markdown(reason: &kittycad::types::ReasoningMessage) fn check_server_compilation_issues( err_out: &mut impl std::io::Write, + filename: &str, + code: &str, issues: &[kcl_error::CompilationIssue], issue_check: kcl_error_fmt::KclIssueCheck, ) -> Result<()> { @@ -879,8 +887,15 @@ fn check_server_compilation_issues( return Ok(()); } - for issue in issues { - writeln!(err_out, "{:?}: {}", issue.severity, issue.message)?; + for (i, issue) in issues.iter().enumerate() { + if i > 0 { + writeln!(err_out)?; + } + writeln!( + err_out, + "{}", + kcl_lib::render_compilation_issue_miette(filename, code, &Default::default(), issue.clone()) + )?; } if issue_check == kcl_error_fmt::KclIssueCheck::DenyErrors && issues.iter().any(|issue| issue.is_err()) { diff --git a/src/tests.rs b/src/tests.rs index 72d323bc..8791b42f 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -688,8 +688,7 @@ cli_tests! { svec!["zoo", "kcl", "snapshot", "tests/gear.kcl", "tests/gear.png"], ) .setup(setup_authenticated) - .stdout_contains("Snapshot saved to `tests/gear.png`") - .stderr_contains("Prefer to use explicit units for angles") + .stdout_contains("Snapshot from engine saved to `tests/gear.png`") } snapshot_via_engine(_ctx) => { @@ -714,8 +713,7 @@ cli_tests! { ], ) .setup(setup_authenticated) - .stdout_contains("Snapshot saved to `tests/with-settings/gear.png`") - .stderr_contains("Prefer to use explicit units for angles") + .stdout_contains("Snapshot from engine saved to `tests/with-settings/gear.png`") } snapshot_a_kcl_file_with_a_nested_project_toml_as_png(_ctx) => { @@ -730,8 +728,7 @@ cli_tests! { ], ) .setup(setup_authenticated) - .stdout_contains("Snapshot saved to `tests/nested-settings/subdir/gear.png`") - .stderr_contains("Prefer to use explicit units for angles") + .stdout_contains("Snapshot from engine saved to `tests/nested-settings/subdir/gear.png`") } snapshot_a_kcl_assembly_as_png(_ctx) => { @@ -740,7 +737,7 @@ cli_tests! { svec!["zoo", "kcl", "snapshot", "tests/walkie-talkie", "tests/walkie-talkie.png"], ) .setup(setup_authenticated) - .stdout_contains("Snapshot saved to `tests/walkie-talkie.png`") + .stdout_contains("Snapshot from engine saved to `tests/walkie-talkie.png`") } snapshot_a_kcl_assembly_as_png_with_dot(_ctx) => { @@ -750,7 +747,7 @@ cli_tests! { ) .setup(setup_authenticated) .current_directory(std::env::current_dir().unwrap().join("tests/walkie-talkie")) - .stdout_contains("Snapshot saved to `walkie-talkie.png`") + .stdout_contains("Snapshot from engine saved to `walkie-talkie.png`") } get_the_mass_of_a_kcl_file(_ctx) => { @@ -772,7 +769,6 @@ cli_tests! { ) .setup(setup_authenticated) .stdout_contains("1268.234") - .stderr_contains("Prefer to use explicit units for angles") } get_the_mass_of_a_kcl_file_but_use_project_toml(_ctx) => { @@ -794,7 +790,6 @@ cli_tests! { ) .setup(setup_authenticated) .stdout_contains("74.023") - .stderr_contains("Prefer to use explicit units for angles") } get_the_mass_of_a_kcl_file_with_nested_dirs_and_a_project_toml(_ctx) => { @@ -816,7 +811,6 @@ cli_tests! { ) .setup(setup_authenticated) .stdout_contains("74.023") - .stderr_contains("Prefer to use explicit units for angles") } analyze_a_kcl_file_as_table(_ctx) => { @@ -841,7 +835,6 @@ cli_tests! { ) .setup(setup_authenticated) .stdout_contains("center_of_mass") - .stderr_contains("Prefer to use explicit units for angles") } analyze_a_kcl_file_as_json(_ctx) => { @@ -867,7 +860,6 @@ cli_tests! { ) .setup(setup_authenticated) .stdout_contains(r#""center_of_mass""#) - .stderr_contains("Prefer to use explicit units for angles") } analyze_a_kcl_file_as_json_with_default_metric_units(_ctx) => { @@ -885,7 +877,6 @@ cli_tests! { ) .setup(setup_authenticated) .stdout_contains(r#""output_unit": "kg:m3""#) - .stderr_contains("Prefer to use explicit units for angles") } analyze_a_kcl_file_and_use_project_toml(_ctx) => { @@ -911,7 +902,6 @@ cli_tests! { ) .setup(setup_authenticated) .stdout_contains(r#""mass""#) - .stderr_contains("Prefer to use explicit units for angles") } analyze_a_kcl_file_with_invalid_density(_ctx) => { @@ -957,7 +947,6 @@ cli_tests! { ) .setup(setup_authenticated) .stdout_contains("0.0007") - .stderr_contains("Prefer to use explicit units for angles") } }