huskies: merge 1163 story Replace perm_rx lock-as-presence-signal with a permission router
This commit is contained in:
@@ -32,8 +32,12 @@ pub(super) async fn handle_incoming_message(
|
||||
// If there is a pending permission prompt for this sender, interpret the
|
||||
// message as a yes/no response instead of starting a new command/LLM flow.
|
||||
{
|
||||
let mut pending = ctx.services.pending_perm_replies.lock().await;
|
||||
if let Some(tx) = pending.remove(sender) {
|
||||
if let Some(tx) = ctx
|
||||
.services
|
||||
.pending_perm_replies
|
||||
.resolve_oldest(sender)
|
||||
.await
|
||||
{
|
||||
let decision = if is_permission_approval(message) {
|
||||
PermissionDecision::Approve
|
||||
} else {
|
||||
@@ -279,7 +283,6 @@ mod tests {
|
||||
let (tx, _rx) = tokio::sync::broadcast::channel::<WatcherEvent>(16);
|
||||
let agents = Arc::new(AgentPool::new(3999, tx));
|
||||
let tracker = Arc::new(MessagingWindowTracker::new());
|
||||
let (_perm_tx, perm_rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
let services = Arc::new(crate::services::Services {
|
||||
project_root: tmp.path().to_path_buf(),
|
||||
status: agents.status_broadcaster(),
|
||||
@@ -287,8 +290,8 @@ mod tests {
|
||||
bot_name: "Bot".to_string(),
|
||||
bot_user_id: "whatsapp-bot".to_string(),
|
||||
ambient_rooms: Arc::new(std::sync::Mutex::new(Default::default())),
|
||||
perm_rx: Arc::new(tokio::sync::Mutex::new(perm_rx)),
|
||||
pending_perm_replies: Arc::new(tokio::sync::Mutex::new(Default::default())),
|
||||
permission_registry: crate::service::permission_router::ResponderRegistry::new(),
|
||||
pending_perm_replies: crate::service::permission_router::PendingPermReplies::new(),
|
||||
permission_timeout_secs: 120,
|
||||
chat_dispatcher: Arc::new(crate::chat::dispatcher::ChatDispatcher::new(1_500)),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user