MCPcopy Create free account
hub / github.com/codename-co/stack / run

Function run

packages/app/src-tauri/src/api.rs:32–60  ·  view source on GitHub ↗
(input: web::Json<RunInput>)

Source from the content-addressed store, hash-verified

30
31#[post("/run")]
32async fn run(input: web::Json<RunInput>) -> HttpResponse {
33 let slug = input.slug.clone();
34 log::info!("Opening stack file: {:#?}", slug);
35 println!("Running {}!", slug);
36
37 // Create a channel for streaming output
38 let (tx, mut rx) = tokio::sync::mpsc::channel(100);
39
40 // Spawn the CLI command in a separate task
41 tokio::spawn(async move {
42 let output_callback = Box::new(move |line: String| {
43 let tx = tx.clone();
44 tokio::spawn(async move {
45 let _ = tx.send(line).await;
46 });
47 });
48
49 cli::run_with_callback(&slug, output_callback).await;
50 });
51
52 // Create a streaming response
53 HttpResponse::Ok()
54 .content_type("text/event-stream")
55 .streaming(Box::pin(async_stream::stream! {
56 while let Some(line) = rx.recv().await {
57 yield Ok::<_, actix_web::Error>(web::Bytes::from(format!("{}\n", line)));
58 }
59 }))
60}
61
62#[actix_web::main]
63pub async fn init(tauri: AppHandle) -> std::io::Result<()> {

Callers

nothing calls this directly

Calls 1

run_with_callbackFunction · 0.85

Tested by

no test coverage detected