feat: merge litian

This commit is contained in:
ai-business-hql
2025-07-22 19:51:10 +08:00
9 changed files with 54 additions and 61 deletions
@@ -1,7 +1,7 @@
function getImportPath(filename) {
return `./${filename}`;
}
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-BxUjNu_D.js","copilot_web/vendor-markdown-CBmlBP6m.js","copilot_web/vendor-react-Dixhfmvb.js","copilot_web/message-components-DXmFocDz.js","copilot_web/input.js","copilot_web/assets/input-D6jqEd7F.css","copilot_web/fonts.css"].map(path => {
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/workflowChat-BH5RQW5C.js","copilot_web/vendor-markdown-CBmlBP6m.js","copilot_web/vendor-react-Dixhfmvb.js","copilot_web/message-components-CUhQ_OMh.js","copilot_web/input.js","copilot_web/assets/input-D6jqEd7F.css","copilot_web/fonts.css"].map(path => {
const apiBase = window.comfyAPI?.api?.api?.api_base;
if (apiBase) {
// 有 API base 时,使用完整路径
@@ -11,4 +11,4 @@ function getImportPath(filename) {
return `./${path}`;
}
}))))=>i.map(i=>d[i]);
import{_ as a}from"./input.js";import{j as e}from"./vendor-markdown-CBmlBP6m.js";import{r as t,R as i}from"./vendor-react-Dixhfmvb.js";import{C as n}from"./message-components-DXmFocDz.js";const s={EXPLAIN_NODE:"copilot:explain-node",TOOLBOX_USAGE:"copilot:toolbox-usage",TOOLBOX_PARAMETERS:"copilot:toolbox-parameters",TOOLBOX_DOWNSTREAMNODES:"copilot:toolbox-downstreamnodes"},d=i.lazy(()=>a(()=>import(getImportPath("workflowChat-BxUjNu_D.js")),__vite__mapDeps([0,1,2,3,4,5,6])).then(o=>({default:o.default})));function c(){const[o,r]=t.useState(!1);return t.useEffect(()=>{const l=()=>{r(!0)};return window.addEventListener(s.EXPLAIN_NODE,l),()=>window.removeEventListener(s.EXPLAIN_NODE,l)},[]),e.jsx(n,{children:e.jsx("div",{className:"h-full w-full flex flex-col",children:e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:e.jsx(d,{visible:!0,triggerUsage:o,onUsageTriggered:()=>r(!1)})})})})}const O=Object.freeze(Object.defineProperty({__proto__:null,default:c},Symbol.toStringTag,{value:"Module"}));export{O as A,s as C};
import{_ as a}from"./input.js";import{j as e}from"./vendor-markdown-CBmlBP6m.js";import{r as t,R as i}from"./vendor-react-Dixhfmvb.js";import{C as n}from"./message-components-CUhQ_OMh.js";const s={EXPLAIN_NODE:"copilot:explain-node",TOOLBOX_USAGE:"copilot:toolbox-usage",TOOLBOX_PARAMETERS:"copilot:toolbox-parameters",TOOLBOX_DOWNSTREAMNODES:"copilot:toolbox-downstreamnodes"},d=i.lazy(()=>a(()=>import(getImportPath("workflowChat-BH5RQW5C.js")),__vite__mapDeps([0,1,2,3,4,5,6])).then(o=>({default:o.default})));function c(){const[o,r]=t.useState(!1);return t.useEffect(()=>{const l=()=>{r(!0)};return window.addEventListener(s.EXPLAIN_NODE,l),()=>window.removeEventListener(s.EXPLAIN_NODE,l)},[]),e.jsx(n,{children:e.jsx("div",{className:"h-full w-full flex flex-col",children:e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:"Loading..."}),children:e.jsx(d,{visible:!0,triggerUsage:o,onUsageTriggered:()=>r(!1)})})})})}const O=Object.freeze(Object.defineProperty({__proto__:null,default:c},Symbol.toStringTag,{value:"Module"}));export{O as A,s as C};
@@ -1,5 +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-DXmFocDz.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...
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};
@@ -1,4 +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-DXmFocDz.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};
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};
@@ -1,7 +1,7 @@
function getImportPath(filename) {
return `./${filename}`;
}
import{j as we}from"./vendor-markdown-CBmlBP6m.js";import{W as Si,g as Wa,a as Wt}from"./message-components-DXmFocDz.js";import{g as _u,R as Oe,b as Ba,r as g,d as Ca,a as Ou}from"./vendor-react-Dixhfmvb.js";var ns={exports:{}};/*!
import{j as we}from"./vendor-markdown-CBmlBP6m.js";import{W as Si,g as Wa,a as Wt}from"./message-components-CUhQ_OMh.js";import{g as _u,R as Oe,b as Ba,r as g,d as Ca,a as Ou}from"./vendor-react-Dixhfmvb.js";var ns={exports:{}};/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
+3 -3
View File
File diff suppressed because one or more lines are too long
@@ -1,7 +1,7 @@
function getImportPath(filename) {
return `./${filename}`;
}
import{r as pe,R as LT}from"./vendor-react-Dixhfmvb.js";import{j as S,M as zT,r as HT,a as VT,b as WT,c as UT}from"./vendor-markdown-CBmlBP6m.js";let Ne=null;const Wp=location.pathname.split("/").slice(0,-1).join("/");let KT=null;async function Qde(){try{await Promise.all([import(Wp+"/scripts/api.js").then(i=>{KT=i?.api}),import(Wp+"/scripts/app.js").then(i=>{Ne=i?.app})])}catch(i){console.error("waitForApp error",i)}}const Y1={messages:[],selectedNode:Object.keys(Ne?.canvas?.selected_nodes??{})?.length?Object.values(Ne?.canvas?.selected_nodes):null,installedNodes:[],loading:!1,sessionId:null,showChat:!1,activeTab:"chat",screenState:null,guiding:!1};function GT(i,e){switch(e.type){case"SET_MESSAGES":return{...i,messages:e.payload};case"ADD_MESSAGE":return{...i,messages:[...i.messages,e.payload]};case"UPDATE_MESSAGE":return{...i,messages:i.messages.map(t=>t.id===e.payload.id&&!t.finished?e.payload:t)};case"SET_SELECTED_NODE":return{...i,selectedNode:e.payload};case"SET_INSTALLED_NODES":return{...i,installedNodes:e.payload};case"SET_LOADING":return{...i,loading:e.payload};case"SET_SESSION_ID":return{...i,sessionId:e.payload};case"SET_SHOW_CHAT":return{...i,showChat:e.payload};case"SET_ACTIVE_TAB":return{...i,activeTab:e.payload};case"SET_SCREEN_STATE":return{...i,screenState:e.payload};case"SET_GUIDING":return{...i,guiding:e.payload};case"CLEAR_MESSAGES":return{...i,messages:[]};default:return i}}const X1=pe.createContext({state:Y1,dispatch:()=>null,isAutoScroll:{current:!0},showcasIng:{current:!1}});function ece({children:i}){const[e,t]=pe.useReducer(GT,Y1),r=pe.useRef(!0),n=pe.useRef(!0);return LT.useEffect(()=>{e.sessionId&&e.messages.length>0&&localStorage.setItem(`messages_${e.sessionId}`,JSON.stringify(e.messages))},[e.messages,e.sessionId]),S.jsx(X1.Provider,{value:{state:e,dispatch:t,isAutoScroll:r,showcasIng:n},children:i})}function qT(){const i=pe.useContext(X1);if(!i)throw new Error("useChatContext must be used within a ChatProvider");return i}const J1={apiBaseUrl:"https://comfyui-copilot-server-pre.onrender.com"};function ut(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){const e=Math.random()*16|0;return(i==="x"?e:e&3|8).toString(16)})}var YT="0123456789abcdefghijklmnopqrstuvwxyz";function cr(i){return YT.charAt(i)}function XT(i,e){return i&e}function ta(i,e){return i|e}function Up(i,e){return i^e}function Kp(i,e){return i&~e}function JT(i){if(i==0)return-1;var e=0;return i&65535||(i>>=16,e+=16),i&255||(i>>=8,e+=8),i&15||(i>>=4,e+=4),i&3||(i>>=2,e+=2),i&1||++e,e}function ZT(i){for(var e=0;i!=0;)i&=i-1,++e;return e}var pn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Z1="=";function fl(i){var e,t,r="";for(e=0;e+3<=i.length;e+=3)t=parseInt(i.substring(e,e+3),16),r+=pn.charAt(t>>6)+pn.charAt(t&63);for(e+1==i.length?(t=parseInt(i.substring(e,e+1),16),r+=pn.charAt(t<<2)):e+2==i.length&&(t=parseInt(i.substring(e,e+2),16),r+=pn.charAt(t>>2)+pn.charAt((t&3)<<4));(r.length&3)>0;)r+=Z1;return r}function Gp(i){var e="",t,r=0,n=0;for(t=0;t<i.length&&i.charAt(t)!=Z1;++t){var s=pn.indexOf(i.charAt(t));s<0||(r==0?(e+=cr(s>>2),n=s&3,r=1):r==1?(e+=cr(n<<2|s>>4),n=s&15,r=2):r==2?(e+=cr(n),e+=cr(s>>2),n=s&3,r=3):(e+=cr(n<<2|s>>4),e+=cr(s&15),r=0))}return r==1&&(e+=cr(n<<2)),e}var Zi,QT={decode:function(i){var e;if(Zi===void 0){var t="0123456789ABCDEF",r=` \f
import{r as pe,R as LT}from"./vendor-react-Dixhfmvb.js";import{j as S,M as zT,r as HT,a as VT,b as WT,c as UT}from"./vendor-markdown-CBmlBP6m.js";let Ne=null;const Wp=location.pathname.split("/").slice(0,-1).join("/");let KT=null;async function Qde(){try{await Promise.all([import(Wp+"/scripts/api.js").then(i=>{KT=i?.api}),import(Wp+"/scripts/app.js").then(i=>{Ne=i?.app})])}catch(i){console.error("waitForApp error",i)}}const Y1={messages:[],selectedNode:Object.keys(Ne?.canvas?.selected_nodes??{})?.length?Object.values(Ne?.canvas?.selected_nodes):null,installedNodes:[],loading:!1,sessionId:null,showChat:!1,activeTab:"chat",screenState:null};function GT(i,e){switch(e.type){case"SET_MESSAGES":return{...i,messages:e.payload};case"ADD_MESSAGE":return{...i,messages:[...i.messages,e.payload]};case"UPDATE_MESSAGE":return{...i,messages:i.messages.map(t=>t.id===e.payload.id&&!t.finished?e.payload:t)};case"SET_SELECTED_NODE":return{...i,selectedNode:e.payload};case"SET_INSTALLED_NODES":return{...i,installedNodes:e.payload};case"SET_LOADING":return{...i,loading:e.payload};case"SET_SESSION_ID":return{...i,sessionId:e.payload};case"SET_SHOW_CHAT":return{...i,showChat:e.payload};case"SET_ACTIVE_TAB":return{...i,activeTab:e.payload};case"SET_SCREEN_STATE":return{...i,screenState:e.payload};case"CLEAR_MESSAGES":return{...i,messages:[]};default:return i}}const X1=pe.createContext({state:Y1,dispatch:()=>null,isAutoScroll:{current:!0},showcasIng:{current:!1}});function ece({children:i}){const[e,t]=pe.useReducer(GT,Y1),r=pe.useRef(!0),n=pe.useRef(!0);return LT.useEffect(()=>{e.sessionId&&e.messages.length>0&&localStorage.setItem(`messages_${e.sessionId}`,JSON.stringify(e.messages))},[e.messages,e.sessionId]),S.jsx(X1.Provider,{value:{state:e,dispatch:t,isAutoScroll:r,showcasIng:n},children:i})}function qT(){const i=pe.useContext(X1);if(!i)throw new Error("useChatContext must be used within a ChatProvider");return i}const J1={apiBaseUrl:"https://comfyui-copilot-server-pre.onrender.com"};function ut(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){const e=Math.random()*16|0;return(i==="x"?e:e&3|8).toString(16)})}var YT="0123456789abcdefghijklmnopqrstuvwxyz";function cr(i){return YT.charAt(i)}function XT(i,e){return i&e}function ta(i,e){return i|e}function Up(i,e){return i^e}function Kp(i,e){return i&~e}function JT(i){if(i==0)return-1;var e=0;return i&65535||(i>>=16,e+=16),i&255||(i>>=8,e+=8),i&15||(i>>=4,e+=4),i&3||(i>>=2,e+=2),i&1||++e,e}function ZT(i){for(var e=0;i!=0;)i&=i-1,++e;return e}var pn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Z1="=";function fl(i){var e,t,r="";for(e=0;e+3<=i.length;e+=3)t=parseInt(i.substring(e,e+3),16),r+=pn.charAt(t>>6)+pn.charAt(t&63);for(e+1==i.length?(t=parseInt(i.substring(e,e+1),16),r+=pn.charAt(t<<2)):e+2==i.length&&(t=parseInt(i.substring(e,e+2),16),r+=pn.charAt(t>>2)+pn.charAt((t&3)<<4));(r.length&3)>0;)r+=Z1;return r}function Gp(i){var e="",t,r=0,n=0;for(t=0;t<i.length&&i.charAt(t)!=Z1;++t){var s=pn.indexOf(i.charAt(t));s<0||(r==0?(e+=cr(s>>2),n=s&3,r=1):r==1?(e+=cr(n<<2|s>>4),n=s&15,r=2):r==2?(e+=cr(n),e+=cr(s>>2),n=s&3,r=3):(e+=cr(n<<2|s>>4),e+=cr(s&15),r=0))}return r==1&&(e+=cr(n<<2)),e}var Zi,QT={decode:function(i){var e;if(Zi===void 0){var t="0123456789ABCDEF",r=` \f
\r  \u2028\u2029`;for(Zi={},e=0;e<16;++e)Zi[t.charAt(e)]=e;for(t=t.toLowerCase(),e=10;e<16;++e)Zi[t.charAt(e)]=e;for(e=0;e<r.length;++e)Zi[r.charAt(e)]=-1}var n=[],s=0,o=0;for(e=0;e<i.length;++e){var a=i.charAt(e);if(a=="=")break;if(a=Zi[a],a!=-1){if(a===void 0)throw new Error("Illegal character at offset "+e);s|=a,++o>=2?(n[n.length]=s,s=0,o=0):s<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return n}},ci,nu={decode:function(i){var e;if(ci===void 0){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=`= \f
\r  \u2028\u2029`;for(ci=Object.create(null),e=0;e<64;++e)ci[t.charAt(e)]=e;for(ci["-"]=62,ci._=63,e=0;e<r.length;++e)ci[r.charAt(e)]=-1}var n=[],s=0,o=0;for(e=0;e<i.length;++e){var a=i.charAt(e);if(a=="=")break;if(a=ci[a],a!=-1){if(a===void 0)throw new Error("Illegal character at offset "+e);s|=a,++o>=4?(n[n.length]=s>>16,n[n.length]=s>>8&255,n[n.length]=s&255,s=0,o=0):s<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:n[n.length]=s>>10;break;case 3:n[n.length]=s>>16,n[n.length]=s>>8&255;break}return n},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(i){var e=nu.re.exec(i);if(e)if(e[1])i=e[1];else if(e[2])i=e[2];else throw new Error("RegExp out of sync");return nu.decode(i)}},Qi=1e13,Ts=function(){function i(e){this.buf=[+e||0]}return i.prototype.mulAdd=function(e,t){var r=this.buf,n=r.length,s,o;for(s=0;s<n;++s)o=r[s]*e+t,o<Qi?t=0:(t=0|o/Qi,o-=t*Qi),r[s]=o;t>0&&(r[s]=t)},i.prototype.sub=function(e){var t=this.buf,r=t.length,n,s;for(n=0;n<r;++n)s=t[n]-e,s<0?(s+=Qi,e=1):e=0,t[n]=s;for(;t[t.length-1]===0;)t.pop()},i.prototype.toString=function(e){if((e||10)!=10)throw new Error("only base 10 is supported");for(var t=this.buf,r=t[t.length-1].toString(),n=t.length-2;n>=0;--n)r+=(Qi+t[n]).toString().substring(1);return r},i.prototype.valueOf=function(){for(var e=this.buf,t=0,r=e.length-1;r>=0;--r)t=t*Qi+e[r];return t},i.prototype.simplify=function(){var e=this.buf;return e.length==1?e[0]:this},i}(),Q1="…",eO=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,tO=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function In(i,e){return i.length>e&&(i=i.substring(0,e)+Q1),i}var Wh=function(){function i(e,t){this.hexDigits="0123456789ABCDEF",e instanceof i?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=t)}return i.prototype.get=function(e){if(e===void 0&&(e=this.pos++),e>=this.enc.length)throw new Error("Requesting byte offset ".concat(e," on a stream of length ").concat(this.enc.length));return typeof this.enc=="string"?this.enc.charCodeAt(e):this.enc[e]},i.prototype.hexByte=function(e){return this.hexDigits.charAt(e>>4&15)+this.hexDigits.charAt(e&15)},i.prototype.hexDump=function(e,t,r){for(var n="",s=e;s<t;++s)if(n+=this.hexByte(this.get(s)),r!==!0)switch(s&15){case 7:n+=" ";break;case 15:n+=`
`;break;default:n+=" "}return n},i.prototype.isASCII=function(e,t){for(var r=e;r<t;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0},i.prototype.parseStringISO=function(e,t){for(var r="",n=e;n<t;++n)r+=String.fromCharCode(this.get(n));return r},i.prototype.parseStringUTF=function(e,t){for(var r="",n=e;n<t;){var s=this.get(n++);s<128?r+=String.fromCharCode(s):s>191&&s<224?r+=String.fromCharCode((s&31)<<6|this.get(n++)&63):r+=String.fromCharCode((s&15)<<12|(this.get(n++)&63)<<6|this.get(n++)&63)}return r},i.prototype.parseStringBMP=function(e,t){for(var r="",n,s,o=e;o<t;)n=this.get(o++),s=this.get(o++),r+=String.fromCharCode(n<<8|s);return r},i.prototype.parseTime=function(e,t,r){var n=this.parseStringISO(e,t),s=(r?eO:tO).exec(n);return s?(r&&(s[1]=+s[1],s[1]+=+s[1]<70?2e3:1900),n=s[1]+"-"+s[2]+"-"+s[3]+" "+s[4],s[5]&&(n+=":"+s[5],s[6]&&(n+=":"+s[6],s[7]&&(n+="."+s[7]))),s[8]&&(n+=" UTC",s[8]!="Z"&&(n+=s[8],s[9]&&(n+=":"+s[9]))),n):"Unrecognized time: "+n},i.prototype.parseInteger=function(e,t){for(var r=this.get(e),n=r>127,s=n?255:0,o,a="";r==s&&++e<t;)r=this.get(e);if(o=t-e,o===0)return n?-1:0;if(o>4){for(a=r,o<<=3;!((+a^s)&128);)a=+a<<1,--o;a="("+o+` bit)
File diff suppressed because one or more lines are too long
-5
View File
@@ -23,7 +23,6 @@ interface ChatState {
showChat: boolean;
activeTab: TabType;
screenState: ScreenState | null; // Add screen state
guiding: boolean;
}
type ChatAction =
@@ -37,7 +36,6 @@ type ChatAction =
| { type: 'SET_SHOW_CHAT'; payload: boolean }
| { type: 'SET_ACTIVE_TAB'; payload: TabType }
| { type: 'SET_SCREEN_STATE'; payload: ScreenState | null } // Add action for setting screen state
| { type: 'SET_GUIDING', payload: boolean}
| { type: 'CLEAR_MESSAGES' }
const initialState: ChatState = {
@@ -49,7 +47,6 @@ const initialState: ChatState = {
showChat: false,
activeTab: 'chat',
screenState: null, // Initialize as null
guiding: false
};
function chatReducer(state: ChatState, action: ChatAction): ChatState {
@@ -79,8 +76,6 @@ function chatReducer(state: ChatState, action: ChatAction): ChatState {
return { ...state, activeTab: action.payload };
case 'SET_SCREEN_STATE':
return { ...state, screenState: action.payload };
case 'SET_GUIDING':
return { ...state, guiding: action.payload };
case 'CLEAR_MESSAGES':
return { ...state, messages: [] };
default:
+2 -4
View File
@@ -165,7 +165,7 @@ const TabButton = ({
export default function WorkflowChat({ onClose, visible = true, triggerUsage = false, onUsageTriggered }: WorkflowChatProps) {
const { state, dispatch, isAutoScroll, showcasIng } = useChatContext();
const { messages, installedNodes, loading, sessionId, selectedNode, activeTab, guiding } = state;
const { messages, installedNodes, loading, sessionId, selectedNode, activeTab } = state;
const messageDivRef = useRef<HTMLDivElement>(null);
const [input, setInput] = useState<string>('');
const [latestInput, setLatestInput] = useState<string>('');
@@ -231,7 +231,6 @@ export default function WorkflowChat({ onClose, visible = true, triggerUsage = f
}, [activeTab]);
const showGuide = () => {
dispatch({ type: 'SET_GUIDING', payload: true });
dispatch({ type: 'SET_MESSAGES', payload: [
{
id: generateUUID(),
@@ -371,8 +370,7 @@ export default function WorkflowChat({ onClose, visible = true, triggerUsage = f
}
const handleSendMessage = async () => {
if (guiding) {
dispatch({ type: 'SET_GUIDING', payload: false });
if (messages?.[0]?.role === 'showcase') {
dispatch({ type: 'CLEAR_MESSAGES' });
}
isAutoScroll.current = true