Files
modeling-app/rust/kcl-lib/src/engine/conn.rs

494 lines
20 KiB
Rust
Raw Normal View History

//! Functions for setting up our WebSocket and WebRTC connections for communications with the
//! engine.
use std::{collections::HashMap, sync::Arc};
use anyhow::{anyhow, Result};
use futures::{SinkExt, StreamExt};
use indexmap::IndexMap;
use kcmc::{
websocket::{
BatchResponse, FailureWebSocketResponse, ModelingCmdReq, ModelingSessionData, OkWebSocketResponseData,
SuccessWebSocketResponse, WebSocketRequest, WebSocketResponse,
},
ModelingCmd,
};
use kittycad_modeling_cmds::{self as kcmc};
use tokio::sync::{mpsc, oneshot, RwLock};
use tokio_tungstenite::tungstenite::Message as WsMsg;
use uuid::Uuid;
use super::ExecutionKind;
both edit and move in one PR (#566) * get the data for where lines are Signed-off-by: Jess Frazelle <github@jessfraz.com> * make pretty Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * new shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * beginning of stufff Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * add new fns Signed-off-by: Jess Frazelle <github@jessfraz.com> * basic function Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix ups to keep order Signed-off-by: Jess Frazelle <github@jessfraz.com> * further Signed-off-by: Jess Frazelle <github@jessfraz.com> * failing test Signed-off-by: Jess Frazelle <github@jessfraz.com> * do it in rust Signed-off-by: Jess Frazelle <github@jessfraz.com> * trait Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of ui integration Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * weird shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * generate close on close Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of constraint functions Signed-off-by: Jess Frazelle <github@jessfraz.com> * helper functions Signed-off-by: Jess Frazelle <github@jessfraz.com> * make work Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * constraints w ranges Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * skip Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * comment Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * throw Signed-off-by: Jess Frazelle <github@jessfraz.com> * make close a bit less sensitive in move scenario Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup shit we didnt end up using Signed-off-by: Jess Frazelle <github@jessfraz.com> * make it less hard to close Signed-off-by: Jess Frazelle <github@jessfraz.com> * Fix edit after sketch * Move to plane for sketch * Fix pathToNode for ast mods * Fix exit sketch mode with escape * Fix fmt since my editor did it wrong * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix link Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Adam Sunderland <adam@kittycad.io>
2023-09-17 21:57:43 -07:00
use crate::{
engine::EngineManager,
errors::{KclError, KclErrorDetails},
execution::{ArtifactCommand, DefaultPlanes, IdGenerator},
SourceRange,
both edit and move in one PR (#566) * get the data for where lines are Signed-off-by: Jess Frazelle <github@jessfraz.com> * make pretty Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * new shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * beginning of stufff Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * add new fns Signed-off-by: Jess Frazelle <github@jessfraz.com> * basic function Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix ups to keep order Signed-off-by: Jess Frazelle <github@jessfraz.com> * further Signed-off-by: Jess Frazelle <github@jessfraz.com> * failing test Signed-off-by: Jess Frazelle <github@jessfraz.com> * do it in rust Signed-off-by: Jess Frazelle <github@jessfraz.com> * trait Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of ui integration Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * weird shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * generate close on close Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of constraint functions Signed-off-by: Jess Frazelle <github@jessfraz.com> * helper functions Signed-off-by: Jess Frazelle <github@jessfraz.com> * make work Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * constraints w ranges Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * skip Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * comment Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * throw Signed-off-by: Jess Frazelle <github@jessfraz.com> * make close a bit less sensitive in move scenario Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup shit we didnt end up using Signed-off-by: Jess Frazelle <github@jessfraz.com> * make it less hard to close Signed-off-by: Jess Frazelle <github@jessfraz.com> * Fix edit after sketch * Move to plane for sketch * Fix pathToNode for ast mods * Fix exit sketch mode with escape * Fix fmt since my editor did it wrong * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix link Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Adam Sunderland <adam@kittycad.io>
2023-09-17 21:57:43 -07:00
};
#[derive(Debug, PartialEq)]
enum SocketHealth {
Active,
Inactive,
}
type WebSocketTcpWrite = futures::stream::SplitSink<tokio_tungstenite::WebSocketStream<reqwest::Upgraded>, WsMsg>;
#[derive(Debug)]
pub struct EngineConnection {
engine_req_tx: mpsc::Sender<ToEngineReq>,
shutdown_tx: mpsc::Sender<()>,
responses: Arc<RwLock<IndexMap<uuid::Uuid, WebSocketResponse>>>,
pending_errors: Arc<RwLock<Vec<String>>>,
#[allow(dead_code)]
tcp_read_handle: Arc<TcpReadHandle>,
socket_health: Arc<RwLock<SocketHealth>>,
batch: Arc<RwLock<Vec<(WebSocketRequest, SourceRange)>>>,
batch_end: Arc<RwLock<IndexMap<uuid::Uuid, (WebSocketRequest, SourceRange)>>>,
artifact_commands: Arc<RwLock<Vec<ArtifactCommand>>>,
/// The default planes for the scene.
default_planes: Arc<RwLock<Option<DefaultPlanes>>>,
/// If the server sends session data, it'll be copied to here.
session_data: Arc<RwLock<Option<ModelingSessionData>>>,
execution_kind: Arc<RwLock<ExecutionKind>>,
}
pub struct TcpRead {
stream: futures::stream::SplitStream<tokio_tungstenite::WebSocketStream<reqwest::Upgraded>>,
}
/// Occurs when client couldn't read from the WebSocket to the engine.
// #[derive(Debug)]
pub enum WebSocketReadError {
/// Could not read a message due to WebSocket errors.
Read(tokio_tungstenite::tungstenite::Error),
/// WebSocket message didn't contain a valid message that the KCL Executor could parse.
Deser(anyhow::Error),
}
impl From<anyhow::Error> for WebSocketReadError {
fn from(e: anyhow::Error) -> Self {
Self::Deser(e)
}
}
impl TcpRead {
pub async fn read(&mut self) -> std::result::Result<WebSocketResponse, WebSocketReadError> {
let Some(msg) = self.stream.next().await else {
return Err(anyhow::anyhow!("Failed to read from WebSocket").into());
};
let msg = match msg {
Ok(msg) => msg,
Err(e) if matches!(e, tokio_tungstenite::tungstenite::Error::Protocol(_)) => {
return Err(WebSocketReadError::Read(e))
}
Err(e) => return Err(anyhow::anyhow!("Error reading from engine's WebSocket: {e}").into()),
};
let msg: WebSocketResponse = match msg {
WsMsg::Text(text) => serde_json::from_str(&text)
.map_err(anyhow::Error::from)
.map_err(WebSocketReadError::from)?,
WsMsg::Binary(bin) => bson::from_slice(&bin)
.map_err(anyhow::Error::from)
.map_err(WebSocketReadError::from)?,
other => return Err(anyhow::anyhow!("Unexpected WebSocket message from engine API: {other}").into()),
};
Ok(msg)
}
}
pub struct TcpReadHandle {
handle: Arc<tokio::task::JoinHandle<Result<(), WebSocketReadError>>>,
}
impl std::fmt::Debug for TcpReadHandle {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "TcpReadHandle")
}
}
impl Drop for TcpReadHandle {
fn drop(&mut self) {
// Drop the read handle.
self.handle.abort();
}
}
/// Requests to send to the engine, and a way to await a response.
struct ToEngineReq {
/// The request to send
req: WebSocketRequest,
/// If this resolves to Ok, the request was sent.
/// If this resolves to Err, the request could not be sent.
/// If this has not yet resolved, the request has not been sent yet.
request_sent: oneshot::Sender<Result<()>>,
}
impl EngineConnection {
/// Start waiting for incoming engine requests, and send each one over the WebSocket to the engine.
async fn start_write_actor(
mut tcp_write: WebSocketTcpWrite,
mut engine_req_rx: mpsc::Receiver<ToEngineReq>,
mut shutdown_rx: mpsc::Receiver<()>,
) {
loop {
tokio::select! {
maybe_req = engine_req_rx.recv() => {
match maybe_req {
Some(ToEngineReq { req, request_sent }) => {
// Decide whether to send as binary or text,
// then send to the engine.
let res = if let WebSocketRequest::ModelingCmdReq(ModelingCmdReq {
cmd: ModelingCmd::ImportFiles { .. },
cmd_id: _,
}) = &req
{
Self::inner_send_to_engine_binary(req, &mut tcp_write).await
} else {
Self::inner_send_to_engine(req, &mut tcp_write).await
};
// Let the caller know weve sent the request (ok or error).
let _ = request_sent.send(res);
}
None => {
// The engine_req_rx channel has closed, so no more requests.
// We'll gracefully exit the loop and close the engine.
break;
}
}
},
// If we get a shutdown signal, close the engine immediately and return.
_ = shutdown_rx.recv() => {
let _ = Self::inner_close_engine(&mut tcp_write).await;
return;
}
}
}
// If we exit the loop (e.g. engine_req_rx was closed),
// still gracefully close the engine before returning.
let _ = Self::inner_close_engine(&mut tcp_write).await;
}
/// Send the given `request` to the engine via the WebSocket connection `tcp_write`.
async fn inner_close_engine(tcp_write: &mut WebSocketTcpWrite) -> Result<()> {
tcp_write
.send(WsMsg::Close(None))
.await
.map_err(|e| anyhow!("could not send close over websocket: {e}"))?;
Ok(())
}
/// Send the given `request` to the engine via the WebSocket connection `tcp_write`.
async fn inner_send_to_engine(request: WebSocketRequest, tcp_write: &mut WebSocketTcpWrite) -> Result<()> {
let msg = serde_json::to_string(&request).map_err(|e| anyhow!("could not serialize json: {e}"))?;
tcp_write
.send(WsMsg::Text(msg))
.await
.map_err(|e| anyhow!("could not send json over websocket: {e}"))?;
Ok(())
}
/// Send the given `request` to the engine via the WebSocket connection `tcp_write` as binary.
async fn inner_send_to_engine_binary(request: WebSocketRequest, tcp_write: &mut WebSocketTcpWrite) -> Result<()> {
let msg = bson::to_vec(&request).map_err(|e| anyhow!("could not serialize bson: {e}"))?;
tcp_write
.send(WsMsg::Binary(msg))
.await
.map_err(|e| anyhow!("could not send json over websocket: {e}"))?;
Ok(())
}
pub async fn new(ws: reqwest::Upgraded) -> Result<EngineConnection> {
let wsconfig = tokio_tungstenite::tungstenite::protocol::WebSocketConfig {
// 4294967296 bytes, which is around 4.2 GB.
2025-03-04 22:21:12 -08:00
max_message_size: Some(usize::MAX),
max_frame_size: Some(usize::MAX),
..Default::default()
};
let ws_stream = tokio_tungstenite::WebSocketStream::from_raw_socket(
ws,
tokio_tungstenite::tungstenite::protocol::Role::Client,
Some(wsconfig),
)
.await;
let (tcp_write, tcp_read) = ws_stream.split();
let (engine_req_tx, engine_req_rx) = mpsc::channel(10);
let (shutdown_tx, shutdown_rx) = mpsc::channel(1);
tokio::task::spawn(Self::start_write_actor(tcp_write, engine_req_rx, shutdown_rx));
let mut tcp_read = TcpRead { stream: tcp_read };
let session_data: Arc<RwLock<Option<ModelingSessionData>>> = Arc::new(RwLock::new(None));
let session_data2 = session_data.clone();
let responses: Arc<RwLock<IndexMap<uuid::Uuid, WebSocketResponse>>> = Arc::new(RwLock::new(IndexMap::new()));
let responses_clone = responses.clone();
let socket_health = Arc::new(RwLock::new(SocketHealth::Active));
let pending_errors = Arc::new(RwLock::new(Vec::new()));
return errors back to user (#4075) * Log any Errors to stderr This isn't perfect -- in fact, this is maybe not even very good at all, but it's better than what we have today. Currently, when we get an Erorr back from the WebSocket, we drop it in kcl-lib. The web-app logs these to the console (I can't find my commit doing that off the top of my head, but I remember doing it) -- so this is some degree of partity. This won't be very useful at all for wasm usage, but it will fix issues with the zoo cli silently breaking with a "WebSocket Closed" error -- which is the same issue I was solving for in the desktop app too. In the future perhaps this can be a real Error? I'm not totally sure yet, since we can't align to the request-id, so we can't really tie it to a specific call (yet). * add to responses Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * add a test Signed-off-by: Jess Frazelle <github@jessfraz.com> * clippy[ Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * empty * fix error Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * docs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
2024-10-03 01:05:12 -04:00
let pending_errors_clone = pending_errors.clone();
let socket_health_tcp_read = socket_health.clone();
let tcp_read_handle = tokio::spawn(async move {
// Get Websocket messages from API server
loop {
match tcp_read.read().await {
Ok(ws_resp) => {
get responses back from batch (#2687) * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove my stupid println Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * weird typescript Signed-off-by: Jess Frazelle <github@jessfraz.com> * better batch stuff; Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * ckeanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * typpo Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * batch more Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * thing * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * up[dates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixces Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> * images Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * empty * cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> * console log all the things Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * console log cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * nicer types Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logs Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-19 13:57:50 -07:00
// If we got a batch response, add all the inner responses.
let id = ws_resp.request_id();
match &ws_resp {
WebSocketResponse::Success(SuccessWebSocketResponse {
resp: OkWebSocketResponseData::ModelingBatch { responses },
..
}) =>
{
#[expect(
clippy::iter_over_hash_type,
reason = "modeling command uses a HashMap and keys are random, so we don't really have a choice"
)]
for (resp_id, batch_response) in responses {
let id: uuid::Uuid = (*resp_id).into();
match batch_response {
BatchResponse::Success { response } => {
responses_clone.write().await.insert(
id,
WebSocketResponse::Success(SuccessWebSocketResponse {
success: true,
request_id: Some(id),
resp: OkWebSocketResponseData::Modeling {
modeling_response: response.clone(),
},
}),
);
}
BatchResponse::Failure { errors } => {
responses_clone.write().await.insert(
id,
WebSocketResponse::Failure(FailureWebSocketResponse {
success: false,
request_id: Some(id),
errors: errors.clone(),
}),
);
}
}
get responses back from batch (#2687) * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove my stupid println Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * weird typescript Signed-off-by: Jess Frazelle <github@jessfraz.com> * better batch stuff; Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * ckeanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * typpo Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * batch more Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * thing * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * up[dates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixces Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> * images Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * empty * cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> * console log all the things Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * console log cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * nicer types Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logs Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-19 13:57:50 -07:00
}
}
WebSocketResponse::Success(SuccessWebSocketResponse {
resp: OkWebSocketResponseData::ModelingSessionData { session },
..
}) => {
let mut sd = session_data2.write().await;
sd.replace(session.clone());
}
return errors back to user (#4075) * Log any Errors to stderr This isn't perfect -- in fact, this is maybe not even very good at all, but it's better than what we have today. Currently, when we get an Erorr back from the WebSocket, we drop it in kcl-lib. The web-app logs these to the console (I can't find my commit doing that off the top of my head, but I remember doing it) -- so this is some degree of partity. This won't be very useful at all for wasm usage, but it will fix issues with the zoo cli silently breaking with a "WebSocket Closed" error -- which is the same issue I was solving for in the desktop app too. In the future perhaps this can be a real Error? I'm not totally sure yet, since we can't align to the request-id, so we can't really tie it to a specific call (yet). * add to responses Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * add a test Signed-off-by: Jess Frazelle <github@jessfraz.com> * clippy[ Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * empty * fix error Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * docs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
2024-10-03 01:05:12 -04:00
WebSocketResponse::Failure(FailureWebSocketResponse {
success: _,
request_id,
errors,
}) => {
if let Some(id) = request_id {
responses_clone.write().await.insert(
return errors back to user (#4075) * Log any Errors to stderr This isn't perfect -- in fact, this is maybe not even very good at all, but it's better than what we have today. Currently, when we get an Erorr back from the WebSocket, we drop it in kcl-lib. The web-app logs these to the console (I can't find my commit doing that off the top of my head, but I remember doing it) -- so this is some degree of partity. This won't be very useful at all for wasm usage, but it will fix issues with the zoo cli silently breaking with a "WebSocket Closed" error -- which is the same issue I was solving for in the desktop app too. In the future perhaps this can be a real Error? I'm not totally sure yet, since we can't align to the request-id, so we can't really tie it to a specific call (yet). * add to responses Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * add a test Signed-off-by: Jess Frazelle <github@jessfraz.com> * clippy[ Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * empty * fix error Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * docs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
2024-10-03 01:05:12 -04:00
*id,
WebSocketResponse::Failure(FailureWebSocketResponse {
success: false,
request_id: *request_id,
errors: errors.clone(),
}),
);
} else {
// Add it to our pending errors.
let mut pe = pending_errors_clone.write().await;
return errors back to user (#4075) * Log any Errors to stderr This isn't perfect -- in fact, this is maybe not even very good at all, but it's better than what we have today. Currently, when we get an Erorr back from the WebSocket, we drop it in kcl-lib. The web-app logs these to the console (I can't find my commit doing that off the top of my head, but I remember doing it) -- so this is some degree of partity. This won't be very useful at all for wasm usage, but it will fix issues with the zoo cli silently breaking with a "WebSocket Closed" error -- which is the same issue I was solving for in the desktop app too. In the future perhaps this can be a real Error? I'm not totally sure yet, since we can't align to the request-id, so we can't really tie it to a specific call (yet). * add to responses Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * add a test Signed-off-by: Jess Frazelle <github@jessfraz.com> * clippy[ Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * empty * fix error Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * docs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
2024-10-03 01:05:12 -04:00
for error in errors {
if !pe.contains(&error.message) {
pe.push(error.message.clone());
}
}
drop(pe);
return errors back to user (#4075) * Log any Errors to stderr This isn't perfect -- in fact, this is maybe not even very good at all, but it's better than what we have today. Currently, when we get an Erorr back from the WebSocket, we drop it in kcl-lib. The web-app logs these to the console (I can't find my commit doing that off the top of my head, but I remember doing it) -- so this is some degree of partity. This won't be very useful at all for wasm usage, but it will fix issues with the zoo cli silently breaking with a "WebSocket Closed" error -- which is the same issue I was solving for in the desktop app too. In the future perhaps this can be a real Error? I'm not totally sure yet, since we can't align to the request-id, so we can't really tie it to a specific call (yet). * add to responses Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * add a test Signed-off-by: Jess Frazelle <github@jessfraz.com> * clippy[ Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * empty * fix error Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * docs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
2024-10-03 01:05:12 -04:00
}
}
_ => {}
get responses back from batch (#2687) * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove my stupid println Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * weird typescript Signed-off-by: Jess Frazelle <github@jessfraz.com> * better batch stuff; Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * ckeanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * typpo Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * batch more Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * thing * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * up[dates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixces Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> * images Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * empty * cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> * console log all the things Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * console log cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * nicer types Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logs Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-19 13:57:50 -07:00
}
if let Some(id) = id {
responses_clone.write().await.insert(id, ws_resp.clone());
}
}
Err(e) => {
match &e {
WebSocketReadError::Read(e) => crate::logln!("could not read from WS: {:?}", e),
WebSocketReadError::Deser(e) => crate::logln!("could not deserialize msg from WS: {:?}", e),
}
*socket_health_tcp_read.write().await = SocketHealth::Inactive;
both edit and move in one PR (#566) * get the data for where lines are Signed-off-by: Jess Frazelle <github@jessfraz.com> * make pretty Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * new shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * beginning of stufff Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * add new fns Signed-off-by: Jess Frazelle <github@jessfraz.com> * basic function Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix ups to keep order Signed-off-by: Jess Frazelle <github@jessfraz.com> * further Signed-off-by: Jess Frazelle <github@jessfraz.com> * failing test Signed-off-by: Jess Frazelle <github@jessfraz.com> * do it in rust Signed-off-by: Jess Frazelle <github@jessfraz.com> * trait Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of ui integration Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * weird shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * generate close on close Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of constraint functions Signed-off-by: Jess Frazelle <github@jessfraz.com> * helper functions Signed-off-by: Jess Frazelle <github@jessfraz.com> * make work Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * constraints w ranges Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * skip Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * comment Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * throw Signed-off-by: Jess Frazelle <github@jessfraz.com> * make close a bit less sensitive in move scenario Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup shit we didnt end up using Signed-off-by: Jess Frazelle <github@jessfraz.com> * make it less hard to close Signed-off-by: Jess Frazelle <github@jessfraz.com> * Fix edit after sketch * Move to plane for sketch * Fix pathToNode for ast mods * Fix exit sketch mode with escape * Fix fmt since my editor did it wrong * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix link Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Adam Sunderland <adam@kittycad.io>
2023-09-17 21:57:43 -07:00
return Err(e);
}
}
}
});
Ok(EngineConnection {
engine_req_tx,
shutdown_tx,
tcp_read_handle: Arc::new(TcpReadHandle {
handle: Arc::new(tcp_read_handle),
}),
responses,
return errors back to user (#4075) * Log any Errors to stderr This isn't perfect -- in fact, this is maybe not even very good at all, but it's better than what we have today. Currently, when we get an Erorr back from the WebSocket, we drop it in kcl-lib. The web-app logs these to the console (I can't find my commit doing that off the top of my head, but I remember doing it) -- so this is some degree of partity. This won't be very useful at all for wasm usage, but it will fix issues with the zoo cli silently breaking with a "WebSocket Closed" error -- which is the same issue I was solving for in the desktop app too. In the future perhaps this can be a real Error? I'm not totally sure yet, since we can't align to the request-id, so we can't really tie it to a specific call (yet). * add to responses Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * add a test Signed-off-by: Jess Frazelle <github@jessfraz.com> * clippy[ Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * empty * fix error Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * docs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
2024-10-03 01:05:12 -04:00
pending_errors,
socket_health,
batch: Arc::new(RwLock::new(Vec::new())),
batch_end: Arc::new(RwLock::new(IndexMap::new())),
artifact_commands: Arc::new(RwLock::new(Vec::new())),
default_planes: Default::default(),
session_data,
execution_kind: Default::default(),
})
}
both edit and move in one PR (#566) * get the data for where lines are Signed-off-by: Jess Frazelle <github@jessfraz.com> * make pretty Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * new shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * beginning of stufff Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * add new fns Signed-off-by: Jess Frazelle <github@jessfraz.com> * basic function Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix ups to keep order Signed-off-by: Jess Frazelle <github@jessfraz.com> * further Signed-off-by: Jess Frazelle <github@jessfraz.com> * failing test Signed-off-by: Jess Frazelle <github@jessfraz.com> * do it in rust Signed-off-by: Jess Frazelle <github@jessfraz.com> * trait Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of ui integration Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * weird shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * generate close on close Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of constraint functions Signed-off-by: Jess Frazelle <github@jessfraz.com> * helper functions Signed-off-by: Jess Frazelle <github@jessfraz.com> * make work Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * constraints w ranges Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * skip Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * comment Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * throw Signed-off-by: Jess Frazelle <github@jessfraz.com> * make close a bit less sensitive in move scenario Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup shit we didnt end up using Signed-off-by: Jess Frazelle <github@jessfraz.com> * make it less hard to close Signed-off-by: Jess Frazelle <github@jessfraz.com> * Fix edit after sketch * Move to plane for sketch * Fix pathToNode for ast mods * Fix exit sketch mode with escape * Fix fmt since my editor did it wrong * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix link Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Adam Sunderland <adam@kittycad.io>
2023-09-17 21:57:43 -07:00
}
#[async_trait::async_trait]
both edit and move in one PR (#566) * get the data for where lines are Signed-off-by: Jess Frazelle <github@jessfraz.com> * make pretty Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * new shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * beginning of stufff Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * add new fns Signed-off-by: Jess Frazelle <github@jessfraz.com> * basic function Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix ups to keep order Signed-off-by: Jess Frazelle <github@jessfraz.com> * further Signed-off-by: Jess Frazelle <github@jessfraz.com> * failing test Signed-off-by: Jess Frazelle <github@jessfraz.com> * do it in rust Signed-off-by: Jess Frazelle <github@jessfraz.com> * trait Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of ui integration Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * weird shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * generate close on close Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of constraint functions Signed-off-by: Jess Frazelle <github@jessfraz.com> * helper functions Signed-off-by: Jess Frazelle <github@jessfraz.com> * make work Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * constraints w ranges Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * skip Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * comment Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * throw Signed-off-by: Jess Frazelle <github@jessfraz.com> * make close a bit less sensitive in move scenario Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup shit we didnt end up using Signed-off-by: Jess Frazelle <github@jessfraz.com> * make it less hard to close Signed-off-by: Jess Frazelle <github@jessfraz.com> * Fix edit after sketch * Move to plane for sketch * Fix pathToNode for ast mods * Fix exit sketch mode with escape * Fix fmt since my editor did it wrong * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix link Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Adam Sunderland <adam@kittycad.io>
2023-09-17 21:57:43 -07:00
impl EngineManager for EngineConnection {
fn batch(&self) -> Arc<RwLock<Vec<(WebSocketRequest, SourceRange)>>> {
Add batch support to current KCL implementation (#1871) * wip * wip * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * more batch shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * push up mods Signed-off-by: Jess Frazelle <github@jessfraz.com> * go back to batch id Signed-off-by: Jess Frazelle <github@jessfraz.com> * add unlocks back Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logging Signed-off-by: Jess Frazelle <github@jessfraz.com> * port to wasm Signed-off-by: Jess Frazelle <github@jessfraz.com> * use a trait Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * snapshojts Signed-off-by: Jess Frazelle <github@jessfraz.com> * artifact map fix Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove the blur Signed-off-by: Jess Frazelle <github@jessfraz.com> * hacks on hacks Signed-off-by: Jess Frazelle <github@jessfraz.com> * artifact map clean up * tweak * fix so extrudes work * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * start of id to source range infra Signed-off-by: Jess Frazelle <github@jessfraz.com> * basic map to ids and source ranges Signed-off-by: Jess Frazelle <github@jessfraz.com> * make typescript happy Signed-off-by: Jess Frazelle <github@jessfraz.com> * flush at end of exxecute Signed-off-by: Jess Frazelle <github@jessfraz.com> * small thing for flush Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger ci --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: 49lf <ircsurfer33@gmail.com> Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-23 15:45:55 -07:00
self.batch.clone()
}
fn batch_end(&self) -> Arc<RwLock<IndexMap<uuid::Uuid, (WebSocketRequest, SourceRange)>>> {
self.batch_end.clone()
}
fn responses(&self) -> Arc<RwLock<IndexMap<Uuid, WebSocketResponse>>> {
self.responses.clone()
Rust artifact graph (#5068) * Start porting artifact graph creation to Rust * Add most of artifact graph creation * Add handling loft command from recent PR * Refactor artifact merge code so that it errors when a new artifact type is added * Add sweep subtype * Finish implementation of build artifact graph * Fix wasm.ts to use new combined generated ts-rs file * Fix Rust lints * Fix lints * Fix up replacement code * Add artifact graph to WASM outcome * Add artifact graph to simulation test output * Add new artifact graph output snapshots * Fix wall field and reduce unreachable code * Change field order for subtype * Change subtype to be determined from the request, like the TS * Fix plane sweep_id * Condense code * Change ID types to be properly optional * Change to favor the new ID, the same as TS * Fix to make error impossible * Rename artifact type tag values to match TS * Fix name of field on Cap * Update outputs * Change to use Rust source range * Update output snapshots * Add conversion to mermaid mind map and add to snapshot tests * Add new mermaid mind map output * Add flowchart * Remove raw artifact graph from tests * Remove JSON artifact graph output * Update output file with header * Update output after adding flowchart * Fix flowchart to not have duplicate edges, one in each direction * Fix not not output duplicate edges in flowcharts * Change flowchart edge style to be more obvious when a direction is missing * Update output after deduplication of edges * Fix not not skip sketch-on-face artifacts * Add docs * Fix edge iteration order to be stable * Update output after fixing order * Port TS artifactGraph.test.ts tests to simulation tests * Add grouping segments and solid2ds with their path * Update output flowcharts since grouping paths * Remove TS artifactGraph tests * Remove unused d3 dependencies * Fix to track loft ID on paths * Add command ID to error messages * Move artifact graph test code to a separate file since it's a large file * Reduce function visibility * Remove TS artifact graph code * Fix spelling error with serde * Add TODO for edge cut consumed ID * Add comment about mermaid edge rank * Fix mermaid flowchart edge cuts to appear as children of their edges * Update output since fixing flowchart order * Fix to always build the artifact graph even when there's a KCL error * Add artifact graph to error output * Change optional ID merge to match TS * Remove redundant SourceRange definition * Remove Rust-flavored default source range function * Add helper for source range creation * Update doc comment for the website * Update docs after doc comment change * Fix to save engine responses in execution cache * Remove unused import * Fix to not call WASM function before beforeAll callback is run * Remove more unused imports
2025-01-17 14:34:36 -05:00
}
fn artifact_commands(&self) -> Arc<RwLock<Vec<ArtifactCommand>>> {
self.artifact_commands.clone()
}
async fn execution_kind(&self) -> ExecutionKind {
let guard = self.execution_kind.read().await;
*guard
}
async fn replace_execution_kind(&self, execution_kind: ExecutionKind) -> ExecutionKind {
let mut guard = self.execution_kind.write().await;
let original = *guard;
*guard = execution_kind;
original
}
Change artifact IDs to be stable across KCL executions (#4101) * Add ID generator to ExecState * Change default plane IDs to be hardcoded * Fix lint warning * Add exposing ID generator as output of executor * Change to use generated definition of ExecState in TS * Fix IdGenerator to use camel case in TS * Fix TS type errors * Add exposing id_generator parameter * Add using the previously generated ID generator * wip: Add display of feature tree in debug pane * Remove artifact graph augmentation * Change default planes to use id generator instead of hardcoded UUIDs * Fix to reuse previously generated IDs * Add e2e test * Change feature tree to be collapsed by default * Remove debug prints * Fix unit test to use execState * Fix type to be more general * Remove outdated comment * Update derive-docs output * Fix object display component to be more general * Remove unused ArtifactId type * Fix test to be less brittle * Remove codeRef and pathToNode from display * Fix to remove test.only Co-authored-by: Frank Noirot <frank@zoo.dev> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Move plane conversion code to be next to type * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)" This reverts commit 3455cc951b0add326eb986510a1f1e8190d44f70. * Rename file * Rename components and add doc comments * Revive the collapse button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Confirm * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Confirm * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Confirm --------- Co-authored-by: Frank Noirot <frank@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-10-09 19:38:40 -04:00
async fn default_planes(
&self,
id_generator: &mut IdGenerator,
source_range: SourceRange,
Change artifact IDs to be stable across KCL executions (#4101) * Add ID generator to ExecState * Change default plane IDs to be hardcoded * Fix lint warning * Add exposing ID generator as output of executor * Change to use generated definition of ExecState in TS * Fix IdGenerator to use camel case in TS * Fix TS type errors * Add exposing id_generator parameter * Add using the previously generated ID generator * wip: Add display of feature tree in debug pane * Remove artifact graph augmentation * Change default planes to use id generator instead of hardcoded UUIDs * Fix to reuse previously generated IDs * Add e2e test * Change feature tree to be collapsed by default * Remove debug prints * Fix unit test to use execState * Fix type to be more general * Remove outdated comment * Update derive-docs output * Fix object display component to be more general * Remove unused ArtifactId type * Fix test to be less brittle * Remove codeRef and pathToNode from display * Fix to remove test.only Co-authored-by: Frank Noirot <frank@zoo.dev> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Move plane conversion code to be next to type * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)" This reverts commit 3455cc951b0add326eb986510a1f1e8190d44f70. * Rename file * Rename components and add doc comments * Revive the collapse button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Confirm * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Confirm * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Confirm --------- Co-authored-by: Frank Noirot <frank@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-10-09 19:38:40 -04:00
) -> Result<DefaultPlanes, KclError> {
{
let opt = self.default_planes.read().await.as_ref().cloned();
if let Some(planes) = opt {
return Ok(planes);
}
} // drop the read lock
Change artifact IDs to be stable across KCL executions (#4101) * Add ID generator to ExecState * Change default plane IDs to be hardcoded * Fix lint warning * Add exposing ID generator as output of executor * Change to use generated definition of ExecState in TS * Fix IdGenerator to use camel case in TS * Fix TS type errors * Add exposing id_generator parameter * Add using the previously generated ID generator * wip: Add display of feature tree in debug pane * Remove artifact graph augmentation * Change default planes to use id generator instead of hardcoded UUIDs * Fix to reuse previously generated IDs * Add e2e test * Change feature tree to be collapsed by default * Remove debug prints * Fix unit test to use execState * Fix type to be more general * Remove outdated comment * Update derive-docs output * Fix object display component to be more general * Remove unused ArtifactId type * Fix test to be less brittle * Remove codeRef and pathToNode from display * Fix to remove test.only Co-authored-by: Frank Noirot <frank@zoo.dev> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Move plane conversion code to be next to type * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)" This reverts commit 3455cc951b0add326eb986510a1f1e8190d44f70. * Rename file * Rename components and add doc comments * Revive the collapse button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Confirm * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Confirm * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Confirm --------- Co-authored-by: Frank Noirot <frank@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-10-09 19:38:40 -04:00
let new_planes = self.new_default_planes(id_generator, source_range).await?;
*self.default_planes.write().await = Some(new_planes.clone());
Ok(new_planes)
}
Change artifact IDs to be stable across KCL executions (#4101) * Add ID generator to ExecState * Change default plane IDs to be hardcoded * Fix lint warning * Add exposing ID generator as output of executor * Change to use generated definition of ExecState in TS * Fix IdGenerator to use camel case in TS * Fix TS type errors * Add exposing id_generator parameter * Add using the previously generated ID generator * wip: Add display of feature tree in debug pane * Remove artifact graph augmentation * Change default planes to use id generator instead of hardcoded UUIDs * Fix to reuse previously generated IDs * Add e2e test * Change feature tree to be collapsed by default * Remove debug prints * Fix unit test to use execState * Fix type to be more general * Remove outdated comment * Update derive-docs output * Fix object display component to be more general * Remove unused ArtifactId type * Fix test to be less brittle * Remove codeRef and pathToNode from display * Fix to remove test.only Co-authored-by: Frank Noirot <frank@zoo.dev> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Move plane conversion code to be next to type * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)" This reverts commit 3455cc951b0add326eb986510a1f1e8190d44f70. * Rename file * Rename components and add doc comments * Revive the collapse button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Confirm * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Confirm * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Confirm --------- Co-authored-by: Frank Noirot <frank@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-10-09 19:38:40 -04:00
async fn clear_scene_post_hook(
&self,
id_generator: &mut IdGenerator,
source_range: SourceRange,
Change artifact IDs to be stable across KCL executions (#4101) * Add ID generator to ExecState * Change default plane IDs to be hardcoded * Fix lint warning * Add exposing ID generator as output of executor * Change to use generated definition of ExecState in TS * Fix IdGenerator to use camel case in TS * Fix TS type errors * Add exposing id_generator parameter * Add using the previously generated ID generator * wip: Add display of feature tree in debug pane * Remove artifact graph augmentation * Change default planes to use id generator instead of hardcoded UUIDs * Fix to reuse previously generated IDs * Add e2e test * Change feature tree to be collapsed by default * Remove debug prints * Fix unit test to use execState * Fix type to be more general * Remove outdated comment * Update derive-docs output * Fix object display component to be more general * Remove unused ArtifactId type * Fix test to be less brittle * Remove codeRef and pathToNode from display * Fix to remove test.only Co-authored-by: Frank Noirot <frank@zoo.dev> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Move plane conversion code to be next to type * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)" This reverts commit 3455cc951b0add326eb986510a1f1e8190d44f70. * Rename file * Rename components and add doc comments * Revive the collapse button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Confirm * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Confirm * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Confirm --------- Co-authored-by: Frank Noirot <frank@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-10-09 19:38:40 -04:00
) -> Result<(), KclError> {
// Remake the default planes, since they would have been removed after the scene was cleared.
Change artifact IDs to be stable across KCL executions (#4101) * Add ID generator to ExecState * Change default plane IDs to be hardcoded * Fix lint warning * Add exposing ID generator as output of executor * Change to use generated definition of ExecState in TS * Fix IdGenerator to use camel case in TS * Fix TS type errors * Add exposing id_generator parameter * Add using the previously generated ID generator * wip: Add display of feature tree in debug pane * Remove artifact graph augmentation * Change default planes to use id generator instead of hardcoded UUIDs * Fix to reuse previously generated IDs * Add e2e test * Change feature tree to be collapsed by default * Remove debug prints * Fix unit test to use execState * Fix type to be more general * Remove outdated comment * Update derive-docs output * Fix object display component to be more general * Remove unused ArtifactId type * Fix test to be less brittle * Remove codeRef and pathToNode from display * Fix to remove test.only Co-authored-by: Frank Noirot <frank@zoo.dev> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Move plane conversion code to be next to type * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)" This reverts commit 3455cc951b0add326eb986510a1f1e8190d44f70. * Rename file * Rename components and add doc comments * Revive the collapse button * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Confirm * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Confirm * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Confirm --------- Co-authored-by: Frank Noirot <frank@zoo.dev> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-10-09 19:38:40 -04:00
let new_planes = self.new_default_planes(id_generator, source_range).await?;
*self.default_planes.write().await = Some(new_planes);
Ok(())
}
Add batch support to current KCL implementation (#1871) * wip * wip * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * more batch shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * push up mods Signed-off-by: Jess Frazelle <github@jessfraz.com> * go back to batch id Signed-off-by: Jess Frazelle <github@jessfraz.com> * add unlocks back Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logging Signed-off-by: Jess Frazelle <github@jessfraz.com> * port to wasm Signed-off-by: Jess Frazelle <github@jessfraz.com> * use a trait Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * snapshojts Signed-off-by: Jess Frazelle <github@jessfraz.com> * artifact map fix Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove the blur Signed-off-by: Jess Frazelle <github@jessfraz.com> * hacks on hacks Signed-off-by: Jess Frazelle <github@jessfraz.com> * artifact map clean up * tweak * fix so extrudes work * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * start of id to source range infra Signed-off-by: Jess Frazelle <github@jessfraz.com> * basic map to ids and source ranges Signed-off-by: Jess Frazelle <github@jessfraz.com> * make typescript happy Signed-off-by: Jess Frazelle <github@jessfraz.com> * flush at end of exxecute Signed-off-by: Jess Frazelle <github@jessfraz.com> * small thing for flush Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger ci --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: 49lf <ircsurfer33@gmail.com> Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-23 15:45:55 -07:00
async fn inner_send_modeling_cmd(
&self,
id: uuid::Uuid,
source_range: SourceRange,
cmd: WebSocketRequest,
_id_to_source_range: HashMap<Uuid, SourceRange>,
get responses back from batch (#2687) * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove my stupid println Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * weird typescript Signed-off-by: Jess Frazelle <github@jessfraz.com> * better batch stuff; Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * ckeanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * typpo Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * batch more Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * thing * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * up[dates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixces Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> * images Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * empty * cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> * console log all the things Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * console log cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * nicer types Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logs Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-19 13:57:50 -07:00
) -> Result<WebSocketResponse, KclError> {
let (tx, rx) = oneshot::channel();
// Send the request to the engine, via the actor.
self.engine_req_tx
.send(ToEngineReq {
Add batch support to current KCL implementation (#1871) * wip * wip * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * more batch shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * push up mods Signed-off-by: Jess Frazelle <github@jessfraz.com> * go back to batch id Signed-off-by: Jess Frazelle <github@jessfraz.com> * add unlocks back Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logging Signed-off-by: Jess Frazelle <github@jessfraz.com> * port to wasm Signed-off-by: Jess Frazelle <github@jessfraz.com> * use a trait Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * snapshojts Signed-off-by: Jess Frazelle <github@jessfraz.com> * artifact map fix Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove the blur Signed-off-by: Jess Frazelle <github@jessfraz.com> * hacks on hacks Signed-off-by: Jess Frazelle <github@jessfraz.com> * artifact map clean up * tweak * fix so extrudes work * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * start of id to source range infra Signed-off-by: Jess Frazelle <github@jessfraz.com> * basic map to ids and source ranges Signed-off-by: Jess Frazelle <github@jessfraz.com> * make typescript happy Signed-off-by: Jess Frazelle <github@jessfraz.com> * flush at end of exxecute Signed-off-by: Jess Frazelle <github@jessfraz.com> * small thing for flush Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger ci --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: 49lf <ircsurfer33@gmail.com> Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-23 15:45:55 -07:00
req: cmd.clone(),
request_sent: tx,
})
both edit and move in one PR (#566) * get the data for where lines are Signed-off-by: Jess Frazelle <github@jessfraz.com> * make pretty Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * new shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * beginning of stufff Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * add new fns Signed-off-by: Jess Frazelle <github@jessfraz.com> * basic function Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix ups to keep order Signed-off-by: Jess Frazelle <github@jessfraz.com> * further Signed-off-by: Jess Frazelle <github@jessfraz.com> * failing test Signed-off-by: Jess Frazelle <github@jessfraz.com> * do it in rust Signed-off-by: Jess Frazelle <github@jessfraz.com> * trait Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of ui integration Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * weird shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * generate close on close Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of constraint functions Signed-off-by: Jess Frazelle <github@jessfraz.com> * helper functions Signed-off-by: Jess Frazelle <github@jessfraz.com> * make work Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * constraints w ranges Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * skip Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * comment Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * throw Signed-off-by: Jess Frazelle <github@jessfraz.com> * make close a bit less sensitive in move scenario Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup shit we didnt end up using Signed-off-by: Jess Frazelle <github@jessfraz.com> * make it less hard to close Signed-off-by: Jess Frazelle <github@jessfraz.com> * Fix edit after sketch * Move to plane for sketch * Fix pathToNode for ast mods * Fix exit sketch mode with escape * Fix fmt since my editor did it wrong * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix link Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Adam Sunderland <adam@kittycad.io>
2023-09-17 21:57:43 -07:00
.await
.map_err(|e| {
KclError::Engine(KclErrorDetails {
message: format!("Failed to send modeling command: {}", e),
source_ranges: vec![source_range],
})
})?;
// Wait for the request to be sent.
rx.await
.map_err(|e| {
KclError::Engine(KclErrorDetails {
message: format!("could not send request to the engine actor: {e}"),
source_ranges: vec![source_range],
})
})?
.map_err(|e| {
KclError::Engine(KclErrorDetails {
message: format!("could not send request to the engine: {e}"),
source_ranges: vec![source_range],
})
})?;
// Wait for the response.
let current_time = std::time::Instant::now();
while current_time.elapsed().as_secs() < 60 {
let guard = self.socket_health.read().await;
if *guard == SocketHealth::Inactive {
// Check if we have any pending errors.
let pe = self.pending_errors.read().await;
if !pe.is_empty() {
return Err(KclError::Engine(KclErrorDetails {
message: pe.join(", ").to_string(),
source_ranges: vec![source_range],
}));
} else {
return Err(KclError::Engine(KclErrorDetails {
message: "Modeling command failed: websocket closed early".to_string(),
source_ranges: vec![source_range],
}));
}
}
// We pop off the responses to cleanup our mappings.
if let Some(resp) = self.responses.write().await.shift_remove(&id) {
get responses back from batch (#2687) * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove my stupid println Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * weird typescript Signed-off-by: Jess Frazelle <github@jessfraz.com> * better batch stuff; Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * ckeanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * typpo Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * batch more Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * thing * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * up[dates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixces Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> * images Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * empty * cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> * console log all the things Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * console log cleanup Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * nicer types Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logs Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove logs Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-19 13:57:50 -07:00
return Ok(resp);
}
}
Err(KclError::Engine(KclErrorDetails {
message: format!("Modeling command timed out `{}`", id),
source_ranges: vec![source_range],
}))
}
async fn get_session_data(&self) -> Option<ModelingSessionData> {
self.session_data.read().await.clone()
}
async fn close(&self) {
let _ = self.shutdown_tx.send(()).await;
loop {
let guard = self.socket_health.read().await;
if *guard == SocketHealth::Inactive {
return;
}
}
}
}