huskies: merge 638_refactor_migrate_discord_transport_to_services_bundle

This commit is contained in:
dave
2026-04-25 19:28:50 +00:00
parent 33cb2bed3e
commit e4dd4bbe2c
3 changed files with 68 additions and 86 deletions
+3 -17
View File
@@ -565,7 +565,6 @@ async fn main() -> Result<(), std::io::Error> {
// bundle (AppContext + Matrix bot) and the webhook-based transports.
let perm_rx = Arc::new(tokio::sync::Mutex::new(perm_rx));
let perm_rx_for_whatsapp = Arc::clone(&perm_rx);
let perm_rx_for_discord = Arc::clone(&perm_rx);
// Capture project root, agents Arc, and reconciliation sender before ctx
// is consumed by build_routes.
@@ -688,10 +687,6 @@ async fn main() -> Result<(), std::io::Error> {
let transport = Arc::new(chat::transport::discord::DiscordTransport::new(
cfg.discord_bot_token.clone().unwrap_or_default(),
));
let bot_name = cfg
.display_name
.clone()
.unwrap_or_else(|| "Assistant".to_string());
let root = startup_root.clone().unwrap();
let history = chat::transport::discord::load_discord_history(&root);
let channel_ids: std::collections::HashSet<String> =
@@ -699,22 +694,13 @@ async fn main() -> Result<(), std::io::Error> {
let allowed_users: std::collections::HashSet<String> =
cfg.discord_allowed_users.iter().cloned().collect();
Arc::new(chat::transport::discord::DiscordContext {
services: Arc::clone(&services),
bot_token: cfg.discord_bot_token.clone().unwrap_or_default(),
transport,
project_root: root,
agents: Arc::clone(&startup_agents),
bot_name,
bot_user_id: "discord-bot".to_string(),
ambient_rooms: Arc::new(std::sync::Mutex::new(std::collections::HashSet::new())),
history: std::sync::Arc::new(tokio::sync::Mutex::new(history)),
history_size: cfg.history_size,
channel_ids,
allowed_users,
perm_rx: perm_rx_for_discord,
pending_perm_replies: Arc::new(tokio::sync::Mutex::new(
std::collections::HashMap::new(),
)),
permission_timeout_secs: cfg.permission_timeout_secs,
})
});
@@ -737,7 +723,7 @@ async fn main() -> Result<(), std::io::Error> {
Some(Arc::new(BotShutdownNotifier::new(
Arc::clone(&ctx.transport) as Arc<dyn crate::chat::ChatTransport>,
channels,
ctx.bot_name.clone(),
ctx.services.bot_name.clone(),
)))
} else {
None
@@ -783,7 +769,7 @@ async fn main() -> Result<(), std::io::Error> {
}
if let Some(ref ctx) = discord_ctx {
let transport = Arc::clone(&ctx.transport) as Arc<dyn crate::chat::ChatTransport>;
let bot_name = ctx.bot_name.clone();
let bot_name = ctx.services.bot_name.clone();
let channels: Vec<String> = ctx.channel_ids.iter().cloned().collect();
tokio::spawn(async move {
if channels.is_empty() {