Fix double-encoded JSON in Plan JSON display

Parse nested plan_json field before displaying to avoid escaped newlines.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
giles
2026-01-11 08:19:40 +00:00
parent 25f7213741
commit 791fe31483

View File

@@ -1589,7 +1589,14 @@ async def run_plan_visualization(run_id: str, request: Request):
'''
# Add collapsible Plan JSON section
plan_json_str = json.dumps(plan_data, indent=2)
# Parse nested plan_json if present (it's double-encoded as a string)
display_plan = plan_data.copy()
if "plan_json" in display_plan and isinstance(display_plan["plan_json"], str):
try:
display_plan["plan_json"] = json.loads(display_plan["plan_json"])
except json.JSONDecodeError:
pass
plan_json_str = json.dumps(display_plan, indent=2)
# Escape HTML entities in JSON
plan_json_str = plan_json_str.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
content += f'''