fix(socket): intake-task now returns full task with id #206
2 changed files with 9 additions and 2 deletions
|
|
@ -1082,13 +1082,19 @@ async fn cmd_intake_task(
|
||||||
capabilities: Option<Vec<String>>,
|
capabilities: Option<Vec<String>>,
|
||||||
) -> ColibriResponse {
|
) -> ColibriResponse {
|
||||||
let caps = capabilities.unwrap_or_default();
|
let caps = capabilities.unwrap_or_default();
|
||||||
|
// Create the task immediately so the caller gets the ID back.
|
||||||
|
let task = match state.store.lock().unwrap().create_task(&title, description.as_deref()) {
|
||||||
|
Ok(t) => t,
|
||||||
|
Err(e) => return ColibriResponse::err(format!("create task failed: {e}")),
|
||||||
|
};
|
||||||
|
// Also queue for the scheduler tick to route to a capable agent.
|
||||||
let mut scheduler = state.scheduler.lock().await;
|
let mut scheduler = state.scheduler.lock().await;
|
||||||
scheduler.submit(crate::scheduler::TaskRequest {
|
scheduler.submit(crate::scheduler::TaskRequest {
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
required_capabilities: caps,
|
required_capabilities: caps,
|
||||||
});
|
});
|
||||||
ColibriResponse::ok(serde_json::json!({"status": "queued"}))
|
ColibriResponse::ok(serde_json::to_value(&task).unwrap_or_default())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn cmd_set_cost_mode(state: &SharedState, mode: String) -> ColibriResponse {
|
async fn cmd_set_cost_mode(state: &SharedState, mode: String) -> ColibriResponse {
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,8 @@ async fn scheduler_routes_intake_tasks_by_capability() {
|
||||||
r#"{"cmd":"intake-task","title":"scrub zroot","capabilities":["freebsd"]}"#,
|
r#"{"cmd":"intake-task","title":"scrub zroot","capabilities":["freebsd"]}"#,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
assert_eq!(fs_intake["data"]["status"].as_str(), Some("queued"));
|
// Intake now returns the full task (id + status), not just {"status":"queued"}.
|
||||||
|
assert!(fs_intake["data"]["id"].is_string(), "intake must return task id");
|
||||||
|
|
||||||
send_command(
|
send_command(
|
||||||
&socket_path,
|
&socket_path,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue