From 05ea50a8341318903dabdeede60b338aa3c054bb Mon Sep 17 00:00:00 2001 From: Haze <709547807@qq.com> Date: Mon, 15 Jun 2026 19:46:40 +0800 Subject: [PATCH] opt(cron): cron job status (#1125) --- electron/gateway/config-sync.ts | 8 + .../tasks/render-cron-run-live-status.md | 43 +++ src/components/layout/Sidebar.tsx | 1 + src/stores/chat.ts | 43 ++- src/stores/chat/cron-session-utils.ts | 30 +++ src/stores/gateway.ts | 26 +- tests/e2e/cron-run-live-status.spec.ts | 245 ++++++++++++++++++ tests/unit/cron-session-utils.test.ts | 76 ++++++ tests/unit/gateway-events.test.ts | 204 +++++++++++++++ 9 files changed, 665 insertions(+), 11 deletions(-) create mode 100644 harness/specs/tasks/render-cron-run-live-status.md create mode 100644 tests/e2e/cron-run-live-status.spec.ts create mode 100644 tests/unit/cron-session-utils.test.ts diff --git a/electron/gateway/config-sync.ts b/electron/gateway/config-sync.ts index eb32b060..1af6e139 100644 --- a/electron/gateway/config-sync.ts +++ b/electron/gateway/config-sync.ts @@ -638,6 +638,14 @@ export async function prepareGatewayLaunchContext(port: number): Promise` inside a sanitized login shell that strips ELECTRON_RUN_AS_NODE. + // Electron then treats the script as an app path and pops up "Unable to find + // Electron app at /const safe = new Set(...)". Turning the snapshot off + // avoids that broken spawn; exec tools fall back to the Gateway launch env. + OPENCLAW_EXEC_SHELL_SNAPSHOT: '0', }; // Ensure extension-specific packages (e.g. grammy from the telegram diff --git a/harness/specs/tasks/render-cron-run-live-status.md b/harness/specs/tasks/render-cron-run-live-status.md new file mode 100644 index 00000000..3f405c51 --- /dev/null +++ b/harness/specs/tasks/render-cron-run-live-status.md @@ -0,0 +1,43 @@ +--- +id: render-cron-run-live-status +title: Render live execution status for cron-triggered runs without a session switch +scenario: gateway-backend-communication +taskType: runtime-bridge +intent: When a scheduled (cron) job fires while the user is viewing that cron session, ClawX must render the live running state (Thinking indicator, Execution Graph, tool steps) in realtime. Today the Gateway streams runtime events under the run-scoped session key (agent::cron::run:) while the UI tracks the base cron key (agent::cron:), so events are dropped by strict session-key equality and the user must switch sessions to force a transcript reload. +touchedAreas: + - harness/specs/tasks/render-cron-run-live-status.md + - src/stores/chat/cron-session-utils.ts + - src/stores/chat.ts + - src/stores/gateway.ts + - src/components/layout/Sidebar.tsx + - tests/unit/cron-session-utils.test.ts + - tests/unit/gateway-events.test.ts + - tests/e2e/cron-run-live-status.spec.ts +expectedUserBehavior: + - When a cron job triggers while the user is viewing that cron session, the renderer adopts the run, surfaces the running/Thinking state, and renders the Execution Graph live from streamed runtime events. + - Runtime events whose sessionKey carries the run-scoped suffix are treated as belonging to the equivalent base cron session the user is viewing. + - When the cron run ends, the renderer reloads the transcript for the current session so the completed graph and final reply render without a manual session switch. + - Background :main heartbeat runs continue to NOT surface a Thinking indicator. + - Renderer continues to use Host events / api-client boundaries; no new direct IPC or Gateway HTTP calls are added. +requiredProfiles: + - fast + - comms +requiredRules: + - renderer-main-boundary + - backend-communication-boundary + - api-client-transport-policy + - host-events-fallback-policy + - gateway-readiness-policy +requiredTests: + - pnpm exec vitest run tests/unit/cron-session-utils.test.ts + - pnpm exec vitest run tests/unit/gateway-events.test.ts + - pnpm run typecheck +acceptance: + - A cron session-key equivalence helper treats the base cron key and its run-scoped variant as the same session. + - chat store handleChatEvent / handleRuntimeEvent apply cron run-scoped events to the equivalent base cron session currently in view. + - Cron sessions are treated as trackable inbound runs so run.started arms the running state, while :main heartbeats remain suppressed. + - gateway runtime-event dispatch reloads history for the current cron session on run end (and start) using equivalence rather than strict equality. + - Renderer does not add direct IPC calls or Gateway HTTP fetches outside the existing api-client / host-events path. +docs: + required: false +--- diff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsx index 70c82d82..a944f554 100644 --- a/src/components/layout/Sidebar.tsx +++ b/src/components/layout/Sidebar.tsx @@ -478,6 +478,7 @@ export function Sidebar() { ) : ( <>