From 3236d19e288469a7a1e634d1a809a8b3e4c6db4e Mon Sep 17 00:00:00 2001 From: fujie Date: Sat, 28 Feb 2026 14:35:53 +0800 Subject: [PATCH] fix(pipes): restore corrupted isinstance check + add frontend console debug tracing --- .../github-copilot-sdk/github_copilot_sdk.py | 67 ++++++++++++++++--- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/plugins/pipes/github-copilot-sdk/github_copilot_sdk.py b/plugins/pipes/github-copilot-sdk/github_copilot_sdk.py index cfc710d..83dac32 100644 --- a/plugins/pipes/github-copilot-sdk/github_copilot_sdk.py +++ b/plugins/pipes/github-copilot-sdk/github_copilot_sdk.py @@ -1248,6 +1248,16 @@ class Pipe: logger.info( f"[Copilot] Queued richui embed for '{safe_filename}', pending_embeds len={len(pending_embeds)}" ) + if __event_emitter__: + await __event_emitter__( + { + "type": "status", + "data": { + "description": f"📦 Queued richui embed: {safe_filename} (queue={len(pending_embeds)})", + "done": True, + }, + } + ) elif embed_type == "artifacts": artifacts_content = f"\n```html\n{embed_content}\n```\n" pending_embeds.append( @@ -1260,10 +1270,30 @@ class Pipe: logger.info( f"[Copilot] Queued artifacts embed for '{safe_filename}', content len={len(artifacts_content)}, pending_embeds len={len(pending_embeds)}" ) + if __event_emitter__: + await __event_emitter__( + { + "type": "status", + "data": { + "description": f"📦 Queued artifacts embed: {safe_filename} (content={len(artifacts_content)}, queue={len(pending_embeds)})", + "done": True, + }, + } + ) else: logger.warning( f"[Copilot] pending_embeds is None! Cannot queue embed for '{safe_filename}'" ) + if __event_emitter__: + await __event_emitter__( + { + "type": "status", + "data": { + "description": f"⚠️ pending_embeds is None for {safe_filename}", + "done": True, + }, + } + ) except Exception as e: logger.error(f"Failed to prepare HTML embed: {e}") @@ -3503,7 +3533,7 @@ class Pipe: result = input_data.get("result", "") # Logic to detect and move large files saved to /tmp - # Pattern: Saved to: /tmp/copilot_result_xxxx.txt + # Pattern: "Saved to: /tmp/copilot_result_xxxx.txt" import re import shutil @@ -5280,7 +5310,6 @@ class Pipe: is_done=True, ) - # Display tool result with improved formatting # --- TODO Sync Logic (File + DB) --- if tool_name == "update_todo" and result_type == "success": try: @@ -5679,14 +5708,36 @@ class Pipe: pass # 2. Emit UI components (richui or artifacts type) - logger.info( - f"[Copilot] IDLE: pending_embeds count={len(pending_embeds) if pending_embeds else 0}, types={[e.get('type') for e in pending_embeds] if pending_embeds else []}" - ) + _idle_dbg = f"IDLE: pending_embeds count={len(pending_embeds) if pending_embeds else 0}, types={[e.get('type') for e in pending_embeds] if pending_embeds else []}" + logger.info(f"[Copilot] {_idle_dbg}") + if __event_call__: + try: + await __event_call__( + { + "type": "execute", + "data": { + "code": f'console.debug("%c[Copilot IDLE] {_idle_dbg}", "color: #f59e0b;");' + }, + } + ) + except Exception: + pass if pending_embeds: for embed in pending_embeds: - logger.info( - f"[Copilot] IDLE: Processing embed type='{embed.get('type')}', filename='{embed.get('filename')}', content_len={len(embed.get('content', ''))}" - ) + _embed_dbg = f"Processing embed type='{embed.get('type')}', filename='{embed.get('filename')}', content_len={len(embed.get('content', ''))}" + logger.info(f"[Copilot] IDLE: {_embed_dbg}") + if __event_call__: + try: + await __event_call__( + { + "type": "execute", + "data": { + "code": f'console.debug("%c[Copilot IDLE] {_embed_dbg}", "color: #f59e0b;");' + }, + } + ) + except Exception: + pass if embed.get("type") in ["richui", "artifacts"]: # Status update await __event_emitter__(