coder-config 0.41.14 → 0.41.15
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/lib/constants.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coder-config",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.15",
|
|
4
4
|
"description": "Configuration manager for AI coding tools - Claude Code, Gemini CLI, Codex CLI, Antigravity. Manage MCPs, rules, permissions, memory, and workstreams.",
|
|
5
5
|
"author": "regression.io",
|
|
6
6
|
"main": "config-loader.js",
|
|
@@ -2867,7 +2867,7 @@ When reporting issues, include:
|
|
|
2867
2867
|
|
|
2868
2868
|
These projects are frequently worked on together.`),f(!0)},_e=ee=>{A(Ae=>Ae.filter(se=>se!==ee))},Oe=ee=>{P.includes(ee)||A(Ae=>[...Ae,ee])},Ve=async ee=>{const Ae=$[ee];if(!Ae&&!Y[ee]){G(se=>({...se,[ee]:!0}));try{const se=await ve.getSubprojects(ee);z(Pe=>({...Pe,[ee]:se.subprojects||[]}))}catch(se){console.error("Failed to load subprojects:",se),z(Pe=>({...Pe,[ee]:[]}))}finally{G(se=>({...se,[ee]:!1}))}}H(se=>({...se,[ee]:!Ae}))},ne=ee=>{const Ae=ee.projects.sort().join("|"),se=[...W,Ae];ce(se),localStorage.setItem("dismissedWorkstreamSuggestions",JSON.stringify(se)),he(Pe=>Pe.filter(Xe=>Xe.projects.sort().join("|")!==Ae)),J.success("Suggestion dismissed")},de=ae.filter(ee=>{const Ae=ee.projects.sort().join("|");return!W.includes(Ae)}),je=async()=>{if(confirm("Clear activity data older than 30 days?"))try{const ee=await ve.clearActivity(30);ee.success&&(J.success(`Cleared ${ee.cleared} old entries`),Q())}catch(ee){J.error("Failed to clear activity: "+ee.message)}},De=async()=>{B(!0);try{const ee=await ve.installWorkstreamHook();ee.success?(J.success(ee.message),L(Ae=>({...Ae,isInstalled:!0}))):J.error(ee.error||"Failed to install hook")}catch(ee){J.error("Failed to install hook: "+ee.message)}finally{B(!1)}},Ye=async()=>{try{u(!0);const ee=await ve.getWorkstreams();s(ee.workstreams||[])}catch{J.error("Failed to load workstreams")}finally{u(!1)}},we=async()=>{if(!g.trim()){J.error("Name is required");return}R(!0);try{const ee=await ve.createWorkstream(g.trim(),P,j);ee.success?(s(Ae=>[...Ae,ee.workstream]),J.success(`Created workstream: ${g}`),f(!1),y(""),E(""),A([]),he(Ae=>Ae.filter(se=>se.name!==g.trim()))):J.error(ee.error||"Failed to create workstream")}catch(ee){J.error("Failed to create workstream: "+ee.message)}finally{R(!1)}},ye=async ee=>{if(confirm(`Delete workstream "${ee.name}"?
|
|
2869
2869
|
|
|
2870
|
-
This cannot be undone.`))try{const Ae=await ve.deleteWorkstream(ee.id);Ae.success?(s(se=>se.filter(Pe=>Pe.id!==ee.id)),J.success(`Deleted workstream: ${ee.name}`)):J.error(Ae.error||"Failed to delete workstream")}catch(Ae){J.error("Failed to delete workstream: "+Ae.message)}},Ie=async()=>{if(m){R(!0);try{const ee=await ve.updateWorkstream(m.id,{name:m.name,rules:m.rules,projects:m.projects||[]});ee.success?(s(Ae=>Ae.map(se=>se.id===m.id?ee.workstream:se)),J.success("Workstream updated"),h(null)):J.error(ee.error||"Failed to update workstream")}catch(ee){J.error("Failed to update workstream: "+ee.message)}finally{R(!1)}}},ft=ee=>{v(Ae=>{const se=new Set(Ae);return se.has(ee)?se.delete(ee):se.add(ee),se})},Pt=async()=>{if(!k||b.size===0)return;R(!0);let ee=0,Ae=null;for(const se of b)try{const Pe=await ve.addProjectToWorkstream(k.id,se);Pe.success&&(Ae=Pe.workstream,ee++)}catch(Pe){console.error("Failed to add project:",se,Pe)}Ae&&s(se=>se.map(Pe=>Pe.id===k.id?Ae:Pe)),ee>0?J.success(`Added ${ee} project${ee>1?"s":""} to ${k.name}`):J.error("Failed to add projects"),R(!1),w(!1),_(null),v(new Set)},ge=async(ee,Ae)=>{try{const se=await ve.removeProjectFromWorkstream(ee.id,Ae);se.success?(s(Pe=>Pe.map(Xe=>Xe.id===ee.id?se.workstream:Xe)),J.success(`Removed project from ${ee.name}`)):J.error(se.error||"Failed to remove project")}catch(se){J.error("Failed to remove project: "+se.message)}},Ce=ee=>ee.split("/").pop()||ee,Fe=ee=>n.filter(Ae=>{var se;return(se=Ae.projects)==null?void 0:se.includes(ee)}).length,Ge=(ee,Ae=null)=>{var Xe,yt;const se=Fe(ee),Pe=Ae?(yt=(Xe=n.find(ct=>ct.id===Ae))==null?void 0:Xe.projects)==null?void 0:yt.includes(ee):!1;return se===0?null:se===1?Pe?null:"in use":"shared"};return o?r.jsx("div",{className:"flex items-center justify-center h-64",children:r.jsx(it,{className:"w-8 h-8 animate-spin text-indigo-600"})}):r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-100 dark:bg-purple-900/30 flex items-center justify-center",children:r.jsx(ei,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Workstreams"}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Context sets for multi-project workflows"})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(le,{variant:"outline",onClick:Ye,size:"sm",children:[r.jsx(br,{className:"w-4 h-4 mr-2"}),"Refresh"]}),r.jsxs(le,{onClick:()=>f(!0),className:"bg-purple-600 hover:bg-purple-700",children:[r.jsx(wt,{className:"w-4 h-4 mr-2"}),"New Workstream"]})]})]}),r.jsxs("div",{className:"bg-purple-50 dark:bg-purple-950/30 border border-purple-200 dark:border-purple-800 rounded-lg p-4 text-sm text-purple-700 dark:text-purple-400",children:[r.jsx("p",{className:"font-medium mb-1",children:"What are Workstreams?"}),r.jsx("p",{children:"Workstreams are virtual projects that group repos belonging to the same product. When active, workstream rules are automatically injected into every Claude session."})]}),r.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 shadow-sm overflow-hidden",children:n.length===0?r.jsxs("div",{className:"p-12 text-center",children:[r.jsx(ei,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-slate-600"}),r.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"No Workstreams Yet"}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-4",children:"Create your first workstream to organize multi-project contexts."}),r.jsxs(le,{onClick:()=>f(!0),children:[r.jsx(wt,{className:"w-4 h-4 mr-2"}),"Create Your First Workstream"]})]}):r.jsx("div",{className:"divide-y divide-gray-100 dark:divide-slate-800",children:n.map(ee=>{var Ae,se,Pe;return r.jsxs("div",{className:"group",children:[r.jsxs("div",{className:"p-4 flex items-center gap-4 transition-colors cursor-pointer hover:bg-gray-50 dark:hover:bg-slate-900",onClick:()=>l(d===ee.id?null:ee.id),children:[r.jsx("div",{className:"w-5 h-5 flex items-center justify-center text-gray-400",children:d===ee.id?r.jsx(yr,{className:"w-4 h-4"}):r.jsx(Hr,{className:"w-4 h-4"})}),r.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-gray-100 dark:bg-slate-800",children:r.jsx(ei,{className:"w-5 h-5 text-gray-500 dark:text-slate-400"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h3",{className:"font-medium truncate text-gray-900 dark:text-white",children:ee.name}),((Ae=ee.projects)==null?void 0:Ae.length)>0&&r.jsxs("span",{className:"text-xs bg-gray-100 dark:bg-slate-800 text-gray-600 dark:text-slate-400 px-1.5 py-0.5 rounded",children:[ee.projects.length," project",ee.projects.length!==1?"s":""]}),ee.rules&&r.jsxs("span",{className:"text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 px-1.5 py-0.5 rounded",children:[r.jsx(Er,{className:"w-3 h-3 inline mr-0.5"}),"Rules"]})]}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 truncate",children:((se=ee.projects)==null?void 0:se.length)>0?ee.projects.map(Xe=>Ce(Xe)).join(", "):"No projects added"})]}),r.jsxs("div",{className:"flex items-center gap-2",onClick:Xe=>Xe.stopPropagation(),children:[r.jsx(le,{size:"sm",variant:"ghost",onClick:()=>h({...ee}),className:"text-gray-500 dark:text-slate-400 hover:text-purple-600 dark:hover:text-purple-400",title:"Edit workstream",children:r.jsx(lb,{className:"w-4 h-4"})}),r.jsx(le,{size:"sm",variant:"ghost",onClick:()=>ye(ee),className:"text-gray-500 dark:text-slate-400 hover:text-red-600 dark:hover:text-red-400",title:"Delete workstream",children:r.jsx(mn,{className:"w-4 h-4"})})]})]}),d===ee.id&&r.jsxs("div",{className:"px-4 pb-4 pl-16 space-y-4 bg-gray-50/50 dark:bg-slate-900/50",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Projects"}),r.jsxs(le,{size:"sm",variant:"outline",onClick:()=>{_(ee),w(!0)},children:[r.jsx(Li,{className:"w-4 h-4 mr-1"}),"Add Project"]})]}),((Pe=ee.projects)==null?void 0:Pe.length)>0?r.jsx("div",{className:"space-y-1",children:ee.projects.map(Xe=>r.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 bg-white dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[r.jsx("span",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:Xe.replace(/^\/Users\/[^/]+/,"~")}),r.jsx(le,{size:"sm",variant:"ghost",onClick:()=>ge(ee,Xe),className:"text-gray-400 hover:text-red-500 h-6 w-6 p-0",children:r.jsx(qM,{className:"w-4 h-4"})})]},Xe))}):r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic",children:"No projects added yet. Add projects to help organize your workstream."})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Rules"}),ee.rules?r.jsx("pre",{className:"text-sm text-gray-600 dark:text-slate-400 bg-white dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700 p-3 overflow-auto max-h-40 whitespace-pre-wrap",children:ee.rules}):r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic",children:"No rules defined. Click Edit to add context rules for this workstream."})]})]})]},ee.id)})})}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Hook Integration"}),r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx("button",{className:"text-gray-400 hover:text-gray-600 dark:hover:text-slate-300",children:r.jsx(Zu,{className:"w-4 h-4"})})}),r.jsx(Ht,{side:"right",className:"max-w-xs",children:r.jsxs("p",{className:"text-sm",children:[r.jsx("strong",{children:"What are hooks?"}),r.jsx("br",{}),r.jsx("br",{}),"Hooks are scripts that run automatically at specific points in Claude Code sessions. The workstream hook runs before each prompt and injects your active workstream's rules into the context.",r.jsx("br",{}),r.jsx("br",{}),r.jsx("strong",{children:"How it works:"}),r.jsx("br",{}),"1. You activate a workstream",r.jsx("br",{}),"2. Hook detects the active workstream",r.jsx("br",{}),"3. Rules are prepended to Claude's context",r.jsx("br",{}),"4. Claude understands your project context"]})})]})})]}),U.isInstalled?r.jsx("div",{className:"bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-800 rounded-lg p-4 text-sm text-green-700 dark:text-green-400",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ol,{className:"w-5 h-5 flex-shrink-0"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:"Hook Installed"}),r.jsx("p",{className:"text-green-600 dark:text-green-500",children:"Workstream rules will be automatically injected into every Claude session."})]})]})}):r.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-4 text-sm text-amber-700 dark:text-amber-400",children:r.jsxs("div",{className:"flex gap-3",children:[r.jsx(ii,{className:"w-5 h-5 flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"font-medium mb-1",children:"Hook Not Installed"}),r.jsx("p",{className:"mb-3",children:"Install the pre-prompt hook to automatically inject workstream rules into every Claude session."}),r.jsxs(le,{onClick:De,disabled:M||U.loading,size:"sm",className:"bg-amber-600 hover:bg-amber-700 text-white",children:[M?r.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):r.jsx(Sl,{className:"w-4 h-4 mr-2"}),"Install Hook"]}),r.jsxs("p",{className:"text-xs mt-2 text-amber-600 dark:text-amber-500",children:["Creates ",r.jsx("code",{className:"bg-amber-100 dark:bg-amber-900/50 px-1 rounded",children:"~/.claude/hooks/pre-prompt.sh"})]})]})]})})]}),q&&q.totalSessions>0&&r.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 shadow-sm p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(nM,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"}),r.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Activity Insights"})]}),r.jsxs(le,{variant:"ghost",size:"sm",onClick:je,className:"text-gray-500 dark:text-slate-400 hover:text-red-500",children:[r.jsx(mn,{className:"w-4 h-4 mr-1"}),"Clear Old"]})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-4",children:[r.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-slate-400 text-xs mb-1",children:[r.jsx(jC,{className:"w-3 h-3"}),"Sessions"]}),r.jsx("div",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:q.totalSessions})]}),r.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-slate-400 text-xs mb-1",children:[r.jsx(Er,{className:"w-3 h-3"}),"Files Tracked"]}),r.jsx("div",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:q.totalFiles})]}),r.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-slate-400 text-xs mb-1",children:[r.jsx(ei,{className:"w-3 h-3"}),"Projects Active"]}),r.jsx("div",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:q.projectCount})]})]}),((qe=q.topProjects)==null?void 0:qe.length)>0&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Most Active Projects"}),r.jsx("div",{className:"space-y-1",children:q.topProjects.slice(0,5).map((ee,Ae)=>r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-gray-600 dark:text-slate-400 truncate",title:ee.path,children:ee.path.split("/").pop()}),r.jsxs("span",{className:"text-gray-400 dark:text-slate-500 text-xs",children:[ee.fileCount," files"]})]},ee.path))})]})]}),de.length>0&&r.jsxs("div",{className:"bg-gradient-to-r from-indigo-50 to-purple-50 dark:from-indigo-950/30 dark:to-purple-950/30 rounded-xl border border-indigo-200 dark:border-indigo-800 p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Wt,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"}),r.jsx("h3",{className:"font-medium text-indigo-900 dark:text-indigo-300",children:"Suggested Workstreams"}),r.jsx("span",{className:"text-xs bg-indigo-100 dark:bg-indigo-900/50 text-indigo-600 dark:text-indigo-400 px-1.5 py-0.5 rounded",children:"Based on activity patterns"})]}),r.jsx("p",{className:"text-sm text-indigo-700 dark:text-indigo-400 mb-4",children:"These projects are frequently worked on together. Create a workstream to group them?"}),r.jsx("div",{className:"space-y-3",children:de.map(ee=>r.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg border border-indigo-200 dark:border-indigo-800 p-3",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(nd,{className:"w-4 h-4 text-amber-500"}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name}),ee.coActivityScore&&r.jsxs("span",{className:"text-xs text-gray-500 dark:text-slate-400",children:[ee.coActivityScore,"% co-activity"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(le,{size:"sm",variant:"ghost",onClick:()=>ne(ee),className:"text-gray-400 hover:text-gray-600 dark:hover:text-slate-300",title:"Dismiss suggestion",children:r.jsx(ti,{className:"w-4 h-4"})}),r.jsxs(le,{size:"sm",onClick:()=>oe(ee),className:"bg-indigo-600 hover:bg-indigo-700",children:[r.jsx(wt,{className:"w-4 h-4 mr-1"}),"Create"]})]})]}),r.jsx("div",{className:"flex flex-wrap gap-1",children:ee.projects.map(Ae=>r.jsx("span",{className:"text-xs bg-gray-100 dark:bg-slate-800 text-gray-600 dark:text-slate-400 px-2 py-0.5 rounded",children:Ae.split("/").pop()},Ae))})]},ee.name))})]}),r.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[r.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),r.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[r.jsx("p",{children:"coder-config workstream # List workstreams"}),r.jsx("p",{children:'coder-config workstream use "Name" # Set workstream for this tab'}),r.jsx("p",{children:'coder-config workstream create "Name" # Create workstream'})]})]}),r.jsx(Nt,{open:c,onOpenChange:ee=>{ee||(f(!1),y(""),E(""),A([]),O(!1),H({}))},children:r.jsxs(_t,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[r.jsx(Ct,{children:r.jsxs(St,{className:"flex items-center gap-2",children:[r.jsx(ei,{className:"w-5 h-5 text-purple-600"}),"Create Workstream"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1 block",children:"Name"}),r.jsx(lt,{value:g,onChange:ee=>y(ee.target.value),placeholder:"e.g., User Auth, Admin Dashboard",autoFocus:!0})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Projects"}),r.jsxs(le,{type:"button",size:"sm",variant:"outline",onClick:()=>O(!I),children:[r.jsx(Li,{className:"w-4 h-4 mr-1"}),"Add"]})]}),P.length>0?r.jsx("div",{className:"space-y-1 mb-2",children:P.map(ee=>r.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 bg-gray-50 dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[r.jsx("span",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:ee.replace(/^\/Users\/[^/]+/,"~")}),r.jsx(le,{type:"button",size:"sm",variant:"ghost",onClick:()=>_e(ee),className:"text-gray-400 hover:text-red-500 h-6 w-6 p-0",children:r.jsx(ti,{className:"w-4 h-4"})})]},ee))}):r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic mb-2",children:"No projects added. Add projects to help organize your workstream."}),I&&e.length>0&&r.jsx("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg p-2 max-h-64 overflow-y-auto bg-white dark:bg-slate-900",children:e.map(ee=>{const Ae=Ge(ee.path),se=$[ee.path],Pe=K[ee.path],Xe=Y[ee.path]||[],yt=P.includes(ee.path);return r.jsxs("div",{className:"mb-1",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{type:"button",onClick:()=>Ve(ee.path),className:"p-1 hover:bg-gray-100 dark:hover:bg-slate-800 rounded",title:"Show sub-projects",children:Pe?r.jsx(it,{className:"w-4 h-4 animate-spin text-gray-400"}):se?r.jsx(yr,{className:"w-4 h-4 text-gray-400"}):r.jsx(Hr,{className:"w-4 h-4 text-gray-400"})}),r.jsxs("button",{type:"button",onClick:()=>Oe(ee.path),disabled:yt,className:`flex-1 text-left p-2 rounded transition-colors ${yt?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name}),r.jsxs("div",{className:"flex items-center gap-1",children:[Ae&&r.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${Ae==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:Ae}),yt&&r.jsx(qt,{className:"w-4 h-4 text-purple-600"})]})]}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate",children:ee.path.replace(/^\/Users\/[^/]+/,"~")})]})]}),se&&Xe.length>0&&r.jsx("div",{className:"ml-6 mt-1 space-y-1 border-l-2 border-gray-200 dark:border-slate-700 pl-2",children:Xe.map(ct=>{const mt=P.includes(ct.dir),At=Ge(ct.dir);return r.jsxs("button",{type:"button",onClick:()=>Oe(ct.dir),disabled:mt,className:`w-full text-left p-2 rounded transition-colors ${mt?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-gray-700 dark:text-slate-300",children:ct.name}),r.jsxs("div",{className:"flex items-center gap-1",children:[At&&r.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${At==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:At}),mt&&r.jsx(qt,{className:"w-4 h-4 text-purple-600"})]})]}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono",children:ct.relativePath})]},ct.dir)})}),se&&Xe.length===0&&!Pe&&r.jsx("div",{className:"ml-6 mt-1 pl-2 text-xs text-gray-400 dark:text-slate-500 italic",children:"No sub-projects found"})]},ee.id)})})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1 block",children:"Context (optional)"}),r.jsx(pt,{value:j,onChange:ee=>E(ee.target.value),placeholder:"Context rules for this workstream. These will be injected into every Claude session when this workstream is active.",rows:6}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:'Example: "Focus on user authentication. Use JWT tokens. React Query for state management."'})]})]}),r.jsxs(Tt,{children:[r.jsx(le,{variant:"outline",onClick:()=>{f(!1),y(""),E(""),A([]),O(!1),H({})},children:"Cancel"}),r.jsxs(le,{onClick:we,disabled:N||!g.trim(),className:"bg-purple-600 hover:bg-purple-700",children:[N?r.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):r.jsx(wt,{className:"w-4 h-4 mr-2"}),"Create"]})]})]})}),r.jsx(Nt,{open:!!m,onOpenChange:ee=>!ee&&h(null),children:r.jsxs(_t,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[r.jsx(Ct,{children:r.jsxs(St,{className:"flex items-center gap-2",children:[r.jsx(lb,{className:"w-5 h-5 text-purple-600"}),"Edit Workstream"]})}),m&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1 block",children:"Name"}),r.jsx(lt,{value:m.name,onChange:ee=>h(Ae=>({...Ae,name:ee.target.value}))})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Projects"}),r.jsxs(le,{type:"button",size:"sm",variant:"outline",onClick:()=>h(ee=>({...ee,showPicker:!ee.showPicker})),children:[r.jsx(Li,{className:"w-4 h-4 mr-1"}),"Add"]})]}),((vt=m.projects)==null?void 0:vt.length)>0?r.jsx("div",{className:"space-y-1 mb-2",children:m.projects.map(ee=>r.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 bg-gray-50 dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[r.jsx("span",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:ee.replace(/^\/Users\/[^/]+/,"~")}),r.jsx(le,{type:"button",size:"sm",variant:"ghost",onClick:()=>h(Ae=>({...Ae,projects:Ae.projects.filter(se=>se!==ee)})),className:"text-gray-400 hover:text-red-500 h-6 w-6 p-0",children:r.jsx(ti,{className:"w-4 h-4"})})]},ee))}):r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic mb-2",children:"No projects in this workstream."}),m.showPicker&&e.length>0&&r.jsx("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg p-2 max-h-48 overflow-y-auto bg-white dark:bg-slate-900",children:e.map(ee=>{var ct;const Ae=(ct=m.projects)==null?void 0:ct.includes(ee.path),se=Ge(ee.path,m.id),Pe=$[ee.path],Xe=K[ee.path],yt=Y[ee.path]||[];return r.jsxs("div",{className:"mb-1",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{type:"button",onClick:()=>Ve(ee.path),className:"p-1 hover:bg-gray-100 dark:hover:bg-slate-800 rounded",title:"Show sub-projects",children:Xe?r.jsx(it,{className:"w-4 h-4 animate-spin text-gray-400"}):Pe?r.jsx(yr,{className:"w-4 h-4 text-gray-400"}):r.jsx(Hr,{className:"w-4 h-4 text-gray-400"})}),r.jsxs("button",{type:"button",onClick:()=>!Ae&&h(mt=>({...mt,projects:[...mt.projects||[],ee.path]})),disabled:Ae,className:`flex-1 text-left p-2 rounded transition-colors ${Ae?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name}),r.jsxs("div",{className:"flex items-center gap-1",children:[se&&r.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${se==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:se}),Ae&&r.jsx(qt,{className:"w-4 h-4 text-purple-600"})]})]}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate",children:ee.path.replace(/^\/Users\/[^/]+/,"~")})]})]}),Pe&&yt.length>0&&r.jsx("div",{className:"ml-6 mt-1 space-y-1 border-l-2 border-gray-200 dark:border-slate-700 pl-2",children:yt.map(mt=>{var or;const At=(or=m.projects)==null?void 0:or.includes(mt.dir),gt=Ge(mt.dir,m.id);return r.jsxs("button",{type:"button",onClick:()=>!At&&h(Vr=>({...Vr,projects:[...Vr.projects||[],mt.dir]})),disabled:At,className:`w-full text-left p-2 rounded transition-colors ${At?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-gray-700 dark:text-slate-300",children:mt.name}),r.jsxs("div",{className:"flex items-center gap-1",children:[gt&&r.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${gt==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:gt}),At&&r.jsx(qt,{className:"w-4 h-4 text-purple-600"})]})]}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate",children:mt.relativePath})]},mt.dir)})}),Pe&&yt.length===0&&!Xe&&r.jsx("div",{className:"ml-6 mt-1 pl-2 text-xs text-gray-400 dark:text-slate-500 italic",children:"No sub-projects found"})]},ee.id)})})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1 block",children:"Rules"}),r.jsx(pt,{value:m.rules||"",onChange:ee=>h(Ae=>({...Ae,rules:ee.target.value})),placeholder:"Context rules for this workstream...",rows:8})]})]}),r.jsxs(Tt,{children:[r.jsx(le,{variant:"outline",onClick:()=>h(null),children:"Cancel"}),r.jsxs(le,{onClick:Ie,disabled:N,className:"bg-purple-600 hover:bg-purple-700",children:[N?r.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):r.jsx(hi,{className:"w-4 h-4 mr-2"}),"Save Changes"]})]})]})}),r.jsx(Nt,{open:x,onOpenChange:ee=>{w(ee),ee||(H({}),v(new Set))},children:r.jsxs(_t,{className:"max-w-lg",children:[r.jsx(Ct,{children:r.jsxs(St,{className:"flex items-center gap-2",children:[r.jsx(Li,{className:"w-5 h-5 text-purple-600"}),"Add Project to ",k==null?void 0:k.name]})}),r.jsxs("div",{className:"py-4",children:[r.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400 mb-4",children:"Select projects to add to this workstream (multi-select enabled):"}),e.length>0?r.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto border border-gray-200 dark:border-slate-700 rounded-lg p-2 bg-white dark:bg-slate-900",children:e.map(ee=>{var mt;const Ae=(mt=k==null?void 0:k.projects)==null?void 0:mt.includes(ee.path),se=b.has(ee.path),Pe=Ge(ee.path,k==null?void 0:k.id),Xe=$[ee.path],yt=K[ee.path],ct=Y[ee.path]||[];return r.jsxs("div",{className:"mb-1",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{type:"button",onClick:()=>Ve(ee.path),className:"p-1 hover:bg-gray-100 dark:hover:bg-slate-800 rounded",title:"Show sub-projects",children:yt?r.jsx(it,{className:"w-4 h-4 animate-spin text-gray-400"}):Xe?r.jsx(yr,{className:"w-4 h-4 text-gray-400"}):r.jsx(Hr,{className:"w-4 h-4 text-gray-400"})}),r.jsxs("button",{type:"button",onClick:()=>!Ae&&ft(ee.path),disabled:Ae,className:`flex-1 text-left p-2 rounded transition-colors ${Ae?"bg-gray-100 dark:bg-slate-800 opacity-50 cursor-not-allowed":se?"bg-purple-100 dark:bg-purple-950/50 ring-2 ring-purple-500":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-4 h-4 rounded border-2 flex items-center justify-center ${Ae?"bg-gray-300 dark:bg-slate-600 border-gray-300 dark:border-slate-600":se?"bg-purple-600 border-purple-600":"border-gray-300 dark:border-slate-600"}`,children:(Ae||se)&&r.jsx(qt,{className:"w-3 h-3 text-white"})}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[Pe&&r.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${Pe==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:Pe}),Ae&&r.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400",children:"added"})]})]}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate ml-6",children:ee.path.replace(/^\/Users\/[^/]+/,"~")})]})]}),Xe&&ct.length>0&&r.jsx("div",{className:"ml-6 mt-1 space-y-1 border-l-2 border-gray-200 dark:border-slate-700 pl-2",children:ct.map(At=>{var rt;const gt=(rt=k==null?void 0:k.projects)==null?void 0:rt.includes(At.dir),or=b.has(At.dir),Vr=Ge(At.dir,k==null?void 0:k.id);return r.jsxs("button",{type:"button",onClick:()=>!gt&&ft(At.dir),disabled:gt,className:`w-full text-left p-2 rounded transition-colors ${gt?"bg-gray-100 dark:bg-slate-800 opacity-50 cursor-not-allowed":or?"bg-purple-100 dark:bg-purple-950/50 ring-2 ring-purple-500":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-4 h-4 rounded border-2 flex items-center justify-center ${gt?"bg-gray-300 dark:bg-slate-600 border-gray-300 dark:border-slate-600":or?"bg-purple-600 border-purple-600":"border-gray-300 dark:border-slate-600"}`,children:(gt||or)&&r.jsx(qt,{className:"w-3 h-3 text-white"})}),r.jsx("span",{className:"text-gray-700 dark:text-slate-300",children:At.name})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[Vr&&r.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${Vr==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:Vr}),gt&&r.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400",children:"added"})]})]}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate ml-6",children:At.relativePath})]},At.dir)})}),Xe&&ct.length===0&&!yt&&r.jsx("div",{className:"ml-6 mt-1 pl-2 text-xs text-gray-400 dark:text-slate-500 italic",children:"No sub-projects found"})]},ee.id)})}):r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 text-center py-4",children:"No projects registered. Add projects in the Projects view first."})]}),r.jsxs(Tt,{children:[r.jsx(le,{variant:"outline",onClick:()=>{w(!1),v(new Set)},children:"Cancel"}),r.jsxs(le,{onClick:Pt,disabled:b.size===0||N,className:"bg-purple-600 hover:bg-purple-700",children:[N?r.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):r.jsx(wt,{className:"w-4 h-4 mr-2"}),"Add Selected (",b.size,")"]})]})]})})]})}const zw={clarify:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",plan:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",execute:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200"},za={pending:r.jsx(pu,{className:"w-4 h-4 text-gray-500"}),running:r.jsx(DC,{className:"w-4 h-4 text-green-500"}),paused:r.jsx(RC,{className:"w-4 h-4 text-yellow-500"}),completed:r.jsx(ol,{className:"w-4 h-4 text-green-600"}),failed:r.jsx(Pu,{className:"w-4 h-4 text-red-500"}),cancelled:r.jsx(Pu,{className:"w-4 h-4 text-gray-500"})};function UH({workstreams:e=[]}){var Pt,ge,Ce,Fe,Ge,qe,vt,ee,Ae;const[t,n]=S.useState([]),[s,o]=S.useState(!0),[u,d]=S.useState(null),[l,c]=S.useState({}),[f,m]=S.useState(!1),[h,x]=S.useState(!1),[w,k]=S.useState(!1),[_,b]=S.useState(!1),[v,g]=S.useState(null),[y,j]=S.useState(""),[E,P]=S.useState(""),[A,N]=S.useState(!1),[R,I]=S.useState(50),[O,$]=S.useState(10),[H,Y]=S.useState(!1),[z,K]=S.useState([]),[G,U]=S.useState({stopHook:{},prepromptHook:{}}),[L,M]=S.useState(!1),[B,q]=S.useState(!1),[F,ae]=S.useState(null);S.useEffect(()=>{he(),me(),X()},[]);const he=async()=>{try{o(!0);const se=await ve.getLoops();n(se.loops||[]),c(se.config||{})}catch{J.error("Failed to load loops")}finally{o(!1)}},me=async()=>{try{const Pe=(await ve.getLoopConfig()).config||{};c(Pe),I(Pe.maxIterations||50),$(Pe.maxCost||10),Y(Pe.autoApprovePlan||!1)}catch(se){console.error("Failed to load config:",se)}},X=async()=>{try{const se=await ve.getLoopHookStatus();U(se)}catch(se){console.error("Failed to load hook status:",se)}},W=async()=>{try{const se=await ve.getLoopHistory();K(se.completed||[])}catch{J.error("Failed to load history")}},ce=async()=>{if(!y.trim()){J.error("Task description is required");return}try{N(!0);const se=await ve.createLoop(y,{workstreamId:E||null});se.success?(J.success("Loop created"),m(!1),j(""),P(""),he()):J.error(se.error||"Failed to create loop")}catch(se){J.error(se.message)}finally{N(!1)}},re=async se=>{try{const Pe=await ve.startLoop(se);Pe.success&&Pe.loop?(J.success("Loop started - launching Claude Code"),ae(Pe.loop),q(!0),he()):J.error(Pe.error||"Failed to start loop")}catch(Pe){J.error(Pe.message)}},Q=S.useCallback(async(se,Pe)=>{var Xe,yt,ct,mt;if(F)try{const gt=(await ve.getLoop(F.id)).loop;gt.taskComplete||gt.status==="completed"?(J.success("Loop completed successfully!"),q(!1),ae(null)):gt.status==="paused"?J.info(`Loop paused: ${gt.pauseReason||"user requested"}`):((Xe=gt.iterations)==null?void 0:Xe.current)>=((yt=gt.iterations)==null?void 0:yt.max)?(J.warning("Loop reached max iterations"),await ve.pauseLoop(gt.id)):((ct=gt.budget)==null?void 0:ct.currentCost)>=((mt=gt.budget)==null?void 0:mt.maxCost)?(J.warning("Loop reached budget limit"),await ve.pauseLoop(gt.id)):J.info("Claude exited. Click Start to continue the loop."),he()}catch(At){console.error("Failed to check loop status:",At)}},[F]),oe=async se=>{try{const Pe=await ve.pauseLoop(se);Pe.success?(J.success("Loop paused"),he()):J.error(Pe.error||"Failed to pause loop")}catch(Pe){J.error(Pe.message)}},_e=async se=>{try{const Pe=await ve.resumeLoop(se);Pe.success?(J.success("Loop resumed"),he()):J.error(Pe.error||"Failed to resume loop")}catch(Pe){J.error(Pe.message)}},Oe=async se=>{if(confirm("Cancel this loop?"))try{const Pe=await ve.cancelLoop(se);Pe.success?(J.success("Loop cancelled"),he()):J.error(Pe.error||"Failed to cancel loop")}catch(Pe){J.error(Pe.message)}},Ve=async se=>{if(confirm("Delete this loop and all its data?"))try{const Pe=await ve.deleteLoop(se);Pe.success?(J.success("Loop deleted"),he()):J.error(Pe.error||"Failed to delete loop")}catch(Pe){J.error(Pe.message)}},ne=async se=>{try{const Pe=await ve.approveLoop(se);Pe.success?(J.success("Plan approved"),he()):J.error(Pe.error||"Failed to approve plan")}catch(Pe){J.error(Pe.message)}},de=async()=>{try{N(!0);const se=await ve.updateLoopConfig({maxIterations:parseInt(R,10),maxCost:parseFloat(O),autoApprovePlan:H});se.success?(J.success("Configuration saved"),x(!1),me()):J.error(se.error||"Failed to save configuration")}catch(se){J.error(se.message)}finally{N(!1)}},je=async()=>{try{M(!0);const se=await ve.installLoopHooks();se.success?(J.success("Hooks installed successfully"),X()):J.error(se.error||"Failed to install hooks")}catch(se){J.error(se.message)}finally{M(!1)}},De=async se=>{try{const Pe=await ve.getLoop(se.id);g({...Pe.loop,clarifications:Pe.clarifications,plan:Pe.plan}),b(!0)}catch{J.error("Failed to load loop details")}},Ye=se=>{navigator.clipboard.writeText(se),J.success("Copied to clipboard")},we=se=>se?new Date(se).toLocaleString():"-",ye=se=>se.iterations?Math.min(100,se.iterations.current/se.iterations.max*100):0,Ie=se=>se.budget?Math.min(100,se.budget.currentCost/se.budget.maxCost*100):0,ft=((Pt=G.stopHook)==null?void 0:Pt.exists)&&((ge=G.prepromptHook)==null?void 0:ge.exists);return r.jsxs("div",{className:"p-6 space-y-6 max-w-6xl mx-auto",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[r.jsx(ll,{className:"w-6 h-6"}),"Ralph Loops"]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Autonomous development loops that run Claude Code until a task is completed"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",onClick:()=>{W(),k(!0)},children:[r.jsx(Tu,{className:"w-4 h-4 mr-1"}),"History"]})}),r.jsx(Ht,{children:"View completed loops"})]})}),r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",onClick:()=>x(!0),children:[r.jsx(En,{className:"w-4 h-4 mr-1"}),"Config"]})}),r.jsx(Ht,{children:"Configure loop defaults"})]})}),r.jsxs(le,{onClick:()=>m(!0),children:[r.jsx(wt,{className:"w-4 h-4 mr-1"}),"New Loop"]})]})]}),!ft&&r.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(ii,{className:"w-5 h-5 text-yellow-600"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-yellow-800 dark:text-yellow-200",children:"Hooks not installed"}),r.jsx("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:"Install the Ralph Loop hooks to enable automatic loop continuation"})]})]}),r.jsxs(le,{variant:"outline",size:"sm",onClick:je,disabled:L,children:[L?r.jsx(it,{className:"w-4 h-4 animate-spin mr-1"}):null,"Install Hooks"]})]}),s?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(it,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):t.length===0?r.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[r.jsx(ll,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{className:"text-lg font-medium",children:"No loops yet"}),r.jsx("p",{className:"text-sm mt-1",children:"Create a loop to start autonomous development"})]}):r.jsx("div",{className:"space-y-3",children:t.map(se=>{var Pe,Xe,yt,ct,mt,At,gt,or;return r.jsxs("div",{className:"border rounded-lg bg-card overflow-hidden",children:[r.jsxs("div",{className:"p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>d(u===se.id?null:se.id),children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[u===se.id?r.jsx(yr,{className:"w-4 h-4 text-muted-foreground"}):r.jsx(Hr,{className:"w-4 h-4 text-muted-foreground"}),za[se.status]||za.pending,r.jsxs("div",{children:[r.jsx("h3",{className:"font-medium",children:se.name}),r.jsx("p",{className:"text-sm text-muted-foreground truncate max-w-md",children:((Pe=se.task)==null?void 0:Pe.original)||"No task"})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${zw[se.phase]||"bg-gray-100"}`,children:se.phase}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:[((Xe=se.iterations)==null?void 0:Xe.current)||0,"/",((yt=se.iterations)==null?void 0:yt.max)||50]}),r.jsxs("div",{className:"flex items-center gap-1",onClick:Vr=>Vr.stopPropagation(),children:[se.status==="pending"&&r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>re(se.id),children:r.jsx(DC,{className:"w-4 h-4"})})}),r.jsx(Ht,{children:"Start loop"})]})}),se.status==="running"&&r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>oe(se.id),children:r.jsx(RC,{className:"w-4 h-4"})})}),r.jsx(Ht,{children:"Pause loop"})]})}),se.status==="paused"&&r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>_e(se.id),children:r.jsx(I5,{className:"w-4 h-4"})})}),r.jsx(Ht,{children:"Resume loop"})]})}),se.phase==="plan"&&se.status==="running"&&r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>ne(se.id),children:r.jsx(qt,{className:"w-4 h-4"})})}),r.jsx(Ht,{children:"Approve plan"})]})}),r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>De(se),children:r.jsx(Gp,{className:"w-4 h-4"})})}),r.jsx(Ht,{children:"View details"})]})}),(se.status==="running"||se.status==="paused")&&r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>Oe(se.id),children:r.jsx(Pu,{className:"w-4 h-4"})})}),r.jsx(Ht,{children:"Cancel loop"})]})}),r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>Ve(se.id),children:r.jsx(mn,{className:"w-4 h-4 text-red-500"})})}),r.jsx(Ht,{children:"Delete loop"})]})})]})]})]}),r.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground mb-1",children:[r.jsx("span",{children:"Iterations"}),r.jsxs("span",{children:[((ct=se.iterations)==null?void 0:ct.current)||0," / ",((mt=se.iterations)==null?void 0:mt.max)||50]})]}),r.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-blue-500 transition-all",style:{width:`${ye(se)}%`}})})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground mb-1",children:[r.jsx("span",{children:"Budget"}),r.jsxs("span",{children:["$",(((At=se.budget)==null?void 0:At.currentCost)||0).toFixed(2)," / $",(((gt=se.budget)==null?void 0:gt.maxCost)||10).toFixed(2)]})]}),r.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-green-500 transition-all",style:{width:`${Ie(se)}%`}})})]})]})]}),u===se.id&&r.jsxs("div",{className:"border-t p-4 bg-muted/30 space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"ID:"}),r.jsx("span",{className:"ml-2 font-mono",children:se.id}),r.jsx(le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 ml-1",onClick:()=>Ye(se.id),children:r.jsx(al,{className:"w-3 h-3"})})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Status:"}),r.jsxs("span",{className:"ml-2",children:[se.status,se.pauseReason?` (${se.pauseReason})`:""]})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Created:"}),r.jsx("span",{className:"ml-2",children:we(se.createdAt)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Updated:"}),r.jsx("span",{className:"ml-2",children:we(se.updatedAt)})]}),se.workstreamId&&r.jsxs("div",{className:"col-span-2",children:[r.jsx("span",{className:"text-muted-foreground",children:"Workstream:"}),r.jsx("span",{className:"ml-2",children:se.workstreamId})]})]}),r.jsxs("div",{className:"bg-muted p-3 rounded-md",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Terminal,{className:"w-4 h-4"}),r.jsx("span",{className:"text-sm font-medium",children:"Run this loop:"})]}),r.jsxs("code",{className:"text-xs bg-background p-2 rounded block",children:["export CODER_LOOP_ID=",se.id,r.jsx("br",{}),'claude --continue "',(or=se.task)==null?void 0:or.original,'"']})]})]})]},se.id)})}),r.jsx(Nt,{open:f,onOpenChange:m,children:r.jsxs(_t,{className:"sm:max-w-lg",children:[r.jsx(Ct,{children:r.jsx(St,{children:"Create New Loop"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Task Description"}),r.jsx(pt,{placeholder:"Describe what you want Claude to accomplish...",value:y,onChange:se=>j(se.target.value),rows:4}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Be specific about the goal. The loop will continue until this task is completed."})]}),e.length>0&&r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Workstream (optional)"}),r.jsxs("select",{className:"w-full border rounded-md p-2 bg-background",value:E,onChange:se=>P(se.target.value),children:[r.jsx("option",{value:"",children:"No workstream"}),e.map(se=>r.jsx("option",{value:se.id,children:se.name},se.id))]})]})]}),r.jsxs(Tt,{children:[r.jsx(le,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),r.jsxs(le,{onClick:ce,disabled:A||!y.trim(),children:[A?r.jsx(it,{className:"w-4 h-4 animate-spin mr-1"}):null,"Create Loop"]})]})]})}),r.jsx(Nt,{open:h,onOpenChange:x,children:r.jsxs(_t,{className:"sm:max-w-md",children:[r.jsx(Ct,{children:r.jsx(St,{children:"Loop Configuration"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),r.jsx(lt,{type:"number",value:R,onChange:se=>I(se.target.value),min:1,max:1e3}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Loop will pause after this many iterations"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Cost ($)"}),r.jsx(lt,{type:"number",value:O,onChange:se=>$(se.target.value),min:.01,step:.01}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Loop will pause when estimated cost exceeds this amount"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"checkbox",id:"autoApprovePlan",checked:H,onChange:se=>Y(se.target.checked),className:"rounded"}),r.jsx("label",{htmlFor:"autoApprovePlan",className:"text-sm",children:"Auto-approve plans (skip manual plan approval)"})]})]}),r.jsxs(Tt,{children:[r.jsx(le,{variant:"outline",onClick:()=>x(!1),children:"Cancel"}),r.jsxs(le,{onClick:de,disabled:A,children:[A?r.jsx(it,{className:"w-4 h-4 animate-spin mr-1"}):null,"Save"]})]})]})}),r.jsx(Nt,{open:w,onOpenChange:k,children:r.jsxs(_t,{className:"sm:max-w-2xl max-h-[80vh] overflow-y-auto",children:[r.jsx(Ct,{children:r.jsx(St,{children:"Loop History"})}),r.jsx("div",{className:"space-y-3 py-4",children:z.length===0?r.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No completed loops yet"}):z.slice().reverse().map(se=>r.jsxs("div",{className:"border rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[za[se.status]||za.completed,r.jsx("span",{className:"font-medium",children:se.name})]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:we(se.completedAt)})]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:se.task}),r.jsxs("div",{className:"flex gap-4 mt-2 text-xs text-muted-foreground",children:[r.jsxs("span",{children:["Iterations: ",se.totalIterations]}),r.jsxs("span",{children:["Cost: $",(se.totalCost||0).toFixed(2)]})]})]},se.id))})]})}),r.jsx(Nt,{open:_,onOpenChange:b,children:r.jsxs(_t,{className:"sm:max-w-3xl max-h-[80vh] overflow-y-auto",children:[r.jsx(Ct,{children:r.jsx(St,{children:(v==null?void 0:v.name)||"Loop Details"})}),v&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Phase"}),r.jsx("span",{className:`text-sm px-2 py-0.5 rounded-full ${zw[v.phase]||""}`,children:v.phase})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Status"}),r.jsxs("div",{className:"flex items-center gap-1",children:[za[v.status],r.jsx("span",{children:v.status})]})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Progress"}),r.jsxs("span",{children:[((Ce=v.iterations)==null?void 0:Ce.current)||0," / ",((Fe=v.iterations)==null?void 0:Fe.max)||50]})]})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Task"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm",children:(Ge=v.task)==null?void 0:Ge.original})]}),v.clarifications&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Clarifications"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-40 overflow-y-auto",children:v.clarifications})]}),v.plan&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Plan"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-60 overflow-y-auto font-mono",children:v.plan})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Run Command"}),r.jsxs("code",{className:"text-xs bg-muted p-3 rounded block",children:["export CODER_LOOP_ID=",v.id,r.jsx("br",{}),'claude --continue "',(qe=v.task)==null?void 0:qe.original,'"']})]})]})]})}),r.jsx(cj,{open:B,onOpenChange:se=>{q(se),se||(ae(null),he())},title:F?`Loop: ${F.name}`:"Running Loop",description:(vt=F==null?void 0:F.task)==null?void 0:vt.original,cwd:F==null?void 0:F.projectPath,initialCommand:F?`claude --continue "${(Ae=(ee=F.task)==null?void 0:ee.original)==null?void 0:Ae.replace(/"/g,'\\"')}"`:"",env:F?{CODER_LOOP_ID:F.id}:{},onExit:Q})]})}function GH(e,t=[]){let n=[];function s(u,d){const l=S.createContext(d);l.displayName=u+"Context";const c=n.length;n=[...n,d];const f=h=>{var v;const{scope:x,children:w,...k}=h,_=((v=x==null?void 0:x[e])==null?void 0:v[c])||l,b=S.useMemo(()=>k,Object.values(k));return r.jsx(_.Provider,{value:b,children:w})};f.displayName=u+"Provider";function m(h,x){var _;const w=((_=x==null?void 0:x[e])==null?void 0:_[c])||l,k=S.useContext(w);if(k)return k;if(d!==void 0)return d;throw new Error(`\`${h}\` must be used within \`${u}\``)}return[f,m]}const o=()=>{const u=n.map(d=>S.createContext(d));return function(l){const c=(l==null?void 0:l[e])||u;return S.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return o.scopeName=e,[s,KH(o,...t)]}function KH(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(u){const d=s.reduce((l,{useScope:c,scopeName:f})=>{const h=c(u)[`__scope${f}`];return{...l,...h}},{});return S.useMemo(()=>({[`__scope${t.scopeName}`]:d}),[d])}};return n.scopeName=t.scopeName,n}var qH=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],VN=qH.reduce((e,t)=>{const n=sd(`Primitive.${t}`),s=S.forwardRef((o,u)=>{const{asChild:d,...l}=o,c=d?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(c,{...l,ref:u})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),tx="Progress",rx=100,[YH]=GH(tx),[XH,JH]=YH(tx),UN=S.forwardRef((e,t)=>{const{__scopeProgress:n,value:s=null,max:o,getValueLabel:u=QH,...d}=e;(o||o===0)&&!Hw(o)&&console.error(ZH(`${o}`,"Progress"));const l=Hw(o)?o:rx;s!==null&&!Ww(s,l)&&console.error(eW(`${s}`,"Progress"));const c=Ww(s,l)?s:null,f=Gu(c)?u(c,l):void 0;return r.jsx(XH,{scope:n,value:c,max:l,children:r.jsx(VN.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":Gu(c)?c:void 0,"aria-valuetext":f,role:"progressbar","data-state":qN(c,l),"data-value":c??void 0,"data-max":l,...d,ref:t})})});UN.displayName=tx;var GN="ProgressIndicator",KN=S.forwardRef((e,t)=>{const{__scopeProgress:n,...s}=e,o=JH(GN,n);return r.jsx(VN.div,{"data-state":qN(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...s,ref:t})});KN.displayName=GN;function QH(e,t){return`${Math.round(e/t*100)}%`}function qN(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function Gu(e){return typeof e=="number"}function Hw(e){return Gu(e)&&!isNaN(e)&&e>0}function Ww(e,t){return Gu(e)&&!isNaN(e)&&e<=t&&e>=0}function ZH(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${rx}\`.`}function eW(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
|
|
2870
|
+
This cannot be undone.`))try{const Ae=await ve.deleteWorkstream(ee.id);Ae.success?(s(se=>se.filter(Pe=>Pe.id!==ee.id)),J.success(`Deleted workstream: ${ee.name}`)):J.error(Ae.error||"Failed to delete workstream")}catch(Ae){J.error("Failed to delete workstream: "+Ae.message)}},Ie=async()=>{if(m){R(!0);try{const ee=await ve.updateWorkstream(m.id,{name:m.name,rules:m.rules,projects:m.projects||[]});ee.success?(s(Ae=>Ae.map(se=>se.id===m.id?ee.workstream:se)),J.success("Workstream updated"),h(null)):J.error(ee.error||"Failed to update workstream")}catch(ee){J.error("Failed to update workstream: "+ee.message)}finally{R(!1)}}},ft=ee=>{v(Ae=>{const se=new Set(Ae);return se.has(ee)?se.delete(ee):se.add(ee),se})},Pt=async()=>{if(!k||b.size===0)return;R(!0);let ee=0,Ae=null;for(const se of b)try{const Pe=await ve.addProjectToWorkstream(k.id,se);Pe.success&&(Ae=Pe.workstream,ee++)}catch(Pe){console.error("Failed to add project:",se,Pe)}Ae&&s(se=>se.map(Pe=>Pe.id===k.id?Ae:Pe)),ee>0?J.success(`Added ${ee} project${ee>1?"s":""} to ${k.name}`):J.error("Failed to add projects"),R(!1),w(!1),_(null),v(new Set)},ge=async(ee,Ae)=>{try{const se=await ve.removeProjectFromWorkstream(ee.id,Ae);se.success?(s(Pe=>Pe.map(Xe=>Xe.id===ee.id?se.workstream:Xe)),J.success(`Removed project from ${ee.name}`)):J.error(se.error||"Failed to remove project")}catch(se){J.error("Failed to remove project: "+se.message)}},Ce=ee=>ee.split("/").pop()||ee,Fe=ee=>n.filter(Ae=>{var se;return(se=Ae.projects)==null?void 0:se.includes(ee)}).length,Ge=(ee,Ae=null)=>{var Xe,yt;const se=Fe(ee),Pe=Ae?(yt=(Xe=n.find(ct=>ct.id===Ae))==null?void 0:Xe.projects)==null?void 0:yt.includes(ee):!1;return se===0?null:se===1?Pe?null:"in use":"shared"};return o?r.jsx("div",{className:"flex items-center justify-center h-64",children:r.jsx(it,{className:"w-8 h-8 animate-spin text-indigo-600"})}):r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-100 dark:bg-purple-900/30 flex items-center justify-center",children:r.jsx(ei,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Workstreams"}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Context sets for multi-project workflows"})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(le,{variant:"outline",onClick:Ye,size:"sm",children:[r.jsx(br,{className:"w-4 h-4 mr-2"}),"Refresh"]}),r.jsxs(le,{onClick:()=>f(!0),className:"bg-purple-600 hover:bg-purple-700",children:[r.jsx(wt,{className:"w-4 h-4 mr-2"}),"New Workstream"]})]})]}),r.jsxs("div",{className:"bg-purple-50 dark:bg-purple-950/30 border border-purple-200 dark:border-purple-800 rounded-lg p-4 text-sm text-purple-700 dark:text-purple-400",children:[r.jsx("p",{className:"font-medium mb-1",children:"What are Workstreams?"}),r.jsx("p",{children:"Workstreams are virtual projects that group repos belonging to the same product. When active, workstream rules are automatically injected into every Claude session."})]}),r.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 shadow-sm overflow-hidden",children:n.length===0?r.jsxs("div",{className:"p-12 text-center",children:[r.jsx(ei,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-slate-600"}),r.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"No Workstreams Yet"}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-4",children:"Create your first workstream to organize multi-project contexts."}),r.jsxs(le,{onClick:()=>f(!0),children:[r.jsx(wt,{className:"w-4 h-4 mr-2"}),"Create Your First Workstream"]})]}):r.jsx("div",{className:"divide-y divide-gray-100 dark:divide-slate-800",children:n.map(ee=>{var Ae,se,Pe;return r.jsxs("div",{className:"group",children:[r.jsxs("div",{className:"p-4 flex items-center gap-4 transition-colors cursor-pointer hover:bg-gray-50 dark:hover:bg-slate-900",onClick:()=>l(d===ee.id?null:ee.id),children:[r.jsx("div",{className:"w-5 h-5 flex items-center justify-center text-gray-400",children:d===ee.id?r.jsx(yr,{className:"w-4 h-4"}):r.jsx(Hr,{className:"w-4 h-4"})}),r.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-gray-100 dark:bg-slate-800",children:r.jsx(ei,{className:"w-5 h-5 text-gray-500 dark:text-slate-400"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h3",{className:"font-medium truncate text-gray-900 dark:text-white",children:ee.name}),((Ae=ee.projects)==null?void 0:Ae.length)>0&&r.jsxs("span",{className:"text-xs bg-gray-100 dark:bg-slate-800 text-gray-600 dark:text-slate-400 px-1.5 py-0.5 rounded",children:[ee.projects.length," project",ee.projects.length!==1?"s":""]}),ee.rules&&r.jsxs("span",{className:"text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 px-1.5 py-0.5 rounded",children:[r.jsx(Er,{className:"w-3 h-3 inline mr-0.5"}),"Rules"]})]}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 truncate",children:((se=ee.projects)==null?void 0:se.length)>0?ee.projects.map(Xe=>Ce(Xe)).join(", "):"No projects added"})]}),r.jsxs("div",{className:"flex items-center gap-2",onClick:Xe=>Xe.stopPropagation(),children:[r.jsx(le,{size:"sm",variant:"ghost",onClick:()=>h({...ee}),className:"text-gray-500 dark:text-slate-400 hover:text-purple-600 dark:hover:text-purple-400",title:"Edit workstream",children:r.jsx(lb,{className:"w-4 h-4"})}),r.jsx(le,{size:"sm",variant:"ghost",onClick:()=>ye(ee),className:"text-gray-500 dark:text-slate-400 hover:text-red-600 dark:hover:text-red-400",title:"Delete workstream",children:r.jsx(mn,{className:"w-4 h-4"})})]})]}),d===ee.id&&r.jsxs("div",{className:"px-4 pb-4 pl-16 space-y-4 bg-gray-50/50 dark:bg-slate-900/50",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Projects"}),r.jsxs(le,{size:"sm",variant:"outline",onClick:()=>{_(ee),w(!0)},children:[r.jsx(Li,{className:"w-4 h-4 mr-1"}),"Add Project"]})]}),((Pe=ee.projects)==null?void 0:Pe.length)>0?r.jsx("div",{className:"space-y-1",children:ee.projects.map(Xe=>r.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 bg-white dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[r.jsx("span",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:Xe.replace(/^\/Users\/[^/]+/,"~")}),r.jsx(le,{size:"sm",variant:"ghost",onClick:()=>ge(ee,Xe),className:"text-gray-400 hover:text-red-500 h-6 w-6 p-0",children:r.jsx(qM,{className:"w-4 h-4"})})]},Xe))}):r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic",children:"No projects added yet. Add projects to help organize your workstream."})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Rules"}),ee.rules?r.jsx("pre",{className:"text-sm text-gray-600 dark:text-slate-400 bg-white dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700 p-3 overflow-auto max-h-40 whitespace-pre-wrap",children:ee.rules}):r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic",children:"No rules defined. Click Edit to add context rules for this workstream."})]})]})]},ee.id)})})}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Hook Integration"}),r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx("button",{className:"text-gray-400 hover:text-gray-600 dark:hover:text-slate-300",children:r.jsx(Zu,{className:"w-4 h-4"})})}),r.jsx(Ht,{side:"right",className:"max-w-xs",children:r.jsxs("p",{className:"text-sm",children:[r.jsx("strong",{children:"What are hooks?"}),r.jsx("br",{}),r.jsx("br",{}),"Hooks are scripts that run automatically at specific points in Claude Code sessions. The workstream hook runs before each prompt and injects your active workstream's rules into the context.",r.jsx("br",{}),r.jsx("br",{}),r.jsx("strong",{children:"How it works:"}),r.jsx("br",{}),"1. You activate a workstream",r.jsx("br",{}),"2. Hook detects the active workstream",r.jsx("br",{}),"3. Rules are prepended to Claude's context",r.jsx("br",{}),"4. Claude understands your project context"]})})]})})]}),U.isInstalled?r.jsx("div",{className:"bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-800 rounded-lg p-4 text-sm text-green-700 dark:text-green-400",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ol,{className:"w-5 h-5 flex-shrink-0"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:"Hook Installed"}),r.jsx("p",{className:"text-green-600 dark:text-green-500",children:"Workstream rules will be automatically injected into every Claude session."})]})]})}):r.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-4 text-sm text-amber-700 dark:text-amber-400",children:r.jsxs("div",{className:"flex gap-3",children:[r.jsx(ii,{className:"w-5 h-5 flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"font-medium mb-1",children:"Hook Not Installed"}),r.jsx("p",{className:"mb-3",children:"Install the pre-prompt hook to automatically inject workstream rules into every Claude session."}),r.jsxs(le,{onClick:De,disabled:M||U.loading,size:"sm",className:"bg-amber-600 hover:bg-amber-700 text-white",children:[M?r.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):r.jsx(Sl,{className:"w-4 h-4 mr-2"}),"Install Hook"]}),r.jsxs("p",{className:"text-xs mt-2 text-amber-600 dark:text-amber-500",children:["Creates ",r.jsx("code",{className:"bg-amber-100 dark:bg-amber-900/50 px-1 rounded",children:"~/.claude/hooks/pre-prompt.sh"})]})]})]})})]}),q&&q.totalSessions>0&&r.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 shadow-sm p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(nM,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"}),r.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Activity Insights"})]}),r.jsxs(le,{variant:"ghost",size:"sm",onClick:je,className:"text-gray-500 dark:text-slate-400 hover:text-red-500",children:[r.jsx(mn,{className:"w-4 h-4 mr-1"}),"Clear Old"]})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-4",children:[r.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-slate-400 text-xs mb-1",children:[r.jsx(jC,{className:"w-3 h-3"}),"Sessions"]}),r.jsx("div",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:q.totalSessions})]}),r.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-slate-400 text-xs mb-1",children:[r.jsx(Er,{className:"w-3 h-3"}),"Files Tracked"]}),r.jsx("div",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:q.totalFiles})]}),r.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-slate-400 text-xs mb-1",children:[r.jsx(ei,{className:"w-3 h-3"}),"Projects Active"]}),r.jsx("div",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:q.projectCount})]})]}),((qe=q.topProjects)==null?void 0:qe.length)>0&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Most Active Projects"}),r.jsx("div",{className:"space-y-1",children:q.topProjects.slice(0,5).map((ee,Ae)=>r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-gray-600 dark:text-slate-400 truncate",title:ee.path,children:ee.path.split("/").pop()}),r.jsxs("span",{className:"text-gray-400 dark:text-slate-500 text-xs",children:[ee.fileCount," files"]})]},ee.path))})]})]}),de.length>0&&r.jsxs("div",{className:"bg-gradient-to-r from-indigo-50 to-purple-50 dark:from-indigo-950/30 dark:to-purple-950/30 rounded-xl border border-indigo-200 dark:border-indigo-800 p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Wt,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"}),r.jsx("h3",{className:"font-medium text-indigo-900 dark:text-indigo-300",children:"Suggested Workstreams"}),r.jsx("span",{className:"text-xs bg-indigo-100 dark:bg-indigo-900/50 text-indigo-600 dark:text-indigo-400 px-1.5 py-0.5 rounded",children:"Based on activity patterns"})]}),r.jsx("p",{className:"text-sm text-indigo-700 dark:text-indigo-400 mb-4",children:"These projects are frequently worked on together. Create a workstream to group them?"}),r.jsx("div",{className:"space-y-3",children:de.map(ee=>r.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg border border-indigo-200 dark:border-indigo-800 p-3",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(nd,{className:"w-4 h-4 text-amber-500"}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name}),ee.coActivityScore&&r.jsxs("span",{className:"text-xs text-gray-500 dark:text-slate-400",children:[ee.coActivityScore,"% co-activity"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(le,{size:"sm",variant:"ghost",onClick:()=>ne(ee),className:"text-gray-400 hover:text-gray-600 dark:hover:text-slate-300",title:"Dismiss suggestion",children:r.jsx(ti,{className:"w-4 h-4"})}),r.jsxs(le,{size:"sm",onClick:()=>oe(ee),className:"bg-indigo-600 hover:bg-indigo-700",children:[r.jsx(wt,{className:"w-4 h-4 mr-1"}),"Create"]})]})]}),r.jsx("div",{className:"flex flex-wrap gap-1",children:ee.projects.map(Ae=>r.jsx("span",{className:"text-xs bg-gray-100 dark:bg-slate-800 text-gray-600 dark:text-slate-400 px-2 py-0.5 rounded",children:Ae.split("/").pop()},Ae))})]},ee.name))})]}),r.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[r.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),r.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[r.jsx("p",{children:"coder-config workstream # List workstreams"}),r.jsx("p",{children:'coder-config workstream use "Name" # Set workstream for this tab'}),r.jsx("p",{children:'coder-config workstream create "Name" # Create workstream'})]})]}),r.jsx(Nt,{open:c,onOpenChange:ee=>{ee||(f(!1),y(""),E(""),A([]),O(!1),H({}))},children:r.jsxs(_t,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[r.jsx(Ct,{children:r.jsxs(St,{className:"flex items-center gap-2",children:[r.jsx(ei,{className:"w-5 h-5 text-purple-600"}),"Create Workstream"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1 block",children:"Name"}),r.jsx(lt,{value:g,onChange:ee=>y(ee.target.value),placeholder:"e.g., User Auth, Admin Dashboard",autoFocus:!0})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Projects"}),r.jsxs(le,{type:"button",size:"sm",variant:"outline",onClick:()=>O(!I),children:[r.jsx(Li,{className:"w-4 h-4 mr-1"}),"Add"]})]}),P.length>0?r.jsx("div",{className:"space-y-1 mb-2",children:P.map(ee=>r.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 bg-gray-50 dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[r.jsx("span",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:ee.replace(/^\/Users\/[^/]+/,"~")}),r.jsx(le,{type:"button",size:"sm",variant:"ghost",onClick:()=>_e(ee),className:"text-gray-400 hover:text-red-500 h-6 w-6 p-0",children:r.jsx(ti,{className:"w-4 h-4"})})]},ee))}):r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic mb-2",children:"No projects added. Add projects to help organize your workstream."}),I&&e.length>0&&r.jsx("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg p-2 max-h-64 overflow-y-auto bg-white dark:bg-slate-900",children:e.map(ee=>{const Ae=Ge(ee.path),se=$[ee.path],Pe=K[ee.path],Xe=Y[ee.path]||[],yt=P.includes(ee.path);return r.jsxs("div",{className:"mb-1",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{type:"button",onClick:()=>Ve(ee.path),className:"p-1 hover:bg-gray-100 dark:hover:bg-slate-800 rounded",title:"Show sub-projects",children:Pe?r.jsx(it,{className:"w-4 h-4 animate-spin text-gray-400"}):se?r.jsx(yr,{className:"w-4 h-4 text-gray-400"}):r.jsx(Hr,{className:"w-4 h-4 text-gray-400"})}),r.jsxs("button",{type:"button",onClick:()=>Oe(ee.path),disabled:yt,className:`flex-1 text-left p-2 rounded transition-colors ${yt?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name}),r.jsxs("div",{className:"flex items-center gap-1",children:[Ae&&r.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${Ae==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:Ae}),yt&&r.jsx(qt,{className:"w-4 h-4 text-purple-600"})]})]}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate",children:ee.path.replace(/^\/Users\/[^/]+/,"~")})]})]}),se&&Xe.length>0&&r.jsx("div",{className:"ml-6 mt-1 space-y-1 border-l-2 border-gray-200 dark:border-slate-700 pl-2",children:Xe.map(ct=>{const mt=P.includes(ct.dir),At=Ge(ct.dir);return r.jsxs("button",{type:"button",onClick:()=>Oe(ct.dir),disabled:mt,className:`w-full text-left p-2 rounded transition-colors ${mt?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-gray-700 dark:text-slate-300",children:ct.name}),r.jsxs("div",{className:"flex items-center gap-1",children:[At&&r.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${At==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:At}),mt&&r.jsx(qt,{className:"w-4 h-4 text-purple-600"})]})]}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono",children:ct.relativePath})]},ct.dir)})}),se&&Xe.length===0&&!Pe&&r.jsx("div",{className:"ml-6 mt-1 pl-2 text-xs text-gray-400 dark:text-slate-500 italic",children:"No sub-projects found"})]},ee.id)})})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1 block",children:"Context (optional)"}),r.jsx(pt,{value:j,onChange:ee=>E(ee.target.value),placeholder:"Context rules for this workstream. These will be injected into every Claude session when this workstream is active.",rows:6}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:'Example: "Focus on user authentication. Use JWT tokens. React Query for state management."'})]})]}),r.jsxs(Tt,{children:[r.jsx(le,{variant:"outline",onClick:()=>{f(!1),y(""),E(""),A([]),O(!1),H({})},children:"Cancel"}),r.jsxs(le,{onClick:we,disabled:N||!g.trim(),className:"bg-purple-600 hover:bg-purple-700",children:[N?r.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):r.jsx(wt,{className:"w-4 h-4 mr-2"}),"Create"]})]})]})}),r.jsx(Nt,{open:!!m,onOpenChange:ee=>!ee&&h(null),children:r.jsxs(_t,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[r.jsx(Ct,{children:r.jsxs(St,{className:"flex items-center gap-2",children:[r.jsx(lb,{className:"w-5 h-5 text-purple-600"}),"Edit Workstream"]})}),m&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1 block",children:"Name"}),r.jsx(lt,{value:m.name,onChange:ee=>h(Ae=>({...Ae,name:ee.target.value}))})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Projects"}),r.jsxs(le,{type:"button",size:"sm",variant:"outline",onClick:()=>h(ee=>({...ee,showPicker:!ee.showPicker})),children:[r.jsx(Li,{className:"w-4 h-4 mr-1"}),"Add"]})]}),((vt=m.projects)==null?void 0:vt.length)>0?r.jsx("div",{className:"space-y-1 mb-2",children:m.projects.map(ee=>r.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 bg-gray-50 dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[r.jsx("span",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:ee.replace(/^\/Users\/[^/]+/,"~")}),r.jsx(le,{type:"button",size:"sm",variant:"ghost",onClick:()=>h(Ae=>({...Ae,projects:Ae.projects.filter(se=>se!==ee)})),className:"text-gray-400 hover:text-red-500 h-6 w-6 p-0",children:r.jsx(ti,{className:"w-4 h-4"})})]},ee))}):r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic mb-2",children:"No projects in this workstream."}),m.showPicker&&e.length>0&&r.jsx("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg p-2 max-h-48 overflow-y-auto bg-white dark:bg-slate-900",children:e.map(ee=>{var ct;const Ae=(ct=m.projects)==null?void 0:ct.includes(ee.path),se=Ge(ee.path,m.id),Pe=$[ee.path],Xe=K[ee.path],yt=Y[ee.path]||[];return r.jsxs("div",{className:"mb-1",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{type:"button",onClick:()=>Ve(ee.path),className:"p-1 hover:bg-gray-100 dark:hover:bg-slate-800 rounded",title:"Show sub-projects",children:Xe?r.jsx(it,{className:"w-4 h-4 animate-spin text-gray-400"}):Pe?r.jsx(yr,{className:"w-4 h-4 text-gray-400"}):r.jsx(Hr,{className:"w-4 h-4 text-gray-400"})}),r.jsxs("button",{type:"button",onClick:()=>!Ae&&h(mt=>({...mt,projects:[...mt.projects||[],ee.path]})),disabled:Ae,className:`flex-1 text-left p-2 rounded transition-colors ${Ae?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name}),r.jsxs("div",{className:"flex items-center gap-1",children:[se&&r.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${se==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:se}),Ae&&r.jsx(qt,{className:"w-4 h-4 text-purple-600"})]})]}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate",children:ee.path.replace(/^\/Users\/[^/]+/,"~")})]})]}),Pe&&yt.length>0&&r.jsx("div",{className:"ml-6 mt-1 space-y-1 border-l-2 border-gray-200 dark:border-slate-700 pl-2",children:yt.map(mt=>{var or;const At=(or=m.projects)==null?void 0:or.includes(mt.dir),gt=Ge(mt.dir,m.id);return r.jsxs("button",{type:"button",onClick:()=>!At&&h(Vr=>({...Vr,projects:[...Vr.projects||[],mt.dir]})),disabled:At,className:`w-full text-left p-2 rounded transition-colors ${At?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-gray-700 dark:text-slate-300",children:mt.name}),r.jsxs("div",{className:"flex items-center gap-1",children:[gt&&r.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${gt==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:gt}),At&&r.jsx(qt,{className:"w-4 h-4 text-purple-600"})]})]}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate",children:mt.relativePath})]},mt.dir)})}),Pe&&yt.length===0&&!Xe&&r.jsx("div",{className:"ml-6 mt-1 pl-2 text-xs text-gray-400 dark:text-slate-500 italic",children:"No sub-projects found"})]},ee.id)})})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1 block",children:"Rules"}),r.jsx(pt,{value:m.rules||"",onChange:ee=>h(Ae=>({...Ae,rules:ee.target.value})),placeholder:"Context rules for this workstream...",rows:8})]})]}),r.jsxs(Tt,{children:[r.jsx(le,{variant:"outline",onClick:()=>h(null),children:"Cancel"}),r.jsxs(le,{onClick:Ie,disabled:N,className:"bg-purple-600 hover:bg-purple-700",children:[N?r.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):r.jsx(hi,{className:"w-4 h-4 mr-2"}),"Save Changes"]})]})]})}),r.jsx(Nt,{open:x,onOpenChange:ee=>{w(ee),ee||(H({}),v(new Set))},children:r.jsxs(_t,{className:"max-w-lg",children:[r.jsx(Ct,{children:r.jsxs(St,{className:"flex items-center gap-2",children:[r.jsx(Li,{className:"w-5 h-5 text-purple-600"}),"Add Project to ",k==null?void 0:k.name]})}),r.jsxs("div",{className:"py-4",children:[r.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400 mb-4",children:"Select projects to add to this workstream (multi-select enabled):"}),e.length>0?r.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto border border-gray-200 dark:border-slate-700 rounded-lg p-2 bg-white dark:bg-slate-900",children:e.map(ee=>{var mt;const Ae=(mt=k==null?void 0:k.projects)==null?void 0:mt.includes(ee.path),se=b.has(ee.path),Pe=Ge(ee.path,k==null?void 0:k.id),Xe=$[ee.path],yt=K[ee.path],ct=Y[ee.path]||[];return r.jsxs("div",{className:"mb-1",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{type:"button",onClick:()=>Ve(ee.path),className:"p-1 hover:bg-gray-100 dark:hover:bg-slate-800 rounded",title:"Show sub-projects",children:yt?r.jsx(it,{className:"w-4 h-4 animate-spin text-gray-400"}):Xe?r.jsx(yr,{className:"w-4 h-4 text-gray-400"}):r.jsx(Hr,{className:"w-4 h-4 text-gray-400"})}),r.jsxs("button",{type:"button",onClick:()=>!Ae&&ft(ee.path),disabled:Ae,className:`flex-1 text-left p-2 rounded transition-colors ${Ae?"bg-gray-100 dark:bg-slate-800 opacity-50 cursor-not-allowed":se?"bg-purple-100 dark:bg-purple-950/50 ring-2 ring-purple-500":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-4 h-4 rounded border-2 flex items-center justify-center ${Ae?"bg-gray-300 dark:bg-slate-600 border-gray-300 dark:border-slate-600":se?"bg-purple-600 border-purple-600":"border-gray-300 dark:border-slate-600"}`,children:(Ae||se)&&r.jsx(qt,{className:"w-3 h-3 text-white"})}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[Pe&&r.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${Pe==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:Pe}),Ae&&r.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400",children:"added"})]})]}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate ml-6",children:ee.path.replace(/^\/Users\/[^/]+/,"~")})]})]}),Xe&&ct.length>0&&r.jsx("div",{className:"ml-6 mt-1 space-y-1 border-l-2 border-gray-200 dark:border-slate-700 pl-2",children:ct.map(At=>{var rt;const gt=(rt=k==null?void 0:k.projects)==null?void 0:rt.includes(At.dir),or=b.has(At.dir),Vr=Ge(At.dir,k==null?void 0:k.id);return r.jsxs("button",{type:"button",onClick:()=>!gt&&ft(At.dir),disabled:gt,className:`w-full text-left p-2 rounded transition-colors ${gt?"bg-gray-100 dark:bg-slate-800 opacity-50 cursor-not-allowed":or?"bg-purple-100 dark:bg-purple-950/50 ring-2 ring-purple-500":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-4 h-4 rounded border-2 flex items-center justify-center ${gt?"bg-gray-300 dark:bg-slate-600 border-gray-300 dark:border-slate-600":or?"bg-purple-600 border-purple-600":"border-gray-300 dark:border-slate-600"}`,children:(gt||or)&&r.jsx(qt,{className:"w-3 h-3 text-white"})}),r.jsx("span",{className:"text-gray-700 dark:text-slate-300",children:At.name})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[Vr&&r.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${Vr==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:Vr}),gt&&r.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400",children:"added"})]})]}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate ml-6",children:At.relativePath})]},At.dir)})}),Xe&&ct.length===0&&!yt&&r.jsx("div",{className:"ml-6 mt-1 pl-2 text-xs text-gray-400 dark:text-slate-500 italic",children:"No sub-projects found"})]},ee.id)})}):r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 text-center py-4",children:"No projects registered. Add projects in the Projects view first."})]}),r.jsxs(Tt,{children:[r.jsx(le,{variant:"outline",onClick:()=>{w(!1),v(new Set)},children:"Cancel"}),r.jsxs(le,{onClick:Pt,disabled:b.size===0||N,className:"bg-purple-600 hover:bg-purple-700",children:[N?r.jsx(it,{className:"w-4 h-4 animate-spin mr-2"}):r.jsx(wt,{className:"w-4 h-4 mr-2"}),"Add Selected (",b.size,")"]})]})]})})]})}const zw={clarify:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",plan:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",execute:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200"},za={pending:r.jsx(pu,{className:"w-4 h-4 text-gray-500"}),running:r.jsx(DC,{className:"w-4 h-4 text-green-500"}),paused:r.jsx(RC,{className:"w-4 h-4 text-yellow-500"}),completed:r.jsx(ol,{className:"w-4 h-4 text-green-600"}),failed:r.jsx(Pu,{className:"w-4 h-4 text-red-500"}),cancelled:r.jsx(Pu,{className:"w-4 h-4 text-gray-500"})};function UH({workstreams:e=[]}){var Pt,ge,Ce,Fe,Ge,qe,vt,ee,Ae;const[t,n]=S.useState([]),[s,o]=S.useState(!0),[u,d]=S.useState(null),[l,c]=S.useState({}),[f,m]=S.useState(!1),[h,x]=S.useState(!1),[w,k]=S.useState(!1),[_,b]=S.useState(!1),[v,g]=S.useState(null),[y,j]=S.useState(""),[E,P]=S.useState(""),[A,N]=S.useState(!1),[R,I]=S.useState(50),[O,$]=S.useState(10),[H,Y]=S.useState(!1),[z,K]=S.useState([]),[G,U]=S.useState({stopHook:{},prepromptHook:{}}),[L,M]=S.useState(!1),[B,q]=S.useState(!1),[F,ae]=S.useState(null);S.useEffect(()=>{he(),me(),X()},[]);const he=async()=>{try{o(!0);const se=await ve.getLoops();n(se.loops||[]),c(se.config||{})}catch{J.error("Failed to load loops")}finally{o(!1)}},me=async()=>{try{const Pe=(await ve.getLoopConfig()).config||{};c(Pe),I(Pe.maxIterations||50),$(Pe.maxCost||10),Y(Pe.autoApprovePlan||!1)}catch(se){console.error("Failed to load config:",se)}},X=async()=>{try{const se=await ve.getLoopHookStatus();U(se)}catch(se){console.error("Failed to load hook status:",se)}},W=async()=>{try{const se=await ve.getLoopHistory();K(se.completed||[])}catch{J.error("Failed to load history")}},ce=async()=>{if(!y.trim()){J.error("Task description is required");return}try{N(!0);const se=await ve.createLoop(y,{workstreamId:E||null});se.success?(J.success("Loop created"),m(!1),j(""),P(""),he()):J.error(se.error||"Failed to create loop")}catch(se){J.error(se.message)}finally{N(!1)}},re=async se=>{try{const Pe=await ve.startLoop(se);Pe.success&&Pe.loop?(J.success("Loop started - launching Claude Code"),ae(Pe.loop),q(!0),he()):J.error(Pe.error||"Failed to start loop")}catch(Pe){J.error(Pe.message)}},Q=S.useCallback(async(se,Pe)=>{var Xe,yt,ct,mt;if(F)try{const gt=(await ve.getLoop(F.id)).loop;gt.taskComplete||gt.status==="completed"?(J.success("Loop completed successfully!"),q(!1),ae(null)):gt.status==="paused"?J.info(`Loop paused: ${gt.pauseReason||"user requested"}`):((Xe=gt.iterations)==null?void 0:Xe.current)>=((yt=gt.iterations)==null?void 0:yt.max)?(J.warning("Loop reached max iterations"),await ve.pauseLoop(gt.id)):((ct=gt.budget)==null?void 0:ct.currentCost)>=((mt=gt.budget)==null?void 0:mt.maxCost)?(J.warning("Loop reached budget limit"),await ve.pauseLoop(gt.id)):J.info("Claude exited. Click Start to continue the loop."),he()}catch(At){console.error("Failed to check loop status:",At)}},[F]),oe=async se=>{try{const Pe=await ve.pauseLoop(se);Pe.success?(J.success("Loop paused"),he()):J.error(Pe.error||"Failed to pause loop")}catch(Pe){J.error(Pe.message)}},_e=async se=>{try{const Pe=await ve.resumeLoop(se);Pe.success?(J.success("Loop resumed"),he()):J.error(Pe.error||"Failed to resume loop")}catch(Pe){J.error(Pe.message)}},Oe=async se=>{if(confirm("Cancel this loop?"))try{const Pe=await ve.cancelLoop(se);Pe.success?(J.success("Loop cancelled"),he()):J.error(Pe.error||"Failed to cancel loop")}catch(Pe){J.error(Pe.message)}},Ve=async se=>{if(confirm("Delete this loop and all its data?"))try{const Pe=await ve.deleteLoop(se);Pe.success?(J.success("Loop deleted"),he()):J.error(Pe.error||"Failed to delete loop")}catch(Pe){J.error(Pe.message)}},ne=async se=>{try{const Pe=await ve.approveLoop(se);Pe.success?(J.success("Plan approved"),he()):J.error(Pe.error||"Failed to approve plan")}catch(Pe){J.error(Pe.message)}},de=async()=>{try{N(!0);const se=await ve.updateLoopConfig({maxIterations:parseInt(R,10),maxCost:parseFloat(O),autoApprovePlan:H});se.success?(J.success("Configuration saved"),x(!1),me()):J.error(se.error||"Failed to save configuration")}catch(se){J.error(se.message)}finally{N(!1)}},je=async()=>{try{M(!0);const se=await ve.installLoopHooks();se.success?(J.success("Hooks installed successfully"),X()):J.error(se.error||"Failed to install hooks")}catch(se){J.error(se.message)}finally{M(!1)}},De=async se=>{try{const Pe=await ve.getLoop(se.id);g({...Pe.loop,clarifications:Pe.clarifications,plan:Pe.plan}),b(!0)}catch{J.error("Failed to load loop details")}},Ye=se=>{navigator.clipboard.writeText(se),J.success("Copied to clipboard")},we=se=>se?new Date(se).toLocaleString():"-",ye=se=>se.iterations?Math.min(100,se.iterations.current/se.iterations.max*100):0,Ie=se=>se.budget?Math.min(100,se.budget.currentCost/se.budget.maxCost*100):0,ft=((Pt=G.stopHook)==null?void 0:Pt.exists)&&((ge=G.prepromptHook)==null?void 0:ge.exists);return r.jsxs("div",{className:"p-6 space-y-6 max-w-6xl mx-auto",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[r.jsx(ll,{className:"w-6 h-6"}),"Ralph Loops"]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Autonomous development loops that run Claude Code until a task is completed"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",onClick:()=>{W(),k(!0)},children:[r.jsx(Tu,{className:"w-4 h-4 mr-1"}),"History"]})}),r.jsx(Ht,{children:"View completed loops"})]})}),r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsxs(le,{variant:"outline",size:"sm",onClick:()=>x(!0),children:[r.jsx(En,{className:"w-4 h-4 mr-1"}),"Config"]})}),r.jsx(Ht,{children:"Configure loop defaults"})]})}),r.jsxs(le,{onClick:()=>m(!0),children:[r.jsx(wt,{className:"w-4 h-4 mr-1"}),"New Loop"]})]})]}),!ft&&r.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(ii,{className:"w-5 h-5 text-yellow-600"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-yellow-800 dark:text-yellow-200",children:"Hooks not installed"}),r.jsx("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:"Install the Ralph Loop hooks to enable automatic loop continuation"})]})]}),r.jsxs(le,{variant:"outline",size:"sm",onClick:je,disabled:L,children:[L?r.jsx(it,{className:"w-4 h-4 animate-spin mr-1"}):null,"Install Hooks"]})]}),s?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(it,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):t.length===0?r.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[r.jsx(ll,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{className:"text-lg font-medium",children:"No loops yet"}),r.jsx("p",{className:"text-sm mt-1",children:"Create a loop to start autonomous development"})]}):r.jsx("div",{className:"space-y-3",children:t.map(se=>{var Pe,Xe,yt,ct,mt,At,gt,or;return r.jsxs("div",{className:"border rounded-lg bg-card overflow-hidden",children:[r.jsxs("div",{className:"p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>d(u===se.id?null:se.id),children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[u===se.id?r.jsx(yr,{className:"w-4 h-4 text-muted-foreground"}):r.jsx(Hr,{className:"w-4 h-4 text-muted-foreground"}),za[se.status]||za.pending,r.jsxs("div",{children:[r.jsx("h3",{className:"font-medium",children:se.name}),r.jsx("p",{className:"text-sm text-muted-foreground truncate max-w-md",children:((Pe=se.task)==null?void 0:Pe.original)||"No task"})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${zw[se.phase]||"bg-gray-100"}`,children:se.phase}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:[((Xe=se.iterations)==null?void 0:Xe.current)||0,"/",((yt=se.iterations)==null?void 0:yt.max)||50]}),r.jsxs("div",{className:"flex items-center gap-1",onClick:Vr=>Vr.stopPropagation(),children:[se.status==="pending"&&r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>re(se.id),children:r.jsx(DC,{className:"w-4 h-4"})})}),r.jsx(Ht,{children:"Start loop"})]})}),se.status==="running"&&r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>oe(se.id),children:r.jsx(RC,{className:"w-4 h-4"})})}),r.jsx(Ht,{children:"Pause loop"})]})}),se.status==="paused"&&r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>_e(se.id),children:r.jsx(I5,{className:"w-4 h-4"})})}),r.jsx(Ht,{children:"Resume loop"})]})}),se.phase==="plan"&&se.status==="running"&&r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>ne(se.id),children:r.jsx(qt,{className:"w-4 h-4"})})}),r.jsx(Ht,{children:"Approve plan"})]})}),r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>De(se),children:r.jsx(Gp,{className:"w-4 h-4"})})}),r.jsx(Ht,{children:"View details"})]})}),(se.status==="running"||se.status==="paused")&&r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>Oe(se.id),children:r.jsx(Pu,{className:"w-4 h-4"})})}),r.jsx(Ht,{children:"Cancel loop"})]})}),r.jsx(Ir,{children:r.jsxs(Gt,{children:[r.jsx(Kt,{asChild:!0,children:r.jsx(le,{variant:"ghost",size:"sm",onClick:()=>Ve(se.id),children:r.jsx(mn,{className:"w-4 h-4 text-red-500"})})}),r.jsx(Ht,{children:"Delete loop"})]})})]})]})]}),r.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground mb-1",children:[r.jsx("span",{children:"Iterations"}),r.jsxs("span",{children:[((ct=se.iterations)==null?void 0:ct.current)||0," / ",((mt=se.iterations)==null?void 0:mt.max)||50]})]}),r.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-blue-500 transition-all",style:{width:`${ye(se)}%`}})})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground mb-1",children:[r.jsx("span",{children:"Budget"}),r.jsxs("span",{children:["$",(((At=se.budget)==null?void 0:At.currentCost)||0).toFixed(2)," / $",(((gt=se.budget)==null?void 0:gt.maxCost)||10).toFixed(2)]})]}),r.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-green-500 transition-all",style:{width:`${Ie(se)}%`}})})]})]})]}),u===se.id&&r.jsxs("div",{className:"border-t p-4 bg-muted/30 space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"ID:"}),r.jsx("span",{className:"ml-2 font-mono",children:se.id}),r.jsx(le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 ml-1",onClick:()=>Ye(se.id),children:r.jsx(al,{className:"w-3 h-3"})})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Status:"}),r.jsxs("span",{className:"ml-2",children:[se.status,se.pauseReason?` (${se.pauseReason})`:""]})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Created:"}),r.jsx("span",{className:"ml-2",children:we(se.createdAt)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Updated:"}),r.jsx("span",{className:"ml-2",children:we(se.updatedAt)})]}),se.workstreamId&&r.jsxs("div",{className:"col-span-2",children:[r.jsx("span",{className:"text-muted-foreground",children:"Workstream:"}),r.jsx("span",{className:"ml-2",children:se.workstreamId})]})]}),r.jsxs("div",{className:"bg-muted p-3 rounded-md",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Terminal,{className:"w-4 h-4"}),r.jsx("span",{className:"text-sm font-medium",children:"Run this loop:"})]}),r.jsxs("code",{className:"text-xs bg-background p-2 rounded block",children:["export CODER_LOOP_ID=",se.id,r.jsx("br",{}),'claude --continue "',(or=se.task)==null?void 0:or.original,'"']})]})]})]},se.id)})}),r.jsx(Nt,{open:f,onOpenChange:m,children:r.jsxs(_t,{className:"sm:max-w-lg",children:[r.jsx(Ct,{children:r.jsx(St,{children:"Create New Loop"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Task Description"}),r.jsx(pt,{placeholder:"Describe what you want Claude to accomplish...",value:y,onChange:se=>j(se.target.value),rows:4}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Be specific about the goal. The loop will continue until this task is completed."})]}),e.length>0&&r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Workstream (optional)"}),r.jsxs("select",{className:"w-full border rounded-md p-2 bg-background",value:E,onChange:se=>P(se.target.value),children:[r.jsx("option",{value:"",children:"No workstream"}),e.map(se=>r.jsx("option",{value:se.id,children:se.name},se.id))]})]})]}),r.jsxs(Tt,{children:[r.jsx(le,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),r.jsxs(le,{onClick:ce,disabled:A||!y.trim(),children:[A?r.jsx(it,{className:"w-4 h-4 animate-spin mr-1"}):null,"Create Loop"]})]})]})}),r.jsx(Nt,{open:h,onOpenChange:x,children:r.jsxs(_t,{className:"sm:max-w-md",children:[r.jsx(Ct,{children:r.jsx(St,{children:"Loop Configuration"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),r.jsx(lt,{type:"number",value:R,onChange:se=>I(se.target.value),min:1,max:1e3}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Loop will pause after this many iterations"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Cost ($)"}),r.jsx(lt,{type:"number",value:O,onChange:se=>$(se.target.value),min:.01,step:.01}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Loop will pause when estimated cost exceeds this amount"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"checkbox",id:"autoApprovePlan",checked:H,onChange:se=>Y(se.target.checked),className:"rounded"}),r.jsx("label",{htmlFor:"autoApprovePlan",className:"text-sm",children:"Auto-approve plans (skip manual plan approval)"})]})]}),r.jsxs(Tt,{children:[r.jsx(le,{variant:"outline",onClick:()=>x(!1),children:"Cancel"}),r.jsxs(le,{onClick:de,disabled:A,children:[A?r.jsx(it,{className:"w-4 h-4 animate-spin mr-1"}):null,"Save"]})]})]})}),r.jsx(Nt,{open:w,onOpenChange:k,children:r.jsxs(_t,{className:"sm:max-w-2xl max-h-[80vh] overflow-y-auto",children:[r.jsx(Ct,{children:r.jsx(St,{children:"Loop History"})}),r.jsx("div",{className:"space-y-3 py-4",children:z.length===0?r.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No completed loops yet"}):z.slice().reverse().map(se=>r.jsxs("div",{className:"border rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[za[se.status]||za.completed,r.jsx("span",{className:"font-medium",children:se.name})]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:we(se.completedAt)})]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:se.task}),r.jsxs("div",{className:"flex gap-4 mt-2 text-xs text-muted-foreground",children:[r.jsxs("span",{children:["Iterations: ",se.totalIterations]}),r.jsxs("span",{children:["Cost: $",(se.totalCost||0).toFixed(2)]})]})]},se.id))})]})}),r.jsx(Nt,{open:_,onOpenChange:b,children:r.jsxs(_t,{className:"sm:max-w-3xl max-h-[80vh] overflow-y-auto",children:[r.jsx(Ct,{children:r.jsx(St,{children:(v==null?void 0:v.name)||"Loop Details"})}),v&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Phase"}),r.jsx("span",{className:`text-sm px-2 py-0.5 rounded-full ${zw[v.phase]||""}`,children:v.phase})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Status"}),r.jsxs("div",{className:"flex items-center gap-1",children:[za[v.status],r.jsx("span",{children:v.status})]})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Progress"}),r.jsxs("span",{children:[((Ce=v.iterations)==null?void 0:Ce.current)||0," / ",((Fe=v.iterations)==null?void 0:Fe.max)||50]})]})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Task"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm",children:(Ge=v.task)==null?void 0:Ge.original})]}),v.clarifications&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Clarifications"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-40 overflow-y-auto",children:v.clarifications})]}),v.plan&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Plan"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-60 overflow-y-auto font-mono",children:v.plan})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Run Command"}),r.jsxs("code",{className:"text-xs bg-muted p-3 rounded block",children:["export CODER_LOOP_ID=",v.id,r.jsx("br",{}),v.workstreamId&&r.jsxs(r.Fragment,{children:["export CODER_WORKSTREAM=",v.workstreamId,r.jsx("br",{})]}),'claude --continue "',(qe=v.task)==null?void 0:qe.original,'"']})]})]})]})}),r.jsx(cj,{open:B,onOpenChange:se=>{q(se),se||(ae(null),he())},title:F?`Loop: ${F.name}`:"Running Loop",description:(vt=F==null?void 0:F.task)==null?void 0:vt.original,cwd:F==null?void 0:F.projectPath,initialCommand:F?`claude --continue "${(Ae=(ee=F.task)==null?void 0:ee.original)==null?void 0:Ae.replace(/"/g,'\\"')}"`:"",env:F?{CODER_LOOP_ID:F.id,...F.workstreamId&&{CODER_WORKSTREAM:F.workstreamId}}:{},onExit:Q})]})}function GH(e,t=[]){let n=[];function s(u,d){const l=S.createContext(d);l.displayName=u+"Context";const c=n.length;n=[...n,d];const f=h=>{var v;const{scope:x,children:w,...k}=h,_=((v=x==null?void 0:x[e])==null?void 0:v[c])||l,b=S.useMemo(()=>k,Object.values(k));return r.jsx(_.Provider,{value:b,children:w})};f.displayName=u+"Provider";function m(h,x){var _;const w=((_=x==null?void 0:x[e])==null?void 0:_[c])||l,k=S.useContext(w);if(k)return k;if(d!==void 0)return d;throw new Error(`\`${h}\` must be used within \`${u}\``)}return[f,m]}const o=()=>{const u=n.map(d=>S.createContext(d));return function(l){const c=(l==null?void 0:l[e])||u;return S.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return o.scopeName=e,[s,KH(o,...t)]}function KH(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(u){const d=s.reduce((l,{useScope:c,scopeName:f})=>{const h=c(u)[`__scope${f}`];return{...l,...h}},{});return S.useMemo(()=>({[`__scope${t.scopeName}`]:d}),[d])}};return n.scopeName=t.scopeName,n}var qH=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],VN=qH.reduce((e,t)=>{const n=sd(`Primitive.${t}`),s=S.forwardRef((o,u)=>{const{asChild:d,...l}=o,c=d?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(c,{...l,ref:u})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),tx="Progress",rx=100,[YH]=GH(tx),[XH,JH]=YH(tx),UN=S.forwardRef((e,t)=>{const{__scopeProgress:n,value:s=null,max:o,getValueLabel:u=QH,...d}=e;(o||o===0)&&!Hw(o)&&console.error(ZH(`${o}`,"Progress"));const l=Hw(o)?o:rx;s!==null&&!Ww(s,l)&&console.error(eW(`${s}`,"Progress"));const c=Ww(s,l)?s:null,f=Gu(c)?u(c,l):void 0;return r.jsx(XH,{scope:n,value:c,max:l,children:r.jsx(VN.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":Gu(c)?c:void 0,"aria-valuetext":f,role:"progressbar","data-state":qN(c,l),"data-value":c??void 0,"data-max":l,...d,ref:t})})});UN.displayName=tx;var GN="ProgressIndicator",KN=S.forwardRef((e,t)=>{const{__scopeProgress:n,...s}=e,o=JH(GN,n);return r.jsx(VN.div,{"data-state":qN(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...s,ref:t})});KN.displayName=GN;function QH(e,t){return`${Math.round(e/t*100)}%`}function qN(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function Gu(e){return typeof e=="number"}function Hw(e){return Gu(e)&&!isNaN(e)&&e>0}function Ww(e,t){return Gu(e)&&!isNaN(e)&&e<=t&&e>=0}function ZH(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${rx}\`.`}function eW(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
|
|
2871
2871
|
- a positive number
|
|
2872
2872
|
- less than the value passed to \`max\` (or ${rx} if no \`max\` prop is set)
|
|
2873
2873
|
- \`null\` or \`undefined\` if the progress is indeterminate.
|
package/ui/dist/index.html
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
<!-- PWA Manifest -->
|
|
21
21
|
<link rel="manifest" href="/manifest.json">
|
|
22
|
-
<script type="module" crossorigin src="/assets/index-
|
|
22
|
+
<script type="module" crossorigin src="/assets/index-ly45ouwX.js"></script>
|
|
23
23
|
<link rel="stylesheet" crossorigin href="/assets/index-DN9CerwX.css">
|
|
24
24
|
</head>
|
|
25
25
|
<body>
|