Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(core): prevent duplicate event handler registration

Steven Enamakel45d64b5543c8
diff --git a/crates/openhuman-core/src/core/bus.rs b/crates/openhuman-core/src/core/bus.rs
index ce6932c8b0..33908f1a9c 100644
--- a/crates/openhuman-core/src/core/bus.rs
+++ b/crates/openhuman-core/src/core/bus.rs
@@ -72,7 +72,7 @@ pub const EVENTS_INTERFACE: &str = "ai.tinyhumans.openhuman.Events";
/// (`request_id`), the new `ThreadTodosChanged` and `ThreadRunModeChanged`
/// variants. All additions are optional/defaulted, so an older subscriber
/// keeps parsing what a newer publisher emits.
-pub const EVENTS_VERSION: Version = Version::new(1, 4, 0);
+pub const EVENTS_VERSION: Version = Version::new(1, 5, 0);
/// The bus. Initialised once by [`init`]; safe to touch before that.
pub static BUS: OnceBus<DomainEvent> = OnceBus::new();
diff --git a/crates/openhuman-core/src/core/events.rs b/crates/openhuman-core/src/core/events.rs
index 83bb93fda2..de34f5b5be 100644
--- a/crates/openhuman-core/src/core/events.rs
+++ b/crates/openhuman-core/src/core/events.rs
@@ -1432,6 +1432,14 @@ pub enum DomainEvent {
/// never to Sentry or the UI verbatim.
SessionExpired { source: String, reason: String },
+ /// The backend credential this core holds was stored, replaced or
+ /// cleared (`auth.set_credential` / `auth.clear_credential`, including the
+ /// teardown after `SessionExpired`). `kind` is `session`, `api_key`,
+ /// `local` or `cleared` — never the credential itself. Subscribers that
+ /// cache credential-derived state (the search module's managed routes)
+ /// refresh on it.
+ CredentialChanged { kind: String },
+
// ── Voice ────────────────────────────────────────────────────────────
/// A voice domain event (PTT, transcription lifecycle, etc.).
Voice(VoiceEvent),
@@ -1623,7 +1631,9 @@ impl DomainEvent {
Self::KeyringConsentRequired | Self::KeyringDecryptFailed { .. } => "keyring",
- Self::SessionExpired { .. } | Self::ProviderApiKeyRejected { .. } => "auth",
+ Self::SessionExpired { .. }
+ | Self::CredentialChanged { .. }
+ | Self::ProviderApiKeyRejected { .. } => "auth",
Self::TaskSourceFetched { .. }
| Self::TaskSourceTaskIngested { .. }
@@ -1765,6 +1775,7 @@ impl DomainEvent {
Self::KeyringConsentRequired => "KeyringConsentRequired",
Self::KeyringDecryptFailed { .. } => "KeyringDecryptFailed",
Self::SessionExpired { .. } => "SessionExpired",
+ Self::CredentialChanged { .. } => "CredentialChanged",
Self::ApprovalRequested { .. } => "ApprovalRequested",
Self::ApprovalDecided { .. } => "ApprovalDecided",
Self::FlowApprovalRequested { .. } => "FlowApprovalRequested",