From 45c23b1521f77628f9241137cd558640d67c3389 Mon Sep 17 00:00:00 2001 From: Satrio Ponco Sushadi <74602380+poncosh@users.noreply.github.com> Date: Tue, 6 Oct 2026 20:25:36 +0700 Subject: [PATCH] feat(explain): export explain plans to files --- .../components/explain/ExplainPlanDiagram.vue | 13 +- .../components/explain/ExplainPlanViewer.vue | 54 +++++- .../ExplainPlanViewer.export.spec.ts | 132 +++++++++++++++ apps/desktop/src/lib/diagram/planCanvas.ts | 15 ++ .../__tests__/explainPlanExport.spec.ts | 157 ++++++++++++++++++ .../__tests__/explainPlanSvgExport.spec.ts | 82 +++++++++ .../src/lib/export/diagramSvgExport.ts | 29 +--- .../src/lib/export/explainPlanExport.ts | 74 +++++++++ .../src/lib/export/explainPlanSvgExport.ts | 112 +++++++++++++ apps/desktop/src/lib/export/svgPrimitives.ts | 29 ++++ 10 files changed, 657 insertions(+), 40 deletions(-) create mode 100644 apps/desktop/src/components/explain/__tests__/ExplainPlanViewer.export.spec.ts create mode 100644 apps/desktop/src/lib/export/__tests__/explainPlanExport.spec.ts create mode 100644 apps/desktop/src/lib/export/__tests__/explainPlanSvgExport.spec.ts create mode 100644 apps/desktop/src/lib/export/explainPlanExport.ts create mode 100644 apps/desktop/src/lib/export/explainPlanSvgExport.ts create mode 100644 apps/desktop/src/lib/export/svgPrimitives.ts diff --git a/apps/desktop/src/components/explain/ExplainPlanDiagram.vue b/apps/desktop/src/components/explain/ExplainPlanDiagram.vue index 690e43dec9..49bcc2ef07 100644 --- a/apps/desktop/src/components/explain/ExplainPlanDiagram.vue +++ b/apps/desktop/src/components/explain/ExplainPlanDiagram.vue @@ -6,7 +6,7 @@ import { Button } from "@/components/ui/button"; import type { ExplainPlanNode } from "@/lib/diagram/explainPlan"; import { formatExplainPlanDetails } from "@/lib/diagram/explainPlan"; import type { PlanCanvasCategory, PlanCanvasNode } from "@/lib/diagram/planCanvas"; -import { buildPlanCanvas, edgeStrokeWidth, formatPlanRows, heatLevel, PLAN_CANVAS_GAP_X, PLAN_CANVAS_NODE_H, PLAN_CANVAS_NODE_W } from "@/lib/diagram/planCanvas"; +import { buildPlanCanvas, edgeStrokeWidth, formatPlanRows, heatLevel, PLAN_CATEGORY_COLORS, PLAN_CANVAS_GAP_X, PLAN_CANVAS_NODE_H, PLAN_CANVAS_NODE_W } from "@/lib/diagram/planCanvas"; const props = defineProps<{ nodes: ExplainPlanNode[]; @@ -15,16 +15,7 @@ const props = defineProps<{ const { t } = useI18n(); const CATEGORY_COLORS: Record = { - result: "#a78bfa", - sort: "#38bdf8", - join: "#f472b6", - tscan: "#fb923c", - iscan: "#34d399", - lookup: "#2dd4bf", - mat: "#94a3b8", - agg: "#c084fc", - xchg: "#facc15", - mod: "#f87171", + ...PLAN_CATEGORY_COLORS, other: "var(--muted-foreground)", }; diff --git a/apps/desktop/src/components/explain/ExplainPlanViewer.vue b/apps/desktop/src/components/explain/ExplainPlanViewer.vue index 6702135d27..2904644b9f 100644 --- a/apps/desktop/src/components/explain/ExplainPlanViewer.vue +++ b/apps/desktop/src/components/explain/ExplainPlanViewer.vue @@ -1,11 +1,15 @@