The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(voice): extract capture shutdown into a reusable function
Steven Enamakel895c4b66b3ec
diff --git a/crates/openhuman-core/src/channels/runtime/mod.rs b/crates/openhuman-core/src/channels/runtime/mod.rsindex c9d1273f88..0121b5ce5d 100644--- a/crates/openhuman-core/src/channels/runtime/mod.rs+++ b/crates/openhuman-core/src/channels/runtime/mod.rs@@ -5,9 +5,9 @@ pub(crate) mod session;mod startup;mod supervision;+pub(crate) use startup::hydrate_channel_credentials;pub use startup::start_channels;pub(crate) use startup::start_channels_with_session;-pub(crate) use startup::hydrate_channel_credentials;// The hosted-channel relay (`channels::providers::relay`) runs one message// through the same pipeline, with a context built from the caller's config.pub(crate) use dispatch::process_channel_message;diff --git a/crates/openhuman-core/src/voice/always_on/processor.rs b/crates/openhuman-core/src/voice/always_on/processor.rsindex 05ccade37c..1b6003ff7b 100644--- a/crates/openhuman-core/src/voice/always_on/processor.rs+++ b/crates/openhuman-core/src/voice/always_on/processor.rs@@ -404,3 +404,7 @@ pub(super) fn spawn_transcription(}});}++#[cfg(test)]+#[path = "processor_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/voice/always_on/processor_tests.rs b/crates/openhuman-core/src/voice/always_on/processor_tests.rsnew file mode 100644index 0000000000..eb627ddd16--- /dev/null+++ b/crates/openhuman-core/src/voice/always_on/processor_tests.rs@@ -0,0 +1,46 @@+use super::*;++#[test]+fn core_shutdown_stops_and_joins_always_on_processing() {+ let output = std::process::Command::new(std::env::current_exe().unwrap())+ .args([+ "--ignored",+ "--exact",+ "voice::always_on::processor::tests::shutdown_fixture",+ "--nocapture",+ ])+ .output()+ .unwrap();+ assert!(+ output.status.success(),+ "shutdown fixture failed: {}{}",+ String::from_utf8_lossy(&output.stdout),+ String::from_utf8_lossy(&output.stderr)+ );+}++// A child process isolates the process-wide capture and processor state.+#[tokio::test]+#[ignore = "invoked by the isolated shutdown regression"]+async fn shutdown_fixture() {+ ENABLED.store(true, Ordering::SeqCst);+ let mut stopped = super::super::capture::stop_subscription();+ let joined = std::sync::Arc::new(AtomicBool::new(false));+ let completed = joined.clone();+ *PROCESSOR.lock().unwrap() = Some(tokio::spawn(async move {+ stopped.changed().await.unwrap();+ completed.store(true, Ordering::SeqCst);+ }));++ crate::voice::capture_lease::shutdown_capture().await;++ assert!(+ !ENABLED.load(Ordering::SeqCst),+ "shutdown must disable processing"+ );+ assert!(+ joined.load(Ordering::SeqCst),+ "shutdown must join the processor"+ );+ assert!(PROCESSOR.lock().unwrap().is_none());+}diff --git a/crates/openhuman-core/src/voice/capture_lease.rs b/crates/openhuman-core/src/voice/capture_lease.rsindex a9a14092e2..e2a5df134a 100644--- a/crates/openhuman-core/src/voice/capture_lease.rs+++ b/crates/openhuman-core/src/voice/capture_lease.rs@@ -374,12 +374,15 @@ fn register_shutdown() {return;}crate::core::shutdown::register(|| async {- HOOK.store(false, Ordering::SeqCst);- if let Err(error) = close_all().await {- log::warn!("[voice_capture] shutdown cleanup pending: {error}");- }+ shutdown_capture().await;});}+pub(crate) async fn shutdown_capture() {+ HOOK.store(false, Ordering::SeqCst);+ if let Err(error) = close_all().await {+ log::warn!("[voice_capture] shutdown cleanup pending: {error}");+ }+}#[cfg(test)]#[path = "capture_lease_tests.rs"]mod tests;