feat: 合并debug样式优化

This commit is contained in:
ai-business-hql
2025-07-23 17:35:33 +08:00
parent 0a9d22c822
commit eb17fb76a1
12 changed files with 611 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
function getImportPath(filename) {
return `./${filename}`;
}
import{j as e}from"./vendor-markdown-CBmlBP6m.js";import{r as g}from"./vendor-react-Dixhfmvb.js";import{B as k,W as f,a as u,g as b}from"./message-components-CUhQ_OMh.js";const D=({checkpointId:l,onRestore:x})=>{const[i,c]=g.useState(!1),o=async()=>{if(!i){c(!0);try{const r=await f.restoreWorkflowCheckpoint(l),d=r.workflow_data_ui||r.workflow_data;d&&(r.workflow_data_ui?u.loadGraphData(d):u.loadApiJson(d),console.log(`Restored workflow checkpoint ${l}`),x())}catch(r){console.error("Failed to restore checkpoint:",r),alert("Failed to restore workflow checkpoint. Please try again.")}finally{c(!1)}}};return e.jsx("button",{onClick:o,disabled:i,className:`p-1 rounded transition-colors ${i?"text-gray-400 cursor-not-allowed":"text-gray-500 hover:text-blue-600 hover:bg-blue-50"}`,title:`Restore checkpoint ${l}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",className:i?"animate-spin":"",children:[e.jsx("path",{d:"M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 .908-.417A6 6 0 1 1 8 2v1z"}),e.jsx("path",{d:"M8 4.466V2.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384L8.41 6.658A.25.25 0 0 1 8 6.466z"})]})})};function R({content:l,name:x="Assistant",avatar:i,onAddMessage:c}){const[o,r]=g.useState(!1),[d,h]=g.useState(""),[y,p]=g.useState(!1),[m,j]=g.useState(null);let w;try{w=JSON.parse(l)}catch(t){return console.error("Failed to parse message content:",t),null}const v=async()=>{if(!o){r(!0),p(!0),h(`🔍 Starting workflow analysis...
`);try{await N(),await S()}finally{r(!1)}}},N=async()=>{try{const t=await u.graphToPrompt(),s=localStorage.getItem("sessionId")||"";if(s&&t){const a=await f.saveWorkflowCheckpoint(s,t.output,t.workflow,"debug_start");j(a.version_id),console.log(`Saved debug start checkpoint: ${a.version_id}`)}}catch(t){console.error("Failed to save checkpoint before debug:",t)}},S=async()=>{try{const t=await u.graphToPrompt();let s="",a=null;for await(const n of f.streamDebugAgent(t))n.text&&(s=n.text,h(s),n.ext&&(a=n.ext));if(p(!1),s){const n={id:b(),role:"ai",content:JSON.stringify({text:s,ext:a||[]}),format:"markdown",name:"Assistant"};c?.(n)}}catch(t){console.error("Error calling debug agent:",t),p(!1);const s=t,a={id:b(),role:"ai",content:JSON.stringify({text:`I encountered an error while analyzing your workflow: ${s.message||"Unknown error"}`,ext:[]}),format:"markdown",name:"Assistant"};c?.(a)}};return e.jsxs("div",{className:"w-full space-y-4",children:[e.jsx(k,{name:x,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("p",{className:"text-gray-700 text-sm flex-1",children:w.text}),m&&e.jsx("div",{className:"ml-2 flex-shrink-0",children:e.jsx(D,{checkpointId:m,onRestore:()=>{console.log("Workflow restored from checkpoint")}})})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx("button",{onClick:v,disabled:o,className:`px-4 py-2 text-white text-sm rounded-md transition-colors ${o?"bg-gray-400 cursor-not-allowed":"bg-blue-500 hover:bg-blue-600"}`,children:o?"Analyzing...":"Debug Errors"})})]})}),y&&e.jsx(k,{name:"Assistant",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"prose prose-sm max-w-none",children:e.jsx("pre",{className:"whitespace-pre-wrap text-gray-700 text-sm leading-relaxed",children:d})}),o&&e.jsxs("div",{className:"flex items-center gap-2 text-blue-500 text-sm",children:[e.jsx("div",{className:"animate-spin h-4 w-4 border-2 border-blue-500 border-t-transparent rounded-full"}),"Analyzing workflow..."]})]})})]})}export{R as DebugGuide};
+4
View File
@@ -0,0 +1,4 @@
function getImportPath(filename) {
return `./${filename}`;
}
import{j as e}from"./vendor-markdown-CBmlBP6m.js";import{r as p}from"./vendor-react-Dixhfmvb.js";import{B as x,W as h,a as i}from"./message-components-CUhQ_OMh.js";const m=({checkpointId:s,onRestore:c})=>{const[a,n]=p.useState(!1),o=async()=>{if(!a){n(!0);try{const t=await h.restoreWorkflowCheckpoint(s),l=t.workflow_data_ui||t.workflow_data;l&&(t.workflow_data_ui?i.loadGraphData(l):i.loadApiJson(l),console.log(`Restored workflow checkpoint ${s}`),c())}catch(t){console.error("Failed to restore checkpoint:",t),alert("Failed to restore workflow checkpoint. Please try again.")}finally{n(!1)}}};return e.jsx("button",{onClick:o,disabled:a,className:`p-1 rounded transition-colors ${a?"text-gray-400 cursor-not-allowed":"text-gray-500 hover:text-blue-600 hover:bg-blue-50"}`,title:`Restore checkpoint ${s}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",className:a?"animate-spin":"",children:[e.jsx("path",{d:"M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 .908-.417A6 6 0 1 1 8 2v1z"}),e.jsx("path",{d:"M8 4.466V2.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384L8.41 6.658A.25.25 0 0 1 8 6.466z"})]})})};function w({content:s,name:c="Assistant",avatar:a,format:n="markdown"}){let o,t=null;try{if(o=JSON.parse(s),o.ext){const r=o.ext.find(d=>d.type==="debug_checkpoint");r&&r.data&&r.data.checkpoint_id&&(t=r.data.checkpoint_id)}}catch(r){return console.error("Failed to parse DebugResult content:",r),null}const l=r=>n==="markdown"?r.replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/`(.*?)`/g,'<code class="bg-gray-100 px-1 rounded">$1</code>').replace(/\n/g,"<br/>"):r;return e.jsx(x,{name:c,children:e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("div",{className:"flex-1 prose prose-sm max-w-none",children:n==="markdown"?e.jsx("div",{className:"text-gray-700 text-sm leading-relaxed",dangerouslySetInnerHTML:{__html:l(o.text||"")}}):e.jsx("pre",{className:"whitespace-pre-wrap text-gray-700 text-sm leading-relaxed",children:o.text||""})}),t&&e.jsx("div",{className:"ml-2 flex-shrink-0",children:e.jsx(m,{checkpointId:t,onRestore:()=>{console.log("Workflow restored from debug completion checkpoint")}})})]})})})}export{w as DebugResult};
File diff suppressed because one or more lines are too long
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Generated by IcoMoon</metadata>
<defs>
<font id="cc-icon-logo" horiz-adv-x="1024">
<font-face units-per-em="1024" ascent="960" descent="-64" />
<missing-glyph horiz-adv-x="1024" />
<glyph unicode="&#x20;" horiz-adv-x="512" d="" />
<glyph unicode="&#xe900;" glyph-name="cc-icon-logo" horiz-adv-x="1673"
d="M953.240 271.522c7.894-6.874 12.965-16.634 19.585-24.709 11.100-13.542 23.393-25.939 36.892-37.094 56.683-46.839 134.714-63.303 205.904-46.280 36.563 8.744 71.347 27.153 98.834 52.889 6.503 6.089 26.996 19.767 21.187 30.485-9.427 17.396-31.912 31.962-45.898 45.893-4.414 4.397-10.841 13.638-17.632 14.025-8.042 0.458-18.046-13.623-23.549-18.443-14.098-12.353-30.474-20.840-48.239-26.551-86.646-27.857-171.451 32.122-189.787 118.031-19.441 91.078 54.091 198.993 153.313 189.040 24.603-2.468 46.791-9.195 68.243-21.640 8.668-5.028 22.977-21.652 32.930-21.475 6.976 0.124 13.251 9.647 17.670 14.093l36.477 36.459c6.590 6.636 14.250 12.156 6.741 21.193-15.330 18.450-37.542 32.228-58.519 43.305-118.109 62.355-262.374 13.472-323.782-103.311-35.469-67.452-25.685-150.041-68.487-214.140-30.167-45.177-80.951-74.275-136.022-70.413-19.842 1.391-39.756 6.076-57.653 14.847-104.915 51.407-113.944 202.931-23.532 272.699 38.111 29.409 90.649 36.425 135.309 18.880 11.810-4.640 22.625-10.821 32.945-18.183 4.417-3.151 10.625-9.812 16.473-9.484 6.426 0.363 12.309 8.692 16.473 12.855 11.977 11.973 23.349 24.496 35.298 36.475 4.345 4.355 14.559 11.600 12.080 18.825-3.723 10.854-20.787 20.481-29.729 26.835-33.085 23.507-73.643 37.831-114.130 40.263-129.389 7.774-246.857-87.826-260.937-218.877-11.557-107.563 36.224-215.138 135.041-266.113 84.024-43.342 187.873-30.941 261.204 27.158 19.671 15.585 46.151 38.408 55.300 62.466z" />
</font>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

+1
View File
File diff suppressed because one or more lines are too long
+38
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4
View File
@@ -0,0 +1,4 @@
function getImportPath(filename) {
return `./${filename}`;
}