@runfusion/fusion 0.4.1 → 1.0.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.
- package/dist/bin.js +34074 -34923
- package/dist/client/assets/{AgentDetailView-sy6Hg1Xr.js → AgentDetailView-dhJd4os0.js} +6 -11
- package/dist/client/assets/{AgentsView-DpEpW88a.js → AgentsView-CYVTv2_l.js} +3 -3
- package/dist/client/assets/{ChatView-BUt3C4cf.js → ChatView-ByPhfQZ6.js} +1 -1
- package/dist/client/assets/{DevServerView-BOyWtQJM.js → DevServerView-CD7mgC11.js} +1 -1
- package/dist/client/assets/{DirectoryPicker-BJyEEso5.js → DirectoryPicker-Cm0FCC9M.js} +1 -1
- package/dist/client/assets/{DocumentsView-Dx0M1YHw.js → DocumentsView-oB319uCj.js} +1 -1
- package/dist/client/assets/{InsightsView-BtXdAo7D.js → InsightsView-BHdMNnOa.js} +1 -1
- package/dist/client/assets/{MemoryView-kKPuqmwf.js → MemoryView-BDJMlzlM.js} +1 -1
- package/dist/client/assets/{NodesView-B_ZwUORz.js → NodesView-BfOlOj-Q.js} +1 -1
- package/dist/client/assets/{PiExtensionsManager-Db0EGr0Q.js → PiExtensionsManager-D-IznnkU.js} +2 -2
- package/dist/client/assets/{PluginManager-mOwWndfg.js → PluginManager-D40uAE-p.js} +1 -1
- package/dist/client/assets/{RoadmapsView-DbUzBLeF.js → RoadmapsView-DtgL8yl3.js} +1 -1
- package/dist/client/assets/{SettingsModal-TRJu_mTn.js → SettingsModal-0IyoaKEv.js} +1 -1
- package/dist/client/assets/SettingsModal-D1vZdAS4.js +31 -0
- package/dist/client/assets/{SetupWizardModal-D1bmCQrf.js → SetupWizardModal-BaQ8VkZm.js} +1 -1
- package/dist/client/assets/{SkillsView-Dzzpd5Md.js → SkillsView-DAvaRl37.js} +1 -1
- package/dist/client/assets/TodoView-BXRQSmSw.js +1 -0
- package/dist/client/assets/TodoView-DNi8blBB.css +1 -0
- package/dist/client/assets/{folder-open-BcuByk6U.js → folder-open-BJ4SvamV.js} +1 -1
- package/dist/client/assets/index-B7TDbn3p.css +1 -0
- package/dist/client/assets/index-CGW6tOaX.js +631 -0
- package/dist/client/assets/list-checks-CpGwz9gV.js +6 -0
- package/dist/client/assets/{upload-BzNbXYEj.js → upload-DJYyvab0.js} +1 -1
- package/dist/client/assets/{users-BvIqhSXp.js → users-ndAFpylb.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/client/version.json +1 -1
- package/dist/extension.js +3262 -599
- package/dist/pi-claude-cli/package.json +1 -1
- package/dist/pi-claude-cli/src/__tests__/process-manager.test.ts +50 -17
- package/dist/pi-claude-cli/src/__tests__/setup-test-isolation.test.ts +30 -0
- package/dist/pi-claude-cli/src/__tests__/setup-test-isolation.ts +6 -0
- package/package.json +5 -5
- package/skill/fusion/references/extension-tools.md +5 -5
- package/skill/fusion/references/fusion-capabilities.md +5 -5
- package/dist/client/assets/SettingsModal-Bs_lNs5B.js +0 -31
- package/dist/client/assets/index-BipedNj4.css +0 -1
- package/dist/client/assets/index-k2c4LrUr.js +0 -616
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,j as e}from"./vendor-react-K0fH_qHe.js";import{
|
|
1
|
+
import{r as l,j as e}from"./vendor-react-K0fH_qHe.js";import{bN as L,au as B,bO as E,bP as $,bQ as _,X as O,ad as W,D as G,C as b,L as Y}from"./index-CGW6tOaX.js";import{D as Z}from"./DirectoryPicker-Cm0FCC9M.js";import"./vendor-xterm-DzcZoU0P.js";import"./folder-open-BJ4SvamV.js";function f(c){const r=c.split(/[/\\]/).filter(h=>h.length>0);return(r[r.length-1]||"My Project").replace(/[^a-zA-Z0-9-_]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"My Project"}function K({onProjectRegistered:c,onClose:r}){const j="https://github.com/runfusion/fusion/discussions",[h,k]=l.useState(!0),[s,n]=l.useState({step:"manual",manualMode:"existing",manualPath:"",manualCloneUrl:"",manualName:"",manualIsolationMode:"in-process",manualNodeId:"",isRegistering:!1,error:null}),[x,C]=l.useState(!1),[u,g]=l.useState(""),[m,y]=l.useState(()=>L()),{nodes:N,loading:z}=B(),M=N.find(a=>a.type==="local")?.id,w=l.useCallback(()=>{k(!1),r?.()},[r]),I=l.useCallback(a=>{n(t=>{const d={manualPath:a};return a&&(!t.manualName||t.manualName===f(t.manualPath))&&(d.manualName=f(a)),{...t,...d}})},[]),P=l.useCallback(async()=>{const a=s.manualPath.trim(),t=s.manualName.trim(),d=s.manualCloneUrl.trim();if(!(!a||!t)&&!(s.manualMode==="clone"&&!d)){n(i=>({...i,isRegistering:!0,error:null}));try{const i={name:t,path:a,isolationMode:s.manualIsolationMode,nodeId:s.manualNodeId||void 0,cloneUrl:s.manualMode==="clone"?d:void 0},p=await E(i);c(p),n(D=>({...D,step:"complete",isRegistering:!1}))}catch(i){n(p=>({...p,isRegistering:!1,error:i instanceof Error?i.message:"Failed to register project"}))}}},[s.manualPath,s.manualName,s.manualCloneUrl,s.manualMode,s.manualIsolationMode,s.manualNodeId,c]),S=l.useCallback(()=>{const a=u.trim();a&&($(a),window.location.reload())},[u]),R=l.useCallback(()=>{_(),y(void 0),g(""),window.location.reload()},[]);if(!h)return null;const v=s.manualMode==="existing",o=s.manualMode==="clone",A=s.manualPath.trim().length>0,U=s.manualName.trim().length>0,F=s.manualCloneUrl.trim().length>0,T=s.isRegistering||!A||!U||o&&!F;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:[s.step==="manual"&&"Welcome to Fusion",s.step==="complete"&&"Setup Complete!"]})]}),s.step!=="complete"&&e.jsx("button",{className:"modal-close",onClick:w,"aria-label":"Close wizard",children:e.jsx(O,{size:20})})]}),e.jsxs("div",{className:"setup-wizard-content",children:[s.step==="manual"&&e.jsxs("div",{className:"setup-wizard-manual",children:[e.jsx("div",{className:"welcome-icon",children:e.jsx(W,{size:32})}),e.jsx("p",{className:"welcome-text",children:"Let's set up your first project. Register an existing directory or clone a git repository into a destination folder, then register it."}),e.jsxs("fieldset",{className:"setup-wizard-mode-switch","aria-label":"Project setup mode",children:[e.jsx("legend",{children:"Setup Mode"}),e.jsxs("label",{className:`setup-wizard-mode-option${v?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"setup-mode",value:"existing",checked:v,onChange:()=>n(a=>({...a,manualMode:"existing",error:null}))}),e.jsx("span",{children:"Use Existing Directory"})]}),e.jsxs("label",{className:`setup-wizard-mode-option${o?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"setup-mode",value:"clone",checked:o,onChange:()=>n(a=>({...a,manualMode:"clone",error:null}))}),e.jsx("span",{children:"Clone Git Repository"})]})]}),o&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-clone-url",children:"Repository URL"}),e.jsx("input",{id:"project-clone-url",type:"text",value:s.manualCloneUrl,onChange:a=>n(t=>({...t,manualCloneUrl:a.target.value})),placeholder:"https://github.com/owner/repo.git"}),e.jsx("p",{className:"form-hint",children:"Fusion will run git clone into the destination directory, then register that cloned folder."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-path",children:o?"Destination Directory":"Project Directory"}),e.jsx(Z,{value:s.manualPath,onChange:I,nodeId:s.manualNodeId||void 0,localNodeId:M,placeholder:o?"/path/for/new-clone":"/path/to/your/project"}),e.jsx("p",{className:"form-hint",children:o?"Select or type an absolute destination path. Fusion will clone into this directory.":"Select or type the absolute path to your project"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-name",children:"Project Name"}),e.jsx("input",{id:"project-name",type:"text",value:s.manualName,onChange:a=>n(t=>({...t,manualName:a.target.value})),placeholder:"my-project"}),e.jsx("p",{className:"form-hint",children:o?"By default this follows the destination folder name unless you edit it.":"By default this follows the selected directory name unless you edit it."})]}),e.jsxs("div",{className:"setup-wizard-advanced",children:[e.jsxs("button",{type:"button",className:"setup-wizard-advanced-toggle","aria-expanded":x,onClick:()=>C(a=>!a),children:[e.jsx(G,{size:16,className:"setup-wizard-advanced-chevron"}),e.jsx("span",{children:"Advanced settings"})]}),x&&e.jsxs("div",{className:"setup-wizard-advanced-panel",children:[e.jsx("div",{className:"form-group",children:e.jsxs("div",{className:"project-node-selector",children:[e.jsx("span",{className:"project-node-selector__label",children:"Runtime Node"}),e.jsxs("select",{value:s.manualNodeId,onChange:a=>n(t=>({...t,manualNodeId:a.target.value})),disabled:z||s.isRegistering,children:[e.jsx("option",{value:"",children:"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:"Isolation Mode"}),e.jsxs("div",{className:"setup-wizard-isolation-options",children:[e.jsxs("label",{className:`setup-wizard-isolation-option${s.manualIsolationMode==="in-process"?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"isolation-mode",value:"in-process",checked:s.manualIsolationMode==="in-process",onChange:()=>n(a=>({...a,manualIsolationMode:"in-process"}))}),e.jsxs("div",{className:"setup-wizard-isolation-option-content",children:[e.jsx("strong",{children:"In-Process"}),e.jsx("span",{children:"Lower overhead, shared memory. Best for most projects."}),e.jsx("span",{className:"wizard-option-recommended",children:"Recommended"})]})]}),e.jsxs("label",{className:`setup-wizard-isolation-option${s.manualIsolationMode==="child-process"?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"isolation-mode",value:"child-process",checked:s.manualIsolationMode==="child-process",onChange:()=>n(a=>({...a,manualIsolationMode:"child-process"}))}),e.jsxs("div",{className:"setup-wizard-isolation-option-content",children:[e.jsx("strong",{children:"Child-Process"}),e.jsx("span",{children:"Isolated execution with crash containment."})]})]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"setup-auth-token",children:"Browser Auth Token"}),e.jsxs("div",{className:"setup-wizard-auth-token",children:[e.jsx("input",{id:"setup-auth-token",type:"password",value:u,onChange:a=>g(a.target.value),placeholder:m?"Enter a new token to replace the stored one":"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:S,disabled:u.trim().length===0,children:m?"Update token":"Set token"}),m&&e.jsx("button",{type:"button",className:"btn",onClick:R,children:"Reset token"})]})]}),e.jsx("p",{className:"form-hint",children:m?"A token is already stored in this browser. Updating or resetting it will reload the page.":"Store a token in this browser for authenticated dashboard requests, then reload the page."})]})]})]}),s.error&&e.jsx("div",{className:"wizard-error",role:"alert",children:s.error})]}),s.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(b,{size:64,className:"success-icon"}),e.jsx("h3",{children:"All Set!"}),e.jsx("p",{children:"Your project has been registered successfully."}),e.jsx("p",{children:"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:j,target:"_blank",rel:"noreferrer",children:"Need help?"}),s.step==="manual"&&e.jsx("button",{className:"btn btn-primary",onClick:P,disabled:T,children:s.isRegistering?e.jsxs(e.Fragment,{children:[e.jsx(Y,{size:16,className:"animate-spin"}),e.jsx("span",{children:"Registering..."})]}):e.jsx("span",{children:"Register Project"})}),s.step==="complete"&&e.jsxs("button",{className:"btn btn-primary",onClick:w,children:[e.jsx(b,{size:16}),e.jsx("span",{children:"Get Started"})]})]})]})})}export{K as SetupWizardModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,j as e}from"./vendor-react-K0fH_qHe.js";import{f as _,b5 as q,b6 as B,b7 as G,aM as H,X as P,R as J,K as O,D as Y,L as Z,ae as I}from"./index-
|
|
1
|
+
import{r as i,j as e}from"./vendor-react-K0fH_qHe.js";import{f as _,b5 as q,b6 as B,b7 as G,aM as H,X as P,R as J,K as O,D as Y,L as Z,ae as I}from"./index-CGW6tOaX.js";import"./vendor-xterm-DzcZoU0P.js";function ie({projectId:c,addToast:o,onClose:Q}){const[d,v]=i.useState([]),[f,y]=i.useState(!0),[K,E]=i.useState(!1),[L,p]=i.useState(null),[D,A]=i.useState([]),[h,M]=i.useState(""),[m,g]=i.useState(null),[k,x]=i.useState(null),[V,R]=i.useState(!1),[z,j]=i.useState(null),r=i.useRef(null),[N,W]=i.useState(""),F=h.trim()?d.filter(s=>s.name.toLowerCase().includes(h.toLowerCase())||s.relativePath.toLowerCase().includes(h.toLowerCase())):d,C=i.useCallback(async()=>{y(!0);try{const s=await _(c);v(s)}catch(s){const a=s instanceof Error?s.message:"Failed to load discovered skills";o(a,"error")}finally{y(!1)}},[c,o]),u=i.useCallback(async s=>{const a=l=>{if(!l||typeof l!="object")return!1;const t=l;if(typeof t.status=="number"&&t.status>=500)return!0;if(t.details&&typeof t.details=="object"){const w=t.details;if(typeof w.code=="string"&&w.code.startsWith("upstream_"))return!0}const n=l;return typeof n.error=="string"&&typeof n.code=="string"};E(!0),p(null);try{const l=await q(s,20,c);A(l.entries)}catch(l){if(a(l))p("Catalog is temporarily unavailable. Please try again later.");else{const t=l instanceof Error?l.message:"Failed to load catalog";p(t)}}finally{E(!1)}},[c]);i.useEffect(()=>{C(),u("")},[C,u]);const T=i.useCallback(s=>{M(s),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{W(s),r.current=null},300)},[]);i.useEffect(()=>()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]),i.useEffect(()=>{u(N)},[N,u]);const U=i.useCallback(async(s,a)=>{const l=!a;v(t=>t.map(n=>n.id===s?{...n,toggling:!0}:n));try{await B(s,l,c),v(t=>t.map(n=>n.id===s?{...n,enabled:l,toggling:!1}:n)),o(`Skill ${l?"enabled":"disabled"}`,"success")}catch(t){v(w=>w.map(S=>S.id===s?{...S,toggling:!1}:S));const n=t instanceof Error?t.message:"Failed to toggle skill";o(`Failed to toggle skill: ${n}`,"error")}},[c,o]),b=i.useCallback(async s=>{R(!0),j(null),x(null);try{const a=await G(s,c);x(a)}catch(a){const l=a instanceof Error?a.message:"Failed to load skill content";j(l)}finally{R(!1)}},[c]),$=i.useCallback((s,a)=>{if(!(a&&a.target.closest(".skills-view-item-toggle"))){if(m===s){g(null),x(null),j(null);return}g(s),b(s)}},[m,b]),X=i.useCallback(s=>{m!==s&&g(s),b(s)},[b,m]);return e.jsxs("div",{className:"skills-view","data-testid":"skills-view",children:[e.jsxs("div",{className:"skills-view-header",children:[e.jsxs("div",{className:"skills-view-title",children:[e.jsxs("h2",{children:[e.jsx(H,{size:20}),"Skills"]}),e.jsxs("span",{className:"skills-view-count","aria-label":`${d.length} discovered skills`,children:[d.length," discovered"]})]}),e.jsxs("div",{className:"skills-view-actions",children:[e.jsx("button",{className:"btn-icon skills-view-close touch-target",onClick:Q,"aria-label":"Close skills view",children:e.jsx(P,{size:16})}),e.jsxs("button",{className:"btn btn-sm touch-target",onClick:()=>void C(),disabled:f,children:[e.jsx(J,{size:14,className:f?"spin":""}),"Refresh"]})]})]}),e.jsxs("div",{className:"skills-view-content",children:[e.jsx("div",{className:"skills-view-search",children:e.jsx("input",{type:"text",className:"form-input",placeholder:"Search skills...",value:h,onChange:s=>T(s.target.value),"aria-label":"Search skills"})}),e.jsxs("section",{className:"skills-view-section","aria-labelledby":"discovered-skills-title",children:[e.jsx("h3",{id:"discovered-skills-title",className:"skills-view-section-title",children:"Discovered Skills"}),f?e.jsxs("div",{className:"skills-view-loading",children:[e.jsx("span",{className:"spinner"}),"Loading discovered skills..."]}):d.length===0?e.jsx("div",{className:"skills-view-empty",children:e.jsx("p",{children:"No skills discovered in this project."})}):F.length===0?e.jsx("div",{className:"skills-view-empty",children:e.jsx("p",{children:"No discovered skills match your search."})}):e.jsx("div",{className:"skills-view-list",children:F.map(s=>{const a=m===s.id;return e.jsxs("div",{children:[e.jsxs("div",{className:`skills-view-item${a?" skills-view-item--selected":""}`,onClick:l=>$(s.id,l),role:"button",tabIndex:0,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),$(s.id))},"aria-expanded":a,"aria-label":`View details for ${s.name}`,children:[e.jsxs("div",{className:"skills-view-item-info",children:[e.jsxs("span",{className:"skills-view-item-name",children:[a?e.jsx(O,{size:14}):e.jsx(Y,{size:14}),s.name]}),e.jsx("span",{className:"skills-view-item-path",children:s.relativePath}),e.jsx("span",{className:"skills-view-item-source",children:s.metadata.source})]}),e.jsxs("label",{className:"skills-view-item-toggle",onClick:l=>l.stopPropagation(),children:[e.jsx("input",{type:"checkbox",checked:s.enabled,disabled:s.toggling,onChange:()=>void U(s.id,s.enabled),"aria-label":`${s.enabled?"Disable":"Enable"} ${s.name}`}),e.jsx("span",{className:"skills-view-toggle-slider"})]})]}),a&&e.jsxs("div",{className:"skills-view-detail","data-testid":"skill-detail",children:[e.jsxs("div",{className:"skills-view-detail-header",children:[e.jsx("span",{className:"skills-view-detail-title",children:s.name}),e.jsxs("button",{className:"btn btn-sm skills-view-detail-close",onClick:()=>{g(null),x(null),j(null)},"aria-label":"Close skill detail",children:[e.jsx(P,{size:14}),"Close"]})]}),V?e.jsxs("div",{className:"skills-view-detail-loading",children:[e.jsx(Z,{size:16,className:"spin"}),"Loading skill content..."]}):z?e.jsxs("div",{className:"skills-view-detail-error",children:[e.jsx(I,{size:14}),e.jsx("span",{children:z}),e.jsx("button",{className:"btn btn-sm",onClick:()=>X(s.id),children:"Retry"})]}):k?e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"skills-view-detail-content",children:k.skillMd||"(No SKILL.md found)"}),k.files.length>0&&e.jsxs("div",{className:"skills-view-detail-files",children:[e.jsx("span",{className:"skills-view-detail-files-label",children:"Files:"}),k.files.map(l=>e.jsxs("span",{className:"badge badge--sm",children:[l.name,l.type==="directory"&&"/"]},l.relativePath))]})]}):null]})]},s.id)})})]}),e.jsxs("section",{className:"skills-view-section","aria-labelledby":"catalog-title",children:[e.jsx("h3",{id:"catalog-title",className:"skills-view-section-title",children:"Skills Catalog"}),L?e.jsxs("div",{className:"skills-view-error",children:[e.jsx("p",{children:L}),e.jsx("button",{className:"btn btn-sm",onClick:()=>void u(N),children:"Try Again"})]}):K?e.jsxs("div",{className:"skills-view-loading",children:[e.jsx("span",{className:"spinner"}),"Loading catalog..."]}):D.length===0?e.jsx("div",{className:"skills-view-empty",children:h?e.jsx("p",{children:"No skills match your search."}):e.jsx("p",{children:"No skills available in the catalog."})}):e.jsx("div",{className:"skills-view-grid",children:D.map(s=>e.jsxs("div",{className:"skills-view-card",children:[e.jsx("h4",{className:"skills-view-card-title",children:s.name}),s.description&&e.jsx("p",{className:"skills-view-card-description",children:s.description}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"skills-view-card-tags",children:s.tags.map(a=>e.jsx("span",{className:"badge badge--sm",children:a},a))}),s.installs!==void 0&&e.jsxs("span",{className:"skills-view-card-installs",children:[s.installs.toLocaleString()," installs"]})]},s.id))})]})]})]})}export{ie as SkillsView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as u,j as t}from"./vendor-react-K0fH_qHe.js";import{bF as nt,bG as it,bH as ot,bI as at,bJ as dt,bK as rt,bL as ct,bM as lt,L as mt,w as ut,b2 as H,X as J,as as W,I as Y,a7 as bt,K as pt}from"./index-CGW6tOaX.js";import{L as Z}from"./list-checks-CpGwz9gV.js";import"./vendor-xterm-DzcZoU0P.js";function ht(N){const{items:b,...p}=N;return p}function tt(N){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${N}-${crypto.randomUUID()}`:`${N}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function xt(N={}){const{projectId:b,addToast:p}=N,[w,y]=u.useState([]),[g,x]=u.useState([]),[M,O]=u.useState(!0),[U,j]=u.useState(null),[k,S]=u.useState(null),[v,h]=u.useState([]),C=u.useRef(k);C.current=k,u.useEffect(()=>{let s=!1;async function a(){O(!0),j(null);try{const c=await lt(b);if(s)return;h(c),y(c.map(ht));const r=C.current&&c.some(d=>d.id===C.current)?C.current:c[0]?.id??null;S(r),x(r?c.find(d=>d.id===r)?.items??[]:[])}catch(c){if(s)return;h([]),y([]),x([]),S(null),j(c instanceof Error?c.message:"Failed to load todo lists")}finally{s||O(!1)}}return a(),()=>{s=!0}},[b]),u.useEffect(()=>{if(!k){x([]);return}const s=v.find(a=>a.id===k);x(s?.items??[])},[v,k]);const z=u.useCallback(async s=>{const a=w,c=v,r=new Date().toISOString(),d={id:tt("temp-list"),projectId:b??"",title:s,createdAt:r,updatedAt:r};j(null),y(n=>[...n,d]),h(n=>[...n,{...d,items:[]}]);try{const n=await nt(s,b);y(o=>o.map(i=>i.id===d.id?n:i)),h(o=>o.map(i=>i.id===d.id?{...n,items:[]}:i)),C.current||S(n.id)}catch(n){y(a),h(c),j(n instanceof Error?n.message:"Failed to create list"),p?.("Failed to create todo list","error")}},[p,v,w,b]),D=u.useCallback(async(s,a)=>{const c=w,r=v;j(null),y(d=>d.map(n=>n.id===s?{...n,title:a}:n)),h(d=>d.map(n=>n.id===s?{...n,title:a}:n));try{const d=await it(s,a,b);y(n=>n.map(o=>o.id===s?d:o)),h(n=>n.map(o=>o.id===s?{...d,items:o.items}:o))}catch(d){y(c),h(r),j(d instanceof Error?d.message:"Failed to rename list"),p?.("Failed to rename todo list","error")}},[p,v,w,b]),R=u.useCallback(async s=>{const a=w,c=v,r=C.current,d=r===s?w.find(n=>n.id!==s)?.id??null:r;j(null),y(n=>n.filter(o=>o.id!==s)),h(n=>n.filter(o=>o.id!==s)),r===s&&S(d);try{await ot(s,b)}catch(n){y(a),h(c),S(r),j(n instanceof Error?n.message:"Failed to delete list"),p?.("Failed to delete todo list","error")}},[p,v,w,b]),T=u.useCallback(async s=>{const a=C.current;if(!a)return;const c=g,r=v,d=new Date().toISOString(),n=g.reduce((i,l)=>Math.max(i,l.sortOrder),-1),o={id:tt("temp-item"),listId:a,text:s,completed:!1,completedAt:null,createdAt:d,updatedAt:d,sortOrder:n+1};j(null),x(i=>[...i,o]),h(i=>i.map(l=>l.id===a?{...l,items:[...l.items,o]}:l));try{const i=await at(a,s,b);x(l=>l.map(f=>f.id===o.id?i:f)),h(l=>l.map(f=>f.id===a?{...f,items:f.items.map(E=>E.id===o.id?i:E)}:f))}catch(i){x(c),h(r),j(i instanceof Error?i.message:"Failed to create item"),p?.("Failed to create todo item","error")}},[p,g,v,b]),A=u.useCallback(async(s,a)=>{const c=g.find(i=>i.id===s);if(!c)return;const r=g,d=v,n=a.completed??c.completed,o={...c,...a,completed:n,completedAt:n?c.completedAt??new Date().toISOString():null,updatedAt:new Date().toISOString()};j(null),x(i=>i.map(l=>l.id===s?o:l)),h(i=>i.map(l=>l.id===o.listId?{...l,items:l.items.map(f=>f.id===s?o:f)}:l));try{const i=await dt(s,a,b);x(l=>l.map(f=>f.id===s?i:f)),h(l=>l.map(f=>f.id===i.listId?{...f,items:f.items.map(E=>E.id===s?i:E)}:f))}catch(i){x(r),h(d),j(i instanceof Error?i.message:"Failed to update item"),p?.("Failed to update todo item","error")}},[p,g,v,b]),F=u.useCallback(async s=>{const a=g.find(c=>c.id===s);a&&await A(s,{completed:!a.completed})},[g,A]),K=u.useCallback(async s=>{const a=g,c=v;j(null),x(r=>r.filter(d=>d.id!==s)),h(r=>r.map(d=>({...d,items:d.items.filter(n=>n.id!==s)})));try{await rt(s,b)}catch(r){x(a),h(c),j(r instanceof Error?r.message:"Failed to delete item"),p?.("Failed to delete todo item","error")}},[p,g,v,b]),$=u.useCallback(async s=>{const a=C.current;if(!a)return;const c=g,r=v,d=new Map(g.map(o=>[o.id,o])),n=s.map((o,i)=>{const l=d.get(o);return l?{...l,sortOrder:i}:null}).filter(o=>o!==null);j(null),x(n),h(o=>o.map(i=>i.id===a?{...i,items:n}:i));try{await ct(a,s,b)}catch(o){x(c),h(r),j(o instanceof Error?o.message:"Failed to reorder items"),p?.("Failed to reorder todo items","error")}},[p,g,v,b]);return{lists:w,items:g,loading:M,error:U,selectedListId:k,setSelectedListId:S,createList:z,renameList:D,deleteList:R,createItem:T,updateItem:A,toggleItem:F,deleteItem:K,reorderItems:$}}function ft(N){return[...N].sort((b,p)=>b.sortOrder-p.sortOrder)}function yt({projectId:N,addToast:b}){const{lists:p,items:w,loading:y,error:g,selectedListId:x,setSelectedListId:M,createList:O,renameList:U,deleteList:j,createItem:k,updateItem:S,toggleItem:v,deleteItem:h,reorderItems:C}=xt({projectId:N,addToast:(e,I)=>{if(I==="success"||I==="error"||I==="info"||I===void 0){b(e,I);return}b(e,"info")}}),[z,D]=u.useState(null),[R,T]=u.useState(""),[A,F]=u.useState(null),[K,$]=u.useState(""),[s,a]=u.useState(""),[c,r]=u.useState(!1),[d,n]=u.useState(""),o=u.useMemo(()=>p.find(e=>e.id===x)??null,[p,x]),i=u.useMemo(()=>ft(w.filter(e=>e.listId===x)),[w,x]);function l(e){D(e.id),T(e.title),r(!1)}async function f(){if(!z)return;const e=R.trim();if(!e){D(null),T("");return}await U(z,e),D(null),T("")}function E(){D(null),T("")}function V(e){F(e.id),$(e.text)}async function X(){if(!A)return;const e=K.trim();if(!e){F(null),$("");return}await S(A,{text:e}),F(null),$("")}function _(){F(null),$("")}async function q(){const e=s.trim();e&&(await O(e),a(""),r(!1))}async function B(){if(!x)return;const e=d.trim();e&&(await k(e),n(""))}async function et(e){window.confirm("Delete this list and all its items?")&&await j(e)}async function st(e){await h(e)}async function Q(e,I){const L=i.map(G=>G.id),m=L.findIndex(G=>G===e);if(m<0)return;const P=I==="up"?m-1:m+1;P<0||P>=L.length||([L[m],L[P]]=[L[P],L[m]],await C(L))}return y?t.jsx("div",{className:"todo-view",children:t.jsxs("div",{className:"todo-loading",children:[t.jsx(mt,{className:"todo-loading-icon","aria-hidden":"true"}),t.jsx("p",{children:"Loading todos..."})]})}):t.jsxs("div",{className:"todo-view",children:[t.jsx("div",{className:"todo-view-header",children:t.jsxs("div",{children:[t.jsx("h2",{children:"Todos"}),t.jsx("p",{className:"todo-view-description",children:"Manage reusable todo lists for your project."})]})}),t.jsxs("div",{className:"todo-view-layout",children:[t.jsxs("aside",{className:"todo-view-sidebar","aria-label":"Todo lists sidebar",children:[t.jsxs("div",{className:"todo-sidebar-header",children:[t.jsx("h3",{className:"todo-sidebar-title",children:"Lists"}),t.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-add-list-btn",onClick:()=>{r(!0),D(null)},"aria-label":"Add list","data-testid":"add-list-button",children:t.jsx(ut,{size:14})})]}),c&&t.jsxs("div",{className:"todo-list-item",children:[t.jsx("input",{className:"input todo-inline-edit-input",placeholder:"New list title",value:s,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key==="Enter"&&q(),e.key==="Escape"&&(a(""),r(!1))},autoFocus:!0,"data-testid":"new-list-input"}),t.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{q()},"aria-label":"Save list",children:t.jsx(H,{size:14})}),t.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{a(""),r(!1)},"aria-label":"Cancel list",children:t.jsx(J,{size:14})})]}),p.length===0?t.jsxs("div",{className:"todo-empty-state",children:[t.jsx(Z,{"aria-hidden":"true"}),t.jsx("p",{children:"No todo lists yet. Create one to get started."}),t.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>r(!0),children:"Create List"})]}):t.jsx("div",{className:"todo-list-items",children:p.map(e=>{const I=e.id===x,L=e.id===z;return t.jsx("div",{className:`todo-list-item${I?" todo-list-item--active":""}`,onClick:()=>M(e.id),role:"button",tabIndex:0,onKeyDown:m=>{m.key==="Enter"&&M(e.id)},"data-testid":`todo-list-${e.id}`,children:L?t.jsxs(t.Fragment,{children:[t.jsx("input",{className:"input todo-inline-edit-input",value:R,onChange:m=>T(m.target.value),onKeyDown:m=>{m.key==="Enter"&&f(),m.key==="Escape"&&E()},autoFocus:!0,onClick:m=>m.stopPropagation(),"data-testid":`rename-list-input-${e.id}`}),t.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:m=>{m.stopPropagation(),f()},"aria-label":"Save list rename",children:t.jsx(H,{size:14})}),t.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:m=>{m.stopPropagation(),E()},"aria-label":"Cancel list rename",children:t.jsx(J,{size:14})})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"todo-list-item-name",children:e.title}),t.jsxs("div",{className:"todo-list-item-actions",children:[t.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:m=>{m.stopPropagation(),l(e)},"aria-label":`Rename ${e.title}`,"data-testid":`rename-list-button-${e.id}`,children:t.jsx(W,{size:14})}),t.jsx("button",{type:"button",className:"btn btn-sm btn-icon btn-danger todo-icon-btn",onClick:m=>{m.stopPropagation(),et(e.id)},"aria-label":`Delete ${e.title}`,"data-testid":`delete-list-button-${e.id}`,children:t.jsx(Y,{size:14})})]})]})},e.id)})})]}),t.jsxs("section",{className:"todo-view-main","aria-label":"Todo items",children:[g&&t.jsxs("div",{className:"todo-error-banner",role:"alert",children:[t.jsx("span",{className:"todo-error-message",children:g}),t.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>window.location.reload(),children:"Retry"})]}),o?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"todo-items-header",children:t.jsx("h3",{children:o.title})}),t.jsxs("div",{className:"todo-add-item-row",children:[t.jsx("input",{className:"input",placeholder:"Add a todo item",value:d,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key==="Enter"&&B()},"data-testid":"new-item-input"}),t.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>{B()},children:"Add"})]}),i.length===0?t.jsx("div",{className:"todo-empty-state",children:t.jsx("p",{children:"No items in this list. Add one above."})}):t.jsx("div",{className:"todo-items-list",children:i.map((e,I)=>{const L=e.id===A;return t.jsxs("div",{className:"todo-item","data-testid":`todo-item-${e.id}`,children:[t.jsx("input",{type:"checkbox",checked:e.completed,onChange:()=>{v(e.id)},className:"todo-item-checkbox","aria-label":`Toggle ${e.text}`,"data-testid":`toggle-item-${e.id}`}),L?t.jsx("input",{className:"input todo-inline-edit-input",value:K,onChange:m=>$(m.target.value),onKeyDown:m=>{m.key==="Enter"&&X(),m.key==="Escape"&&_()},autoFocus:!0,"data-testid":`edit-item-input-${e.id}`}):t.jsx("button",{type:"button",className:`todo-item-text${e.completed?" todo-item-text--completed":""}`,onClick:()=>V(e),children:e.text}),t.jsx("div",{className:"todo-item-actions",children:L?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{X()},"aria-label":"Save item edit",children:t.jsx(H,{size:14})}),t.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:_,"aria-label":"Cancel item edit",children:t.jsx(J,{size:14})})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"todo-item-reorder-btns",children:[t.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-item-reorder-btn",onClick:()=>{Q(e.id,"up")},disabled:I===0,"aria-label":`Move ${e.text} up`,"data-testid":`move-up-${e.id}`,children:t.jsx(bt,{size:14})}),t.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-item-reorder-btn",onClick:()=>{Q(e.id,"down")},disabled:I===i.length-1,"aria-label":`Move ${e.text} down`,"data-testid":`move-down-${e.id}`,children:t.jsx(pt,{size:14})})]}),t.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>V(e),"aria-label":`Edit ${e.text}`,"data-testid":`edit-item-${e.id}`,children:t.jsx(W,{size:14})}),t.jsx("button",{type:"button",className:"btn btn-sm btn-icon btn-danger todo-icon-btn",onClick:()=>{st(e.id)},"aria-label":`Delete ${e.text}`,"data-testid":`delete-item-${e.id}`,children:t.jsx(Y,{size:14})})]})})]},e.id)})})]}):t.jsxs("div",{className:"todo-empty-state",children:[t.jsx(Z,{"aria-hidden":"true"}),t.jsx("p",{children:"Select a list from the sidebar"})]})]})]})]})}export{yt as TodoView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.todo-view{display:flex;flex-direction:column;height:100%;padding:var(--space-lg);overflow:hidden}.todo-view-header{display:flex;flex-direction:row;justify-content:space-between;align-items:flex-start;margin-bottom:var(--space-lg);gap:var(--space-md)}.todo-view-header h2{font-size:calc(var(--space-lg) + (var(--space-xs) / 2));color:var(--text);margin:0}.todo-view-description{color:var(--text-muted);font-size:calc(var(--space-md) + (var(--space-xs) / 4));margin:var(--space-xs) 0 0 0}.todo-view-layout{display:flex;flex-direction:row;flex:1;overflow:hidden;gap:var(--space-lg)}.todo-view-sidebar{width:calc(var(--space-2xl) * 7 + var(--space-sm));border-right:calc(var(--space-xs) / 4) solid var(--border);padding-right:var(--space-lg);overflow-y:auto;flex-shrink:0}.todo-view-main{flex:1;overflow-y:auto;display:flex;flex-direction:column;min-width:0}.todo-sidebar-header{display:flex;flex-direction:row;justify-content:space-between;align-items:center;margin-bottom:var(--space-md)}.todo-sidebar-title{font-size:calc(var(--space-md) + (var(--space-xs) / 4));color:var(--text-muted);text-transform:uppercase;letter-spacing:calc(var(--space-xs) / 8);margin:0}.todo-add-list-btn{min-height:calc(var(--space-2xl) + var(--space-xs));min-width:calc(var(--space-2xl) + var(--space-xs))}.todo-list-items{display:flex;flex-direction:column;gap:var(--space-xs)}.todo-list-item{display:flex;flex-direction:row;align-items:center;padding:var(--space-sm) var(--space-md);border-radius:var(--radius-sm);cursor:pointer;gap:var(--space-sm);color:var(--text-muted);transition:background var(--transition-fast),color var(--transition-fast)}.todo-list-item:hover{background:var(--card-hover);color:var(--text)}.todo-list-item:focus-visible{outline:none;box-shadow:var(--focus-ring)}.todo-list-item--active{background:var(--surface);color:var(--text);font-weight:500}.todo-list-item-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:calc(var(--space-md) + (var(--space-xs) / 4))}.todo-list-item-actions{display:flex;flex-direction:row;gap:var(--space-xs);opacity:0;transition:opacity var(--transition-fast)}.todo-list-item:hover .todo-list-item-actions,.todo-list-item:focus-within .todo-list-item-actions,.todo-list-item--active .todo-list-item-actions{opacity:1}.todo-icon-btn{min-height:calc(var(--space-lg) + var(--space-sm));min-width:calc(var(--space-lg) + var(--space-sm))}.todo-inline-edit-input{flex:1;font-size:calc(var(--space-md) + (var(--space-xs) / 4))}.todo-items-header{display:flex;flex-direction:row;justify-content:space-between;align-items:center;margin-bottom:var(--space-md);gap:var(--space-sm)}.todo-items-header h3{margin:0;font-size:calc(var(--space-md) + (var(--space-xs) / 2));font-weight:500;color:var(--text)}.todo-add-item-row{display:flex;flex-direction:row;gap:var(--space-sm);margin-bottom:var(--space-lg)}.todo-add-item-row .input{flex:1}.todo-items-list{display:flex;flex-direction:column}.todo-item{display:flex;flex-direction:row;align-items:center;padding:var(--space-sm) var(--space-md);border-radius:var(--radius-sm);gap:var(--space-sm);border-bottom:calc(var(--space-xs) / 4) solid var(--border);transition:background var(--transition-fast)}.todo-item:hover{background:var(--card-hover)}.todo-item-checkbox{margin:0;width:var(--space-md);height:var(--space-md);accent-color:var(--todo);cursor:pointer}.todo-item-text{flex:1;font-size:calc(var(--space-md) + (var(--space-xs) / 4));color:var(--text);cursor:pointer;word-break:break-word;background:none;border:0;padding:0;text-align:left}.todo-item-text--completed{text-decoration:line-through;color:var(--text-muted)}.todo-item-actions{display:flex;flex-direction:row;gap:var(--space-xs);opacity:0;transition:opacity var(--transition-fast)}.todo-item:hover .todo-item-actions,.todo-item:focus-within .todo-item-actions{opacity:1}.todo-item-reorder-btns{display:flex;flex-direction:row;gap:0}.todo-item-reorder-btn{min-height:var(--space-xl);min-width:var(--space-xl)}.todo-error-banner{border:calc(var(--space-xs) / 4) solid color-mix(in srgb,var(--color-error) 35%,transparent);background:color-mix(in srgb,var(--color-error) 10%,transparent);color:var(--color-error);border-radius:var(--radius-md);padding:var(--space-md);margin-bottom:var(--space-md);display:flex;align-items:center;justify-content:space-between;gap:var(--space-sm)}.todo-error-message{font-size:calc(var(--space-md) + (var(--space-xs) / 4))}.todo-empty-state,.todo-loading{color:var(--text-muted);padding:var(--space-2xl);text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-sm);flex:1}.todo-loading-icon{animation:spin calc(var(--transition-slow) * 4) linear infinite}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@media(max-width:768px){.todo-view{padding:var(--space-md)}.todo-view-layout{flex-direction:column}.todo-view-sidebar{width:100%;border-right:none;border-bottom:calc(var(--space-xs) / 4) solid var(--border);padding-right:0;padding-bottom:var(--space-md);max-height:calc(var(--space-2xl) * 6 + var(--space-sm))}.todo-view-main{width:100%}.todo-list-item,.todo-add-list-btn,.todo-icon-btn,.todo-item,.todo-item-reorder-btn,.todo-add-item-row .btn{min-height:calc(var(--space-2xl) + var(--space-xs))}.todo-add-item-row{flex-wrap:wrap}.todo-add-item-row .btn{width:100%}}
|