huskies: merge 1140 story One-shot project-rebuild chat command: rebuild image, swap container, reconnect, preserve state

This commit is contained in:
dave
2026-05-18 14:55:31 +00:00
parent 4aaf7dbdc6
commit b1dec36e1c
6 changed files with 738 additions and 2 deletions
@@ -225,6 +225,7 @@ pub(in crate::chat::transport::matrix::bot) async fn on_room_message(
"all_status",
"new",
"config",
"project-rebuild",
];
let stripped = crate::chat::util::strip_bot_mention(
@@ -404,6 +405,46 @@ pub(in crate::chat::transport::matrix::bot) async fn on_room_message(
return;
}
// In gateway mode, handle the `project-rebuild <name>` command to rebuild a
// project container and swap it without losing pipeline state.
if ctx.is_gateway()
&& let Some(rebuild_cmd) =
super::super::super::project_rebuild::extract_project_rebuild_command(
&user_message,
&ctx.services.bot_name,
ctx.matrix_user_id.as_str(),
)
{
slog!(
"[matrix-bot] Handling project-rebuild command from {sender}: name={:?} timeout={}s force={}",
rebuild_cmd.name,
rebuild_cmd.drain_timeout_secs,
rebuild_cmd.force,
);
let response = if let Some(ref store) = ctx.gateway_projects_store {
super::super::super::project_rebuild::handle_project_rebuild(
&rebuild_cmd.name,
rebuild_cmd.drain_timeout_secs,
rebuild_cmd.force,
store,
&ctx.services.project_root,
)
.await
} else {
"Gateway projects store unavailable — cannot rebuild project.".to_string()
};
let html = markdown_to_html(&response);
if let Ok(msg_id) = ctx
.transport
.send_message(&room_id_str, &response, &html)
.await
&& let Ok(event_id) = msg_id.parse()
{
ctx.bot_sent_event_ids.lock().await.insert(event_id);
}
return;
}
// Check for bot-level commands (help, status, ambient, …) before invoking
// the LLM. All commands are registered in commands.rs — no special-casing
// needed here.