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(
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__(