fix(pipes): restore corrupted isinstance check + add frontend console debug tracing

This commit is contained in:
fujie
2026-02-28 14:35:53 +08:00
parent 354c1eee6b
commit 3236d19e28

View File

@@ -1248,6 +1248,16 @@ class Pipe:
logger.info( logger.info(
f"[Copilot] Queued richui embed for '{safe_filename}', pending_embeds len={len(pending_embeds)}" 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": elif embed_type == "artifacts":
artifacts_content = f"\n```html\n{embed_content}\n```\n" artifacts_content = f"\n```html\n{embed_content}\n```\n"
pending_embeds.append( pending_embeds.append(
@@ -1260,10 +1270,30 @@ class Pipe:
logger.info( logger.info(
f"[Copilot] Queued artifacts embed for '{safe_filename}', content len={len(artifacts_content)}, pending_embeds len={len(pending_embeds)}" 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: else:
logger.warning( logger.warning(
f"[Copilot] pending_embeds is None! Cannot queue embed for '{safe_filename}'" 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: except Exception as e:
logger.error(f"Failed to prepare HTML embed: {e}") logger.error(f"Failed to prepare HTML embed: {e}")
@@ -3503,7 +3533,7 @@ class Pipe:
result = input_data.get("result", "") result = input_data.get("result", "")
# Logic to detect and move large files saved to /tmp # 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 re
import shutil import shutil
@@ -5280,7 +5310,6 @@ class Pipe:
is_done=True, is_done=True,
) )
# Display tool result with improved formatting
# --- TODO Sync Logic (File + DB) --- # --- TODO Sync Logic (File + DB) ---
if tool_name == "update_todo" and result_type == "success": if tool_name == "update_todo" and result_type == "success":
try: try:
@@ -5679,14 +5708,36 @@ class Pipe:
pass pass
# 2. Emit UI components (richui or artifacts type) # 2. Emit UI components (richui or artifacts type)
logger.info( _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 []}"
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 []}" 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: if pending_embeds:
for embed in pending_embeds: for embed in pending_embeds:
logger.info( _embed_dbg = f"Processing embed type='{embed.get('type')}', filename='{embed.get('filename')}', content_len={len(embed.get('content', ''))}"
f"[Copilot] IDLE: 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"]: if embed.get("type") in ["richui", "artifacts"]:
# Status update # Status update
await __event_emitter__( await __event_emitter__(