log
2026-06-25 7c4c956be0c3c4c2f76f181e356779003bc8f998
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import json
import os
import glob
 
session_file = '/Users/logchen/Documents/github/VideoClaw/video-claw/video-claw/backend/code/data/sessions/1782135655622.json'
 
with open(session_file, 'r', encoding='utf-8') as f:
    data = json.load(f)
 
changed = False
 
# Fix reference_generation
if "reference_generation" in data.get("artifacts", {}):
    scenes = data["artifacts"]["reference_generation"].get("scenes", [])
    for scene in scenes:
        if scene.get("status") == "running":
            # Check if there are files
            shot_id = scene["id"]
            scenes_dir = os.path.join('/Users/logchen/Documents/github/VideoClaw/video-claw/video-claw/backend/code/result/image/1782135655622/Scenes')
            pattern = os.path.join(scenes_dir, f"{shot_id}*.*")
            files = []
            for ext in ("jpg", "jpeg", "png", "webp", "bmp"):
                pattern = os.path.join(scenes_dir, f"{shot_id}*.{ext}")
                files.extend(glob.glob(pattern))
            
            if files:
                files = sorted(set(files), key=os.path.getmtime)
                # Map paths to relative or absolute as they are normally stored
                # reference_agent stores absolute paths? No, it uses os.path.join which might be relative
                # Let's see what is stored in selected:
                # 'code/result/image/1782135655622/Scenes/seg_02_01.jpg'
                
                # We need to construct relative path
                rel_files = []
                for f in files:
                    rel_files.append(f.replace('/Users/logchen/Documents/github/VideoClaw/video-claw/video-claw/backend/', ''))
                
                scene["versions"] = rel_files
                scene["selected"] = rel_files[-1]
                scene["status"] = "done"
            else:
                scene["status"] = "failed"
            changed = True
 
if changed:
    with open(session_file, 'w', encoding='utf-8') as f:
        json.dump(data, f, ensure_ascii=False, indent=2)
    print("Fixed!")
else:
    print("No changes needed.")