Skip to content

Commit c318b91

Browse files
committed
actually apply the refactor
1 parent 6241f73 commit c318b91

30 files changed

+642
-1479
lines changed

engine/Cargo.lock

Lines changed: 27 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

engine/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ members = [
2424
"sandbox",
2525
"llm-response-parser",
2626
"boundary-udf",
27-
"tokio-console-demo",
27+
"playground-server",
2828
"repro",
2929
]
3030
default-members = [
@@ -92,6 +92,7 @@ indoc = "2.0.5"
9292
internal-baml-codegen = { path = "language_client_codegen" }
9393
internal-baml-core = { path = "baml-lib/baml-core" }
9494
internal-baml-jinja = { path = "baml-lib/jinja-runtime" }
95+
playground-server = { path = "playground-server" }
9596
internal-llm-client = { path = "baml-lib/llm-client" }
9697
itertools = "0.14.0"
9798
jsonish = { path = "baml-lib/jsonish" }

engine/language_server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ baml-lsp-types = { path = "../baml-lsp-types" }
2323
internal-baml-core = { path = "../baml-lib/baml-core" }
2424
internal-baml-diagnostics = { path = "../baml-lib/diagnostics" }
2525
internal-baml-codegen = { workspace = true }
26+
playground-server = { workspace = true }
2627
crossbeam = { version = "0.8.4", features = ["crossbeam-channel"] }
2728
ignore = { version = "0.4.22" }
2829
parking_lot = { version = "0.12", features = ["deadlock_detection"] }

engine/language_server/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ pub use session::{ClientSettings, DocumentQuery, DocumentSnapshot, Session};
88
use tokio::sync::broadcast;
99

1010
use crate::{
11-
playground2::server::LangServerToWasmMessage,
1211
server::{Server, ServerArgs},
13-
session::PreSendToWasmMessage,
1412
};
13+
use playground_server::{LangServerToWasmMessage, PreSendToWasmMessage};
1514

1615
#[macro_use]
1716
mod message;
@@ -44,11 +43,15 @@ pub fn run_server() -> anyhow::Result<()> {
4443
let (broadcast_tx, broadcast_rx) = broadcast::channel(1000);
4544
let (playground_tx, playground_rx) = broadcast::channel(1000);
4645

47-
let port_picks = tokio_runtime.block_on(playground2::port_picker::pick())?;
46+
let port_config = playground2::PortConfiguration {
47+
base_port: 3700,
48+
max_attempts: 100,
49+
};
50+
let port_picks = tokio_runtime.block_on(playground2::port_picker_pick(port_config))?;
4851

4952
tokio_runtime.spawn(futures::future::join(
5053
playground2::Playground2Server {
51-
app_state: playground2::server::AppState {
54+
app_state: playground_server::AppState {
5255
broadcast_rx,
5356
playground_tx: playground_tx.clone(),
5457
playground_port: port_picks.playground_port,
Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,2 @@
1-
use std::collections::{HashMap, VecDeque};
2-
3-
use serde::{Deserialize, Serialize};
4-
use tokio::sync::broadcast;
5-
6-
// Note: the name add_project should match exactly to the
7-
// EventListener.tsx command definitions due to how serde serializes these into json
8-
#[allow(non_camel_case_types)]
9-
#[derive(Serialize, Deserialize, Debug, Clone)]
10-
#[serde(tag = "command", content = "content")]
11-
pub enum FrontendMessage {
12-
add_project {
13-
root_path: String,
14-
files: HashMap<String, String>,
15-
},
16-
remove_project {
17-
root_path: String,
18-
},
19-
select_function {
20-
root_path: String,
21-
function_name: String,
22-
},
23-
baml_settings_updated {
24-
settings: HashMap<String, String>,
25-
},
26-
run_test {
27-
function_name: String,
28-
test_name: String,
29-
},
30-
}
1+
// Use the shared FrontendMessage from playground-server
2+
pub use playground_server::FrontendMessage;
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
mod ping_handler;
2-
pub mod port_picker;
3-
pub mod proxy;
4-
pub mod server;
5-
mod websocket_rpc_handler;
6-
mod websocket_ws_handler;
1+
pub use playground_server::{
2+
PortConfiguration, PortPicks, pick_ports as port_picker_pick
3+
};
74

5+
mod proxy;
86
pub use proxy::ProxyServer;
7+
98
pub use server::Playground2Server;
9+
mod server;

0 commit comments

Comments
 (0)