Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix(cron): web run-now push routing

kdgmpw6819a5f726b6
diff --git a/jiuwenswarm/gateway/cron/scheduler.py b/jiuwenswarm/gateway/cron/scheduler.py
index 676fffaf20..f0edd708cf 100644
--- a/jiuwenswarm/gateway/cron/scheduler.py
+++ b/jiuwenswarm/gateway/cron/scheduler.py
@@ -1202,6 +1202,8 @@ class CronSchedulerService:
"run_id": state.run_id,
"push_at": state.push_at_iso,
"wake_at": state.wake_at_iso,
+ "exec_channel_id": state.exec_channel_id,
+ "exec_session_id": state.exec_session_id,
"is_placeholder": bool(is_placeholder),
"status": state.status,
},
diff --git a/tests/unit_tests/gateway/test_cron_scheduler.py b/tests/unit_tests/gateway/test_cron_scheduler.py
index d6b93f9d69..b477890ce2 100644
--- a/tests/unit_tests/gateway/test_cron_scheduler.py
+++ b/tests/unit_tests/gateway/test_cron_scheduler.py
@@ -513,6 +513,33 @@ class TestHandleEventStoreValidation:
content = _cron_published_content(handler.published[0])
assert content == "result: 9am now"
+ @pytest.mark.asyncio
+ async def test_web_push_update_includes_execution_session_id(self, tmp_path):
+ store_file = tmp_path / "cron_jobs.json"
+ store = CronJobStore(path=store_file)
+ job = await _create_one_job(store, targets="web")
+
+ handler = FakeMessageHandler()
+ svc = _make_scheduler(store, handler)
+ await svc.reload()
+
+ run_info = await svc.trigger_run_now_info(job.id)
+ run_id = run_info["run_id"]
+ state = svc.runs[run_id]
+ state.result_text = "web result"
+ state.status = "succeeded"
+
+ ev = _Event(at_ts=time.time(), seq=1, kind="push_update", job_id=job.id, run_id=run_id)
+ await svc.handle_event(ev)
+
+ assert len(handler.published) == 1
+ msg = handler.published[0]
+ cron = msg.payload["cron"]
+ assert msg.channel_id == "web"
+ assert msg.session_id is None
+ assert cron["exec_channel_id"] == "__cron__"
+ assert cron["exec_session_id"] == run_info["session_id"]
+
@pytest.mark.asyncio
async def test_wake_executes_normally_when_job_present(self, tmp_path):
store_file = tmp_path / "cron_jobs.json"