@bigduu/lotus 2026.5.9 → 2026.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{App-BTGbaEEX.js → App-BocqxYkX.js} +7 -7
- package/dist/assets/{SubAgentsPanel-Ce4m3347.js → SubAgentsPanel-XAgdP-xO.js} +1 -1
- package/dist/assets/{index-BgLl21bt.js → index-C8GkXwzS.js} +1 -1
- package/dist/assets/{index-BS58SFDp.js → index-DC9Ggtrl.js} +1 -1
- package/dist/assets/{index-CczbX5-W.js → index-DHJJSQ2h.js} +1 -1
- package/dist/assets/{index-BznNIVdg.js → index-DJeQeDwp.js} +1 -1
- package/dist/assets/{index-wTpHqXAd.js → index-DMaXHadP.js} +2 -2
- package/dist/assets/{index-OvJdu3L8.js → index-DRVv9Wt_.js} +1 -1
- package/dist/assets/{index-CqLfWip6.js → index-Dgw8qH4q.js} +1 -1
- package/dist/assets/{index-Boq-mY30.js → index-dBIF9Wdr.js} +1 -1
- package/dist/assets/{index-De_fWx5w.js → index-o5s-6ubE.js} +1 -1
- package/dist/assets/{index-DxXScfYt.js → index-pOHcR4B7.js} +1 -1
- package/dist/assets/{index-BastF0O4.js → index-rWoFDRGk.js} +1 -1
- package/dist/assets/{main-mHH04gTP.js → main-TSfsr__P.js} +2 -2
- package/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var ne=Object.defineProperty;var se=(n,t,s)=>t in n?ne(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var N=(n,t,s)=>se(n,typeof t!="symbol"?t+"":t,s);import{j as i}from"./vendor-markdown-DzaXAW9Q.js";import{a as u,u as re}from"./vendor-i18n-BNURlJ23.js";import{n as E,v as W,w as oe,u as f,x as ae,o as le}from"./App-BTGbaEEX.js";import{l as I,C as ie,a7 as k,j as ue,E as _,ak as ce,v as de,ad as ge,t as me}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-mHH04gTP.js";const v=class v{static getInstance(){return v.instance||(v.instance=new v),v.instance}parseUserCommand(t){E("[ToolService]",`[ToolService] parseUserCommand: Parsing content: "${t}"`);const s=t.trim();if(!s.startsWith("/"))return E("[ToolService]",'[ToolService] parseUserCommand: Content does not start with "/", not a tool command.'),null;const o=s.indexOf(" ");let c,p;if(o===-1?(c=s.substring(1),p=""):(c=s.substring(1,o),p=s.substring(o+1).trim()),c){const d={tool_name:c,user_description:p};return E("[ToolService]","[ToolService] parseUserCommand: Successfully parsed command:",d),d}return E("[ToolService]","[ToolService] parseUserCommand: Failed to parse tool name from content."),null}parseAIResponseToToolCall(t){return this.parseUserCommand(t)}async executeTool(t){E("[ToolService]","[ToolService] executeTool: Attempting to execute tool via HTTP with request:",t);try{const s=await W.post("tools/execute",t),o=JSON.parse(s.result);return E("[ToolService]","[ToolService] executeTool: Parsed structured result:",o),o}catch(s){throw console.error("[ToolService] executeTool: HTTP tool execution failed:",s),s instanceof oe?new Error(`Workflow execution failed: ${s.message}`):s}}};N(v,"instance");let F=v;const H=new F;class pe{async listProfiles(){return W.get("subagent_profiles")}}const fe=new pe,he=[];function ye(n={}){const{enabled:t=!0,refreshKey:s}=n,[o,c]=u.useState(null),[p,d]=u.useState(!1),[A,S]=u.useState(null),b=u.useCallback(async()=>{d(!0);try{const m=await fe.listProfiles();c(m),S(null)}catch(m){S(m instanceof Error?m:new Error(String(m)))}finally{d(!1)}},[]);u.useEffect(()=>{t&&b()},[t,b,s]);const x=u.useMemo(()=>{const m=new Map;if(o!=null&&o.profiles)for(const j of o.profiles)m.set(j.id,j);return m},[o]);return{profiles:(o==null?void 0:o.profiles)??he,fallbackId:(o==null?void 0:o.fallback_id)??null,loading:p,error:A,refresh:b,byId:x}}const Se=(n,t)=>{var A,S,b,x,m;const s=n==null?void 0:n.trim();if(!s)return null;const o=t.get(s),c=((A=o==null?void 0:o.display_name)==null?void 0:A.trim())||s,p=(b=(S=o==null?void 0:o.ui)==null?void 0:S.icon)==null?void 0:b.trim(),d=((m=(x=o==null?void 0:o.ui)==null?void 0:x.color)==null?void 0:m.trim())||void 0;return i.jsx(I,{color:d,style:{marginInlineEnd:0,flex:"0 0 auto"},"data-testid":`sub-agent-role-tag-${s}`,children:p?`${p} ${c}`:c})},{Text:C}=ue,{useToken:G}=me,be="chat-session-sub-agents-collapsed:",we=3,Ce=600,P=n=>{const t=(n||"").trim().toLowerCase();return t?t==="started"||t==="already_running"?"running":t==="success"||t==="done"?"completed":t==="canceled"?"cancelled":t==="queued"||t==="created"?"pending":t:"pending"},xe=(n,t)=>{if(t&&t.trim())return t;if(n.isRunning)return"running";if(n.lastRunStatus&&n.lastRunStatus.trim())return n.lastRunStatus;const s=n.messageCount??0;return s>2?"completed":(s>0,"pending")},K=n=>`${be}${n}`,D=n=>{if(typeof window>"u")return!1;try{const t=window.localStorage.getItem(K(n));return t==="1"?!0:t==="0"?!1:null}catch{return null}},ve=(n,t)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(K(n),t?"1":"0")}catch{}},Oe=({parentSessionId:n})=>{const{t}=re(),{token:s}=G(),[o,c]=u.useState(()=>D(n)??!1),[p,d]=u.useState(null),[A,S]=u.useState(null),[b,x]=u.useState(null),m=f(e=>ae(n)(e)),j=f(e=>e.chats),O=f(e=>e.loadChatHistory),T=f(e=>e.refreshChats),M=f(e=>e.markOptimisticStart),z=f(e=>e.markRetryStart),R=f(e=>e.markSettleTimeout),Y=f(e=>e.pinSession),J=f(e=>e.unpinSession),h=f(e=>e.applyChildProgress),L=f(e=>e.clearChildProgress),{byId:q}=ye(),U=u.useMemo(()=>Object.entries(m).map(([e,l])=>({childSessionId:e,...l})),[m]),B=u.useMemo(()=>j.filter(e=>e.kind==="child"&&e.parentSessionId===n).sort((e,l)=>{const r=Date.parse(e.updatedAt||"")||0;return(Date.parse(l.updatedAt||"")||0)-r}),[j,n]),w=u.useMemo(()=>{const e=new Map(U.map(r=>[r.childSessionId,r])),l=[];for(const r of B){const a=e.get(r.id);l.push({childSessionId:r.id,title:r.title||(a==null?void 0:a.title),status:P(xe(r,a==null?void 0:a.status)),error:(a==null?void 0:a.error)||r.lastRunError,lastHeartbeatAt:a==null?void 0:a.lastHeartbeatAt,lastEventAt:a==null?void 0:a.lastEventAt,outputPreview:a==null?void 0:a.outputPreview,roundCount:a==null?void 0:a.roundCount,pinned:r.pinned,updatedAt:r.updatedAt,isRunning:r.isRunning,messageCount:r.messageCount,lastRunStatus:r.lastRunStatus,lastRunError:r.lastRunError,subagentType:r.subagentType??null}),e.delete(r.id)}for(const r of e.values())l.push({childSessionId:r.childSessionId,title:r.title,status:P(r.status),error:r.error,lastHeartbeatAt:r.lastHeartbeatAt,lastEventAt:r.lastEventAt,outputPreview:r.outputPreview,roundCount:r.roundCount});return l},[B,U]);u.useEffect(()=>{c(D(n)??!1)},[n]),u.useEffect(()=>{D(n)===null&&c(w.length>we)},[n,w.length]);const Q=u.useCallback(()=>{c(e=>{const l=!e;return ve(n,l),l})},[n]),X=u.useCallback(e=>e instanceof Error&&e.message.trim()?e.message:"Failed to run child session",[]),V=u.useCallback(async(e,l="regenerate")=>{d(e),h(n,e,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),z(e);try{const r=await H.executeTool({tool_name:"SubAgent",session_id:n,parameters:[{name:"action",value:"run"},{name:"child_session_id",value:e},{name:"reset_to_last_user",value:l==="error_retry"?"false":"true"}]});if(!r.success)throw new Error(r.result||"Failed to run sub-agent");h(n,e,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),await O(e,{mode:"replace"}),await T()}catch(r){R(e),h(n,e,{status:"error",error:X(r),lastEventAt:new Date().toISOString()})}finally{d(r=>r===e?null:r)}},[O,n,T,z,R,X,h]),Z=u.useCallback(async e=>{const l=typeof window<"u"?window.prompt.bind(window):null;if(!l)return;const r=l("Send a follow-up message to this sub-agent:","Continue from where you left off.");if(r===null)return;const a=r.trim();if(!a){h(n,e,{status:"error",error:"Follow-up message cannot be empty.",lastEventAt:new Date().toISOString()});return}S(e),h(n,e,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),M(e);try{const g=await H.executeTool({tool_name:"SubAgent",session_id:n,parameters:[{name:"action",value:"send_message"},{name:"child_session_id",value:e},{name:"message",value:a},{name:"auto_run",value:"true"}]});if(!g.success)throw new Error(g.result||"Follow-up failed");let y="running";try{JSON.parse(g.result).status==="pending"&&(y="pending")}catch{y="running"}h(n,e,{status:y,error:void 0,lastEventAt:new Date().toISOString()}),await T()}catch(g){R(e),h(n,e,{status:"error",error:g instanceof Error&&g.message.trim()?g.message:"Failed to continue child session",lastEventAt:new Date().toISOString()})}finally{S(g=>g===e?null:g)}},[n,T,M,R,h]),ee=u.useCallback(async e=>{x(e);try{const l=await H.executeTool({tool_name:"SubAgent",session_id:n,parameters:[{name:"action",value:"delete"},{name:"child_session_id",value:e}]});if(!l.success)throw new Error(l.result||"Failed to delete sub-agent");L(n,e),await T()}finally{x(l=>l===e?null:l)}},[L,n,T]);return w.length===0?null:i.jsxs(ie,{size:"small",className:"lotus-settings-card",style:{marginBottom:s.marginMD},"data-testid":"sub-agents-panel",title:i.jsxs(C,{strong:!0,children:[t("chat.subAgents.title")," ",i.jsxs(C,{type:"secondary",children:["(",w.length,")"]})]}),extra:i.jsx(_,{type:"text",size:"small",icon:o?i.jsx(de,{}):i.jsx(ge,{}),onClick:Q,"data-testid":"sub-agents-toggle",children:t(o?"chat.subAgents.expand":"chat.subAgents.collapse")}),children:[o?i.jsx(C,{type:"secondary","data-testid":"sub-agents-collapsed-hint",children:t("chat.subAgents.hiddenHint",{count:w.length})}):i.jsx(k,{vertical:!0,gap:s.marginSM,"data-testid":"sub-agents-list",style:{maxHeight:`${Ce}px`,overflowY:"auto",paddingRight:s.paddingXS},children:w.map(e=>{const l=P(e.status),r=l==="running",a=p===e.childSessionId,g=A===e.childSessionId,y=b===e.childSessionId,$=a||g||y;return i.jsxs(k,{align:"flex-start",justify:"space-between",gap:s.marginSM,className:"lotus-settings-list-item",style:{padding:s.paddingSM,borderRadius:s.borderRadiusSM},children:[i.jsxs(k,{vertical:!0,style:{flex:1,minWidth:0},children:[i.jsxs(k,{align:"center",gap:s.marginXS,style:{minWidth:0},children:[i.jsx(C,{strong:!0,ellipsis:!0,style:{minWidth:0},children:e.title||"Sub-agent"}),i.jsx(I,{color:l==="running"?"processing":l==="completed"?"success":l==="error"||l==="failed"?"error":l==="cancelled"?"warning":"default",style:{marginInlineEnd:0,flex:"0 0 auto"},children:l}),e.pinned?i.jsx(I,{color:"warning",style:{marginInlineEnd:0,flex:"0 0 auto"},children:"Pinned"}):null,Se(e.subagentType,q)]}),i.jsxs(C,{type:"secondary",style:{fontSize:12,marginTop:2},children:[e.childSessionId.slice(0,8),e.updatedAt?` • ${e.updatedAt}`:"",e.lastHeartbeatAt?` • heartbeat: ${e.lastHeartbeatAt}`:"",typeof e.roundCount=="number"?` • round ${e.roundCount+1}`:""]}),e.outputPreview?i.jsx(C,{type:"secondary",style:{marginTop:s.marginXS,fontSize:13},ellipsis:!0,children:e.outputPreview}):null,e.error?i.jsx(C,{type:"danger",style:{marginTop:s.marginXS},children:e.error}):null]}),i.jsxs(k,{gap:8,children:[i.jsx(_,{size:"small",disabled:$,onClick:()=>{le(e.childSessionId),O(e.childSessionId)},children:t("chat.subAgents.open")}),i.jsx(_,{size:"small",loading:g,disabled:y||a||r,"data-testid":`sub-agent-continue-${e.childSessionId}`,onClick:()=>{Z(e.childSessionId)},children:t("chat.subAgents.continue")}),i.jsx(ce,{trigger:["click"],menu:{items:[{key:"regenerate",label:t("chat.actions.regenerate")},{key:"error_retry",label:t("chat.actions.retryFailed")}],onClick:({key:te})=>{V(e.childSessionId,te)}},disabled:y||r||g,children:i.jsx(_,{size:"small",loading:a,disabled:y||r||g,"data-testid":`sub-agent-retry-${e.childSessionId}`,children:t("chat.subAgents.retry")})}),typeof e.pinned=="boolean"?i.jsx(_,{size:"small",disabled:$,onClick:()=>{e.pinned?J(e.childSessionId):Y(e.childSessionId)},children:e.pinned?t("chat.actions.unpin"):t("chat.actions.pin")}):null,i.jsx(_,{danger:!0,size:"small",loading:y,disabled:a,"data-testid":`sub-agent-delete-${e.childSessionId}`,onClick:()=>{ee(e.childSessionId)},children:t("common.delete")})]})]},e.childSessionId)})}),!o&&w.length>1&&i.jsx(Ae,{items:w})]})},Ae=({items:n})=>{const{token:t}=G(),s=n.reduce((c,p)=>{const d=P(p.status);return d==="completed"?c.completed++:d==="running"?c.running++:d==="error"||d==="failed"?c.error++:c.pending++,c},{completed:0,running:0,error:0,pending:0}),o=[];return s.completed>0&&o.push(`${s.completed} completed`),s.running>0&&o.push(`${s.running} running`),s.pending>0&&o.push(`${s.pending} pending`),s.error>0&&o.push(`${s.error} failed`),o.length===0?null:i.jsx(C,{type:"secondary",style:{fontSize:11,marginTop:t.marginXS,display:"block"},children:o.join(" · ")})};export{Oe as SubAgentsPanel};
|
|
1
|
+
var ne=Object.defineProperty;var se=(n,t,s)=>t in n?ne(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var N=(n,t,s)=>se(n,typeof t!="symbol"?t+"":t,s);import{j as i}from"./vendor-markdown-DzaXAW9Q.js";import{a as u,u as re}from"./vendor-i18n-BNURlJ23.js";import{n as E,v as W,w as oe,u as f,x as ae,o as le}from"./App-BocqxYkX.js";import{l as I,C as ie,a7 as k,j as ue,E as _,ak as ce,v as de,ad as ge,t as me}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-TSfsr__P.js";const v=class v{static getInstance(){return v.instance||(v.instance=new v),v.instance}parseUserCommand(t){E("[ToolService]",`[ToolService] parseUserCommand: Parsing content: "${t}"`);const s=t.trim();if(!s.startsWith("/"))return E("[ToolService]",'[ToolService] parseUserCommand: Content does not start with "/", not a tool command.'),null;const o=s.indexOf(" ");let c,p;if(o===-1?(c=s.substring(1),p=""):(c=s.substring(1,o),p=s.substring(o+1).trim()),c){const d={tool_name:c,user_description:p};return E("[ToolService]","[ToolService] parseUserCommand: Successfully parsed command:",d),d}return E("[ToolService]","[ToolService] parseUserCommand: Failed to parse tool name from content."),null}parseAIResponseToToolCall(t){return this.parseUserCommand(t)}async executeTool(t){E("[ToolService]","[ToolService] executeTool: Attempting to execute tool via HTTP with request:",t);try{const s=await W.post("tools/execute",t),o=JSON.parse(s.result);return E("[ToolService]","[ToolService] executeTool: Parsed structured result:",o),o}catch(s){throw console.error("[ToolService] executeTool: HTTP tool execution failed:",s),s instanceof oe?new Error(`Workflow execution failed: ${s.message}`):s}}};N(v,"instance");let F=v;const H=new F;class pe{async listProfiles(){return W.get("subagent_profiles")}}const fe=new pe,he=[];function ye(n={}){const{enabled:t=!0,refreshKey:s}=n,[o,c]=u.useState(null),[p,d]=u.useState(!1),[A,S]=u.useState(null),b=u.useCallback(async()=>{d(!0);try{const m=await fe.listProfiles();c(m),S(null)}catch(m){S(m instanceof Error?m:new Error(String(m)))}finally{d(!1)}},[]);u.useEffect(()=>{t&&b()},[t,b,s]);const x=u.useMemo(()=>{const m=new Map;if(o!=null&&o.profiles)for(const j of o.profiles)m.set(j.id,j);return m},[o]);return{profiles:(o==null?void 0:o.profiles)??he,fallbackId:(o==null?void 0:o.fallback_id)??null,loading:p,error:A,refresh:b,byId:x}}const Se=(n,t)=>{var A,S,b,x,m;const s=n==null?void 0:n.trim();if(!s)return null;const o=t.get(s),c=((A=o==null?void 0:o.display_name)==null?void 0:A.trim())||s,p=(b=(S=o==null?void 0:o.ui)==null?void 0:S.icon)==null?void 0:b.trim(),d=((m=(x=o==null?void 0:o.ui)==null?void 0:x.color)==null?void 0:m.trim())||void 0;return i.jsx(I,{color:d,style:{marginInlineEnd:0,flex:"0 0 auto"},"data-testid":`sub-agent-role-tag-${s}`,children:p?`${p} ${c}`:c})},{Text:C}=ue,{useToken:G}=me,be="chat-session-sub-agents-collapsed:",we=3,Ce=600,P=n=>{const t=(n||"").trim().toLowerCase();return t?t==="started"||t==="already_running"?"running":t==="success"||t==="done"?"completed":t==="canceled"?"cancelled":t==="queued"||t==="created"?"pending":t:"pending"},xe=(n,t)=>{if(t&&t.trim())return t;if(n.isRunning)return"running";if(n.lastRunStatus&&n.lastRunStatus.trim())return n.lastRunStatus;const s=n.messageCount??0;return s>2?"completed":(s>0,"pending")},K=n=>`${be}${n}`,D=n=>{if(typeof window>"u")return!1;try{const t=window.localStorage.getItem(K(n));return t==="1"?!0:t==="0"?!1:null}catch{return null}},ve=(n,t)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(K(n),t?"1":"0")}catch{}},Oe=({parentSessionId:n})=>{const{t}=re(),{token:s}=G(),[o,c]=u.useState(()=>D(n)??!1),[p,d]=u.useState(null),[A,S]=u.useState(null),[b,x]=u.useState(null),m=f(e=>ae(n)(e)),j=f(e=>e.chats),O=f(e=>e.loadChatHistory),T=f(e=>e.refreshChats),M=f(e=>e.markOptimisticStart),z=f(e=>e.markRetryStart),R=f(e=>e.markSettleTimeout),Y=f(e=>e.pinSession),J=f(e=>e.unpinSession),h=f(e=>e.applyChildProgress),L=f(e=>e.clearChildProgress),{byId:q}=ye(),U=u.useMemo(()=>Object.entries(m).map(([e,l])=>({childSessionId:e,...l})),[m]),B=u.useMemo(()=>j.filter(e=>e.kind==="child"&&e.parentSessionId===n).sort((e,l)=>{const r=Date.parse(e.updatedAt||"")||0;return(Date.parse(l.updatedAt||"")||0)-r}),[j,n]),w=u.useMemo(()=>{const e=new Map(U.map(r=>[r.childSessionId,r])),l=[];for(const r of B){const a=e.get(r.id);l.push({childSessionId:r.id,title:r.title||(a==null?void 0:a.title),status:P(xe(r,a==null?void 0:a.status)),error:(a==null?void 0:a.error)||r.lastRunError,lastHeartbeatAt:a==null?void 0:a.lastHeartbeatAt,lastEventAt:a==null?void 0:a.lastEventAt,outputPreview:a==null?void 0:a.outputPreview,roundCount:a==null?void 0:a.roundCount,pinned:r.pinned,updatedAt:r.updatedAt,isRunning:r.isRunning,messageCount:r.messageCount,lastRunStatus:r.lastRunStatus,lastRunError:r.lastRunError,subagentType:r.subagentType??null}),e.delete(r.id)}for(const r of e.values())l.push({childSessionId:r.childSessionId,title:r.title,status:P(r.status),error:r.error,lastHeartbeatAt:r.lastHeartbeatAt,lastEventAt:r.lastEventAt,outputPreview:r.outputPreview,roundCount:r.roundCount});return l},[B,U]);u.useEffect(()=>{c(D(n)??!1)},[n]),u.useEffect(()=>{D(n)===null&&c(w.length>we)},[n,w.length]);const Q=u.useCallback(()=>{c(e=>{const l=!e;return ve(n,l),l})},[n]),X=u.useCallback(e=>e instanceof Error&&e.message.trim()?e.message:"Failed to run child session",[]),V=u.useCallback(async(e,l="regenerate")=>{d(e),h(n,e,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),z(e);try{const r=await H.executeTool({tool_name:"SubAgent",session_id:n,parameters:[{name:"action",value:"run"},{name:"child_session_id",value:e},{name:"reset_to_last_user",value:l==="error_retry"?"false":"true"}]});if(!r.success)throw new Error(r.result||"Failed to run sub-agent");h(n,e,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),await O(e,{mode:"replace"}),await T()}catch(r){R(e),h(n,e,{status:"error",error:X(r),lastEventAt:new Date().toISOString()})}finally{d(r=>r===e?null:r)}},[O,n,T,z,R,X,h]),Z=u.useCallback(async e=>{const l=typeof window<"u"?window.prompt.bind(window):null;if(!l)return;const r=l("Send a follow-up message to this sub-agent:","Continue from where you left off.");if(r===null)return;const a=r.trim();if(!a){h(n,e,{status:"error",error:"Follow-up message cannot be empty.",lastEventAt:new Date().toISOString()});return}S(e),h(n,e,{status:"running",error:void 0,lastEventAt:new Date().toISOString()}),M(e);try{const g=await H.executeTool({tool_name:"SubAgent",session_id:n,parameters:[{name:"action",value:"send_message"},{name:"child_session_id",value:e},{name:"message",value:a},{name:"auto_run",value:"true"}]});if(!g.success)throw new Error(g.result||"Follow-up failed");let y="running";try{JSON.parse(g.result).status==="pending"&&(y="pending")}catch{y="running"}h(n,e,{status:y,error:void 0,lastEventAt:new Date().toISOString()}),await T()}catch(g){R(e),h(n,e,{status:"error",error:g instanceof Error&&g.message.trim()?g.message:"Failed to continue child session",lastEventAt:new Date().toISOString()})}finally{S(g=>g===e?null:g)}},[n,T,M,R,h]),ee=u.useCallback(async e=>{x(e);try{const l=await H.executeTool({tool_name:"SubAgent",session_id:n,parameters:[{name:"action",value:"delete"},{name:"child_session_id",value:e}]});if(!l.success)throw new Error(l.result||"Failed to delete sub-agent");L(n,e),await T()}finally{x(l=>l===e?null:l)}},[L,n,T]);return w.length===0?null:i.jsxs(ie,{size:"small",className:"lotus-settings-card",style:{marginBottom:s.marginMD},"data-testid":"sub-agents-panel",title:i.jsxs(C,{strong:!0,children:[t("chat.subAgents.title")," ",i.jsxs(C,{type:"secondary",children:["(",w.length,")"]})]}),extra:i.jsx(_,{type:"text",size:"small",icon:o?i.jsx(de,{}):i.jsx(ge,{}),onClick:Q,"data-testid":"sub-agents-toggle",children:t(o?"chat.subAgents.expand":"chat.subAgents.collapse")}),children:[o?i.jsx(C,{type:"secondary","data-testid":"sub-agents-collapsed-hint",children:t("chat.subAgents.hiddenHint",{count:w.length})}):i.jsx(k,{vertical:!0,gap:s.marginSM,"data-testid":"sub-agents-list",style:{maxHeight:`${Ce}px`,overflowY:"auto",paddingRight:s.paddingXS},children:w.map(e=>{const l=P(e.status),r=l==="running",a=p===e.childSessionId,g=A===e.childSessionId,y=b===e.childSessionId,$=a||g||y;return i.jsxs(k,{align:"flex-start",justify:"space-between",gap:s.marginSM,className:"lotus-settings-list-item",style:{padding:s.paddingSM,borderRadius:s.borderRadiusSM},children:[i.jsxs(k,{vertical:!0,style:{flex:1,minWidth:0},children:[i.jsxs(k,{align:"center",gap:s.marginXS,style:{minWidth:0},children:[i.jsx(C,{strong:!0,ellipsis:!0,style:{minWidth:0},children:e.title||"Sub-agent"}),i.jsx(I,{color:l==="running"?"processing":l==="completed"?"success":l==="error"||l==="failed"?"error":l==="cancelled"?"warning":"default",style:{marginInlineEnd:0,flex:"0 0 auto"},children:l}),e.pinned?i.jsx(I,{color:"warning",style:{marginInlineEnd:0,flex:"0 0 auto"},children:"Pinned"}):null,Se(e.subagentType,q)]}),i.jsxs(C,{type:"secondary",style:{fontSize:12,marginTop:2},children:[e.childSessionId.slice(0,8),e.updatedAt?` • ${e.updatedAt}`:"",e.lastHeartbeatAt?` • heartbeat: ${e.lastHeartbeatAt}`:"",typeof e.roundCount=="number"?` • round ${e.roundCount+1}`:""]}),e.outputPreview?i.jsx(C,{type:"secondary",style:{marginTop:s.marginXS,fontSize:13},ellipsis:!0,children:e.outputPreview}):null,e.error?i.jsx(C,{type:"danger",style:{marginTop:s.marginXS},children:e.error}):null]}),i.jsxs(k,{gap:8,children:[i.jsx(_,{size:"small",disabled:$,onClick:()=>{le(e.childSessionId),O(e.childSessionId)},children:t("chat.subAgents.open")}),i.jsx(_,{size:"small",loading:g,disabled:y||a||r,"data-testid":`sub-agent-continue-${e.childSessionId}`,onClick:()=>{Z(e.childSessionId)},children:t("chat.subAgents.continue")}),i.jsx(ce,{trigger:["click"],menu:{items:[{key:"regenerate",label:t("chat.actions.regenerate")},{key:"error_retry",label:t("chat.actions.retryFailed")}],onClick:({key:te})=>{V(e.childSessionId,te)}},disabled:y||r||g,children:i.jsx(_,{size:"small",loading:a,disabled:y||r||g,"data-testid":`sub-agent-retry-${e.childSessionId}`,children:t("chat.subAgents.retry")})}),typeof e.pinned=="boolean"?i.jsx(_,{size:"small",disabled:$,onClick:()=>{e.pinned?J(e.childSessionId):Y(e.childSessionId)},children:e.pinned?t("chat.actions.unpin"):t("chat.actions.pin")}):null,i.jsx(_,{danger:!0,size:"small",loading:y,disabled:a,"data-testid":`sub-agent-delete-${e.childSessionId}`,onClick:()=>{ee(e.childSessionId)},children:t("common.delete")})]})]},e.childSessionId)})}),!o&&w.length>1&&i.jsx(Ae,{items:w})]})},Ae=({items:n})=>{const{token:t}=G(),s=n.reduce((c,p)=>{const d=P(p.status);return d==="completed"?c.completed++:d==="running"?c.running++:d==="error"||d==="failed"?c.error++:c.pending++,c},{completed:0,running:0,error:0,pending:0}),o=[];return s.completed>0&&o.push(`${s.completed} completed`),s.running>0&&o.push(`${s.running} running`),s.pending>0&&o.push(`${s.pending} pending`),s.error>0&&o.push(`${s.error} failed`),o.length===0?null:i.jsx(C,{type:"secondary",style:{fontSize:11,marginTop:t.marginXS,display:"block"},children:o.join(" · ")})};export{Oe as SubAgentsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n}from"./vendor-markdown-DzaXAW9Q.js";import{u as U,a}from"./vendor-i18n-BNURlJ23.js";import{u as k,a as H,b as B,c as P,d as V,A as W,g as z,s as G,o as Y}from"./App-BTGbaEEX.js";import{t as X,K as Z,X as J,N as ee,Y as te,Z as se,$ as ne,a0 as oe,a1 as ae,a2 as ie,V as le,a3 as ce,W as re,j as de,z as me,a4 as ue,l as pe}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-mHH04gTP.js";const ge=[{id:"settings-provider",tabKey:"provider",titleKey:"commandPalette.actions.openProviderSettings",fallbackTitle:"Open Provider Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["api","key","openai","anthropic","gemini","model"]},{id:"settings-model-limits",tabKey:"model-limits",titleKey:"commandPalette.actions.openModelLimits",fallbackTitle:"Open Model Limits",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["token","context","window","budget","limit"]},{id:"settings-prompts",tabKey:"prompts",titleKey:"commandPalette.actions.openPrompts",fallbackTitle:"Open System Prompts",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["system","prompt","persona","instruction"]},{id:"settings-skills",tabKey:"skills",titleKey:"commandPalette.actions.openSkills",fallbackTitle:"Open Skills",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["skill","capability","plugin"]},{id:"settings-mcp",tabKey:"mcp",titleKey:"commandPalette.actions.openMcpSettings",fallbackTitle:"Open MCP Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["mcp","server","tool","external"]},{id:"settings-workflows",tabKey:"workflows",titleKey:"commandPalette.actions.openWorkflowSettings",fallbackTitle:"Open Workflow Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["workflow","automation","template"]},{id:"settings-hooks",tabKey:"hooks",titleKey:"commandPalette.actions.openHooks",fallbackTitle:"Open Hooks",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["hook","event","trigger","callback"]},{id:"settings-schedules",tabKey:"schedules",titleKey:"commandPalette.actions.openSchedulesSettings",fallbackTitle:"Open Schedules",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Ops",keywords:["schedule","cron","recurring","timer","automated"]},{id:"settings-sessions",tabKey:"sessions",titleKey:"commandPalette.actions.openSessionsSettings",fallbackTitle:"Open Session Monitor",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Monitor",keywords:["session","monitor","cleanup","history"]},{id:"settings-metrics",tabKey:"metrics",titleKey:"commandPalette.actions.openMetrics",fallbackTitle:"Open Metrics Dashboard",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Monitor",keywords:["metrics","dashboard","analytics","usage","stats"]},{id:"settings-masking",tabKey:"masking",titleKey:"commandPalette.actions.openMasking",fallbackTitle:"Open Keyword Masking",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"Security & privacy",badge:"Security",keywords:["mask","redact","privacy","keyword","sensitive"]},{id:"settings-env",tabKey:"env-vars",titleKey:"commandPalette.actions.openEnvVars",fallbackTitle:"Open Environment Variables",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["env","environment","variable","config"]},{id:"settings-config",tabKey:"config",titleKey:"commandPalette.actions.openConfig",fallbackTitle:"Open Configuration",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["config","json","bamboo","data","path"]},{id:"settings-app",tabKey:"app",titleKey:"commandPalette.actions.openAppSettings",fallbackTitle:"Open App Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["app","application","reset","theme","language"]}],be=(t,c)=>{const i=[t.title,t.id,t.kind||"root"];return t.pinned&&i.push("pinned","pin"),c&&i.push("running","processing"),t.config.workspacePath&&i.push(t.config.workspacePath),t.updatedAt&&i.push(t.updatedAt),i.filter(Boolean)},fe=(t,c,i)=>{const l=[];if(t.kind==="child"?l.push(c):l.push(i),t.config.workspacePath&&l.push(t.config.workspacePath),t.updatedAt)try{l.push(new Date(t.updatedAt).toLocaleString())}catch{l.push(t.updatedAt)}return l.join(" • ")},ye=(t,c)=>{const i=c.trim().toLowerCase();return i?t.filter(l=>[l.title,l.subtitle||"",...l.keywords].join(" ").toLowerCase().includes(i)):t},ke=t=>{if(!(t instanceof HTMLElement))return!1;const c=t.tagName.toLowerCase();return t.isContentEditable?!0:c==="input"||c==="textarea"||c==="select"},K="__LOTUS_COMMAND_PALETTE_FORCE_OPEN__",Te=()=>{const{t}=U(),{token:c}=X.useToken(),i=typeof document<"u"&&document.body.getAttribute("data-vdi-safe")==="true",{message:l}=Z.useApp(),x=k(e=>e.chats),j=k(e=>e.addChat),v=k(e=>e.lastSelectedPromptId),m=k(e=>e.systemPrompts),I=k(e=>e.executionBySession),[u,p]=a.useState(()=>typeof window>"u"?!1:window[K]?(delete window[K],!0):!1),[T,S]=a.useState(""),[b,f]=a.useState(0),A=a.useRef(null),M=a.useRef(null),C=H(e=>e.open),O=B(e=>e.toggleTheme),E=B(e=>e.themeMode),w=P(e=>e.sidebar.collapsed),N=P(e=>e.setSidebarCollapsed),h=V(e=>e.mode),L=V(e=>e.toggleMode),R=a.useCallback(async()=>{var F,q;const e=m.find(y=>y.id===v),s=(e==null?void 0:e.id)||(m.length>0?((F=m.find(y=>y.id==="general_assistant"))==null?void 0:F.id)||m[0].id:""),d=await j({title:t("chat.sidebar.newSession"),createdAt:Date.now(),messages:[],config:{systemPromptId:s,baseSystemPrompt:(e==null?void 0:e.content)||(m.length>0?((q=m.find(y=>y.id==="general_assistant"))==null?void 0:q.content)||m[0].content:""),lastUsedEnhancedPrompt:null}}),{activeLeafId:o,setLeafSessionId:g,setActiveLeafId:Q}=P.getState();g(o,d),Q(o)},[j,v,m,t]),_=a.useMemo(()=>{const e=ge.filter(s=>!(h==="simple"&&W.has(s.tabKey))).map(s=>({id:s.id,kind:"action",title:t(s.titleKey,s.fallbackTitle),subtitle:t(s.subtitleKey||"commandPalette.groups.settings",s.fallbackSubtitle||"System settings"),keywords:[s.tabKey,s.badge||"","settings","config",...s.keywords||[]],icon:n.jsx(J,{}),badge:s.badge,onSelect:()=>{C("chat",s.tabKey)}}));return[{id:"new-session",kind:"action",title:t("commandPalette.actions.newSession","Create New Session"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["new","create","session","chat","conversation"],icon:n.jsx(ee,{}),badge:t("commandPalette.badges.quickAction","Action"),onSelect:async()=>{await R()}},{id:"toggle-theme",kind:"action",title:E==="dark"?t("commandPalette.actions.switchToLight","Switch to Light Mode"):t("commandPalette.actions.switchToDark","Switch to Dark Mode"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["theme","dark","light","mode","appearance","toggle","color"],icon:n.jsx(te,{}),badge:E==="dark"?"☀️":"🌙",onSelect:()=>{O()}},{id:"toggle-sidebar",kind:"action",title:w?t("commandPalette.actions.showSidebar","Show Sidebar"):t("commandPalette.actions.hideSidebar","Hide Sidebar"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["sidebar","toggle","hide","show","panel","menu"],icon:w?n.jsx(se,{}):n.jsx(ne,{}),badge:"Layout",onSelect:()=>{N(!w)}},{id:"split-pane",kind:"action",title:t("commandPalette.actions.splitPane","Split Pane"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["split","pane","multi","dual","side","layout"],icon:n.jsx(oe,{}),badge:"Layout",onSelect:()=>{const{tree:s,activeLeafId:d,splitLeaf:o}=P.getState();z(s).length<4&&o(d,"vertical")}},...e,{id:"toggle-experience-mode",kind:"action",title:h==="simple"?t("commandPalette.actions.switchToAdvanced","Switch to Advanced Mode"):t("commandPalette.actions.switchToSimple","Switch to Simple Mode"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["mode","simple","advanced","beginner","expert","experience","complexity"],icon:n.jsx(ae,{}),badge:h==="simple"?"Simple":"Advanced",onSelect:()=>{L()}}]},[R,C,O,E,w,N,h,L,t]),D=a.useMemo(()=>x.map(e=>{const s=G(e.id)({executionBySession:I});return{id:`session-${e.id}`,kind:"session",title:e.title,subtitle:fe(e,t("commandPalette.badges.childSession","Child session"),t("commandPalette.badges.rootSession","Session")),keywords:be(e,s),icon:n.jsx(ie,{}),badge:e.pinned?t("commandPalette.badges.pinned","Pinned"):s?t("commandPalette.badges.running","Running"):e.kind==="child"?t("commandPalette.badges.child","Child"):void 0,onSelect:()=>{Y(e.id)}}}),[x,I,t]),$=a.useMemo(()=>[..._,...D],[_,D]),r=a.useMemo(()=>ye($,T).slice(0,40),[$,T]);return a.useEffect(()=>{f(e=>r.length===0?0:Math.min(e,r.length-1))},[r.length]),a.useEffect(()=>{if(!u)return;const e=window.setTimeout(()=>{var s,d;(s=A.current)==null||s.focus(),(d=A.current)==null||d.select()},0);return()=>window.clearTimeout(e)},[u]),a.useEffect(()=>{if(typeof window>"u")return;const e=s=>{if((s.metaKey||s.ctrlKey)&&s.key.toLowerCase()==="k"){s.preventDefault(),p(o=>!o);return}if(u){if(s.key==="Escape"){s.preventDefault(),p(!1);return}if(!(ke(s.target)&&s.key!=="ArrowUp"&&s.key!=="ArrowDown"&&s.key!=="Enter")){if(s.key==="ArrowDown"){s.preventDefault(),f(o=>r.length===0?0:(o+1)%r.length);return}if(s.key==="ArrowUp"){s.preventDefault(),f(o=>r.length===0?0:o===0?r.length-1:o-1);return}if(s.key==="Enter"){const o=r[b];if(!o)return;s.preventDefault(),(async()=>{try{await o.onSelect(),p(!1),S("")}catch(g){console.error("[CommandPalette] action failed",g),l.error(g instanceof Error?g.message:t("commandPalette.errors.actionFailed","Command failed"))}})()}}}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,l,u,b,t]),a.useEffect(()=>{u||(S(""),f(0))},[u]),a.useEffect(()=>{typeof window>"u"||!window[K]||(delete window[K],p(!0))},[]),a.useEffect(()=>{const e=M.current;if(!e)return;const s=e.querySelector(`[data-command-index="${b}"]`);s==null||s.scrollIntoView({block:"nearest"})},[b]),n.jsx(le,{open:u,onCancel:()=>p(!1),footer:null,centered:!0,width:680,destroyOnClose:!0,className:"lotus-command-palette-modal",title:null,closable:!1,styles:{content:{padding:12,borderRadius:c.borderRadiusLG,overflow:"hidden",background:c.colorBgElevated,backdropFilter:i?"none":"blur(18px)",WebkitBackdropFilter:i?"none":"blur(18px)"},body:{padding:0},mask:{backdropFilter:i?"none":"blur(6px)",WebkitBackdropFilter:i?"none":"blur(6px)"}},children:n.jsxs("div",{className:"lotus-command-palette-shell",children:[n.jsxs("div",{className:"lotus-command-palette-search",children:[n.jsx(ce,{style:{color:c.colorTextTertiary,fontSize:16}}),n.jsx(re,{ref:A,value:T,onChange:e=>S(e.target.value),variant:"borderless",placeholder:t("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),"aria-label":t("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),suffix:n.jsx(de.Text,{type:"secondary",style:{fontSize:12},children:"⌘K"})})]}),n.jsxs("div",{className:"lotus-command-palette-hint",children:[n.jsx(me,{}),n.jsx("span",{children:t("commandPalette.navigationHint","Use ↑↓ to navigate, Enter to open, and Esc to close.")})]}),n.jsx("div",{ref:M,className:"lotus-command-palette-list",role:"listbox",children:r.length===0?n.jsxs("div",{className:"lotus-command-palette-empty",children:[n.jsx(ue,{}),n.jsx("span",{children:t("commandPalette.empty","No matching commands")})]}):r.map((e,s)=>{const d=s===b;return n.jsxs("button",{type:"button",className:`lotus-command-palette-item ${d?"is-selected":""}`,"data-command-index":s,onMouseEnter:()=>f(s),onClick:()=>{(async()=>{try{await e.onSelect(),p(!1),S("")}catch(o){console.error("[CommandPalette] action failed",o),l.error(o instanceof Error?o.message:t("commandPalette.errors.actionFailed","Command failed"))}})()},children:[n.jsx("span",{className:"lotus-command-palette-item-icon",children:e.icon}),n.jsxs("span",{className:"lotus-command-palette-item-content",children:[n.jsxs("span",{className:"lotus-command-palette-item-title-row",children:[n.jsx("span",{className:"lotus-command-palette-item-title",children:e.title}),e.badge?n.jsx(pe,{bordered:!1,children:e.badge}):null]}),e.subtitle?n.jsx("span",{className:"lotus-command-palette-item-subtitle",children:e.subtitle}):null]})]},e.id)})})]})})};export{Te as CommandPalette,Te as default};
|
|
1
|
+
import{j as n}from"./vendor-markdown-DzaXAW9Q.js";import{u as U,a}from"./vendor-i18n-BNURlJ23.js";import{u as k,a as H,b as B,c as P,d as V,A as W,g as z,s as G,o as Y}from"./App-BocqxYkX.js";import{t as X,K as Z,X as J,N as ee,Y as te,Z as se,$ as ne,a0 as oe,a1 as ae,a2 as ie,V as le,a3 as ce,W as re,j as de,z as me,a4 as ue,l as pe}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-TSfsr__P.js";const ge=[{id:"settings-provider",tabKey:"provider",titleKey:"commandPalette.actions.openProviderSettings",fallbackTitle:"Open Provider Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["api","key","openai","anthropic","gemini","model"]},{id:"settings-model-limits",tabKey:"model-limits",titleKey:"commandPalette.actions.openModelLimits",fallbackTitle:"Open Model Limits",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["token","context","window","budget","limit"]},{id:"settings-prompts",tabKey:"prompts",titleKey:"commandPalette.actions.openPrompts",fallbackTitle:"Open System Prompts",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["system","prompt","persona","instruction"]},{id:"settings-skills",tabKey:"skills",titleKey:"commandPalette.actions.openSkills",fallbackTitle:"Open Skills",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["skill","capability","plugin"]},{id:"settings-mcp",tabKey:"mcp",titleKey:"commandPalette.actions.openMcpSettings",fallbackTitle:"Open MCP Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["mcp","server","tool","external"]},{id:"settings-workflows",tabKey:"workflows",titleKey:"commandPalette.actions.openWorkflowSettings",fallbackTitle:"Open Workflow Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["workflow","automation","template"]},{id:"settings-hooks",tabKey:"hooks",titleKey:"commandPalette.actions.openHooks",fallbackTitle:"Open Hooks",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["hook","event","trigger","callback"]},{id:"settings-schedules",tabKey:"schedules",titleKey:"commandPalette.actions.openSchedulesSettings",fallbackTitle:"Open Schedules",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Ops",keywords:["schedule","cron","recurring","timer","automated"]},{id:"settings-sessions",tabKey:"sessions",titleKey:"commandPalette.actions.openSessionsSettings",fallbackTitle:"Open Session Monitor",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Monitor",keywords:["session","monitor","cleanup","history"]},{id:"settings-metrics",tabKey:"metrics",titleKey:"commandPalette.actions.openMetrics",fallbackTitle:"Open Metrics Dashboard",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Monitor",keywords:["metrics","dashboard","analytics","usage","stats"]},{id:"settings-masking",tabKey:"masking",titleKey:"commandPalette.actions.openMasking",fallbackTitle:"Open Keyword Masking",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"Security & privacy",badge:"Security",keywords:["mask","redact","privacy","keyword","sensitive"]},{id:"settings-env",tabKey:"env-vars",titleKey:"commandPalette.actions.openEnvVars",fallbackTitle:"Open Environment Variables",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["env","environment","variable","config"]},{id:"settings-config",tabKey:"config",titleKey:"commandPalette.actions.openConfig",fallbackTitle:"Open Configuration",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["config","json","bamboo","data","path"]},{id:"settings-app",tabKey:"app",titleKey:"commandPalette.actions.openAppSettings",fallbackTitle:"Open App Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["app","application","reset","theme","language"]}],be=(t,c)=>{const i=[t.title,t.id,t.kind||"root"];return t.pinned&&i.push("pinned","pin"),c&&i.push("running","processing"),t.config.workspacePath&&i.push(t.config.workspacePath),t.updatedAt&&i.push(t.updatedAt),i.filter(Boolean)},fe=(t,c,i)=>{const l=[];if(t.kind==="child"?l.push(c):l.push(i),t.config.workspacePath&&l.push(t.config.workspacePath),t.updatedAt)try{l.push(new Date(t.updatedAt).toLocaleString())}catch{l.push(t.updatedAt)}return l.join(" • ")},ye=(t,c)=>{const i=c.trim().toLowerCase();return i?t.filter(l=>[l.title,l.subtitle||"",...l.keywords].join(" ").toLowerCase().includes(i)):t},ke=t=>{if(!(t instanceof HTMLElement))return!1;const c=t.tagName.toLowerCase();return t.isContentEditable?!0:c==="input"||c==="textarea"||c==="select"},K="__LOTUS_COMMAND_PALETTE_FORCE_OPEN__",Te=()=>{const{t}=U(),{token:c}=X.useToken(),i=typeof document<"u"&&document.body.getAttribute("data-vdi-safe")==="true",{message:l}=Z.useApp(),x=k(e=>e.chats),j=k(e=>e.addChat),v=k(e=>e.lastSelectedPromptId),m=k(e=>e.systemPrompts),I=k(e=>e.executionBySession),[u,p]=a.useState(()=>typeof window>"u"?!1:window[K]?(delete window[K],!0):!1),[T,S]=a.useState(""),[b,f]=a.useState(0),A=a.useRef(null),M=a.useRef(null),C=H(e=>e.open),O=B(e=>e.toggleTheme),E=B(e=>e.themeMode),w=P(e=>e.sidebar.collapsed),N=P(e=>e.setSidebarCollapsed),h=V(e=>e.mode),L=V(e=>e.toggleMode),R=a.useCallback(async()=>{var F,q;const e=m.find(y=>y.id===v),s=(e==null?void 0:e.id)||(m.length>0?((F=m.find(y=>y.id==="general_assistant"))==null?void 0:F.id)||m[0].id:""),d=await j({title:t("chat.sidebar.newSession"),createdAt:Date.now(),messages:[],config:{systemPromptId:s,baseSystemPrompt:(e==null?void 0:e.content)||(m.length>0?((q=m.find(y=>y.id==="general_assistant"))==null?void 0:q.content)||m[0].content:""),lastUsedEnhancedPrompt:null}}),{activeLeafId:o,setLeafSessionId:g,setActiveLeafId:Q}=P.getState();g(o,d),Q(o)},[j,v,m,t]),_=a.useMemo(()=>{const e=ge.filter(s=>!(h==="simple"&&W.has(s.tabKey))).map(s=>({id:s.id,kind:"action",title:t(s.titleKey,s.fallbackTitle),subtitle:t(s.subtitleKey||"commandPalette.groups.settings",s.fallbackSubtitle||"System settings"),keywords:[s.tabKey,s.badge||"","settings","config",...s.keywords||[]],icon:n.jsx(J,{}),badge:s.badge,onSelect:()=>{C("chat",s.tabKey)}}));return[{id:"new-session",kind:"action",title:t("commandPalette.actions.newSession","Create New Session"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["new","create","session","chat","conversation"],icon:n.jsx(ee,{}),badge:t("commandPalette.badges.quickAction","Action"),onSelect:async()=>{await R()}},{id:"toggle-theme",kind:"action",title:E==="dark"?t("commandPalette.actions.switchToLight","Switch to Light Mode"):t("commandPalette.actions.switchToDark","Switch to Dark Mode"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["theme","dark","light","mode","appearance","toggle","color"],icon:n.jsx(te,{}),badge:E==="dark"?"☀️":"🌙",onSelect:()=>{O()}},{id:"toggle-sidebar",kind:"action",title:w?t("commandPalette.actions.showSidebar","Show Sidebar"):t("commandPalette.actions.hideSidebar","Hide Sidebar"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["sidebar","toggle","hide","show","panel","menu"],icon:w?n.jsx(se,{}):n.jsx(ne,{}),badge:"Layout",onSelect:()=>{N(!w)}},{id:"split-pane",kind:"action",title:t("commandPalette.actions.splitPane","Split Pane"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["split","pane","multi","dual","side","layout"],icon:n.jsx(oe,{}),badge:"Layout",onSelect:()=>{const{tree:s,activeLeafId:d,splitLeaf:o}=P.getState();z(s).length<4&&o(d,"vertical")}},...e,{id:"toggle-experience-mode",kind:"action",title:h==="simple"?t("commandPalette.actions.switchToAdvanced","Switch to Advanced Mode"):t("commandPalette.actions.switchToSimple","Switch to Simple Mode"),subtitle:t("commandPalette.groups.quickActions","Quick actions"),keywords:["mode","simple","advanced","beginner","expert","experience","complexity"],icon:n.jsx(ae,{}),badge:h==="simple"?"Simple":"Advanced",onSelect:()=>{L()}}]},[R,C,O,E,w,N,h,L,t]),D=a.useMemo(()=>x.map(e=>{const s=G(e.id)({executionBySession:I});return{id:`session-${e.id}`,kind:"session",title:e.title,subtitle:fe(e,t("commandPalette.badges.childSession","Child session"),t("commandPalette.badges.rootSession","Session")),keywords:be(e,s),icon:n.jsx(ie,{}),badge:e.pinned?t("commandPalette.badges.pinned","Pinned"):s?t("commandPalette.badges.running","Running"):e.kind==="child"?t("commandPalette.badges.child","Child"):void 0,onSelect:()=>{Y(e.id)}}}),[x,I,t]),$=a.useMemo(()=>[..._,...D],[_,D]),r=a.useMemo(()=>ye($,T).slice(0,40),[$,T]);return a.useEffect(()=>{f(e=>r.length===0?0:Math.min(e,r.length-1))},[r.length]),a.useEffect(()=>{if(!u)return;const e=window.setTimeout(()=>{var s,d;(s=A.current)==null||s.focus(),(d=A.current)==null||d.select()},0);return()=>window.clearTimeout(e)},[u]),a.useEffect(()=>{if(typeof window>"u")return;const e=s=>{if((s.metaKey||s.ctrlKey)&&s.key.toLowerCase()==="k"){s.preventDefault(),p(o=>!o);return}if(u){if(s.key==="Escape"){s.preventDefault(),p(!1);return}if(!(ke(s.target)&&s.key!=="ArrowUp"&&s.key!=="ArrowDown"&&s.key!=="Enter")){if(s.key==="ArrowDown"){s.preventDefault(),f(o=>r.length===0?0:(o+1)%r.length);return}if(s.key==="ArrowUp"){s.preventDefault(),f(o=>r.length===0?0:o===0?r.length-1:o-1);return}if(s.key==="Enter"){const o=r[b];if(!o)return;s.preventDefault(),(async()=>{try{await o.onSelect(),p(!1),S("")}catch(g){console.error("[CommandPalette] action failed",g),l.error(g instanceof Error?g.message:t("commandPalette.errors.actionFailed","Command failed"))}})()}}}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,l,u,b,t]),a.useEffect(()=>{u||(S(""),f(0))},[u]),a.useEffect(()=>{typeof window>"u"||!window[K]||(delete window[K],p(!0))},[]),a.useEffect(()=>{const e=M.current;if(!e)return;const s=e.querySelector(`[data-command-index="${b}"]`);s==null||s.scrollIntoView({block:"nearest"})},[b]),n.jsx(le,{open:u,onCancel:()=>p(!1),footer:null,centered:!0,width:680,destroyOnClose:!0,className:"lotus-command-palette-modal",title:null,closable:!1,styles:{content:{padding:12,borderRadius:c.borderRadiusLG,overflow:"hidden",background:c.colorBgElevated,backdropFilter:i?"none":"blur(18px)",WebkitBackdropFilter:i?"none":"blur(18px)"},body:{padding:0},mask:{backdropFilter:i?"none":"blur(6px)",WebkitBackdropFilter:i?"none":"blur(6px)"}},children:n.jsxs("div",{className:"lotus-command-palette-shell",children:[n.jsxs("div",{className:"lotus-command-palette-search",children:[n.jsx(ce,{style:{color:c.colorTextTertiary,fontSize:16}}),n.jsx(re,{ref:A,value:T,onChange:e=>S(e.target.value),variant:"borderless",placeholder:t("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),"aria-label":t("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),suffix:n.jsx(de.Text,{type:"secondary",style:{fontSize:12},children:"⌘K"})})]}),n.jsxs("div",{className:"lotus-command-palette-hint",children:[n.jsx(me,{}),n.jsx("span",{children:t("commandPalette.navigationHint","Use ↑↓ to navigate, Enter to open, and Esc to close.")})]}),n.jsx("div",{ref:M,className:"lotus-command-palette-list",role:"listbox",children:r.length===0?n.jsxs("div",{className:"lotus-command-palette-empty",children:[n.jsx(ue,{}),n.jsx("span",{children:t("commandPalette.empty","No matching commands")})]}):r.map((e,s)=>{const d=s===b;return n.jsxs("button",{type:"button",className:`lotus-command-palette-item ${d?"is-selected":""}`,"data-command-index":s,onMouseEnter:()=>f(s),onClick:()=>{(async()=>{try{await e.onSelect(),p(!1),S("")}catch(o){console.error("[CommandPalette] action failed",o),l.error(o instanceof Error?o.message:t("commandPalette.errors.actionFailed","Command failed"))}})()},children:[n.jsx("span",{className:"lotus-command-palette-item-icon",children:e.icon}),n.jsxs("span",{className:"lotus-command-palette-item-content",children:[n.jsxs("span",{className:"lotus-command-palette-item-title-row",children:[n.jsx("span",{className:"lotus-command-palette-item-title",children:e.title}),e.badge?n.jsx(pe,{bordered:!1,children:e.badge}):null]}),e.subtitle?n.jsx("span",{className:"lotus-command-palette-item-subtitle",children:e.subtitle}):null]})]},e.id)})})]})})};export{Te as CommandPalette,Te as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as o}from"./vendor-markdown-DzaXAW9Q.js";import{u as A,R as D,a as T}from"./vendor-i18n-BNURlJ23.js";import{u as g}from"./App-
|
|
1
|
+
import{j as o}from"./vendor-markdown-DzaXAW9Q.js";import{u as A,R as D,a as T}from"./vendor-i18n-BNURlJ23.js";import{u as g}from"./App-BocqxYkX.js";import{t as F,C as M,A as W,i as q,P as O,j as Q,L as k,S as m,k as f,l as y,m as G,n as H,o as $,p as J,q as N,u as U,v as V,w as X,x as v,B as Y,y as Z,z as oo}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-TSfsr__P.js";const{Text:p}=Q,so=c=>({pending:{icon:o.jsx(oo,{}),color:c.colorTextTertiary,textKey:"components.todoList.status.pending",tagColor:"default"},in_progress:{icon:o.jsx(v,{spin:!0}),color:c.colorPrimary,textKey:"components.todoList.status.inProgress",tagColor:"processing"},completed:{icon:o.jsx($,{}),color:c.colorSuccess,textKey:"components.todoList.status.completed",tagColor:"success"},blocked:{icon:o.jsx(Z,{}),color:c.colorError,textKey:"components.todoList.status.blocked",tagColor:"error"}}),io=({sessionId:c,initialCollapsed:P=!0})=>{const{t:e}=A(),{token:t}=F.useToken(),z=D.useMemo(()=>so(t),[t]),x=g(s=>s.chats.find(d=>d.id===c)),h=(x==null?void 0:x.kind)==="child"&&(x.parentSessionId||x.rootSessionId)||c,n=g(s=>s.taskLists[h]),_=g(s=>s.activeItems[h]),a=g(s=>s.evaluationStates[h]),[l,S]=T.useState(P),[i,B]=T.useState(!1),I=(a==null?void 0:a.isEvaluating)||!1,L=(a==null?void 0:a.reasoning)||null,C=n?{session_id:n.session_id,title:n.title,items:n.items,progress:{completed:n.items.filter(s=>s.status==="completed").length,total:n.items.length,percentage:n.items.length>0?Math.round(n.items.filter(s=>s.status==="completed").length/n.items.length*100):0}}:null;if(!C)return null;const R=()=>{i||S(!l)},w=s=>{s.stopPropagation(),B(!i),i||S(!1)},{title:E,items:K,progress:r}=C,j=r.percentage===100;return o.jsx(M,{size:"small",style:{marginBottom:16,borderRadius:8,boxShadow:I?`0 0 0 2px ${t.colorPrimaryBorder}`:"0 2px 8px rgba(0, 0, 0, 0.06)",opacity:l&&!i?.9:1},styles:{body:{padding:l?"12px 16px":16}},title:o.jsxs(m,{onClick:R,style:{cursor:"pointer",width:"100%"},children:[o.jsx(X,{style:{color:t.colorPrimary}}),o.jsx(p,{strong:!0,style:{fontSize:15},children:E||e("components.todoList.title")}),I&&o.jsx(y,{icon:o.jsx(v,{spin:!0}),color:"processing",children:e("components.todoList.evaluating")}),!l&&r.total>0&&o.jsx(Y,{count:`${r.completed}/${r.total}`,style:{backgroundColor:j?t.colorSuccess:t.colorPrimary}})]}),extra:o.jsxs(m,{children:[r.total>0&&l&&o.jsxs(p,{type:"secondary",style:{fontSize:13},children:[r.completed,"/",r.total,j&&o.jsx($,{style:{color:t.colorSuccess,marginLeft:4}})]}),o.jsx(f,{title:e(i?"components.todoList.unpin":"components.todoList.pin"),children:o.jsx("span",{onClick:w,style:{cursor:"pointer",color:i?t.colorPrimary:t.colorTextSecondary,fontSize:16},children:i?o.jsx(J,{}):o.jsx(N,{})})}),!i&&o.jsx("span",{onClick:R,style:{cursor:"pointer",color:t.colorTextSecondary,fontSize:12,transform:l?"rotate(-90deg)":void 0,transition:"transform 0.2s"},children:l?o.jsx(U,{}):o.jsx(V,{})})]}),children:!l&&o.jsxs(o.Fragment,{children:[L&&o.jsx(W,{icon:o.jsx(q,{}),message:e("components.todoList.llmEvaluation"),description:L,type:"info",showIcon:!0,style:{marginBottom:16}}),r.total>0&&o.jsx("div",{style:{marginBottom:16},children:o.jsx(O,{percent:r.percentage,size:"small",status:j?"success":"active",format:s=>o.jsxs(p,{type:"secondary",children:[s,"%"]})})}),o.jsx(k,{size:"small",dataSource:K,renderItem:s=>{const d=z[s.status],u=_===s.id,b=e(d.textKey);return o.jsx(k.Item,{style:{padding:"12px 0",borderLeft:u?`3px solid ${t.colorPrimary}`:"3px solid transparent",paddingLeft:u?12:15,backgroundColor:u?t.colorPrimaryBg:"transparent",borderRadius:4,marginBottom:4},children:o.jsx("div",{style:{width:"100%"},children:o.jsxs(m,{align:"start",style:{width:"100%"},children:[o.jsx(f,{title:b,children:o.jsx("span",{style:{color:d.color,fontSize:16},children:d.icon})}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx(p,{style:{textDecoration:s.status==="completed"?"line-through":"none",color:s.status==="completed"?t.colorTextSecondary:t.colorText,fontWeight:u?500:400},children:s.description}),o.jsx("div",{style:{marginTop:4},children:o.jsxs(m,{size:8,wrap:!0,children:[o.jsx(y,{color:d.tagColor,children:b}),s.tool_calls_count!==void 0&&s.tool_calls_count>0&&o.jsxs(y,{icon:o.jsx(G,{}),color:"processing",children:[s.tool_calls_count," ",e("components.todoList.tools")]}),s.depends_on.length>0&&o.jsx(f,{title:e("components.todoList.dependsOn",{deps:s.depends_on.join(", ")}),children:o.jsxs(y,{icon:o.jsx(H,{}),children:[s.depends_on.length," ",e("components.todoList.dependencies")]})})]})}),s.status==="completed"&&s.summary&&o.jsx(p,{type:"secondary",style:{display:"block",marginTop:6,fontSize:12,padding:"4px 8px",backgroundColor:t.colorSuccessBg,borderRadius:4,color:t.colorSuccess},children:s.summary}),s.notes&&o.jsx(p,{type:"secondary",style:{display:"block",marginTop:6,fontSize:12,padding:"4px 8px",backgroundColor:t.colorFillQuaternary,borderRadius:4},children:s.notes})]})]})})})}})]})})};export{io as TodoList,io as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var ee=Object.defineProperty;var te=(i,t,s)=>t in i?ee(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var z=(i,t,s)=>te(i,typeof t!="symbol"?t+"":t,s);import{j as e}from"./vendor-markdown-DzaXAW9Q.js";import{u as V,a as o,i as J}from"./vendor-i18n-BNURlJ23.js";import{y as D,v as se}from"./App-BTGbaEEX.js";import{K as Z,t as Y,j as B,V as G,S as j,E as P,an as N,ao as ae,ap as re,aq as K,C as ie,J as O,G as M,L as W,H as C,a7 as _,ar as Q,as as ne,o as ce,y as oe,A as L,W as le,at as de}from"./vendor-antd-DODjfilb.js";import"./main-mHH04gTP.js";import"./vendor-mermaid-De-Yacw-.js";const he=({visible:i,onClose:t,onSelect:s})=>{const{t:n}=V(),{message:r}=Z.useApp(),{token:a}=Y.useToken(),{Text:c}=B,[p,w]=o.useState(!1),[l,x]=o.useState(""),[u,I]=o.useState(),[S,k]=o.useState([]),[v,y]=o.useState([]);o.useEffect(()=>{i&&m()},[i]);const m=async d=>{w(!0);try{const g=await D.browseFolder(d);x(g.current_path),I(g.parent_path),k(g.folders)}catch(g){console.error("Failed to load directory:",g),r.error("Unable to read folder")}finally{w(!1)}},f=d=>{y([...v,l]),m(d.path)},E=()=>{u&&(y(v.slice(0,-1)),m(u))},T=()=>{y([]),m()},b=()=>{s(l),t()},R=()=>{if(!l)return[];const d=l.split(/[/\\]/).filter(Boolean);return l.startsWith("/")&&d.unshift("/"),d},A=d=>{const F=R().slice(0,d+1).join("/"),$=(l.startsWith("/"),F);m($)};return e.jsx(G,{title:n("chat.folderBrowser.title"),open:i,onCancel:t,width:700,footer:null,children:e.jsxs(j,{direction:"vertical",size:"middle",style:{width:"100%"},children:[e.jsxs(j,{children:[e.jsx(P,{icon:e.jsx(N,{}),onClick:T,size:"small",children:n("common.home")}),e.jsx(P,{icon:e.jsx(ae,{}),onClick:E,disabled:!u,size:"small",children:n("common.parentDirectory")}),e.jsx(P,{type:"primary",icon:e.jsx(re,{}),onClick:b,size:"small",children:n("chat.folderBrowser.selectCurrent")})]}),e.jsx(K,{children:R().map((d,g)=>e.jsx(K.Item,{children:e.jsx(P,{type:"link",size:"small",onClick:()=>A(g),style:{padding:0},children:d==="/"?e.jsx(N,{}):d})},g))}),e.jsxs(ie,{size:"small",styles:{body:{padding:a.paddingXS}},children:[e.jsx(c,{type:"secondary",style:{fontSize:12},children:n("common.currentPath")})," ",e.jsx(c,{code:!0,children:l})]}),e.jsx(O,{spinning:p,children:S.length===0&&!p?e.jsx(M,{image:M.PRESENTED_IMAGE_SIMPLE,description:e.jsx(c,{type:"secondary",children:n("chat.folderBrowser.emptyFolder")})}):e.jsx(W,{dataSource:S,style:{maxHeight:400,overflowY:"auto"},renderItem:d=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(P,{type:"text",icon:e.jsx(C,{}),onClick:()=>f(d),style:{width:"100%",textAlign:"left",padding:`${a.paddingXS}px ${a.paddingSM}px`},children:d.name})})})}),e.jsx(c,{type:"secondary",style:{fontSize:12},children:n("chat.folderBrowser.tip")})]})})};class pe{constructor(t={}){z(this,"cache",new Map);z(this,"pendingValidations",new Map);z(this,"options");this.options={debounceMs:t.debounceMs??300,cacheTimeoutMs:t.cacheTimeoutMs??5*60*1e3,maxRetries:t.maxRetries??3}}async validateWorkspace(t){if(!t||t.trim().length===0)return{path:"",is_valid:!1,error_message:J.t("chat.workspace.errorEnterPath")};const s=t.trim(),n=this.getCachedResult(s);if(n)return n;const r=this.pendingValidations.get(s);if(r)return r;const a=this.performValidation(s);this.pendingValidations.set(s,a);try{const c=await a;return this.setCachedResult(s,c),c}finally{this.pendingValidations.delete(s)}}validateWorkspaceDebounced(t,s){let n;return n=setTimeout(async()=>{try{const a=await this.validateWorkspace(t);s(a)}catch(a){const c={path:t,is_valid:!1,error_message:a instanceof Error?a.message:J.t("chat.workspace.checkDescription")};s(c)}},this.options.debounceMs),()=>{clearTimeout(n)}}clearCache(){this.cache.clear()}getCachedResult(t){const s=this.cache.get(t);return s?Date.now()-s.timestamp>this.options.cacheTimeoutMs?(this.cache.delete(t),null):s.result:null}setCachedResult(t,s){this.cache.set(t,{result:s,timestamp:Date.now()})}async performValidation(t,s=0){try{return await se.post("workspace/validate",{path:t})}catch(n){if(s<this.options.maxRetries&&this.isRetryableError(n))return await this.delay(Math.pow(2,s)*1e3),this.performValidation(t,s+1);throw n}}isRetryableError(t){return t instanceof Error?t.message.includes("Failed to fetch")||t.message.includes("HTTP error! status: 5"):!1}delay(t){return new Promise(s=>setTimeout(s,t))}async validateMultiplePaths(t){const n=[];for(let r=0;r<t.length;r+=5){const a=t.slice(r,r+5),c=await Promise.all(a.map(p=>this.validateWorkspace(p)));n.push(...c),r+5<t.length&&await this.delay(100)}return n}}const ue=new pe,ge=({value:i="",onChange:t,showRecentWorkspaces:s,showSuggestions:n,onValidationChange:r})=>{const{message:a}=Z.useApp(),[c,p]=o.useState(i),[w,l]=o.useState({isValidating:!1,result:null}),[x,u]=o.useState([]),[I,S]=o.useState(!1),[k,v]=o.useState([]),[y,m]=o.useState(!1),[f,E]=o.useState(!1),T=o.useRef(null),b=o.useRef(null);o.useEffect(()=>{p(i)},[i]),o.useEffect(()=>(s&&R(),n&&A(),()=>{T.current&&T.current.abort(),b.current&&b.current()}),[s,n]);const R=o.useCallback(async()=>{m(!0);try{const h=await D.getRecentWorkspaces();u(h.slice(0,5))}catch(h){console.error("Failed to load recent workspaces:",h),u([])}finally{m(!1)}},[]),A=o.useCallback(async()=>{E(!0);try{const h=await D.getPathSuggestions();v(h.suggestions.slice(0,8))}catch(h){console.error("Failed to load suggestions:",h),v([])}finally{E(!1)}},[]),d=o.useCallback(h=>{p(h),t&&t(h),T.current&&T.current.abort(),b.current&&b.current(),h.trim()?(l({isValidating:!0,result:null}),b.current=ue.validateWorkspaceDebounced(h.trim(),q=>{l({isValidating:!1,result:q}),r&&r(q)})):(l({isValidating:!1,result:null}),r&&r(null))},[t,r]),g=o.useCallback(()=>{S(!0)},[]),F=o.useCallback(h=>{d(h),a.success("Folder selected successfully")},[d]),$=o.useCallback(h=>{d(h)},[d]);return{path:c,validationStatus:w,recentWorkspaces:x,suggestions:k,isLoadingRecent:y,isLoadingSuggestions:f,folderBrowserVisible:I,setFolderBrowserVisible:S,handlePathChange:d,handleBrowseClick:g,handleFolderSelect:F,handleWorkspaceSelect:$}},{Text:H}=B,me=({show:i,isLoading:t,recentWorkspaces:s,onSelect:n,token:r})=>{const{t:a}=V();return i?e.jsxs(_,{vertical:!0,gap:r.marginXS,style:{marginTop:r.marginMD},children:[e.jsxs(j,{style:{paddingInline:r.paddingSM},children:[e.jsx(Q,{}),e.jsx(H,{strong:!0,children:a("chat.workspace.recentTitle")})]}),t?e.jsx(_,{justify:"center",style:{padding:r.paddingSM},children:e.jsx(O,{size:"small"})}):s.length===0?e.jsx(M,{description:a("chat.workspace.noRecentWorkspaces"),image:M.PRESENTED_IMAGE_SIMPLE,style:{padding:r.paddingSM}}):e.jsx(W,{size:"small",dataSource:s,style:{paddingInline:r.paddingSM},renderItem:c=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(P,{type:"text",onClick:()=>n(c.path),style:{width:"100%",textAlign:"left",padding:`${r.paddingXS}px 0`,height:"auto"},children:e.jsxs(_,{justify:"space-between",align:"center",style:{width:"100%"},children:[e.jsxs(j,{children:[e.jsx(C,{style:{color:r.colorWarning}}),e.jsx(H,{strong:!0,children:c.workspace_name||c.path.split("/").pop()||a("chat.workspace.defaultWorkspaceName")})]}),e.jsx(H,{type:"secondary",ellipsis:{tooltip:c.path},style:{fontSize:12,maxWidth:"55%",textAlign:"right"},children:c.path})]})})})})]}):null},{Text:X}=B,xe=(i,t)=>{switch(i.suggestion_type){case"home":return e.jsx(N,{style:{color:t.colorPrimary}});case"documents":case"desktop":case"downloads":return e.jsx(C,{style:{color:t.colorSuccess}});case"recent":return e.jsx(Q,{style:{color:t.colorWarning}});default:return e.jsx(C,{})}},fe=({show:i,isLoading:t,suggestions:s,onSelect:n,token:r})=>{const{t:a}=V();return i?e.jsxs(_,{vertical:!0,gap:r.marginXS,style:{marginTop:r.marginMD},children:[e.jsxs(j,{style:{paddingInline:r.paddingSM},children:[e.jsx(C,{}),e.jsx(X,{strong:!0,children:a("chat.workspace.suggestedTitle")})]}),t?e.jsx(_,{justify:"center",style:{padding:r.paddingSM},children:e.jsx(O,{size:"small"})}):s.length===0?e.jsx(M,{description:a("chat.workspace.noSuggestions"),image:M.PRESENTED_IMAGE_SIMPLE,style:{padding:r.paddingSM}}):e.jsx(W,{size:"small",dataSource:s,style:{paddingInline:r.paddingSM},renderItem:c=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(P,{type:"text",onClick:()=>n(c.path),style:{width:"100%",textAlign:"left",padding:`${r.paddingXS}px 0`,height:"auto"},children:e.jsxs(_,{justify:"space-between",align:"center",style:{width:"100%"},children:[e.jsxs(j,{children:[xe(c,r),e.jsx(X,{strong:!0,children:c.name})]}),e.jsx(X,{type:"secondary",ellipsis:{tooltip:c.path},style:{fontSize:12,maxWidth:"55%",textAlign:"right"},children:c.path})]})})})})]}):null},ye=({isValidating:i,result:t,token:s})=>i?e.jsx(ne,{style:{color:s.colorPrimary}}):t?t.is_valid?e.jsx(ce,{style:{color:s.colorSuccess}}):e.jsx(oe,{style:{color:s.colorError}}):null,{Text:U}=B,je=({result:i,token:t})=>{const{t:s}=V();return i?e.jsx("div",{style:{marginTop:t.marginXS},children:i.is_valid?e.jsx(L,{type:"success",message:e.jsxs(j,{children:[e.jsx("span",{children:s("chat.workspace.validWorkspace")}),i.workspace_name&&e.jsxs(U,{type:"secondary",children:["(",i.workspace_name,")"]}),i.file_count!==void 0&&e.jsx(U,{type:"secondary",children:s("chat.workspace.fileCount",{count:i.file_count})})]}),showIcon:!0}):e.jsx(L,{type:"error",message:i.error_message||s("validation.invalidPath"),showIcon:!0})}):null},{Text:we}=B,Se=({value:i="",onChange:t,placeholder:s,disabled:n=!1,allowBrowse:r=!0,showRecentWorkspaces:a=!0,showSuggestions:c=!0,onValidationChange:p,className:w,style:l})=>{const{t:x}=V(),{token:u}=Y.useToken(),I=s??x("chat.workspace.placeholder"),{path:S,validationStatus:k,recentWorkspaces:v,suggestions:y,isLoadingRecent:m,isLoadingSuggestions:f,folderBrowserVisible:E,setFolderBrowserVisible:T,handlePathChange:b,handleBrowseClick:R,handleFolderSelect:A,handleWorkspaceSelect:d}=ge({value:i,onChange:t,showRecentWorkspaces:a,showSuggestions:c,onValidationChange:p});return e.jsxs("div",{className:w,style:l,children:[e.jsx(le,{value:S,onChange:g=>b(g.target.value),placeholder:I,disabled:n,size:"middle",style:{width:"100%"},suffix:e.jsx(ye,{isValidating:k.isValidating,result:k.result,token:u}),addonBefore:e.jsxs(j,{children:[e.jsx(C,{}),e.jsx(we,{children:x("chat.workspace.label")})]}),addonAfter:r?e.jsx(P,{"aria-label":x("chat.workspace.browseFolder"),title:x("chat.workspace.browseFolder"),icon:e.jsx(C,{}),onClick:R,disabled:n,type:"text",size:"middle",style:{display:"inline-flex",alignItems:"center"}}):void 0}),e.jsx(je,{result:k.result,token:u}),(a||c)&&e.jsxs(e.Fragment,{children:[e.jsx(de,{style:{margin:"16px 0 12px 0"}}),e.jsx(me,{show:a,isLoading:m,recentWorkspaces:v,onSelect:d,token:u}),e.jsx(fe,{show:c,isLoading:f,suggestions:y,onSelect:d,token:u})]}),e.jsx(he,{visible:E,onClose:()=>T(!1),onSelect:A})]})},{Title:ke}=B,Re=({open:i,initialPath:t="",loading:s=!1,onSubmit:n,onCancel:r})=>{const{t:a}=V(),{message:c}=Z.useApp(),[p,w]=o.useState(t),[l,x]=o.useState(null),[u,I]=o.useState(!1);o.useEffect(()=>{i&&(w(t),x(null))},[i,t]);const S=f=>{w(f)},k=f=>{x(f)},v=async()=>{if(!p.trim()){c.error(a("chat.workspace.errorEnterPath"));return}l&&!l.is_valid?G.confirm({title:a("chat.workspace.invalidTitle"),content:e.jsxs("div",{children:[e.jsx("p",{children:a("chat.workspace.issuesDetected")}),e.jsx("p",{children:l.error_message||a("chat.workspace.invalidTitle")}),e.jsx("p",{children:a("chat.workspace.confirmSaveInvalid")})]}),okText:a("common.saveAnyway"),cancelText:a("common.cancel"),onOk:()=>y()}):y()},y=async()=>{I(!0);try{l!=null&&l.is_valid&&await D.addRecentWorkspace(p.trim(),{workspace_name:l.workspace_name}),n(p.trim())}catch(f){console.error("Failed to save workspace path:",f),c.error(a("chat.workspace.errorSaveFailed"))}finally{I(!1)}},m=!p.trim()||s||u;return e.jsx(G,{open:i,title:e.jsx(j,{children:e.jsx(ke,{level:4,style:{margin:0},children:a("chat.workspace.modalTitle")})}),okText:a("common.save"),cancelText:a("common.cancel"),onOk:v,onCancel:r,okButtonProps:{disabled:m,loading:u||s},width:600,destroyOnClose:!0,children:e.jsxs(j,{direction:"vertical",size:"middle",style:{width:"100%"},children:[e.jsx(L,{message:a("chat.workspace.descriptionTitle"),description:e.jsxs("div",{children:[e.jsx("p",{children:a("chat.workspace.descriptionP1")}),e.jsx("p",{children:a("chat.workspace.descriptionP2")})]}),type:"info",showIcon:!0}),e.jsx(Se,{value:p,onChange:S,onValidationChange:k,placeholder:a("chat.workspace.placeholder"),disabled:u,allowBrowse:!0,showRecentWorkspaces:!0,showSuggestions:!0}),l&&!l.is_valid&&e.jsx(L,{message:a("chat.workspace.checkTitle"),description:l.error_message||a("chat.workspace.checkDescription"),type:"warning",showIcon:!0})]})})};export{Re as default};
|
|
1
|
+
var ee=Object.defineProperty;var te=(i,t,s)=>t in i?ee(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var z=(i,t,s)=>te(i,typeof t!="symbol"?t+"":t,s);import{j as e}from"./vendor-markdown-DzaXAW9Q.js";import{u as V,a as o,i as J}from"./vendor-i18n-BNURlJ23.js";import{y as D,v as se}from"./App-BocqxYkX.js";import{K as Z,t as Y,j as B,V as G,S as j,E as P,an as N,ao as ae,ap as re,aq as K,C as ie,J as O,G as M,L as W,H as C,a7 as _,ar as Q,as as ne,o as ce,y as oe,A as L,W as le,at as de}from"./vendor-antd-DODjfilb.js";import"./main-TSfsr__P.js";import"./vendor-mermaid-De-Yacw-.js";const he=({visible:i,onClose:t,onSelect:s})=>{const{t:n}=V(),{message:r}=Z.useApp(),{token:a}=Y.useToken(),{Text:c}=B,[p,w]=o.useState(!1),[l,x]=o.useState(""),[u,I]=o.useState(),[S,k]=o.useState([]),[v,y]=o.useState([]);o.useEffect(()=>{i&&m()},[i]);const m=async d=>{w(!0);try{const g=await D.browseFolder(d);x(g.current_path),I(g.parent_path),k(g.folders)}catch(g){console.error("Failed to load directory:",g),r.error("Unable to read folder")}finally{w(!1)}},f=d=>{y([...v,l]),m(d.path)},E=()=>{u&&(y(v.slice(0,-1)),m(u))},T=()=>{y([]),m()},b=()=>{s(l),t()},R=()=>{if(!l)return[];const d=l.split(/[/\\]/).filter(Boolean);return l.startsWith("/")&&d.unshift("/"),d},A=d=>{const F=R().slice(0,d+1).join("/"),$=(l.startsWith("/"),F);m($)};return e.jsx(G,{title:n("chat.folderBrowser.title"),open:i,onCancel:t,width:700,footer:null,children:e.jsxs(j,{direction:"vertical",size:"middle",style:{width:"100%"},children:[e.jsxs(j,{children:[e.jsx(P,{icon:e.jsx(N,{}),onClick:T,size:"small",children:n("common.home")}),e.jsx(P,{icon:e.jsx(ae,{}),onClick:E,disabled:!u,size:"small",children:n("common.parentDirectory")}),e.jsx(P,{type:"primary",icon:e.jsx(re,{}),onClick:b,size:"small",children:n("chat.folderBrowser.selectCurrent")})]}),e.jsx(K,{children:R().map((d,g)=>e.jsx(K.Item,{children:e.jsx(P,{type:"link",size:"small",onClick:()=>A(g),style:{padding:0},children:d==="/"?e.jsx(N,{}):d})},g))}),e.jsxs(ie,{size:"small",styles:{body:{padding:a.paddingXS}},children:[e.jsx(c,{type:"secondary",style:{fontSize:12},children:n("common.currentPath")})," ",e.jsx(c,{code:!0,children:l})]}),e.jsx(O,{spinning:p,children:S.length===0&&!p?e.jsx(M,{image:M.PRESENTED_IMAGE_SIMPLE,description:e.jsx(c,{type:"secondary",children:n("chat.folderBrowser.emptyFolder")})}):e.jsx(W,{dataSource:S,style:{maxHeight:400,overflowY:"auto"},renderItem:d=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(P,{type:"text",icon:e.jsx(C,{}),onClick:()=>f(d),style:{width:"100%",textAlign:"left",padding:`${a.paddingXS}px ${a.paddingSM}px`},children:d.name})})})}),e.jsx(c,{type:"secondary",style:{fontSize:12},children:n("chat.folderBrowser.tip")})]})})};class pe{constructor(t={}){z(this,"cache",new Map);z(this,"pendingValidations",new Map);z(this,"options");this.options={debounceMs:t.debounceMs??300,cacheTimeoutMs:t.cacheTimeoutMs??5*60*1e3,maxRetries:t.maxRetries??3}}async validateWorkspace(t){if(!t||t.trim().length===0)return{path:"",is_valid:!1,error_message:J.t("chat.workspace.errorEnterPath")};const s=t.trim(),n=this.getCachedResult(s);if(n)return n;const r=this.pendingValidations.get(s);if(r)return r;const a=this.performValidation(s);this.pendingValidations.set(s,a);try{const c=await a;return this.setCachedResult(s,c),c}finally{this.pendingValidations.delete(s)}}validateWorkspaceDebounced(t,s){let n;return n=setTimeout(async()=>{try{const a=await this.validateWorkspace(t);s(a)}catch(a){const c={path:t,is_valid:!1,error_message:a instanceof Error?a.message:J.t("chat.workspace.checkDescription")};s(c)}},this.options.debounceMs),()=>{clearTimeout(n)}}clearCache(){this.cache.clear()}getCachedResult(t){const s=this.cache.get(t);return s?Date.now()-s.timestamp>this.options.cacheTimeoutMs?(this.cache.delete(t),null):s.result:null}setCachedResult(t,s){this.cache.set(t,{result:s,timestamp:Date.now()})}async performValidation(t,s=0){try{return await se.post("workspace/validate",{path:t})}catch(n){if(s<this.options.maxRetries&&this.isRetryableError(n))return await this.delay(Math.pow(2,s)*1e3),this.performValidation(t,s+1);throw n}}isRetryableError(t){return t instanceof Error?t.message.includes("Failed to fetch")||t.message.includes("HTTP error! status: 5"):!1}delay(t){return new Promise(s=>setTimeout(s,t))}async validateMultiplePaths(t){const n=[];for(let r=0;r<t.length;r+=5){const a=t.slice(r,r+5),c=await Promise.all(a.map(p=>this.validateWorkspace(p)));n.push(...c),r+5<t.length&&await this.delay(100)}return n}}const ue=new pe,ge=({value:i="",onChange:t,showRecentWorkspaces:s,showSuggestions:n,onValidationChange:r})=>{const{message:a}=Z.useApp(),[c,p]=o.useState(i),[w,l]=o.useState({isValidating:!1,result:null}),[x,u]=o.useState([]),[I,S]=o.useState(!1),[k,v]=o.useState([]),[y,m]=o.useState(!1),[f,E]=o.useState(!1),T=o.useRef(null),b=o.useRef(null);o.useEffect(()=>{p(i)},[i]),o.useEffect(()=>(s&&R(),n&&A(),()=>{T.current&&T.current.abort(),b.current&&b.current()}),[s,n]);const R=o.useCallback(async()=>{m(!0);try{const h=await D.getRecentWorkspaces();u(h.slice(0,5))}catch(h){console.error("Failed to load recent workspaces:",h),u([])}finally{m(!1)}},[]),A=o.useCallback(async()=>{E(!0);try{const h=await D.getPathSuggestions();v(h.suggestions.slice(0,8))}catch(h){console.error("Failed to load suggestions:",h),v([])}finally{E(!1)}},[]),d=o.useCallback(h=>{p(h),t&&t(h),T.current&&T.current.abort(),b.current&&b.current(),h.trim()?(l({isValidating:!0,result:null}),b.current=ue.validateWorkspaceDebounced(h.trim(),q=>{l({isValidating:!1,result:q}),r&&r(q)})):(l({isValidating:!1,result:null}),r&&r(null))},[t,r]),g=o.useCallback(()=>{S(!0)},[]),F=o.useCallback(h=>{d(h),a.success("Folder selected successfully")},[d]),$=o.useCallback(h=>{d(h)},[d]);return{path:c,validationStatus:w,recentWorkspaces:x,suggestions:k,isLoadingRecent:y,isLoadingSuggestions:f,folderBrowserVisible:I,setFolderBrowserVisible:S,handlePathChange:d,handleBrowseClick:g,handleFolderSelect:F,handleWorkspaceSelect:$}},{Text:H}=B,me=({show:i,isLoading:t,recentWorkspaces:s,onSelect:n,token:r})=>{const{t:a}=V();return i?e.jsxs(_,{vertical:!0,gap:r.marginXS,style:{marginTop:r.marginMD},children:[e.jsxs(j,{style:{paddingInline:r.paddingSM},children:[e.jsx(Q,{}),e.jsx(H,{strong:!0,children:a("chat.workspace.recentTitle")})]}),t?e.jsx(_,{justify:"center",style:{padding:r.paddingSM},children:e.jsx(O,{size:"small"})}):s.length===0?e.jsx(M,{description:a("chat.workspace.noRecentWorkspaces"),image:M.PRESENTED_IMAGE_SIMPLE,style:{padding:r.paddingSM}}):e.jsx(W,{size:"small",dataSource:s,style:{paddingInline:r.paddingSM},renderItem:c=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(P,{type:"text",onClick:()=>n(c.path),style:{width:"100%",textAlign:"left",padding:`${r.paddingXS}px 0`,height:"auto"},children:e.jsxs(_,{justify:"space-between",align:"center",style:{width:"100%"},children:[e.jsxs(j,{children:[e.jsx(C,{style:{color:r.colorWarning}}),e.jsx(H,{strong:!0,children:c.workspace_name||c.path.split("/").pop()||a("chat.workspace.defaultWorkspaceName")})]}),e.jsx(H,{type:"secondary",ellipsis:{tooltip:c.path},style:{fontSize:12,maxWidth:"55%",textAlign:"right"},children:c.path})]})})})})]}):null},{Text:X}=B,xe=(i,t)=>{switch(i.suggestion_type){case"home":return e.jsx(N,{style:{color:t.colorPrimary}});case"documents":case"desktop":case"downloads":return e.jsx(C,{style:{color:t.colorSuccess}});case"recent":return e.jsx(Q,{style:{color:t.colorWarning}});default:return e.jsx(C,{})}},fe=({show:i,isLoading:t,suggestions:s,onSelect:n,token:r})=>{const{t:a}=V();return i?e.jsxs(_,{vertical:!0,gap:r.marginXS,style:{marginTop:r.marginMD},children:[e.jsxs(j,{style:{paddingInline:r.paddingSM},children:[e.jsx(C,{}),e.jsx(X,{strong:!0,children:a("chat.workspace.suggestedTitle")})]}),t?e.jsx(_,{justify:"center",style:{padding:r.paddingSM},children:e.jsx(O,{size:"small"})}):s.length===0?e.jsx(M,{description:a("chat.workspace.noSuggestions"),image:M.PRESENTED_IMAGE_SIMPLE,style:{padding:r.paddingSM}}):e.jsx(W,{size:"small",dataSource:s,style:{paddingInline:r.paddingSM},renderItem:c=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(P,{type:"text",onClick:()=>n(c.path),style:{width:"100%",textAlign:"left",padding:`${r.paddingXS}px 0`,height:"auto"},children:e.jsxs(_,{justify:"space-between",align:"center",style:{width:"100%"},children:[e.jsxs(j,{children:[xe(c,r),e.jsx(X,{strong:!0,children:c.name})]}),e.jsx(X,{type:"secondary",ellipsis:{tooltip:c.path},style:{fontSize:12,maxWidth:"55%",textAlign:"right"},children:c.path})]})})})})]}):null},ye=({isValidating:i,result:t,token:s})=>i?e.jsx(ne,{style:{color:s.colorPrimary}}):t?t.is_valid?e.jsx(ce,{style:{color:s.colorSuccess}}):e.jsx(oe,{style:{color:s.colorError}}):null,{Text:U}=B,je=({result:i,token:t})=>{const{t:s}=V();return i?e.jsx("div",{style:{marginTop:t.marginXS},children:i.is_valid?e.jsx(L,{type:"success",message:e.jsxs(j,{children:[e.jsx("span",{children:s("chat.workspace.validWorkspace")}),i.workspace_name&&e.jsxs(U,{type:"secondary",children:["(",i.workspace_name,")"]}),i.file_count!==void 0&&e.jsx(U,{type:"secondary",children:s("chat.workspace.fileCount",{count:i.file_count})})]}),showIcon:!0}):e.jsx(L,{type:"error",message:i.error_message||s("validation.invalidPath"),showIcon:!0})}):null},{Text:we}=B,Se=({value:i="",onChange:t,placeholder:s,disabled:n=!1,allowBrowse:r=!0,showRecentWorkspaces:a=!0,showSuggestions:c=!0,onValidationChange:p,className:w,style:l})=>{const{t:x}=V(),{token:u}=Y.useToken(),I=s??x("chat.workspace.placeholder"),{path:S,validationStatus:k,recentWorkspaces:v,suggestions:y,isLoadingRecent:m,isLoadingSuggestions:f,folderBrowserVisible:E,setFolderBrowserVisible:T,handlePathChange:b,handleBrowseClick:R,handleFolderSelect:A,handleWorkspaceSelect:d}=ge({value:i,onChange:t,showRecentWorkspaces:a,showSuggestions:c,onValidationChange:p});return e.jsxs("div",{className:w,style:l,children:[e.jsx(le,{value:S,onChange:g=>b(g.target.value),placeholder:I,disabled:n,size:"middle",style:{width:"100%"},suffix:e.jsx(ye,{isValidating:k.isValidating,result:k.result,token:u}),addonBefore:e.jsxs(j,{children:[e.jsx(C,{}),e.jsx(we,{children:x("chat.workspace.label")})]}),addonAfter:r?e.jsx(P,{"aria-label":x("chat.workspace.browseFolder"),title:x("chat.workspace.browseFolder"),icon:e.jsx(C,{}),onClick:R,disabled:n,type:"text",size:"middle",style:{display:"inline-flex",alignItems:"center"}}):void 0}),e.jsx(je,{result:k.result,token:u}),(a||c)&&e.jsxs(e.Fragment,{children:[e.jsx(de,{style:{margin:"16px 0 12px 0"}}),e.jsx(me,{show:a,isLoading:m,recentWorkspaces:v,onSelect:d,token:u}),e.jsx(fe,{show:c,isLoading:f,suggestions:y,onSelect:d,token:u})]}),e.jsx(he,{visible:E,onClose:()=>T(!1),onSelect:A})]})},{Title:ke}=B,Re=({open:i,initialPath:t="",loading:s=!1,onSubmit:n,onCancel:r})=>{const{t:a}=V(),{message:c}=Z.useApp(),[p,w]=o.useState(t),[l,x]=o.useState(null),[u,I]=o.useState(!1);o.useEffect(()=>{i&&(w(t),x(null))},[i,t]);const S=f=>{w(f)},k=f=>{x(f)},v=async()=>{if(!p.trim()){c.error(a("chat.workspace.errorEnterPath"));return}l&&!l.is_valid?G.confirm({title:a("chat.workspace.invalidTitle"),content:e.jsxs("div",{children:[e.jsx("p",{children:a("chat.workspace.issuesDetected")}),e.jsx("p",{children:l.error_message||a("chat.workspace.invalidTitle")}),e.jsx("p",{children:a("chat.workspace.confirmSaveInvalid")})]}),okText:a("common.saveAnyway"),cancelText:a("common.cancel"),onOk:()=>y()}):y()},y=async()=>{I(!0);try{l!=null&&l.is_valid&&await D.addRecentWorkspace(p.trim(),{workspace_name:l.workspace_name}),n(p.trim())}catch(f){console.error("Failed to save workspace path:",f),c.error(a("chat.workspace.errorSaveFailed"))}finally{I(!1)}},m=!p.trim()||s||u;return e.jsx(G,{open:i,title:e.jsx(j,{children:e.jsx(ke,{level:4,style:{margin:0},children:a("chat.workspace.modalTitle")})}),okText:a("common.save"),cancelText:a("common.cancel"),onOk:v,onCancel:r,okButtonProps:{disabled:m,loading:u||s},width:600,destroyOnClose:!0,children:e.jsxs(j,{direction:"vertical",size:"middle",style:{width:"100%"},children:[e.jsx(L,{message:a("chat.workspace.descriptionTitle"),description:e.jsxs("div",{children:[e.jsx("p",{children:a("chat.workspace.descriptionP1")}),e.jsx("p",{children:a("chat.workspace.descriptionP2")})]}),type:"info",showIcon:!0}),e.jsx(Se,{value:p,onChange:S,onValidationChange:k,placeholder:a("chat.workspace.placeholder"),disabled:u,allowBrowse:!0,showRecentWorkspaces:!0,showSuggestions:!0}),l&&!l.is_valid&&e.jsx(L,{message:a("chat.workspace.checkTitle"),description:l.error_message||a("chat.workspace.checkDescription"),type:"warning",showIcon:!0})]})})};export{Re as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./vendor-markdown-DzaXAW9Q.js";import{u as b,a as x}from"./vendor-i18n-BNURlJ23.js";import{u as i}from"./App-
|
|
1
|
+
import{j as t}from"./vendor-markdown-DzaXAW9Q.js";import{u as b,a as x}from"./vendor-i18n-BNURlJ23.js";import{u as i}from"./App-BocqxYkX.js";import{K as w,M as n,E as l,N as T,L as c,l as E,O as L,Q as R,U as k,V as v,W as d}from"./vendor-antd-DODjfilb.js";import"./vendor-mermaid-De-Yacw-.js";import"./main-TSfsr__P.js";const B=()=>{const{t:s}=b(),{message:r}=w.useApp(),f=i(e=>e.systemPrompts),P=i(e=>e.addSystemPrompt),M=i(e=>e.updateSystemPrompt),j=i(e=>e.deleteSystemPrompt),[h,u]=x.useState(!1),[a,p]=x.useState(null),[o]=n.useForm(),g=(e=null)=>{if(e!=null&&e.isDefault){r.warning(s("settings.systemPromptManager.defaultPromptLocked"));return}p(e),o.setFieldsValue(e||{name:"",description:"",content:""}),u(!0)},y=()=>{u(!1),p(null),o.resetFields()},S=async()=>{if(a!=null&&a.isDefault){r.warning(s("settings.systemPromptManager.defaultPromptLocked"));return}try{const e=await o.validateFields();a?(await M({...a,...e}),r.success(s("settings.systemPromptManager.updateSuccess"))):(await P(e),r.success(s("settings.systemPromptManager.addSuccess"))),y()}catch(e){console.error("Failed to save prompt:",e),r.error(e instanceof Error?e.message:s("settings.systemPromptManager.saveError"))}},I=async e=>{try{await j(e),r.success(s("settings.systemPromptManager.deleteSuccess"))}catch(m){console.error("Failed to delete prompt:",m),r.error(m instanceof Error?m.message:s("settings.systemPromptManager.deleteError"))}};return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[t.jsx("h2",{children:s("settings.systemPromptManager.title")}),t.jsx(l,{type:"primary",icon:t.jsx(T,{}),onClick:()=>g(),children:s("settings.systemPromptManager.addButton")})]}),t.jsx(c,{itemLayout:"horizontal",dataSource:f,renderItem:e=>t.jsxs(c.Item,{actions:[e.isDefault?null:t.jsx(l,{type:"text",icon:t.jsx(L,{}),onClick:()=>g(e)}),e.isDefault?null:t.jsx(R,{title:s("settings.systemPromptManager.deleteConfirm"),onConfirm:()=>I(e.id),okText:s("common.yes"),cancelText:s("common.no"),children:t.jsx(l,{type:"text",danger:!0,icon:t.jsx(k,{}),"aria-label":s("common.delete")})})],children:[t.jsx(c.Item.Meta,{title:e.name,description:e.description||e.content.substring(0,200)+(e.content.length>200?"...":"")}),e.isDefault&&t.jsx(E,{children:s("settings.systemPromptManager.defaultTag")})]})}),t.jsx(v,{title:s(a?"settings.systemPromptManager.editTitle":"settings.systemPromptManager.addTitle"),open:h,onOk:S,onCancel:y,width:"60%",forceRender:!0,children:t.jsxs(n,{form:o,layout:"vertical",name:"system_prompt_form",children:[t.jsx(n.Item,{name:"name",label:s("settings.systemPromptManager.nameLabel"),rules:[{required:!0,message:s("settings.systemPromptManager.nameRequired")}],children:t.jsx(d,{})}),t.jsx(n.Item,{name:"description",label:s("settings.systemPromptManager.descriptionLabel"),rules:[{required:!1,message:s("settings.systemPromptManager.descriptionRequired")}],children:t.jsx(d.TextArea,{rows:3})}),t.jsx(n.Item,{name:"content",label:s("settings.systemPromptManager.contentLabel"),rules:[{required:!0,message:s("settings.systemPromptManager.contentRequired")}],children:t.jsx(d.TextArea,{rows:10})})]})})]})};export{B as default};
|