Fixing build/test errors in master/

This commit is contained in:
Timmy
2026-03-27 12:31:08 +00:00
parent 2dc77479ad
commit 02d08faaa2
2 changed files with 35 additions and 2349 deletions
+35 -47
View File
@@ -4,12 +4,12 @@
mod agent_log;
mod agents;
mod chat;
mod config;
mod http;
mod io;
mod llm;
pub mod log_buffer;
mod chat;
pub mod rebuild;
mod state;
mod store;
@@ -17,6 +17,7 @@ mod workflow;
mod worktree;
use crate::agents::AgentPool;
use crate::chat::transport::whatsapp::WhatsAppConversationHistory;
use crate::http::build_routes;
use crate::http::context::AppContext;
use crate::http::{remove_port_file, resolve_port, write_port_file};
@@ -116,17 +117,11 @@ async fn main() -> Result<(), std::io::Error> {
// directory. We do not create directories from the command line.
if let Some(ref path) = explicit_path {
if !path.exists() {
eprintln!(
"error: path does not exist: {}",
path.display()
);
eprintln!("error: path does not exist: {}", path.display());
std::process::exit(1);
}
if !path.is_dir() {
eprintln!(
"error: path is not a directory: {}",
path.display()
);
eprintln!("error: path is not a directory: {}", path.display());
std::process::exit(1);
}
}
@@ -276,24 +271,23 @@ async fn main() -> Result<(), std::io::Error> {
.filter(|cfg| cfg.transport == "whatsapp")
.map(|cfg| {
let provider = cfg.whatsapp_provider.clone();
let transport: Arc<dyn crate::chat::ChatTransport> =
if provider == "twilio" {
Arc::new(chat::transport::whatsapp::TwilioWhatsAppTransport::new(
cfg.twilio_account_sid.clone().unwrap_or_default(),
cfg.twilio_auth_token.clone().unwrap_or_default(),
cfg.twilio_whatsapp_number.clone().unwrap_or_default(),
))
} else {
let template_name = cfg
.whatsapp_notification_template
.clone()
.unwrap_or_else(|| "pipeline_notification".to_string());
Arc::new(chat::transport::whatsapp::WhatsAppTransport::new(
cfg.whatsapp_phone_number_id.clone().unwrap_or_default(),
cfg.whatsapp_access_token.clone().unwrap_or_default(),
template_name,
))
};
let transport: Arc<dyn crate::chat::ChatTransport> = if provider == "twilio" {
Arc::new(chat::transport::whatsapp::TwilioWhatsAppTransport::new(
cfg.twilio_account_sid.clone().unwrap_or_default(),
cfg.twilio_auth_token.clone().unwrap_or_default(),
cfg.twilio_whatsapp_number.clone().unwrap_or_default(),
))
} else {
let template_name = cfg
.whatsapp_notification_template
.clone()
.unwrap_or_else(|| "pipeline_notification".to_string());
Arc::new(chat::transport::whatsapp::WhatsAppTransport::new(
cfg.whatsapp_phone_number_id.clone().unwrap_or_default(),
cfg.whatsapp_access_token.clone().unwrap_or_default(),
template_name,
))
};
let bot_name = cfg
.display_name
.clone()
@@ -363,17 +357,16 @@ async fn main() -> Result<(), std::io::Error> {
// • WhatsApp: active senders are tracked at runtime in ambient_rooms.
// We keep the WhatsApp context Arc so we can read the rooms at shutdown.
// • Matrix: the bot task manages its own announcement via matrix_shutdown_tx.
let bot_shutdown_notifier: Option<Arc<BotShutdownNotifier>> =
if let Some(ref ctx) = slack_ctx {
let channels: Vec<String> = ctx.channel_ids.iter().cloned().collect();
Some(Arc::new(BotShutdownNotifier::new(
Arc::clone(&ctx.transport) as Arc<dyn crate::chat::ChatTransport>,
channels,
ctx.bot_name.clone(),
)))
} else {
None
};
let bot_shutdown_notifier: Option<Arc<BotShutdownNotifier>> = if let Some(ref ctx) = slack_ctx {
let channels: Vec<String> = ctx.channel_ids.iter().cloned().collect();
Some(Arc::new(BotShutdownNotifier::new(
Arc::clone(&ctx.transport) as Arc<dyn crate::chat::ChatTransport>,
channels,
ctx.bot_name.clone(),
)))
} else {
None
};
// Retain a reference to the WhatsApp context for shutdown notifications.
// At shutdown time we read ambient_rooms to get the current set of active senders.
let whatsapp_ctx_for_shutdown: Option<Arc<chat::transport::whatsapp::WhatsAppWebhookContext>> =
@@ -391,14 +384,13 @@ async fn main() -> Result<(), std::io::Error> {
if let Some(ref ctx) = whatsapp_ctx {
let transport = Arc::clone(&ctx.transport);
let bot_name = ctx.bot_name.clone();
let history = Arc::clone(&ctx.history);
let history: WhatsAppConversationHistory = Arc::clone(&ctx.history);
tokio::spawn(async move {
let senders: Vec<String> = history.lock().await.keys().cloned().collect();
if senders.is_empty() {
return;
}
let notifier =
crate::rebuild::BotShutdownNotifier::new(transport, senders, bot_name);
let notifier = crate::rebuild::BotShutdownNotifier::new(transport, senders, bot_name);
notifier.notify_startup().await;
});
}
@@ -410,8 +402,7 @@ async fn main() -> Result<(), std::io::Error> {
if channels.is_empty() {
return;
}
let notifier =
crate::rebuild::BotShutdownNotifier::new(transport, channels, bot_name);
let notifier = crate::rebuild::BotShutdownNotifier::new(transport, channels, bot_name);
notifier.notify_startup().await;
});
}
@@ -591,10 +582,7 @@ name = "coder"
#[test]
fn classify_help_short() {
assert_eq!(
classify_cli_args(&["-h".to_string()]),
CliDirective::Help
);
assert_eq!(classify_cli_args(&["-h".to_string()]), CliDirective::Help);
}
#[test]