Skip to content

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

feat(notifications): add rpc handlers for desktop notifications

Steven Enamakele71090d0746a
diff --git a/crates/openhuman-core/src/desktop/notifications/rpc.rs b/crates/openhuman-core/src/desktop/notifications/rpc.rs
index 2468f4b99f..8a310f6fed 100644
--- a/crates/openhuman-core/src/desktop/notifications/rpc.rs
+++ b/crates/openhuman-core/src/desktop/notifications/rpc.rs
@@ -89,6 +89,7 @@ pub async fn handle_ingest(ctx: &DispatchCtx, params: Map<String, Value>) -> Res
// Spawn background triage — the ingest RPC returns immediately.
let id_for_triage = id.clone();
let config_for_triage = config.clone();
+ let ctx = ctx.clone();
crate::core::runtime::spawn_scoped(async move {
let envelope = TriggerEnvelope {
source: TriggerSource::WebviewIntegration {
@@ -109,7 +110,7 @@ pub async fn handle_ingest(ctx: &DispatchCtx, params: Map<String, Value>) -> Res
received_at: ingest_started_at,
};
- match run_triage(&envelope).await {
+ match run_triage(&ctx, &envelope).await {
Ok(TriageOutcome::Decision(triage_run)) => {
let action = triage_run.decision.action.as_str().to_string();
let reason = triage_run.decision.reason.clone();
@@ -184,7 +185,7 @@ pub async fn handle_ingest(ctx: &DispatchCtx, params: Map<String, Value>) -> Res
// (#5634).
let origin = local_trigger_origin();
if let Err(e) =
- with_origin(origin, apply_decision(triage_run, &envelope)).await
+ with_origin(origin, apply_decision(&ctx, triage_run, &envelope)).await
{
tracing::warn!(
id = %id_for_triage,
diff --git a/crates/openhuman-core/src/integrations/task_sources/route.rs b/crates/openhuman-core/src/integrations/task_sources/route.rs
index 8f023cfdbc..9bef16a755 100644
--- a/crates/openhuman-core/src/integrations/task_sources/route.rs
+++ b/crates/openhuman-core/src/integrations/task_sources/route.rs
@@ -51,6 +51,8 @@ pub async fn route_enriched(
async fn dispatch_triage(source: &TaskSource, enriched: &EnrichedTask) -> Result<(), String> {
// Respect background-AI throttling. When the gate denies capacity
// (Off / paused), we keep the card but skip the proactive turn.
+ // Entry point of a scheduler-driven turn: bind the calling task's context once.
+ let ctx = crate::core::runtime::DispatchCtx::ambient();
let Some(_permit) = scheduler_gate::wait_for_capacity().await else {
tracing::info!(
source_id = %source.id,
@@ -76,7 +78,7 @@ async fn dispatch_triage(source: &TaskSource, enriched: &EnrichedTask) -> Result
payload,
);
- let outcome = run_triage(&envelope)
+ let outcome = run_triage(&ctx, &envelope)
.await
.map_err(|e| format!("[task_sources:route] triage evaluation failed: {e}"))?;
@@ -85,7 +87,7 @@ async fn dispatch_triage(source: &TaskSource, enriched: &EnrichedTask) -> Result
// Remote payload: the task arrived from an external board, so the
// dispatch parks rather than running on a trust root (#5634).
let origin = remote_trigger_origin(&envelope);
- with_origin(origin, apply_decision(run, &envelope))
+ with_origin(origin, apply_decision(&ctx, run, &envelope))
.await
.map_err(|e| format!("[task_sources:route] apply_decision failed: {e}"))?;
tracing::debug!(