File size: 1,038 Bytes
e412b9c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Patch sse-chat-transport.ts - handle task_incomplete event."""

SSE_TRANSPORT = "/source/frontend/src/lib/sse-chat-transport.ts"

def patch():
    import os
    if not os.path.exists(SSE_TRANSPORT):
        print(f"SKIP: {SSE_TRANSPORT} not found")
        return
        
    with open(SSE_TRANSPORT, "r", encoding="utf-8") as f:
        content = f.read()
    
    # Add task_incomplete case in createEventToChunkStream
    if "case 'task_incomplete'" not in content:
        task_incomplete_case = '''      case 'task_incomplete':
          sideChannel.onTaskIncomplete(
            (event.data?.incomplete_plan as Array<{ id: string; content: string; status: string }>) || [],
          );
          break;
'''
        content = content.replace(
            "case 'turn_complete':",
            task_incomplete_case + "\n        case 'turn_complete':"
        )
    
    with open(SSE_TRANSPORT, "w", encoding="utf-8") as f:
        f.write(content)
    print(f"OK: Patched {SSE_TRANSPORT}")

if __name__ == "__main__":
    patch()