diff --git a/src/channels/mod.rs b/src/channels/mod.rs index 748819f4a..b7d64ee76 100644 --- a/src/channels/mod.rs +++ b/src/channels/mod.rs @@ -294,6 +294,7 @@ struct InterruptOnNewMessageConfig { slack: bool, discord: bool, mattermost: bool, + matrix: bool, } impl InterruptOnNewMessageConfig { @@ -303,6 +304,7 @@ impl InterruptOnNewMessageConfig { "slack" => self.slack, "discord" => self.discord, "mattermost" => self.mattermost, + "matrix" => self.matrix, _ => false, } } @@ -4413,6 +4415,11 @@ pub async fn start_channels(config: Config) -> Result<()> { .mattermost .as_ref() .is_some_and(|mm| mm.interrupt_on_new_message); + let interrupt_on_new_message_matrix = config + .channels_config + .matrix + .as_ref() + .is_some_and(|mx| mx.interrupt_on_new_message); let runtime_ctx = Arc::new(ChannelRuntimeContext { channels_by_name, @@ -4443,6 +4450,7 @@ pub async fn start_channels(config: Config) -> Result<()> { slack: interrupt_on_new_message_slack, discord: interrupt_on_new_message_discord, mattermost: interrupt_on_new_message_mattermost, + matrix: interrupt_on_new_message_matrix, }, multimodal: config.multimodal.clone(), hooks: if config.hooks.enabled { @@ -4761,6 +4769,7 @@ mod tests { slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -4875,6 +4884,7 @@ mod tests { slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -4945,6 +4955,7 @@ mod tests { slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -5034,6 +5045,7 @@ mod tests { slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -5577,6 +5589,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, non_cli_excluded_tools: Arc::new(Vec::new()), autonomy_level: AutonomyLevel::default(), @@ -5656,6 +5669,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, non_cli_excluded_tools: Arc::new(Vec::new()), autonomy_level: AutonomyLevel::default(), @@ -5749,6 +5763,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -5827,6 +5842,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -5915,6 +5931,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -6024,6 +6041,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -6114,6 +6132,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -6219,6 +6238,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -6309,6 +6329,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -6389,6 +6410,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -6580,6 +6602,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -6680,6 +6703,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -6795,6 +6819,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: true, discord: false, mattermost: false, + matrix: false, }, ack_reactions: true, show_tool_calls: true, @@ -6907,6 +6932,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -7001,6 +7027,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -7079,6 +7106,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -7843,6 +7871,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -7972,6 +8001,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -8141,6 +8171,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -8245,6 +8276,7 @@ BTC is currently around $65,000 based on latest tool output."# slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -8814,6 +8846,7 @@ This is an example JSON object for profile settings."#; slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -8899,6 +8932,7 @@ This is an example JSON object for profile settings."#; slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -9059,6 +9093,7 @@ This is an example JSON object for profile settings."#; slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -9168,6 +9203,7 @@ This is an example JSON object for profile settings."#; slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -9269,6 +9305,7 @@ This is an example JSON object for profile settings."#; slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -9390,6 +9427,7 @@ This is an example JSON object for profile settings."#; slack: false, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, @@ -9520,6 +9558,7 @@ This is an example JSON object for profile settings."#; slack: false, discord: false, mattermost: true, + matrix: false, }; assert!(cfg.enabled_for_channel("mattermost")); } @@ -9531,6 +9570,7 @@ This is an example JSON object for profile settings."#; slack: false, discord: false, mattermost: false, + matrix: false, }; assert!(!cfg.enabled_for_channel("mattermost")); } @@ -9542,6 +9582,7 @@ This is an example JSON object for profile settings."#; slack: false, discord: true, mattermost: false, + matrix: false, }; assert!(cfg.enabled_for_channel("discord")); } @@ -9553,6 +9594,7 @@ This is an example JSON object for profile settings."#; slack: false, discord: false, mattermost: false, + matrix: false, }; assert!(!cfg.enabled_for_channel("discord")); } @@ -9644,6 +9686,7 @@ This is an example JSON object for profile settings."#; slack: true, discord: false, mattermost: false, + matrix: false, }, multimodal: crate::config::MultimodalConfig::default(), hooks: None, diff --git a/src/config/schema.rs b/src/config/schema.rs index 0ad6abdb5..f3ff7e105 100644 --- a/src/config/schema.rs +++ b/src/config/schema.rs @@ -4932,6 +4932,9 @@ pub struct MatrixConfig { pub room_id: String, /// Allowed Matrix user IDs. Empty = deny all. pub allowed_users: Vec, + /// Whether to interrupt an in-flight agent response when a new message arrives. + #[serde(default)] + pub interrupt_on_new_message: bool, } impl ChannelConfig for MatrixConfig { @@ -9768,6 +9771,7 @@ tool_dispatcher = "xml" device_id: Some("DEVICE123".into()), room_id: "!room123:matrix.org".into(), allowed_users: vec!["@user:matrix.org".into()], + interrupt_on_new_message: false, }; let json = serde_json::to_string(&mc).unwrap(); let parsed: MatrixConfig = serde_json::from_str(&json).unwrap(); @@ -9788,6 +9792,7 @@ tool_dispatcher = "xml" device_id: None, room_id: "!abc:synapse.local".into(), allowed_users: vec!["@admin:synapse.local".into(), "*".into()], + interrupt_on_new_message: false, }; let toml_str = toml::to_string(&mc).unwrap(); let parsed: MatrixConfig = toml::from_str(&toml_str).unwrap(); @@ -9877,6 +9882,7 @@ allowed_users = ["@ops:matrix.org"] device_id: None, room_id: "!r:m".into(), allowed_users: vec!["@u:m".into()], + interrupt_on_new_message: false, }), signal: None, whatsapp: None, diff --git a/src/integrations/registry.rs b/src/integrations/registry.rs index be88f9b1e..8ef7815b3 100644 --- a/src/integrations/registry.rs +++ b/src/integrations/registry.rs @@ -890,6 +890,7 @@ mod tests { device_id: None, room_id: "!r:m".into(), allowed_users: vec![], + interrupt_on_new_message: false, }); let entries = all_integrations(); let mx = entries.iter().find(|e| e.name == "Matrix").unwrap(); diff --git a/src/onboard/wizard.rs b/src/onboard/wizard.rs index 56f8cce24..70c80258c 100644 --- a/src/onboard/wizard.rs +++ b/src/onboard/wizard.rs @@ -4148,6 +4148,7 @@ fn setup_channels() -> Result { device_id: detected_device_id, room_id, allowed_users, + interrupt_on_new_message: false, }); } ChannelMenuChoice::Signal => {