Mnovich/temporal foreground tasks (#2895)

Co-authored-by: Carlos M. Lopez <carlopez@squareup.com>
This commit is contained in:
Max Novich
2025-06-20 16:19:58 -07:00
committed by GitHub
parent b3aed4bc11
commit 180b1df25d
58 changed files with 4009 additions and 1920 deletions
+7 -2
View File
@@ -40,6 +40,7 @@ struct ChatRequest {
messages: Vec<Message>,
session_id: Option<String>,
session_working_dir: String,
scheduled_job_id: Option<String>,
}
pub struct SseResponse {
@@ -181,7 +182,8 @@ async fn handler(
Some(SessionConfig {
id: session::Identifier::Name(session_id.clone()),
working_dir: PathBuf::from(session_working_dir),
schedule_id: None,
schedule_id: request.scheduled_job_id.clone(),
execution_mode: None,
}),
)
.await
@@ -303,6 +305,7 @@ struct AskRequest {
prompt: String,
session_id: Option<String>,
session_working_dir: String,
scheduled_job_id: Option<String>,
}
#[derive(Debug, Serialize)]
@@ -339,7 +342,8 @@ async fn ask_handler(
Some(SessionConfig {
id: session::Identifier::Name(session_id.clone()),
working_dir: PathBuf::from(session_working_dir),
schedule_id: None,
schedule_id: request.scheduled_job_id.clone(),
execution_mode: None,
}),
)
.await
@@ -578,6 +582,7 @@ mod tests {
prompt: "test prompt".to_string(),
session_id: Some("test-session".to_string()),
session_working_dir: "test-working-dir".to_string(),
scheduled_job_id: None,
})
.unwrap(),
))
@@ -19,6 +19,8 @@ pub struct CreateScheduleRequest {
id: String,
recipe_source: String,
cron: String,
#[serde(default)]
execution_mode: Option<String>, // "foreground" or "background"
}
#[derive(Deserialize, Serialize, utoipa::ToSchema)]
@@ -124,6 +126,7 @@ async fn create_schedule(
paused: false,
current_session_id: None,
process_start_time: None,
execution_mode: req.execution_mode.or(Some("background".to_string())), // Default to background
};
scheduler
.add_scheduled_job(job.clone())