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

Callers

nothing calls this directly

Calls 1

run_with_callbackFunction · 0.85

Tested by

no test coverage detected