@runfusion/fusion 0.40.1 → 0.41.0

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.
Files changed (50) hide show
  1. package/dist/client/.vite/manifest.json +68 -68
  2. package/dist/client/assets/{AgentDetailView-BrETpTDj.js → AgentDetailView-krC0B2O0.js} +1 -1
  3. package/dist/client/assets/{AgentPermissionPolicyEditor-BP6d1LFG.js → AgentPermissionPolicyEditor-VDXL4XQc.js} +1 -1
  4. package/dist/client/assets/{AgentsView-COx3draV.js → AgentsView-ChXccELt.js} +3 -3
  5. package/dist/client/assets/{ChatView-CrVSqQK_.js → ChatView-Dz_xBKit.js} +1 -1
  6. package/dist/client/assets/{DevServerView-DXQ1LX4H.js → DevServerView-DGOahw1o.js} +1 -1
  7. package/dist/client/assets/{DirectoryPicker-B_8ICSPl.js → DirectoryPicker-DgqHlxyh.js} +1 -1
  8. package/dist/client/assets/{DocumentsView-DmNB9rJZ.js → DocumentsView-CbbZwzbH.js} +1 -1
  9. package/dist/client/assets/{EvalsView-72w3_AO6.js → EvalsView-BL_ue7fJ.js} +1 -1
  10. package/dist/client/assets/{ExperimentalAgentOnboardingModal-Be4oaohM.js → ExperimentalAgentOnboardingModal-8H4XAu4O.js} +1 -1
  11. package/dist/client/assets/{GoalsView-DkEXO_mx.js → GoalsView-CO4FVL3E.js} +1 -1
  12. package/dist/client/assets/{InsightsView-_-wd4BOJ.js → InsightsView-C5vLvWVE.js} +1 -1
  13. package/dist/client/assets/{MemoryView-BOCIc8HT.js → MemoryView-BL3W3yOv.js} +1 -1
  14. package/dist/client/assets/{NodesView-DTQP1j4H.js → NodesView-DfBNNm9c.js} +1 -1
  15. package/dist/client/assets/{PiExtensionsManager-BqaI9GKX.js → PiExtensionsManager-HvSiVeDN.js} +1 -1
  16. package/dist/client/assets/{PluginManager-DYaVwsXd.js → PluginManager-DIjrlhnU.js} +1 -1
  17. package/dist/client/assets/{PullRequestView-Dk9a7jRZ.js → PullRequestView-C2jQX8xZ.js} +1 -1
  18. package/dist/client/assets/{ReliabilityView-B-i5SOoD.js → ReliabilityView-DbqEwoRs.js} +1 -1
  19. package/dist/client/assets/{ResearchView-C2Gx8jC9.js → ResearchView-C1QghmLI.js} +1 -1
  20. package/dist/client/assets/{SecretsView-Db2HAGi2.js → SecretsView-Y2MQ-9n5.js} +1 -1
  21. package/dist/client/assets/{SessionTerminal-DwlNZLlr.js → SessionTerminal-DaTXNT3A.js} +1 -1
  22. package/dist/client/assets/{SettingsModal-Dje7N0hv.js → SettingsModal-BAzm2kYd.js} +3 -3
  23. package/dist/client/assets/{SettingsModal-B-d30TVy.js → SettingsModal-DabcZZ6S.js} +1 -1
  24. package/dist/client/assets/{SetupWizardModal-Cw3RdN83.js → SetupWizardModal-Db-Rxinm.js} +1 -1
  25. package/dist/client/assets/{SkillsView-BGyynaI4.js → SkillsView-CIEY1-DE.js} +1 -1
  26. package/dist/client/assets/{StashRecoveryView-CFaU-hym.js → StashRecoveryView-B6iDu5tI.js} +1 -1
  27. package/dist/client/assets/{TodoView-Djjwcb49.js → TodoView-B8IK_BPM.js} +1 -1
  28. package/dist/client/assets/{WorkflowNodeEditor-vnXnKvAr.js → WorkflowNodeEditor-DaPyvD_R.js} +1 -1
  29. package/dist/client/assets/{dashboard-view-DOEa6gWS.js → dashboard-view-Dn4CztR6.js} +1 -1
  30. package/dist/client/assets/{folder-open-BtEAEp7E.js → folder-open-C9XAaduE.js} +1 -1
  31. package/dist/client/assets/{index-CW4OzecJ.js → index-CgfrecpF.js} +5 -5
  32. package/dist/client/assets/{upload-Y9NiLQ9o.js → upload-BRAEugYV.js} +1 -1
  33. package/dist/client/assets/{users-B13HD4Tp.js → users-BlflbMZ3.js} +1 -1
  34. package/dist/client/index.html +1 -1
  35. package/dist/client/version.json +1 -1
  36. package/dist/droid-cli/package.json +1 -1
  37. package/dist/pi-claude-cli/package.json +1 -1
  38. package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
  39. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  40. package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
  41. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  42. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  43. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  44. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  45. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  46. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  47. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  48. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  49. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  50. package/package.json +3 -3
@@ -1 +1 @@
1
- import{r as e}from"./vendor-react-D37HfzIf.js";import{cS as C}from"./index-CW4OzecJ.js";function L(S={}){const{projectId:d,pollInterval:b=6e4,autoRefresh:p=!1,enabled:t=!0}=S,[k,o]=e.useState(null),[m,l]=e.useState(t),[E,c]=e.useState(null),[R,v]=e.useState(null),r=e.useRef(null),n=e.useRef(null),a=e.useRef(!0),s=e.useCallback(async()=>{if(!t){l(!1),c(null),o(null);return}r.current&&r.current.abort(),r.current=new AbortController,l(!0),c(null),o(null);try{const u=await C(d);if(!a.current)return;o(u),c(null),v(new Date),l(!1)}catch(u){if(u instanceof Error&&u.name==="AbortError"||!a.current)return;const A=u instanceof Error?u.message:"Failed to fetch memory backend status";c(A),l(!1)}},[t,d]);e.useEffect(()=>(a.current=!0,t?(s(),()=>{a.current=!1}):(r.current&&r.current.abort(),o(null),c(null),l(!1),()=>{a.current=!1})),[t,s]),e.useEffect(()=>{if(!(!t||!p))return n.current=setInterval(()=>{s()},b),()=>{n.current&&(clearInterval(n.current),n.current=null)}},[t,p,b,s]),e.useEffect(()=>()=>{a.current=!1,r.current&&r.current.abort(),n.current&&(clearInterval(n.current),n.current=null)},[]);const h=e.useCallback(()=>s(),[s]),f=m?null:k,B=f?.currentBackend??null,i=f?.capabilities??null,y=f?.availableBackends??[],I=i?.readable??!1,g=i?.writable??!1,w=i?.supportsAtomicWrite??!1;return{status:f,currentBackend:B,capabilities:i,availableBackends:y,isReadable:I,isWritable:g,supportsAtomicWrite:w,loading:m,error:E,lastUpdated:R,refresh:h}}export{L as u};
1
+ import{r as e}from"./vendor-react-D37HfzIf.js";import{cS as C}from"./index-CgfrecpF.js";function L(S={}){const{projectId:d,pollInterval:b=6e4,autoRefresh:p=!1,enabled:t=!0}=S,[k,o]=e.useState(null),[m,l]=e.useState(t),[E,c]=e.useState(null),[R,v]=e.useState(null),r=e.useRef(null),n=e.useRef(null),a=e.useRef(!0),s=e.useCallback(async()=>{if(!t){l(!1),c(null),o(null);return}r.current&&r.current.abort(),r.current=new AbortController,l(!0),c(null),o(null);try{const u=await C(d);if(!a.current)return;o(u),c(null),v(new Date),l(!1)}catch(u){if(u instanceof Error&&u.name==="AbortError"||!a.current)return;const A=u instanceof Error?u.message:"Failed to fetch memory backend status";c(A),l(!1)}},[t,d]);e.useEffect(()=>(a.current=!0,t?(s(),()=>{a.current=!1}):(r.current&&r.current.abort(),o(null),c(null),l(!1),()=>{a.current=!1})),[t,s]),e.useEffect(()=>{if(!(!t||!p))return n.current=setInterval(()=>{s()},b),()=>{n.current&&(clearInterval(n.current),n.current=null)}},[t,p,b,s]),e.useEffect(()=>()=>{a.current=!1,r.current&&r.current.abort(),n.current&&(clearInterval(n.current),n.current=null)},[]);const h=e.useCallback(()=>s(),[s]),f=m?null:k,B=f?.currentBackend??null,i=f?.capabilities??null,y=f?.availableBackends??[],I=i?.readable??!1,g=i?.writable??!1,w=i?.supportsAtomicWrite??!1;return{status:f,currentBackend:B,capabilities:i,availableBackends:y,isReadable:I,isWritable:g,supportsAtomicWrite:w,loading:m,error:E,lastUpdated:R,refresh:h}}export{L as u};
@@ -1 +1 @@
1
- import{r as l,j as e}from"./vendor-react-D37HfzIf.js";import{cT as b,bd as L,cU as O,cV as W,cW as _,X as G,b as $,C,L as Y}from"./index-CW4OzecJ.js";import{D as V}from"./DirectoryPicker-B_8ICSPl.js";import{s as f}from"./projectDetection-G3XuxD2X.js";import{u as q}from"./vendor-i18n-CV0mwX_-.js";import"./vendor-reactflow-CRZcPCXF.js";import"./vendor-xterm-tcedd2Jt.js";import"./vendor-codemirror-jBKmHyH0.js";import"./folder-open-BtEAEp7E.js";function oe({onProjectRegistered:m,onClose:j}){const{t:s}=q("app"),y="https://github.com/runfusion/fusion/discussions",[z,P]=l.useState(!0),[t,n]=l.useState(()=>({step:b()?"manual":"auth",manualMode:"existing",manualPath:"",manualCloneUrl:"",manualName:"",manualIsolationMode:"in-process",manualNodeId:"",isRegistering:!1,error:null})),[x,T]=l.useState(!1),[i,u]=l.useState(""),[p,g]=l.useState(()=>b()),{nodes:N,loading:M}=L(),S=N.find(a=>a.type==="local")?.id,k=l.useCallback(()=>{P(!1),j?.()},[j]),I=l.useCallback(a=>{n(o=>{const d={manualPath:a};return a&&(!o.manualName||o.manualName===f(o.manualPath))&&(d.manualName=f(a)),{...o,...d}})},[]),R=l.useCallback(async()=>{const a=t.manualPath.trim(),o=t.manualName.trim(),d=t.manualCloneUrl.trim();if(!(!a||!o)&&!(t.manualMode==="clone"&&!d)){n(c=>({...c,isRegistering:!0,error:null}));try{const c={name:o,path:a,isolationMode:t.manualIsolationMode,nodeId:t.manualNodeId||void 0,cloneUrl:t.manualMode==="clone"?d:void 0},h=await O(c);m(h),n(B=>({...B,step:"complete",isRegistering:!1}))}catch(c){n(h=>({...h,isRegistering:!1,error:c instanceof Error?c.message:"Failed to register project"}))}}},[t.manualPath,t.manualName,t.manualCloneUrl,t.manualMode,t.manualIsolationMode,t.manualNodeId,m]),v=l.useCallback(()=>{const a=i.trim();a&&(W(a),g(a),u(""),n(o=>o.step==="auth"?{...o,step:"manual"}:o))},[i]),A=l.useCallback(()=>{_(),g(void 0),u("")},[]),F=l.useCallback(()=>{n(a=>({...a,step:"manual"}))},[]);if(!z)return null;const w=t.manualMode==="existing",r=t.manualMode==="clone",U=t.manualPath.trim().length>0,D=t.manualName.trim().length>0,E=t.manualCloneUrl.trim().length>0,H=t.isRegistering||!U||!D||r&&!E;return e.jsx("div",{className:"modal-overlay open setup-wizard-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"wizard-title",children:e.jsxs("div",{className:"modal setup-wizard-modal",children:[e.jsxs("div",{className:"setup-wizard-header",children:[e.jsxs("div",{className:"setup-wizard-heading",children:[e.jsxs("div",{className:"setup-wizard-brand","aria-label":"Fusion",children:[e.jsxs("svg",{className:"setup-wizard-brand-logo",width:28,height:28,viewBox:"0 0 128 128",fill:"none","aria-label":"Fusion logo",role:"img",children:[e.jsx("circle",{cx:"64",cy:"64",r:"52",stroke:"currentColor",strokeWidth:"8"}),e.jsx("path",{d:"M26 101C44 82 62 64 82 45C90 37 98 30 104 24C96 35 89 47 81 60C70 79 57 95 43 108C38 112 32 108 26 101Z",fill:"currentColor"})]}),e.jsx("span",{className:"setup-wizard-brand-name",children:"Fusion"})]}),e.jsxs("h2",{id:"wizard-title",className:"setup-wizard-title",children:[t.step==="auth"&&s("setup.setAuthToken","Set Auth Token"),t.step==="manual"&&s("setup.welcomeToFusion","Welcome to Fusion"),t.step==="complete"&&s("setup.setupComplete","Setup Complete!")]})]}),t.step!=="complete"&&e.jsx("button",{className:"modal-close",onClick:k,"aria-label":s("setup.closeWizard","Close wizard"),children:e.jsx(G,{size:20})})]}),e.jsxs("div",{className:"setup-wizard-content",children:[t.step==="auth"&&e.jsxs("div",{className:"setup-wizard-auth-step",children:[e.jsx("p",{className:"setup-wizard-auth-step-description",children:s("setup.authDescription","This dashboard requires an auth token to communicate with the Fusion daemon. Paste the token below to continue.")}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"setup-auth-token",children:s("setup.authToken","Auth Token")}),e.jsx("input",{id:"setup-auth-token",type:"password",value:i,onChange:a=>u(a.target.value),placeholder:s("setup.pasteTokenPlaceholder","Paste the daemon auth token"),autoComplete:"off",spellCheck:!1,autoFocus:!0}),e.jsx("p",{className:"form-hint",children:s("setup.tokenEnvVar","The token was set via the {{env}} environment variable when starting the dashboard.",{env:"FUSION_DAEMON_TOKEN"})})]}),t.error&&e.jsx("div",{className:"wizard-error",role:"alert",children:t.error})]}),t.step==="manual"&&e.jsxs("div",{className:"setup-wizard-manual",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-name",children:s("setup.projectName","Project Name")}),e.jsx("input",{id:"project-name",type:"text",value:t.manualName,onChange:a=>n(o=>({...o,manualName:a.target.value})),placeholder:s("setup.projectNamePlaceholder","my-project")}),e.jsx("p",{className:"form-hint",children:r?s("setup.projectNameHintClone","By default this follows the destination folder name unless you edit it."):s("setup.projectNameHintExisting","By default this follows the selected directory name unless you edit it.")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-path",children:r?s("setup.destinationDirectory","Destination Directory"):s("setup.projectDirectory","Project Directory")}),e.jsx(V,{value:t.manualPath,onChange:I,nodeId:t.manualNodeId||void 0,localNodeId:S,placeholder:r?s("setup.clonePathPlaceholder","/path/for/new-clone"):s("setup.projectPathPlaceholder","/path/to/your/project")}),e.jsx("p",{className:"form-hint",children:r?s("setup.clonePathHint","Select or type an absolute destination path. Fusion will clone into this directory."):s("setup.projectPathHint","Select or type the absolute path to your project")})]}),e.jsxs("div",{className:"setup-wizard-advanced",children:[e.jsxs("button",{type:"button",className:"setup-wizard-advanced-toggle","aria-expanded":x,onClick:()=>T(a=>!a),children:[e.jsx($,{size:16,className:"setup-wizard-advanced-chevron"}),e.jsx("span",{children:s("setup.advancedSettings","Advanced settings")})]}),x&&e.jsxs("div",{className:"setup-wizard-advanced-panel",children:[e.jsxs("fieldset",{className:"setup-wizard-mode-switch","aria-label":"Project setup mode",children:[e.jsx("legend",{children:s("setup.setupMode","Setup Mode")}),e.jsxs("label",{className:`setup-wizard-mode-option${w?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"setup-mode",value:"existing",checked:w,onChange:()=>n(a=>({...a,manualMode:"existing",error:null}))}),e.jsx("span",{children:s("setup.useExistingDirectory","Use Existing Directory")})]}),e.jsxs("label",{className:`setup-wizard-mode-option${r?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"setup-mode",value:"clone",checked:r,onChange:()=>n(a=>({...a,manualMode:"clone",error:null}))}),e.jsx("span",{children:s("setup.cloneGitRepository","Clone Git Repository")})]})]}),r&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-clone-url",children:s("setup.repositoryUrl","Repository URL")}),e.jsx("input",{id:"project-clone-url",type:"text",value:t.manualCloneUrl,onChange:a=>n(o=>({...o,manualCloneUrl:a.target.value})),placeholder:s("setup.repositoryUrlPlaceholder","https://github.com/owner/repo.git")}),e.jsx("p",{className:"form-hint",children:s("setup.cloneGitHint","Fusion will run git clone into the destination directory, then register that cloned folder.")})]}),e.jsx("div",{className:"form-group",children:e.jsxs("div",{className:"project-node-selector",children:[e.jsx("span",{className:"project-node-selector__label",children:s("setup.runtimeNode","Runtime Node")}),e.jsxs("select",{value:t.manualNodeId,onChange:a=>n(o=>({...o,manualNodeId:a.target.value})),disabled:M||t.isRegistering,children:[e.jsx("option",{value:"",children:s("setup.localNode","Local node")}),N.map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",a.type,")"]},a.id))]})]})}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:s("setup.isolationMode","Isolation Mode")}),e.jsxs("div",{className:"setup-wizard-isolation-options",children:[e.jsxs("label",{className:`setup-wizard-isolation-option${t.manualIsolationMode==="in-process"?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"isolation-mode",value:"in-process",checked:t.manualIsolationMode==="in-process",onChange:()=>n(a=>({...a,manualIsolationMode:"in-process"}))}),e.jsxs("div",{className:"setup-wizard-isolation-option-content",children:[e.jsx("strong",{children:s("setup.inProcess","In-Process")}),e.jsx("span",{children:s("setup.inProcessDesc","Lower overhead, shared memory. Best for most projects.")}),e.jsx("span",{className:"wizard-option-recommended",children:s("setup.recommended","Recommended")})]})]}),e.jsxs("label",{className:`setup-wizard-isolation-option${t.manualIsolationMode==="child-process"?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"isolation-mode",value:"child-process",checked:t.manualIsolationMode==="child-process",onChange:()=>n(a=>({...a,manualIsolationMode:"child-process"}))}),e.jsxs("div",{className:"setup-wizard-isolation-option-content",children:[e.jsx("strong",{children:s("setup.childProcess","Child-Process")}),e.jsx("span",{children:s("setup.childProcessDesc","Isolated execution with crash containment.")})]})]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"advanced-auth-token",children:s("setup.browserAuthToken","Browser Auth Token")}),e.jsxs("div",{className:"setup-wizard-auth-token",children:[e.jsx("input",{id:"advanced-auth-token",type:"password",value:i,onChange:a=>u(a.target.value),placeholder:p?s("setup.replaceTokenPlaceholder","Enter a new token to replace the stored one"):s("setup.pasteTokenForBrowserPlaceholder","Paste the auth token for this browser"),autoComplete:"off",spellCheck:!1}),e.jsxs("div",{className:"setup-wizard-auth-token-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:v,disabled:i.trim().length===0,children:p?s("setup.updateToken","Update token"):s("setup.setToken","Set token")}),p&&e.jsx("button",{type:"button",className:"btn",onClick:A,children:s("setup.resetToken","Reset token")})]})]}),e.jsx("p",{className:"form-hint",children:p?s("setup.tokenStoredHint","A token is already stored in this browser. You can update or reset it below."):s("setup.noTokenHint","No token is stored. Use the auth prompt at the top of the wizard, or set one here.")})]})]})]}),t.error&&e.jsx("div",{className:"wizard-error",role:"alert",children:t.error})]}),t.step==="complete"&&e.jsxs("div",{className:"setup-wizard-complete",children:[e.jsxs("div",{className:"setup-wizard-success-streak","aria-hidden":"true",children:[e.jsx("div",{className:"setup-wizard-success-streak-core"}),e.jsx("div",{className:"setup-wizard-success-streak-glow"})]}),e.jsx(C,{size:64,className:"success-icon"}),e.jsx("h3",{children:s("setup.allSet","All Set!")}),e.jsx("p",{children:s("setup.projectRegisteredSuccess","Your project has been registered successfully.")}),e.jsx("p",{children:s("setup.addMoreProjectsHint","You can add more projects anytime from the project overview.")})]})]}),e.jsxs("div",{className:"setup-wizard-footer",children:[e.jsx("a",{className:"btn setup-wizard-help-link",href:y,target:"_blank",rel:"noreferrer",children:s("setup.needHelp","Need help?")}),t.step==="auth"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:F,children:s("setup.skip","Skip")}),e.jsx("button",{className:"btn btn-primary",onClick:v,disabled:i.trim().length===0,children:e.jsx("span",{children:s("setup.setTokenContinue","Set Token & Continue")})})]}),t.step==="manual"&&e.jsx("button",{className:"btn btn-primary",onClick:R,disabled:H,children:t.isRegistering?e.jsxs(e.Fragment,{children:[e.jsx(Y,{size:16,className:"animate-spin"}),e.jsx("span",{children:s("setup.registering","Registering...")})]}):e.jsx("span",{children:s("setup.registerProject","Register Project")})}),t.step==="complete"&&e.jsxs("button",{className:"btn btn-primary",onClick:k,children:[e.jsx(C,{size:16}),e.jsx("span",{children:s("setup.getStarted","Get Started")})]})]})]})})}export{oe as SetupWizardModal};
1
+ import{r as l,j as e}from"./vendor-react-D37HfzIf.js";import{cT as b,bd as L,cU as O,cV as W,cW as _,X as G,b as $,C,L as Y}from"./index-CgfrecpF.js";import{D as V}from"./DirectoryPicker-DgqHlxyh.js";import{s as f}from"./projectDetection-G3XuxD2X.js";import{u as q}from"./vendor-i18n-CV0mwX_-.js";import"./vendor-reactflow-CRZcPCXF.js";import"./vendor-xterm-tcedd2Jt.js";import"./vendor-codemirror-jBKmHyH0.js";import"./folder-open-C9XAaduE.js";function oe({onProjectRegistered:m,onClose:j}){const{t:s}=q("app"),y="https://github.com/runfusion/fusion/discussions",[z,P]=l.useState(!0),[t,n]=l.useState(()=>({step:b()?"manual":"auth",manualMode:"existing",manualPath:"",manualCloneUrl:"",manualName:"",manualIsolationMode:"in-process",manualNodeId:"",isRegistering:!1,error:null})),[x,T]=l.useState(!1),[i,u]=l.useState(""),[p,g]=l.useState(()=>b()),{nodes:N,loading:M}=L(),S=N.find(a=>a.type==="local")?.id,k=l.useCallback(()=>{P(!1),j?.()},[j]),I=l.useCallback(a=>{n(o=>{const d={manualPath:a};return a&&(!o.manualName||o.manualName===f(o.manualPath))&&(d.manualName=f(a)),{...o,...d}})},[]),R=l.useCallback(async()=>{const a=t.manualPath.trim(),o=t.manualName.trim(),d=t.manualCloneUrl.trim();if(!(!a||!o)&&!(t.manualMode==="clone"&&!d)){n(c=>({...c,isRegistering:!0,error:null}));try{const c={name:o,path:a,isolationMode:t.manualIsolationMode,nodeId:t.manualNodeId||void 0,cloneUrl:t.manualMode==="clone"?d:void 0},h=await O(c);m(h),n(B=>({...B,step:"complete",isRegistering:!1}))}catch(c){n(h=>({...h,isRegistering:!1,error:c instanceof Error?c.message:"Failed to register project"}))}}},[t.manualPath,t.manualName,t.manualCloneUrl,t.manualMode,t.manualIsolationMode,t.manualNodeId,m]),v=l.useCallback(()=>{const a=i.trim();a&&(W(a),g(a),u(""),n(o=>o.step==="auth"?{...o,step:"manual"}:o))},[i]),A=l.useCallback(()=>{_(),g(void 0),u("")},[]),F=l.useCallback(()=>{n(a=>({...a,step:"manual"}))},[]);if(!z)return null;const w=t.manualMode==="existing",r=t.manualMode==="clone",U=t.manualPath.trim().length>0,D=t.manualName.trim().length>0,E=t.manualCloneUrl.trim().length>0,H=t.isRegistering||!U||!D||r&&!E;return e.jsx("div",{className:"modal-overlay open setup-wizard-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"wizard-title",children:e.jsxs("div",{className:"modal setup-wizard-modal",children:[e.jsxs("div",{className:"setup-wizard-header",children:[e.jsxs("div",{className:"setup-wizard-heading",children:[e.jsxs("div",{className:"setup-wizard-brand","aria-label":"Fusion",children:[e.jsxs("svg",{className:"setup-wizard-brand-logo",width:28,height:28,viewBox:"0 0 128 128",fill:"none","aria-label":"Fusion logo",role:"img",children:[e.jsx("circle",{cx:"64",cy:"64",r:"52",stroke:"currentColor",strokeWidth:"8"}),e.jsx("path",{d:"M26 101C44 82 62 64 82 45C90 37 98 30 104 24C96 35 89 47 81 60C70 79 57 95 43 108C38 112 32 108 26 101Z",fill:"currentColor"})]}),e.jsx("span",{className:"setup-wizard-brand-name",children:"Fusion"})]}),e.jsxs("h2",{id:"wizard-title",className:"setup-wizard-title",children:[t.step==="auth"&&s("setup.setAuthToken","Set Auth Token"),t.step==="manual"&&s("setup.welcomeToFusion","Welcome to Fusion"),t.step==="complete"&&s("setup.setupComplete","Setup Complete!")]})]}),t.step!=="complete"&&e.jsx("button",{className:"modal-close",onClick:k,"aria-label":s("setup.closeWizard","Close wizard"),children:e.jsx(G,{size:20})})]}),e.jsxs("div",{className:"setup-wizard-content",children:[t.step==="auth"&&e.jsxs("div",{className:"setup-wizard-auth-step",children:[e.jsx("p",{className:"setup-wizard-auth-step-description",children:s("setup.authDescription","This dashboard requires an auth token to communicate with the Fusion daemon. Paste the token below to continue.")}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"setup-auth-token",children:s("setup.authToken","Auth Token")}),e.jsx("input",{id:"setup-auth-token",type:"password",value:i,onChange:a=>u(a.target.value),placeholder:s("setup.pasteTokenPlaceholder","Paste the daemon auth token"),autoComplete:"off",spellCheck:!1,autoFocus:!0}),e.jsx("p",{className:"form-hint",children:s("setup.tokenEnvVar","The token was set via the {{env}} environment variable when starting the dashboard.",{env:"FUSION_DAEMON_TOKEN"})})]}),t.error&&e.jsx("div",{className:"wizard-error",role:"alert",children:t.error})]}),t.step==="manual"&&e.jsxs("div",{className:"setup-wizard-manual",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-name",children:s("setup.projectName","Project Name")}),e.jsx("input",{id:"project-name",type:"text",value:t.manualName,onChange:a=>n(o=>({...o,manualName:a.target.value})),placeholder:s("setup.projectNamePlaceholder","my-project")}),e.jsx("p",{className:"form-hint",children:r?s("setup.projectNameHintClone","By default this follows the destination folder name unless you edit it."):s("setup.projectNameHintExisting","By default this follows the selected directory name unless you edit it.")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-path",children:r?s("setup.destinationDirectory","Destination Directory"):s("setup.projectDirectory","Project Directory")}),e.jsx(V,{value:t.manualPath,onChange:I,nodeId:t.manualNodeId||void 0,localNodeId:S,placeholder:r?s("setup.clonePathPlaceholder","/path/for/new-clone"):s("setup.projectPathPlaceholder","/path/to/your/project")}),e.jsx("p",{className:"form-hint",children:r?s("setup.clonePathHint","Select or type an absolute destination path. Fusion will clone into this directory."):s("setup.projectPathHint","Select or type the absolute path to your project")})]}),e.jsxs("div",{className:"setup-wizard-advanced",children:[e.jsxs("button",{type:"button",className:"setup-wizard-advanced-toggle","aria-expanded":x,onClick:()=>T(a=>!a),children:[e.jsx($,{size:16,className:"setup-wizard-advanced-chevron"}),e.jsx("span",{children:s("setup.advancedSettings","Advanced settings")})]}),x&&e.jsxs("div",{className:"setup-wizard-advanced-panel",children:[e.jsxs("fieldset",{className:"setup-wizard-mode-switch","aria-label":"Project setup mode",children:[e.jsx("legend",{children:s("setup.setupMode","Setup Mode")}),e.jsxs("label",{className:`setup-wizard-mode-option${w?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"setup-mode",value:"existing",checked:w,onChange:()=>n(a=>({...a,manualMode:"existing",error:null}))}),e.jsx("span",{children:s("setup.useExistingDirectory","Use Existing Directory")})]}),e.jsxs("label",{className:`setup-wizard-mode-option${r?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"setup-mode",value:"clone",checked:r,onChange:()=>n(a=>({...a,manualMode:"clone",error:null}))}),e.jsx("span",{children:s("setup.cloneGitRepository","Clone Git Repository")})]})]}),r&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-clone-url",children:s("setup.repositoryUrl","Repository URL")}),e.jsx("input",{id:"project-clone-url",type:"text",value:t.manualCloneUrl,onChange:a=>n(o=>({...o,manualCloneUrl:a.target.value})),placeholder:s("setup.repositoryUrlPlaceholder","https://github.com/owner/repo.git")}),e.jsx("p",{className:"form-hint",children:s("setup.cloneGitHint","Fusion will run git clone into the destination directory, then register that cloned folder.")})]}),e.jsx("div",{className:"form-group",children:e.jsxs("div",{className:"project-node-selector",children:[e.jsx("span",{className:"project-node-selector__label",children:s("setup.runtimeNode","Runtime Node")}),e.jsxs("select",{value:t.manualNodeId,onChange:a=>n(o=>({...o,manualNodeId:a.target.value})),disabled:M||t.isRegistering,children:[e.jsx("option",{value:"",children:s("setup.localNode","Local node")}),N.map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",a.type,")"]},a.id))]})]})}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:s("setup.isolationMode","Isolation Mode")}),e.jsxs("div",{className:"setup-wizard-isolation-options",children:[e.jsxs("label",{className:`setup-wizard-isolation-option${t.manualIsolationMode==="in-process"?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"isolation-mode",value:"in-process",checked:t.manualIsolationMode==="in-process",onChange:()=>n(a=>({...a,manualIsolationMode:"in-process"}))}),e.jsxs("div",{className:"setup-wizard-isolation-option-content",children:[e.jsx("strong",{children:s("setup.inProcess","In-Process")}),e.jsx("span",{children:s("setup.inProcessDesc","Lower overhead, shared memory. Best for most projects.")}),e.jsx("span",{className:"wizard-option-recommended",children:s("setup.recommended","Recommended")})]})]}),e.jsxs("label",{className:`setup-wizard-isolation-option${t.manualIsolationMode==="child-process"?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"isolation-mode",value:"child-process",checked:t.manualIsolationMode==="child-process",onChange:()=>n(a=>({...a,manualIsolationMode:"child-process"}))}),e.jsxs("div",{className:"setup-wizard-isolation-option-content",children:[e.jsx("strong",{children:s("setup.childProcess","Child-Process")}),e.jsx("span",{children:s("setup.childProcessDesc","Isolated execution with crash containment.")})]})]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"advanced-auth-token",children:s("setup.browserAuthToken","Browser Auth Token")}),e.jsxs("div",{className:"setup-wizard-auth-token",children:[e.jsx("input",{id:"advanced-auth-token",type:"password",value:i,onChange:a=>u(a.target.value),placeholder:p?s("setup.replaceTokenPlaceholder","Enter a new token to replace the stored one"):s("setup.pasteTokenForBrowserPlaceholder","Paste the auth token for this browser"),autoComplete:"off",spellCheck:!1}),e.jsxs("div",{className:"setup-wizard-auth-token-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:v,disabled:i.trim().length===0,children:p?s("setup.updateToken","Update token"):s("setup.setToken","Set token")}),p&&e.jsx("button",{type:"button",className:"btn",onClick:A,children:s("setup.resetToken","Reset token")})]})]}),e.jsx("p",{className:"form-hint",children:p?s("setup.tokenStoredHint","A token is already stored in this browser. You can update or reset it below."):s("setup.noTokenHint","No token is stored. Use the auth prompt at the top of the wizard, or set one here.")})]})]})]}),t.error&&e.jsx("div",{className:"wizard-error",role:"alert",children:t.error})]}),t.step==="complete"&&e.jsxs("div",{className:"setup-wizard-complete",children:[e.jsxs("div",{className:"setup-wizard-success-streak","aria-hidden":"true",children:[e.jsx("div",{className:"setup-wizard-success-streak-core"}),e.jsx("div",{className:"setup-wizard-success-streak-glow"})]}),e.jsx(C,{size:64,className:"success-icon"}),e.jsx("h3",{children:s("setup.allSet","All Set!")}),e.jsx("p",{children:s("setup.projectRegisteredSuccess","Your project has been registered successfully.")}),e.jsx("p",{children:s("setup.addMoreProjectsHint","You can add more projects anytime from the project overview.")})]})]}),e.jsxs("div",{className:"setup-wizard-footer",children:[e.jsx("a",{className:"btn setup-wizard-help-link",href:y,target:"_blank",rel:"noreferrer",children:s("setup.needHelp","Need help?")}),t.step==="auth"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:F,children:s("setup.skip","Skip")}),e.jsx("button",{className:"btn btn-primary",onClick:v,disabled:i.trim().length===0,children:e.jsx("span",{children:s("setup.setTokenContinue","Set Token & Continue")})})]}),t.step==="manual"&&e.jsx("button",{className:"btn btn-primary",onClick:R,disabled:H,children:t.isRegistering?e.jsxs(e.Fragment,{children:[e.jsx(Y,{size:16,className:"animate-spin"}),e.jsx("span",{children:s("setup.registering","Registering...")})]}):e.jsx("span",{children:s("setup.registerProject","Register Project")})}),t.step==="complete"&&e.jsxs("button",{className:"btn btn-primary",onClick:k,children:[e.jsx(C,{size:16}),e.jsx("span",{children:s("setup.getStarted","Get Started")})]})]})]})})}export{oe as SetupWizardModal};
@@ -1 +1 @@
1
- import{r as a,j as s}from"./vendor-react-D37HfzIf.js";import{bT as J,bU as O,bV as T,bW as Y,bX as Z,bS as ss,X as V,R as es,a as ls,b as is,L as U,ay as as}from"./index-CW4OzecJ.js";import{u as ts}from"./vendor-i18n-CV0mwX_-.js";import"./vendor-reactflow-CRZcPCXF.js";import"./vendor-xterm-tcedd2Jt.js";import"./vendor-codemirror-jBKmHyH0.js";function us({projectId:o,addToast:r,onClose:W}){const{t:l}=ts("app"),[m,v]=a.useState([]),[C,L]=a.useState(!0),[$,D]=a.useState(!1),[F,N]=a.useState(null),[z,K]=a.useState([]),[u,X]=a.useState(""),[S,R]=a.useState(null),[k,b]=a.useState(null),[x,j]=a.useState(null),[B,P]=a.useState(!1),[A,w]=a.useState(null),d=a.useRef(null),[y,I]=a.useState(""),M=u.trim()?m.filter(e=>e.name.toLowerCase().includes(u.toLowerCase())||e.relativePath.toLowerCase().includes(u.toLowerCase())):m,g=a.useCallback(async()=>{L(!0);try{const e=await J(o);v(e)}catch(e){const t=e instanceof Error?e.message:l("skills.loadDiscoveredError","Failed to load discovered skills");r(t,"error")}finally{L(!1)}},[o,r]),h=a.useCallback(async e=>{const t=i=>{if(!i||typeof i!="object")return!1;const n=i;if(typeof n.status=="number"&&n.status>=500)return!0;if(n.details&&typeof n.details=="object"){const p=n.details;if(typeof p.code=="string"&&p.code.startsWith("upstream_"))return!0}const c=i;return typeof c.error=="string"&&typeof c.code=="string"};D(!0),N(null);try{const i=await O(e,20,o);K(i.entries)}catch(i){if(t(i))N(l("skills.catalogUnavailable","Catalog is temporarily unavailable. Please try again later."));else{const n=i instanceof Error?i.message:l("skills.loadCatalogError","Failed to load catalog");N(n)}}finally{D(!1)}},[o]);a.useEffect(()=>{g(),h("")},[g,h]);const _=a.useCallback(e=>{X(e),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{I(e),d.current=null},300)},[]);a.useEffect(()=>()=>{d.current&&(clearTimeout(d.current),d.current=null)},[]),a.useEffect(()=>{h(y)},[y,h]);const q=a.useCallback(async(e,t)=>{const i=!t;v(n=>n.map(c=>c.id===e?{...c,toggling:!0}:c));try{await T(e,i,o),v(n=>n.map(c=>c.id===e?{...c,enabled:i,toggling:!1}:c)),r(l(`skills.${i?"enabled":"disabled"}`,i?"Skill enabled":"Skill disabled"),"success")}catch(n){v(p=>p.map(E=>E.id===e?{...E,toggling:!1}:E));const c=n instanceof Error?n.message:l("skills.toggleError","Failed to toggle skill");r(l("skills.toggleFailed","Failed to toggle skill: {{message}}",{message:c}),"error")}},[o,r]),G=a.useCallback(async e=>{const t=e.repo?.trim();if(!(!t||S===e.id)){R(e.id);try{await Y(t,e.slug||e.name,o),r(l("skills.installSuccess","Installed {{name}}",{name:e.name}),"success"),await g()}catch(i){const n=i instanceof Error?i.message:l("skills.installError","Failed to install skill");r(l("skills.installFailed","Failed to install {{name}}: {{message}}",{name:e.name,message:n}),"error")}finally{R(i=>i===e.id?null:i)}}},[r,S,g,o]),f=a.useCallback(async e=>{P(!0),w(null),j(null);try{const t=await Z(e,o);j(t)}catch(t){const i=t instanceof Error?t.message:l("skills.loadContentError","Failed to load skill content");w(i)}finally{P(!1)}},[o]),Q=a.useCallback((e,t)=>{if(!(t&&t.target.closest(".skills-view-item-toggle"))){if(k===e){b(null),j(null),w(null);return}b(e),f(e)}},[k,f]),H=a.useCallback(e=>{k!==e&&b(e),f(e)},[f,k]);return s.jsxs("div",{className:"skills-view","data-testid":"skills-view",children:[s.jsxs("div",{className:"skills-view-header",children:[s.jsxs("div",{className:"skills-view-title",children:[s.jsxs("h2",{children:[s.jsx(ss,{size:20}),l("skills.title","Skills")]}),s.jsxs("span",{className:"skills-view-count","aria-label":l("skills.discoveredCount","{{count}} discovered skills",{count:m.length}),children:[m.length," ",l("skills.discovered","discovered")]})]}),s.jsxs("div",{className:"skills-view-actions",children:[s.jsx("button",{className:"btn-icon skills-view-close touch-target",onClick:W,"aria-label":l("skills.closeView","Close skills view"),children:s.jsx(V,{size:16})}),s.jsxs("button",{className:"btn btn-sm touch-target",onClick:()=>void g(),disabled:C,children:[s.jsx(es,{size:14,className:C?"spin":""}),l("common.refresh","Refresh")]})]})]}),s.jsxs("div",{className:"skills-view-content",children:[s.jsx("div",{className:"skills-view-search",children:s.jsx("input",{type:"text",className:"form-input",placeholder:l("skills.searchPlaceholder","Search skills..."),value:u,onChange:e=>_(e.target.value),"aria-label":l("skills.searchLabel","Search skills")})}),s.jsxs("section",{className:"skills-view-section","aria-labelledby":"discovered-skills-title",children:[s.jsx("h3",{id:"discovered-skills-title",className:"skills-view-section-title",children:l("skills.discoveredSection","Discovered Skills")}),C?s.jsxs("div",{className:"skills-view-loading",children:[s.jsx("span",{className:"spinner"}),l("skills.loadingDiscovered","Loading discovered skills...")]}):m.length===0?s.jsx("div",{className:"skills-view-empty",children:s.jsx("p",{children:l("skills.noDiscovered","No skills discovered in this project.")})}):M.length===0?s.jsx("div",{className:"skills-view-empty",children:s.jsx("p",{children:l("skills.noMatchingDiscovered","No discovered skills match your search.")})}):s.jsx("div",{className:"skills-view-list",children:M.map(e=>{const t=k===e.id;return s.jsxs("div",{children:[s.jsxs("div",{className:`skills-view-item${t?" skills-view-item--selected":""}`,onClick:i=>Q(e.id,i),role:"button",tabIndex:0,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),Q(e.id))},"aria-expanded":t,"aria-label":l("skills.viewDetails","View details for {{name}}",{name:e.name}),children:[s.jsxs("div",{className:"skills-view-item-info",children:[s.jsxs("span",{className:"skills-view-item-name",children:[t?s.jsx(ls,{size:14}):s.jsx(is,{size:14}),e.name]}),s.jsx("span",{className:"skills-view-item-path",children:e.relativePath}),s.jsx("span",{className:"skills-view-item-source",children:e.metadata.source})]}),s.jsxs("label",{className:"skills-view-item-toggle",onClick:i=>i.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:e.enabled,disabled:e.toggling,onChange:()=>void q(e.id,e.enabled),"aria-label":l(`skills.${e.enabled?"disable":"enable"}Skill`,e.enabled?"Disable {{name}}":"Enable {{name}}",{name:e.name})}),s.jsx("span",{className:"skills-view-toggle-slider"})]})]}),t&&s.jsxs("div",{className:"skills-view-detail","data-testid":"skill-detail",children:[s.jsxs("div",{className:"skills-view-detail-header",children:[s.jsx("span",{className:"skills-view-detail-title",children:e.name}),s.jsxs("button",{className:"btn btn-sm skills-view-detail-close",onClick:()=>{b(null),j(null),w(null)},"aria-label":l("skills.closeDetail","Close skill detail"),children:[s.jsx(V,{size:14}),l("common.close","Close")]})]}),B?s.jsxs("div",{className:"skills-view-detail-loading",children:[s.jsx(U,{size:16,className:"spin"}),l("skills.loadingContent","Loading skill content...")]}):A?s.jsxs("div",{className:"skills-view-detail-error",children:[s.jsx(as,{size:14}),s.jsx("span",{children:A}),s.jsx("button",{className:"btn btn-sm",onClick:()=>H(e.id),children:l("common.retry","Retry")})]}):x?s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"skills-view-detail-content",children:x.skillMd||l("skills.noSkillMd","(No SKILL.md found)")}),x.files.length>0&&s.jsxs("div",{className:"skills-view-detail-files",children:[s.jsxs("span",{className:"skills-view-detail-files-label",children:[l("skills.filesLabel","Files"),":"]}),x.files.map(i=>s.jsxs("span",{className:"badge badge--sm",children:[i.name,i.type==="directory"&&"/"]},i.relativePath))]})]}):null]})]},e.id)})})]}),s.jsxs("section",{className:"skills-view-section","aria-labelledby":"catalog-title",children:[s.jsx("h3",{id:"catalog-title",className:"skills-view-section-title",children:l("skills.catalogSection","Skills Catalog")}),F?s.jsxs("div",{className:"skills-view-error",children:[s.jsx("p",{children:F}),s.jsx("button",{className:"btn btn-sm",onClick:()=>void h(y),children:l("common.tryAgain","Try Again")})]}):$?s.jsxs("div",{className:"skills-view-loading",children:[s.jsx("span",{className:"spinner"}),l("skills.loadingCatalog","Loading catalog...")]}):z.length===0?s.jsx("div",{className:"skills-view-empty",children:u?s.jsx("p",{children:l("skills.noMatchingSearch","No skills match your search.")}):s.jsx("p",{children:l("skills.noCatalogAvailable","No skills available in the catalog.")})}):s.jsx("div",{className:"skills-view-grid",children:z.map(e=>{const i=!!e.repo?.trim(),n=S===e.id;return s.jsxs("div",{className:"skills-view-card",children:[s.jsxs("div",{className:"skills-view-card-header",children:[s.jsx("h4",{className:"skills-view-card-title",children:e.name}),i?s.jsxs("button",{type:"button",className:"btn btn-sm skills-view-card-install",onClick:()=>void G(e),disabled:n,"aria-label":l("skills.installSkill","Install {{name}}",{name:e.name}),children:[n?s.jsx(U,{size:14,className:"spin"}):null,n?l("skills.installing","Installing…"):l("skills.install","Install")]}):null]}),e.description&&s.jsx("p",{className:"skills-view-card-description",children:e.description}),e.tags&&e.tags.length>0&&s.jsx("div",{className:"skills-view-card-tags",children:e.tags.map(c=>s.jsx("span",{className:"badge badge--sm",children:c},c))}),e.installs!==void 0&&s.jsx("span",{className:"skills-view-card-installs",children:l("skills.installsCount","{{value}} installs",{value:e.installs.toLocaleString()})})]},e.id)})})]})]})]})}export{us as SkillsView};
1
+ import{r as a,j as s}from"./vendor-react-D37HfzIf.js";import{bT as J,bU as O,bV as T,bW as Y,bX as Z,bS as ss,X as V,R as es,a as ls,b as is,L as U,ay as as}from"./index-CgfrecpF.js";import{u as ts}from"./vendor-i18n-CV0mwX_-.js";import"./vendor-reactflow-CRZcPCXF.js";import"./vendor-xterm-tcedd2Jt.js";import"./vendor-codemirror-jBKmHyH0.js";function us({projectId:o,addToast:r,onClose:W}){const{t:l}=ts("app"),[m,v]=a.useState([]),[C,L]=a.useState(!0),[$,D]=a.useState(!1),[F,N]=a.useState(null),[z,K]=a.useState([]),[u,X]=a.useState(""),[S,R]=a.useState(null),[k,b]=a.useState(null),[x,j]=a.useState(null),[B,P]=a.useState(!1),[A,w]=a.useState(null),d=a.useRef(null),[y,I]=a.useState(""),M=u.trim()?m.filter(e=>e.name.toLowerCase().includes(u.toLowerCase())||e.relativePath.toLowerCase().includes(u.toLowerCase())):m,g=a.useCallback(async()=>{L(!0);try{const e=await J(o);v(e)}catch(e){const t=e instanceof Error?e.message:l("skills.loadDiscoveredError","Failed to load discovered skills");r(t,"error")}finally{L(!1)}},[o,r]),h=a.useCallback(async e=>{const t=i=>{if(!i||typeof i!="object")return!1;const n=i;if(typeof n.status=="number"&&n.status>=500)return!0;if(n.details&&typeof n.details=="object"){const p=n.details;if(typeof p.code=="string"&&p.code.startsWith("upstream_"))return!0}const c=i;return typeof c.error=="string"&&typeof c.code=="string"};D(!0),N(null);try{const i=await O(e,20,o);K(i.entries)}catch(i){if(t(i))N(l("skills.catalogUnavailable","Catalog is temporarily unavailable. Please try again later."));else{const n=i instanceof Error?i.message:l("skills.loadCatalogError","Failed to load catalog");N(n)}}finally{D(!1)}},[o]);a.useEffect(()=>{g(),h("")},[g,h]);const _=a.useCallback(e=>{X(e),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{I(e),d.current=null},300)},[]);a.useEffect(()=>()=>{d.current&&(clearTimeout(d.current),d.current=null)},[]),a.useEffect(()=>{h(y)},[y,h]);const q=a.useCallback(async(e,t)=>{const i=!t;v(n=>n.map(c=>c.id===e?{...c,toggling:!0}:c));try{await T(e,i,o),v(n=>n.map(c=>c.id===e?{...c,enabled:i,toggling:!1}:c)),r(l(`skills.${i?"enabled":"disabled"}`,i?"Skill enabled":"Skill disabled"),"success")}catch(n){v(p=>p.map(E=>E.id===e?{...E,toggling:!1}:E));const c=n instanceof Error?n.message:l("skills.toggleError","Failed to toggle skill");r(l("skills.toggleFailed","Failed to toggle skill: {{message}}",{message:c}),"error")}},[o,r]),G=a.useCallback(async e=>{const t=e.repo?.trim();if(!(!t||S===e.id)){R(e.id);try{await Y(t,e.slug||e.name,o),r(l("skills.installSuccess","Installed {{name}}",{name:e.name}),"success"),await g()}catch(i){const n=i instanceof Error?i.message:l("skills.installError","Failed to install skill");r(l("skills.installFailed","Failed to install {{name}}: {{message}}",{name:e.name,message:n}),"error")}finally{R(i=>i===e.id?null:i)}}},[r,S,g,o]),f=a.useCallback(async e=>{P(!0),w(null),j(null);try{const t=await Z(e,o);j(t)}catch(t){const i=t instanceof Error?t.message:l("skills.loadContentError","Failed to load skill content");w(i)}finally{P(!1)}},[o]),Q=a.useCallback((e,t)=>{if(!(t&&t.target.closest(".skills-view-item-toggle"))){if(k===e){b(null),j(null),w(null);return}b(e),f(e)}},[k,f]),H=a.useCallback(e=>{k!==e&&b(e),f(e)},[f,k]);return s.jsxs("div",{className:"skills-view","data-testid":"skills-view",children:[s.jsxs("div",{className:"skills-view-header",children:[s.jsxs("div",{className:"skills-view-title",children:[s.jsxs("h2",{children:[s.jsx(ss,{size:20}),l("skills.title","Skills")]}),s.jsxs("span",{className:"skills-view-count","aria-label":l("skills.discoveredCount","{{count}} discovered skills",{count:m.length}),children:[m.length," ",l("skills.discovered","discovered")]})]}),s.jsxs("div",{className:"skills-view-actions",children:[s.jsx("button",{className:"btn-icon skills-view-close touch-target",onClick:W,"aria-label":l("skills.closeView","Close skills view"),children:s.jsx(V,{size:16})}),s.jsxs("button",{className:"btn btn-sm touch-target",onClick:()=>void g(),disabled:C,children:[s.jsx(es,{size:14,className:C?"spin":""}),l("common.refresh","Refresh")]})]})]}),s.jsxs("div",{className:"skills-view-content",children:[s.jsx("div",{className:"skills-view-search",children:s.jsx("input",{type:"text",className:"form-input",placeholder:l("skills.searchPlaceholder","Search skills..."),value:u,onChange:e=>_(e.target.value),"aria-label":l("skills.searchLabel","Search skills")})}),s.jsxs("section",{className:"skills-view-section","aria-labelledby":"discovered-skills-title",children:[s.jsx("h3",{id:"discovered-skills-title",className:"skills-view-section-title",children:l("skills.discoveredSection","Discovered Skills")}),C?s.jsxs("div",{className:"skills-view-loading",children:[s.jsx("span",{className:"spinner"}),l("skills.loadingDiscovered","Loading discovered skills...")]}):m.length===0?s.jsx("div",{className:"skills-view-empty",children:s.jsx("p",{children:l("skills.noDiscovered","No skills discovered in this project.")})}):M.length===0?s.jsx("div",{className:"skills-view-empty",children:s.jsx("p",{children:l("skills.noMatchingDiscovered","No discovered skills match your search.")})}):s.jsx("div",{className:"skills-view-list",children:M.map(e=>{const t=k===e.id;return s.jsxs("div",{children:[s.jsxs("div",{className:`skills-view-item${t?" skills-view-item--selected":""}`,onClick:i=>Q(e.id,i),role:"button",tabIndex:0,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),Q(e.id))},"aria-expanded":t,"aria-label":l("skills.viewDetails","View details for {{name}}",{name:e.name}),children:[s.jsxs("div",{className:"skills-view-item-info",children:[s.jsxs("span",{className:"skills-view-item-name",children:[t?s.jsx(ls,{size:14}):s.jsx(is,{size:14}),e.name]}),s.jsx("span",{className:"skills-view-item-path",children:e.relativePath}),s.jsx("span",{className:"skills-view-item-source",children:e.metadata.source})]}),s.jsxs("label",{className:"skills-view-item-toggle",onClick:i=>i.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:e.enabled,disabled:e.toggling,onChange:()=>void q(e.id,e.enabled),"aria-label":l(`skills.${e.enabled?"disable":"enable"}Skill`,e.enabled?"Disable {{name}}":"Enable {{name}}",{name:e.name})}),s.jsx("span",{className:"skills-view-toggle-slider"})]})]}),t&&s.jsxs("div",{className:"skills-view-detail","data-testid":"skill-detail",children:[s.jsxs("div",{className:"skills-view-detail-header",children:[s.jsx("span",{className:"skills-view-detail-title",children:e.name}),s.jsxs("button",{className:"btn btn-sm skills-view-detail-close",onClick:()=>{b(null),j(null),w(null)},"aria-label":l("skills.closeDetail","Close skill detail"),children:[s.jsx(V,{size:14}),l("common.close","Close")]})]}),B?s.jsxs("div",{className:"skills-view-detail-loading",children:[s.jsx(U,{size:16,className:"spin"}),l("skills.loadingContent","Loading skill content...")]}):A?s.jsxs("div",{className:"skills-view-detail-error",children:[s.jsx(as,{size:14}),s.jsx("span",{children:A}),s.jsx("button",{className:"btn btn-sm",onClick:()=>H(e.id),children:l("common.retry","Retry")})]}):x?s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"skills-view-detail-content",children:x.skillMd||l("skills.noSkillMd","(No SKILL.md found)")}),x.files.length>0&&s.jsxs("div",{className:"skills-view-detail-files",children:[s.jsxs("span",{className:"skills-view-detail-files-label",children:[l("skills.filesLabel","Files"),":"]}),x.files.map(i=>s.jsxs("span",{className:"badge badge--sm",children:[i.name,i.type==="directory"&&"/"]},i.relativePath))]})]}):null]})]},e.id)})})]}),s.jsxs("section",{className:"skills-view-section","aria-labelledby":"catalog-title",children:[s.jsx("h3",{id:"catalog-title",className:"skills-view-section-title",children:l("skills.catalogSection","Skills Catalog")}),F?s.jsxs("div",{className:"skills-view-error",children:[s.jsx("p",{children:F}),s.jsx("button",{className:"btn btn-sm",onClick:()=>void h(y),children:l("common.tryAgain","Try Again")})]}):$?s.jsxs("div",{className:"skills-view-loading",children:[s.jsx("span",{className:"spinner"}),l("skills.loadingCatalog","Loading catalog...")]}):z.length===0?s.jsx("div",{className:"skills-view-empty",children:u?s.jsx("p",{children:l("skills.noMatchingSearch","No skills match your search.")}):s.jsx("p",{children:l("skills.noCatalogAvailable","No skills available in the catalog.")})}):s.jsx("div",{className:"skills-view-grid",children:z.map(e=>{const i=!!e.repo?.trim(),n=S===e.id;return s.jsxs("div",{className:"skills-view-card",children:[s.jsxs("div",{className:"skills-view-card-header",children:[s.jsx("h4",{className:"skills-view-card-title",children:e.name}),i?s.jsxs("button",{type:"button",className:"btn btn-sm skills-view-card-install",onClick:()=>void G(e),disabled:n,"aria-label":l("skills.installSkill","Install {{name}}",{name:e.name}),children:[n?s.jsx(U,{size:14,className:"spin"}):null,n?l("skills.installing","Installing…"):l("skills.install","Install")]}):null]}),e.description&&s.jsx("p",{className:"skills-view-card-description",children:e.description}),e.tags&&e.tags.length>0&&s.jsx("div",{className:"skills-view-card-tags",children:e.tags.map(c=>s.jsx("span",{className:"badge badge--sm",children:c},c))}),e.installs!==void 0&&s.jsx("span",{className:"skills-view-card-installs",children:l("skills.installsCount","{{value}} installs",{value:e.installs.toLocaleString()})})]},e.id)})})]})]})]})}export{us as SkillsView};
@@ -1 +1 @@
1
- import{r as n,j as s}from"./vendor-react-D37HfzIf.js";import{v as g,cG as d}from"./index-CW4OzecJ.js";import{u as R}from"./vendor-i18n-CV0mwX_-.js";import"./vendor-reactflow-CRZcPCXF.js";import"./vendor-xterm-tcedd2Jt.js";import"./vendor-codemirror-jBKmHyH0.js";function L(){const{t:e}=R("app"),{confirm:f}=g(),[i,v]=n.useState([]),[h,p]=n.useState(null),[u,y]=n.useState({}),[t,c]=n.useState(null),l=n.useCallback(async()=>{try{p(null);const a=await d("/stash-recovery/orphans");v(a.records??[])}catch(a){p(a instanceof Error?a.message:e("stashRecovery.failedToLoadOrphans","Failed to load orphans"))}},[e]);n.useEffect(()=>{l()},[l]);const x=n.useMemo(()=>{const a=new Map;for(const r of i){const o=r.sourceTaskId??e("stashRecovery.unknownSource","Unknown source"),m=a.get(o)??[];m.push(r),a.set(o,m)}return Array.from(a.entries())},[i,e]),j=n.useCallback(async a=>{const r=await d(`/stash-recovery/orphans/${a}/apply`,{method:"POST"});y(o=>({...o,[a]:r.ok?e("stashRecovery.applied","Applied"):r.stderr??r.reason??e("stashRecovery.applyFailed","Apply failed")}))},[e]),b=n.useCallback(async a=>{await f({title:e("stashRecovery.dropTitle","Drop orphaned stash?"),message:e("stashRecovery.dropMessage","This removes the stash entry permanently."),confirmLabel:e("stashRecovery.dropConfirm","Drop"),danger:!0})&&(await d(`/stash-recovery/orphans/${a}/drop`,{method:"POST",body:JSON.stringify({confirm:!0})}),await l())},[f,l,e]),N=n.useCallback(async a=>{c({sha:a,diff:"",truncated:!1,loading:!0,error:null});try{const r=await d(`/stash-recovery/orphans/${a}/diff`);c({sha:a,diff:r.diff??"",truncated:!!r.truncated,loading:!1,error:null})}catch(r){c({sha:a,diff:"",truncated:!1,loading:!1,error:r instanceof Error?r.message:e("stashRecovery.failedToLoadDiff","Failed to load diff")})}},[e]);return i.length===0&&!h?s.jsxs("div",{className:"card stash-recovery-view",children:[s.jsx("p",{children:e("stashRecovery.noOrphans","No orphaned merger autostashes found.")}),s.jsx("button",{className:"btn btn-sm",onClick:()=>void l(),children:e("actions.refresh","Refresh")})]}):s.jsxs("div",{className:"card stash-recovery-view",children:[s.jsxs("div",{className:"stash-recovery-header",children:[s.jsx("h2",{children:e("stashRecovery.title","Stash Recovery")}),s.jsx("span",{children:e("stashRecovery.orphanCount","{{count}} orphans",{count:i.length})}),s.jsx("button",{className:"btn btn-sm",onClick:()=>void l(),children:e("actions.refresh","Refresh")})]}),h&&s.jsx("div",{className:"form-error",children:h}),x.map(([a,r])=>s.jsxs("section",{children:[s.jsx("h3",{children:a}),r.map(o=>s.jsxs("div",{className:"stash-row",children:[s.jsxs("div",{className:"stash-field",children:[s.jsx("span",{className:"stash-field-label",children:e("stashRecovery.shaLabel","SHA")}),s.jsx("span",{children:o.sha.slice(0,7)})]}),s.jsxs("div",{className:"stash-field",children:[s.jsx("span",{className:"stash-field-label",children:e("stashRecovery.classificationLabel","Classification")}),s.jsx("span",{children:o.classification})]}),s.jsxs("div",{className:"stash-field",children:[s.jsx("span",{className:"stash-field-label",children:e("stashRecovery.changedPathsLabel","Changed paths")}),s.jsx("span",{children:e("stashRecovery.fileCount","{{count}} files",{count:o.changedPaths.length})})]}),s.jsxs("div",{className:"stash-row-actions",children:[s.jsx("button",{className:"btn btn-sm stash-action-btn",onClick:()=>void N(o.sha),children:e("stashRecovery.inspectDiff","Inspect diff")}),s.jsx("button",{className:"btn btn-sm stash-action-btn",onClick:()=>void j(o.sha),children:e("stashRecovery.apply","Apply")})]}),s.jsx("div",{className:"stash-row-actions-danger",children:s.jsx("button",{className:"btn btn-sm btn-danger stash-action-btn",onClick:()=>void b(o.sha),children:e("stashRecovery.drop","Drop")})}),u[o.sha]&&s.jsx("div",{className:"stash-status",children:u[o.sha]})]},o.sha))]},a)),t&&s.jsx("div",{className:"modal-overlay open",onClick:()=>c(null),children:s.jsxs("div",{className:"modal stash-recovery-diff-modal",role:"dialog","aria-modal":"true","aria-label":e("stashRecovery.diffDialogLabel","Diff for {{sha}}",{sha:t.sha}),onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{children:e("stashRecovery.diffHeader","Diff for {{sha}}",{sha:t.sha.slice(0,7)})}),s.jsx("button",{className:"modal-close",onClick:()=>c(null),"aria-label":e("stashRecovery.closeDiffDialog","Close diff dialog"),children:"×"})]}),t.loading&&s.jsx("p",{children:e("stashRecovery.loadingDiff","Loading diff…")}),t.error&&s.jsx("div",{className:"form-error",children:t.error}),!t.loading&&!t.error&&s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"stash-recovery-diff-pre",children:t.diff||e("stashRecovery.noDiffOutput","No diff output available.")}),t.truncated&&s.jsx("p",{className:"stash-status",children:e("stashRecovery.diffTruncated","Diff output truncated.")})]}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{className:"btn",onClick:()=>c(null),children:e("actions.close","Close")})})]})})]})}export{L as StashRecoveryView};
1
+ import{r as n,j as s}from"./vendor-react-D37HfzIf.js";import{v as g,cG as d}from"./index-CgfrecpF.js";import{u as R}from"./vendor-i18n-CV0mwX_-.js";import"./vendor-reactflow-CRZcPCXF.js";import"./vendor-xterm-tcedd2Jt.js";import"./vendor-codemirror-jBKmHyH0.js";function L(){const{t:e}=R("app"),{confirm:f}=g(),[i,v]=n.useState([]),[h,p]=n.useState(null),[u,y]=n.useState({}),[t,c]=n.useState(null),l=n.useCallback(async()=>{try{p(null);const a=await d("/stash-recovery/orphans");v(a.records??[])}catch(a){p(a instanceof Error?a.message:e("stashRecovery.failedToLoadOrphans","Failed to load orphans"))}},[e]);n.useEffect(()=>{l()},[l]);const x=n.useMemo(()=>{const a=new Map;for(const r of i){const o=r.sourceTaskId??e("stashRecovery.unknownSource","Unknown source"),m=a.get(o)??[];m.push(r),a.set(o,m)}return Array.from(a.entries())},[i,e]),j=n.useCallback(async a=>{const r=await d(`/stash-recovery/orphans/${a}/apply`,{method:"POST"});y(o=>({...o,[a]:r.ok?e("stashRecovery.applied","Applied"):r.stderr??r.reason??e("stashRecovery.applyFailed","Apply failed")}))},[e]),b=n.useCallback(async a=>{await f({title:e("stashRecovery.dropTitle","Drop orphaned stash?"),message:e("stashRecovery.dropMessage","This removes the stash entry permanently."),confirmLabel:e("stashRecovery.dropConfirm","Drop"),danger:!0})&&(await d(`/stash-recovery/orphans/${a}/drop`,{method:"POST",body:JSON.stringify({confirm:!0})}),await l())},[f,l,e]),N=n.useCallback(async a=>{c({sha:a,diff:"",truncated:!1,loading:!0,error:null});try{const r=await d(`/stash-recovery/orphans/${a}/diff`);c({sha:a,diff:r.diff??"",truncated:!!r.truncated,loading:!1,error:null})}catch(r){c({sha:a,diff:"",truncated:!1,loading:!1,error:r instanceof Error?r.message:e("stashRecovery.failedToLoadDiff","Failed to load diff")})}},[e]);return i.length===0&&!h?s.jsxs("div",{className:"card stash-recovery-view",children:[s.jsx("p",{children:e("stashRecovery.noOrphans","No orphaned merger autostashes found.")}),s.jsx("button",{className:"btn btn-sm",onClick:()=>void l(),children:e("actions.refresh","Refresh")})]}):s.jsxs("div",{className:"card stash-recovery-view",children:[s.jsxs("div",{className:"stash-recovery-header",children:[s.jsx("h2",{children:e("stashRecovery.title","Stash Recovery")}),s.jsx("span",{children:e("stashRecovery.orphanCount","{{count}} orphans",{count:i.length})}),s.jsx("button",{className:"btn btn-sm",onClick:()=>void l(),children:e("actions.refresh","Refresh")})]}),h&&s.jsx("div",{className:"form-error",children:h}),x.map(([a,r])=>s.jsxs("section",{children:[s.jsx("h3",{children:a}),r.map(o=>s.jsxs("div",{className:"stash-row",children:[s.jsxs("div",{className:"stash-field",children:[s.jsx("span",{className:"stash-field-label",children:e("stashRecovery.shaLabel","SHA")}),s.jsx("span",{children:o.sha.slice(0,7)})]}),s.jsxs("div",{className:"stash-field",children:[s.jsx("span",{className:"stash-field-label",children:e("stashRecovery.classificationLabel","Classification")}),s.jsx("span",{children:o.classification})]}),s.jsxs("div",{className:"stash-field",children:[s.jsx("span",{className:"stash-field-label",children:e("stashRecovery.changedPathsLabel","Changed paths")}),s.jsx("span",{children:e("stashRecovery.fileCount","{{count}} files",{count:o.changedPaths.length})})]}),s.jsxs("div",{className:"stash-row-actions",children:[s.jsx("button",{className:"btn btn-sm stash-action-btn",onClick:()=>void N(o.sha),children:e("stashRecovery.inspectDiff","Inspect diff")}),s.jsx("button",{className:"btn btn-sm stash-action-btn",onClick:()=>void j(o.sha),children:e("stashRecovery.apply","Apply")})]}),s.jsx("div",{className:"stash-row-actions-danger",children:s.jsx("button",{className:"btn btn-sm btn-danger stash-action-btn",onClick:()=>void b(o.sha),children:e("stashRecovery.drop","Drop")})}),u[o.sha]&&s.jsx("div",{className:"stash-status",children:u[o.sha]})]},o.sha))]},a)),t&&s.jsx("div",{className:"modal-overlay open",onClick:()=>c(null),children:s.jsxs("div",{className:"modal stash-recovery-diff-modal",role:"dialog","aria-modal":"true","aria-label":e("stashRecovery.diffDialogLabel","Diff for {{sha}}",{sha:t.sha}),onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{children:e("stashRecovery.diffHeader","Diff for {{sha}}",{sha:t.sha.slice(0,7)})}),s.jsx("button",{className:"modal-close",onClick:()=>c(null),"aria-label":e("stashRecovery.closeDiffDialog","Close diff dialog"),children:"×"})]}),t.loading&&s.jsx("p",{children:e("stashRecovery.loadingDiff","Loading diff…")}),t.error&&s.jsx("div",{className:"form-error",children:t.error}),!t.loading&&!t.error&&s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"stash-recovery-diff-pre",children:t.diff||e("stashRecovery.noDiffOutput","No diff output available.")}),t.truncated&&s.jsx("p",{className:"stash-status",children:e("stashRecovery.diffTruncated","Diff output truncated.")})]}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{className:"btn",onClick:()=>c(null),children:e("actions.close","Close")})})]})})]})}export{L as StashRecoveryView};
@@ -1,4 +1,4 @@
1
- import{r as c,j as e}from"./vendor-react-D37HfzIf.js";import{c as Et,a7 as ut,a8 as bt,a9 as Tt,cu as Dt,cv as Ft,cw as $t,cx as Rt,cy as Mt,cz as Ot,cA as _t,cB as Ut,ac as Pt,v as Kt,j as Bt,z as q,cC as pt,L as Xt,J as zt,bI as Q,X as Z,cD as ft,b6 as ht,U as xt,aj as Wt,a as Gt,aA as Ht,B as gt}from"./index-CW4OzecJ.js";import{u as Lt}from"./vendor-i18n-CV0mwX_-.js";import"./vendor-reactflow-CRZcPCXF.js";import"./vendor-xterm-tcedd2Jt.js";import"./vendor-codemirror-jBKmHyH0.js";/**
1
+ import{r as c,j as e}from"./vendor-react-D37HfzIf.js";import{c as Et,a7 as ut,a8 as bt,a9 as Tt,cu as Dt,cv as Ft,cw as $t,cx as Rt,cy as Mt,cz as Ot,cA as _t,cB as Ut,ac as Pt,v as Kt,j as Bt,z as q,cC as pt,L as Xt,J as zt,bI as Q,X as Z,cD as ft,b6 as ht,U as xt,aj as Wt,a as Gt,aA as Ht,B as gt}from"./index-CgfrecpF.js";import{u as Lt}from"./vendor-i18n-CV0mwX_-.js";import"./vendor-reactflow-CRZcPCXF.js";import"./vendor-xterm-tcedd2Jt.js";import"./vendor-codemirror-jBKmHyH0.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{r as o,j as e,b as qa}from"./vendor-react-D37HfzIf.js";import{R as Ga,u as Ha,a as Ua,b as Ka,i as Ya,B as Ja,C as Xa,M as Qa}from"./vendor-reactflow-CRZcPCXF.js";import{c as Za,es as Vt,et as _e,eu as la,ev as eo,ew as to,ex as so,ey as ia,z as ae,j as ut,J as je,T as Pe,B as ao,aj as oo,a as Fe,U as be,b8 as ra,dM as no,i as ft,dN as Fs,ao as da,b7 as qt,b as Re,m as Gt,b6 as lo,ez as io,eA as ro,eB as co,eC as uo,dS as fo,p as mo,eD as Is,v as po,eE as wo,eF as ho,eG as go,eH as xo,eI as bo,eJ as ko,dK as vo,eK as jo,eL as No,eM as yo,eN as Ms,eO as As,eP as Rs,eQ as Co,eR as So,eS as Eo,eT as Fo,eU as Io,eV as Mo,eW as Ao,eX as Ro,eY as Po,eZ as Do,e_ as Ps,e$ as zo,f0 as Ds,f1 as zs,f2 as To,f3 as Lt,f4 as Lo,f5 as ca,f6 as Oo,f7 as Ts,f8 as $o,bT as Ls,ei as ua,M as Wo,X as Ht,L as Ee,bK as _o,f9 as Ot,cD as fa,bx as Bo,em as Vo,by as qo,b0 as Go,cH as Ho,fa as Uo,fb as Ko,fc as Yo,fd as Os,fe as Jo,ff as Xo,fg as Qo,b3 as ct,av as $e,fh as Zo,fi as en,fj as tn,fk as sn,cr as an,fl as on,fm as nn}from"./index-CW4OzecJ.js";import{u as ke}from"./vendor-i18n-CV0mwX_-.js";import{U as ln}from"./upload-Y9NiLQ9o.js";import"./vendor-xterm-tcedd2Jt.js";import"./vendor-codemirror-jBKmHyH0.js";/**
1
+ import{r as o,j as e,b as qa}from"./vendor-react-D37HfzIf.js";import{R as Ga,u as Ha,a as Ua,b as Ka,i as Ya,B as Ja,C as Xa,M as Qa}from"./vendor-reactflow-CRZcPCXF.js";import{c as Za,es as Vt,et as _e,eu as la,ev as eo,ew as to,ex as so,ey as ia,z as ae,j as ut,J as je,T as Pe,B as ao,aj as oo,a as Fe,U as be,b8 as ra,dM as no,i as ft,dN as Fs,ao as da,b7 as qt,b as Re,m as Gt,b6 as lo,ez as io,eA as ro,eB as co,eC as uo,dS as fo,p as mo,eD as Is,v as po,eE as wo,eF as ho,eG as go,eH as xo,eI as bo,eJ as ko,dK as vo,eK as jo,eL as No,eM as yo,eN as Ms,eO as As,eP as Rs,eQ as Co,eR as So,eS as Eo,eT as Fo,eU as Io,eV as Mo,eW as Ao,eX as Ro,eY as Po,eZ as Do,e_ as Ps,e$ as zo,f0 as Ds,f1 as zs,f2 as To,f3 as Lt,f4 as Lo,f5 as ca,f6 as Oo,f7 as Ts,f8 as $o,bT as Ls,ei as ua,M as Wo,X as Ht,L as Ee,bK as _o,f9 as Ot,cD as fa,bx as Bo,em as Vo,by as qo,b0 as Go,cH as Ho,fa as Uo,fb as Ko,fc as Yo,fd as Os,fe as Jo,ff as Xo,fg as Qo,b3 as ct,av as $e,fh as Zo,fi as en,fj as tn,fk as sn,cr as an,fl as on,fm as nn}from"./index-CgfrecpF.js";import{u as ke}from"./vendor-i18n-CV0mwX_-.js";import{U as ln}from"./upload-BRAEugYV.js";import"./vendor-xterm-tcedd2Jt.js";import"./vendor-codemirror-jBKmHyH0.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as t,j as R}from"./vendor-react-D37HfzIf.js";import{cK as Ee,cL as Ye,t as _e,w as Xe,bo as ve}from"./index-CW4OzecJ.js";import{Z as Ae,a as je,M as $e,R as Ge}from"./zoom-out-CSTHbJgD.js";import"./vendor-i18n-CV0mwX_-.js";import"./vendor-reactflow-CRZcPCXF.js";import"./vendor-xterm-tcedd2Jt.js";import"./vendor-codemirror-jBKmHyH0.js";import"./createLucideIcon-BYvOGRiO.js";const ye=4,xe=300,We=24;function Le({taskId:r,position:s,scale:o,canDrag:a,onPositionChange:f,onDragStateChange:c,onDragEnd:m,onDoubleTap:b}){const[C,I]=t.useState(!1),k=t.useRef(null),T=t.useRef(s),E=t.useRef(!1),n=t.useRef(null),h=t.useRef(!1);T.current=s,h.current=C;const l=t.useCallback(()=>{n.current=null},[]),M=t.useCallback(u=>{k.current=null,I(!1),h.current=!1,u&&(c?.(!1),m?.(),E.current=!0,l())},[m,c,l]),z=t.useCallback(u=>{if(!u.isPrimary)return;if(u.defaultPrevented){l();return}const P=Date.now();n.current&&P-n.current.timeStamp>xe&&l(),a&&u.stopPropagation();const D=u.currentTarget;a&&typeof D.setPointerCapture=="function"&&D.setPointerCapture(u.pointerId),k.current={pointerId:u.pointerId,pointerType:u.pointerType,startPointer:{x:u.clientX,y:u.clientY},startPosition:T.current,defaultPrevented:u.defaultPrevented,movedBeyondThreshold:!1}},[a,l]),_=t.useCallback(u=>{const P=k.current;if(!P||P.pointerId!==u.pointerId)return;a&&u.stopPropagation();const D=u.clientX-P.startPointer.x,X=u.clientY-P.startPointer.y,ee=Math.hypot(D,X);if(ee>=ye&&(P.movedBeyondThreshold=!0),!a){P.movedBeyondThreshold&&l();return}if(!h.current&&ee>=ye&&(I(!0),h.current=!0,c?.(!0),l()),ee<ye)return;const L=o>0?o:1;f(r,{x:P.startPosition.x+D/L,y:P.startPosition.y+X/L})},[a,c,f,l,o,r]),W=t.useCallback((u,P)=>{if(!b||P.defaultPrevented||P.movedBeyondThreshold)return Date.now()-(n.current?.timeStamp??0)>xe&&l(),!1;if(P.pointerType==="mouse")return l(),!1;const D={timeStamp:Date.now(),point:{x:P.startPointer.x,y:P.startPointer.y}},X=n.current;return!X||D.timeStamp-X.timeStamp>xe||Math.hypot(D.point.x-X.point.x,D.point.y-X.point.y)>We?(n.current=D,!1):(E.current=!0,l(),b(),!0)},[b,l]),$=t.useCallback(u=>{const P=k.current;if(!P||P.pointerId!==u.pointerId)return;a&&u.stopPropagation(),a&&typeof u.currentTarget.hasPointerCapture=="function"&&u.currentTarget.hasPointerCapture(u.pointerId)&&typeof u.currentTarget.releasePointerCapture=="function"&&u.currentTarget.releasePointerCapture(u.pointerId);const D=h.current;!D&&W(u,P)&&u.preventDefault(),M(D)},[a,M,W]),G=t.useCallback(u=>{const P=k.current;!P||P.pointerId!==u.pointerId||(a&&u.stopPropagation(),a&&typeof u.currentTarget.hasPointerCapture=="function"&&u.currentTarget.hasPointerCapture(u.pointerId)&&typeof u.currentTarget.releasePointerCapture=="function"&&u.currentTarget.releasePointerCapture(u.pointerId),l(),M(h.current))},[a,M,l]),j=t.useCallback(u=>{E.current&&(E.current=!1,u.preventDefault(),u.stopPropagation())},[]);return t.useMemo(()=>({isDragging:C,onPointerDown:z,onPointerMove:_,onPointerUp:$,onPointerCancel:G,onClickCapture:j}),[C,j,G,z,_,$])}const Ue=new Set(["planning","researching","executing","finalizing","merging","merging-fix"]);function Fe(r){return r?r.charAt(0).toUpperCase()+r.slice(1):"Executing"}function Be({style:r,position:s,scale:o,isSelected:a=!1,isHighlighted:f=!1,isDimmed:c=!1,onMouseEnter:m,onMouseLeave:b,onClick:C,onNodePositionChange:I,onNodeDragStateChange:k,onNodeDragEnd:T,...E}){const{task:n,globalPaused:h,taskStuckTimeoutMs:l,lastFetchTimeMs:M,onOpenDetail:z}=E,_=n.status==="failed",W=n.paused===!0,$=Ee(n,l,M),G=n.column==="triage"&&n.status==="awaiting-approval",j=!h&&!_&&!W&&!$&&!G&&(n.column==="in-progress"||Ue.has(n.status)),u=typeof n.currentStep=="number"&&n.currentStep>=0&&Array.isArray(n.steps)&&n.currentStep<n.steps.length,P=n.column==="in-review",D=Le({taskId:n.id,position:s,scale:o,canDrag:a,onPositionChange:I,onDragStateChange:k,onDragEnd:T,onDoubleTap:()=>z(n)});return R.jsxs("div",{className:`graph-task-node${a?" graph-node--draggable graph-task-node--selected":""}${D.isDragging?" graph-node--dragging":""}${f?" graph-task-node--highlighted graph-node--highlighted":""}${c?" graph-task-node--dimmed graph-node--dimmed":""}${j?" graph-task-node--active":""}${P?" graph-task-node--in-review":""}`,style:r,draggable:!1,"data-testid":`graph-task-node-${n.id}`,"data-current-step":j&&u?String(n.currentStep):void 0,onMouseEnter:m,onMouseLeave:b,onClick:C,onDoubleClick:X=>{X.defaultPrevented||z(n)},onClickCapture:D.onClickCapture,onPointerDown:D.onPointerDown,onPointerMove:D.onPointerMove,onPointerUp:D.onPointerUp,onPointerCancel:D.onPointerCancel,children:[j?R.jsx("div",{className:"graph-task-active-indicator",children:R.jsx("span",{className:"graph-task-active-indicator-text",children:Fe(n.status)})}):null,R.jsx(Ye,{...E,onOpenDetail:()=>{},disableDrag:!0})]})}function Ze({zoom:r,onZoomIn:s,onZoomOut:o,onFitToGraph:a,onResetView:f}){return R.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[R.jsx("button",{className:"btn btn-icon",title:"Zoom in (Ctrl+=)","aria-label":"Zoom in",onClick:s,children:R.jsx(Ae,{size:16})}),R.jsx("button",{className:"btn btn-icon",title:"Zoom out (Ctrl+-)","aria-label":"Zoom out",onClick:o,children:R.jsx(je,{size:16})}),R.jsxs("div",{className:"graph-toolbar__zoom-label","aria-live":"polite",children:[Math.round(r*100),"%"]}),R.jsx("button",{className:"btn btn-icon",title:"Fit to graph (Ctrl+Shift+F)","aria-label":"Fit to graph",onClick:a,children:R.jsx($e,{size:16})}),R.jsx("button",{className:"btn btn-icon",title:"Reset view (Ctrl+0)","aria-label":"Reset view",onClick:f,children:R.jsx(Ge,{size:16})})]})}const Ve=280,Ke=100;function qe({edges:r,positions:s,nodeWidth:o=Ve,nodeHeight:a=Ke,nodeHeights:f,highlightedEdgeIds:c}){const m=!!(c&&c.size>0);return R.jsxs("svg",{className:"dependency-graph-edges","aria-hidden":"true",children:[R.jsx("defs",{children:R.jsx("marker",{id:"dependency-graph-arrowhead",markerWidth:"10",markerHeight:"7",refX:"10",refY:"3.5",orient:"auto",markerUnits:"strokeWidth",children:R.jsx("path",{d:"M 0 0 L 10 3.5 L 0 7 z",fill:"var(--border)"})})}),r.map(b=>{const C=s.get(b.source),I=s.get(b.target);if(!C||!I)return null;const k=`${b.source}->${b.target}`,T=m&&(c?.has(k)??!1),E=C.x+o/2,n=C.y+(f?.get(b.source)??a),h=I.x+o/2,l=I.y,M=n+(l-n)/2;return R.jsx("path",{"data-testid":"dependency-edge","data-edge-id":k,className:`dependency-graph-edge${T?" graph-edge--highlighted":""}${m&&!T?" graph-edge--dimmed":""}`,d:`M ${E} ${n} C ${E} ${M}, ${h} ${M}, ${h} ${l}`,fill:"none",stroke:T?"var(--todo)":"var(--border)",strokeWidth:T?"var(--space-xs)":"var(--btn-border-width)",opacity:m&&!T?.15:1,markerEnd:"url(#dependency-graph-arrowhead)",style:{transition:"opacity var(--transition-fast), stroke var(--transition-fast), stroke-width var(--transition-fast)"}},k)})]})}const Je=new Set(["triage","todo","in-progress","in-review"]);function Qe(r){return r.filter(s=>Je.has(s.column))}const et={nodeWidth:280,nodeHeight:100,horizontalGap:40,verticalGap:80,orientation:"vertical"};function we(r,s){const o={...et,...s},a=r.nodes.map(n=>n.task.id);if(a.length===0)return new Map;const f=new Map,c=new Map;for(const n of a)c.set(n,0),f.set(n,[]);for(const n of r.edges)!c.has(n.source)||!c.has(n.target)||(f.get(n.target)?.push(n.source),c.set(n.source,(c.get(n.source)??0)+1));const m=a.filter(n=>(c.get(n)??0)===0),b=[];for(;m.length>0;){const n=m.shift();b.push(n);for(const h of f.get(n)??[]){const l=(c.get(h)??0)-1;c.set(h,l),l===0&&m.push(h)}}for(const n of a)b.includes(n)||b.push(n);const C=new Map;for(const n of b){const h=r.edges.filter(M=>M.source===n).map(M=>M.target);let l=0;for(const M of h)l=Math.max(l,(C.get(M)??0)+1);C.set(n,l)}const I=new Map;for(const n of a){const h=C.get(n)??0,l=I.get(h)??[];l.push(n),I.set(h,l)}const k=new Map,T=Array.from(I.keys()).sort((n,h)=>n-h),E=new Map;if(o.orientation==="vertical"){let n=0;for(const h of T){E.set(h,n);const l=I.get(h)??[],M=Math.max(o.nodeHeight,...l.map(z=>o.measuredHeights?.get(z)??o.nodeHeight));n+=M+o.verticalGap}}for(const n of T){const h=I.get(n)??[];if(h.sort(),o.orientation==="horizontal"){const W=-(h.reduce((j,u)=>j+(o.measuredHeights?.get(u)??o.nodeHeight),0)+Math.max(0,h.length-1)*o.verticalGap)/2,$=n*(o.nodeWidth+o.horizontalGap);let G=W;for(const j of h)k.set(j,{x:$,y:G}),G+=(o.measuredHeights?.get(j)??o.nodeHeight)+o.verticalGap;continue}const z=-(h.length*o.nodeWidth+Math.max(0,h.length-1)*o.horizontalGap)/2;h.forEach((_,W)=>{const $=z+W*(o.nodeWidth+o.horizontalGap),G=E.get(n)??n*(o.nodeHeight+o.verticalGap);k.set(_,{x:$,y:G})})}return k}function tt(r){return t.useMemo(()=>{const s=r.map(f=>({task:f})),o=new Set(r.map(f=>f.id)),a=r.flatMap(f=>(f.dependencies??[]).filter(c=>o.has(c)).map(c=>({source:f.id,target:c})));return{nodes:s,edges:a}},[r])}const ce=.1,ue=3,Se=40,nt=200;function J(r,s,o){return Math.min(o,Math.max(s,r))}function rt(r){if(!(r instanceof HTMLElement))return!1;const s=r.tagName.toLowerCase();return r.isContentEditable||s==="input"||s==="textarea"||s==="select"}function ot(){const[r,s]=t.useState({x:0,y:0}),[o,a]=t.useState(1),[f,c]=t.useState(!1),m=t.useRef(r),b=t.useRef(o),C=t.useRef(null),I=t.useRef(null),k=t.useRef(new Map),T=t.useRef(null),E=t.useRef({minX:0,minY:0,maxX:0,maxY:0});t.useEffect(()=>{m.current=r},[r]),t.useEffect(()=>{b.current=o},[o]),t.useEffect(()=>()=>{C.current!==null&&window.clearTimeout(C.current)},[]);const n=t.useMemo(()=>`translate(${r.x}px, ${r.y}px) scale(${o})`,[r.x,r.y,o]),h=t.useMemo(()=>Math.round(o*100),[o]),l=t.useCallback(i=>{if(!i){C.current!==null&&(window.clearTimeout(C.current),C.current=null),c(!1);return}c(!0),C.current!==null&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>{c(!1),C.current=null},nt)},[]),M=t.useCallback((i,d,g,S=b.current)=>{const x=E.current;if(x.maxX<=x.minX||x.maxY<=x.minY)return{x:J(i.x,-d,d),y:J(i.y,-g,g)};const U=d-x.maxX*S,O=-x.minX*S,v=g-x.maxY*S,B=-x.minY*S,Z=U>O?(U+O)/2:J(i.x,U,O),K=v>B?(v+B)/2:J(i.y,v,B);return{x:Z,y:K}},[]),z=t.useCallback((i,d,g,S)=>{const x=b.current,U=m.current,O=J(i,ce,ue),v=O/x,B=M({x:d.x-(d.x-U.x)*v,y:d.y-(d.y-U.y)*v},g,S,O);a(O),s(B)},[M]),_=t.useCallback((i,d,g,S)=>{l(!1);const x=S??{x:d/2,y:g/2};z(b.current*i,x,d,g)},[l,z]),W=t.useCallback((i,d)=>{if(i&&d){_(1.2,i,d);return}a(g=>J(g+.1,ce,ue))},[_]),$=t.useCallback((i,d)=>{if(i&&d){_(1/1.2,i,d);return}a(g=>J(g-.1,ce,ue))},[_]),G=t.useCallback(()=>{l(!0),s({x:0,y:0}),a(1)},[l]),j=t.useCallback((i,d,g,S)=>{if(l(!0),i.size===0){s({x:0,y:0}),a(1);return}const x=S?.nodeWidth??280,U=S?.nodeHeight??100,O=Array.from(i.entries()),v=Math.min(...O.map(([,q])=>q.x)),B=Math.min(...O.map(([,q])=>q.y)),Z=Math.max(...O.map(([,q])=>q.x+x)),K=Math.max(...O.map(([q,he])=>he.y+(S?.measuredHeights?.get(q)??U))),te=Math.max(1,Z-v),A=Math.max(1,K-B),oe=Math.max(1,d-Se*2),se=Math.max(1,g-Se*2),ne=J(Math.min(oe/te,se/A),ce,ue),pe=(d-te*ne)/2-v*ne,de=(g-A*ne)/2-B*ne;a(ne),s(M({x:pe,y:de},d,g,ne))},[M,l]),u=t.useCallback((i,d)=>{if(k.current.set(i,d),k.current.size===2){const[g,S]=Array.from(k.current.values());T.current={distance:Math.hypot(g.x-S.x,g.y-S.y),zoom:b.current,pan:m.current,midpoint:{x:(g.x+S.x)/2,y:(g.y+S.y)/2}},I.current=null;return}I.current={start:d,panStart:m.current}},[]),P=t.useCallback((i,d,g,S)=>{if(k.current.has(i)&&k.current.set(i,d),k.current.size===2&&T.current){l(!1);const[O,v]=Array.from(k.current.values()),Z=Math.hypot(O.x-v.x,O.y-v.y)/Math.max(1,T.current.distance),K={x:(O.x+v.x)/2,y:(O.y+v.y)/2},te=J(T.current.zoom*Z,ce,ue),A=te/T.current.zoom,oe=M({x:K.x-(T.current.midpoint.x-T.current.pan.x)*A,y:K.y-(T.current.midpoint.y-T.current.pan.y)*A},g,S);a(te),s(oe);return}const x=I.current;if(!x)return;l(!1);const U={x:x.panStart.x+(d.x-x.start.x),y:x.panStart.y+(d.y-x.start.y)};s(M(U,g,S))},[M,l]),D=t.useCallback(i=>{if(k.current.delete(i),k.current.size<2&&(T.current=null),k.current.size===1){const[d]=Array.from(k.current.values());I.current={start:d,panStart:m.current};return}k.current.size===0&&(I.current=null)},[]),X=t.useCallback((i,d,g,S)=>{l(!1);const x={x:m.current.x-i,y:m.current.y-d};s(M(x,g,S))},[M,l]),ee=t.useCallback((i,d,g,S)=>{const x=i<0?1.1:.9;l(!1),z(b.current*x,d,g,S)},[l,z]),L=t.useCallback(i=>{E.current=i},[]),le=t.useCallback((i,d,g,S,x)=>{if(rt(i.target))return;const U=i.metaKey||i.ctrlKey;if(i.key==="Escape"){i.preventDefault(),G();return}if(U){if(i.key==="="||i.key==="+"){i.preventDefault(),_(1.2,d,g);return}if(i.key==="-"){i.preventDefault(),_(1/1.2,d,g);return}if(i.key==="0"){i.preventDefault(),G();return}(i.key==="f"||i.key==="F")&&i.shiftKey&&(i.preventDefault(),j(S,d,g,x))}},[j,G,_]);return{pan:r,zoom:o,zoomPercent:h,transform:n,transitioning:f,zoomIn:W,zoomOut:$,resetView:G,fitToGraph:j,setAnimate:l,onPointerDown:u,onPointerMove:P,onPointerUp:D,onWheelPan:X,onWheelZoom:ee,handleKeyDown:le,setGraphBounds:L}}function st(r){const{upstreamMap:s,downstreamMap:o}=t.useMemo(()=>{const f=new Map,c=new Map;for(const m of r)f.set(m.id,new Set(m.dependencies??[])),c.has(m.id)||c.set(m.id,new Set);for(const m of r)for(const b of m.dependencies??[])c.has(b)||c.set(b,new Set),c.get(b)?.add(m.id);return{upstreamMap:f,downstreamMap:c}},[r]);return{getChain:t.useCallback(f=>{if(!s.has(f)&&!o.has(f))return new Set;const c=new Set([f]),m=(b,C)=>{const I=[b],k=new Set([b]);for(;I.length>0;){const T=I.shift();if(!T)continue;const E=C.get(T);if(E)for(const n of E)k.has(n)||(k.add(n),c.add(n),I.push(n))}};return m(f,s),m(f,o),c},[o,s])}}const ke="fusion-plugin-dependency-graph:positions";function fe(r){if(!r||typeof r!="object")return!1;const s=r;return typeof s.x=="number"&&Number.isFinite(s.x)&&typeof s.y=="number"&&Number.isFinite(s.y)}function it(r){const s=_e(ke,r);if(!s)return{};try{const o=JSON.parse(s);if(!o||typeof o!="object")return{};const a={};for(const[f,c]of Object.entries(o))fe(c)&&(a[f]=c);return a}catch{return{}}}function at(r,s,o){const a={};for(const[f,c]of Object.entries(r))s.has(f)&&fe(c)&&(a[f]=c);Xe(ke,JSON.stringify(a),o)}function ct(r){ve(ke,r)}function ut(r,s,o){const a={};for(const[f,c]of Object.entries(r))o.has(f)&&fe(c)&&(a[f]=c);for(const[f,c]of Object.entries(s))o.has(f)&&fe(c)&&(a[f]=c);return a}function lt(r,s){const o={};for(const[a,f]of Object.entries(r))s.has(a)&&(o[a]=f);return o}function dt({projectId:r,visibleTaskIds:s}){const[o,a]=t.useState(null);t.useEffect(()=>{a(it(r))},[r]);const f=t.useCallback(m=>{at(m,s,r),a(lt(m,s))},[r,s]),c=t.useCallback(()=>{ct(r),a(null)},[r]);return{savedPositions:o,persistPositions:f,clearSavedPositions:c}}const ae=280,Q=100,ft=768,Te=4;function pt({tasks:r,projectId:s,onOpenTaskDetail:o,onOpenDetail:a,addToast:f,globalPaused:c,onUpdateTask:m,onArchiveTask:b,onUnarchiveTask:C,onDeleteTask:I,onRetryTask:k,onOpenDetailWithTab:T,taskStuckTimeoutMs:E,onOpenMission:n,onMoveTask:h,lastFetchTimeMs:l,workflowStepNameLookup:M}){const z=t.useRef(null),_=t.useRef(!1),W=t.useRef(null),$=t.useRef(!1),G=t.useRef(new Map),[j,u]=t.useState(null),[P,D]=t.useState(null),[X,ee]=t.useState({width:0,height:0}),[L,le]=t.useState(new Map),i=t.useMemo(()=>Qe(r),[r]),d=tt(i),{getChain:g}=st(i),S=j??P,x=t.useMemo(()=>S?g(S):new Set,[S,g]),U=t.useMemo(()=>{const e=X.width||(typeof window<"u"?window.innerWidth:0);return(X.height||(typeof window<"u"?window.innerHeight:0))>e||e<ft?"horizontal":"vertical"},[X.height,X.width]),O=t.useMemo(()=>({nodeWidth:ae,nodeHeight:Q,horizontalGap:40,verticalGap:80,orientation:U,measuredHeights:L}),[L,U]),v=t.useMemo(()=>we(d,O),[d,O]),B=t.useMemo(()=>new Set(i.map(e=>e.id)),[i]),{savedPositions:Z,persistPositions:K,clearSavedPositions:te}=dt({projectId:s,visibleTaskIds:B}),[A,oe]=t.useState(v),[se,ne]=t.useState(!1);t.useEffect(()=>{const e={};for(const[y,H]of v.entries())e[y]=H;const p=Z?ut(e,Z,B):e;oe(new Map(Object.entries(p)))},[v,Z,B]),t.useEffect(()=>{const e=z.current;if(!e)return;const p=(H,Y)=>{ee(w=>w.width===H&&w.height===Y?w:{width:H,height:Y})};if(typeof ResizeObserver>"u"){p(e.clientWidth||(typeof window<"u"?window.innerWidth:0),e.clientHeight||(typeof window<"u"?window.innerHeight:0));return}p(e.clientWidth,e.clientHeight);const y=new ResizeObserver(H=>{const Y=H[0];Y&&p(Y.contentRect.width,Y.contentRect.height)});return y.observe(e),()=>y.disconnect()},[]),t.useEffect(()=>{const e=z.current;if(!e)return;const p=new Set(d.nodes.map(w=>w.task.id)),y=new Map;for(const w of p){const N=e.querySelector(`[data-testid="graph-task-node-${w}"]`);N&&y.set(w,N)}G.current=y,le(w=>{let N=!1;const F=new Map;for(const[re,ie]of w.entries()){if(!p.has(re)){N=!0;continue}F.set(re,ie)}return N?F:w});const H=(w,N)=>{le(F=>{const re=F.get(w);if(re!==void 0&&Math.abs(re-N)<1)return F;const ie=new Map(F);return ie.set(w,N),ie})};for(const[w,N]of y.entries())H(w,N.offsetHeight||Q);if(typeof ResizeObserver>"u")return;const Y=new ResizeObserver(w=>{for(const N of w){const F=N.target,re=Array.from(y.entries()).find(([,ie])=>ie===F)?.[0];re&&H(re,F.offsetHeight||Q)}});for(const w of y.values())Y.observe(w);return()=>Y.disconnect()},[d.nodes,A,X.height,X.width]);const{transform:pe,zoom:de,transitioning:q,zoomIn:he,zoomOut:Ce,resetView:De,fitToGraph:me,onPointerDown:Re,onPointerMove:Ie,onPointerUp:be,onWheelPan:ze,onWheelZoom:He,handleKeyDown:Ne,setGraphBounds:Me}=ot();t.useEffect(()=>{if(_.current||i.length===0)return;if(!!(Z&&Object.keys(Z).length>0)){_.current=!0;return}const p=z.current;p&&(me(A,p.clientWidth,p.clientHeight,{nodeWidth:ae,nodeHeight:Q,measuredHeights:L}),_.current=!0)},[i.length,me,L,A,Z]);const V=t.useMemo(()=>{const e=Array.from(A.values());if(e.length===0)return{minX:0,minY:0,maxX:0,maxY:0,width:0,height:0};const p=Math.min(...e.map(w=>w.x)),y=Math.min(...e.map(w=>w.y)),H=Math.max(...e.map(w=>w.x+ae)),Y=Math.max(...Array.from(A.entries()).map(([w,N])=>N.y+(L.get(w)??Q)));return{minX:p,minY:y,maxX:H,maxY:Y,width:Math.max(0,H-p),height:Math.max(0,Y-y)}},[L,A]),ge=t.useMemo(()=>{if(A.size===0)return A;const e=new Map;for(const[p,y]of A.entries())e.set(p,{x:y.x-V.minX,y:y.y-V.minY});return e},[V.minX,V.minY,A]);t.useEffect(()=>{Me({minX:0,minY:0,maxX:V.width,maxY:V.height})},[V.height,V.width,Me]);const Pe=t.useCallback(()=>{te();const e=we(d,O);oe(e)},[te,d,O]),Oe=t.useCallback(()=>{const e={};for(const[p,y]of A.entries())e[p]=y;K(e)},[K,A]);return R.jsxs("section",{className:"dependency-graph","data-testid":"dependency-graph",children:[R.jsx("div",{ref:z,className:"dependency-graph__viewport",onPointerDown:e=>{se||(W.current={x:e.clientX,y:e.clientY},$.current=!1,Re(e.pointerId,{x:e.clientX,y:e.clientY}))},onPointerMove:e=>{if(se)return;const p=z.current;if(!p)return;const y=W.current;if(y){const H=Math.abs(e.clientX-y.x),Y=Math.abs(e.clientY-y.y);(H>Te||Y>Te)&&($.current=!0)}Ie(e.pointerId,{x:e.clientX,y:e.clientY},p.clientWidth,p.clientHeight)},onPointerUp:e=>{se||be(e.pointerId),W.current=null},onPointerCancel:e=>{se||be(e.pointerId),W.current=null,$.current=!1},onWheel:e=>{e.preventDefault();const p=z.current;if(p){if(e.ctrlKey||e.metaKey){const y=p.getBoundingClientRect();He(e.deltaY,{x:e.clientX-y.left,y:e.clientY-y.top},p.clientWidth,p.clientHeight);return}ze(e.deltaX,e.deltaY,p.clientWidth,p.clientHeight)}},onKeyDown:e=>{const p=z.current;p&&Ne(e,p.clientWidth,p.clientHeight,ge,{nodeWidth:ae,nodeHeight:Q,measuredHeights:L})},tabIndex:0,onClick:()=>{$.current||se||D(null)},children:i.length===0?R.jsx("div",{className:"dependency-graph__empty",children:"No active tasks to display in graph view."}):R.jsxs("div",{className:`graph-canvas-transform${q?" graph-canvas-transform--animate":""}`,style:{transform:pe,width:`${V.width}px`,height:`${V.height}px`},children:[R.jsx(qe,{edges:d.edges,positions:ge,nodeWidth:ae,nodeHeight:Q,nodeHeights:L,highlightedEdgeIds:x.size>0?new Set(d.edges.filter(e=>x.has(e.source)&&x.has(e.target)).map(e=>`${e.source}->${e.target}`)):void 0}),R.jsx("div",{className:"dependency-graph__nodes-layer",children:d.nodes.map(e=>{const p=ge.get(e.task.id);return p?R.jsx(Be,{task:e.task,projectId:s,isSelected:P===e.task.id,style:{minHeight:`${Q}px`,left:`${p.x}px`,top:`${p.y}px`},position:p,scale:de,onNodePositionChange:(y,H)=>{oe(Y=>{const w={x:H.x+V.minX,y:H.y+V.minY},N=Y.get(y);if(N&&N.x===w.x&&N.y===w.y)return Y;const F=new Map(Y);return F.set(y,w),F})},onNodeDragStateChange:ne,onNodeDragEnd:Oe,isHighlighted:x.size>0&&x.has(e.task.id),isDimmed:x.size>0&&!x.has(e.task.id),onOpenDetail:a??(y=>o?.(y.id)),addToast:f??(()=>{}),globalPaused:c,onUpdateTask:m,onArchiveTask:b,onUnarchiveTask:C,onDeleteTask:I,onRetryTask:k,onOpenDetailWithTab:T,taskStuckTimeoutMs:E,onOpenMission:n,onMoveTask:h,lastFetchTimeMs:l,workflowStepNameLookup:M,onMouseEnter:()=>u(e.task.id),onMouseLeave:()=>u(null),onClick:y=>{y.stopPropagation(),$.current=!1,D(H=>H===e.task.id?null:e.task.id)}},e.task.id):null})})]})}),R.jsx(Ze,{zoom:de,onZoomIn:()=>{const e=z.current;e&&he(e.clientWidth,e.clientHeight)},onZoomOut:()=>{const e=z.current;e&&Ce(e.clientWidth,e.clientHeight)},onFitToGraph:()=>{Pe();const e=z.current;if(!e)return;const p=we(d,O),y=new Map,H=Array.from(p.values()),Y=H.length>0?Math.min(...H.map(N=>N.x)):0,w=H.length>0?Math.min(...H.map(N=>N.y)):0;for(const[N,F]of p.entries())y.set(N,{x:F.x-Y,y:F.y-w});me(y,e.clientWidth,e.clientHeight,{nodeWidth:ae,nodeHeight:Q,measuredHeights:L})},onResetView:()=>{Pe(),De()}})]})}function ht(r){return new Map((r??[]).map(s=>[s.id,s.name]))}function Pt({context:r}){return t.createElement(pt,{tasks:r?.tasks??[],projectId:r?.projectId,workflowStepNameLookup:ht(r?.workflowSteps),onOpenDetail:r?.openTaskDetail})}export{pt as DependencyGraph,Pt as DependencyGraphDashboardView,Pt as default};
1
+ import{r as t,j as R}from"./vendor-react-D37HfzIf.js";import{cK as Ee,cL as Ye,t as _e,w as Xe,bo as ve}from"./index-CgfrecpF.js";import{Z as Ae,a as je,M as $e,R as Ge}from"./zoom-out-CSTHbJgD.js";import"./vendor-i18n-CV0mwX_-.js";import"./vendor-reactflow-CRZcPCXF.js";import"./vendor-xterm-tcedd2Jt.js";import"./vendor-codemirror-jBKmHyH0.js";import"./createLucideIcon-BYvOGRiO.js";const ye=4,xe=300,We=24;function Le({taskId:r,position:s,scale:o,canDrag:a,onPositionChange:f,onDragStateChange:c,onDragEnd:m,onDoubleTap:b}){const[C,I]=t.useState(!1),k=t.useRef(null),T=t.useRef(s),E=t.useRef(!1),n=t.useRef(null),h=t.useRef(!1);T.current=s,h.current=C;const l=t.useCallback(()=>{n.current=null},[]),M=t.useCallback(u=>{k.current=null,I(!1),h.current=!1,u&&(c?.(!1),m?.(),E.current=!0,l())},[m,c,l]),z=t.useCallback(u=>{if(!u.isPrimary)return;if(u.defaultPrevented){l();return}const P=Date.now();n.current&&P-n.current.timeStamp>xe&&l(),a&&u.stopPropagation();const D=u.currentTarget;a&&typeof D.setPointerCapture=="function"&&D.setPointerCapture(u.pointerId),k.current={pointerId:u.pointerId,pointerType:u.pointerType,startPointer:{x:u.clientX,y:u.clientY},startPosition:T.current,defaultPrevented:u.defaultPrevented,movedBeyondThreshold:!1}},[a,l]),_=t.useCallback(u=>{const P=k.current;if(!P||P.pointerId!==u.pointerId)return;a&&u.stopPropagation();const D=u.clientX-P.startPointer.x,X=u.clientY-P.startPointer.y,ee=Math.hypot(D,X);if(ee>=ye&&(P.movedBeyondThreshold=!0),!a){P.movedBeyondThreshold&&l();return}if(!h.current&&ee>=ye&&(I(!0),h.current=!0,c?.(!0),l()),ee<ye)return;const L=o>0?o:1;f(r,{x:P.startPosition.x+D/L,y:P.startPosition.y+X/L})},[a,c,f,l,o,r]),W=t.useCallback((u,P)=>{if(!b||P.defaultPrevented||P.movedBeyondThreshold)return Date.now()-(n.current?.timeStamp??0)>xe&&l(),!1;if(P.pointerType==="mouse")return l(),!1;const D={timeStamp:Date.now(),point:{x:P.startPointer.x,y:P.startPointer.y}},X=n.current;return!X||D.timeStamp-X.timeStamp>xe||Math.hypot(D.point.x-X.point.x,D.point.y-X.point.y)>We?(n.current=D,!1):(E.current=!0,l(),b(),!0)},[b,l]),$=t.useCallback(u=>{const P=k.current;if(!P||P.pointerId!==u.pointerId)return;a&&u.stopPropagation(),a&&typeof u.currentTarget.hasPointerCapture=="function"&&u.currentTarget.hasPointerCapture(u.pointerId)&&typeof u.currentTarget.releasePointerCapture=="function"&&u.currentTarget.releasePointerCapture(u.pointerId);const D=h.current;!D&&W(u,P)&&u.preventDefault(),M(D)},[a,M,W]),G=t.useCallback(u=>{const P=k.current;!P||P.pointerId!==u.pointerId||(a&&u.stopPropagation(),a&&typeof u.currentTarget.hasPointerCapture=="function"&&u.currentTarget.hasPointerCapture(u.pointerId)&&typeof u.currentTarget.releasePointerCapture=="function"&&u.currentTarget.releasePointerCapture(u.pointerId),l(),M(h.current))},[a,M,l]),j=t.useCallback(u=>{E.current&&(E.current=!1,u.preventDefault(),u.stopPropagation())},[]);return t.useMemo(()=>({isDragging:C,onPointerDown:z,onPointerMove:_,onPointerUp:$,onPointerCancel:G,onClickCapture:j}),[C,j,G,z,_,$])}const Ue=new Set(["planning","researching","executing","finalizing","merging","merging-fix"]);function Fe(r){return r?r.charAt(0).toUpperCase()+r.slice(1):"Executing"}function Be({style:r,position:s,scale:o,isSelected:a=!1,isHighlighted:f=!1,isDimmed:c=!1,onMouseEnter:m,onMouseLeave:b,onClick:C,onNodePositionChange:I,onNodeDragStateChange:k,onNodeDragEnd:T,...E}){const{task:n,globalPaused:h,taskStuckTimeoutMs:l,lastFetchTimeMs:M,onOpenDetail:z}=E,_=n.status==="failed",W=n.paused===!0,$=Ee(n,l,M),G=n.column==="triage"&&n.status==="awaiting-approval",j=!h&&!_&&!W&&!$&&!G&&(n.column==="in-progress"||Ue.has(n.status)),u=typeof n.currentStep=="number"&&n.currentStep>=0&&Array.isArray(n.steps)&&n.currentStep<n.steps.length,P=n.column==="in-review",D=Le({taskId:n.id,position:s,scale:o,canDrag:a,onPositionChange:I,onDragStateChange:k,onDragEnd:T,onDoubleTap:()=>z(n)});return R.jsxs("div",{className:`graph-task-node${a?" graph-node--draggable graph-task-node--selected":""}${D.isDragging?" graph-node--dragging":""}${f?" graph-task-node--highlighted graph-node--highlighted":""}${c?" graph-task-node--dimmed graph-node--dimmed":""}${j?" graph-task-node--active":""}${P?" graph-task-node--in-review":""}`,style:r,draggable:!1,"data-testid":`graph-task-node-${n.id}`,"data-current-step":j&&u?String(n.currentStep):void 0,onMouseEnter:m,onMouseLeave:b,onClick:C,onDoubleClick:X=>{X.defaultPrevented||z(n)},onClickCapture:D.onClickCapture,onPointerDown:D.onPointerDown,onPointerMove:D.onPointerMove,onPointerUp:D.onPointerUp,onPointerCancel:D.onPointerCancel,children:[j?R.jsx("div",{className:"graph-task-active-indicator",children:R.jsx("span",{className:"graph-task-active-indicator-text",children:Fe(n.status)})}):null,R.jsx(Ye,{...E,onOpenDetail:()=>{},disableDrag:!0})]})}function Ze({zoom:r,onZoomIn:s,onZoomOut:o,onFitToGraph:a,onResetView:f}){return R.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[R.jsx("button",{className:"btn btn-icon",title:"Zoom in (Ctrl+=)","aria-label":"Zoom in",onClick:s,children:R.jsx(Ae,{size:16})}),R.jsx("button",{className:"btn btn-icon",title:"Zoom out (Ctrl+-)","aria-label":"Zoom out",onClick:o,children:R.jsx(je,{size:16})}),R.jsxs("div",{className:"graph-toolbar__zoom-label","aria-live":"polite",children:[Math.round(r*100),"%"]}),R.jsx("button",{className:"btn btn-icon",title:"Fit to graph (Ctrl+Shift+F)","aria-label":"Fit to graph",onClick:a,children:R.jsx($e,{size:16})}),R.jsx("button",{className:"btn btn-icon",title:"Reset view (Ctrl+0)","aria-label":"Reset view",onClick:f,children:R.jsx(Ge,{size:16})})]})}const Ve=280,Ke=100;function qe({edges:r,positions:s,nodeWidth:o=Ve,nodeHeight:a=Ke,nodeHeights:f,highlightedEdgeIds:c}){const m=!!(c&&c.size>0);return R.jsxs("svg",{className:"dependency-graph-edges","aria-hidden":"true",children:[R.jsx("defs",{children:R.jsx("marker",{id:"dependency-graph-arrowhead",markerWidth:"10",markerHeight:"7",refX:"10",refY:"3.5",orient:"auto",markerUnits:"strokeWidth",children:R.jsx("path",{d:"M 0 0 L 10 3.5 L 0 7 z",fill:"var(--border)"})})}),r.map(b=>{const C=s.get(b.source),I=s.get(b.target);if(!C||!I)return null;const k=`${b.source}->${b.target}`,T=m&&(c?.has(k)??!1),E=C.x+o/2,n=C.y+(f?.get(b.source)??a),h=I.x+o/2,l=I.y,M=n+(l-n)/2;return R.jsx("path",{"data-testid":"dependency-edge","data-edge-id":k,className:`dependency-graph-edge${T?" graph-edge--highlighted":""}${m&&!T?" graph-edge--dimmed":""}`,d:`M ${E} ${n} C ${E} ${M}, ${h} ${M}, ${h} ${l}`,fill:"none",stroke:T?"var(--todo)":"var(--border)",strokeWidth:T?"var(--space-xs)":"var(--btn-border-width)",opacity:m&&!T?.15:1,markerEnd:"url(#dependency-graph-arrowhead)",style:{transition:"opacity var(--transition-fast), stroke var(--transition-fast), stroke-width var(--transition-fast)"}},k)})]})}const Je=new Set(["triage","todo","in-progress","in-review"]);function Qe(r){return r.filter(s=>Je.has(s.column))}const et={nodeWidth:280,nodeHeight:100,horizontalGap:40,verticalGap:80,orientation:"vertical"};function we(r,s){const o={...et,...s},a=r.nodes.map(n=>n.task.id);if(a.length===0)return new Map;const f=new Map,c=new Map;for(const n of a)c.set(n,0),f.set(n,[]);for(const n of r.edges)!c.has(n.source)||!c.has(n.target)||(f.get(n.target)?.push(n.source),c.set(n.source,(c.get(n.source)??0)+1));const m=a.filter(n=>(c.get(n)??0)===0),b=[];for(;m.length>0;){const n=m.shift();b.push(n);for(const h of f.get(n)??[]){const l=(c.get(h)??0)-1;c.set(h,l),l===0&&m.push(h)}}for(const n of a)b.includes(n)||b.push(n);const C=new Map;for(const n of b){const h=r.edges.filter(M=>M.source===n).map(M=>M.target);let l=0;for(const M of h)l=Math.max(l,(C.get(M)??0)+1);C.set(n,l)}const I=new Map;for(const n of a){const h=C.get(n)??0,l=I.get(h)??[];l.push(n),I.set(h,l)}const k=new Map,T=Array.from(I.keys()).sort((n,h)=>n-h),E=new Map;if(o.orientation==="vertical"){let n=0;for(const h of T){E.set(h,n);const l=I.get(h)??[],M=Math.max(o.nodeHeight,...l.map(z=>o.measuredHeights?.get(z)??o.nodeHeight));n+=M+o.verticalGap}}for(const n of T){const h=I.get(n)??[];if(h.sort(),o.orientation==="horizontal"){const W=-(h.reduce((j,u)=>j+(o.measuredHeights?.get(u)??o.nodeHeight),0)+Math.max(0,h.length-1)*o.verticalGap)/2,$=n*(o.nodeWidth+o.horizontalGap);let G=W;for(const j of h)k.set(j,{x:$,y:G}),G+=(o.measuredHeights?.get(j)??o.nodeHeight)+o.verticalGap;continue}const z=-(h.length*o.nodeWidth+Math.max(0,h.length-1)*o.horizontalGap)/2;h.forEach((_,W)=>{const $=z+W*(o.nodeWidth+o.horizontalGap),G=E.get(n)??n*(o.nodeHeight+o.verticalGap);k.set(_,{x:$,y:G})})}return k}function tt(r){return t.useMemo(()=>{const s=r.map(f=>({task:f})),o=new Set(r.map(f=>f.id)),a=r.flatMap(f=>(f.dependencies??[]).filter(c=>o.has(c)).map(c=>({source:f.id,target:c})));return{nodes:s,edges:a}},[r])}const ce=.1,ue=3,Se=40,nt=200;function J(r,s,o){return Math.min(o,Math.max(s,r))}function rt(r){if(!(r instanceof HTMLElement))return!1;const s=r.tagName.toLowerCase();return r.isContentEditable||s==="input"||s==="textarea"||s==="select"}function ot(){const[r,s]=t.useState({x:0,y:0}),[o,a]=t.useState(1),[f,c]=t.useState(!1),m=t.useRef(r),b=t.useRef(o),C=t.useRef(null),I=t.useRef(null),k=t.useRef(new Map),T=t.useRef(null),E=t.useRef({minX:0,minY:0,maxX:0,maxY:0});t.useEffect(()=>{m.current=r},[r]),t.useEffect(()=>{b.current=o},[o]),t.useEffect(()=>()=>{C.current!==null&&window.clearTimeout(C.current)},[]);const n=t.useMemo(()=>`translate(${r.x}px, ${r.y}px) scale(${o})`,[r.x,r.y,o]),h=t.useMemo(()=>Math.round(o*100),[o]),l=t.useCallback(i=>{if(!i){C.current!==null&&(window.clearTimeout(C.current),C.current=null),c(!1);return}c(!0),C.current!==null&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>{c(!1),C.current=null},nt)},[]),M=t.useCallback((i,d,g,S=b.current)=>{const x=E.current;if(x.maxX<=x.minX||x.maxY<=x.minY)return{x:J(i.x,-d,d),y:J(i.y,-g,g)};const U=d-x.maxX*S,O=-x.minX*S,v=g-x.maxY*S,B=-x.minY*S,Z=U>O?(U+O)/2:J(i.x,U,O),K=v>B?(v+B)/2:J(i.y,v,B);return{x:Z,y:K}},[]),z=t.useCallback((i,d,g,S)=>{const x=b.current,U=m.current,O=J(i,ce,ue),v=O/x,B=M({x:d.x-(d.x-U.x)*v,y:d.y-(d.y-U.y)*v},g,S,O);a(O),s(B)},[M]),_=t.useCallback((i,d,g,S)=>{l(!1);const x=S??{x:d/2,y:g/2};z(b.current*i,x,d,g)},[l,z]),W=t.useCallback((i,d)=>{if(i&&d){_(1.2,i,d);return}a(g=>J(g+.1,ce,ue))},[_]),$=t.useCallback((i,d)=>{if(i&&d){_(1/1.2,i,d);return}a(g=>J(g-.1,ce,ue))},[_]),G=t.useCallback(()=>{l(!0),s({x:0,y:0}),a(1)},[l]),j=t.useCallback((i,d,g,S)=>{if(l(!0),i.size===0){s({x:0,y:0}),a(1);return}const x=S?.nodeWidth??280,U=S?.nodeHeight??100,O=Array.from(i.entries()),v=Math.min(...O.map(([,q])=>q.x)),B=Math.min(...O.map(([,q])=>q.y)),Z=Math.max(...O.map(([,q])=>q.x+x)),K=Math.max(...O.map(([q,he])=>he.y+(S?.measuredHeights?.get(q)??U))),te=Math.max(1,Z-v),A=Math.max(1,K-B),oe=Math.max(1,d-Se*2),se=Math.max(1,g-Se*2),ne=J(Math.min(oe/te,se/A),ce,ue),pe=(d-te*ne)/2-v*ne,de=(g-A*ne)/2-B*ne;a(ne),s(M({x:pe,y:de},d,g,ne))},[M,l]),u=t.useCallback((i,d)=>{if(k.current.set(i,d),k.current.size===2){const[g,S]=Array.from(k.current.values());T.current={distance:Math.hypot(g.x-S.x,g.y-S.y),zoom:b.current,pan:m.current,midpoint:{x:(g.x+S.x)/2,y:(g.y+S.y)/2}},I.current=null;return}I.current={start:d,panStart:m.current}},[]),P=t.useCallback((i,d,g,S)=>{if(k.current.has(i)&&k.current.set(i,d),k.current.size===2&&T.current){l(!1);const[O,v]=Array.from(k.current.values()),Z=Math.hypot(O.x-v.x,O.y-v.y)/Math.max(1,T.current.distance),K={x:(O.x+v.x)/2,y:(O.y+v.y)/2},te=J(T.current.zoom*Z,ce,ue),A=te/T.current.zoom,oe=M({x:K.x-(T.current.midpoint.x-T.current.pan.x)*A,y:K.y-(T.current.midpoint.y-T.current.pan.y)*A},g,S);a(te),s(oe);return}const x=I.current;if(!x)return;l(!1);const U={x:x.panStart.x+(d.x-x.start.x),y:x.panStart.y+(d.y-x.start.y)};s(M(U,g,S))},[M,l]),D=t.useCallback(i=>{if(k.current.delete(i),k.current.size<2&&(T.current=null),k.current.size===1){const[d]=Array.from(k.current.values());I.current={start:d,panStart:m.current};return}k.current.size===0&&(I.current=null)},[]),X=t.useCallback((i,d,g,S)=>{l(!1);const x={x:m.current.x-i,y:m.current.y-d};s(M(x,g,S))},[M,l]),ee=t.useCallback((i,d,g,S)=>{const x=i<0?1.1:.9;l(!1),z(b.current*x,d,g,S)},[l,z]),L=t.useCallback(i=>{E.current=i},[]),le=t.useCallback((i,d,g,S,x)=>{if(rt(i.target))return;const U=i.metaKey||i.ctrlKey;if(i.key==="Escape"){i.preventDefault(),G();return}if(U){if(i.key==="="||i.key==="+"){i.preventDefault(),_(1.2,d,g);return}if(i.key==="-"){i.preventDefault(),_(1/1.2,d,g);return}if(i.key==="0"){i.preventDefault(),G();return}(i.key==="f"||i.key==="F")&&i.shiftKey&&(i.preventDefault(),j(S,d,g,x))}},[j,G,_]);return{pan:r,zoom:o,zoomPercent:h,transform:n,transitioning:f,zoomIn:W,zoomOut:$,resetView:G,fitToGraph:j,setAnimate:l,onPointerDown:u,onPointerMove:P,onPointerUp:D,onWheelPan:X,onWheelZoom:ee,handleKeyDown:le,setGraphBounds:L}}function st(r){const{upstreamMap:s,downstreamMap:o}=t.useMemo(()=>{const f=new Map,c=new Map;for(const m of r)f.set(m.id,new Set(m.dependencies??[])),c.has(m.id)||c.set(m.id,new Set);for(const m of r)for(const b of m.dependencies??[])c.has(b)||c.set(b,new Set),c.get(b)?.add(m.id);return{upstreamMap:f,downstreamMap:c}},[r]);return{getChain:t.useCallback(f=>{if(!s.has(f)&&!o.has(f))return new Set;const c=new Set([f]),m=(b,C)=>{const I=[b],k=new Set([b]);for(;I.length>0;){const T=I.shift();if(!T)continue;const E=C.get(T);if(E)for(const n of E)k.has(n)||(k.add(n),c.add(n),I.push(n))}};return m(f,s),m(f,o),c},[o,s])}}const ke="fusion-plugin-dependency-graph:positions";function fe(r){if(!r||typeof r!="object")return!1;const s=r;return typeof s.x=="number"&&Number.isFinite(s.x)&&typeof s.y=="number"&&Number.isFinite(s.y)}function it(r){const s=_e(ke,r);if(!s)return{};try{const o=JSON.parse(s);if(!o||typeof o!="object")return{};const a={};for(const[f,c]of Object.entries(o))fe(c)&&(a[f]=c);return a}catch{return{}}}function at(r,s,o){const a={};for(const[f,c]of Object.entries(r))s.has(f)&&fe(c)&&(a[f]=c);Xe(ke,JSON.stringify(a),o)}function ct(r){ve(ke,r)}function ut(r,s,o){const a={};for(const[f,c]of Object.entries(r))o.has(f)&&fe(c)&&(a[f]=c);for(const[f,c]of Object.entries(s))o.has(f)&&fe(c)&&(a[f]=c);return a}function lt(r,s){const o={};for(const[a,f]of Object.entries(r))s.has(a)&&(o[a]=f);return o}function dt({projectId:r,visibleTaskIds:s}){const[o,a]=t.useState(null);t.useEffect(()=>{a(it(r))},[r]);const f=t.useCallback(m=>{at(m,s,r),a(lt(m,s))},[r,s]),c=t.useCallback(()=>{ct(r),a(null)},[r]);return{savedPositions:o,persistPositions:f,clearSavedPositions:c}}const ae=280,Q=100,ft=768,Te=4;function pt({tasks:r,projectId:s,onOpenTaskDetail:o,onOpenDetail:a,addToast:f,globalPaused:c,onUpdateTask:m,onArchiveTask:b,onUnarchiveTask:C,onDeleteTask:I,onRetryTask:k,onOpenDetailWithTab:T,taskStuckTimeoutMs:E,onOpenMission:n,onMoveTask:h,lastFetchTimeMs:l,workflowStepNameLookup:M}){const z=t.useRef(null),_=t.useRef(!1),W=t.useRef(null),$=t.useRef(!1),G=t.useRef(new Map),[j,u]=t.useState(null),[P,D]=t.useState(null),[X,ee]=t.useState({width:0,height:0}),[L,le]=t.useState(new Map),i=t.useMemo(()=>Qe(r),[r]),d=tt(i),{getChain:g}=st(i),S=j??P,x=t.useMemo(()=>S?g(S):new Set,[S,g]),U=t.useMemo(()=>{const e=X.width||(typeof window<"u"?window.innerWidth:0);return(X.height||(typeof window<"u"?window.innerHeight:0))>e||e<ft?"horizontal":"vertical"},[X.height,X.width]),O=t.useMemo(()=>({nodeWidth:ae,nodeHeight:Q,horizontalGap:40,verticalGap:80,orientation:U,measuredHeights:L}),[L,U]),v=t.useMemo(()=>we(d,O),[d,O]),B=t.useMemo(()=>new Set(i.map(e=>e.id)),[i]),{savedPositions:Z,persistPositions:K,clearSavedPositions:te}=dt({projectId:s,visibleTaskIds:B}),[A,oe]=t.useState(v),[se,ne]=t.useState(!1);t.useEffect(()=>{const e={};for(const[y,H]of v.entries())e[y]=H;const p=Z?ut(e,Z,B):e;oe(new Map(Object.entries(p)))},[v,Z,B]),t.useEffect(()=>{const e=z.current;if(!e)return;const p=(H,Y)=>{ee(w=>w.width===H&&w.height===Y?w:{width:H,height:Y})};if(typeof ResizeObserver>"u"){p(e.clientWidth||(typeof window<"u"?window.innerWidth:0),e.clientHeight||(typeof window<"u"?window.innerHeight:0));return}p(e.clientWidth,e.clientHeight);const y=new ResizeObserver(H=>{const Y=H[0];Y&&p(Y.contentRect.width,Y.contentRect.height)});return y.observe(e),()=>y.disconnect()},[]),t.useEffect(()=>{const e=z.current;if(!e)return;const p=new Set(d.nodes.map(w=>w.task.id)),y=new Map;for(const w of p){const N=e.querySelector(`[data-testid="graph-task-node-${w}"]`);N&&y.set(w,N)}G.current=y,le(w=>{let N=!1;const F=new Map;for(const[re,ie]of w.entries()){if(!p.has(re)){N=!0;continue}F.set(re,ie)}return N?F:w});const H=(w,N)=>{le(F=>{const re=F.get(w);if(re!==void 0&&Math.abs(re-N)<1)return F;const ie=new Map(F);return ie.set(w,N),ie})};for(const[w,N]of y.entries())H(w,N.offsetHeight||Q);if(typeof ResizeObserver>"u")return;const Y=new ResizeObserver(w=>{for(const N of w){const F=N.target,re=Array.from(y.entries()).find(([,ie])=>ie===F)?.[0];re&&H(re,F.offsetHeight||Q)}});for(const w of y.values())Y.observe(w);return()=>Y.disconnect()},[d.nodes,A,X.height,X.width]);const{transform:pe,zoom:de,transitioning:q,zoomIn:he,zoomOut:Ce,resetView:De,fitToGraph:me,onPointerDown:Re,onPointerMove:Ie,onPointerUp:be,onWheelPan:ze,onWheelZoom:He,handleKeyDown:Ne,setGraphBounds:Me}=ot();t.useEffect(()=>{if(_.current||i.length===0)return;if(!!(Z&&Object.keys(Z).length>0)){_.current=!0;return}const p=z.current;p&&(me(A,p.clientWidth,p.clientHeight,{nodeWidth:ae,nodeHeight:Q,measuredHeights:L}),_.current=!0)},[i.length,me,L,A,Z]);const V=t.useMemo(()=>{const e=Array.from(A.values());if(e.length===0)return{minX:0,minY:0,maxX:0,maxY:0,width:0,height:0};const p=Math.min(...e.map(w=>w.x)),y=Math.min(...e.map(w=>w.y)),H=Math.max(...e.map(w=>w.x+ae)),Y=Math.max(...Array.from(A.entries()).map(([w,N])=>N.y+(L.get(w)??Q)));return{minX:p,minY:y,maxX:H,maxY:Y,width:Math.max(0,H-p),height:Math.max(0,Y-y)}},[L,A]),ge=t.useMemo(()=>{if(A.size===0)return A;const e=new Map;for(const[p,y]of A.entries())e.set(p,{x:y.x-V.minX,y:y.y-V.minY});return e},[V.minX,V.minY,A]);t.useEffect(()=>{Me({minX:0,minY:0,maxX:V.width,maxY:V.height})},[V.height,V.width,Me]);const Pe=t.useCallback(()=>{te();const e=we(d,O);oe(e)},[te,d,O]),Oe=t.useCallback(()=>{const e={};for(const[p,y]of A.entries())e[p]=y;K(e)},[K,A]);return R.jsxs("section",{className:"dependency-graph","data-testid":"dependency-graph",children:[R.jsx("div",{ref:z,className:"dependency-graph__viewport",onPointerDown:e=>{se||(W.current={x:e.clientX,y:e.clientY},$.current=!1,Re(e.pointerId,{x:e.clientX,y:e.clientY}))},onPointerMove:e=>{if(se)return;const p=z.current;if(!p)return;const y=W.current;if(y){const H=Math.abs(e.clientX-y.x),Y=Math.abs(e.clientY-y.y);(H>Te||Y>Te)&&($.current=!0)}Ie(e.pointerId,{x:e.clientX,y:e.clientY},p.clientWidth,p.clientHeight)},onPointerUp:e=>{se||be(e.pointerId),W.current=null},onPointerCancel:e=>{se||be(e.pointerId),W.current=null,$.current=!1},onWheel:e=>{e.preventDefault();const p=z.current;if(p){if(e.ctrlKey||e.metaKey){const y=p.getBoundingClientRect();He(e.deltaY,{x:e.clientX-y.left,y:e.clientY-y.top},p.clientWidth,p.clientHeight);return}ze(e.deltaX,e.deltaY,p.clientWidth,p.clientHeight)}},onKeyDown:e=>{const p=z.current;p&&Ne(e,p.clientWidth,p.clientHeight,ge,{nodeWidth:ae,nodeHeight:Q,measuredHeights:L})},tabIndex:0,onClick:()=>{$.current||se||D(null)},children:i.length===0?R.jsx("div",{className:"dependency-graph__empty",children:"No active tasks to display in graph view."}):R.jsxs("div",{className:`graph-canvas-transform${q?" graph-canvas-transform--animate":""}`,style:{transform:pe,width:`${V.width}px`,height:`${V.height}px`},children:[R.jsx(qe,{edges:d.edges,positions:ge,nodeWidth:ae,nodeHeight:Q,nodeHeights:L,highlightedEdgeIds:x.size>0?new Set(d.edges.filter(e=>x.has(e.source)&&x.has(e.target)).map(e=>`${e.source}->${e.target}`)):void 0}),R.jsx("div",{className:"dependency-graph__nodes-layer",children:d.nodes.map(e=>{const p=ge.get(e.task.id);return p?R.jsx(Be,{task:e.task,projectId:s,isSelected:P===e.task.id,style:{minHeight:`${Q}px`,left:`${p.x}px`,top:`${p.y}px`},position:p,scale:de,onNodePositionChange:(y,H)=>{oe(Y=>{const w={x:H.x+V.minX,y:H.y+V.minY},N=Y.get(y);if(N&&N.x===w.x&&N.y===w.y)return Y;const F=new Map(Y);return F.set(y,w),F})},onNodeDragStateChange:ne,onNodeDragEnd:Oe,isHighlighted:x.size>0&&x.has(e.task.id),isDimmed:x.size>0&&!x.has(e.task.id),onOpenDetail:a??(y=>o?.(y.id)),addToast:f??(()=>{}),globalPaused:c,onUpdateTask:m,onArchiveTask:b,onUnarchiveTask:C,onDeleteTask:I,onRetryTask:k,onOpenDetailWithTab:T,taskStuckTimeoutMs:E,onOpenMission:n,onMoveTask:h,lastFetchTimeMs:l,workflowStepNameLookup:M,onMouseEnter:()=>u(e.task.id),onMouseLeave:()=>u(null),onClick:y=>{y.stopPropagation(),$.current=!1,D(H=>H===e.task.id?null:e.task.id)}},e.task.id):null})})]})}),R.jsx(Ze,{zoom:de,onZoomIn:()=>{const e=z.current;e&&he(e.clientWidth,e.clientHeight)},onZoomOut:()=>{const e=z.current;e&&Ce(e.clientWidth,e.clientHeight)},onFitToGraph:()=>{Pe();const e=z.current;if(!e)return;const p=we(d,O),y=new Map,H=Array.from(p.values()),Y=H.length>0?Math.min(...H.map(N=>N.x)):0,w=H.length>0?Math.min(...H.map(N=>N.y)):0;for(const[N,F]of p.entries())y.set(N,{x:F.x-Y,y:F.y-w});me(y,e.clientWidth,e.clientHeight,{nodeWidth:ae,nodeHeight:Q,measuredHeights:L})},onResetView:()=>{Pe(),De()}})]})}function ht(r){return new Map((r??[]).map(s=>[s.id,s.name]))}function Pt({context:r}){return t.createElement(pt,{tasks:r?.tasks??[],projectId:r?.projectId,workflowStepNameLookup:ht(r?.workflowSteps),onOpenDetail:r?.openTaskDetail})}export{pt as DependencyGraph,Pt as DependencyGraphDashboardView,Pt as default};
@@ -1,4 +1,4 @@
1
- import{c as a}from"./index-CW4OzecJ.js";/**
1
+ import{c as a}from"./index-CgfrecpF.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.