Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ repo as well since that is where the API client comes from.

### Running the tests

The tests use the `ZOO_TEST_TOKEN` variables for knowing how to authenticate.
Authenticated tests use `ZOO_TEST_TOKEN` and `ZOO_TEST_HOST`. Set these according to the deployment you want to test against.

```sh
export ZOO_TEST_TOKEN=$ZOO_API_TOKEN # dev or prod
export ZOO_TEST_HOST=$ZOO_HOST # dev or prod
cargo nextest run --no-fail-fast
```

### Releasing a new version

Expand Down
2 changes: 2 additions & 0 deletions src/cmd_kcl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,7 @@ fn get_modeling_settings_from_project_toml(input: &std::path::Path) -> Result<kc
let mut default_settings: kcl_lib::ExecutorSettings = Default::default();
let typed_path = TypedPath::from(input.display().to_string().as_str());
default_settings.with_current_file(typed_path);
default_settings.geometry_only = true;

// Check if the path was stdin.
if input.to_str() == Some("-") {
Expand Down Expand Up @@ -1782,6 +1783,7 @@ fn get_modeling_settings_from_project_toml(input: &std::path::Path) -> Result<kc
let mut settings: kcl_lib::ExecutorSettings = project_toml.into();
let typed_path = TypedPath::from(input.display().to_string().as_str());
settings.with_current_file(typed_path);
settings.geometry_only = true;
Ok(with_heartbeats(settings))
} else {
Ok(with_heartbeats(default_settings))
Expand Down
30 changes: 23 additions & 7 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use camino::Utf8Path;
use futures::{SinkExt, StreamExt};
use kcl_lib::{KclRuntimeFlags, RuntimeFlag, engine_connection::EngineManager};
use kittycad_modeling_cmds::{
ModelingCmd, each_cmd as mcmd,
ModelingCmd, ToggleGraphics, each_cmd as mcmd,
id::ModelingCmdId,
output::TakeSnapshot,
websocket::{
FailureWebSocketResponse, ModelingCmdReq, ModelingSessionData, OkWebSocketResponseData, RawFile,
Expand Down Expand Up @@ -45,7 +46,7 @@ struct KclProgramRun {
}

/// Runs a KCL program and returns state needed for follow-up commands.
async fn run_kcl_program(
async fn run_kcl_program_locally_with_graphics(
client: &kittycad::Client,
program: &kcl_lib::Program,
settings: kcl_lib::ExecutorSettings,
Expand All @@ -58,6 +59,10 @@ async fn run_kcl_program(
let kcl_version = program.language_version()?;
let exec_ctx = kcl_lib::ExecutorContext::new(client, settings, kcl_version).await?;
let mut exec_state = kcl_lib::ExecState::new(&exec_ctx);
// not all KCL commands run successfully without a graphics context (looking at you, PlaneSetColor).
// so for an arbitrary KCL file we always have to enable graphics.
exec_ctx.enable_engine_graphics_settings(&mut exec_state).await?;
exec_ctx.enable_engine_graphics(&mut exec_state).await?;
let (main_ref, session_data) = exec_ctx
.run(program, &mut exec_state)
.await
Expand Down Expand Up @@ -303,7 +308,7 @@ impl<'a> Context<'a> {
api_call_id: None,
fps: None,
order_independent_transparency: None,
pool: None,
pool: settings.geometry_only.then(|| "cpu".to_string()),
post_effect: if settings.enable_ssao {
Some(kittycad::types::PostEffectType::Ssao)
} else {
Expand Down Expand Up @@ -347,6 +352,17 @@ impl<'a> Context<'a> {
let mut heartbeat =
tokio::time::interval(Duration::from_secs(settings.heartbeats.unwrap_or(cmd_kcl::HEARTBEATS)));

// for arbitrary KCL we must always have graphics enabled because some KCL demands it.
let graphics_on_request_id = ModelingCmdId(uuid::Uuid::new_v4());
send_ws_request(
&mut write,
WebSocketRequest::ModelingCmdReq(ModelingCmdReq {
cmd: ModelingCmd::ToggleGraphics(ToggleGraphics::enabled(true)),
cmd_id: graphics_on_request_id,
}),
)
.await?;

let exec_request_id = uuid::Uuid::new_v4();
send_ws_request(
&mut write,
Expand Down Expand Up @@ -492,7 +508,7 @@ impl<'a> Context<'a> {
.map_err(|err| kcl_error_fmt::into_miette_for_parse(filename, code, err))?;

let settings = cmd_kcl::with_heartbeats(settings);
let run = run_kcl_program(&client, &program, settings, filename, code).await?;
let run = run_kcl_program_locally_with_graphics(&client, &program, settings, filename, code).await?;

kcl_error_fmt::check_exec_outcome_issues(&mut self.io.err_out, filename, code, &run.exec_outcome, issue_check)?;

Expand Down Expand Up @@ -551,7 +567,7 @@ impl<'a> Context<'a> {
.map_err(|err| kcl_error_fmt::into_miette_for_parse(filename, code, err))?;

let settings = cmd_kcl::with_heartbeats(settings);
let run = run_kcl_program(&client, &program, settings, filename, code).await?;
let run = run_kcl_program_locally_with_graphics(&client, &program, settings, filename, code).await?;

kcl_error_fmt::check_exec_outcome_issues(&mut self.io.err_out, filename, code, &run.exec_outcome, issue_check)?;

Expand Down Expand Up @@ -616,7 +632,7 @@ impl<'a> Context<'a> {
.map_err(|err| kcl_error_fmt::into_miette_for_parse(filename, code, err))?;

let settings = cmd_kcl::with_heartbeats(settings);
let run = run_kcl_program(&client, &program, settings, filename, code).await?;
let run = run_kcl_program_locally_with_graphics(&client, &program, settings, filename, code).await?;

kcl_error_fmt::check_exec_outcome_issues(&mut self.io.err_out, filename, code, &run.exec_outcome, issue_check)?;

Expand Down Expand Up @@ -656,7 +672,7 @@ impl<'a> Context<'a> {
output_format: kittycad_modeling_cmds::format::OutputFormat3d,
) -> Result<(Vec<RawFile>, Option<ModelingSessionData>)> {
let client = self.api_client("")?;
let run = run_kcl_program(&client, program, settings, filename, code).await?;
let run = run_kcl_program_locally_with_graphics(&client, program, settings, filename, code).await?;

kcl_error_fmt::check_exec_outcome_issues(&mut self.io.err_out, filename, code, &run.exec_outcome, issue_check)?;

Expand Down
Binary file modified tests/gear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/nested-settings/subdir/gear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/output_formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ async fn serve_bounding_box(listener: TcpListener) {
}
WebSocketRequest::ModelingCmdReq(request) => {
let response = match request.cmd {
ModelingCmd::ToggleGraphics(_) => continue,
ModelingCmd::ZoomToFit(_) => json!({
"type": "zoom_to_fit", "data": {"settings": {
"pos": {"x": 0, "y": -100, "z": 0},
Expand Down
Binary file modified tests/walkie-talkie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/walkie-talkie/walkie-talkie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/with-settings/gear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading