coder-config 0.45.3 → 0.45.5
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.45.
|
|
3
|
+
"version": "0.45.5",
|
|
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",
|
|
@@ -3003,7 +3003,7 @@ ${Mr.plan}
|
|
|
3003
3003
|
|
|
3004
3004
|
`),Mr.iterationHistory&&(Zr+=`=== Recent Iterations ===
|
|
3005
3005
|
${Mr.iterationHistory}
|
|
3006
|
-
`),Mr.transcript=Zr;const qn=await ue.tuneLoopPrompt(Qr,Le.projectPath||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,Mr);qn.success?(await ue.updateLoop(Le.id,{task:{original:qn.tunedPrompt}}),Y.success("Prompt tuned and loop updated"),we(!1),await Pt(Le.id),Cr()):Y.error(qn.error||"Failed to tune prompt")}catch(Qr){Y.error(Qr.message)}finally{$(!1),Ke(null)}},Wo=async()=>{Le&&(we(!1),await gr(Le.id),Ke(null))},ee=async te=>{try{O(!0);const Me=await ue.createLoop(te,{workstreamId:q||null,projectPath:(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,maxIterations:parseInt(G,10)||50,completionPromise:K||"DONE"});Me.success?(Y.success("Loop created"),C(!1),H(""),z(""),J(De),F(dt),Q(!1),Cr()):Y.error(Me.error||"Failed to create loop")}catch(Me){Y.error(Me.message)}finally{O(!1)}},Ie=async te=>{if(Us.needsInstall){Lt(te),tr("start"),As(!0);return}await He(te)},He=async te=>{try{const Me=await ue.startLoop(te);Me.success&&Me.loop?(Y.success("Loop started - launching Claude Code"),fr(Me.loop),Wr(!0),Cr()):Y.error(Me.error||"Failed to start loop")}catch(Me){Y.error(Me.message)}},Ot=async()=>{try{Vt(!0);const te=await ue.installRalphLoopPlugin();te.success?(Y.success("ralph-loop plugin installed"),fs({installed:!0,scope:"user",needsInstall:!1}),As(!1),nt&&(ir==="resume"?await Pt(nt):await He(nt),Lt(null),tr(null))):Y.error(te.error||"Failed to install plugin")}catch(te){Y.error(te.message)}finally{Vt(!1)}},or=()=>{As(!1),Lt(null),tr(null)},jt=_.useCallback(async(te,Me)=>{var At,Sr,Qr,pt,Rr,Mr,Zr,qn,so,yi,bi,Yn,no,Wc;if(ut)try{const ft=(await ue.getLoop(ut.id)).loop;if(ft.taskComplete||ft.status==="completed")Y.success("Loop completed successfully!"),an({id:ft.id,name:ft.name,task:(At=ft.task)==null?void 0:At.original,status:"completed",iterations:((Sr=ft.iterations)==null?void 0:Sr.current)||0,maxIterations:((Qr=ft.iterations)==null?void 0:Qr.max)||50,phase:ft.phase,startedAt:ft.startedAt,completedAt:ft.completedAt||new Date().toISOString()}),ps(!0),Wr(!1),fr(null);else if(ft.status==="paused")Y.info(`Loop paused: ${ft.pauseReason||"user requested"}`),an({id:ft.id,name:ft.name,task:(pt=ft.task)==null?void 0:pt.original,status:"paused",pauseReason:ft.pauseReason,iterations:((Rr=ft.iterations)==null?void 0:Rr.current)||0,maxIterations:((Mr=ft.iterations)==null?void 0:Mr.max)||50,phase:ft.phase,startedAt:ft.startedAt,completedAt:new Date().toISOString()}),ps(!0);else if(te===0&&!Me)await ue.completeLoop(ft.id),Y.success("Loop completed successfully!"),an({id:ft.id,name:ft.name,task:(Zr=ft.task)==null?void 0:Zr.original,status:"completed",iterations:((qn=ft.iterations)==null?void 0:qn.current)||0,maxIterations:((so=ft.iterations)==null?void 0:so.max)||50,phase:"execute",startedAt:ft.startedAt,completedAt:new Date().toISOString()}),ps(!0),Wr(!1),fr(null);else if(((yi=ft.iterations)==null?void 0:yi.current)>=((bi=ft.iterations)==null?void 0:bi.max))Y.warning("Loop reached max iterations"),await ue.pauseLoop(ft.id);else{const Yo=Me?`Signal: ${Me}`:`Exit code: ${te}`;an({id:ft.id,name:ft.name,task:(Yn=ft.task)==null?void 0:Yn.original,status:"paused",pauseReason:Yo,iterations:((no=ft.iterations)==null?void 0:no.current)||0,maxIterations:((Wc=ft.iterations)==null?void 0:Wc.max)||50,phase:ft.phase,startedAt:ft.startedAt,completedAt:new Date().toISOString()}),ps(!0)}Cr()}catch(Vc){console.error("Failed to check loop status:",Vc)}},[ut]),Wt=async te=>{try{const Me=await ue.pauseLoop(te);Me.success?(Y.success("Loop paused"),Cr()):Y.error(Me.error||"Failed to pause loop")}catch(Me){Y.error(Me.message)}},gr=async te=>{if(Us.needsInstall){Lt(te),tr("resume"),As(!0);return}await Pt(te)},Pt=async te=>{try{const Me=await ue.resumeLoop(te);Me.success&&Me.loop?(Y.success("Loop resumed - launching Claude Code"),fr(Me.loop),Wr(!0),Cr()):Y.error(Me.error||"Failed to resume loop")}catch(Me){Y.error(Me.message)}},gs=async te=>{if(confirm("Cancel this loop?"))try{const Me=await ue.cancelLoop(te);Me.success?(Y.success("Loop cancelled"),Cr()):Y.error(Me.error||"Failed to cancel loop")}catch(Me){Y.error(Me.message)}},Sn=async te=>{if(confirm("Delete this loop and all its data?"))try{const Me=await ue.deleteLoop(te);Me.success?(Y.success("Loop deleted"),Cr()):Y.error(Me.error||"Failed to delete loop")}catch(Me){Y.error(Me.message)}},kn=te=>{var Me,At;L(te),Ye(te.name||""),ke(((Me=te.task)==null?void 0:Me.original)||""),Oe(((At=te.iterations)==null?void 0:At.max)||50),_e(te.completionPromise||"DONE"),ve(te.workstreamId||""),M(!0)},Kn=async()=>{if(I)try{O(!0);const te={name:Je,task:{original:ot},iterations:{max:parseInt(be,10)},completionPromise:Ee,workstreamId:oe||null},Me=await ue.updateLoop(I.id,te);Me.success?(Y.success("Loop updated"),M(!1),L(null),Cr()):Y.error(Me.error||"Failed to update loop")}catch(te){Y.error(te.message)}finally{O(!1)}},Vo=async te=>{var Me,At;try{O(!0);const Sr=await ue.createLoop(((Me=te.task)==null?void 0:Me.original)||"",{name:`${te.name} (copy)`,workstreamId:te.workstreamId||null,projectPath:te.projectPath||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,maxIterations:((At=te.iterations)==null?void 0:At.max)||50,completionPromise:te.completionPromise||"DONE"});Sr.success?(Y.success("Loop copied"),Cr()):Y.error(Sr.error||"Failed to copy loop")}catch(Sr){Y.error(Sr.message)}finally{O(!1)}},Zi=async te=>{try{const Me=await ue.approveLoop(te);Me.success?(Y.success("Plan approved"),Cr()):Y.error(Me.error||"Failed to approve plan")}catch(Me){Y.error(Me.message)}},Uo=async()=>{try{O(!0);const te=await ue.updateLoopConfig({maxIterations:parseInt(De,10),autoApprovePlan:ze,completionPromise:dt});te.success?(Y.success("Configuration saved"),y(!1),Ji()):Y.error(te.error||"Failed to save configuration")}catch(te){Y.error(te.message)}finally{O(!1)}},Nh=async()=>{try{Hr(!0);const te=await ue.installLoopHooks();te.success?(Y.success("Hooks installed successfully"),Qi()):Y.error(te.error||"Failed to install hooks")}catch(te){Y.error(te.message)}finally{Hr(!1)}},zc=async te=>{try{const Me=await ue.getLoop(te.id);T({...Me.loop,clarifications:Me.clarifications,plan:Me.plan}),E(!0)}catch{Y.error("Failed to load loop details")}},nl=te=>{navigator.clipboard.writeText(te),Y.success("Copied to clipboard")},eo=te=>te?new Date(te).toLocaleString():"-",il=te=>te.iterations?Math.min(100,te.iterations.current/te.iterations.max*100):0,to=((ol=Ht.stopHook)==null?void 0:ol.registered)&&((al=Ht.prepromptHook)==null?void 0:al.registered),Hc=te=>{if(!te)return null;const Me=f.find(At=>At.id===te);return(Me==null?void 0:Me.name)||te},Go=x?t.filter(te=>te.workstreamId===x):t,Nt=(te,Me=!1)=>{var pt,Rr;const At=((pt=te.task)==null?void 0:pt.original)||"";if((Rr=te.iterations)!=null&&Rr.max,te.completionPromise,Me){const Mr=At.replace(/\n+/g," ").substring(0,100),Zr=At.length>100?"...":"";return`claude --dangerously-skip-permissions "${Mr.replace(/"/g,'\\"')}${Zr}"`}return{startCmd:"claude --dangerously-skip-permissions",skillCmd:At}};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(cc,{className:"w-6 h-6"}),"Ralph Loops"]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Autonomous development loops using the official ralph-loop plugin"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[f.length>0&&r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(Rg,{className:"w-4 h-4 text-muted-foreground"}),r.jsxs("select",{className:"text-sm border rounded px-2 py-1 bg-background",value:x,onChange:te=>w(te.target.value),children:[r.jsx("option",{value:"",children:"All workstreams"}),f.map(te=>r.jsx("option",{value:te.id,children:te.name},te.id))]})]}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:()=>{Bo(),b(!0)},children:[r.jsx(Su,{className:"w-4 h-4 mr-1"}),"History"]})}),r.jsx(Mt,{children:"View completed loops"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:()=>y(!0),children:[r.jsx(sn,{className:"w-4 h-4 mr-1"}),"Config"]})}),r.jsx(Mt,{children:"Configure loop defaults"})]})}),r.jsxs(re,{onClick:()=>C(!0),children:[r.jsx(Rt,{className:"w-4 h-4 mr-1"}),"New Loop"]})]})]}),!to&&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($s,{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(re,{variant:"outline",size:"sm",onClick:Nh,disabled:hr,children:[hr?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Install Hooks"]})]}),n?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(Ze,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):Go.length===0?r.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[r.jsx(cc,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{className:"text-lg font-medium",children:x?"No loops in this workstream":"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:Go.map(te=>{var Me,At,Sr,Qr,pt;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:()=>u(c===te.id?null:te.id),children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[c===te.id?r.jsx(Er,{className:"w-4 h-4 text-muted-foreground"}):r.jsx(us,{className:"w-4 h-4 text-muted-foreground"}),Ca[te.status]||Ca.pending,r.jsxs("div",{children:[r.jsx("h3",{className:"font-medium",children:te.name}),r.jsx("p",{className:"text-sm text-muted-foreground truncate max-w-md",children:((Me=te.task)==null?void 0:Me.original)||"No task"})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[te.workstreamId&&r.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200 flex items-center gap-1",children:[r.jsx(Rn,{className:"w-3 h-3"}),Hc(te.workstreamId)]}),r.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${g_[te.phase]||"bg-gray-100 dark:bg-gray-800"}`,children:te.phase}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:[((At=te.iterations)==null?void 0:At.current)||0,"/",((Sr=te.iterations)==null?void 0:Sr.max)||50]}),r.jsxs("div",{className:"flex items-center gap-1",onClick:Rr=>Rr.stopPropagation(),children:[te.status==="pending"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Ie(te.id),children:r.jsx(aS,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Start loop"})]})}),te.status==="running"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Wt(te.id),children:r.jsx(xp,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Pause loop"})]})}),te.status==="paused"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>vi(te),children:r.jsx(Kd,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Resume loop"})]})}),(te.status==="cancelled"||te.status==="failed")&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>vi(te),children:r.jsx(Kd,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Restart loop"})]})}),te.phase==="plan"&&te.status==="running"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Zi(te.id),children:r.jsx($t,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Approve plan"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>kn(te),children:r.jsx(qu,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Edit loop"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Vo(te),children:r.jsx($a,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Duplicate loop"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>zc(te),children:r.jsx(Ag,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"View details"})]})}),(te.status==="running"||te.status==="paused")&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>gs(te.id),children:r.jsx(Ta,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Cancel loop"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Sn(te.id),children:r.jsx(js,{className:"w-4 h-4 text-red-500"})})}),r.jsx(Mt,{children:"Delete loop"})]})})]})]})]}),r.jsxs("div",{className:"mt-3",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:[((Qr=te.iterations)==null?void 0:Qr.current)||0," / ",((pt=te.iterations)==null?void 0:pt.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:`${il(te)}%`}})})]})]}),c===te.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:te.id}),r.jsx(re,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 ml-1",onClick:()=>nl(te.id),children:r.jsx($a,{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:[te.status,te.pauseReason?` (${te.pauseReason})`:""]})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Created:"}),r.jsx("span",{className:"ml-2",children:eo(te.createdAt)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Updated:"}),r.jsx("span",{className:"ml-2",children:eo(te.updatedAt)})]}),te.workstreamId&&r.jsxs("div",{className:"col-span-2",children:[r.jsx("span",{className:"text-muted-foreground",children:"Workstream:"}),r.jsxs("span",{className:"ml-2 inline-flex items-center gap-1",children:[r.jsx(Rn,{className:"w-3 h-3 text-purple-500"}),Hc(te.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(qt,{className:"w-4 h-4"}),r.jsx("span",{className:"text-sm font-medium",children:"Run this loop (uses official ralph-loop plugin):"})]}),r.jsx("code",{className:"text-xs bg-background p-2 rounded block whitespace-pre-wrap",children:Nt(te,!0)})]})]})]},te.id)})}),r.jsx(wt,{open:j,onOpenChange:C,children:r.jsxs(xt,{className:"sm:max-w-lg",children:[r.jsx(vt,{children:r.jsx(yt,{children:"Create New Loop"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("label",{className:"text-sm font-medium",children:"Task Description"}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:zo,disabled:V||!B.trim(),className:"h-7 text-xs",children:[V?r.jsx(Ze,{className:"w-3 h-3 animate-spin mr-1"}):r.jsx(os,{className:"w-3 h-3 mr-1"}),"Tune with AI"]})}),r.jsx(Mt,{children:r.jsx("p",{className:"max-w-xs",children:"Use Claude to optimize your prompt for Ralph Loop execution - adds clear completion signals, verification steps, and acceptance criteria."})})]})})]}),r.jsx(Ct,{placeholder:"Describe what you want Claude to accomplish...",value:B,onChange:te=>{H(te.target.value),Q(!1)},rows:4}),r.jsxs("div",{className:"flex items-center justify-between mt-1",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"Be specific about the goal. The loop will continue until this task is completed."}),ie&&r.jsxs("span",{className:"text-xs text-green-600 dark:text-green-400 flex items-center gap-1",children:[r.jsx(Yt,{className:"w-3 h-3"}),"AI-tuned"]})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Project"}),r.jsx("div",{className:"text-sm p-2 bg-muted rounded-md",children:e?r.jsx("span",{className:"font-mono",children:e.name||e.path||e.dir}):r.jsx("span",{className:"text-muted-foreground",children:"No project selected - loop will run in server directory"})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),r.jsx(ct,{type:"number",value:G,onChange:te=>J(te.target.value),min:1,max:1e3}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Safety limit for the loop"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Completion Promise"}),r.jsx(ct,{value:K,onChange:te=>F(te.target.value),placeholder:"DONE"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Text that signals completion"})]})]}),f.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:q,onChange:te=>z(te.target.value),children:[r.jsx("option",{value:"",children:"No workstream"}),f.map(te=>r.jsx("option",{value:te.id,children:te.name},te.id))]})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),r.jsxs(re,{onClick:$o,disabled:R||!B.trim(),children:[R?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Create Loop"]})]})]})}),r.jsx(wt,{open:N,onOpenChange:M,children:r.jsxs(xt,{className:"sm:max-w-lg",children:[r.jsx(vt,{children:r.jsx(yt,{children:"Edit 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:"Name"}),r.jsx(ct,{placeholder:"Loop name",value:Je,onChange:te=>Ye(te.target.value)})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("label",{className:"text-sm font-medium",children:"Task Description"}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:async()=>{if(!ot.trim()){Y.error("Enter a task description first");return}try{$(!0),ce(ot),ye("edit");const te=await ue.tuneLoopPrompt(ot,(I==null?void 0:I.projectPath)||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null);te.success?(X(te.tunedPrompt),de(!0)):Y.error(te.error||"Failed to tune prompt")}catch(te){Y.error(te.message)}finally{$(!1)}},disabled:V||!ot.trim(),className:"h-7 text-xs",children:[V?r.jsx(Ze,{className:"w-3 h-3 animate-spin mr-1"}):r.jsx(os,{className:"w-3 h-3 mr-1"}),"Tune with AI"]})}),r.jsx(Mt,{children:r.jsx("p",{className:"max-w-xs",children:"Use Claude to optimize your prompt for Ralph Loop execution."})})]})})]}),r.jsx(Ct,{placeholder:"Describe what you want Claude to accomplish...",value:ot,onChange:te=>ke(te.target.value),rows:4})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),r.jsx(ct,{type:"number",value:be,onChange:te=>Oe(te.target.value),min:1,max:1e3})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Completion Promise"}),r.jsx(ct,{value:Ee,onChange:te=>_e(te.target.value),placeholder:"DONE"})]})]}),f.length>0&&r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Workstream"}),r.jsxs("select",{className:"w-full border rounded-md p-2 bg-background",value:oe,onChange:te=>ve(te.target.value),children:[r.jsx("option",{value:"",children:"No workstream"}),f.map(te=>r.jsx("option",{value:te.id,children:te.name},te.id))]})]}),I&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:[r.jsxs("span",{children:["ID: ",I.id]}),r.jsx("span",{className:"mx-2",children:"|"}),r.jsxs("span",{children:["Status: ",I.status]}),r.jsx("span",{className:"mx-2",children:"|"}),r.jsxs("span",{children:["Phase: ",I.phase]})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>M(!1),children:"Cancel"}),r.jsxs(re,{onClick:Kn,disabled:R||!ot.trim(),children:[R?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Save Changes"]})]})]})}),r.jsx(wt,{open:v,onOpenChange:y,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsx(yt,{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(ct,{type:"number",value:De,onChange:te=>Be(te.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:"Default Completion Promise"}),r.jsx(ct,{value:dt,onChange:te=>er(te.target.value),placeholder:"DONE"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Default text that signals loop completion (used with official ralph-loop plugin)"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"checkbox",id:"autoApprovePlan",checked:ze,onChange:te=>St(te.target.checked),className:"rounded"}),r.jsx("label",{htmlFor:"autoApprovePlan",className:"text-sm",children:"Auto-approve plans (skip manual plan approval)"})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),r.jsxs(re,{onClick:Uo,disabled:R,children:[R?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Save"]})]})]})}),r.jsx(wt,{open:g,onOpenChange:b,children:r.jsxs(xt,{className:"sm:max-w-2xl max-h-[80vh] overflow-y-auto",children:[r.jsx(vt,{children:r.jsx(yt,{children:"Loop History"})}),r.jsx("div",{className:"space-y-3 py-4",children:wr.length===0?r.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No completed loops yet"}):wr.slice().reverse().map(te=>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:[Ca[te.status]||Ca.completed,r.jsx("span",{className:"font-medium",children:te.name})]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:eo(te.completedAt)})]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:te.task}),r.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:r.jsxs("span",{children:["Iterations: ",te.totalIterations]})})]},te.id))})]})}),r.jsx(wt,{open:k,onOpenChange:E,children:r.jsxs(xt,{className:"sm:max-w-3xl max-h-[80vh] overflow-y-auto",children:[r.jsx(vt,{children:r.jsx(yt,{children:(P==null?void 0:P.name)||"Loop Details"})}),P&&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 ${g_[P.phase]||""}`,children:P.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:[Ca[P.status],r.jsx("span",{children:P.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:[((Ko=P.iterations)==null?void 0:Ko.current)||0," / ",((ll=P.iterations)==null?void 0:ll.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:(cl=P.task)==null?void 0:cl.original})]}),P.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:P.clarifications})]}),P.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:P.plan})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Max Iterations"}),r.jsx("div",{className:"bg-muted p-2 rounded text-sm",children:((dl=P.iterations)==null?void 0:dl.max)||50})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Completion Promise"}),r.jsxs("div",{className:"bg-muted p-2 rounded text-sm font-mono",children:["<promise>",P.completionPromise||"DONE","</promise>"]})]})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Run Command (uses official ralph-loop plugin)"}),r.jsx("code",{className:"text-xs bg-muted p-3 rounded block whitespace-pre-wrap",children:Nt(P,!0)})]})]})]})}),r.jsx(wt,{open:Ps,onOpenChange:As,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[r.jsx(ui,{className:"w-5 h-5"}),"Install ralph-loop Plugin"]})}),r.jsxs("div",{className:"py-4",children:[r.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["The ",r.jsx("code",{className:"bg-muted px-1 rounded",children:"ralph-loop"})," plugin is required to run loops. This plugin provides the ",r.jsx("code",{className:"bg-muted px-1 rounded",children:"/ralph-loop"})," command that enables autonomous iteration."]}),Us.scope==="project"&&r.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded p-3 mb-4",children:r.jsxs("p",{className:"text-sm text-yellow-800 dark:text-yellow-200",children:["Plugin is currently installed only for project: ",r.jsx("br",{}),r.jsx("code",{className:"text-xs",children:Us.projectPath})]})}),r.jsx("p",{className:"text-sm",children:"Install the plugin globally (user scope) to use loops from any project?"})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:or,disabled:ms,children:"Cancel"}),r.jsx(re,{onClick:Ot,disabled:ms,children:ms?r.jsxs(r.Fragment,{children:[r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}),"Installing..."]}):r.jsxs(r.Fragment,{children:[r.jsx(ui,{className:"w-4 h-4 mr-1"}),"Install Plugin"]})})]})]})}),r.jsx(Lj,{open:rr,onOpenChange:te=>{Wr(te),te||(fr(null),Cr())},title:ut?`Loop: ${ut.name}`:"Running Loop",description:ut?((ro=(qo=ut.task)==null?void 0:qo.original)==null?void 0:ro.substring(0,100))+(((dn=(cn=ut.task)==null?void 0:cn.original)==null?void 0:dn.length)>100?"...":""):"",cwd:ut==null?void 0:ut.projectPath,initialCommand:ut?Nt(ut).startCmd:"",delayedCommand:ut?Nt(ut).skillCmd:"",delayedCommandDelay:5e3,env:ut?{CODER_LOOP_ID:ut.id,...ut.workstreamId&&{CODER_WORKSTREAM:ut.workstreamId}}:{},onExit:jt,headerExtra:r.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer select-none",children:[r.jsx("input",{type:"checkbox",checked:Xr,onChange:te=>Jr(te.target.checked),className:"rounded"}),"Auto-close when done"]})}),r.jsx(wt,{open:se,onOpenChange:de,children:r.jsxs(xt,{className:"sm:max-w-2xl max-h-[80vh] overflow-y-auto",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[r.jsx(os,{className:"w-5 h-5 text-purple-500"}),"AI-Tuned Prompt"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2 text-muted-foreground",children:"Original Prompt"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-32 overflow-y-auto",children:W})]}),r.jsxs("div",{children:[r.jsxs("h4",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[r.jsx(Yt,{className:"w-4 h-4 text-purple-500"}),"Tuned Prompt"]}),r.jsx(Ct,{value:pe,onChange:te=>X(te.target.value),rows:10,className:"font-mono text-sm"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"You can edit the tuned prompt before accepting it."})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:Ho,children:"Keep Original"}),r.jsxs(re,{onClick:ln,children:[r.jsx($t,{className:"w-4 h-4 mr-1"}),"Use Tuned Prompt"]})]})]})}),r.jsx(wt,{open:le,onOpenChange:we,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[r.jsx(Kd,{className:"w-5 h-5"}),"Resume Loop"]})}),r.jsx("div",{className:"py-4",children:Le&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"text-sm mb-4",children:["This loop ",Le.status==="failed"?"failed":Le.status==="cancelled"?"was cancelled":"was paused",Le.pauseReason&&`: ${Le.pauseReason}`]}),r.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Would you like to tune the prompt with AI before resuming? This can help add guardrails based on what went wrong."}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm max-h-32 overflow-y-auto",children:(un=Le.task)==null?void 0:un.original})]})}),r.jsxs(kt,{className:"flex-col sm:flex-row gap-2",children:[r.jsx(re,{variant:"outline",onClick:()=>{we(!1),Ke(null)},children:"Cancel"}),r.jsx(re,{variant:"secondary",onClick:Wo,children:"Resume As-Is"}),r.jsxs(re,{onClick:Ut,disabled:V,children:[V?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):r.jsx(os,{className:"w-4 h-4 mr-1"}),"Tune & Resume"]})]})]})}),r.jsx(wt,{open:sl,onOpenChange:ps,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[(Qe==null?void 0:Qe.status)==="completed"&&r.jsxs(r.Fragment,{children:[r.jsx(No,{className:"w-5 h-5 text-green-600"})," Loop Completed"]}),(Qe==null?void 0:Qe.status)==="paused"&&r.jsxs(r.Fragment,{children:[r.jsx(xp,{className:"w-5 h-5 text-yellow-500"})," Loop Paused"]}),(Qe==null?void 0:Qe.status)==="failed"&&r.jsxs(r.Fragment,{children:[r.jsx(Ta,{className:"w-5 h-5 text-red-500"})," Loop Failed"]}),(Qe==null?void 0:Qe.status)==="cancelled"&&r.jsxs(r.Fragment,{children:[r.jsx(Ta,{className:"w-5 h-5 text-gray-500"})," Loop Cancelled"]})]})}),Qe&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-1",children:"Task"}),r.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-2 rounded",children:Qe.task})]}),Qe.pauseReason&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-1",children:"Reason"}),r.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-2 rounded",children:Qe.pauseReason})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-sm",children:[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:"font-medium flex items-center gap-1",children:[Ca[Qe.status],r.jsx("span",{className:"capitalize",children:Qe.status})]})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Iterations"}),r.jsxs("div",{className:"font-medium",children:[Qe.iterations," / ",Qe.maxIterations]})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Duration"}),r.jsx("div",{className:"font-medium",children:Qe.duration!=null?Qe.duration<60?`${Qe.duration}s`:Qe.duration<3600?`${Math.floor(Qe.duration/60)}m ${Qe.duration%60}s`:`${Math.floor(Qe.duration/3600)}h ${Math.floor(Qe.duration%3600/60)}m`:"-"})]})]}),r.jsxs("div",{className:"text-xs text-muted-foreground",children:[Qe.status==="completed"?"Completed":"Stopped"," at ",eo(Qe.completedAt)]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>ps(!1),children:"Close"}),((Qe==null?void 0:Qe.status)==="paused"||(Qe==null?void 0:Qe.status)==="failed"||(Qe==null?void 0:Qe.status)==="cancelled")&&r.jsxs(re,{onClick:()=>{if(ps(!1),Qe!=null&&Qe.id){const te=t.find(Me=>Me.id===Qe.id);te&&vi(te)}},children:[r.jsx(Kd,{className:"w-4 h-4 mr-1"}),(Qe==null?void 0:Qe.status)==="paused"?"Resume":"Restart"]}),r.jsx(re,{variant:"secondary",onClick:()=>{if(ps(!1),Qe!=null&&Qe.id){const te=t.find(Me=>Me.id===Qe.id);te&&zc(te)}},children:"View Details"})]})]})})]})}function pW(e,t=[]){let s=[];function n(c,u){const l=_.createContext(u);l.displayName=c+"Context";const d=s.length;s=[...s,u];const f=h=>{var y;const{scope:x,children:w,...j}=h,C=((y=x==null?void 0:x[e])==null?void 0:y[d])||l,v=_.useMemo(()=>j,Object.values(j));return r.jsx(C.Provider,{value:v,children:w})};f.displayName=c+"Provider";function m(h,x){var C;const w=((C=x==null?void 0:x[e])==null?void 0:C[d])||l,j=_.useContext(w);if(j)return j;if(u!==void 0)return u;throw new Error(`\`${h}\` must be used within \`${c}\``)}return[f,m]}const o=()=>{const c=s.map(u=>_.createContext(u));return function(l){const d=(l==null?void 0:l[e])||c;return _.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return o.scopeName=e,[n,gW(o,...t)]}function gW(...e){const t=e[0];if(e.length===1)return t;const s=()=>{const n=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(c){const u=n.reduce((l,{useScope:d,scopeName:f})=>{const h=d(c)[`__scope${f}`];return{...l,...h}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:u}),[u])}};return s.scopeName=t.scopeName,s}var xW=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],v2=xW.reduce((e,t)=>{const s=Yu(`Primitive.${t}`),n=_.forwardRef((o,c)=>{const{asChild:u,...l}=o,d=u?s:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...l,ref:c})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Wx="Progress",Vx=100,[vW]=pW(Wx),[yW,bW]=vW(Wx),y2=_.forwardRef((e,t)=>{const{__scopeProgress:s,value:n=null,max:o,getValueLabel:c=wW,...u}=e;(o||o===0)&&!x_(o)&&console.error(_W(`${o}`,"Progress"));const l=x_(o)?o:Vx;n!==null&&!v_(n,l)&&console.error(CW(`${n}`,"Progress"));const d=v_(n,l)?n:null,f=Bu(d)?c(d,l):void 0;return r.jsx(yW,{scope:s,value:d,max:l,children:r.jsx(v2.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":Bu(d)?d:void 0,"aria-valuetext":f,role:"progressbar","data-state":_2(d,l),"data-value":d??void 0,"data-max":l,...u,ref:t})})});y2.displayName=Wx;var b2="ProgressIndicator",w2=_.forwardRef((e,t)=>{const{__scopeProgress:s,...n}=e,o=bW(b2,s);return r.jsx(v2.div,{"data-state":_2(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...n,ref:t})});w2.displayName=b2;function wW(e,t){return`${Math.round(e/t*100)}%`}function _2(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function Bu(e){return typeof e=="number"}function x_(e){return Bu(e)&&!isNaN(e)&&e>0}function v_(e,t){return Bu(e)&&!isNaN(e)&&e<=t&&e>=0}function _W(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${Vx}\`.`}function CW(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
|
|
3006
|
+
`),Mr.transcript=Zr;const qn=await ue.tuneLoopPrompt(Qr,Le.projectPath||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,Mr);qn.success?(await ue.updateLoop(Le.id,{task:{original:qn.tunedPrompt}}),Y.success("Prompt tuned and loop updated"),we(!1),await Pt(Le.id),Cr()):Y.error(qn.error||"Failed to tune prompt")}catch(Qr){Y.error(Qr.message)}finally{$(!1),Ke(null)}},Wo=async()=>{Le&&(we(!1),await gr(Le.id),Ke(null))},ee=async te=>{try{O(!0);const Me=await ue.createLoop(te,{workstreamId:q||null,projectPath:(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,maxIterations:parseInt(G,10)||50,completionPromise:K||"DONE"});Me.success?(Y.success("Loop created"),C(!1),H(""),z(""),J(De),F(dt),Q(!1),Cr()):Y.error(Me.error||"Failed to create loop")}catch(Me){Y.error(Me.message)}finally{O(!1)}},Ie=async te=>{if(Us.needsInstall){Lt(te),tr("start"),As(!0);return}await He(te)},He=async te=>{try{const Me=await ue.startLoop(te);Me.success&&Me.loop?(Y.success("Loop started - launching Claude Code"),fr(Me.loop),Wr(!0),Cr()):Y.error(Me.error||"Failed to start loop")}catch(Me){Y.error(Me.message)}},Ot=async()=>{try{Vt(!0);const te=await ue.installRalphLoopPlugin();te.success?(Y.success("ralph-loop plugin installed"),fs({installed:!0,scope:"user",needsInstall:!1}),As(!1),nt&&(ir==="resume"?await Pt(nt):await He(nt),Lt(null),tr(null))):Y.error(te.error||"Failed to install plugin")}catch(te){Y.error(te.message)}finally{Vt(!1)}},or=()=>{As(!1),Lt(null),tr(null)},jt=_.useCallback(async(te,Me)=>{var At,Sr,Qr,pt,Rr,Mr,Zr,qn,so,yi,bi,Yn,no,Wc;if(ut)try{const ft=(await ue.getLoop(ut.id)).loop;if(ft.taskComplete||ft.status==="completed")Y.success("Loop completed successfully!"),an({id:ft.id,name:ft.name,task:(At=ft.task)==null?void 0:At.original,status:"completed",iterations:((Sr=ft.iterations)==null?void 0:Sr.current)||0,maxIterations:((Qr=ft.iterations)==null?void 0:Qr.max)||50,phase:ft.phase,startedAt:ft.startedAt,completedAt:ft.completedAt||new Date().toISOString()}),ps(!0),Wr(!1),fr(null);else if(ft.status==="paused")Y.info(`Loop paused: ${ft.pauseReason||"user requested"}`),an({id:ft.id,name:ft.name,task:(pt=ft.task)==null?void 0:pt.original,status:"paused",pauseReason:ft.pauseReason,iterations:((Rr=ft.iterations)==null?void 0:Rr.current)||0,maxIterations:((Mr=ft.iterations)==null?void 0:Mr.max)||50,phase:ft.phase,startedAt:ft.startedAt,completedAt:new Date().toISOString()}),ps(!0);else if(te===0&&!Me)await ue.completeLoop(ft.id),Y.success("Loop completed successfully!"),an({id:ft.id,name:ft.name,task:(Zr=ft.task)==null?void 0:Zr.original,status:"completed",iterations:((qn=ft.iterations)==null?void 0:qn.current)||0,maxIterations:((so=ft.iterations)==null?void 0:so.max)||50,phase:"execute",startedAt:ft.startedAt,completedAt:new Date().toISOString()}),ps(!0),Wr(!1),fr(null);else if(((yi=ft.iterations)==null?void 0:yi.current)>=((bi=ft.iterations)==null?void 0:bi.max))Y.warning("Loop reached max iterations"),await ue.pauseLoop(ft.id);else{const Yo=Me?`Signal: ${Me}`:`Exit code: ${te}`;an({id:ft.id,name:ft.name,task:(Yn=ft.task)==null?void 0:Yn.original,status:"paused",pauseReason:Yo,iterations:((no=ft.iterations)==null?void 0:no.current)||0,maxIterations:((Wc=ft.iterations)==null?void 0:Wc.max)||50,phase:ft.phase,startedAt:ft.startedAt,completedAt:new Date().toISOString()}),ps(!0)}Cr()}catch(Vc){console.error("Failed to check loop status:",Vc)}},[ut]),Wt=async te=>{try{const Me=await ue.pauseLoop(te);Me.success?(Y.success("Loop paused"),Cr()):Y.error(Me.error||"Failed to pause loop")}catch(Me){Y.error(Me.message)}},gr=async te=>{if(Us.needsInstall){Lt(te),tr("resume"),As(!0);return}await Pt(te)},Pt=async te=>{try{const Me=await ue.resumeLoop(te);Me.success&&Me.loop?(Y.success("Loop resumed - launching Claude Code"),fr(Me.loop),Wr(!0),Cr()):Y.error(Me.error||"Failed to resume loop")}catch(Me){Y.error(Me.message)}},gs=async te=>{if(confirm("Cancel this loop?"))try{const Me=await ue.cancelLoop(te);Me.success?(Y.success("Loop cancelled"),Cr()):Y.error(Me.error||"Failed to cancel loop")}catch(Me){Y.error(Me.message)}},Sn=async te=>{if(confirm("Delete this loop and all its data?"))try{const Me=await ue.deleteLoop(te);Me.success?(Y.success("Loop deleted"),Cr()):Y.error(Me.error||"Failed to delete loop")}catch(Me){Y.error(Me.message)}},kn=te=>{var Me,At;L(te),Ye(te.name||""),ke(((Me=te.task)==null?void 0:Me.original)||""),Oe(((At=te.iterations)==null?void 0:At.max)||50),_e(te.completionPromise||"DONE"),ve(te.workstreamId||""),M(!0)},Kn=async()=>{if(I)try{O(!0);const te={name:Je,task:{original:ot},iterations:{max:parseInt(be,10)},completionPromise:Ee,workstreamId:oe||null},Me=await ue.updateLoop(I.id,te);Me.success?(Y.success("Loop updated"),M(!1),L(null),Cr()):Y.error(Me.error||"Failed to update loop")}catch(te){Y.error(te.message)}finally{O(!1)}},Vo=async te=>{var Me,At;try{O(!0);const Sr=await ue.createLoop(((Me=te.task)==null?void 0:Me.original)||"",{name:`${te.name} (copy)`,workstreamId:te.workstreamId||null,projectPath:te.projectPath||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,maxIterations:((At=te.iterations)==null?void 0:At.max)||50,completionPromise:te.completionPromise||"DONE"});Sr.success?(Y.success("Loop copied"),Cr()):Y.error(Sr.error||"Failed to copy loop")}catch(Sr){Y.error(Sr.message)}finally{O(!1)}},Zi=async te=>{try{const Me=await ue.approveLoop(te);Me.success?(Y.success("Plan approved"),Cr()):Y.error(Me.error||"Failed to approve plan")}catch(Me){Y.error(Me.message)}},Uo=async()=>{try{O(!0);const te=await ue.updateLoopConfig({maxIterations:parseInt(De,10),autoApprovePlan:ze,completionPromise:dt});te.success?(Y.success("Configuration saved"),y(!1),Ji()):Y.error(te.error||"Failed to save configuration")}catch(te){Y.error(te.message)}finally{O(!1)}},Nh=async()=>{try{Hr(!0);const te=await ue.installLoopHooks();te.success?(Y.success("Hooks installed successfully"),Qi()):Y.error(te.error||"Failed to install hooks")}catch(te){Y.error(te.message)}finally{Hr(!1)}},zc=async te=>{try{const Me=await ue.getLoop(te.id);T({...Me.loop,clarifications:Me.clarifications,plan:Me.plan}),E(!0)}catch{Y.error("Failed to load loop details")}},nl=te=>{navigator.clipboard.writeText(te),Y.success("Copied to clipboard")},eo=te=>te?new Date(te).toLocaleString():"-",il=te=>te.iterations?Math.min(100,te.iterations.current/te.iterations.max*100):0,to=((ol=Ht.stopHook)==null?void 0:ol.registered)&&((al=Ht.prepromptHook)==null?void 0:al.registered),Hc=te=>{if(!te)return null;const Me=f.find(At=>At.id===te);return(Me==null?void 0:Me.name)||te},Go=x?t.filter(te=>te.workstreamId===x):t,Nt=(te,Me=!1)=>{var pt,Rr;const At=((pt=te.task)==null?void 0:pt.original)||"";if((Rr=te.iterations)!=null&&Rr.max,te.completionPromise,Me){const Mr=At.replace(/\n+/g," ").substring(0,100),Zr=At.length>100?"...":"";return`claude --dangerously-skip-permissions "${Mr.replace(/"/g,'\\"')}${Zr}"`}return{startCmd:"claude --dangerously-skip-permissions",skillCmd:At}};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(cc,{className:"w-6 h-6"}),"Ralph Loops"]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Autonomous development loops with iteration tracking and safety controls"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[f.length>0&&r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(Rg,{className:"w-4 h-4 text-muted-foreground"}),r.jsxs("select",{className:"text-sm border rounded px-2 py-1 bg-background",value:x,onChange:te=>w(te.target.value),children:[r.jsx("option",{value:"",children:"All workstreams"}),f.map(te=>r.jsx("option",{value:te.id,children:te.name},te.id))]})]}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:()=>{Bo(),b(!0)},children:[r.jsx(Su,{className:"w-4 h-4 mr-1"}),"History"]})}),r.jsx(Mt,{children:"View completed loops"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:()=>y(!0),children:[r.jsx(sn,{className:"w-4 h-4 mr-1"}),"Config"]})}),r.jsx(Mt,{children:"Configure loop defaults"})]})}),r.jsxs(re,{onClick:()=>C(!0),children:[r.jsx(Rt,{className:"w-4 h-4 mr-1"}),"New Loop"]})]})]}),!to&&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($s,{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(re,{variant:"outline",size:"sm",onClick:Nh,disabled:hr,children:[hr?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Install Hooks"]})]}),n?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(Ze,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):Go.length===0?r.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[r.jsx(cc,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{className:"text-lg font-medium",children:x?"No loops in this workstream":"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:Go.map(te=>{var Me,At,Sr,Qr,pt;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:()=>u(c===te.id?null:te.id),children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[c===te.id?r.jsx(Er,{className:"w-4 h-4 text-muted-foreground"}):r.jsx(us,{className:"w-4 h-4 text-muted-foreground"}),Ca[te.status]||Ca.pending,r.jsxs("div",{children:[r.jsx("h3",{className:"font-medium",children:te.name}),r.jsx("p",{className:"text-sm text-muted-foreground truncate max-w-md",children:((Me=te.task)==null?void 0:Me.original)||"No task"})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[te.workstreamId&&r.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200 flex items-center gap-1",children:[r.jsx(Rn,{className:"w-3 h-3"}),Hc(te.workstreamId)]}),r.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${g_[te.phase]||"bg-gray-100 dark:bg-gray-800"}`,children:te.phase}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:[((At=te.iterations)==null?void 0:At.current)||0,"/",((Sr=te.iterations)==null?void 0:Sr.max)||50]}),r.jsxs("div",{className:"flex items-center gap-1",onClick:Rr=>Rr.stopPropagation(),children:[te.status==="pending"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Ie(te.id),children:r.jsx(aS,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Start loop"})]})}),te.status==="running"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Wt(te.id),children:r.jsx(xp,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Pause loop"})]})}),te.status==="paused"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>vi(te),children:r.jsx(Kd,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Resume loop"})]})}),(te.status==="cancelled"||te.status==="failed")&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>vi(te),children:r.jsx(Kd,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Restart loop"})]})}),te.phase==="plan"&&te.status==="running"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Zi(te.id),children:r.jsx($t,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Approve plan"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>kn(te),children:r.jsx(qu,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Edit loop"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Vo(te),children:r.jsx($a,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Duplicate loop"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>zc(te),children:r.jsx(Ag,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"View details"})]})}),(te.status==="running"||te.status==="paused")&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>gs(te.id),children:r.jsx(Ta,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Cancel loop"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Sn(te.id),children:r.jsx(js,{className:"w-4 h-4 text-red-500"})})}),r.jsx(Mt,{children:"Delete loop"})]})})]})]})]}),r.jsxs("div",{className:"mt-3",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:[((Qr=te.iterations)==null?void 0:Qr.current)||0," / ",((pt=te.iterations)==null?void 0:pt.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:`${il(te)}%`}})})]})]}),c===te.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:te.id}),r.jsx(re,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 ml-1",onClick:()=>nl(te.id),children:r.jsx($a,{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:[te.status,te.pauseReason?` (${te.pauseReason})`:""]})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Created:"}),r.jsx("span",{className:"ml-2",children:eo(te.createdAt)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Updated:"}),r.jsx("span",{className:"ml-2",children:eo(te.updatedAt)})]}),te.workstreamId&&r.jsxs("div",{className:"col-span-2",children:[r.jsx("span",{className:"text-muted-foreground",children:"Workstream:"}),r.jsxs("span",{className:"ml-2 inline-flex items-center gap-1",children:[r.jsx(Rn,{className:"w-3 h-3 text-purple-500"}),Hc(te.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(qt,{className:"w-4 h-4"}),r.jsx("span",{className:"text-sm font-medium",children:"Run this loop (uses official ralph-loop plugin):"})]}),r.jsx("code",{className:"text-xs bg-background p-2 rounded block whitespace-pre-wrap",children:Nt(te,!0)})]})]})]},te.id)})}),r.jsx(wt,{open:j,onOpenChange:C,children:r.jsxs(xt,{className:"sm:max-w-lg",children:[r.jsx(vt,{children:r.jsx(yt,{children:"Create New Loop"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("label",{className:"text-sm font-medium",children:"Task Description"}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:zo,disabled:V||!B.trim(),className:"h-7 text-xs",children:[V?r.jsx(Ze,{className:"w-3 h-3 animate-spin mr-1"}):r.jsx(os,{className:"w-3 h-3 mr-1"}),"Tune with AI"]})}),r.jsx(Mt,{children:r.jsx("p",{className:"max-w-xs",children:"Use Claude to optimize your prompt for Ralph Loop execution - adds clear completion signals, verification steps, and acceptance criteria."})})]})})]}),r.jsx(Ct,{placeholder:"Describe what you want Claude to accomplish...",value:B,onChange:te=>{H(te.target.value),Q(!1)},rows:4}),r.jsxs("div",{className:"flex items-center justify-between mt-1",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"Be specific about the goal. The loop will continue until this task is completed."}),ie&&r.jsxs("span",{className:"text-xs text-green-600 dark:text-green-400 flex items-center gap-1",children:[r.jsx(Yt,{className:"w-3 h-3"}),"AI-tuned"]})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Project"}),r.jsx("div",{className:"text-sm p-2 bg-muted rounded-md",children:e?r.jsx("span",{className:"font-mono",children:e.name||e.path||e.dir}):r.jsx("span",{className:"text-muted-foreground",children:"No project selected - loop will run in server directory"})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),r.jsx(ct,{type:"number",value:G,onChange:te=>J(te.target.value),min:1,max:1e3}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Safety limit for the loop"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Completion Promise"}),r.jsx(ct,{value:K,onChange:te=>F(te.target.value),placeholder:"DONE"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Text that signals completion"})]})]}),f.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:q,onChange:te=>z(te.target.value),children:[r.jsx("option",{value:"",children:"No workstream"}),f.map(te=>r.jsx("option",{value:te.id,children:te.name},te.id))]})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),r.jsxs(re,{onClick:$o,disabled:R||!B.trim(),children:[R?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Create Loop"]})]})]})}),r.jsx(wt,{open:N,onOpenChange:M,children:r.jsxs(xt,{className:"sm:max-w-lg",children:[r.jsx(vt,{children:r.jsx(yt,{children:"Edit 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:"Name"}),r.jsx(ct,{placeholder:"Loop name",value:Je,onChange:te=>Ye(te.target.value)})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("label",{className:"text-sm font-medium",children:"Task Description"}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:async()=>{if(!ot.trim()){Y.error("Enter a task description first");return}try{$(!0),ce(ot),ye("edit");const te=await ue.tuneLoopPrompt(ot,(I==null?void 0:I.projectPath)||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null);te.success?(X(te.tunedPrompt),de(!0)):Y.error(te.error||"Failed to tune prompt")}catch(te){Y.error(te.message)}finally{$(!1)}},disabled:V||!ot.trim(),className:"h-7 text-xs",children:[V?r.jsx(Ze,{className:"w-3 h-3 animate-spin mr-1"}):r.jsx(os,{className:"w-3 h-3 mr-1"}),"Tune with AI"]})}),r.jsx(Mt,{children:r.jsx("p",{className:"max-w-xs",children:"Use Claude to optimize your prompt for Ralph Loop execution."})})]})})]}),r.jsx(Ct,{placeholder:"Describe what you want Claude to accomplish...",value:ot,onChange:te=>ke(te.target.value),rows:4})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),r.jsx(ct,{type:"number",value:be,onChange:te=>Oe(te.target.value),min:1,max:1e3})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Completion Promise"}),r.jsx(ct,{value:Ee,onChange:te=>_e(te.target.value),placeholder:"DONE"})]})]}),f.length>0&&r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Workstream"}),r.jsxs("select",{className:"w-full border rounded-md p-2 bg-background",value:oe,onChange:te=>ve(te.target.value),children:[r.jsx("option",{value:"",children:"No workstream"}),f.map(te=>r.jsx("option",{value:te.id,children:te.name},te.id))]})]}),I&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:[r.jsxs("span",{children:["ID: ",I.id]}),r.jsx("span",{className:"mx-2",children:"|"}),r.jsxs("span",{children:["Status: ",I.status]}),r.jsx("span",{className:"mx-2",children:"|"}),r.jsxs("span",{children:["Phase: ",I.phase]})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>M(!1),children:"Cancel"}),r.jsxs(re,{onClick:Kn,disabled:R||!ot.trim(),children:[R?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Save Changes"]})]})]})}),r.jsx(wt,{open:v,onOpenChange:y,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsx(yt,{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(ct,{type:"number",value:De,onChange:te=>Be(te.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:"Default Completion Promise"}),r.jsx(ct,{value:dt,onChange:te=>er(te.target.value),placeholder:"DONE"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Default text that signals loop completion (used with official ralph-loop plugin)"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"checkbox",id:"autoApprovePlan",checked:ze,onChange:te=>St(te.target.checked),className:"rounded"}),r.jsx("label",{htmlFor:"autoApprovePlan",className:"text-sm",children:"Auto-approve plans (skip manual plan approval)"})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),r.jsxs(re,{onClick:Uo,disabled:R,children:[R?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Save"]})]})]})}),r.jsx(wt,{open:g,onOpenChange:b,children:r.jsxs(xt,{className:"sm:max-w-2xl max-h-[80vh] overflow-y-auto",children:[r.jsx(vt,{children:r.jsx(yt,{children:"Loop History"})}),r.jsx("div",{className:"space-y-3 py-4",children:wr.length===0?r.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No completed loops yet"}):wr.slice().reverse().map(te=>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:[Ca[te.status]||Ca.completed,r.jsx("span",{className:"font-medium",children:te.name})]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:eo(te.completedAt)})]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:te.task}),r.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:r.jsxs("span",{children:["Iterations: ",te.totalIterations]})})]},te.id))})]})}),r.jsx(wt,{open:k,onOpenChange:E,children:r.jsxs(xt,{className:"sm:max-w-3xl max-h-[80vh] overflow-y-auto",children:[r.jsx(vt,{children:r.jsx(yt,{children:(P==null?void 0:P.name)||"Loop Details"})}),P&&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 ${g_[P.phase]||""}`,children:P.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:[Ca[P.status],r.jsx("span",{children:P.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:[((Ko=P.iterations)==null?void 0:Ko.current)||0," / ",((ll=P.iterations)==null?void 0:ll.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:(cl=P.task)==null?void 0:cl.original})]}),P.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:P.clarifications})]}),P.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:P.plan})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Max Iterations"}),r.jsx("div",{className:"bg-muted p-2 rounded text-sm",children:((dl=P.iterations)==null?void 0:dl.max)||50})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Completion Promise"}),r.jsxs("div",{className:"bg-muted p-2 rounded text-sm font-mono",children:["<promise>",P.completionPromise||"DONE","</promise>"]})]})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Run Command (uses official ralph-loop plugin)"}),r.jsx("code",{className:"text-xs bg-muted p-3 rounded block whitespace-pre-wrap",children:Nt(P,!0)})]})]})]})}),r.jsx(wt,{open:Ps,onOpenChange:As,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[r.jsx(ui,{className:"w-5 h-5"}),"Install ralph-loop Plugin"]})}),r.jsxs("div",{className:"py-4",children:[r.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["The ",r.jsx("code",{className:"bg-muted px-1 rounded",children:"ralph-loop"})," plugin is required to run loops. This plugin provides the ",r.jsx("code",{className:"bg-muted px-1 rounded",children:"/ralph-loop"})," command that enables autonomous iteration."]}),Us.scope==="project"&&r.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded p-3 mb-4",children:r.jsxs("p",{className:"text-sm text-yellow-800 dark:text-yellow-200",children:["Plugin is currently installed only for project: ",r.jsx("br",{}),r.jsx("code",{className:"text-xs",children:Us.projectPath})]})}),r.jsx("p",{className:"text-sm",children:"Install the plugin globally (user scope) to use loops from any project?"})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:or,disabled:ms,children:"Cancel"}),r.jsx(re,{onClick:Ot,disabled:ms,children:ms?r.jsxs(r.Fragment,{children:[r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}),"Installing..."]}):r.jsxs(r.Fragment,{children:[r.jsx(ui,{className:"w-4 h-4 mr-1"}),"Install Plugin"]})})]})]})}),r.jsx(Lj,{open:rr,onOpenChange:te=>{Wr(te),te||(fr(null),Cr())},title:ut?`Loop: ${ut.name}`:"Running Loop",description:ut?((ro=(qo=ut.task)==null?void 0:qo.original)==null?void 0:ro.substring(0,100))+(((dn=(cn=ut.task)==null?void 0:cn.original)==null?void 0:dn.length)>100?"...":""):"",cwd:ut==null?void 0:ut.projectPath,initialCommand:ut?Nt(ut).startCmd:"",delayedCommand:ut?Nt(ut).skillCmd:"",delayedCommandDelay:5e3,env:ut?{CODER_LOOP_ID:ut.id,...ut.workstreamId&&{CODER_WORKSTREAM:ut.workstreamId}}:{},onExit:jt,headerExtra:r.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer select-none",children:[r.jsx("input",{type:"checkbox",checked:Xr,onChange:te=>Jr(te.target.checked),className:"rounded"}),"Auto-close when done"]})}),r.jsx(wt,{open:se,onOpenChange:de,children:r.jsxs(xt,{className:"sm:max-w-2xl max-h-[80vh] overflow-y-auto",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[r.jsx(os,{className:"w-5 h-5 text-purple-500"}),"AI-Tuned Prompt"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2 text-muted-foreground",children:"Original Prompt"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-32 overflow-y-auto",children:W})]}),r.jsxs("div",{children:[r.jsxs("h4",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[r.jsx(Yt,{className:"w-4 h-4 text-purple-500"}),"Tuned Prompt"]}),r.jsx(Ct,{value:pe,onChange:te=>X(te.target.value),rows:10,className:"font-mono text-sm"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"You can edit the tuned prompt before accepting it."})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:Ho,children:"Keep Original"}),r.jsxs(re,{onClick:ln,children:[r.jsx($t,{className:"w-4 h-4 mr-1"}),"Use Tuned Prompt"]})]})]})}),r.jsx(wt,{open:le,onOpenChange:we,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[r.jsx(Kd,{className:"w-5 h-5"}),"Resume Loop"]})}),r.jsx("div",{className:"py-4",children:Le&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"text-sm mb-4",children:["This loop ",Le.status==="failed"?"failed":Le.status==="cancelled"?"was cancelled":"was paused",Le.pauseReason&&`: ${Le.pauseReason}`]}),r.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Would you like to tune the prompt with AI before resuming? This can help add guardrails based on what went wrong."}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm max-h-32 overflow-y-auto",children:(un=Le.task)==null?void 0:un.original})]})}),r.jsxs(kt,{className:"flex-col sm:flex-row gap-2",children:[r.jsx(re,{variant:"outline",onClick:()=>{we(!1),Ke(null)},children:"Cancel"}),r.jsx(re,{variant:"secondary",onClick:Wo,children:"Resume As-Is"}),r.jsxs(re,{onClick:Ut,disabled:V,children:[V?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):r.jsx(os,{className:"w-4 h-4 mr-1"}),"Tune & Resume"]})]})]})}),r.jsx(wt,{open:sl,onOpenChange:ps,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[(Qe==null?void 0:Qe.status)==="completed"&&r.jsxs(r.Fragment,{children:[r.jsx(No,{className:"w-5 h-5 text-green-600"})," Loop Completed"]}),(Qe==null?void 0:Qe.status)==="paused"&&r.jsxs(r.Fragment,{children:[r.jsx(xp,{className:"w-5 h-5 text-yellow-500"})," Loop Paused"]}),(Qe==null?void 0:Qe.status)==="failed"&&r.jsxs(r.Fragment,{children:[r.jsx(Ta,{className:"w-5 h-5 text-red-500"})," Loop Failed"]}),(Qe==null?void 0:Qe.status)==="cancelled"&&r.jsxs(r.Fragment,{children:[r.jsx(Ta,{className:"w-5 h-5 text-gray-500"})," Loop Cancelled"]})]})}),Qe&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-1",children:"Task"}),r.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-2 rounded",children:Qe.task})]}),Qe.pauseReason&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-1",children:"Reason"}),r.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-2 rounded",children:Qe.pauseReason})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-sm",children:[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:"font-medium flex items-center gap-1",children:[Ca[Qe.status],r.jsx("span",{className:"capitalize",children:Qe.status})]})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Iterations"}),r.jsxs("div",{className:"font-medium",children:[Qe.iterations," / ",Qe.maxIterations]})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Duration"}),r.jsx("div",{className:"font-medium",children:Qe.duration!=null?Qe.duration<60?`${Qe.duration}s`:Qe.duration<3600?`${Math.floor(Qe.duration/60)}m ${Qe.duration%60}s`:`${Math.floor(Qe.duration/3600)}h ${Math.floor(Qe.duration%3600/60)}m`:"-"})]})]}),r.jsxs("div",{className:"text-xs text-muted-foreground",children:[Qe.status==="completed"?"Completed":"Stopped"," at ",eo(Qe.completedAt)]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>ps(!1),children:"Close"}),((Qe==null?void 0:Qe.status)==="paused"||(Qe==null?void 0:Qe.status)==="failed"||(Qe==null?void 0:Qe.status)==="cancelled")&&r.jsxs(re,{onClick:()=>{if(ps(!1),Qe!=null&&Qe.id){const te=t.find(Me=>Me.id===Qe.id);te&&vi(te)}},children:[r.jsx(Kd,{className:"w-4 h-4 mr-1"}),(Qe==null?void 0:Qe.status)==="paused"?"Resume":"Restart"]}),r.jsx(re,{variant:"secondary",onClick:()=>{if(ps(!1),Qe!=null&&Qe.id){const te=t.find(Me=>Me.id===Qe.id);te&&zc(te)}},children:"View Details"})]})]})})]})}function pW(e,t=[]){let s=[];function n(c,u){const l=_.createContext(u);l.displayName=c+"Context";const d=s.length;s=[...s,u];const f=h=>{var y;const{scope:x,children:w,...j}=h,C=((y=x==null?void 0:x[e])==null?void 0:y[d])||l,v=_.useMemo(()=>j,Object.values(j));return r.jsx(C.Provider,{value:v,children:w})};f.displayName=c+"Provider";function m(h,x){var C;const w=((C=x==null?void 0:x[e])==null?void 0:C[d])||l,j=_.useContext(w);if(j)return j;if(u!==void 0)return u;throw new Error(`\`${h}\` must be used within \`${c}\``)}return[f,m]}const o=()=>{const c=s.map(u=>_.createContext(u));return function(l){const d=(l==null?void 0:l[e])||c;return _.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return o.scopeName=e,[n,gW(o,...t)]}function gW(...e){const t=e[0];if(e.length===1)return t;const s=()=>{const n=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(c){const u=n.reduce((l,{useScope:d,scopeName:f})=>{const h=d(c)[`__scope${f}`];return{...l,...h}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:u}),[u])}};return s.scopeName=t.scopeName,s}var xW=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],v2=xW.reduce((e,t)=>{const s=Yu(`Primitive.${t}`),n=_.forwardRef((o,c)=>{const{asChild:u,...l}=o,d=u?s:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...l,ref:c})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Wx="Progress",Vx=100,[vW]=pW(Wx),[yW,bW]=vW(Wx),y2=_.forwardRef((e,t)=>{const{__scopeProgress:s,value:n=null,max:o,getValueLabel:c=wW,...u}=e;(o||o===0)&&!x_(o)&&console.error(_W(`${o}`,"Progress"));const l=x_(o)?o:Vx;n!==null&&!v_(n,l)&&console.error(CW(`${n}`,"Progress"));const d=v_(n,l)?n:null,f=Bu(d)?c(d,l):void 0;return r.jsx(yW,{scope:s,value:d,max:l,children:r.jsx(v2.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":Bu(d)?d:void 0,"aria-valuetext":f,role:"progressbar","data-state":_2(d,l),"data-value":d??void 0,"data-max":l,...u,ref:t})})});y2.displayName=Wx;var b2="ProgressIndicator",w2=_.forwardRef((e,t)=>{const{__scopeProgress:s,...n}=e,o=bW(b2,s);return r.jsx(v2.div,{"data-state":_2(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...n,ref:t})});w2.displayName=b2;function wW(e,t){return`${Math.round(e/t*100)}%`}function _2(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function Bu(e){return typeof e=="number"}function x_(e){return Bu(e)&&!isNaN(e)&&e>0}function v_(e,t){return Bu(e)&&!isNaN(e)&&e<=t&&e>=0}function _W(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${Vx}\`.`}function CW(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
|
|
3007
3007
|
- a positive number
|
|
3008
3008
|
- less than the value passed to \`max\` (or ${Vx} if no \`max\` prop is set)
|
|
3009
3009
|
- \`null\` or \`undefined\` if the progress is indeterminate.
|
|
@@ -3754,4 +3754,4 @@ Everything you can do in the UI, you can do from the command line. Some power us
|
|
|
3754
3754
|
Thanks for using Coder Config. The goal is to make AI coding assistants work the way you want them to, without the friction of scattered configuration files and forgotten context. Hopefully this tool helps.
|
|
3755
3755
|
|
|
3756
3756
|
Happy coding.
|
|
3757
|
-
`}},LW={...kW,...jW,...NW,...EW,...PW,...AW,...TW,...RW,...MW,...DW,...IW},ou={welcome:{bg:"bg-violet-500",light:"bg-violet-100 dark:bg-violet-950",text:"text-violet-600 dark:text-violet-400"},"first-project":{bg:"bg-blue-500",light:"bg-blue-100 dark:bg-blue-950",text:"text-blue-600 dark:text-blue-400"},"rules-guide":{bg:"bg-emerald-500",light:"bg-emerald-100 dark:bg-emerald-950",text:"text-emerald-600 dark:text-emerald-400"},"mcp-guide":{bg:"bg-orange-500",light:"bg-orange-100 dark:bg-orange-950",text:"text-orange-600 dark:text-orange-400"},"permissions-guide":{bg:"bg-green-500",light:"bg-green-100 dark:bg-green-950",text:"text-green-600 dark:text-green-400"},"memory-guide":{bg:"bg-pink-500",light:"bg-pink-100 dark:bg-pink-950",text:"text-pink-600 dark:text-pink-400"},"plugins-guide":{bg:"bg-purple-500",light:"bg-purple-100 dark:bg-purple-950",text:"text-purple-600 dark:text-purple-400"},"workstreams-guide":{bg:"bg-cyan-500",light:"bg-cyan-100 dark:bg-cyan-950",text:"text-cyan-600 dark:text-cyan-400"},"loops-guide":{bg:"bg-teal-500",light:"bg-teal-100 dark:bg-teal-950",text:"text-teal-600 dark:text-teal-400"},"multi-tool-guide":{bg:"bg-amber-500",light:"bg-amber-100 dark:bg-amber-950",text:"text-amber-600 dark:text-amber-400"},"next-steps":{bg:"bg-rose-500",light:"bg-rose-100 dark:bg-rose-950",text:"text-rose-600 dark:text-rose-400"}},y_="claude-config-tutorial-visited";function OW(){const[e,t]=_.useState("intro"),[s,n]=_.useState({welcome:!0}),[o,c]=_.useState(()=>{try{return JSON.parse(localStorage.getItem(y_)||"[]")}catch{return[]}}),u=_.useRef(null);_.useEffect(()=>{if(u.current){const b=u.current.querySelector("[data-radix-scroll-area-viewport]");b&&(b.scrollTop=0)}},[e]),_.useEffect(()=>{if(e&&!o.includes(e)){const b=[...o,e];c(b),localStorage.setItem(y_,JSON.stringify(b))}},[e,o]);const l=b=>{n(k=>({...k,[b]:!k[b]}))},d=LW[e],f=Vl.flatMap(b=>b.subsections.length>0?b.subsections.map(k=>k.id):[b.id]),m=f.indexOf(e),h=m>0?f[m-1]:null,x=m<f.length-1?f[m+1]:null,w=Math.round(o.length/f.length*100),C=(()=>{for(const b of Vl)if(b.id===e||b.subsections.some(k=>k.id===e))return b;return Vl[0]})(),v=ou[C.id]||ou.welcome,y=b=>{for(const k of Vl){if(k.id===b)return k.title;const E=k.subsections.find(P=>P.id===b);if(E)return E.title}return""},g=b=>({__html:x2(b)});return r.jsxs("div",{className:"flex h-full",children:[r.jsxs("div",{className:"w-72 border-r border-border bg-muted/30 flex flex-col",children:[r.jsxs("div",{className:"p-4 border-b border-border bg-gradient-to-r from-indigo-500/10 to-purple-500/10",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center shadow-lg",children:r.jsx(Cu,{className:"w-5 h-5 text-white"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"font-semibold text-foreground",children:"Tutorial"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Step-by-step guide"})]})]}),r.jsxs("div",{className:"mt-3",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground mb-1",children:[r.jsx("span",{children:"Progress"}),r.jsxs("span",{children:[w,"% complete"]})]}),r.jsx(S2,{value:w,className:"h-2"})]})]}),r.jsx(nn,{className:"flex-1",children:r.jsx("div",{className:"p-2",children:Vl.map((b,k)=>{const E=b.icon,P=ou[b.id]||ou.welcome,T=e===b.id||b.subsections.some(M=>M.id===e),N=b.subsections.length>0?b.subsections.every(M=>o.includes(M.id)):o.includes(b.id);return r.jsxs("div",{className:"mb-1",children:[r.jsxs("button",{className:Ne("w-full flex items-center gap-2 px-3 py-2.5 text-sm rounded-lg hover:bg-accent text-left transition-all",T&&"bg-accent"),onClick:()=>{b.subsections.length>0?(l(b.id),s[b.id]||t(b.subsections[0].id)):t(b.id)},children:[r.jsx("span",{className:Ne("w-7 h-7 rounded-lg flex items-center justify-center transition-colors",T?P.bg+" text-white":P.light),children:N?r.jsx(No,{className:"w-4 h-4"}):r.jsx(E,{className:Ne("w-4 h-4",!T&&P.text)})}),r.jsx("span",{className:Ne("flex-1",T&&"font-medium"),children:b.title}),b.subsections.length>0&&r.jsx(us,{className:Ne("w-4 h-4 text-muted-foreground transition-transform",s[b.id]&&"rotate-90")})]}),b.subsections.length>0&&s[b.id]&&r.jsx("div",{className:"ml-4 mt-1 space-y-0.5 border-l-2 border-border pl-3",children:b.subsections.map(M=>{const I=e===M.id,L=o.includes(M.id);return r.jsxs("button",{className:Ne("w-full text-left px-3 py-1.5 text-sm rounded-md hover:bg-accent text-foreground flex items-center gap-2",I&&"bg-accent font-medium",I&&P.text),onClick:()=>t(M.id),children:[L&&!I&&r.jsx(No,{className:"w-3 h-3 text-green-500"}),r.jsx("span",{className:Ne(!L&&!I&&"ml-5"),children:M.title})]},M.id)})})]},b.id)})})})]}),r.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[r.jsx("div",{className:Ne("px-8 py-4 border-b border-border",v.light),children:r.jsxs("div",{className:"max-w-3xl mx-auto flex items-center gap-3",children:[r.jsx("div",{className:Ne("w-10 h-10 rounded-xl flex items-center justify-center",v.bg,"text-white"),children:r.jsx(C.icon,{className:"w-5 h-5"})}),r.jsxs("div",{children:[r.jsx("p",{className:Ne("text-sm font-medium",v.text),children:C.title}),r.jsx("h1",{className:"text-lg font-semibold text-foreground",children:(d==null?void 0:d.title)||y(e)})]})]})}),r.jsx(nn,{className:"flex-1",ref:u,children:r.jsx("div",{className:"max-w-3xl mx-auto p-8",children:d?r.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert prose-headings:text-foreground prose-p:text-muted-foreground prose-strong:text-foreground prose-code:text-primary prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-pre:bg-muted prose-pre:border prose-pre:border-border",dangerouslySetInnerHTML:g(d.content)}):r.jsxs("div",{className:"text-center text-muted-foreground py-12",children:[r.jsx(Cu,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"Select a topic from the sidebar"})]})})}),r.jsx("div",{className:"border-t border-border p-4 bg-muted/30",children:r.jsxs("div",{className:"max-w-3xl mx-auto flex items-center justify-between",children:[h?r.jsxs(re,{variant:"ghost",onClick:()=>t(h),className:"flex items-center gap-2",children:[r.jsx(S5,{className:"w-4 h-4"}),r.jsx("span",{className:"max-w-[150px] truncate",children:y(h)})]}):r.jsx("div",{}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[m+1," of ",f.length]}),x?r.jsxs(re,{onClick:()=>t(x),className:Ne("flex items-center gap-2",v.bg,"hover:opacity-90"),children:[r.jsx("span",{className:"max-w-[150px] truncate",children:y(x)}),r.jsx(Pg,{className:"w-4 h-4"})]}):r.jsx(re,{variant:"outline",onClick:()=>t("intro"),className:"flex items-center gap-2",children:"Start Over"})]})})]})]})}function FW(){const[e,t]=_.useState(null),[s,n]=_.useState(!0),[o,c]=_.useState(!1),[u,l]=_.useState(!1),[d,f]=_.useState(!1),[m,h]=_.useState(null);_.useEffect(()=>{x()},[]);const x=async()=>{try{n(!0);const k=await ue.getSessionStatus();t(k)}catch{Y.error("Failed to load session status")}finally{n(!1)}},w=async()=>{var k,E;c(!0);try{const P=await ue.installSessionAll();P.success?(Y.success("Session persistence installed!"),x()):Y.error(((k=P.hooks)==null?void 0:k.error)||((E=P.command)==null?void 0:E.error)||"Installation failed")}catch{Y.error("Installation failed")}finally{c(!1)}},j=async()=>{c(!0);try{const k=await ue.installSessionHooks();k.success?(Y.success("Session hooks installed!"),x()):Y.error(k.error||"Failed to install hooks")}catch{Y.error("Failed to install hooks")}finally{c(!1)}},C=async()=>{c(!0);try{const k=await ue.installFlushCommand();k.success?(Y.success(k.alreadyInstalled?"/flush command already installed":"/flush command installed!"),x()):Y.error(k.error||"Failed to install command")}catch{Y.error("Failed to install command")}finally{c(!1)}},v=async()=>{l(!0);try{const k=await ue.clearSessionContext();k.success?(Y.success(k.cleared?"Session context cleared":"No context to clear"),x()):Y.error("Failed to clear context")}catch{Y.error("Failed to clear context")}finally{l(!1)}},y=async()=>{try{const k=await ue.getSessionContext();h(k.content),f(!0)}catch{Y.error("Failed to load context")}},g=k=>k===null?"Unknown":k<60?`${k} minutes ago`:k<1440?`${Math.floor(k/60)} hours ago`:`${Math.floor(k/1440)} days ago`;if(s)return r.jsx("div",{className:"flex items-center justify-center h-64",children:r.jsx(Ze,{className:"w-8 h-8 animate-spin text-indigo-600"})});const b=(e==null?void 0:e.hooksInstalled)&&(e==null?void 0:e.flushCommandInstalled)&&(e==null?void 0:e.permissionInstalled);return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-5 shadow-sm",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 rounded-lg bg-indigo-100 dark:bg-indigo-950",children:r.jsx(Vs,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Session Persistence"}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Save and restore Claude Code session context"})]})]}),r.jsx(re,{variant:"ghost",size:"sm",onClick:x,children:r.jsx(Tr,{className:"w-4 h-4"})})]}),r.jsxs("p",{className:"text-sm text-gray-600 dark:text-slate-400",children:["Session persistence allows you to save your current Claude Code context using the ",r.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1.5 py-0.5 rounded text-indigo-600 dark:text-indigo-400",children:"/flush"})," command, and automatically restore it when you start a new session."]})]}),r.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[r.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700",children:r.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Installation Status"})}),r.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-slate-800",children:[r.jsxs("div",{className:"p-4 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[e!=null&&e.hooksInstalled?r.jsx($t,{className:"w-5 h-5 text-green-500"}):r.jsx($s,{className:"w-5 h-5 text-amber-500"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Session Hooks"}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Auto-restore context on session start, preserve on session end"})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(et,{variant:e!=null&&e.hooksInstalled?"default":"secondary",children:e!=null&&e.hooksInstalled?"Installed":"Not Installed"}),!(e!=null&&e.hooksInstalled)&&r.jsx(re,{variant:"outline",size:"sm",onClick:j,disabled:o,children:o?r.jsx(Ze,{className:"w-4 h-4 animate-spin"}):"Install"})]})]}),r.jsxs("div",{className:"p-4 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[e!=null&&e.flushCommandInstalled?r.jsx($t,{className:"w-5 h-5 text-green-500"}):r.jsx($s,{className:"w-5 h-5 text-amber-500"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"/flush Command"}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Adds the /flush command to save session context"})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(et,{variant:e!=null&&e.flushCommandInstalled?"default":"secondary",children:e!=null&&e.flushCommandInstalled?"Installed":"Not Installed"}),!(e!=null&&e.flushCommandInstalled)&&r.jsx(re,{variant:"outline",size:"sm",onClick:C,disabled:o,children:o?r.jsx(Ze,{className:"w-4 h-4 animate-spin"}):"Install"})]})]}),r.jsxs("div",{className:"p-4 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[e!=null&&e.permissionInstalled?r.jsx($t,{className:"w-5 h-5 text-green-500"}):r.jsx($s,{className:"w-5 h-5 text-amber-500"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Write Permission"}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Allows Claude to write session context without prompting"})]})]}),r.jsx(et,{variant:e!=null&&e.permissionInstalled?"default":"secondary",children:e!=null&&e.permissionInstalled?"Granted":"Not Granted"})]})]}),!b&&r.jsx("div",{className:"p-4 bg-gray-50 dark:bg-slate-900 border-t border-gray-200 dark:border-slate-800",children:r.jsxs(re,{onClick:w,disabled:o,className:"w-full bg-indigo-600 hover:bg-indigo-700 text-white",children:[o?r.jsx(Ze,{className:"w-4 h-4 mr-2 animate-spin"}):r.jsx(ui,{className:"w-4 h-4 mr-2"}),"Install All"]})})]}),r.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[r.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700 flex items-center justify-between",children:[r.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Saved Context"}),(e==null?void 0:e.hasSavedContext)&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(re,{variant:"outline",size:"sm",onClick:y,children:[r.jsx(Br,{className:"w-4 h-4 mr-2"}),"View"]}),r.jsx(re,{variant:"outline",size:"sm",onClick:v,disabled:u,className:"text-red-600 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-950",children:u?r.jsx(Ze,{className:"w-4 h-4 animate-spin"}):r.jsx(js,{className:"w-4 h-4"})})]})]}),r.jsx("div",{className:"p-4",children:e!=null&&e.hasSavedContext?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx(ec,{className:"w-4 h-4 text-gray-400"}),r.jsx("span",{className:"text-gray-600 dark:text-slate-400",children:"Last saved:"}),r.jsx("span",{className:"text-gray-900 dark:text-white",children:g(e.contextAge)})]}),e.contextPreview&&r.jsx("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:r.jsx("pre",{className:"text-xs text-gray-600 dark:text-slate-400 whitespace-pre-wrap overflow-hidden",children:e.contextPreview})}),r.jsxs("div",{className:"text-xs text-gray-500 dark:text-slate-500",children:["Storage: ",e.sessionDir]})]}):r.jsxs("div",{className:"text-center py-6",children:[r.jsx(Vs,{className:"w-12 h-12 text-gray-300 dark:text-slate-600 mx-auto mb-3"}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400",children:"No saved context"}),r.jsxs("p",{className:"text-xs text-gray-400 dark:text-slate-500 mt-1",children:["Use ",r.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded",children:"/flush"})," in Claude Code to save your session"]})]})})]}),(e==null?void 0:e.lastSession)&&r.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[r.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700",children:r.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Last Session"})}),r.jsxs("div",{className:"p-4 space-y-2",children:[e.lastSession.session_id&&r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"ID:"}),r.jsx("code",{className:"text-xs bg-gray-100 dark:bg-slate-800 px-2 py-0.5 rounded",children:e.lastSession.session_id})]}),e.lastSession.cwd&&r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"Directory:"}),r.jsx("span",{className:"text-gray-900 dark:text-white font-mono text-xs",children:e.lastSession.cwd})]}),e.lastSession.timestamp&&r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"Ended:"}),r.jsx("span",{className:"text-gray-900 dark:text-white",children:e.lastSession.timestamp})]}),e.lastSession.reason&&r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"Reason:"}),r.jsx(et,{variant:"secondary",children:e.lastSession.reason})]})]})]}),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:"How to Use"}),r.jsxs("ol",{className:"space-y-2 text-sm text-gray-600 dark:text-slate-400",children:[r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"font-medium text-indigo-600 dark:text-indigo-400",children:"1."}),"Install session hooks and the /flush command above"]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"font-medium text-indigo-600 dark:text-indigo-400",children:"2."}),"Use ",r.jsx("code",{className:"bg-white dark:bg-slate-800 px-1.5 py-0.5 rounded",children:"/flush"})," in Claude Code before ending a session"]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"font-medium text-indigo-600 dark:text-indigo-400",children:"3."}),"Your context is automatically restored when you start a new session"]})]})]}),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 session # Show session status"}),r.jsx("p",{children:"coder-config session install-hooks # Install session hooks"}),r.jsx("p",{children:"coder-config session clear # Clear saved context"})]})]}),r.jsx(wt,{open:d,onOpenChange:f,children:r.jsxs(xt,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[r.jsxs(vt,{children:[r.jsx(yt,{children:"Saved Context"}),r.jsx(ur,{children:"This context will be restored on your next Claude Code session"})]}),r.jsx("div",{className:"flex-1 overflow-auto py-4",children:r.jsx("pre",{className:"text-sm text-gray-700 dark:text-slate-300 whitespace-pre-wrap bg-gray-50 dark:bg-slate-900 p-4 rounded-lg",children:m||"No content"})}),r.jsx(kt,{children:r.jsx(re,{variant:"ghost",onClick:()=>f(!1),children:"Close"})})]})})]})}const BW=[{id:"projects",label:"All Projects",icon:Rn,section:"Projects"},{id:"explorer",label:"Project Explorer",icon:Wi,section:"Projects"},{id:"workstreams",label:"Workstreams",icon:lS,section:"Projects"},{id:"registry",label:"MCP Registry",icon:Bn,section:"Tools"},{id:"plugins",label:"Plugins",icon:Po,section:"Tools"},{id:"memory",label:"Memory",icon:jo,section:"Tools"},{id:"claude-settings",label:"Claude Code",icon:Vn,section:"Configuration",tool:"claude"},{id:"gemini-settings",label:"Gemini CLI",icon:qt,section:"Configuration",tool:"gemini"},{id:"codex-settings",label:"Codex CLI",icon:qt,section:"Configuration",isNew:!0,tool:"codex"},{id:"antigravity-settings",label:"Antigravity",icon:Sc,section:"Configuration",tool:"antigravity"},{id:"create-mcp",label:"Create MCP",icon:os,section:"Developer"},{id:"loops",label:"Ralph Loops",icon:cc,section:"Developer",isNew:!0},{id:"sessions",label:"Sessions",icon:Vs,section:"System"},{id:"preferences",label:"Preferences",icon:cS,section:"System"},{id:"tutorial",label:"Tutorial",icon:Cu,section:"Help"},{id:"docs",label:"Docs & Help",icon:ko,section:"Help"}],b_=(e,t)=>{try{const s=localStorage.getItem(`claude-config-${e}`);return s?JSON.parse(s):t}catch{return t}},$W=(e,t)=>{try{localStorage.setItem(`claude-config-${e}`,JSON.stringify(t))}catch{}};function zW(){const{projects:e,activeProject:t,fetch:s,setActive:n}=Ex(),{appConfig:o,version:c,fetch:u,checkVersion:l}=Nw(),[d,f]=_.useState(()=>b_("currentView","explorer")),[m,h]=_.useState(!0),[x,w]=_.useState({dir:"",subprojects:[],hierarchy:[]}),[j,C]=_.useState([]),[v,y]=_.useState({mcpServers:{}}),[g,b]=_.useState([]),[k,E]=_.useState([]),[P,T]=_.useState(null),[N,M]=_.useState(null),[I,L]=_.useState(!1),[B,H]=_.useState({title:"",type:""}),[q,z]=_.useState(""),[G,J]=_.useState(""),[K,F]=_.useState({}),[R,O]=_.useState(null),[V,$]=_.useState(!1),[se,de]=_.useState(!1),[pe,X]=_.useState(null),[W,ce]=_.useState(!1),ie=_.useRef(null);_.useEffect(()=>{$W("currentView",d)},[d]);const Q=_.useCallback(async()=>{try{const[Ee,_e,oe,ve,De]=await Promise.all([ue.getProject(),ue.getConfigs(),ue.getRegistry(),ue.getRules(),ue.getCommands()]);w(Ee),C(_e),y(oe),b(ve),E(De),_e.length>0&&!P&&T(_e[_e.length-1])}catch(Ee){Y.error("Failed to load data: "+Ee.message)}finally{h(!1)}},[P]),le=_.useCallback(async(Ee=!1)=>{try{const _e=await s(),oe=_e==null?void 0:_e.find(ve=>ve.isActive);if(Ee&&oe){const ve=await ue.getSubprojects(oe.path);X({dir:oe.path,subprojects:ve.subprojects||[]})}Ee&&!oe&&(b_("currentView",null)||f("projects"))}catch{console.log("Projects API not available")}},[s]),we=async Ee=>{try{const _e=await n(Ee);_e.success?(w({dir:_e.dir,hierarchy:_e.hierarchy,subprojects:_e.subprojects}),X({dir:_e.dir,subprojects:_e.subprojects}),await Q(),Y.success(`Switched to ${_e.project.name}`)):Y.error(_e.error||"Failed to switch project")}catch(_e){Y.error("Failed to switch project: "+_e.message)}},Le=()=>{s()};_.useEffect(()=>{Q(),le(!0),(async()=>{try{const[_e]=await Promise.all([l(),u()]);!ie.current&&(_e!=null&&_e.installedVersion)&&(ie.current=_e.installedVersion);const oe=Nw.getState().appConfig;if(_e!=null&&_e.updateAvailable&&(_e==null?void 0:_e.updateMethod)==="npm")if(oe!=null&&oe.autoUpdate){Y.info(`Auto-updating to v${_e.latestVersion}...`),$(!0);const ve=await ue.performUpdate({updateMethod:_e.updateMethod,targetVersion:_e.latestVersion});if(ve.success){Y.success(`Updated to v${ve.newVersion}! Restarting server...`);try{await ue.restartServer()}catch{}let De=0;const Be=setInterval(async()=>{De++;try{await ue.checkVersion(),clearInterval(Be),Y.success("Server restarted! Reloading..."),setTimeout(()=>window.location.reload(),500)}catch{De>30&&(clearInterval(Be),Y.info("Server restarting. Please refresh the page."),$(!1))}},500)}else Y.error("Auto-update failed: "+ve.error),$(!1),O(_e)}else O(_e)}catch{}})()},[]),_.useEffect(()=>{const _e=setInterval(async()=>{if(ie.current)try{const oe=await ue.checkVersion();oe!=null&&oe.installedVersion&&oe.installedVersion!==ie.current&&(console.log(`[stale-ui] Server updated to v${oe.installedVersion}, refreshing...`),window.location.reload())}catch{}},3e4);return()=>clearInterval(_e)},[]);const Ke=(Ee,_e)=>{if(!Ee||!_e)return!1;const oe=Be=>Be.split(".").map(ze=>parseInt(ze,10)||0),ve=oe(Ee),De=oe(_e);for(let Be=0;Be<Math.max(ve.length,De.length);Be++){if((ve[Be]||0)>(De[Be]||0))return!0;if((ve[Be]||0)<(De[Be]||0))return!1}return!1},fe=async(Ee,_e="npm")=>{$(!0);const oe=await ue.performUpdate({updateMethod:_e,targetVersion:Ee});if(oe.success){Y.success(`Updated to v${oe.newVersion}! Restarting server...`),O(null);try{await ue.restartServer()}catch{}let ve=0;const De=setInterval(async()=>{ve++;try{await ue.checkVersion(),clearInterval(De),Y.success("Server restarted! Reloading..."),setTimeout(()=>window.location.reload(),500)}catch{ve>30&&(clearInterval(De),Y.info("Server restarting. Please refresh the page."),$(!1))}},500);return!0}else return Y.error("Update failed: "+oe.error),$(!1),!1},ye=async()=>{ce(!0);try{const Ee=await ue.checkVersion(),_e=Ee==null?void 0:Ee.installedVersion,oe=Ee==null?void 0:Ee.latestVersion;if(_e&&ie.current&&_e!==ie.current){Y.info(`Refreshing to v${_e}...`),setTimeout(()=>window.location.reload(),500);return}Ke(oe,_e)&&(o!=null&&o.autoUpdate?(ce(!1),Y.info(`Auto-updating to v${oe}...`),await fe(oe,(Ee==null?void 0:Ee.updateMethod)||"npm")):(O({...Ee,updateAvailable:!0}),Y.info(`Update available: v${oe}`)))}catch{Y.error("Failed to check for updates")}finally{ce(!1)}},Je=async()=>{if(R!=null&&R.updateAvailable){$(!0);try{const Ee=await ue.performUpdate({updateMethod:R.updateMethod,sourcePath:R.sourcePath,targetVersion:R.latestVersion});if(Ee.success){Y.success(`Updated to v${Ee.newVersion}! Restarting server...`),O(null),setVersion(Ee.newVersion);try{await ue.restartServer()}catch{}let _e=0;const oe=setInterval(async()=>{_e++;try{await ue.checkVersion(),clearInterval(oe),Y.success("Server restarted! Reloading..."),setTimeout(()=>window.location.reload(),500)}catch{_e>30&&(clearInterval(oe),Y.info("Server restarting. Please refresh the page."),$(!1))}},500)}else Y.error("Update failed: "+Ee.error),$(!1)}catch(Ee){Y.error("Update failed: "+Ee.message),$(!1)}}};_.useEffect(()=>{const Ee=async()=>{try{const{hashes:oe}=await ue.getFileHashes(),ve=K,De=Object.keys(oe).some(ze=>ve[ze]!==oe[ze])||Object.keys(ve).some(ze=>!oe[ze]),Be=ve.__subprojects__!==oe.__subprojects__;if(De&&Object.keys(ve).length>0&&(Y.info("Files changed externally, reloading..."),await Q(),Be&&pe))try{const ze=await ue.getSubprojects(pe.dir);X(St=>({...St,subprojects:ze.subprojects||[]}))}catch{}F(oe)}catch{}},_e=setInterval(Ee,2e3);return Ee(),()=>clearInterval(_e)},[K,Q,pe]);const Ye=new Set;j.forEach(Ee=>{var _e,oe;(((_e=Ee.config)==null?void 0:_e.include)||[]).forEach(ve=>Ye.add(ve)),Object.keys(((oe=Ee.config)==null?void 0:oe.mcpServers)||{}).forEach(ve=>Ye.add(ve))});const ot={mcps:Ye.size,rules:g.length,commands:k.length},ke=async()=>{try{const Ee=await ue.applyConfig(x.dir);if(Ee.tools){const _e=Object.entries(Ee.tools).filter(([,oe])=>oe).map(([oe])=>oe==="claude"?"Claude Code":"Antigravity");_e.length>0?Y.success(`Config applied to: ${_e.join(", ")}`):Y.warning("No tools were updated")}else Y.success("Configuration applied successfully!")}catch(Ee){Y.error("Failed to apply config: "+Ee.message)}},be=async()=>{h(!0),await Q(),Y.success("Data refreshed")};if(m)return r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-4",children:[r.jsx(Ze,{className:"w-8 h-8 animate-spin text-primary"}),r.jsx("p",{className:"text-muted-foreground",children:"Loading configuration..."})]})});const Oe=()=>{switch(d){case"explorer":return r.jsx(y8,{project:x,onRefresh:Q});case"registry":return r.jsx(FH,{registry:v,searchQuery:q,setSearchQuery:z,onUpdate:Q});case"plugins":return r.jsx(hW,{});case"memory":return r.jsx(BH,{project:x,onUpdate:Q});case"create-mcp":return r.jsx(pH,{project:x});case"claude-settings":return r.jsx(eH,{});case"gemini-settings":return r.jsx(tH,{});case"codex-settings":return r.jsx(fH,{});case"antigravity-settings":return r.jsx(oH,{});case"sessions":return r.jsx(FW,{});case"preferences":return r.jsx(Zz,{onConfigChange:()=>u()});case"projects":return r.jsx(VH,{onProjectSwitch:Ee=>{w({dir:Ee.dir,hierarchy:Ee.hierarchy,subprojects:Ee.subprojects}),X({dir:Ee.dir,subprojects:Ee.subprojects}),Q(),le()}});case"workstreams":return r.jsx(fW,{onWorkstreamChange:Ee=>{Y.success(`Switched to workstream: ${Ee.name}`)}});case"loops":return r.jsx(mW,{activeProject:t});case"docs":return r.jsx(dW,{});case"tutorial":return r.jsx(OW,{});default:return null}};return r.jsxs("div",{className:"min-h-screen bg-background",children:[r.jsx("header",{className:"h-16 bg-card border-b border-border sticky top-0 z-50 shadow-sm",children:r.jsxs("div",{className:"h-full px-6 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center shadow-lg shadow-indigo-500/20",children:r.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 128 128",children:[r.jsx("circle",{cx:"64",cy:"64",r:"52",fill:"none",stroke:"white",strokeWidth:"10",strokeDasharray:"24 12"}),r.jsx("circle",{cx:"64",cy:"64",r:"28",fill:"white"}),r.jsx("circle",{cx:"64",cy:"64",r:"12",fill:"#7c3aed"})]})}),r.jsx("div",{children:r.jsxs("h1",{className:"text-xl font-bold text-foreground",children:["Coder ",r.jsx("span",{className:"text-primary",children:"Config"})]})}),R&&r.jsxs("button",{onClick:Je,disabled:V,className:"ml-3 px-2.5 py-1 text-xs font-medium bg-green-100 text-green-700 hover:bg-green-200 rounded-full flex items-center gap-1.5 transition-colors disabled:opacity-50",children:[V?r.jsx(Ze,{className:"w-3 h-3 animate-spin"}):r.jsx(ui,{className:"w-3 h-3"}),V?"Updating...":`Update to v${R.latestVersion}`]})]}),r.jsx(xN,{orientation:"vertical",className:"h-6"}),r.jsx(b8,{projects:e,activeProject:t,onSwitch:we,onAddClick:()=>de(!0),onManageClick:()=>f("projects")})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(S8,{}),r.jsx(re,{variant:"ghost",size:"sm",onClick:be,children:r.jsx(Tr,{className:"w-4 h-4"})}),r.jsxs(re,{onClick:ke,variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",title:"Config auto-applies on save. Click to manually re-apply.",children:[r.jsx(Sc,{className:"w-4 h-4"}),"Re-apply"]})]})]})}),r.jsxs("div",{className:"flex",children:[r.jsxs("aside",{className:"w-64 h-[calc(100vh-64px)] border-r border-border bg-card sticky top-16 flex flex-col",children:[r.jsx(nn,{className:"flex-1 py-4",children:["Projects","Tools","Configuration","Developer","System","Help"].map(Ee=>r.jsxs("div",{className:"mb-6",children:[r.jsx("h3",{className:"px-4 mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:Ee}),r.jsx("div",{className:"space-y-0.5",children:BW.filter(_e=>_e.section===Ee).filter(_e=>{var oe;return _e.id!=="loops"||((oe=o==null?void 0:o.experimental)==null?void 0:oe.ralphLoops)}).filter(_e=>!_e.tool||((o==null?void 0:o.enabledTools)||["claude"]).includes(_e.tool)).map(_e=>{const oe=_e.icon,ve=d===_e.id;return r.jsxs("button",{onClick:()=>f(_e.id),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-all duration-200 border-l-2 ${ve?"bg-accent border-primary text-primary font-medium":"border-transparent text-muted-foreground hover:text-foreground hover:bg-accent"}`,children:[r.jsx(oe,{className:"w-4 h-4"}),r.jsx("span",{className:"flex-1 text-left",children:_e.label}),_e.badge&&r.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${ve?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:ot[_e.badge]}),_e.isNew&&r.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded font-medium bg-green-500/20 text-green-600 dark:text-green-400",children:"new"})]},_e.id)})})]},Ee))}),r.jsx("div",{className:"px-4 py-3 border-t border-border",children:r.jsxs("button",{onClick:ye,disabled:W,className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1",title:"Check for updates",children:[W?r.jsx(Ze,{className:"w-3 h-3 animate-spin"}):null,c?`v${c}`:""]})})]}),r.jsx("main",{style:["explorer","docs","tutorial"].includes(d)?{}:{zoom:.9},className:Ne("flex-1 overflow-auto",["explorer","docs","tutorial"].includes(d)?"h-[calc(100vh-64px)]":"p-6"),children:r.jsx(k_,{mode:"wait",children:r.jsx(Pa.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},className:["explorer","docs","tutorial"].includes(d)?"h-full":"",children:Oe()},d)})})]}),r.jsx(fN,{open:se,onOpenChange:de,onAdded:Le}),r.jsx(w8,{onStartTutorial:()=>f("tutorial")})]})}function HW(){const[e,t]=_.useState(!1),[s,n]=_.useState(!1),[o,c]=_.useState(!1),u=_.useCallback(async()=>{n(!0);try{await ue.restartServer(),Y.info("Server restarting... page will reload."),setTimeout(()=>{window.location.reload()},2e3)}catch(d){Y.error("Failed to restart: "+d.message),n(!1)}},[]),l=_.useCallback(()=>{c(!0),t(!1),Y.dismiss("update-available")},[]);return _.useEffect(()=>{let d;const f=async()=>{try{const m=await ue.getVersion();console.log("[Update Check]",m),m.needsRestart&&!o&&t(!0)}catch{}};return f(),d=setInterval(f,3e4),()=>clearInterval(d)},[o]),r.jsx(_8,{children:r.jsxs("div",{className:"min-h-screen bg-background",children:[e&&!s&&r.jsxs("div",{className:"fixed top-0 left-0 right-0 z-50 bg-blue-600 text-white px-4 py-2 flex items-center justify-center gap-2 shadow-lg cursor-pointer hover:bg-blue-700 transition-colors",onClick:u,children:[r.jsx(Tr,{className:"w-4 h-4"}),r.jsx("span",{className:"text-sm font-medium",children:"Update available — click to restart"}),r.jsx("button",{onClick:d=>{d.stopPropagation(),l()},className:"absolute right-3 p-1 hover:bg-blue-500 rounded",children:r.jsx(oi,{className:"w-4 h-4"})})]}),s&&r.jsxs("div",{className:"fixed top-0 left-0 right-0 z-50 bg-amber-600 text-white px-4 py-2 flex items-center justify-center gap-2",children:[r.jsx(Tr,{className:"w-4 h-4 animate-spin"}),r.jsx("span",{className:"text-sm font-medium",children:"Restarting server..."})]}),r.jsx(zW,{}),r.jsx(DP,{position:"bottom-right",richColors:!0})]})})}aP.createRoot(document.getElementById("root")).render(r.jsx(HW,{}));
|
|
3757
|
+
`}},LW={...kW,...jW,...NW,...EW,...PW,...AW,...TW,...RW,...MW,...DW,...IW},ou={welcome:{bg:"bg-violet-500",light:"bg-violet-100 dark:bg-violet-950",text:"text-violet-600 dark:text-violet-400"},"first-project":{bg:"bg-blue-500",light:"bg-blue-100 dark:bg-blue-950",text:"text-blue-600 dark:text-blue-400"},"rules-guide":{bg:"bg-emerald-500",light:"bg-emerald-100 dark:bg-emerald-950",text:"text-emerald-600 dark:text-emerald-400"},"mcp-guide":{bg:"bg-orange-500",light:"bg-orange-100 dark:bg-orange-950",text:"text-orange-600 dark:text-orange-400"},"permissions-guide":{bg:"bg-green-500",light:"bg-green-100 dark:bg-green-950",text:"text-green-600 dark:text-green-400"},"memory-guide":{bg:"bg-pink-500",light:"bg-pink-100 dark:bg-pink-950",text:"text-pink-600 dark:text-pink-400"},"plugins-guide":{bg:"bg-purple-500",light:"bg-purple-100 dark:bg-purple-950",text:"text-purple-600 dark:text-purple-400"},"workstreams-guide":{bg:"bg-cyan-500",light:"bg-cyan-100 dark:bg-cyan-950",text:"text-cyan-600 dark:text-cyan-400"},"loops-guide":{bg:"bg-teal-500",light:"bg-teal-100 dark:bg-teal-950",text:"text-teal-600 dark:text-teal-400"},"multi-tool-guide":{bg:"bg-amber-500",light:"bg-amber-100 dark:bg-amber-950",text:"text-amber-600 dark:text-amber-400"},"next-steps":{bg:"bg-rose-500",light:"bg-rose-100 dark:bg-rose-950",text:"text-rose-600 dark:text-rose-400"}},y_="claude-config-tutorial-visited";function OW(){const[e,t]=_.useState("intro"),[s,n]=_.useState({welcome:!0}),[o,c]=_.useState(()=>{try{return JSON.parse(localStorage.getItem(y_)||"[]")}catch{return[]}}),u=_.useRef(null);_.useEffect(()=>{if(u.current){const b=u.current.querySelector("[data-radix-scroll-area-viewport]");b&&(b.scrollTop=0)}},[e]),_.useEffect(()=>{if(e&&!o.includes(e)){const b=[...o,e];c(b),localStorage.setItem(y_,JSON.stringify(b))}},[e,o]);const l=b=>{n(k=>({...k,[b]:!k[b]}))},d=LW[e],f=Vl.flatMap(b=>b.subsections.length>0?b.subsections.map(k=>k.id):[b.id]),m=f.indexOf(e),h=m>0?f[m-1]:null,x=m<f.length-1?f[m+1]:null,w=Math.round(o.length/f.length*100),C=(()=>{for(const b of Vl)if(b.id===e||b.subsections.some(k=>k.id===e))return b;return Vl[0]})(),v=ou[C.id]||ou.welcome,y=b=>{for(const k of Vl){if(k.id===b)return k.title;const E=k.subsections.find(P=>P.id===b);if(E)return E.title}return""},g=b=>({__html:x2(b)});return r.jsxs("div",{className:"flex h-full",children:[r.jsxs("div",{className:"w-72 border-r border-border bg-muted/30 flex flex-col",children:[r.jsxs("div",{className:"p-4 border-b border-border bg-gradient-to-r from-indigo-500/10 to-purple-500/10",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center shadow-lg",children:r.jsx(Cu,{className:"w-5 h-5 text-white"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"font-semibold text-foreground",children:"Tutorial"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Step-by-step guide"})]})]}),r.jsxs("div",{className:"mt-3",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground mb-1",children:[r.jsx("span",{children:"Progress"}),r.jsxs("span",{children:[w,"% complete"]})]}),r.jsx(S2,{value:w,className:"h-2"})]})]}),r.jsx(nn,{className:"flex-1",children:r.jsx("div",{className:"p-2",children:Vl.map((b,k)=>{const E=b.icon,P=ou[b.id]||ou.welcome,T=e===b.id||b.subsections.some(M=>M.id===e),N=b.subsections.length>0?b.subsections.every(M=>o.includes(M.id)):o.includes(b.id);return r.jsxs("div",{className:"mb-1",children:[r.jsxs("button",{className:Ne("w-full flex items-center gap-2 px-3 py-2.5 text-sm rounded-lg hover:bg-accent text-left transition-all",T&&"bg-accent"),onClick:()=>{b.subsections.length>0?(l(b.id),s[b.id]||t(b.subsections[0].id)):t(b.id)},children:[r.jsx("span",{className:Ne("w-7 h-7 rounded-lg flex items-center justify-center transition-colors",T?P.bg+" text-white":P.light),children:N?r.jsx(No,{className:"w-4 h-4"}):r.jsx(E,{className:Ne("w-4 h-4",!T&&P.text)})}),r.jsx("span",{className:Ne("flex-1",T&&"font-medium"),children:b.title}),b.subsections.length>0&&r.jsx(us,{className:Ne("w-4 h-4 text-muted-foreground transition-transform",s[b.id]&&"rotate-90")})]}),b.subsections.length>0&&s[b.id]&&r.jsx("div",{className:"ml-4 mt-1 space-y-0.5 border-l-2 border-border pl-3",children:b.subsections.map(M=>{const I=e===M.id,L=o.includes(M.id);return r.jsxs("button",{className:Ne("w-full text-left px-3 py-1.5 text-sm rounded-md hover:bg-accent text-foreground flex items-center gap-2",I&&"bg-accent font-medium",I&&P.text),onClick:()=>t(M.id),children:[L&&!I&&r.jsx(No,{className:"w-3 h-3 text-green-500"}),r.jsx("span",{className:Ne(!L&&!I&&"ml-5"),children:M.title})]},M.id)})})]},b.id)})})})]}),r.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[r.jsx("div",{className:Ne("px-8 py-4 border-b border-border",v.light),children:r.jsxs("div",{className:"max-w-3xl mx-auto flex items-center gap-3",children:[r.jsx("div",{className:Ne("w-10 h-10 rounded-xl flex items-center justify-center",v.bg,"text-white"),children:r.jsx(C.icon,{className:"w-5 h-5"})}),r.jsxs("div",{children:[r.jsx("p",{className:Ne("text-sm font-medium",v.text),children:C.title}),r.jsx("h1",{className:"text-lg font-semibold text-foreground",children:(d==null?void 0:d.title)||y(e)})]})]})}),r.jsx(nn,{className:"flex-1",ref:u,children:r.jsx("div",{className:"max-w-3xl mx-auto p-8",children:d?r.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert prose-headings:text-foreground prose-p:text-muted-foreground prose-strong:text-foreground prose-code:text-primary prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-pre:bg-muted prose-pre:border prose-pre:border-border",dangerouslySetInnerHTML:g(d.content)}):r.jsxs("div",{className:"text-center text-muted-foreground py-12",children:[r.jsx(Cu,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"Select a topic from the sidebar"})]})})}),r.jsx("div",{className:"border-t border-border p-4 bg-muted/30",children:r.jsxs("div",{className:"max-w-3xl mx-auto flex items-center justify-between",children:[h?r.jsxs(re,{variant:"ghost",onClick:()=>t(h),className:"flex items-center gap-2",children:[r.jsx(S5,{className:"w-4 h-4"}),r.jsx("span",{className:"max-w-[150px] truncate",children:y(h)})]}):r.jsx("div",{}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[m+1," of ",f.length]}),x?r.jsxs(re,{onClick:()=>t(x),className:Ne("flex items-center gap-2",v.bg,"hover:opacity-90"),children:[r.jsx("span",{className:"max-w-[150px] truncate",children:y(x)}),r.jsx(Pg,{className:"w-4 h-4"})]}):r.jsx(re,{variant:"outline",onClick:()=>t("intro"),className:"flex items-center gap-2",children:"Start Over"})]})})]})]})}function FW(){const[e,t]=_.useState(null),[s,n]=_.useState(!0),[o,c]=_.useState(!1),[u,l]=_.useState(!1),[d,f]=_.useState(!1),[m,h]=_.useState(null);_.useEffect(()=>{x()},[]);const x=async()=>{try{n(!0);const k=await ue.getSessionStatus();t(k)}catch{Y.error("Failed to load session status")}finally{n(!1)}},w=async()=>{var k,E;c(!0);try{const P=await ue.installSessionAll();P.success?(Y.success("Session persistence installed!"),x()):Y.error(((k=P.hooks)==null?void 0:k.error)||((E=P.command)==null?void 0:E.error)||"Installation failed")}catch{Y.error("Installation failed")}finally{c(!1)}},j=async()=>{c(!0);try{const k=await ue.installSessionHooks();k.success?(Y.success("Session hooks installed!"),x()):Y.error(k.error||"Failed to install hooks")}catch{Y.error("Failed to install hooks")}finally{c(!1)}},C=async()=>{c(!0);try{const k=await ue.installFlushCommand();k.success?(Y.success(k.alreadyInstalled?"/flush command already installed":"/flush command installed!"),x()):Y.error(k.error||"Failed to install command")}catch{Y.error("Failed to install command")}finally{c(!1)}},v=async()=>{l(!0);try{const k=await ue.clearSessionContext();k.success?(Y.success(k.cleared?"Session context cleared":"No context to clear"),x()):Y.error("Failed to clear context")}catch{Y.error("Failed to clear context")}finally{l(!1)}},y=async()=>{try{const k=await ue.getSessionContext();h(k.content),f(!0)}catch{Y.error("Failed to load context")}},g=k=>k===null?"Unknown":k<60?`${k} minutes ago`:k<1440?`${Math.floor(k/60)} hours ago`:`${Math.floor(k/1440)} days ago`;if(s)return r.jsx("div",{className:"flex items-center justify-center h-64",children:r.jsx(Ze,{className:"w-8 h-8 animate-spin text-indigo-600"})});const b=(e==null?void 0:e.hooksInstalled)&&(e==null?void 0:e.flushCommandInstalled)&&(e==null?void 0:e.permissionInstalled);return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-5 shadow-sm",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 rounded-lg bg-indigo-100 dark:bg-indigo-950",children:r.jsx(Vs,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Session Persistence"}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Save and restore Claude Code session context"})]})]}),r.jsx(re,{variant:"ghost",size:"sm",onClick:x,children:r.jsx(Tr,{className:"w-4 h-4"})})]}),r.jsxs("p",{className:"text-sm text-gray-600 dark:text-slate-400",children:["Session persistence allows you to save your current Claude Code context using the ",r.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1.5 py-0.5 rounded text-indigo-600 dark:text-indigo-400",children:"/flush"})," command, and automatically restore it when you start a new session."]})]}),r.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[r.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700",children:r.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Installation Status"})}),r.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-slate-800",children:[r.jsxs("div",{className:"p-4 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[e!=null&&e.hooksInstalled?r.jsx($t,{className:"w-5 h-5 text-green-500"}):r.jsx($s,{className:"w-5 h-5 text-amber-500"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Session Hooks"}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Auto-restore context on session start, preserve on session end"})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(et,{variant:e!=null&&e.hooksInstalled?"default":"secondary",children:e!=null&&e.hooksInstalled?"Installed":"Not Installed"}),!(e!=null&&e.hooksInstalled)&&r.jsx(re,{variant:"outline",size:"sm",onClick:j,disabled:o,children:o?r.jsx(Ze,{className:"w-4 h-4 animate-spin"}):"Install"})]})]}),r.jsxs("div",{className:"p-4 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[e!=null&&e.flushCommandInstalled?r.jsx($t,{className:"w-5 h-5 text-green-500"}):r.jsx($s,{className:"w-5 h-5 text-amber-500"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"/flush Command"}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Adds the /flush command to save session context"})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(et,{variant:e!=null&&e.flushCommandInstalled?"default":"secondary",children:e!=null&&e.flushCommandInstalled?"Installed":"Not Installed"}),!(e!=null&&e.flushCommandInstalled)&&r.jsx(re,{variant:"outline",size:"sm",onClick:C,disabled:o,children:o?r.jsx(Ze,{className:"w-4 h-4 animate-spin"}):"Install"})]})]}),r.jsxs("div",{className:"p-4 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[e!=null&&e.permissionInstalled?r.jsx($t,{className:"w-5 h-5 text-green-500"}):r.jsx($s,{className:"w-5 h-5 text-amber-500"}),r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Write Permission"}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Allows Claude to write session context without prompting"})]})]}),r.jsx(et,{variant:e!=null&&e.permissionInstalled?"default":"secondary",children:e!=null&&e.permissionInstalled?"Granted":"Not Granted"})]})]}),!b&&r.jsx("div",{className:"p-4 bg-gray-50 dark:bg-slate-900 border-t border-gray-200 dark:border-slate-800",children:r.jsxs(re,{onClick:w,disabled:o,className:"w-full bg-indigo-600 hover:bg-indigo-700 text-white",children:[o?r.jsx(Ze,{className:"w-4 h-4 mr-2 animate-spin"}):r.jsx(ui,{className:"w-4 h-4 mr-2"}),"Install All"]})})]}),r.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[r.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700 flex items-center justify-between",children:[r.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Saved Context"}),(e==null?void 0:e.hasSavedContext)&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(re,{variant:"outline",size:"sm",onClick:y,children:[r.jsx(Br,{className:"w-4 h-4 mr-2"}),"View"]}),r.jsx(re,{variant:"outline",size:"sm",onClick:v,disabled:u,className:"text-red-600 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-950",children:u?r.jsx(Ze,{className:"w-4 h-4 animate-spin"}):r.jsx(js,{className:"w-4 h-4"})})]})]}),r.jsx("div",{className:"p-4",children:e!=null&&e.hasSavedContext?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx(ec,{className:"w-4 h-4 text-gray-400"}),r.jsx("span",{className:"text-gray-600 dark:text-slate-400",children:"Last saved:"}),r.jsx("span",{className:"text-gray-900 dark:text-white",children:g(e.contextAge)})]}),e.contextPreview&&r.jsx("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:r.jsx("pre",{className:"text-xs text-gray-600 dark:text-slate-400 whitespace-pre-wrap overflow-hidden",children:e.contextPreview})}),r.jsxs("div",{className:"text-xs text-gray-500 dark:text-slate-500",children:["Storage: ",e.sessionDir]})]}):r.jsxs("div",{className:"text-center py-6",children:[r.jsx(Vs,{className:"w-12 h-12 text-gray-300 dark:text-slate-600 mx-auto mb-3"}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400",children:"No saved context"}),r.jsxs("p",{className:"text-xs text-gray-400 dark:text-slate-500 mt-1",children:["Use ",r.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded",children:"/flush"})," in Claude Code to save your session"]})]})})]}),(e==null?void 0:e.lastSession)&&r.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[r.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700",children:r.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Last Session"})}),r.jsxs("div",{className:"p-4 space-y-2",children:[e.lastSession.session_id&&r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"ID:"}),r.jsx("code",{className:"text-xs bg-gray-100 dark:bg-slate-800 px-2 py-0.5 rounded",children:e.lastSession.session_id})]}),e.lastSession.cwd&&r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"Directory:"}),r.jsx("span",{className:"text-gray-900 dark:text-white font-mono text-xs",children:e.lastSession.cwd})]}),e.lastSession.timestamp&&r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"Ended:"}),r.jsx("span",{className:"text-gray-900 dark:text-white",children:e.lastSession.timestamp})]}),e.lastSession.reason&&r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"Reason:"}),r.jsx(et,{variant:"secondary",children:e.lastSession.reason})]})]})]}),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:"How to Use"}),r.jsxs("ol",{className:"space-y-2 text-sm text-gray-600 dark:text-slate-400",children:[r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"font-medium text-indigo-600 dark:text-indigo-400",children:"1."}),"Install session hooks and the /flush command above"]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"font-medium text-indigo-600 dark:text-indigo-400",children:"2."}),"Use ",r.jsx("code",{className:"bg-white dark:bg-slate-800 px-1.5 py-0.5 rounded",children:"/flush"})," in Claude Code before ending a session"]}),r.jsxs("li",{className:"flex gap-2",children:[r.jsx("span",{className:"font-medium text-indigo-600 dark:text-indigo-400",children:"3."}),"Your context is automatically restored when you start a new session"]})]})]}),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 session # Show session status"}),r.jsx("p",{children:"coder-config session install-hooks # Install session hooks"}),r.jsx("p",{children:"coder-config session clear # Clear saved context"})]})]}),r.jsx(wt,{open:d,onOpenChange:f,children:r.jsxs(xt,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[r.jsxs(vt,{children:[r.jsx(yt,{children:"Saved Context"}),r.jsx(ur,{children:"This context will be restored on your next Claude Code session"})]}),r.jsx("div",{className:"flex-1 overflow-auto py-4",children:r.jsx("pre",{className:"text-sm text-gray-700 dark:text-slate-300 whitespace-pre-wrap bg-gray-50 dark:bg-slate-900 p-4 rounded-lg",children:m||"No content"})}),r.jsx(kt,{children:r.jsx(re,{variant:"ghost",onClick:()=>f(!1),children:"Close"})})]})})]})}const BW=[{id:"projects",label:"All Projects",icon:Rn,section:"Projects"},{id:"explorer",label:"Project Explorer",icon:Wi,section:"Projects"},{id:"workstreams",label:"Workstreams",icon:lS,section:"Projects"},{id:"registry",label:"MCP Registry",icon:Bn,section:"Tools"},{id:"plugins",label:"Plugins",icon:Po,section:"Tools"},{id:"memory",label:"Memory",icon:jo,section:"Tools"},{id:"claude-settings",label:"Claude Code",icon:Vn,section:"Configuration",tool:"claude"},{id:"gemini-settings",label:"Gemini CLI",icon:qt,section:"Configuration",tool:"gemini"},{id:"codex-settings",label:"Codex CLI",icon:qt,section:"Configuration",isNew:!0,tool:"codex"},{id:"antigravity-settings",label:"Antigravity",icon:Sc,section:"Configuration",tool:"antigravity"},{id:"create-mcp",label:"Create MCP",icon:os,section:"Developer"},{id:"loops",label:"Ralph Loops",icon:cc,section:"Developer",isNew:!0},{id:"sessions",label:"Sessions",icon:Vs,section:"System"},{id:"preferences",label:"Preferences",icon:cS,section:"System"},{id:"tutorial",label:"Tutorial",icon:Cu,section:"Help"},{id:"docs",label:"Docs & Help",icon:ko,section:"Help"}],b_=(e,t)=>{try{const s=localStorage.getItem(`claude-config-${e}`);return s?JSON.parse(s):t}catch{return t}},$W=(e,t)=>{try{localStorage.setItem(`claude-config-${e}`,JSON.stringify(t))}catch{}};function zW(){const{projects:e,activeProject:t,fetch:s,setActive:n}=Ex(),{appConfig:o,version:c,fetch:u,checkVersion:l}=Nw(),[d,f]=_.useState(()=>b_("currentView","explorer")),[m,h]=_.useState(!0),[x,w]=_.useState({dir:"",subprojects:[],hierarchy:[]}),[j,C]=_.useState([]),[v,y]=_.useState({mcpServers:{}}),[g,b]=_.useState([]),[k,E]=_.useState([]),[P,T]=_.useState(null),[N,M]=_.useState(null),[I,L]=_.useState(!1),[B,H]=_.useState({title:"",type:""}),[q,z]=_.useState(""),[G,J]=_.useState(""),[K,F]=_.useState({}),[R,O]=_.useState(null),[V,$]=_.useState(!1),[se,de]=_.useState(!1),[pe,X]=_.useState(null),[W,ce]=_.useState(!1),ie=_.useRef(null);_.useEffect(()=>{$W("currentView",d)},[d]);const Q=_.useCallback(async()=>{try{const[Ee,_e,oe,ve,De]=await Promise.all([ue.getProject(),ue.getConfigs(),ue.getRegistry(),ue.getRules(),ue.getCommands()]);w(Ee),C(_e),y(oe),b(ve),E(De),_e.length>0&&!P&&T(_e[_e.length-1])}catch(Ee){Y.error("Failed to load data: "+Ee.message)}finally{h(!1)}},[P]),le=_.useCallback(async(Ee=!1)=>{try{const _e=await s(),oe=_e==null?void 0:_e.find(ve=>ve.isActive);if(Ee&&oe){const ve=await ue.getSubprojects(oe.path);X({dir:oe.path,subprojects:ve.subprojects||[]})}Ee&&!oe&&(b_("currentView",null)||f("projects"))}catch{console.log("Projects API not available")}},[s]),we=async Ee=>{try{const _e=await n(Ee);_e.success?(w({dir:_e.dir,hierarchy:_e.hierarchy,subprojects:_e.subprojects}),X({dir:_e.dir,subprojects:_e.subprojects}),await Q(),Y.success(`Switched to ${_e.project.name}`)):Y.error(_e.error||"Failed to switch project")}catch(_e){Y.error("Failed to switch project: "+_e.message)}},Le=()=>{s()};_.useEffect(()=>{Q(),le(!0),(async()=>{try{const[_e]=await Promise.all([l(),u()]);!ie.current&&(_e!=null&&_e.installedVersion)&&(ie.current=_e.installedVersion);const oe=Nw.getState().appConfig;if(_e!=null&&_e.updateAvailable&&(_e==null?void 0:_e.updateMethod)==="npm")if(oe!=null&&oe.autoUpdate){Y.info(`Auto-updating to v${_e.latestVersion}...`),$(!0);const ve=await ue.performUpdate({updateMethod:_e.updateMethod,targetVersion:_e.latestVersion});if(ve.success){Y.success(`Updated to v${ve.newVersion}! Restarting server...`);try{await ue.restartServer()}catch{}let De=0;const Be=setInterval(async()=>{De++;try{await ue.checkVersion(),clearInterval(Be),Y.success("Server restarted! Reloading..."),setTimeout(()=>window.location.reload(),500)}catch{De>30&&(clearInterval(Be),Y.info("Server restarting. Please refresh the page."),$(!1))}},500)}else Y.error("Auto-update failed: "+ve.error),$(!1),O(_e)}else O(_e)}catch{}})()},[]),_.useEffect(()=>{const _e=setInterval(async()=>{if(ie.current)try{const oe=await ue.checkVersion();oe!=null&&oe.installedVersion&&oe.installedVersion!==ie.current&&(console.log(`[stale-ui] Server updated to v${oe.installedVersion}, refreshing...`),window.location.reload())}catch{}},3e4);return()=>clearInterval(_e)},[]);const Ke=(Ee,_e)=>{if(!Ee||!_e)return!1;const oe=Be=>Be.split(".").map(ze=>parseInt(ze,10)||0),ve=oe(Ee),De=oe(_e);for(let Be=0;Be<Math.max(ve.length,De.length);Be++){if((ve[Be]||0)>(De[Be]||0))return!0;if((ve[Be]||0)<(De[Be]||0))return!1}return!1},fe=async(Ee,_e="npm")=>{$(!0);const oe=await ue.performUpdate({updateMethod:_e,targetVersion:Ee});if(oe.success){Y.success(`Updated to v${oe.newVersion}! Restarting server...`),O(null);try{await ue.restartServer()}catch{}let ve=0;const De=setInterval(async()=>{ve++;try{await ue.checkVersion(),clearInterval(De),Y.success("Server restarted! Reloading..."),setTimeout(()=>window.location.reload(),500)}catch{ve>30&&(clearInterval(De),Y.info("Server restarting. Please refresh the page."),$(!1))}},500);return!0}else return Y.error("Update failed: "+oe.error),$(!1),!1},ye=async()=>{ce(!0);try{const Ee=await ue.checkVersion(),_e=Ee==null?void 0:Ee.installedVersion,oe=Ee==null?void 0:Ee.latestVersion;if(_e&&ie.current&&_e!==ie.current){Y.info(`Refreshing to v${_e}...`),setTimeout(()=>window.location.reload(),500);return}Ke(oe,_e)&&(o!=null&&o.autoUpdate?(ce(!1),Y.info(`Auto-updating to v${oe}...`),await fe(oe,(Ee==null?void 0:Ee.updateMethod)||"npm")):(O({...Ee,updateAvailable:!0}),Y.info(`Update available: v${oe}`)))}catch{Y.error("Failed to check for updates")}finally{ce(!1)}},Je=async()=>{if(R!=null&&R.updateAvailable){$(!0);try{const Ee=await ue.performUpdate({updateMethod:R.updateMethod,sourcePath:R.sourcePath,targetVersion:R.latestVersion});if(Ee.success){Y.success(`Updated to v${Ee.newVersion}! Restarting server...`),O(null),setVersion(Ee.newVersion);try{await ue.restartServer()}catch{}let _e=0;const oe=setInterval(async()=>{_e++;try{await ue.checkVersion(),clearInterval(oe),Y.success("Server restarted! Reloading..."),setTimeout(()=>window.location.reload(),500)}catch{_e>30&&(clearInterval(oe),Y.info("Server restarting. Please refresh the page."),$(!1))}},500)}else Y.error("Update failed: "+Ee.error),$(!1)}catch(Ee){Y.error("Update failed: "+Ee.message),$(!1)}}};_.useEffect(()=>{const Ee=async()=>{try{const{hashes:oe}=await ue.getFileHashes(),ve=K,De=Object.keys(oe).some(ze=>ve[ze]!==oe[ze])||Object.keys(ve).some(ze=>!oe[ze]),Be=ve.__subprojects__!==oe.__subprojects__;if(De&&Object.keys(ve).length>0&&(Y.info("Files changed externally, reloading..."),await Q(),Be&&pe))try{const ze=await ue.getSubprojects(pe.dir);X(St=>({...St,subprojects:ze.subprojects||[]}))}catch{}F(oe)}catch{}},_e=setInterval(Ee,2e3);return Ee(),()=>clearInterval(_e)},[K,Q,pe]);const Ye=new Set;j.forEach(Ee=>{var _e,oe;(((_e=Ee.config)==null?void 0:_e.include)||[]).forEach(ve=>Ye.add(ve)),Object.keys(((oe=Ee.config)==null?void 0:oe.mcpServers)||{}).forEach(ve=>Ye.add(ve))});const ot={mcps:Ye.size,rules:g.length,commands:k.length},ke=async()=>{try{const Ee=await ue.applyConfig(x.dir);if(Ee.tools){const _e=Object.entries(Ee.tools).filter(([,oe])=>oe).map(([oe])=>oe==="claude"?"Claude Code":"Antigravity");_e.length>0?Y.success(`Config applied to: ${_e.join(", ")}`):Y.warning("No tools were updated")}else Y.success("Configuration applied successfully!")}catch(Ee){Y.error("Failed to apply config: "+Ee.message)}},be=async()=>{h(!0),await Q(),Y.success("Data refreshed")};if(m)return r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-4",children:[r.jsx(Ze,{className:"w-8 h-8 animate-spin text-primary"}),r.jsx("p",{className:"text-muted-foreground",children:"Loading configuration..."})]})});const Oe=()=>{switch(d){case"explorer":return r.jsx(y8,{project:x,onRefresh:Q});case"registry":return r.jsx(FH,{registry:v,searchQuery:q,setSearchQuery:z,onUpdate:Q});case"plugins":return r.jsx(hW,{});case"memory":return r.jsx(BH,{project:x,onUpdate:Q});case"create-mcp":return r.jsx(pH,{project:x});case"claude-settings":return r.jsx(eH,{});case"gemini-settings":return r.jsx(tH,{});case"codex-settings":return r.jsx(fH,{});case"antigravity-settings":return r.jsx(oH,{});case"sessions":return r.jsx(FW,{});case"preferences":return r.jsx(Zz,{onConfigChange:()=>u()});case"projects":return r.jsx(VH,{onProjectSwitch:Ee=>{w({dir:Ee.dir,hierarchy:Ee.hierarchy,subprojects:Ee.subprojects}),X({dir:Ee.dir,subprojects:Ee.subprojects}),Q(),le()}});case"workstreams":return r.jsx(fW,{onWorkstreamChange:Ee=>{Y.success(`Switched to workstream: ${Ee.name}`)}});case"loops":return r.jsx(mW,{activeProject:t});case"docs":return r.jsx(dW,{});case"tutorial":return r.jsx(OW,{});default:return null}};return r.jsxs("div",{className:"min-h-screen bg-background",children:[r.jsx("header",{className:"h-16 bg-card border-b border-border sticky top-0 z-50 shadow-sm",children:r.jsxs("div",{className:"h-full px-6 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center shadow-lg shadow-indigo-500/20",children:r.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 128 128",children:[r.jsx("circle",{cx:"64",cy:"64",r:"52",fill:"none",stroke:"white",strokeWidth:"10",strokeDasharray:"24 12"}),r.jsx("circle",{cx:"64",cy:"64",r:"28",fill:"white"}),r.jsx("circle",{cx:"64",cy:"64",r:"12",fill:"#7c3aed"})]})}),r.jsx("div",{children:r.jsxs("h1",{className:"text-xl font-bold text-foreground",children:["Coder ",r.jsx("span",{className:"text-primary",children:"Config"})]})}),R&&r.jsxs("button",{onClick:Je,disabled:V,className:"ml-3 px-2.5 py-1 text-xs font-medium bg-green-100 text-green-700 hover:bg-green-200 rounded-full flex items-center gap-1.5 transition-colors disabled:opacity-50",children:[V?r.jsx(Ze,{className:"w-3 h-3 animate-spin"}):r.jsx(ui,{className:"w-3 h-3"}),V?"Updating...":`Update to v${R.latestVersion}`]})]}),r.jsx(xN,{orientation:"vertical",className:"h-6"}),r.jsx(b8,{projects:e,activeProject:t,onSwitch:we,onAddClick:()=>de(!0),onManageClick:()=>f("projects")})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(S8,{}),r.jsx(re,{variant:"ghost",size:"sm",onClick:be,children:r.jsx(Tr,{className:"w-4 h-4"})}),r.jsxs(re,{onClick:ke,variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",title:"Config auto-applies on save. Click to manually re-apply.",children:[r.jsx(Sc,{className:"w-4 h-4"}),"Re-apply"]})]})]})}),r.jsxs("div",{className:"flex",children:[r.jsxs("aside",{className:"w-64 h-[calc(100vh-64px)] border-r border-border bg-card sticky top-16 flex flex-col",children:[r.jsx(nn,{className:"flex-1 py-4",children:["Projects","Tools","Configuration","Developer","System","Help"].map(Ee=>r.jsxs("div",{className:"mb-6",children:[r.jsx("h3",{className:"px-4 mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:Ee}),r.jsx("div",{className:"space-y-0.5",children:BW.filter(_e=>_e.section===Ee).filter(_e=>{var oe;return _e.id!=="loops"||((oe=o==null?void 0:o.experimental)==null?void 0:oe.ralphLoops)}).filter(_e=>!_e.tool||((o==null?void 0:o.enabledTools)||["claude"]).includes(_e.tool)).map(_e=>{const oe=_e.icon,ve=d===_e.id;return r.jsxs("button",{onClick:()=>f(_e.id),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-all duration-200 border-l-2 ${ve?"bg-accent border-primary text-primary font-medium":"border-transparent text-muted-foreground hover:text-foreground hover:bg-accent"}`,children:[r.jsx(oe,{className:"w-4 h-4"}),r.jsx("span",{className:"flex-1 text-left",children:_e.label}),_e.badge&&r.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${ve?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:ot[_e.badge]}),_e.isNew&&r.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded font-medium bg-green-500/20 text-green-600 dark:text-green-400",children:"new"})]},_e.id)})})]},Ee))}),r.jsx("div",{className:"px-4 py-3 border-t border-border",children:r.jsxs("button",{onClick:ye,disabled:W,className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1",title:"Check for updates",children:[W?r.jsx(Ze,{className:"w-3 h-3 animate-spin"}):null,c?`v${c}`:""]})})]}),r.jsx("main",{style:["explorer","docs","tutorial"].includes(d)?{}:{zoom:.9},className:Ne("flex-1 overflow-auto",["explorer","docs","tutorial"].includes(d)?"h-[calc(100vh-64px)]":"p-6"),children:r.jsx(k_,{mode:"wait",children:r.jsx(Pa.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:["explorer","docs","tutorial"].includes(d)?"h-full":"",children:Oe()},d)})})]}),r.jsx(fN,{open:se,onOpenChange:de,onAdded:Le}),r.jsx(w8,{onStartTutorial:()=>f("tutorial")})]})}function HW(){const[e,t]=_.useState(!1),[s,n]=_.useState(!1),[o,c]=_.useState(!1),u=_.useCallback(async()=>{n(!0);try{await ue.restartServer(),Y.info("Server restarting... page will reload."),setTimeout(()=>{window.location.reload()},2e3)}catch(d){Y.error("Failed to restart: "+d.message),n(!1)}},[]),l=_.useCallback(()=>{c(!0),t(!1),Y.dismiss("update-available")},[]);return _.useEffect(()=>{let d;const f=async()=>{try{const m=await ue.getVersion();console.log("[Update Check]",m),m.needsRestart&&!o&&t(!0)}catch{}};return f(),d=setInterval(f,3e4),()=>clearInterval(d)},[o]),r.jsx(_8,{children:r.jsxs("div",{className:"min-h-screen bg-background",children:[e&&!s&&r.jsxs("div",{className:"fixed top-0 left-0 right-0 z-50 bg-blue-600 text-white px-4 py-2 flex items-center justify-center gap-2 shadow-lg cursor-pointer hover:bg-blue-700 transition-colors",onClick:u,children:[r.jsx(Tr,{className:"w-4 h-4"}),r.jsx("span",{className:"text-sm font-medium",children:"Update available — click to restart"}),r.jsx("button",{onClick:d=>{d.stopPropagation(),l()},className:"absolute right-3 p-1 hover:bg-blue-500 rounded",children:r.jsx(oi,{className:"w-4 h-4"})})]}),s&&r.jsxs("div",{className:"fixed top-0 left-0 right-0 z-50 bg-amber-600 text-white px-4 py-2 flex items-center justify-center gap-2",children:[r.jsx(Tr,{className:"w-4 h-4 animate-spin"}),r.jsx("span",{className:"text-sm font-medium",children:"Restarting server..."})]}),r.jsx(zW,{}),r.jsx(DP,{position:"bottom-right",richColors:!0})]})})}aP.createRoot(document.getElementById("root")).render(r.jsx(HW,{}));
|
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-BgxtqcxY.js"></script>
|
|
23
23
|
<link rel="stylesheet" crossorigin href="/assets/index-ChBU02w_.css">
|
|
24
24
|
</head>
|
|
25
25
|
<body>
|