"""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()