From 0bc7753fba9b44d4caa5d12bc4075fd402aa689a Mon Sep 17 00:00:00 2001
From: hit-cxf <2024111082@stu.hit.edu.cn>
Date: Sun, 31 May 2026 22:40:38 +0800
Subject: [PATCH] Improve the orchestrator, set up a unified disk storage entry, and maintain global consistency in session state

---
 video-claw/video-claw/backend/api/services/project_helpers.py |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/video-claw/video-claw/backend/api/services/project_helpers.py b/video-claw/video-claw/backend/api/services/project_helpers.py
index 518cf10..fb70bef 100644
--- a/video-claw/video-claw/backend/api/services/project_helpers.py
+++ b/video-claw/video-claw/backend/api/services/project_helpers.py
@@ -1,4 +1,5 @@
 import asyncio
+import copy
 import json
 import queue
 import threading
@@ -131,9 +132,7 @@
                     break
 
             if await request.is_disconnected():
-                if on_disconnect:
-                    on_disconnect()
-                yield json.dumps({"type": "error", "content": "Client disconnected"}) + "\n"
+                workflow_engine.track_background_task(task)
                 return
 
         while not progress_events.empty():
@@ -145,11 +144,13 @@
 
         result = task.result()
         workflow_engine.save_session_to_disk(state.session_id)
+        with workflow_engine._state_lock:
+            status_snapshot = copy.deepcopy(state.status)
 
         payload = {
             "type": "stage_complete",
             "stage": stage,
-            "status": state.status,
+            "status": status_snapshot,
             "requires_intervention": result.get("requires_intervention", False),
             "openclaw": build_openclaw_message(stage, result),
         }

--
Gitblit v1.8.0