cogpit 2.2.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/cli.js +4779 -3746
  2. package/dist/web/assets/{CommandPaletteHost--_g3tlgk.js → CommandPaletteHost-DU1jhhYG.js} +1 -1
  3. package/dist/web/assets/ConfigBrowser-CTZR8nw6.js +1 -0
  4. package/dist/web/assets/{HighlightedEditor-Byq8pOUC.js → HighlightedEditor-CNTtimUO.js} +2 -2
  5. package/dist/web/assets/{KeyboardShortcutsDialog-CFhdeGBw.js → KeyboardShortcutsDialog-DtTE4xjZ.js} +1 -1
  6. package/dist/web/assets/{MobileFileChanges-uxpxh1W6.js → MobileFileChanges-DaJh6sQ7.js} +1 -1
  7. package/dist/web/assets/PreviewPanel-BOL9gNaQ.js +1 -0
  8. package/dist/web/assets/{ProjectFilesPanel-ByyaiSGy.js → ProjectFilesPanel-CBFFT9qJ.js} +3 -3
  9. package/dist/web/assets/{ProjectSwitcherModal-BRbFj3Dd.js → ProjectSwitcherModal-UUQMoktd.js} +1 -1
  10. package/dist/web/assets/{TerminalOutput-Aavw8QCx.js → TerminalOutput-T82q4Tf9.js} +1 -1
  11. package/dist/web/assets/ThemeSelectorModal-rFVnzZuC.js +1 -0
  12. package/dist/web/assets/WorkflowsPanel-COZwo8h-.js +1 -0
  13. package/dist/web/assets/WorktreePanel-DvZNvNhH.js +1 -0
  14. package/dist/web/assets/{index-C-5Kgwol.js → index-BhjwMUil.js} +4 -4
  15. package/dist/web/assets/index-CghBqEmp.js +153 -0
  16. package/dist/web/assets/index-CpHg1sRc.js +1 -0
  17. package/dist/web/assets/index-XlQRZ_Un.js +1 -0
  18. package/dist/web/assets/index-f2DFkgKZ.css +1 -0
  19. package/dist/web/assets/{session-parser.worker-RMitC4X_.js → session-parser.worker-QY58jiXs.js} +1 -1
  20. package/dist/web/assets/vendor-ui-B9m2oOMV.js +867 -0
  21. package/dist/web/index.html +3 -3
  22. package/package.json +1 -1
  23. package/dist/web/assets/ConfigBrowser-DrAZQBx8.js +0 -1
  24. package/dist/web/assets/PreviewPanel-DC6OTZfZ.js +0 -1
  25. package/dist/web/assets/ThemeSelectorModal-CxGMhlkF.js +0 -1
  26. package/dist/web/assets/WorkflowsPanel-Beg1AAtq.js +0 -1
  27. package/dist/web/assets/WorktreePanel-B17_SlFC.js +0 -1
  28. package/dist/web/assets/index-CJcccHRp.js +0 -1
  29. package/dist/web/assets/index-CTpAqQye.js +0 -1
  30. package/dist/web/assets/index-DB1wEO_I.js +0 -148
  31. package/dist/web/assets/index-DU9XxwBy.css +0 -1
  32. package/dist/web/assets/vendor-ui-CyII6N5s.js +0 -807
@@ -15,12 +15,12 @@
15
15
  .dark body { background: #09090b; color: #fafafa; }
16
16
  body { background: #fafafa; color: #09090b; }
17
17
  </style>
18
- <script type="module" crossorigin src="/assets/index-DB1wEO_I.js"></script>
18
+ <script type="module" crossorigin src="/assets/index-CghBqEmp.js"></script>
19
19
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-gGw_S5I_.js">
20
- <link rel="modulepreload" crossorigin href="/assets/vendor-ui-CyII6N5s.js">
20
+ <link rel="modulepreload" crossorigin href="/assets/vendor-ui-B9m2oOMV.js">
21
21
  <link rel="modulepreload" crossorigin href="/assets/vendor-markdown-BE1gYnO9.js">
22
22
  <link rel="modulepreload" crossorigin href="/assets/vendor-shiki-DOn6sF-i.js">
23
- <link rel="stylesheet" crossorigin href="/assets/index-DU9XxwBy.css">
23
+ <link rel="stylesheet" crossorigin href="/assets/index-f2DFkgKZ.css">
24
24
  </head>
25
25
  <body>
26
26
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogpit",
3
- "version": "2.2.1",
3
+ "version": "2.4.0",
4
4
  "description": "Run Cogpit's local Claude Code, Codex, and GitHub Copilot CLI interface without installing it",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1 +0,0 @@
1
- import{c as F,j as t,r as o}from"./vendor-react-gGw_S5I_.js";import{b0 as je,b2 as be,U as P,a9 as ye,aa as W,aV as q,ad as Ce,ae as X,a_ as se,B as z,w as L,b3 as ke,b4 as ve,b5 as Ne,b6 as Se,b7 as we,b8 as De,b9 as V,ba as Te,bb as Z,bc as Ee,V as ee,_ as ae,bd as Re,$ as le,a0 as ie,a2 as re,a3 as oe,a4 as ce,a5 as de,a6 as ue,ai as Ie,E as Oe,y as ze,z as Ae,G as Le,H as Be,T as $e,m as Fe,I as te,n as Ge,ab as Me,q as Pe,be as _e}from"./index-DB1wEO_I.js";import{ag as Ue,B as Ve,b as He,a1 as Ke,ah as Je,ai as Qe,aj as me,ak as xe,al as Ye,am as We,o as H,X as K,P as qe,an as fe,ao as Xe,T as Ze,_ as et,S as tt}from"./vendor-ui-CyII6N5s.js";import{H as nt}from"./HighlightedEditor-Byq8pOUC.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const st={agent:"bg-muted text-muted-foreground",skill:"bg-muted text-muted-foreground",command:"bg-muted text-muted-foreground",instructions:"bg-muted text-muted-foreground",settings:"bg-muted text-muted-foreground"},at={agents:{subdir:"agents",fileType:"agent"},skills:{subdir:"skills",fileType:"skill"},commands:{subdir:"commands",fileType:"command"}},ne=["instructions","agents","skills","commands","settings"],lt={instructions:{label:"Instructions",icon:Je,color:"text-muted-foreground"},agents:{label:"Agents",icon:Ke,color:"text-muted-foreground"},skills:{label:"Skills",icon:He,color:"text-muted-foreground"},commands:{label:"Commands",icon:Ve,color:"text-muted-foreground"},settings:{label:"Settings",icon:Ue,color:"text-muted-foreground"}};function J(l,e,i){const n=[];for(const s of l)s.type==="directory"&&s.children?n.push(...J(s.children,e,i)):s.type==="file"&&n.push({name:s.name,path:s.path,fileType:s.fileType||"unknown",description:s.description||"",scope:e,pluginName:i,readOnly:s.readOnly??e==="plugin",cli:s.cli,linkTarget:s.linkTarget});return n}function it(l){const e={instructions:[],agents:[],skills:[],commands:[],settings:[]};for(const i of l){const n=J(i.items,i.scope,i.pluginName);for(const s of n)switch(s.fileType){case"instructions":e.instructions.push(s);break;case"agent":e.agents.push(s);break;case"skill":e.skills.push(s);break;case"command":e.commands.push(s);break;case"settings":default:e.settings.push(s)}}return e}function he(l){const e=F.c(5),{scope:i,pluginName:n}=l;if(i==="plugin"&&n){let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Qe,{"data-icon":"inline-start",className:"size-3"}),e[0]=r):r=e[0];let u;return e[1]!==n?(u=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[r,n]}),e[1]=n,e[2]=u):u=e[2],u}if(i==="project"){let r;return e[3]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(me,{"data-icon":"inline-start",className:"size-3"}),"project"]}),e[3]=r):r=e[3],r}let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(xe,{"data-icon":"inline-start",className:"size-3"}),"global"]}),e[4]=s):s=e[4],s}const rt=Object.fromEntries(je().map(l=>[l.kind,be(l.kind)]));function pe(l){const e=F.c(10),{cli:i,variant:n}=l,s=n===void 0?"compact":n;if(!i)return null;if(i.length===0){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Ye,{"data-icon":"inline-start",className:"size-3"}),e[0]=m):m=e[0];const c=s==="full"&&"unlinked";let d;return e[1]!==c?(d=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-warning",title:"Present in the shared source directory but not linked into any CLI",children:[m,c]}),e[1]=c,e[2]=d):d=e[2],d}let r;if(e[3]!==i||e[4]!==s){let m;e[6]!==s?(m=c=>{const d=rt[c];return t.jsx("span",{title:d.label,className:s==="full"?"flex h-5 items-center justify-center rounded border bg-muted px-1.5 text-xs font-medium text-muted-foreground":"flex size-5 items-center justify-center rounded border bg-muted text-xs font-medium text-muted-foreground",children:s==="full"?c:d.letter},c)},e[6]=s,e[7]=m):m=e[7],r=i.map(m),e[3]=i,e[4]=s,e[5]=r}else r=e[5];let u;return e[8]!==r?(u=t.jsx("span",{className:"flex items-center gap-0.5 shrink-0",children:r}),e[8]=r,e[9]=u):u=e[9],u}function ge(l){const e=F.c(10),{linkTarget:i,variant:n,className:s}=l,r=n===void 0?"compact":n;if(!i)return null;let u;e[0]!==s?(u=P("flex min-w-0 shrink-0 items-center gap-1 text-info",s),e[0]=s,e[1]=u):u=e[1];const m=`Symlink → ${i}`;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(We,{"data-icon":"inline-start",className:"size-3 shrink-0"}),e[2]=c):c=e[2];let d;e[3]!==i||e[4]!==r?(d=r==="full"&&t.jsxs("span",{className:"truncate font-mono text-xs",children:["→ ",i]}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let g;return e[6]!==u||e[7]!==m||e[8]!==d?(g=t.jsxs("span",{className:u,title:m,children:[c,d]}),e[6]=u,e[7]=m,e[8]=d,e[9]=g):g=e[9],g}function ot({globalDir:l,projectDir:e,fileType:i,onCreated:n,onCancel:s}){const[r,u]=o.useState(""),[m,c]=o.useState(e?"project":"global"),[d,g]=o.useState(!1),N=o.useRef(null),k=o.useId();o.useEffect(()=>{var h;(h=N.current)==null||h.focus()},[]);const S=m==="project"&&e?e:l,f=!!l&&!!e;async function w(){if(!(!r.trim()||!S)){g(!0);try{const h=await L("/api/config-browser/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dir:S,fileType:i,name:r.trim()})});if(h.ok){const p=await h.json();n(p.path,i,m)}}finally{g(!1)}}}return t.jsxs(ye,{className:"gap-3 px-3 py-2",children:[f&&t.jsxs(W,{children:[t.jsx(q,{children:"Scope"}),t.jsxs(Ce,{"aria-label":"File scope",value:[m],onValueChange:h=>{const p=h[0];(p==="global"||p==="project")&&c(p)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsxs(X,{value:"global",className:"flex-1",children:[t.jsx(xe,{"data-icon":"inline-start"}),"Global"]}),t.jsxs(X,{value:"project",className:"flex-1",children:[t.jsx(me,{"data-icon":"inline-start"}),"Project"]})]})]}),t.jsxs(W,{children:[t.jsxs(q,{htmlFor:k,children:[i.charAt(0).toUpperCase()+i.slice(1)," name"]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(se,{id:k,ref:N,type:"text",value:r,onChange:h=>u(h.target.value),onKeyDown:h=>{h.key==="Enter"&&w(),h.key==="Escape"&&s()},placeholder:`${i} name...`,className:"h-7 min-w-0 flex-1 text-xs",disabled:d}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":`Create ${i}`,onClick:()=>void w(),disabled:d||!r.trim()||!S,children:t.jsx(H,{"data-icon":"inline-start"})}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":"Cancel create",onClick:s,children:t.jsx(K,{"data-icon":"inline-start"})})]})]})]})}function ct(l){const e=F.c(50),{category:i,items:n,selectedPath:s,onSelect:r,onNewFile:u,onDeleteItem:m,onRenameItem:c,renamingPath:d,renameValue:g,onRenameValueChange:N,onRenameSubmit:k,onRenameCancel:S,creatingInCategory:f,onCreated:w,onCancelCreate:h}=l,p=lt[i],j=p.icon;if(n.length===0&&!u)return null;let D;e[0]!==p.color?(D=P("size-3.5",p.color),e[0]=p.color,e[1]=D):D=e[1];let T;e[2]!==j||e[3]!==D?(T=t.jsx(j,{"data-icon":"inline-start",className:D}),e[2]=j,e[3]=D,e[4]=T):T=e[4];let y;e[5]!==p.label?(y=t.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:p.label}),e[5]=p.label,e[6]=y):y=e[6];let R;e[7]!==n.length?(R=t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n.length}),e[7]=n.length,e[8]=R):R=e[8];let C;e[9]!==i||e[10]!==u?(C=u&&t.jsxs(ke,{children:[t.jsx(ve,{render:t.jsx(z,{variant:"ghost",size:"icon-xs",className:"opacity-0 transition-opacity group-hover:opacity-100","aria-label":`New ${i.slice(0,-1)}`,onClick:u}),children:t.jsx(qe,{"data-icon":"inline-start"})}),t.jsxs(Ne,{children:["New ",i.slice(0,-1)]})]}),e[9]=i,e[10]=u,e[11]=C):C=e[11];let v;e[12]!==T||e[13]!==y||e[14]!==R||e[15]!==C?(v=t.jsxs("div",{className:"group flex h-8 items-center gap-1.5 px-3",children:[T,y,R,C]}),e[12]=T,e[13]=y,e[14]=R,e[15]=C,e[16]=v):v=e[16];let E;if(e[17]!==n||e[18]!==m||e[19]!==S||e[20]!==c||e[21]!==k||e[22]!==N||e[23]!==r||e[24]!==g||e[25]!==d||e[26]!==s){let $;e[28]!==m||e[29]!==S||e[30]!==c||e[31]!==k||e[32]!==N||e[33]!==r||e[34]!==g||e[35]!==d||e[36]!==s?($=b=>{const _=s===b.path;if(d===b.path)return t.jsxs("div",{className:"flex items-center gap-1 border-l-2 border-foreground/30 bg-accent px-3 py-1",children:[t.jsx(se,{value:g,onChange:A=>N(A.target.value),onKeyDown:A=>{A.key==="Enter"&&k(),A.key==="Escape"&&S()},autoFocus:!0,className:"h-7 min-w-0 flex-1 text-xs"}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":"Save name",onClick:k,disabled:!g.trim(),children:t.jsx(H,{"data-icon":"inline-start"})}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":"Cancel rename",onClick:S,children:t.jsx(K,{"data-icon":"inline-start"})})]},b.path);const G=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-sm",children:b.name}),t.jsx(ge,{linkTarget:b.linkTarget}),b.readOnly&&t.jsx(fe,{className:"size-2.5 shrink-0 text-muted-foreground/40"})]}),b.description&&t.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:b.description})]}),t.jsx(pe,{cli:b.cli}),t.jsx(he,{scope:b.scope,pluginName:b.pluginName})]}),M=P("flex w-full items-center gap-2 border-l-2 px-3 py-2 text-left text-sm transition-colors",_?"border-foreground/30 bg-accent text-accent-foreground":"border-transparent text-muted-foreground hover:bg-accent hover:text-foreground");return!m||!c?t.jsx("button",{type:"button",className:M,onClick:()=>r(b),children:G},b.path):t.jsxs(Se,{children:[t.jsx(we,{render:t.jsx("button",{type:"button",className:M,onClick:()=>r(b)}),children:G}),t.jsx(De,{className:"min-w-36",children:b.readOnly?t.jsx(V,{children:t.jsx(Te,{children:"Read-only file"})}):t.jsxs(t.Fragment,{children:[t.jsx(V,{children:t.jsx(Z,{onClick:()=>c(b),children:"Rename"})}),t.jsx(Ee,{}),t.jsx(V,{children:t.jsx(Z,{variant:"destructive",onClick:()=>m(b),children:"Delete"})})]})})]},b.path)},e[28]=m,e[29]=S,e[30]=c,e[31]=k,e[32]=N,e[33]=r,e[34]=g,e[35]=d,e[36]=s,e[37]=$):$=e[37],E=n.map($),e[17]=n,e[18]=m,e[19]=S,e[20]=c,e[21]=k,e[22]=N,e[23]=r,e[24]=g,e[25]=d,e[26]=s,e[27]=E}else E=e[27];let I;e[38]!==f||e[39]!==n.length?(I=n.length===0&&!f&&t.jsx("p",{className:"px-3 py-1 text-xs text-muted-foreground",children:"None configured"}),e[38]=f,e[39]=n.length,e[40]=I):I=e[40];let O;e[41]!==f||e[42]!==h||e[43]!==w?(O=f&&t.jsx(ot,{globalDir:f.globalDir,projectDir:f.projectDir,fileType:f.fileType,onCreated:w,onCancel:h}),e[41]=f,e[42]=h,e[43]=w,e[44]=O):O=e[44];let B;return e[45]!==v||e[46]!==E||e[47]!==I||e[48]!==O?(B=t.jsxs("section",{children:[v,E,I,O]}),e[45]=v,e[46]=E,e[47]=I,e[48]=O,e[49]=B):B=e[49],B}function dt({file:l,onDeleted:e,readOnly:i=!1}){const[n,s]=o.useState(null),[r,u]=o.useState(null),[m,c]=o.useState(!0),[d,g]=o.useState(!1),[N,k]=o.useState(!1),[S,f]=o.useState(!1),[w,h]=o.useState(!1),p=n!==null&&n!==r,j=i||l.readOnly;o.useEffect(()=>{c(!0),s(null),u(null),k(!1),f(!1),L(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`).then(C=>C.json()).then(C=>{s(C.content??""),u(C.content??"")}).catch(()=>{s(""),u("")}).finally(()=>c(!1))},[l.path]);const D=o.useCallback(async()=>{if(!(!p||j)){g(!0);try{(await L("/api/config-browser/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:l.path,content:n})})).ok&&(u(n),k(!0),setTimeout(()=>k(!1),2e3))}finally{g(!1)}}},[n,l.path,p,j]),T=o.useCallback(()=>{s(r)},[r]),y=o.useCallback(async()=>{if(!j){h(!0);try{(await L(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`,{method:"DELETE"})).ok&&(f(!1),e())}catch{}finally{h(!1)}}},[l.path,j,e]);o.useEffect(()=>{function C(v){!j&&(v.metaKey||v.ctrlKey)&&v.key==="s"&&(v.preventDefault(),D())}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[D,j]);function R(){return N?"Saved!":d?"Saving...":"Save"}return t.jsxs("div",{className:"flex flex-1 flex-col min-h-0 min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b bg-card px-4 py-2",children:[t.jsx(ee,{variant:"outline",className:P("h-5 text-xs",st[l.fileType]||"bg-muted text-muted-foreground"),children:l.fileType}),t.jsx(he,{scope:l.scope,pluginName:l.pluginName}),t.jsx(pe,{cli:l.cli,variant:"full"}),j&&t.jsxs(ee,{variant:"outline",className:"h-5 bg-muted text-xs text-muted-foreground",children:[t.jsx(fe,{"data-icon":"inline-start",className:"size-3"})," read-only"]}),p&&t.jsx("span",{className:"size-2 shrink-0 rounded-full bg-warning",title:"Unsaved changes"}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto min-w-0",children:[t.jsx(ge,{linkTarget:l.linkTarget,variant:"full"}),t.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",title:l.path,children:l.path})]})]}),m?t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"Loading..."}):t.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[t.jsx(nt,{value:n??"",onChange:s,readOnly:j,filePath:l.path}),!j&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t bg-card px-4 py-2",children:[t.jsxs(z,{size:"xs",onClick:D,disabled:!p||d,children:[t.jsx(H,{"data-icon":"inline-start"}),R()]}),t.jsxs(z,{variant:"outline",size:"xs",onClick:T,disabled:!p,children:[t.jsx(Xe,{"data-icon":"inline-start"}),"Discard"]}),t.jsx("div",{className:"flex-1"}),t.jsxs(ae,{open:S,onOpenChange:f,children:[t.jsxs(Re,{render:t.jsx(z,{variant:"outline",size:"xs"}),children:[t.jsx(Ze,{"data-icon":"inline-start"}),"Delete"]}),t.jsxs(le,{size:"sm",children:[t.jsxs(ie,{children:[t.jsx(re,{children:"Delete configuration file?"}),t.jsxs(oe,{children:['Delete "',l.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(ce,{children:[t.jsx(de,{size:"sm",disabled:w,children:"Cancel"}),t.jsxs(ue,{variant:"destructive",size:"sm",disabled:w,onClick:()=>void y(),children:[w&&t.jsx(Ie,{"data-icon":"inline-start"}),w?"Deleting...":"Delete file"]})]})]})]})]})]})]})}function ut(){const l=F.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Oe,{className:"border-0",children:t.jsxs(ze,{children:[t.jsx(Ae,{variant:"icon",children:t.jsx(et,{})}),t.jsx(Le,{children:"Select a configuration file"}),t.jsx(Be,{children:"Browse instructions, agents, skills, commands, and settings from the sidebar."})]})}),l[0]=e):e=l[0],e}function mt(l){return l.cli?l.cli.length>0?l.cli.join(" "):"unlinked":""}function xt(l,e){if(!e)return l;const i=e.toLowerCase();return l.filter(n=>[n.name,n.description,n.path,n.linkTarget??"",mt(n)].some(r=>r.toLowerCase().includes(i)))}const yt=o.memo(function({projectPath:e,initialFilePath:i}){var A,Y;const n=$e("configWrite"),[s,r]=o.useState([]),[u,m]=o.useState(!0),[c,d]=o.useState(null),[g,N]=o.useState(null),[k,S]=o.useState(""),[f,w]=o.useState(null),[h,p]=o.useState(""),[j,D]=o.useState(null),T=o.useRef(!1),y=o.useCallback(async()=>{if(!n){r([]),d(null),m(!1);return}m(!0);try{const a=e?`/api/config-browser/tree?cwd=${encodeURIComponent(e)}`:"/api/config-browser/tree",x=await L(a);if(x.ok){const U=await x.json();r(U.sections||[])}}finally{m(!1)}},[n,e]);o.useEffect(()=>{y()},[y]),o.useEffect(()=>{if(!i||u||T.current)return;const a=s.flatMap(x=>J(x.items,x.scope,x.pluginName)).find(x=>x.path===i);a&&(d(a),T.current=!0)},[i,u,s]);const R=it(s),C=Object.fromEntries(ne.map(a=>[a,xt(R[a],k)])),v=(A=s.find(a=>a.scope==="global"))==null?void 0:A.baseDir,E=(Y=s.find(a=>a.scope==="project"))==null?void 0:Y.baseDir,I=o.useCallback(a=>{d(a),N(null)},[]),O=o.useCallback((a,x,U)=>{N(null),y(),d({path:a,name:a.split("/").pop()||"",fileType:x,readOnly:!1,scope:U,description:""})},[y]),B=o.useCallback(()=>{d(null),y()},[y]),$=o.useCallback(a=>{if(!n||!v&&!E)return;const x=at[a];x&&N({category:a,globalDir:v?`${v}/${x.subdir}`:null,projectDir:E?`${E}/${x.subdir}`:null,fileType:x.fileType})},[n,v,E]),b=o.useCallback(a=>{!n||a.readOnly||D(a)},[n]),_=o.useCallback(async()=>{if(!n||!j||j.readOnly)return;const a=j;D(null);try{(await L(`/api/config-browser/file?path=${encodeURIComponent(a.path)}`,{method:"DELETE"})).ok&&((c==null?void 0:c.path)===a.path&&d(null),y())}catch{}},[n,y,j,c]),Q=o.useCallback(a=>{if(!n||a.readOnly)return;const x=a.name==="SKILL.md"?a.path.split("/").slice(-2,-1)[0]||a.name:a.name.replace(/\.[^.]+$/,"");w(a),p(x)},[n]),G=o.useCallback(async()=>{if(!(!n||!f||!h.trim()))try{const a=await L("/api/config-browser/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:f.path,newName:h.trim()})});if(a.ok){const x=await a.json();w(null),p(""),await y(),x.newPath&&d({...f,path:x.newPath,name:x.newPath.split("/").pop()||f.name})}}catch{}},[n,f,h,y]),M=o.useCallback(()=>{w(null),p("")},[]);return n?t.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0",children:[t.jsxs("div",{className:"flex min-h-0 w-80 shrink-0 flex-col border-r bg-sidebar",children:[t.jsxs("div",{className:"flex h-11 items-center gap-2 border-b px-3",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Configuration"}),e&&t.jsx("span",{className:"ml-auto truncate text-xs text-muted-foreground",title:e,children:e.split("/").pop()})]}),t.jsx("div",{className:"border-b p-2",children:t.jsxs(Fe,{children:[t.jsx(te,{children:t.jsx(tt,{"data-icon":"inline-start"})}),t.jsx(Ge,{value:k,onChange:a=>S(a.target.value),placeholder:"Search configuration"}),k&&t.jsx(te,{align:"inline-end",children:t.jsx(Me,{size:"icon-xs","aria-label":"Clear search",onClick:()=>S(""),children:t.jsx(K,{"data-icon":"inline-start"})})})]})}),t.jsx(Pe,{className:"flex-1",children:t.jsx("div",{className:"flex flex-col gap-1 py-2",children:u?t.jsx("div",{className:"flex flex-col gap-2 px-3 py-2","aria-label":"Loading configuration",children:Array.from({length:6},(a,x)=>t.jsx(_e,{className:"h-8 w-full"},x))}):ne.map(a=>{const x=a==="agents"||a==="skills"||a==="commands";return t.jsx(ct,{category:a,items:C[a],selectedPath:(c==null?void 0:c.path)??null,onSelect:I,onNewFile:n&&x?()=>$(a):void 0,onDeleteItem:n?b:void 0,onRenameItem:n?Q:void 0,renamingPath:(f==null?void 0:f.path)??null,renameValue:h,onRenameValueChange:p,onRenameSubmit:G,onRenameCancel:M,creatingInCategory:n&&(g==null?void 0:g.category)===a?g:null,onCreated:O,onCancelCreate:()=>N(null)},a)})})})]}),c?t.jsx(dt,{file:c,onDeleted:B,readOnly:!n}):t.jsx(ut,{}),t.jsx(ae,{open:j!==null,onOpenChange:a=>{a||D(null)},children:t.jsxs(le,{size:"sm",children:[t.jsxs(ie,{children:[t.jsx(re,{children:"Delete configuration file?"}),t.jsxs(oe,{children:['Delete "',j==null?void 0:j.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(ce,{children:[t.jsx(de,{size:"sm",children:"Cancel"}),t.jsx(ue,{variant:"destructive",size:"sm",onClick:()=>void _(),children:"Delete file"})]})]})})]}):t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Server configuration is available to administrators only."})});export{yt as ConfigBrowser};
@@ -1 +0,0 @@
1
- import{r as s,j as t}from"./vendor-react-gGw_S5I_.js";import{a8 as ne,B as g,l as K,a9 as ie,aa as oe,m as le,n as ce,I as de,ab as G,ac as ue,ad as he,ae as pe,U as me,E as fe,y as xe,z as we,G as ve,H as ge,af as be,w as je,Q as b}from"./index-DB1wEO_I.js";import{f as H,X as ye,c as Se,E as ke,g as Ie,M as Ne,h as Ee,i as Me,j as Pe,Z as ze,k as Re}from"./vendor-ui-CyII6N5s.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const W=360,Ce=560,V="cogpit-preview-width",Y="cogpit-preview-viewport",_="cogpit-preview-zoom",N=.5,E=1.5,I=.1,h={responsive:{label:"Responsive",width:null,height:null,icon:Pe},phone:{label:"Phone",width:390,height:844,icon:Me},tablet:{label:"Tablet",width:768,height:1024,icon:Ee},desktop:{label:"Desktop",width:1280,height:800,icon:Ne}};function De(){try{const a=Number(localStorage.getItem(V));if(Number.isFinite(a)&&a>=W)return a}catch{}return Ce}function Te(){try{const a=localStorage.getItem(Y);if(a&&a in h)return a}catch{}return"responsive"}function We(){try{const a=localStorage.getItem(_);if(a===null)return 1;const i=Number(a);if(Number.isFinite(i))return Math.min(E,Math.max(N,i))}catch{}return 1}function X(a){return be(`cogpit-preview-url:${a}`)}function A(a){const i=a.trim();if(!i||/^[a-z][a-z\d+.-]*:/i.test(i)&&!/^https?:\/\//i.test(i)&&!/^[^/]+:\d+(?:\/|$)/.test(i))return null;const j=/^https?:\/\//i.test(i)?i:`http://${i}`;try{const n=new URL(j);return n.protocol!=="http:"&&n.protocol!=="https:"?null:n.href}catch{return null}}function B(a,i){return`http://${i||"localhost"}:${a}/`}function Le({cwd:a,onClose:i}){const[M,j]=s.useState([]),[n,P]=s.useState(""),[$,y]=s.useState(""),[z,R]=s.useState(null),[Q,q]=s.useState(0),[J,C]=s.useState(!1),[S,ee]=s.useState(De),[l,te]=s.useState(Te),[o,p]=s.useState(We),c=s.useRef(null),O=s.useRef(null),D=s.useRef(null),{activeDevice:m}=ne(),k=(m==null?void 0:m.host)??(window.location.hostname||"localhost"),re=m==null?void 0:m.id;s.useEffect(()=>{let e="";try{e=localStorage.getItem(X(a))??""}catch{}const r=e?A(e)??"":"";P(r),y(r),R(null)},[a,re]),s.useEffect(()=>{let e=!1;async function r(){try{const u=await je(`/api/background-tasks?cwd=${encodeURIComponent(a)}`);if(e||!u.ok)return;const x=await u.json(),f=Array.isArray(x)?x:[];j(f);const L=f.flatMap(w=>w.ports.filter(v=>w.portStatus[v])).at(0);if(L){const w=B(L,k);P(v=>v||w),y(v=>v||w)}}catch{e||j([])}}r();const d=window.setInterval(r,1e4);return()=>{e=!0,window.clearInterval(d)}},[a,k]),s.useEffect(()=>{if(n)try{localStorage.setItem(X(a),n)}catch{}},[a,n]),s.useEffect(()=>{try{localStorage.setItem(Y,l),localStorage.setItem(_,String(o))}catch{}},[l,o]);const Z=s.useMemo(()=>[...new Set(M.flatMap(e=>e.ports.filter(r=>e.portStatus[r])))].sort((e,r)=>e-r),[M]),U=s.useCallback(e=>{const r=A(e);if(!r){R("Enter a valid HTTP or HTTPS URL.");return}R(null),P(r),y(r),C(!0)},[]),T=s.useCallback(()=>{n&&(C(!0),q(e=>e+1))},[n]);s.useEffect(()=>{function e(r){var d,u,x;if((d=O.current)!=null&&d.contains(document.activeElement)){if(b("previewRefresh",r)){r.preventDefault(),T();return}if(b("previewFocusUrl",r)){r.preventDefault(),(u=D.current)==null||u.focus(),(x=D.current)==null||x.select();return}if(b("previewZoomIn",r)){r.preventDefault(),p(f=>Math.min(E,Number((f+I).toFixed(1))));return}if(b("previewZoomOut",r)){r.preventDefault(),p(f=>Math.max(N,Number((f-I).toFixed(1))));return}b("previewResetZoom",r)&&(r.preventDefault(),p(1))}}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[T]);const ae=s.useCallback(e=>{e.preventDefault(),c.current={startX:e.clientX,startWidth:S,currentWidth:S},e.currentTarget.setPointerCapture(e.pointerId)},[S]),se=s.useCallback(e=>{if(!c.current)return;const r=Math.max(W,window.innerWidth*.7),d=c.current.startWidth+(c.current.startX-e.clientX),u=Math.min(r,Math.max(W,d));c.current.currentWidth=u,ee(u)},[]),F=s.useCallback(()=>{if(!c.current)return;const e=c.current.currentWidth;c.current=null;try{localStorage.setItem(V,String(e))}catch{}},[]);return t.jsxs("aside",{ref:O,"aria-label":"Development preview",className:"view-transition-right-panel panel-enter-right relative flex min-h-0 shrink-0 flex-col border-l bg-background",style:{width:S},children:[t.jsx("div",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 w-1 cursor-col-resize hover:bg-primary/30",onPointerDown:ae,onPointerMove:se,onPointerUp:F,onPointerCancel:F}),t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[t.jsx(H,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),t.jsx("h2",{className:"text-sm font-medium",children:"Preview"}),t.jsx("span",{className:"flex-1"}),t.jsx(g,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Close preview",children:t.jsx(ye,{"data-icon":"inline-start"})})]}),t.jsx(K,{}),t.jsx("form",{className:"p-2",onSubmit:e=>{e.preventDefault(),U($)},children:t.jsx(ie,{className:"gap-2",children:t.jsxs(oe,{"data-invalid":!!z,children:[t.jsxs(le,{children:[t.jsx(ce,{ref:D,"aria-label":"Preview URL","aria-invalid":!!z,value:$,onChange:e=>y(e.target.value),placeholder:"localhost:3000",spellCheck:!1}),t.jsxs(de,{align:"inline-end",children:[t.jsx(G,{size:"icon-xs",disabled:!n,onClick:T,"aria-label":"Refresh preview",children:t.jsx(Se,{"data-icon":"inline-start",className:J?"animate-spin":void 0})}),t.jsx(G,{size:"icon-xs",disabled:!n,onClick:()=>window.open(n,"_blank","noopener,noreferrer"),"aria-label":"Open preview in browser",children:t.jsx(ke,{"data-icon":"inline-start"})})]})]}),t.jsx(ue,{children:z})]})})}),Z.length>0&&t.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto px-2 pb-2",children:[t.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),Z.map(e=>t.jsxs(g,{variant:"outline",size:"xs",className:"font-mono text-xs",onClick:()=>U(B(e,k)),"aria-label":`Open ${k}:${e} preview`,children:[":",e]},e))]}),t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 px-2 pb-2",children:[t.jsx(he,{"aria-label":"Preview viewport",value:[l],onValueChange:e=>{const r=e[0];r&&r in h&&te(r)},variant:"outline",size:"sm",spacing:0,children:Object.entries(h).map(([e,r])=>{const d=r.icon;return t.jsx(pe,{value:e,"aria-label":`${r.label} viewport`,title:r.width?`${r.label} · ${r.width}×${r.height}`:r.label,children:t.jsx(d,{})},e)})}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(g,{variant:"ghost",size:"icon-sm",disabled:o<=N,onClick:()=>p(e=>Math.max(N,Number((e-I).toFixed(1)))),"aria-label":"Zoom preview out",title:"Zoom out",children:t.jsx(ze,{"data-icon":"inline-start"})}),t.jsxs(g,{variant:"ghost",size:"sm",onClick:()=>p(1),"aria-label":"Reset preview zoom",children:[Math.round(o*100),"%"]}),t.jsx(g,{variant:"ghost",size:"icon-sm",disabled:o>=E,onClick:()=>p(e=>Math.min(E,Number((e+I).toFixed(1)))),"aria-label":"Zoom preview in",title:"Zoom in",children:t.jsx(Re,{"data-icon":"inline-start"})})]})]}),t.jsx(K,{}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-muted/30 p-3",children:n?t.jsx("div",{className:me("relative mx-auto overflow-hidden bg-white ring-1 ring-border",l==="responsive"&&"size-full"),style:l==="responsive"?void 0:{width:h[l].width*o,height:h[l].height*o},children:t.jsx("iframe",{title:"Development preview",src:n,className:"block border-0 bg-white",style:l==="responsive"?{width:`${100/o}%`,height:`${100/o}%`,transform:`scale(${o})`,transformOrigin:"top left"}:{width:h[l].width,height:h[l].height,transform:`scale(${o})`,transformOrigin:"top left"},sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"no-referrer",onLoad:()=>C(!1)},`${n}-${Q}`)}):t.jsx(fe,{className:"size-full",children:t.jsxs(xe,{children:[t.jsx(we,{variant:"icon",children:t.jsx(H,{})}),t.jsx(ve,{children:"No preview selected"}),t.jsx(ge,{children:"Start a local development server or enter its URL above. Detected ports appear automatically."})]})})})]})}export{Le as PreviewPanel,A as normalizePreviewUrl};
@@ -1 +0,0 @@
1
- import{c as H,r as g,j as n}from"./vendor-react-gGw_S5I_.js";import{aC as W,ae as _,i as U,j as Y,k as q,ad as $,h as B,D as J}from"./index-DB1wEO_I.js";import{O as Q,x as V}from"./vendor-ui-CyII6N5s.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const I=[{id:"narrow",name:"Narrow",css:"44rem"},{id:"medium",name:"Medium",css:"56rem"},{id:"wide",name:"Wide",css:"64rem"},{id:"full",name:"Full",css:"100%"}],K="cogpit-chat-width",O="medium";function X(){try{const s=localStorage.getItem(K);if(I.some(e=>e.id===s))return s}catch{}return O}let R=typeof window>"u"?O:X();const M=new Set;function L(s){if(typeof document>"u")return;const e=I.find(t=>t.id===s)??I[1];document.documentElement.style.setProperty("--chat-width",e.css)}L(R);function Z(){return R}function ee(s){R=s;try{localStorage.setItem(K,s)}catch{}L(s),M.forEach(e=>e())}function te(s){return M.add(s),()=>M.delete(s)}function se(){const s=H.c(2),e=g.useSyncExternalStore(te,Z,ae);let t;return s[0]!==e?(t=[e,ee],s[0]=e,s[1]=t):t=s[1],t}function ae(){return O}function de(s){const e=H.c(42),{open:t,onClose:r,currentTheme:l,onSelectTheme:k,onPreviewTheme:i}=s,[p,P]=g.useState(0),[z,A]=se();let j,w;e[0]!==l||e[1]!==t?(j=()=>{if(t){const a=W.findIndex(D=>D.id===l);P(a>=0?a:0)}},w=[t,l],e[0]=l,e[1]=t,e[2]=j,e[3]=w):(j=e[2],w=e[3]),g.useEffect(j,w);let N,b;e[4]!==i||e[5]!==t||e[6]!==p?(N=()=>{t&&i(W[p].id)},b=[p,t,i],e[4]=i,e[5]=t,e[6]=p,e[7]=N,e[8]=b):(N=e[7],b=e[8]),g.useEffect(N,b);let C,S;e[9]!==i||e[10]!==t?(C=()=>{t||i(null)},S=[t,i],e[9]=i,e[10]=t,e[11]=C,e[12]=S):(C=e[11],S=e[12]),g.useEffect(C,S);let y;e[13]!==r||e[14]!==k?(y=a=>{k(a.id),r()},e[13]=r,e[14]=k,e[15]=y):y=e[15];const F=y;let o;e[16]!==r?(o=a=>{a||r()},e[16]=r,e[17]=o):o=e[17];let E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsxs(U,{className:"border-b p-4 pr-12",children:[n.jsxs(Y,{className:"flex items-center gap-2 text-sm",children:[n.jsx(V,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Appearance"]}),n.jsx(q,{children:"Preview a color theme and set the chat width."})]}),e[18]=E):E=e[18];const G=W[p];let c;e[19]!==G.id?(c=[G.id],e[19]=G.id,e[20]=c):c=e[20];let d;e[21]!==l||e[22]!==F?(d=W.map((a,D)=>n.jsxs(_,{value:a.id,className:"h-auto w-full justify-start gap-3 px-3 py-2.5 text-left text-muted-foreground data-pressed:bg-accent data-pressed:text-accent-foreground",onClick:()=>F(a),onMouseEnter:()=>P(D),onFocus:()=>P(D),children:[n.jsx("div",{className:"flex gap-1",children:a.swatches.map(ne)}),n.jsx("span",{className:"flex-1 text-sm font-medium",children:a.name}),l===a.id&&n.jsx(Q,{"data-icon":"inline-end",className:"size-4 shrink-0 text-foreground"})]},a.id)),e[21]=l,e[22]=F,e[23]=d):d=e[23];let m;e[24]!==c||e[25]!==d?(m=n.jsx($,{"aria-label":"Theme",orientation:"vertical",value:c,className:"w-full items-stretch p-1",children:d}),e[24]=c,e[25]=d,e[26]=m):m=e[26];let v;e[27]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("div",{className:"px-1 pb-2 text-xs font-medium text-muted-foreground",children:"Chat width"}),e[27]=v):v=e[27];let f;e[28]!==z?(f=[z],e[28]=z,e[29]=f):f=e[29];let u;e[30]!==A?(u=I.map(a=>n.jsx(_,{value:a.id,className:"flex-1 text-xs text-muted-foreground data-pressed:bg-accent data-pressed:text-accent-foreground",onClick:()=>A(a.id),children:a.name},a.id)),e[30]=A,e[31]=u):u=e[31];let h;e[32]!==f||e[33]!==u?(h=n.jsxs("div",{className:"border-t p-3",children:[v,n.jsx($,{"aria-label":"Chat width",value:f,className:"w-full items-stretch gap-1",children:u})]}),e[32]=f,e[33]=u,e[34]=h):h=e[34];let x;e[35]!==m||e[36]!==h?(x=n.jsxs(B,{className:"max-w-sm gap-0 overflow-hidden p-0",children:[E,m,h]}),e[35]=m,e[36]=h,e[37]=x):x=e[37];let T;return e[38]!==t||e[39]!==x||e[40]!==o?(T=n.jsx(J,{open:t,onOpenChange:o,children:x}),e[38]=t,e[39]=x,e[40]=o,e[41]=T):T=e[41],T}function ne(s,e){return n.jsx("div",{className:"size-4 rounded-full border",style:{backgroundColor:s}},e)}export{de as ThemeSelectorModal};
@@ -1 +0,0 @@
1
- import{c as X,j as s,r as C}from"./vendor-react-gGw_S5I_.js";import{U as le,aK as mt,aL as ft,aM as xt,aN as He,V as pe,aO as Ke,ai as je,X as Se,Y as Ce,B as ne,Z as Te,w as Ie,aI as Me,aE as Le,aF as Fe,l as De,aG as Ue,A as Ge,aP as pt,p as Qe,aQ as ht,aR as gt,aS as jt,E as ze,y as Ae,G as We,H as Oe,aT as bt,d as Nt,c as wt,S as yt,a as vt,aU as kt,b as St,q as Ct,z as Tt,W as It}from"./index-DB1wEO_I.js";import{M as Rt}from"./vendor-markdown-BE1gYnO9.js";import{V as Xe,W as Ze,Y as et,_ as $t,$ as Re,R as _t,O as tt,D as st,a0 as qe,b as zt,a1 as At,a2 as Wt,J as Ot,a3 as Ye,c as Pt,U as Et}from"./vendor-ui-CyII6N5s.js";import"./vendor-shiki-DOn6sF-i.js";const Mt=new Set(["done","error","skipped"]);function Ve(l){return Mt.has(l)}function Lt(l){return l!=="completed"&&l!=="failed"&&l!=="killed"}function lt(l){switch(l){case"completed":return{label:"Completed",badge:"border-success/30 bg-success/10 text-success",dot:"bg-success"};case"failed":return{label:"Failed",badge:"border-destructive/30 bg-destructive/10 text-destructive",dot:"bg-destructive"};case"killed":return{label:"Stopped",badge:"border-warning/30 bg-warning/10 text-warning",dot:"bg-warning"};default:return{label:"Running",badge:"border-info/30 bg-info/10 text-info",dot:"bg-info"}}}function Ft(l){switch(l){case"done":return{label:"Done",badge:"border-success/30 bg-success/10 text-success",dot:"bg-success"};case"skipped":return{label:"Skipped",badge:"border-border bg-muted/30 text-muted-foreground",dot:"bg-muted-foreground"};case"error":return{label:"Error",badge:"border-destructive/30 bg-destructive/10 text-destructive",dot:"bg-destructive"};case"queued":return{label:"Queued",badge:"border-border bg-muted/30 text-muted-foreground",dot:"bg-muted-foreground"};default:return{label:"Running",badge:"border-info/30 bg-info/10 text-info",dot:"bg-info"}}}function Dt(l){const e=new Map;l.phases.forEach((a,n)=>{const i=n+1;e.set(i,{index:i,title:a.title,detail:a.detail,agents:[]})});const t=[];for(const a of l.agents){const n=e.get(a.phaseIndex);n?n.agents.push(a):t.push(a)}const r=[...e.values()];t.length>0&&r.push({index:r.length+1,title:t[0].phaseTitle||"Other",agents:t});for(const a of r)a.agents.sort((n,i)=>n.index-i.index);return r}function Ut(l){return l.total===0?0:(l.done+l.error)/l.total}function nt(l){return l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}k`:`${l}`}const at=["headline","oneLineSell","verdict","summary","name","lens"],Bt=new Set(["title","name"]),Jt=new Set(["headline","oneLineSell","verdict"]);function Be(l){return typeof l=="object"&&l!==null&&!Array.isArray(l)}function rt(l){const e=l.trim();if(!e.startsWith("{")&&!e.startsWith("["))return l;try{return JSON.parse(e)}catch{return l}}function qt(l){try{return JSON.parse(`"${l}"`)}catch{return l.replace(/\\n/g," ").replace(/\\"/g,'"')}}function Yt(l){const e=rt(l);if(e!==l)return $e(e);for(const t of at){const r=l.match(new RegExp(`"${t}"\\s*:\\s*"((?:\\\\.|[^"\\\\])*)"`));if(r!=null&&r[1])return qt(r[1])}return l.replace(/^[#>*\s-]+/,"").replace(/[`*_#]/g,"").split(/\n\s*\n|\n/)[0].trim()}function $e(l){if(typeof l=="string")return Yt(l);if(typeof l=="number"||typeof l=="boolean")return String(l);if(Array.isArray(l))return l.length>0?$e(l[0]):"";if(Be(l))for(const e of at){const t=l[e];if(typeof t=="string"&&t.trim())return t.trim()}return""}function Je(l){if(typeof l=="string")return l;try{return JSON.stringify(l,null,2)}catch{return String(l)}}function Vt(l){const e={oneLineSell:"In one line",quickWins:"Quick wins",whatIsLost:"What is lost",whyItHurts:"Why it hurts",restingState:"Resting state",fatalFlaws:"Fatal flaws",bestIdeasRegardlessOfConcept:"Best ideas across concepts"};return e[l]?e[l]:l.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/^./,t=>t.toUpperCase())}function it(l){const e=X.c(4),{children:t}=l;let r;e[0]!==t?(r=mt(t),e[0]=t,e[1]=r):r=e[1];const a=r;let n;return e[2]!==a?(n=s.jsx(Rt,{components:xt,remarkPlugins:ft,children:a}),e[2]=a,e[3]=n):n=e[3],n}function ot(l){const e=X.c(7),{value:t}=l;if(typeof t=="string"){let n;return e[0]!==t?(n=s.jsx(it,{children:t}),e[0]=t,e[1]=n):n=e[1],n}if(t===null){let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground",children:"None"}),e[2]=n):n=e[2],n}if(typeof t=="boolean"){const n=t?"Yes":"No";let i;return e[3]!==n?(i=s.jsx("span",{children:n}),e[3]=n,e[4]=i):i=e[4],i}const r=String(t);let a;return e[5]!==r?(a=s.jsx("span",{children:r}),e[5]=r,e[6]=a):a=e[6],a}function Pe(l){const e=X.c(21),{value:t,depth:r}=l,a=r===void 0?0:r;if(!Be(t)&&!Array.isArray(t)){let i;return e[0]!==t?(i=s.jsx(ot,{value:t}),e[0]=t,e[1]=i):i=e[1],i}if(a>5){let i;e[2]!==t?(i=Je(t),e[2]=t,e[3]=i):i=e[3];let o;return e[4]!==i?(o=s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 text-xs text-muted-foreground",children:i}),e[4]=i,e[5]=o):o=e[5],o}if(Array.isArray(t)){if(t.length===0){let d;return e[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx("p",{className:"text-sm text-muted-foreground",children:"No items"}),e[6]=d):d=e[6],d}if(t.every(Gt)){let d;e[7]!==t?(d=t.map(Kt),e[7]=t,e[8]=d):d=e[8];let u;return e[9]!==d?(u=s.jsx("ul",{className:"flex list-disc flex-col gap-2 pl-5 marker:text-muted-foreground",children:d}),e[9]=d,e[10]=u):u=e[10],u}let o;if(e[11]!==a||e[12]!==t){let d;e[14]!==a?(d=(u,c)=>s.jsx("article",{className:"border-l pl-4",children:s.jsx(Pe,{value:u,depth:a+1})},c),e[14]=a,e[15]=d):d=e[15],o=t.map(d),e[11]=a,e[12]=t,e[13]=o}else o=e[13];let m;return e[16]!==o?(m=s.jsx("div",{className:"flex flex-col gap-3",children:o}),e[16]=o,e[17]=m):m=e[17],m}let n;if(e[18]!==a||e[19]!==t){const i=Object.entries(t),o=i.find(Ht),m=i.filter(d=>{const[u]=d;return u!==(o==null?void 0:o[0])});n=s.jsxs("div",{className:"flex flex-col gap-4",children:[o&&s.jsx("h3",{className:le("font-semibold text-foreground",a===0?"text-lg":"text-base"),children:o[1]}),m.map(d=>{const[u,c]=d;return c===void 0?null:Jt.has(u)&&typeof c=="string"?s.jsx("div",{className:"border-l-2 border-foreground/30 pl-4 text-sm font-medium leading-relaxed",children:s.jsx(it,{children:c})},u):s.jsxs("section",{className:"flex min-w-0 flex-col gap-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:Vt(u)}),s.jsx("div",{className:"min-w-0 text-sm leading-relaxed",children:s.jsx(Pe,{value:c,depth:a+1})})]},u)})]}),e[18]=a,e[19]=t,e[20]=n}else n=e[20];return n}function Ht(l){const[e,t]=l;return Bt.has(e)&&typeof t=="string"&&t.trim().length>0}function Kt(l,e){return s.jsx("li",{className:"pl-1 text-sm leading-relaxed",children:s.jsx(ot,{value:l})},e)}function Gt(l){return!Be(l)&&!Array.isArray(l)}function Ee(l){const e=X.c(19),{value:t,className:r}=l;let a;e[0]!==t?(a=typeof t=="string"?rt(t):t,e[0]=t,e[1]=a):a=e[1];const n=a;if(typeof n=="string"&&(n.trim().startsWith("{")||n.trim().startsWith("["))){let u;e[2]!==n?(u=$e(n),e[2]=n,e[3]=u):u=e[3];const c=u;let f;e[4]!==r?(f=le("flex flex-col gap-2",r),e[4]=r,e[5]=f):f=e[5];let x;e[6]!==c?(x=c&&s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:c}),e[6]=c,e[7]=x):x=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx("p",{className:"text-xs text-muted-foreground",children:"Only a shortened preview was saved for this response."}),e[8]=h):h=e[8];let p;return e[9]!==f||e[10]!==x?(p=s.jsxs("div",{className:f,children:[x,h]}),e[9]=f,e[10]=x,e[11]=p):p=e[11],p}let o;e[12]!==r?(o=le("min-w-0 text-sm",r),e[12]=r,e[13]=o):o=e[13];let m;e[14]!==n?(m=s.jsx(Pe,{value:n}),e[14]=n,e[15]=m):m=e[15];let d;return e[16]!==o||e[17]!==m?(d=s.jsx("div",{className:o,children:m}),e[16]=o,e[17]=m,e[18]=d):d=e[18],d}function Qt(l){return l.replace(/\[[0-9;]*m\]/g,"")}function Xt(l){return(l.includes(":")?l.slice(l.indexOf(":")+1):l).replace(/[-_]+/g," ")}function Zt(l){const e=X.c(135),{agent:t,dirName:r,sessionId:a,runId:n}=l,[i,o]=C.useState(!1),[m,d]=C.useState(!1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={status:"idle"},e[0]=u):u=e[0];const[c,f]=C.useState(u),[x,h]=He();let p,j,b,N,S,w,v,g,T,R,A,Y,I,y,k,$,W,_,O,P,z;if(e[1]!==t||e[2]!==r||e[3]!==i||e[4]!==c.status||e[5]!==c.value||e[6]!==n||e[7]!==a){T=Ft(t.state);let Ne;e[29]!==t.state?(Ne=!Ve(t.state)&&t.state!=="queued",e[29]=t.state,e[30]=Ne):Ne=e[30],g=Ne;let we;e[31]!==t.resultPreview?(we=t.resultPreview?$e(t.resultPreview):"",e[31]=t.resultPreview,e[32]=we):we=e[32];const ye=we;let ve;e[33]!==t.agentId||e[34]!==r||e[35]!==n||e[36]!==a?(ve=async()=>{f({status:"loading"});try{const he=await Ie(`/api/workflow-agent-result/${encodeURIComponent(r)}/${encodeURIComponent(a)}/${encodeURIComponent(n)}/${encodeURIComponent(t.agentId)}`);if(!he.ok){f({status:"unavailable"});return}const ut=await he.json();f({status:"loaded",value:ut.result})}catch{f({status:"unavailable"})}},e[33]=t.agentId,e[34]=r,e[35]=n,e[36]=a,e[37]=ve):ve=e[37],v=ve;let ke;e[38]!==t.state||e[39]!==v||e[40]!==c.status?(ke=he=>{o(he),he&&c.status==="idle"&&Ve(t.state)&&v()},e[38]=t.state,e[39]=v,e[40]=c.status,e[41]=ke):ke=e[41];const ct=ke;z=c.status==="loaded"?c.value:t.resultPreview,w=c.status==="unavailable",S=Se,A=i,Y=ct,N=Me,P="sm",R="motion-card motion-list-item gap-0 py-0",b=Le,O="px-0 py-0",j=Ce,$="group flex w-full items-start gap-3 rounded-lg px-3.5 py-3 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring/50",W=s.jsx("span",{className:le("mt-1.5 size-2 shrink-0 rounded-full",T.dot)});const dt=t.label;let ae;e[42]!==t.label?(ae=Xt(t.label),e[42]=t.label,e[43]=ae):ae=e[43];let re;e[44]!==t.label||e[45]!==ae?(re=s.jsx(Fe,{className:"truncate capitalize",title:dt,children:ae}),e[44]=t.label,e[45]=ae,e[46]=re):re=e[46];let ie;e[47]!==t.attempt?(ie=t.attempt&&t.attempt>1&&s.jsxs(pe,{variant:"outline",className:"text-muted-foreground",children:["Attempt ",t.attempt]}),e[47]=t.attempt,e[48]=ie):ie=e[48];let oe;e[49]!==re||e[50]!==ie?(oe=s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[re,ie]}),e[49]=re,e[50]=ie,e[51]=oe):oe=e[51];let ce;e[52]!==t.lastToolName||e[53]!==t.lastToolSummary||e[54]!==g||e[55]!==ye?(ce=ye?s.jsx("p",{className:"mt-1 line-clamp-2 max-w-3xl text-xs leading-relaxed text-muted-foreground",children:ye}):g&&t.lastToolName?s.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:["Working in ",t.lastToolName,t.lastToolSummary?`: ${t.lastToolSummary}`:""]}):null,e[52]=t.lastToolName,e[53]=t.lastToolSummary,e[54]=g,e[55]=ye,e[56]=ce):ce=e[56];let de;e[57]!==t.model?(de=t.model&&s.jsx("span",{children:Qt(t.model)}),e[57]=t.model,e[58]=de):de=e[58];let ue;e[59]!==t.tokens?(ue=typeof t.tokens=="number"&&t.tokens>0&&s.jsxs(_e,{icon:Xe,children:[nt(t.tokens)," tokens"]}),e[59]=t.tokens,e[60]=ue):ue=e[60];let me;e[61]!==t.toolCalls?(me=typeof t.toolCalls=="number"&&t.toolCalls>0&&s.jsxs(_e,{icon:Ze,children:[t.toolCalls," tools"]}),e[61]=t.toolCalls,e[62]=me):me=e[62];let fe;e[63]!==t.durationMs?(fe=typeof t.durationMs=="number"&&s.jsx(_e,{icon:et,children:Ke(t.durationMs)}),e[63]=t.durationMs,e[64]=fe):fe=e[64];let xe;e[65]!==de||e[66]!==ue||e[67]!==me||e[68]!==fe?(xe=s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[de,ue,me,fe]}),e[65]=de,e[66]=ue,e[67]=me,e[68]=fe,e[69]=xe):xe=e[69],e[70]!==oe||e[71]!==ce||e[72]!==xe?(_=s.jsxs("div",{className:"min-w-0 flex-1",children:[oe,ce,xe]}),e[70]=oe,e[71]=ce,e[72]=xe,e[73]=_):_=e[73],k="flex shrink-0 items-center gap-2",p=pe,I="outline",y=le("hidden sm:inline-flex",T.badge),e[1]=t,e[2]=r,e[3]=i,e[4]=c.status,e[5]=c.value,e[6]=n,e[7]=a,e[8]=p,e[9]=j,e[10]=b,e[11]=N,e[12]=S,e[13]=w,e[14]=v,e[15]=g,e[16]=T,e[17]=R,e[18]=A,e[19]=Y,e[20]=I,e[21]=y,e[22]=k,e[23]=$,e[24]=W,e[25]=_,e[26]=O,e[27]=P,e[28]=z}else p=e[8],j=e[9],b=e[10],N=e[11],S=e[12],w=e[13],v=e[14],g=e[15],T=e[16],R=e[17],A=e[18],Y=e[19],I=e[20],y=e[21],k=e[22],$=e[23],W=e[24],_=e[25],O=e[26],P=e[27],z=e[28];let E;e[74]!==g?(E=g&&s.jsx(je,{"data-icon":"inline-start"}),e[74]=g,e[75]=E):E=e[75];let Z;e[76]!==p||e[77]!==T.label||e[78]!==E||e[79]!==I||e[80]!==y?(Z=s.jsxs(p,{variant:I,className:y,children:[E,T.label]}),e[76]=p,e[77]=T.label,e[78]=E,e[79]=I,e[80]=y,e[81]=Z):Z=e[81];let V;e[82]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(Re,{className:"mt-0.5 size-4 text-muted-foreground transition-transform group-data-panel-open:rotate-180 motion-reduce:transition-none"}),e[82]=V):V=e[82];let M;e[83]!==Z||e[84]!==k?(M=s.jsxs("div",{className:k,children:[Z,V]}),e[83]=Z,e[84]=k,e[85]=M):M=e[85];let L;e[86]!==j||e[87]!==M||e[88]!==$||e[89]!==W||e[90]!==_?(L=s.jsxs(j,{className:$,children:[W,_,M]}),e[86]=j,e[87]=M,e[88]=$,e[89]=W,e[90]=_,e[91]=L):L=e[91];let ee;e[92]!==b||e[93]!==L||e[94]!==O?(ee=s.jsx(b,{className:O,children:L}),e[92]=b,e[93]=L,e[94]=O,e[95]=ee):ee=e[95];let H;e[96]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(De,{}),e[96]=H):H=e[96];let K;e[97]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx("h5",{className:"text-sm font-semibold text-foreground",children:"Response"}),e[97]=K):K=e[97];const te=c.status==="loaded"?"Complete agent response":"Saved response preview";let F;e[98]!==te?(F=s.jsxs("div",{children:[K,s.jsx("p",{className:"text-xs text-muted-foreground",children:te})]}),e[98]=te,e[99]=F):F=e[99];let D;e[100]!==w||e[101]!==v?(D=w&&s.jsxs(ne,{variant:"ghost",size:"sm",onClick:()=>void v(),children:[s.jsx(_t,{"data-icon":"inline-start"}),"Retry"]}),e[100]=w,e[101]=v,e[102]=D):D=e[102];let U;e[103]!==x||e[104]!==h||e[105]!==z?(U=z!==void 0&&s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:()=>h(Je(z)),"aria-label":x?"Response copied":"Copy response",title:x?"Copied":"Copy response",children:x?s.jsx(tt,{"data-icon":"inline-start"}):s.jsx(st,{"data-icon":"inline-start"})}),e[103]=x,e[104]=h,e[105]=z,e[106]=U):U=e[106];let B;e[107]!==D||e[108]!==U?(B=s.jsxs("div",{className:"flex items-center gap-1",children:[D,U]}),e[107]=D,e[108]=U,e[109]=B):B=e[109];let J;e[110]!==F||e[111]!==B?(J=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[F,B]}),e[110]=F,e[111]=B,e[112]=J):J=e[112];let q;e[113]!==c.status||e[114]!==g||e[115]!==z?(q=c.status==="loading"?s.jsxs("div",{className:"flex items-center gap-2 py-5 text-sm text-muted-foreground",children:[s.jsx(je,{}),"Loading the complete response…"]}):z!==void 0?s.jsx(Ee,{value:z}):s.jsx("p",{className:"text-sm text-muted-foreground",children:g?"This agent has not returned a response yet.":"No response was saved for this agent."}),e[113]=c.status,e[114]=g,e[115]=z,e[116]=q):q=e[116];let G;e[117]!==t.promptPreview||e[118]!==m?(G=t.promptPreview&&s.jsxs(Se,{open:m,onOpenChange:d,children:[s.jsxs(Ce,{render:s.jsx(ne,{variant:"ghost",size:"sm",className:"w-full justify-start"}),children:[s.jsx($t,{"data-icon":"inline-start"}),"Agent prompt",s.jsx(Re,{"data-icon":"inline-end",className:le("ml-auto transition-transform",m&&"rotate-180")})]}),s.jsx(Te,{className:"pt-2",children:s.jsx("div",{className:"rounded-md border bg-muted/30 p-3 text-xs leading-relaxed text-muted-foreground",children:s.jsx(Ee,{value:t.promptPreview})})})]}),e[117]=t.promptPreview,e[118]=m,e[119]=G):G=e[119];let Q;e[120]!==J||e[121]!==q||e[122]!==G?(Q=s.jsxs(Te,{children:[H,s.jsxs(Ue,{className:"flex flex-col gap-4 px-4 py-4",children:[J,q,G]})]}),e[120]=J,e[121]=q,e[122]=G,e[123]=Q):Q=e[123];let se;e[124]!==N||e[125]!==R||e[126]!==ee||e[127]!==Q||e[128]!==P?(se=s.jsxs(N,{size:P,className:R,children:[ee,Q]}),e[124]=N,e[125]=R,e[126]=ee,e[127]=Q,e[128]=P,e[129]=se):se=e[129];let be;return e[130]!==S||e[131]!==A||e[132]!==Y||e[133]!==se?(be=s.jsx(S,{open:A,onOpenChange:Y,children:se}),e[130]=S,e[131]=A,e[132]=Y,e[133]=se,e[134]=be):be=e[134],be}function _e(l){const e=X.c(5),{icon:t,children:r}=l;let a;e[0]!==t?(a=s.jsx(t,{className:"size-3"}),e[0]=t,e[1]=a):a=e[1];let n;return e[2]!==r||e[3]!==a?(n=s.jsxs("span",{className:"inline-flex items-center gap-1",children:[a,r]}),e[2]=r,e[3]=a,e[4]=n):n=e[4],n}function es(l){const e=X.c(102),{detail:t,dirName:r,sessionId:a,stopping:n,confirming:i,onForceStop:o}=l;let m,d,u,c,f,x,h,p;if(e[0]!==i||e[1]!==t||e[2]!==r||e[3]!==o||e[4]!==a||e[5]!==n){const w=lt(t.status);let v;e[14]!==t.status?(v=Lt(t.status),e[14]=t.status,e[15]=v):v=e[15];const g=v,T=Dt(t),R=Ut(t.agentCounts),A=g&&t.controllable!==!1;f="flex flex-col gap-6 pb-6";const Y=g&&s.jsx("span",{className:le("size-1.5 rounded-full",w.dot)});let I;e[16]!==w||e[17]!==Y?(I=s.jsxs(pe,{variant:"outline",className:w.badge,children:[Y,w.label]}),e[16]=w,e[17]=Y,e[18]=I):I=e[18];let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx("span",{className:"text-xs text-muted-foreground",children:"Workflow run"}),e[19]=y):y=e[19];let k;e[20]!==I?(k=s.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[I,y]}),e[20]=I,e[21]=k):k=e[21];let $;e[22]!==t.workflowName?($=s.jsx("h2",{className:"text-xl font-semibold tracking-tight text-foreground",title:t.workflowName,children:t.workflowName}),e[22]=t.workflowName,e[23]=$):$=e[23];let W;e[24]!==t.summary?(W=t.summary&&s.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-relaxed text-muted-foreground",children:t.summary}),e[24]=t.summary,e[25]=W):W=e[25];let _;e[26]!==k||e[27]!==$||e[28]!==W?(_=s.jsxs("div",{className:"min-w-0",children:[k,$,W]}),e[26]=k,e[27]=$,e[28]=W,e[29]=_):_=e[29];let O;e[30]!==g||e[31]!==A||e[32]!==i||e[33]!==o||e[34]!==n?(O=g&&s.jsxs("div",{className:"flex shrink-0 flex-col items-start gap-1 sm:items-end",children:[s.jsxs(ne,{variant:i?"destructive":"outline",size:"sm",disabled:!A||n,onClick:o,children:[n?s.jsx(je,{"data-icon":"inline-start"}):s.jsx(qe,{"data-icon":"inline-start"}),i?"Confirm stop":"Stop workflow"]}),!A&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"This run is not controlled by Cogpit"})]}),e[30]=g,e[31]=A,e[32]=i,e[33]=o,e[34]=n,e[35]=O):O=e[35];let P;e[36]!==_||e[37]!==O?(P=s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[_,O]}),e[36]=_,e[37]=O,e[38]=P):P=e[38];const z=`${t.agentCounts.done+t.agentCounts.error}/${t.agentCount}`;let E;e[39]!==z?(E=s.jsx(ge,{icon:At,value:z,label:"Agents finished"}),e[39]=z,e[40]=E):E=e[40];const Z=String(t.phaseCount);let V;e[41]!==Z?(V=s.jsx(ge,{icon:Wt,value:Z,label:"Phases"}),e[41]=Z,e[42]=V):V=e[42];let M;e[43]!==t.totalTokens?(M=nt(t.totalTokens),e[43]=t.totalTokens,e[44]=M):M=e[44];let L;e[45]!==M?(L=s.jsx(ge,{icon:Xe,value:M,label:"Tokens"}),e[45]=M,e[46]=L):L=e[46];const ee=String(t.totalToolCalls);let H;e[47]!==ee?(H=s.jsx(ge,{icon:Ze,value:ee,label:"Tool calls"}),e[47]=ee,e[48]=H):H=e[48];let K;e[49]!==t.durationMs?(K=typeof t.durationMs=="number"?Ke(t.durationMs):"In progress",e[49]=t.durationMs,e[50]=K):K=e[50];let te;e[51]!==K?(te=s.jsx(ge,{icon:et,value:K,label:"Duration",className:"col-span-2 sm:col-span-1"}),e[51]=K,e[52]=te):te=e[52];let F;e[53]!==E||e[54]!==V||e[55]!==L||e[56]!==H||e[57]!==te?(F=s.jsxs("div",{className:"grid grid-cols-2 gap-px overflow-hidden rounded-lg border bg-border sm:grid-cols-5",children:[E,V,L,H,te]}),e[53]=E,e[54]=V,e[55]=L,e[56]=H,e[57]=te,e[58]=F):F=e[58];let D;e[59]!==R?(D=Math.round(R*100),e[59]=R,e[60]=D):D=e[60];let U;e[61]!==D?(U=s.jsx(jt,{value:D,"aria-label":"Workflow progress",className:"flex-1"}),e[61]=D,e[62]=U):U=e[62];let B;e[63]!==R?(B=Math.round(R*100),e[63]=R,e[64]=B):B=e[64];let J;e[65]!==B?(J=s.jsxs("span",{className:"w-9 text-right text-xs tabular-nums text-muted-foreground",children:[B,"%"]}),e[65]=B,e[66]=J):J=e[66];let q;e[67]!==U||e[68]!==J?(q=s.jsxs("div",{className:"flex items-center gap-3",children:[U,J]}),e[67]=U,e[68]=J,e[69]=q):q=e[69],e[70]!==P||e[71]!==F||e[72]!==q?(x=s.jsxs("section",{className:"flex flex-col gap-4",children:[P,F,q]}),e[70]=P,e[71]=F,e[72]=q,e[73]=x):x=e[73],e[74]!==t.error?(h=t.error&&s.jsxs(Ge,{variant:"destructive",children:[s.jsx(qe,{}),s.jsx(pt,{children:"Workflow error"}),s.jsx(Qe,{children:s.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-xs",children:t.error})})]}),e[74]=t.error,e[75]=h):h=e[75],e[76]!==t.resultPreview||e[77]!==t.runId||e[78]!==r||e[79]!==a?(p=t.resultPreview&&s.jsx(ns,{preview:t.resultPreview,dirName:r,sessionId:a,runId:t.runId}),e[76]=t.resultPreview,e[77]=t.runId,e[78]=r,e[79]=a,e[80]=p):p=e[80],u="grid items-start gap-6 md:grid-cols-[180px_minmax(0,1fr)]";let G;e[81]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx("p",{className:"px-2 pb-2 pt-1 text-xs font-medium text-muted-foreground",children:"Run outline"}),e[81]=G):G=e[81],c=s.jsxs("nav",{className:"sticky top-0 hidden rounded-lg border bg-card p-2 md:block","aria-label":"Workflow phases",children:[G,s.jsx("div",{className:"flex flex-col gap-1",children:T.map(ts)})]}),m="flex min-w-0 flex-col gap-8";let Q;e[82]!==t.runId||e[83]!==r||e[84]!==a?(Q=se=>s.jsx(ss,{group:se,dirName:r,sessionId:a,runId:t.runId},`${se.index}-${se.title}`),e[82]=t.runId,e[83]=r,e[84]=a,e[85]=Q):Q=e[85],d=T.map(Q),e[0]=i,e[1]=t,e[2]=r,e[3]=o,e[4]=a,e[5]=n,e[6]=m,e[7]=d,e[8]=u,e[9]=c,e[10]=f,e[11]=x,e[12]=h,e[13]=p}else m=e[6],d=e[7],u=e[8],c=e[9],f=e[10],x=e[11],h=e[12],p=e[13];let j;e[86]!==m||e[87]!==d?(j=s.jsx("div",{className:m,children:d}),e[86]=m,e[87]=d,e[88]=j):j=e[88];let b;e[89]!==u||e[90]!==c||e[91]!==j?(b=s.jsxs("div",{className:u,children:[c,j]}),e[89]=u,e[90]=c,e[91]=j,e[92]=b):b=e[92];let N;e[93]!==t.script?(N=t.script&&s.jsx(as,{script:t.script}),e[93]=t.script,e[94]=N):N=e[94];let S;return e[95]!==b||e[96]!==N||e[97]!==f||e[98]!==x||e[99]!==h||e[100]!==p?(S=s.jsxs("div",{className:f,children:[x,h,p,b,N]}),e[95]=b,e[96]=N,e[97]=f,e[98]=x,e[99]=h,e[100]=p,e[101]=S):S=e[101],S}function ts(l){return s.jsxs(ne,{variant:"ghost",size:"sm",type:"button",onClick:()=>{var e;return(e=document.getElementById(`workflow-phase-${l.index}`))==null?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})},className:"h-auto w-full justify-start gap-2 px-2 py-2 text-left text-xs text-muted-foreground",children:[s.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-md bg-muted text-xs font-medium text-foreground",children:l.index}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:l.title}),s.jsx("span",{className:"tabular-nums",children:l.agents.length})]},`${l.index}-${l.title}`)}function ge(l){const e=X.c(15),{icon:t,value:r,label:a,className:n}=l;let i;e[0]!==n?(i=le("flex items-center gap-2.5 bg-card px-3 py-3",n),e[0]=n,e[1]=i):i=e[1];let o;e[2]!==t?(o=s.jsx(t,{className:"size-4 shrink-0 text-muted-foreground"}),e[2]=t,e[3]=o):o=e[3];let m;e[4]!==r?(m=s.jsx("p",{className:"truncate text-sm font-semibold tabular-nums text-foreground",children:r}),e[4]=r,e[5]=m):m=e[5];let d;e[6]!==a?(d=s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a}),e[6]=a,e[7]=d):d=e[7];let u;e[8]!==m||e[9]!==d?(u=s.jsxs("div",{className:"min-w-0",children:[m,d]}),e[8]=m,e[9]=d,e[10]=u):u=e[10];let c;return e[11]!==i||e[12]!==o||e[13]!==u?(c=s.jsxs("div",{className:i,children:[o,u]}),e[11]=i,e[12]=o,e[13]=u,e[14]=c):c=e[14],c}function ss(l){const e=X.c(29),{group:t,dirName:r,sessionId:a,runId:n}=l;let i;e[0]!==t.agents?(i=t.agents.filter(ls),e[0]=t.agents,e[1]=i):i=e[1];const o=i.length,m=`workflow-phase-${t.index}`;let d;e[2]!==t.index?(d=s.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-lg bg-primary text-xs font-semibold text-primary-foreground",children:t.index}),e[2]=t.index,e[3]=d):d=e[3];let u;e[4]!==t.title?(u=s.jsx("h3",{className:"text-base font-semibold text-foreground",children:t.title}),e[4]=t.title,e[5]=u):u=e[5];let c;e[6]!==o||e[7]!==t.agents.length?(c=s.jsxs("span",{className:"text-xs text-muted-foreground",children:[o,"/",t.agents.length," complete"]}),e[6]=o,e[7]=t.agents.length,e[8]=c):c=e[8];let f;e[9]!==u||e[10]!==c?(f=s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[u,c]}),e[9]=u,e[10]=c,e[11]=f):f=e[11];let x;e[12]!==t.detail?(x=t.detail&&s.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:t.detail}),e[12]=t.detail,e[13]=x):x=e[13];let h;e[14]!==f||e[15]!==x?(h=s.jsxs("div",{className:"min-w-0 flex-1",children:[f,x]}),e[14]=f,e[15]=x,e[16]=h):h=e[16];let p;e[17]!==d||e[18]!==h?(p=s.jsxs("div",{className:"mb-3 flex items-start gap-3",children:[d,h]}),e[17]=d,e[18]=h,e[19]=p):p=e[19];let j;e[20]!==r||e[21]!==t.agents||e[22]!==n||e[23]!==a?(j=t.agents.length===0?s.jsx(ze,{className:"border py-6",children:s.jsxs(Ae,{children:[s.jsx(We,{children:"No agents yet"}),s.jsx(Oe,{children:"No agents have started this phase."})]})}):s.jsx("div",{className:"flex flex-col gap-2",children:t.agents.map(N=>s.jsx(Zt,{agent:N,dirName:r,sessionId:a,runId:n},`${n}:${N.agentId||N.index}`))}),e[20]=r,e[21]=t.agents,e[22]=n,e[23]=a,e[24]=j):j=e[24];let b;return e[25]!==j||e[26]!==m||e[27]!==p?(b=s.jsxs("section",{id:m,className:"scroll-mt-4",children:[p,j]}),e[25]=j,e[26]=m,e[27]=p,e[28]=b):b=e[28],b}function ls(l){return l.state==="done"||l.state==="skipped"}function ns({preview:l,dirName:e,sessionId:t,runId:r}){const[a,n]=C.useState(!0),[i,o]=C.useState(),[m,d]=C.useState(!1),[u,c]=C.useState(!1),[f,x]=He(),h=l.endsWith("…"),p=i??l,j=C.useCallback(async()=>{d(!0),c(!1);try{const b=await Ie(`/api/workflow-result/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${encodeURIComponent(r)}`);if(!b.ok){c(!0);return}const N=await b.json();o(N.result)}catch{c(!0)}finally{d(!1)}},[e,r,t]);return s.jsx(Se,{open:a,onOpenChange:n,children:s.jsxs(Me,{className:"motion-enter gap-0 py-0",children:[s.jsxs(Le,{className:"py-4",children:[s.jsxs(Ce,{className:"group flex min-w-0 items-center gap-3 text-left outline-none",children:[s.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",children:s.jsx(zt,{className:"size-4"})}),s.jsxs("span",{className:"min-w-0",children:[s.jsx(Fe,{children:"Workflow outcome"}),s.jsx(ht,{children:"The synthesized answer from this run"})]}),s.jsx(Re,{className:"size-4 shrink-0 text-muted-foreground transition-transform group-data-panel-open:rotate-180 motion-reduce:transition-none"})]}),s.jsxs(gt,{className:"flex items-center gap-1",children:[h&&i===void 0&&s.jsxs(ne,{variant:"outline",size:"sm",disabled:m,onClick:()=>void j(),children:[m&&s.jsx(je,{"data-icon":"inline-start"}),u?"Retry full result":"Load full result"]}),s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:()=>x(Je(p)),"aria-label":f?"Outcome copied":"Copy outcome",title:f?"Copied":"Copy outcome",children:f?s.jsx(tt,{"data-icon":"inline-start"}):s.jsx(st,{"data-icon":"inline-start"})})]})]}),s.jsxs(Te,{children:[s.jsx(De,{}),s.jsx(Ue,{className:"py-5",children:s.jsx(Ee,{value:p})})]})]})})}function as(l){const e=X.c(7),{script:t}=l,[r,a]=C.useState(!1);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(Le,{className:"px-0 py-0",children:s.jsxs(Ce,{className:"group flex w-full items-center gap-2 px-3 py-3 text-left text-sm font-medium text-muted-foreground outline-none transition-colors hover:bg-muted/40 hover:text-foreground",children:[s.jsx(Ot,{className:"size-4"}),s.jsx(Fe,{children:"Orchestration script"}),s.jsx(Re,{className:"ml-auto size-4 transition-transform group-data-panel-open:rotate-180"})]})}),e[0]=n):n=e[0];let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(De,{}),e[1]=i):i=e[1];let o;e[2]!==t?(o=s.jsxs(Me,{size:"sm",className:"gap-0 py-0",children:[n,s.jsxs(Te,{children:[i,s.jsx(Ue,{className:"py-3",children:s.jsx("pre",{className:"max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 text-xs leading-relaxed text-muted-foreground",children:t})})]})]}),e[2]=t,e[3]=o):o=e[3];let m;return e[4]!==r||e[5]!==o?(m=s.jsx(Se,{open:r,onOpenChange:a,children:o}),e[4]=r,e[5]=o,e[6]=m):m=e[6],m}function ms({open:l,onOpenChange:e,dirName:t,sessionId:r,workflows:a,isLive:n,onRefetchList:i}){var I;const[o,m]=C.useState(null),[d,u]=C.useState(!1),[c,f]=C.useState(null),[x,h]=C.useState(!1),[p,j]=C.useState(!1),[b,N]=C.useState(!1),[S,w]=C.useState(null),v=C.useRef(0),g=d?null:o&&a.some(y=>y.runId===o)?o:((I=a[0])==null?void 0:I.runId)??null,T=C.useCallback(async()=>{const y=++v.current;if(!t||!r||!g){f(null);return}try{const k=await Ie(`/api/workflow-detail/${encodeURIComponent(t)}/${encodeURIComponent(r)}/${encodeURIComponent(g)}`);if(!k.ok){y===v.current&&f(null);return}const $=await k.json();y===v.current&&f($)}catch{y===v.current&&f(null)}finally{y===v.current&&h(!1)}},[t,r,g]);C.useEffect(()=>{if(!g){f(null);return}f(null),h(!0),N(!1),w(null),T()},[g,T]),bt(l?t:null,l?r:null,l?g:null,()=>{T(),i()});const R=C.useCallback(async()=>{if(!b){N(!0);return}if(!(!r||!g)){j(!0),w(null);try{const k=await(await Ie("/api/workflow-stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:r,runId:g})})).json().catch(()=>({}));k!=null&&k.success?w("Stop signal sent."):(k==null?void 0:k.controllable)===!1?w("This workflow runs in a session Cogpit doesn't control."):w("Couldn't stop. The session may have already exited."),T(),i()}catch{w("Stop request failed.")}finally{j(!1),N(!1)}}},[b,r,g,T,i]),A=a.length>1,Y=a.find(y=>y.runId===g);return s.jsx(Nt,{open:l,onOpenChange:e,children:s.jsxs(wt,{side:"right",className:"w-full data-[side=right]:max-w-[1120px]",children:[s.jsx(yt,{className:"min-h-14 justify-center border-b py-3",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 pr-9",children:[s.jsxs(vt,{className:"flex items-center gap-2",children:[s.jsx(Ye,{className:"size-4"}),"Workflows",a.length>0&&s.jsx(pe,{variant:"secondary",children:a.length}),n&&s.jsxs(pe,{variant:"outline",className:"border-info/30 text-info",children:[s.jsx(kt,{className:"size-1.5"}),"Live"]})]}),s.jsx(St,{className:"sr-only",children:"Inspect workflow runs, agent progress, and run controls for this session."}),s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Refresh workflows",title:"Refresh workflows",children:s.jsx(Pt,{"data-icon":"inline-start"})})]})}),s.jsx(Ct,{className:"h-[calc(100dvh-3.5rem)]",children:s.jsx("div",{className:"px-5 py-6 sm:px-6",children:a.length===0?s.jsx(ze,{className:"min-h-[60dvh]",children:s.jsxs(Ae,{children:[s.jsx(Tt,{variant:"icon",children:s.jsx(Ye,{})}),s.jsx(We,{children:"No workflows in this session"}),s.jsx(Oe,{children:"Phases, agents, and their responses will appear here when this session starts a workflow."})]})}):s.jsxs(s.Fragment,{children:[A&&s.jsxs("div",{className:"mb-6 flex flex-col gap-2",children:[g&&c&&s.jsxs(ne,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"w-fit px-2 text-muted-foreground",children:[s.jsx(Et,{"data-icon":"inline-start"}),"All runs"]}),(!g||!c)&&a.map(y=>s.jsx(rs,{workflow:y,active:y.runId===g,onClick:()=>{m(y.runId),u(!1)}},y.runId))]}),x&&!c?s.jsxs("div",{className:"flex min-h-[50dvh] items-center justify-center gap-2 text-sm text-muted-foreground",children:[s.jsx(je,{}),"Loading workflow…"]}):c?s.jsxs(s.Fragment,{children:[S&&s.jsx(Ge,{className:"mb-4",children:s.jsx(Qe,{children:S})}),s.jsx(es,{detail:c,dirName:t??"",sessionId:r??"",stopping:p,confirming:b,onForceStop:R})]}):Y?s.jsx(ze,{className:"min-h-[50dvh]",children:s.jsxs(Ae,{children:[s.jsx(We,{children:"Could not load this workflow"}),s.jsx(Oe,{children:"The journal may have moved or the run may no longer be available."})]})}):null]})})})]})})}function rs(l){const e=X.c(45),{workflow:t,active:r,onClick:a}=l;let n,i,o,m,d,u,c;if(e[0]!==r||e[1]!==a||e[2]!==t.agentCounts.done||e[3]!==t.agentCounts.error||e[4]!==t.status){o=lt(t.status),i=t.agentCounts.done+t.agentCounts.error,n=ne,d="ghost",u=a;const g=r?"border-foreground/20 bg-accent":"bg-background hover:bg-muted/50";e[12]!==g?(c=le("h-auto w-full justify-start gap-3 whitespace-normal border px-3 py-3 text-left",g),e[12]=g,e[13]=c):c=e[13],m=le("size-2 shrink-0 rounded-full",o.dot),e[0]=r,e[1]=a,e[2]=t.agentCounts.done,e[3]=t.agentCounts.error,e[4]=t.status,e[5]=n,e[6]=i,e[7]=o,e[8]=m,e[9]=d,e[10]=u,e[11]=c}else n=e[5],i=e[6],o=e[7],m=e[8],d=e[9],u=e[10],c=e[11];let f;e[14]!==m?(f=s.jsx("span",{className:m}),e[14]=m,e[15]=f):f=e[15];let x;e[16]!==t.workflowName?(x=s.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.workflowName}),e[16]=t.workflowName,e[17]=x):x=e[17];let h;e[18]!==o.badge||e[19]!==o.label?(h=s.jsx(pe,{variant:"outline",className:o.badge,children:o.label}),e[18]=o.badge,e[19]=o.label,e[20]=h):h=e[20];let p;e[21]!==x||e[22]!==h?(p=s.jsxs("div",{className:"flex items-center gap-2",children:[x,h]}),e[21]=x,e[22]=h,e[23]=p):p=e[23];let j;e[24]!==t.summary?(j=t.summary&&s.jsx("p",{className:"mt-1 line-clamp-1 text-xs text-muted-foreground",children:t.summary}),e[24]=t.summary,e[25]=j):j=e[25];let b;e[26]!==i||e[27]!==t.agentCount?(b=s.jsxs("span",{children:[i,"/",t.agentCount," agents"]}),e[26]=i,e[27]=t.agentCount,e[28]=b):b=e[28];let N;e[29]!==t.startTime?(N=t.startTime>0&&s.jsx("span",{children:It(new Date(t.startTime).toISOString())}),e[29]=t.startTime,e[30]=N):N=e[30];let S;e[31]!==b||e[32]!==N?(S=s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[b,N]}),e[31]=b,e[32]=N,e[33]=S):S=e[33];let w;e[34]!==S||e[35]!==p||e[36]!==j?(w=s.jsxs("div",{className:"min-w-0 flex-1",children:[p,j,S]}),e[34]=S,e[35]=p,e[36]=j,e[37]=w):w=e[37];let v;return e[38]!==n||e[39]!==w||e[40]!==d||e[41]!==u||e[42]!==c||e[43]!==f?(v=s.jsxs(n,{variant:d,onClick:u,className:c,children:[f,w]}),e[38]=n,e[39]=w,e[40]=d,e[41]=u,e[42]=c,e[43]=f,e[44]=v):v=e[44],v}export{ms as WorkflowsPanel};
@@ -1 +0,0 @@
1
- import{r as h,j as e}from"./vendor-react-gGw_S5I_.js";import{T as Y,d as Z,c as K,S as Q,a as _,B as x,U as S,b as ee,E as se,y as te,z as ne,G as re,H as ae,V as ie,W as le,X as oe,Y as ce,Z as de,_ as A,$ as R,a0 as E,a1 as he,a2 as T,a3 as U,a4 as z,a5 as $,a6 as F,w as u,a7 as c}from"./index-DB1wEO_I.js";import{G as P,b as xe,c as me,E as ue,d as pe,T as O,C as je,e as ge}from"./vendor-ui-CyII6N5s.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const fe={M:"text-warning",A:"text-success",D:"text-destructive",R:"text-info"};function we({open:I,onOpenChange:H,worktrees:v,loading:p,dirName:a,onRefetch:j,onOpenSession:M}){const o=Y("hostFiles"),[B,y]=h.useState(null),[G,b]=h.useState(null),[J,m]=h.useState(!1),[t,d]=h.useState(null),[r,g]=h.useState(null),C=async s=>{if(!(!o||!a)){y(s.name);try{await u(`/api/worktrees/${encodeURIComponent(a)}/${encodeURIComponent(s.name)}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:s.isDirty})}),j()}catch(n){c.error(`Failed to delete worktree: ${n instanceof Error?n.message:"Unknown error"}`)}finally{y(null)}}},W=s=>{if(!(!o||!a)){if(s.isDirty){d({worktree:s,reason:"dirty"});return}if(s.commitsAhead>0){d({worktree:s,reason:"unpushed"});return}C(s)}},L=()=>{if(!t)return;const{worktree:s,reason:n}=t;if(n==="dirty"&&s.commitsAhead>0){d({worktree:s,reason:"unpushed"});return}d(null),C(s)},q=async s=>{if(!(!o||!a)){b(s.name);try{const n=await u(`/api/worktrees/${encodeURIComponent(a)}/create-pr`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeName:s.name,title:s.name.replace(/-/g," ")})});if(n.ok){const l=await n.json();l.url?window.open(l.url,"_blank","noopener,noreferrer"):c.warning("PR created but no URL was returned")}else{const l=await n.json().catch(()=>({error:"Unknown error"}));c.error(`Failed to create PR: ${l.error||"Unknown error"}`)}}catch(n){c.error(`Error creating PR: ${n instanceof Error?n.message:"Unknown error"}`)}finally{b(null)}}},V=async()=>{if(!(!o||!a)){m(!0);try{const s=await u(`/api/worktrees/${encodeURIComponent(a)}/cleanup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(s.ok){const{stale:n}=await s.json();n.length===0?c.info("No stale worktrees found"):g(n.map(l=>l.name))}}catch(s){c.error(`Cleanup failed: ${s instanceof Error?s.message:"Unknown error"}`)}finally{m(!1)}}},X=async()=>{if(!o||!a||!r)return;const s=r;g(null),m(!0);try{await u(`/api/worktrees/${encodeURIComponent(a)}/cleanup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0,names:s})}),j()}catch(n){c.error(`Cleanup failed: ${n instanceof Error?n.message:"Unknown error"}`)}finally{m(!1)}};return e.jsxs(Z,{open:I,onOpenChange:H,children:[e.jsxs(K,{children:[e.jsxs(Q,{children:[e.jsxs("div",{className:"flex items-center justify-between pr-8",children:[e.jsxs(_,{className:"flex items-center gap-2",children:[e.jsx(P,{"data-icon":"inline-start",className:"size-4"}),"Worktrees"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[o&&e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:V,disabled:J,"aria-label":"Cleanup stale worktrees",children:e.jsx(xe,{"data-icon":"inline-start"})}),e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:j,disabled:p,"aria-label":"Refresh worktrees",children:e.jsx(me,{"data-icon":"inline-start",className:S(p&&"animate-spin")})})]})]}),e.jsx(ee,{children:"Review isolated branches and their file changes."})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto p-3",children:[!a&&e.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Select a project to view worktrees"}),a&&v.length===0&&!p&&e.jsx(se,{className:"border-0 py-16",children:e.jsxs(te,{children:[e.jsx(ne,{variant:"icon",children:e.jsx(P,{})}),e.jsx(re,{children:"No worktrees"}),e.jsx(ae,{children:"Create a new session with “Isolate in worktree” enabled"})]})}),v.map(s=>{var w,N,D;const n=((w=s.changedFiles)==null?void 0:w.reduce((i,k)=>i+k.additions,0))??0,l=((N=s.changedFiles)==null?void 0:N.reduce((i,k)=>i+k.deletions,0))??0,f=((D=s.changedFiles)==null?void 0:D.length)??0;return e.jsxs("div",{className:"rounded-lg border bg-card p-3 transition-colors hover:bg-accent/40",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:s.name}),s.isDirty&&e.jsx("span",{className:"flex size-2 shrink-0 rounded-full bg-warning",title:"Uncommitted changes"}),s.commitsAhead>0&&e.jsxs(ie,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-xs",children:[s.commitsAhead," ahead"]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[s.linkedSessions.length>0&&e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:()=>M(s.linkedSessions[0]),"aria-label":"Open session",children:e.jsx(ue,{"data-icon":"inline-start"})}),o&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:()=>q(s),disabled:G===s.name||s.commitsAhead===0,"aria-label":"Create PR",children:e.jsx(pe,{"data-icon":"inline-start"})}),e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:()=>W(s),disabled:B===s.name,className:"text-destructive hover:bg-destructive/10 hover:text-destructive","aria-label":"Delete worktree",children:e.jsx(O,{"data-icon":"inline-start"})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-mono shrink-0",children:s.head}),e.jsx("span",{className:"truncate",children:s.headMessage})]}),s.createdAt&&e.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:le(s.createdAt)}),f>0&&e.jsxs(oe,{className:"mt-2",children:[e.jsxs(ce,{className:"group flex w-full items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(je,{"data-icon":"inline-start",className:"size-3 transition-transform group-data-panel-open:rotate-90 motion-reduce:transition-none"}),e.jsx(ge,{"data-icon":"inline-start",className:"size-3"}),e.jsxs("span",{children:[f," file",f!==1?"s":""," changed"]}),e.jsxs("span",{className:"ml-1",children:[e.jsxs("span",{className:"text-success",children:["+",n]})," ",e.jsxs("span",{className:"text-destructive",children:["-",l]})]})]}),e.jsx(de,{children:e.jsx("div",{className:"mt-1.5 flex flex-col gap-px rounded-md bg-muted/40 p-1.5",children:s.changedFiles.map(i=>e.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5 font-mono text-xs",children:[e.jsx("span",{className:S("shrink-0 w-3 text-center",fe[i.status]??"text-muted-foreground"),children:i.status}),e.jsx("span",{className:"truncate text-foreground/80",children:i.path}),e.jsxs("span",{className:"ml-auto shrink-0 text-muted-foreground",children:[e.jsxs("span",{className:"text-success",children:["+",i.additions]})," ",e.jsxs("span",{className:"text-destructive",children:["-",i.deletions]})]})]},i.path))})})]})]},s.name)})]})]}),e.jsx(A,{open:t!==null,onOpenChange:s=>{s||d(null)},children:e.jsxs(R,{size:"sm",children:[e.jsxs(E,{children:[e.jsx(he,{className:"bg-destructive/10 text-destructive",children:e.jsx(O,{})}),e.jsx(T,{children:(t==null?void 0:t.reason)==="dirty"?"Delete worktree with uncommitted changes?":"Delete worktree with unpushed commits?"}),e.jsxs(U,{children:[(t==null?void 0:t.reason)==="dirty"?`"${t.worktree.name}" has uncommitted changes.`:`"${t==null?void 0:t.worktree.name}" has ${t==null?void 0:t.worktree.commitsAhead} unpushed commit(s).`," "," ","Deleting it cannot be undone."]})]}),e.jsxs(z,{children:[e.jsx($,{size:"sm",children:"Cancel"}),e.jsx(F,{variant:"destructive",size:"sm",onClick:L,children:(t==null?void 0:t.reason)==="dirty"&&t.worktree.commitsAhead>0?"Continue":"Delete worktree"})]})]})}),e.jsx(A,{open:r!==null,onOpenChange:s=>{s||g(null)},children:e.jsxs(R,{children:[e.jsxs(E,{children:[e.jsx(T,{children:"Remove stale worktrees?"}),e.jsxs(U,{children:[r==null?void 0:r.length," stale worktree",(r==null?void 0:r.length)===1?"":"s"," will be removed: ",r==null?void 0:r.join(", "),"."]})]}),e.jsxs(z,{children:[e.jsx($,{size:"sm",children:"Cancel"}),e.jsx(F,{variant:"destructive",size:"sm",onClick:()=>void X(),children:"Remove worktrees"})]})]})})]})}export{we as WorktreePanel};
@@ -1 +0,0 @@
1
- import{r as V,a as Qe,c as P,j as s}from"./vendor-react-gGw_S5I_.js";import{w as He,B as U,a_ as Ke,aP as _e,A as qe,b1 as We,bf as Le,ae as ke,ad as ze,V as Te,bg as Xe,b5 as Je,b4 as Ze,b3 as et,bh as tt,bi as st,bj as nt,bk as it,U as ue,bl as lt,W as ot,ak as at,bm as rt,bn as ct,bo as dt,v as ut,af as ft,bp as mt,E as xt,y as ht,z as gt,G as pt,H as bt,ai as jt,p as wt,bq as vt,br as Nt,q as yt}from"./index-DB1wEO_I.js";import{E as St,ai as It,ap as Pe,C as Fe,aq as Se,af as _t,ar as qt,L as Ct,as as Tt,at as kt,c as At,m as Et}from"./vendor-ui-CyII6N5s.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const Rt=4e3;function Mt(){const[l,e]=V.useState([]),[t,n]=V.useState(!1),[i,r]=V.useState(null),o=V.useRef(!1);V.useEffect(()=>(o.current=!1,()=>{o.current=!0}),[]);const c=V.useCallback(async()=>{try{const m=await He("/api/mission-control");if(o.current)return;if(!m.ok)throw new Error(`Mission Control request failed (${m.status})`);const x=await m.json();if(o.current)return;e(Array.isArray(x.summaries)?x.summaries:[]),r(null)}catch(m){if(o.current)return;r(m instanceof Error?m.message:"Failed to load Mission Control")}finally{o.current||n(!1)}},[]);V.useEffect(()=>{n(!0);const m=()=>{(typeof document>"u"||document.visibilityState==="visible")&&c()},x=()=>{document.visibilityState==="visible"&&c()};m();const j=setInterval(m,Rt);return document.addEventListener("visibilitychange",x),()=>{clearInterval(j),document.removeEventListener("visibilitychange",x)}},[c]);const d=V.useMemo(()=>{const m=new Map;for(const x of l)m.set(x.sessionId,x);return m},[l]),g=V.useCallback(()=>{c()},[c]);return{summaries:d,loading:t,error:i,refresh:g}}const Ae="data-view-transition-kind",Lt="(prefers-reduced-motion: reduce)";let de=null,$e=null;function Dt(l,e,t){t===null?l.removeAttribute(e):l.setAttribute(e,t)}function Ft(l,e){const t={root:l,kind:e,previousKind:l.getAttribute(Ae)};return l.setAttribute(Ae,e),$e=t,t}function Ie(l){$e===l&&(l.root.getAttribute(Ae)===l.kind&&Dt(l.root,Ae,l.previousKind),$e=null)}function $t(){const l=de;if(l){de=null;try{l.transition.skipTransition()}catch{Ie(l.tag);return}Ie(l.tag)}}function zt(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia(Lt).matches}catch{return!1}}function Ot(l,{kind:e}){$t();const t=typeof document>"u"?null:document,n=t==null?void 0:t.startViewTransition;if(!t||!(typeof n=="function")||zt())return l(),null;const r=Ft(t.documentElement,e);let o=!1,c=!1,d;const g=m=>{if(!o){o=!0;try{m?Qe.flushSync(l):l()}catch(x){throw c=!0,d=x,x}}};try{const m=n.call(t,()=>g(!0)),x={transition:m,tag:r};return de=x,m.ready.catch(()=>{}),m.updateCallbackDone.catch(()=>{}),m.finished.then(()=>{de===x&&(de=null),Ie(r)},()=>{de===x&&(de=null),Ie(r)}),m}catch{if(Ie(r),c)throw d;return g(!1),null}}function Vt(l){const e={};for(const t of l)t.type==="boolean"?e[t.name]=t.defaultValue===!0:t.defaultValue!==void 0?e[t.name]=String(t.defaultValue):e[t.name]="";return e}function Ut(l,e){const t={};for(const n of l){const i=e[n.name];if(typeof i=="boolean"){t[n.name]=i;continue}i!==""&&(t[n.name]=n.type==="number"||n.type==="integer"?Number(i):i)}return t}function Yt(l,e){return l.every(t=>{if(!t.required)return!0;const n=e[t.name];return typeof n=="boolean"?!0:n===""?!1:t.type==="number"||t.type==="integer"?Number.isFinite(Number(n)):!0})}function Pt(l){const e=P.c(64),{request:t,responding:n,onAnswer:i}=l;let r;e[0]!==t.fields?(r=()=>Vt(t.fields),e[0]=t.fields,e[1]=r):r=e[1];const[o,c]=V.useState(r);let d;e[2]!==t.fields||e[3]!==o?(d=Yt(t.fields,o),e[2]=t.fields,e[3]=o,e[4]=d):d=e[4];const g=d,m=t.displayName||t.title||t.serverName;let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=(q,S)=>{c(w=>({...w,[q]:S}))},e[5]=x):x=e[5];const j=x;let p;e[6]!==i||e[7]!==t.requestId?(p=()=>i(t.requestId,{action:"decline"}),e[6]=i,e[7]=t.requestId,e[8]=p):p=e[8];const u=p;if(t.mode==="url"&&t.url){const q=t.url;let S;e[9]!==t.message?(S=s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.message}),e[9]=t.message,e[10]=S):S=e[10];let w;e[11]!==q?(w=s.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:q,children:q}),e[11]=q,e[12]=w):w=e[12];let I;e[13]!==i||e[14]!==t.requestId||e[15]!==q?(I=()=>{window.open(q,"_blank","noopener,noreferrer"),i(t.requestId,{action:"accept"})},e[13]=i,e[14]=t.requestId,e[15]=q,e[16]=I):I=e[16];let z;e[17]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(St,{"data-icon":"inline-end"}),e[17]=z):z=e[17];let L;e[18]!==n||e[19]!==I?(L=s.jsxs(U,{size:"sm",disabled:n,onClick:I,children:["Open link",z]}),e[18]=n,e[19]=I,e[20]=L):L=e[20];let k;e[21]!==u||e[22]!==n?(k=s.jsx(U,{variant:"ghost",size:"sm",disabled:n,onClick:u,children:"Decline"}),e[21]=u,e[22]=n,e[23]=k):k=e[23];let R;e[24]!==k||e[25]!==L?(R=s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[L,k]}),e[24]=k,e[25]=L,e[26]=R):R=e[26];let F;return e[27]!==m||e[28]!==R||e[29]!==S||e[30]!==w?(F=s.jsxs(Ve,{server:m,children:[S,w,R]}),e[27]=m,e[28]=R,e[29]=S,e[30]=w,e[31]=F):F=e[31],F}let a;e[32]!==t.message?(a=s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.message}),e[32]=t.message,e[33]=a):a=e[33];let h;if(e[34]!==t.fields||e[35]!==t.requestId||e[36]!==n||e[37]!==o){let q;e[39]!==t.requestId||e[40]!==n||e[41]!==o?(q=S=>s.jsx(Bt,{id:`elicit-${t.requestId}-${S.name}`,field:S,value:o[S.name],disabled:n,onChange:w=>j(S.name,w)},S.name),e[39]=t.requestId,e[40]=n,e[41]=o,e[42]=q):q=e[42],h=t.fields.map(q),e[34]=t.fields,e[35]=t.requestId,e[36]=n,e[37]=o,e[38]=h}else h=e[38];let f;e[43]!==h?(f=s.jsx("div",{className:"mt-3 flex flex-col gap-3",children:h}),e[43]=h,e[44]=f):f=e[44];const y=n||!g;let v;e[45]!==i||e[46]!==t.fields||e[47]!==t.requestId||e[48]!==o?(v=()=>i(t.requestId,{action:"accept",content:Ut(t.fields,o)}),e[45]=i,e[46]=t.fields,e[47]=t.requestId,e[48]=o,e[49]=v):v=e[49];let _;e[50]!==y||e[51]!==v?(_=s.jsx(U,{size:"sm",disabled:y,onClick:v,children:"Send"}),e[50]=y,e[51]=v,e[52]=_):_=e[52];let T;e[53]!==u||e[54]!==n?(T=s.jsx(U,{variant:"ghost",size:"sm",disabled:n,onClick:u,children:"Decline"}),e[53]=u,e[54]=n,e[55]=T):T=e[55];let N;e[56]!==_||e[57]!==T?(N=s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[_,T]}),e[56]=_,e[57]=T,e[58]=N):N=e[58];let b;return e[59]!==m||e[60]!==N||e[61]!==a||e[62]!==f?(b=s.jsxs(Ve,{server:m,children:[a,f,N]}),e[59]=m,e[60]=N,e[61]=a,e[62]=f,e[63]=b):b=e[63],b}function Bt(l){const e=P.c(55),{id:t,field:n,value:i,disabled:r,onChange:o}=l;if(n.type==="boolean"){const u=i===!0;let a;e[0]!==o?(a=v=>o(v===!0),e[0]=o,e[1]=a):a=e[1];let h;e[2]!==r||e[3]!==t||e[4]!==u||e[5]!==a?(h=s.jsx(We,{id:t,checked:u,disabled:r,onCheckedChange:a}),e[2]=r,e[3]=t,e[4]=u,e[5]=a,e[6]=h):h=e[6];let f;e[7]!==n?(f=s.jsx(De,{field:n}),e[7]=n,e[8]=f):f=e[8];let y;return e[9]!==t||e[10]!==h||e[11]!==f?(y=s.jsxs(Le,{htmlFor:t,className:"items-start gap-2 font-normal",children:[h,f]}),e[9]=t,e[10]=h,e[11]=f,e[12]=y):y=e[12],y}if(n.type==="enum"){let u;e[13]!==n?(u=s.jsx(De,{field:n}),e[13]=n,e[14]=u):u=e[14];let a;e[15]!==t||e[16]!==u?(a=s.jsx(Le,{htmlFor:t,children:u}),e[15]=t,e[16]=u,e[17]=a):a=e[17];let h;e[18]!==i?(h=typeof i=="string"&&i?[i]:[],e[18]=i,e[19]=h):h=e[19];let f;e[20]!==o?(f=b=>{b[0]&&o(b[0])},e[20]=o,e[21]=f):f=e[21];const y=n.label;let v;e[22]!==n.options?(v=n.options??[],e[22]=n.options,e[23]=v):v=e[23];let _;if(e[24]!==r||e[25]!==v){let b;e[27]!==r?(b=q=>s.jsx(ke,{value:q.value,disabled:r,className:"w-full justify-start px-3",children:q.label},q.value),e[27]=r,e[28]=b):b=e[28],_=v.map(b),e[24]=r,e[25]=v,e[26]=_}else _=e[26];let T;e[29]!==n.label||e[30]!==t||e[31]!==h||e[32]!==f||e[33]!==_?(T=s.jsx(ze,{id:t,value:h,onValueChange:f,orientation:"vertical",variant:"outline",size:"sm",className:"w-full items-stretch","aria-label":y,children:_}),e[29]=n.label,e[30]=t,e[31]=h,e[32]=f,e[33]=_,e[34]=T):T=e[34];let N;return e[35]!==a||e[36]!==T?(N=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[a,T]}),e[35]=a,e[36]=T,e[37]=N):N=e[37],N}let c;e[38]!==n?(c=s.jsx(De,{field:n}),e[38]=n,e[39]=c):c=e[39];let d;e[40]!==t||e[41]!==c?(d=s.jsx(Le,{htmlFor:t,children:c}),e[40]=t,e[41]=c,e[42]=d):d=e[42];const g=n.type==="string"?"text":"number",m=typeof i=="string"?i:"";let x;e[43]!==o?(x=u=>o(u.target.value),e[43]=o,e[44]=x):x=e[44];let j;e[45]!==r||e[46]!==n.label||e[47]!==t||e[48]!==g||e[49]!==m||e[50]!==x?(j=s.jsx(Ke,{id:t,"aria-label":n.label,type:g,value:m,disabled:r,onChange:x}),e[45]=r,e[46]=n.label,e[47]=t,e[48]=g,e[49]=m,e[50]=x,e[51]=j):j=e[51];let p;return e[52]!==d||e[53]!==j?(p=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[d,j]}),e[52]=d,e[53]=j,e[54]=p):p=e[54],p}function De(l){const e=P.c(8),{field:t}=l;let n;e[0]!==t.required?(n=t.required&&s.jsx("span",{className:"ml-0.5 text-warning",children:"*"}),e[0]=t.required,e[1]=n):n=e[1];let i;e[2]!==t.description?(i=t.description&&s.jsx("span",{className:"block text-xs font-normal text-muted-foreground",children:t.description}),e[2]=t.description,e[3]=i):i=e[3];let r;return e[4]!==t.label||e[5]!==n||e[6]!==i?(r=s.jsxs("span",{className:"min-w-0",children:[t.label,n,i]}),e[4]=t.label,e[5]=n,e[6]=i,e[7]=r):r=e[7],r}function Ve(l){const e=P.c(8),{server:t,children:n}=l;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(It,{className:"text-info"}),e[0]=i):i=e[0];let r;e[1]!==t?(r=s.jsxs(_e,{children:[t," needs input"]}),e[1]=t,e[2]=r):r=e[2];let o;e[3]!==n?(o=s.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:n}),e[3]=n,e[4]=o):o=e[4];let c;return e[5]!==r||e[6]!==o?(c=s.jsxs(qe,{className:"border-info/40 bg-info/5",children:[i,r,o]}),e[5]=r,e[6]=o,e[7]=c):c=e[7],c}const Gt=["allow","allow_always","deny"],Qt=[{decision:"allow",label:"Allow",variant:"default"},{decision:"deny",label:"Deny",variant:"destructive"},{decision:"allow_always",label:"Always",variant:"outline"}];function Ht(l,e){return(l.availableDecisions??Gt).includes(e)}function Kt(l){const e=P.c(22),{request:t,queued:n,responding:i,onRespond:r}=l;let o;if(e[0]!==r||e[1]!==n||e[2]!==t||e[3]!==i){let c;e[5]!==t?(c=y=>Ht(t,y.decision),e[5]=t,e[6]=c):c=e[6];const d=Qt.filter(c),g=d.some(Wt);let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Pe,{className:"text-warning"}),e[7]=m):m=e[7];const x=t.title||`Allow ${t.toolName}?`;let j;e[8]!==x?(j=s.jsx("span",{className:"min-w-0 flex-1 truncate",children:x}),e[8]=x,e[9]=j):j=e[9];let p;e[10]!==n?(p=n>0&&s.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",children:["+",n]}),e[10]=n,e[11]=p):p=e[11];let u;e[12]!==j||e[13]!==p?(u=s.jsxs(_e,{className:"flex min-w-0 items-center gap-2",children:[j,p]}),e[12]=j,e[13]=p,e[14]=u):u=e[14];let a;e[15]!==t.toolName?(a=s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t.toolName}),e[15]=t.toolName,e[16]=a):a=e[16];let h;e[17]!==t.summary?(h=t.summary&&s.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-xs text-foreground",children:t.summary}),e[17]=t.summary,e[18]=h):h=e[18];let f;e[19]!==a||e[20]!==h?(f=s.jsxs("div",{className:"col-start-2 mt-2 flex min-w-0 items-center gap-2",children:[a,h]}),e[19]=a,e[20]=h,e[21]=f):f=e[21],o=s.jsxs(qe,{className:"border-warning/40 bg-warning/5",children:[m,u,f,g?s.jsx("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:d.map(y=>{const{decision:v,label:_,variant:T}=y;return s.jsx(U,{size:"xs",variant:T,disabled:i,onClick:()=>r(t.requestId,v),children:_},v)})}):s.jsx("p",{className:"col-start-2 mt-2 text-xs text-warning",children:"Resolve this approval in its own provider"})]}),e[0]=r,e[1]=n,e[2]=t,e[3]=i,e[4]=o}else o=e[4];return o}function Wt(l){return l.decision!=="allow_always"}function Xt(l){return l.some(e=>e.options.length===0||e.options.some(t=>t.hasPreview))}function Jt(l){const e=P.c(63),{request:t,responding:n,gone:i,onAnswer:r,onOpenSession:o}=l,c=t.questions,[d,g]=V.useState(0);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];const x=V.useRef(m);let j;e[1]===Symbol.for("react.memo_cache_sentinel")?(j=new Set,e[1]=j):j=e[1];const[p,u]=V.useState(j);if(c.length===0)return null;if(Xt(c)){let E;e[2]!==c[0].question?(E=s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:c[0].question}),e[2]=c[0].question,e[3]=E):E=e[3];let C;e[4]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(Fe,{"data-icon":"inline-end"}),e[4]=C):C=e[4];let D;e[5]!==o?(D=s.jsxs(U,{variant:"outline",size:"sm",onClick:o,className:"mt-3",children:["Open full question",C]}),e[5]=o,e[6]=D):D=e[6];let O;return e[7]!==E||e[8]!==D?(O=s.jsxs(Ue,{children:[E,D]}),e[7]=E,e[8]=D,e[9]=O):O=e[9],O}const a=c[d];let h;e[10]!==a.question||e[11]!==d||e[12]!==r||e[13]!==c.length||e[14]!==t.toolUseId?(h=function(C){const D={...x.current,[a.question]:C};if(d+1<c.length){x.current=D,u(new Set),g(d+1);return}r(t.toolUseId,D)},e[10]=a.question,e[11]=d,e[12]=r,e[13]=c.length,e[14]=t.toolUseId,e[15]=h):h=e[15];const f=h;let y;e[16]!==a.header?(y=a.header&&s.jsx(Te,{variant:"outline",className:"border-info/40 text-info",children:a.header}),e[16]=a.header,e[17]=y):y=e[17];let v;e[18]!==d||e[19]!==c.length?(v=c.length>1&&s.jsxs("span",{className:"ml-auto shrink-0 font-mono text-xs text-muted-foreground",children:[d+1," of ",c.length]}),e[18]=d,e[19]=c.length,e[20]=v):v=e[20];let _;e[21]!==y||e[22]!==v?(_=s.jsxs("div",{className:"flex items-baseline gap-1.5",children:[y,v]}),e[21]=y,e[22]=v,e[23]=_):_=e[23];let T;e[24]!==a.question?(T=s.jsx("p",{className:"mt-2 line-clamp-3 text-sm leading-relaxed text-foreground",title:a.question,children:a.question}),e[24]=a.question,e[25]=T):T=e[25];let N;e[26]!==p?(N=[...p],e[26]=p,e[27]=N):N=e[27];let b;e[28]!==f||e[29]!==a.multiSelect?(b=E=>{a.multiSelect?u(new Set(E)):E[0]&&f(E[0])},e[28]=f,e[29]=a.multiSelect,e[30]=b):b=e[30];const q=a.multiSelect,S=a.question;let w;if(e[31]!==a.options||e[32]!==n){let E;e[34]!==n?(E=C=>s.jsx(Zt,{option:C,disabled:n},C.label),e[34]=n,e[35]=E):E=e[35],w=a.options.map(E),e[31]=a.options,e[32]=n,e[33]=w}else w=e[33];let I;e[36]!==a.multiSelect||e[37]!==a.question||e[38]!==w||e[39]!==N||e[40]!==b?(I=s.jsx(ze,{value:N,onValueChange:b,multiple:q,orientation:"vertical",variant:"outline",size:"sm",className:"mt-3 w-full items-stretch","aria-label":S,children:w}),e[36]=a.multiSelect,e[37]=a.question,e[38]=w,e[39]=N,e[40]=b,e[41]=I):I=e[41];let z;e[42]!==f||e[43]!==a.multiSelect||e[44]!==d||e[45]!==c.length||e[46]!==n||e[47]!==p?(z=a.multiSelect&&s.jsx(U,{size:"sm",disabled:n||p.size===0,onClick:()=>f(Xe(p)),children:d+1<c.length?"Next":"Send"}),e[42]=f,e[43]=a.multiSelect,e[44]=d,e[45]=c.length,e[46]=n,e[47]=p,e[48]=z):z=e[48];let L;e[49]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(Fe,{"data-icon":"inline-end"}),e[49]=L):L=e[49];let k;e[50]!==o?(k=s.jsxs(U,{variant:"ghost",size:"sm",onClick:o,className:"ml-auto text-muted-foreground",children:["Open session",L]}),e[50]=o,e[51]=k):k=e[51];let R;e[52]!==z||e[53]!==k?(R=s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[z,k]}),e[52]=z,e[53]=k,e[54]=R):R=e[54];let F;e[55]!==i?(F=i&&s.jsx("p",{className:"mt-2 text-xs text-warning",children:"This question may already be answered. Open the session to check."}),e[55]=i,e[56]=F):F=e[56];let A;return e[57]!==I||e[58]!==R||e[59]!==F||e[60]!==_||e[61]!==T?(A=s.jsxs(Ue,{children:[_,T,I,R,F]}),e[57]=I,e[58]=R,e[59]=F,e[60]=_,e[61]=T,e[62]=A):A=e[62],A}function Zt(l){const e=P.c(17),{option:t,disabled:n}=l;let i;e[0]!==t.label?(i=s.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.label}),e[0]=t.label,e[1]=i):i=e[1];const r=i;if(!t.description){let m;return e[2]!==n||e[3]!==r||e[4]!==t.label?(m=s.jsx(ke,{value:t.label,disabled:n,className:"w-full justify-start px-3",children:r}),e[2]=n,e[3]=r,e[4]=t.label,e[5]=m):m=e[5],m}let o;e[6]!==n||e[7]!==t.label?(o=s.jsx(ke,{value:t.label,disabled:n,className:"w-full justify-start px-3"}),e[6]=n,e[7]=t.label,e[8]=o):o=e[8];let c;e[9]!==r||e[10]!==o?(c=s.jsx(Ze,{render:o,children:r}),e[9]=r,e[10]=o,e[11]=c):c=e[11];let d;e[12]!==t.description?(d=s.jsx(Je,{side:"right",className:"max-w-72 text-left",children:t.description}),e[12]=t.description,e[13]=d):d=e[13];let g;return e[14]!==c||e[15]!==d?(g=s.jsxs(et,{children:[c,d]}),e[14]=c,e[15]=d,e[16]=g):g=e[16],g}function Ue(l){const e=P.c(4),{children:t}=l;let n,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(Se,{className:"text-info"}),i=s.jsx(_e,{children:"Answer to continue"}),e[0]=n,e[1]=i):(n=e[0],i=e[1]);let r;return e[2]!==t?(r=s.jsxs(qe,{className:"border-info/40 bg-info/5",children:[n,i,s.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:t})]}),e[2]=t,e[3]=r):r=e[3],r}function es(l){const e=P.c(33),{request:t,responding:n,onChoose:i}=l;let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(Pe,{className:"text-warning"}),o=s.jsx(_e,{children:"Claude declined this request"}),e[0]=r,e[1]=o):(r=e[0],o=e[1]);let c;e[2]!==t.originalModel?(c=s.jsxs("p",{className:"text-sm leading-relaxed text-foreground",children:[t.originalModel," would not answer. Retrying on a fallback model may work."]}),e[2]=t.originalModel,e[3]=c):c=e[3];let d;e[4]!==t.guidanceText?(d=t.guidanceText&&s.jsx("p",{className:"mt-1 text-sm leading-relaxed text-muted-foreground",children:t.guidanceText}),e[4]=t.guidanceText,e[5]=d):d=e[5];let g;e[6]!==i||e[7]!==t.requestId?(g=()=>i(t.requestId,"retry_fallback"),e[6]=i,e[7]=t.requestId,e[8]=g):g=e[8];let m;e[9]!==t.fallbackModel||e[10]!==n||e[11]!==g?(m=s.jsxs(U,{size:"sm",disabled:n,onClick:g,children:["Retry on ",t.fallbackModel]}),e[9]=t.fallbackModel,e[10]=n,e[11]=g,e[12]=m):m=e[12];let x;e[13]!==i||e[14]!==t.requestId?(x=()=>i(t.requestId,"edit_prompt"),e[13]=i,e[14]=t.requestId,e[15]=x):x=e[15];let j;e[16]!==n||e[17]!==x?(j=s.jsx(U,{variant:"outline",size:"sm",disabled:n,onClick:x,children:"Edit prompt"}),e[16]=n,e[17]=x,e[18]=j):j=e[18];let p;e[19]!==i||e[20]!==t.requestId?(p=()=>i(t.requestId,"cancelled"),e[19]=i,e[20]=t.requestId,e[21]=p):p=e[21];let u;e[22]!==n||e[23]!==p?(u=s.jsx(U,{variant:"ghost",size:"sm",disabled:n,className:"ml-auto text-muted-foreground",onClick:p,children:"Dismiss"}),e[22]=n,e[23]=p,e[24]=u):u=e[24];let a;e[25]!==u||e[26]!==m||e[27]!==j?(a=s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[m,j,u]}),e[25]=u,e[26]=m,e[27]=j,e[28]=a):a=e[28];let h;return e[29]!==a||e[30]!==c||e[31]!==d?(h=s.jsxs(qe,{className:"border-warning/40 bg-warning/5",children:[r,o,s.jsxs("div",{className:"col-start-2 mt-1 min-w-0",children:[c,d,a]})]}),e[29]=a,e[30]=c,e[31]=d,e[32]=h):h=e[32],h}function Be(l){return l==="awaiting_approval"||l==="awaiting_prompt"||l==="awaiting_question"||l==="awaiting_answer"}function Ee(l){return l==="done"||l==="failed"}const Ye={awaiting_approval:0,awaiting_prompt:1,awaiting_question:2,awaiting_answer:3,running:4,failed:5,done:6};function ts(l,e,t,n,i,r){return t?"awaiting_approval":n?"awaiting_prompt":i?"awaiting_question":r||l.agentStatus==="deferred"||l.agentStatus==="idle"&&e?"awaiting_answer":l.agentTerminalReason?"failed":e&&l.agentStatus&&nt.has(l.agentStatus)?"running":"done"}const ss=6;function ns({sessions:l,procBySession:e,summaries:t,permissionsBySession:n,questionsBySession:i,elicitationsBySession:r,dialogsBySession:o,awaitingPlan:c,newlyCompleted:d,finishedLimit:g=ss,now:m=Date.now()}){const x=[];for(const u of tt(l)){const a=n.get(u.sessionId)??[],h=i.get(u.sessionId)??[],f=r.get(u.sessionId)??[],y=o.get(u.sessionId)??[],v=c.has(u.sessionId),_=a.length+h.length+f.length+y.length+Number(v);u.teamName&&u.agentName&&_===0||x.push({session:u,state:ts(u,st(u,e,m),a.length>0,f.length>0||y.length>0,h.length>0,v),summary:t.get(u.sessionId)??null,permissions:a,questions:h,elicitations:f,dialogs:y})}const j=x.filter(u=>Ee(u.state)),p=[...j.filter(u=>d.has(u.session.sessionId)),...j.filter(u=>!d.has(u.session.sessionId))].slice(0,g);return[...x.filter(u=>!Ee(u.state)),...p].sort((u,a)=>Ye[u.state]-Ye[a.state])}function is(l,e){switch(e){case"running":return l.filter(t=>t.state==="running");case"needs-you":return l.filter(t=>Be(t.state));case"finished":return l.filter(t=>Ee(t.state));default:return l}}function ls(l){const e={total:l.length,running:0,needsYou:0,finished:0,failed:0};for(const t of l)t.state==="running"&&e.running++,Be(t.state)&&e.needsYou++,Ee(t.state)&&e.finished++,t.state==="failed"&&e.failed++;return e}function os(l){return l>=90?"text-destructive":l>=70?"text-warning":"text-muted-foreground"}const as={awaiting_approval:{label:"Waiting for approval",text:"text-warning",shell:"border-warning/40 bg-warning/5",icon:Se},awaiting_prompt:{label:"Waiting for your input",text:"text-info",shell:"border-info/40 bg-info/5",icon:Se},awaiting_question:{label:"Waiting for your answer",text:"text-info",shell:"border-info/40 bg-info/5",icon:Se},awaiting_answer:{label:"Waiting for your answer",text:"text-warning",shell:"border-warning/40 bg-warning/5",icon:Se},running:{label:"Running",text:"text-info",shell:"border-border",icon:null},done:{label:"Done",text:"text-success",shell:"border-border",icon:qt},failed:{label:"Failed",text:"text-destructive",shell:"border-destructive/40",icon:_t}};function rs(l){const e=P.c(3),{icon:t}=l;if(!t){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("span",{className:"size-2 shrink-0 rounded-full bg-info"}),e[0]=i):i=e[0],i}let n;return e[1]!==t?(n=s.jsx(t,{className:"size-3.5 shrink-0"}),e[1]=t,e[2]=n):n=e[2],n}const cs=V.memo(function(e){const t=P.c(88),{card:n,customName:i,projectLabel:r,responding:o,goneQuestions:c,compact:d,onOpen:g,onRespond:m,onAnswerQuestion:x,onAnswerElicitation:j,onChooseDialog:p}=e,u=d===void 0?!1:d,{session:a,state:h,summary:f,permissions:y,questions:v,elicitations:_,dialogs:T}=n,N=as[h],b=y[0],q=v[0],S=_[0],w=T[0],I=!!(b||q||S||w);let z;t[0]!==i||t[1]!==a?(z=it(a,i),t[0]=i,t[1]=a,t[2]=z):z=t[2];const L=z,k=u&&"gap-1.5 py-2";let R;t[3]!==N.shell||t[4]!==k?(R=ue("motion-card motion-list-item group flex min-w-0 flex-col gap-2 rounded-lg border bg-card p-3 text-left transition-colors hover:border-foreground/20",N.shell,k),t[3]=N.shell,t[4]=k,t[5]=R):R=t[5];const F=`Open session ${L}`;let A;t[6]!==r?(A=s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:r}),t[6]=r,t[7]=A):A=t[7];let E;t[8]!==f?(E=(f==null?void 0:f.model)&&s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:lt(f.model)}),t[8]=f,t[9]=E):E=t[9];let C;t[10]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx(Fe,{"data-icon":"inline-end",className:"shrink-0 text-transparent transition-colors group-hover:text-muted-foreground"}),t[10]=C):C=t[10];let D;t[11]!==A||t[12]!==E?(D=s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[A,E,C]}),t[11]=A,t[12]=E,t[13]=D):D=t[13];const O=u?"truncate":"line-clamp-2";let se;t[14]!==O?(se=ue("text-sm font-medium leading-snug text-foreground",O),t[14]=O,t[15]=se):se=t[15];let B;t[16]!==se||t[17]!==L?(B=s.jsx("span",{className:se,children:L}),t[16]=se,t[17]=L,t[18]=B):B=t[18];let ne;t[19]!==g||t[20]!==B||t[21]!==F||t[22]!==D?(ne=s.jsxs(U,{variant:"ghost",onClick:g,className:"-m-1 h-auto min-w-0 flex-col items-stretch justify-start gap-1 whitespace-normal p-1 text-left","aria-label":F,children:[D,B]}),t[19]=g,t[20]=B,t[21]=F,t[22]=D,t[23]=ne):ne=t[23];let ie;t[24]!==N.text?(ie=ue("flex items-center gap-1.5 text-xs font-medium",N.text),t[24]=N.text,t[25]=ie):ie=t[25];let le;t[26]!==N.icon?(le=s.jsx(rs,{icon:N.icon}),t[26]=N.icon,t[27]=le):le=t[27];let te;t[28]!==N.label?(te=s.jsx("span",{className:"truncate",children:N.label}),t[28]=N.label,t[29]=te):te=t[29];const ce=a.lastActivityAt||a.lastModified;let G;t[30]!==ce?(G=ot(ce),t[30]=ce,t[31]=G):G=t[31];let oe;t[32]!==G?(oe=s.jsx("span",{className:"ml-auto shrink-0 font-mono text-xs font-normal text-muted-foreground",children:G}),t[32]=G,t[33]=oe):oe=t[33];let Q;t[34]!==ie||t[35]!==le||t[36]!==te||t[37]!==oe?(Q=s.jsxs("div",{className:ie,children:[le,te,oe]}),t[34]=ie,t[35]=le,t[36]=te,t[37]=oe,t[38]=Q):Q=t[38];let H;t[39]!==m||t[40]!==y.length||t[41]!==b||t[42]!==o||t[43]!==a.sessionId?(H=b&&s.jsx(Kt,{request:b,queued:y.length-1,responding:o.has(b.requestId),onRespond:(re,Y)=>m(a.sessionId,re,Y)}),t[39]=m,t[40]=y.length,t[41]=b,t[42]=o,t[43]=a.sessionId,t[44]=H):H=t[44];let K;t[45]!==w||t[46]!==p||t[47]!==b||t[48]!==o||t[49]!==a.sessionId?(K=!b&&w&&s.jsx(es,{request:w,responding:o.has(w.requestId),onChoose:(re,Y)=>p(a.sessionId,re,Y)},w.requestId),t[45]=w,t[46]=p,t[47]=b,t[48]=o,t[49]=a.sessionId,t[50]=K):K=t[50];let W;t[51]!==w||t[52]!==S||t[53]!==j||t[54]!==b||t[55]!==o||t[56]!==a.sessionId?(W=!b&&!w&&S&&s.jsx(Pt,{request:S,responding:o.has(S.requestId),onAnswer:(re,Y)=>j(a.sessionId,re,Y)},S.requestId),t[51]=w,t[52]=S,t[53]=j,t[54]=b,t[55]=o,t[56]=a.sessionId,t[57]=W):W=t[57];let X;t[58]!==w||t[59]!==S||t[60]!==c||t[61]!==x||t[62]!==g||t[63]!==q||t[64]!==b||t[65]!==o||t[66]!==a.sessionId?(X=!b&&!w&&!S&&q&&s.jsx(Jt,{request:q,responding:o.has(q.toolUseId),gone:c.has(q.toolUseId),onAnswer:(re,Y)=>x(a.sessionId,re,Y),onOpenSession:g},q.toolUseId),t[58]=w,t[59]=S,t[60]=c,t[61]=x,t[62]=g,t[63]=q,t[64]=b,t[65]=o,t[66]=a.sessionId,t[67]=X):X=t[67];let J;t[68]!==I||t[69]!==f?(J=!I&&(f==null?void 0:f.currentTool)&&s.jsx(ds,{tool:f.currentTool}),t[68]=I,t[69]=f,t[70]=J):J=t[70];let Z;t[71]!==I||t[72]!==u||t[73]!==f?(Z=!u&&!I&&(f==null?void 0:f.lastAssistantText)&&s.jsx("p",{className:"line-clamp-4 text-sm leading-relaxed text-muted-foreground",children:f.lastAssistantText}),t[71]=I,t[72]=u,t[73]=f,t[74]=Z):Z=t[74];let ee;t[75]!==f?(ee=f&&s.jsx(us,{summary:f}),t[75]=f,t[76]=ee):ee=t[76];let ae;return t[77]!==ne||t[78]!==Q||t[79]!==H||t[80]!==K||t[81]!==W||t[82]!==X||t[83]!==J||t[84]!==Z||t[85]!==ee||t[86]!==R?(ae=s.jsxs("div",{className:R,children:[ne,Q,H,K,W,X,J,Z,ee]}),t[77]=ne,t[78]=Q,t[79]=H,t[80]=K,t[81]=W,t[82]=X,t[83]=J,t[84]=Z,t[85]=ee,t[86]=R,t[87]=ae):ae=t[87],ae});function ds(l){const e=P.c(7),{tool:t}=l;let n;e[0]!==t.name?(n=s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t.name}),e[0]=t.name,e[1]=n):n=e[1];let i;e[2]!==t.summary?(i=s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground/80",children:t.summary}),e[2]=t.summary,e[3]=i):i=e[3];let r;return e[4]!==n||e[5]!==i?(r=s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md bg-muted/50 px-2.5 py-2",children:[n,i]}),e[4]=n,e[5]=i,e[6]=r):r=e[6],r}function us(l){const e=P.c(11),{summary:t}=l,n=t.filesTotal,i=t.context,r=n.count>0,o=i!==null&&i.used>0;if(!r&&!o)return null;let c;e[0]!==n.additions||e[1]!==n.count||e[2]!==n.deletions||e[3]!==r?(c=r&&s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"truncate",children:[n.count," file",n.count===1?"":"s"]}),s.jsx(at,{add:n.additions,del:n.deletions})]}),e[0]=n.additions,e[1]=n.count,e[2]=n.deletions,e[3]=r,e[4]=c):c=e[4];let d;e[5]!==i||e[6]!==o?(d=o&&s.jsxs("span",{className:ue("ml-auto shrink-0",os(i.percent)),children:["ctx ",i.percent,"%"]}),e[5]=i,e[6]=o,e[7]=d):d=e[7];let g;return e[8]!==c||e[9]!==d?(g=s.jsxs("div",{className:"mt-auto flex items-center gap-2 border-t pt-2 font-mono text-xs text-muted-foreground",children:[c,d]}),e[8]=c,e[9]=d,e[10]=g):g=e[10],g}const fs=8e3,ms=12,xs="Start Claude Code, Codex, or Copilot and every session shows up here",hs=[{id:"all",label:"All"},{id:"running",label:"Running"},{id:"needs-you",label:"Needs you"},{id:"finished",label:"Finished"}],gs=[{id:"grid",label:"Grid layout",Icon:Ct},{id:"list",label:"List layout",Icon:Tt}];function Ns(l){const e=P.c(118),{onSelectSession:t}=l,{sessions:n,procBySession:i,newlyCompleted:r,refresh:o}=rt(),{summaries:c,loading:d,error:g,refresh:m}=Mt(),{permissionsBySession:x,questionsBySession:j,elicitationsBySession:p,dialogsBySession:u,awaitingPlan:a,responding:h,respond:f,answerQuestion:y,answerElicitation:v,answerDialog:_,refresh:T}=ct();let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=new Set,e[0]=N):N=e[0];const[b,q]=V.useState(N),{names:S}=dt(),{names:w}=ut(),[I,z]=V.useState("all");let L;e[1]===Symbol.for("react.memo_cache_sentinel")?(L=ft("mission-control-layout"),e[1]=L):L=e[1];const[k,R]=mt(L,"grid");let F;e[2]!==a||e[3]!==u||e[4]!==p||e[5]!==r||e[6]!==x||e[7]!==i||e[8]!==j||e[9]!==n||e[10]!==c?(F=ns({sessions:n,procBySession:i,summaries:c,permissionsBySession:x,questionsBySession:j,elicitationsBySession:p,dialogsBySession:u,awaitingPlan:a,newlyCompleted:r}),e[2]=a,e[3]=u,e[4]=p,e[5]=r,e[6]=x,e[7]=i,e[8]=j,e[9]=n,e[10]=c,e[11]=F):F=e[11];const A=F;let E;e[12]!==A?(E=ls(A),e[12]=A,e[13]=E):E=e[13];const C=E;let D;e[14]!==A||e[15]!==I?(D=is(A,I),e[14]=A,e[15]=I,e[16]=D):D=e[16];const O=D;let se;e[17]!==T||e[18]!==o||e[19]!==m?(se=()=>{o(),m(),T()},e[17]=T,e[18]=o,e[19]=m,e[20]=se):se=e[20];const B=se;let ne,ie;e[21]!==o?(ne=()=>{const $=setInterval(()=>{document.visibilityState==="visible"&&o()},fs);return()=>clearInterval($)},ie=[o],e[21]=o,e[22]=ne,e[23]=ie):(ne=e[22],ie=e[23]),V.useEffect(ne,ie);let le;e[24]!==y?(le=async($,M,Me)=>{(await y($,M,Me)).ok||q(Ge=>new Set(Ge).add(M))},e[24]=y,e[25]=le):le=e[25];const te=le;let ce;e[26]!==A.length?(ce=function(M){A.length<=ms?Ot(M,{kind:"fade"}):V.startTransition(M)},e[26]=A.length,e[27]=ce):ce=e[27];const G=ce;let oe;e[28]===Symbol.for("react.memo_cache_sentinel")?(oe=s.jsx("h2",{className:"truncate text-sm font-semibold",children:"Mission Control"}),e[28]=oe):oe=e[28];let Q;e[29]!==C.total?(Q=s.jsx(Te,{variant:"secondary",children:C.total}),e[29]=C.total,e[30]=Q):Q=e[30];let H;e[31]!==C.needsYou?(H=C.needsYou>0&&s.jsxs(Te,{variant:"outline",className:"border-warning/40 text-warning",children:[C.needsYou," need you"]}),e[31]=C.needsYou,e[32]=H):H=e[32];let K;e[33]!==C.failed?(K=C.failed>0&&s.jsxs(Te,{variant:"destructive",children:[C.failed," failed"]}),e[33]=C.failed,e[34]=K):K=e[34];let W;e[35]!==Q||e[36]!==H||e[37]!==K?(W=s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[oe,Q,H,K]}),e[35]=Q,e[36]=H,e[37]=K,e[38]=W):W=e[38];let X;e[39]!==I?(X=[I],e[39]=I,e[40]=X):X=e[40];let J;e[41]!==I||e[42]!==G?(J=$=>{const M=$.at(-1);M&&M!==I&&G(()=>z(M))},e[41]=I,e[42]=G,e[43]=J):J=e[43];let Z;e[44]!==C.needsYou?(Z=hs.map($=>s.jsxs(ke,{value:$.id,"aria-label":`Show ${$.label.toLowerCase()} sessions`,children:[$.label,$.id==="needs-you"&&C.needsYou>0&&s.jsx("span",{className:"font-mono text-warning",children:C.needsYou})]},$.id)),e[44]=C.needsYou,e[45]=Z):Z=e[45];let ee;e[46]!==X||e[47]!==J||e[48]!==Z?(ee=s.jsx(ze,{value:X,onValueChange:J,variant:"outline",size:"sm",spacing:0,"aria-label":"Filter sessions",children:Z}),e[46]=X,e[47]=J,e[48]=Z,e[49]=ee):ee=e[49];let ae;e[50]!==k||e[51]!==R||e[52]!==G?(ae=gs.map($=>{const{id:M,label:Me,Icon:Oe}=$;return s.jsx(U,{variant:"ghost",size:"icon-xs","aria-label":Me,"aria-pressed":k===M,onClick:()=>{M!==k&&G(()=>R(M))},className:ue(k===M&&"bg-accent text-accent-foreground"),children:s.jsx(Oe,{"data-icon":"inline-start"})},M)}),e[50]=k,e[51]=R,e[52]=G,e[53]=ae):ae=e[53];const re=d&&"animate-spin";let Y;e[54]!==re?(Y=ue(re),e[54]=re,e[55]=Y):Y=e[55];let fe;e[56]!==Y?(fe=s.jsx(At,{"data-icon":"inline-start",className:Y}),e[56]=Y,e[57]=fe):fe=e[57];let me;e[58]!==B||e[59]!==fe?(me=s.jsx(U,{variant:"ghost",size:"icon-xs","aria-label":"Refresh Mission Control",onClick:B,children:fe}),e[58]=B,e[59]=fe,e[60]=me):me=e[60];let xe;e[61]!==ae||e[62]!==me?(xe=s.jsxs("div",{className:"flex items-center gap-1",children:[ae,me]}),e[61]=ae,e[62]=me,e[63]=xe):xe=e[63];let he;e[64]!==ee||e[65]!==xe?(he=s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[ee,xe]}),e[64]=ee,e[65]=xe,e[66]=he):he=e[66];let ge;e[67]!==W||e[68]!==he?(ge=s.jsxs("header",{className:"flex min-h-12 shrink-0 flex-wrap items-center gap-3 border-b px-4 py-2",children:[W,he]}),e[67]=W,e[68]=he,e[69]=ge):ge=e[69];let pe;e[70]!==g||e[71]!==B?(pe=g&&s.jsxs(qe,{variant:"destructive",className:"mb-4",children:[s.jsx(Et,{}),s.jsx(_e,{children:"Mission Control could not refresh"}),s.jsx(wt,{className:"truncate",children:g}),s.jsx(vt,{children:s.jsx(U,{variant:"outline",size:"xs",onClick:B,children:"Retry"})})]}),e[70]=g,e[71]=B,e[72]=pe):pe=e[72];let be;e[73]!==A.length||e[74]!==I||e[75]!==d||e[76]!==O.length?(be=O.length===0&&!d&&s.jsx(xt,{className:"min-h-64",children:s.jsxs(ht,{children:[s.jsx(gt,{variant:"icon",children:s.jsx(kt,{})}),s.jsx(pt,{children:A.length===0?"No live sessions":`Nothing matches "${I}"`}),s.jsx(bt,{children:A.length===0?xs:"Try a different filter."})]})}),e[73]=A.length,e[74]=I,e[75]=d,e[76]=O.length,e[77]=be):be=e[77];let je;e[78]!==A.length||e[79]!==d||e[80]!==O.length?(je=O.length===0&&d&&A.length===0&&s.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground",children:[s.jsx(jt,{}),"Loading sessions…"]}),e[78]=A.length,e[79]=d,e[80]=O.length,e[81]=je):je=e[81];const Re=k==="grid"&&"md:grid-cols-2 2xl:grid-cols-3";let we;e[82]!==Re?(we=ue("grid grid-cols-1 gap-3",Re),e[82]=Re,e[83]=we):we=e[83];let ve;if(e[84]!==_||e[85]!==v||e[86]!==b||e[87]!==te||e[88]!==k||e[89]!==t||e[90]!==w||e[91]!==f||e[92]!==h||e[93]!==S||e[94]!==O){let $;e[96]!==_||e[97]!==v||e[98]!==b||e[99]!==te||e[100]!==k||e[101]!==t||e[102]!==w||e[103]!==f||e[104]!==h||e[105]!==S?($=M=>s.jsx(cs,{card:M,compact:k==="list",customName:S[M.session.sessionId],projectLabel:w[M.session.dirName]??Nt(M.session),responding:h,goneQuestions:b,onOpen:()=>t(M.session.dirName,M.session.fileName),onRespond:f,onAnswerQuestion:te,onAnswerElicitation:v,onChooseDialog:_},M.session.sessionId),e[96]=_,e[97]=v,e[98]=b,e[99]=te,e[100]=k,e[101]=t,e[102]=w,e[103]=f,e[104]=h,e[105]=S,e[106]=$):$=e[106],ve=O.map($),e[84]=_,e[85]=v,e[86]=b,e[87]=te,e[88]=k,e[89]=t,e[90]=w,e[91]=f,e[92]=h,e[93]=S,e[94]=O,e[95]=ve}else ve=e[95];let Ne;e[107]!==we||e[108]!==ve?(Ne=s.jsx("div",{className:we,children:ve}),e[107]=we,e[108]=ve,e[109]=Ne):Ne=e[109];let ye;e[110]!==pe||e[111]!==be||e[112]!==je||e[113]!==Ne?(ye=s.jsx(yt,{className:"flex-1",children:s.jsxs("div",{className:"p-4",children:[pe,be,je,Ne]})}),e[110]=pe,e[111]=be,e[112]=je,e[113]=Ne,e[114]=ye):ye=e[114];let Ce;return e[115]!==ge||e[116]!==ye?(Ce=s.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[ge,ye]}),e[115]=ge,e[116]=ye,e[117]=Ce):Ce=e[117],Ce}export{Ns as MissionControl};
@@ -1 +0,0 @@
1
- import{c as oe,j as t,r as x}from"./vendor-react-gGw_S5I_.js";import{U as st,aa as le,aV as Ae,aW as ne,m as nt,n as at,I as it,ab as ut,ac as ft,aX as mt,B as Ie,aY as ht,w as Je,aZ as lt,X as pt,Y as xt,Z as gt,a_ as Qe,a$ as bt,aw as jt,ax as vt,b0 as wt,i as Nt,j as St,k as Ct,b1 as kt,a9 as yt,an as _t,h as Et,D as At}from"./index-DB1wEO_I.js";import{a5 as zt,a6 as $t,a7 as It,a8 as Tt,i as Dt,h as Pt,M as Ft,a9 as Lt,aa as Bt,ab as Rt,$ as Ut,C as Ot,F as Vt,A as Mt,ac as Xt,J as Gt,ad as ot,ae as Ht,af as Wt}from"./vendor-ui-CyII6N5s.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function qt(s){const e=oe.c(11);let n,i,a;e[0]!==s?({className:n,size:a,...i}=s,e[0]=s,e[1]=n,e[2]=i,e[3]=a):(n=e[1],i=e[2],a=e[3]);const o=a===void 0?"default":a;let c;e[4]!==n?(c=st("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",n),e[4]=n,e[5]=c):c=e[5];let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx($t,{"data-slot":"switch-thumb",className:"pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"}),e[6]=m):m=e[6];let u;return e[7]!==i||e[8]!==o||e[9]!==c?(u=t.jsx(zt,{"data-slot":"switch","data-size":o,className:c,...i,children:m}),e[7]=i,e[8]=o,e[9]=c,e[10]=u):u=e[10],u}function Kt(s){const e=oe.c(3),{name:n}=s,i=n.toLowerCase();if(i.includes("iphone")||i.includes("android")){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(Dt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[0]=o):o=e[0],o}if(i.includes("ipad")||i.includes("tablet")){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(Pt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[1]=o):o=e[1],o}let a;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Ft,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[2]=a):a=e[2],a}function et(s){const e=Math.floor((Date.now()-s)/1e3);if(e<60)return"just now";const n=Math.floor(e/60);if(n<60)return`${n}m ago`;const i=Math.floor(n/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Yt(s){const e=[`Shared ${et(s.createdAt)}`,s.lastAccessAt>0?`opened ${et(s.lastAccessAt)}`:"never opened"];return s.guests>0&&e.push(s.guests===1?"1 guest":`${s.guests} guests`),e.join(" · ")}function Zt(){const s=oe.c(12),{shares:e,revoke:n,revokeAll:i}=mt();let a;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx("p",{className:"text-xs text-muted-foreground",children:"Shared sessions"}),s[0]=a):a=s[0];let o;s[1]!==i||s[2]!==e.length?(o=e.length>0&&t.jsx(Ie,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",onClick:()=>void i(),children:"Revoke all"}),s[1]=i,s[2]=e.length,s[3]=o):o=s[3];let c;s[4]!==o?(c=t.jsxs("div",{className:"flex h-6 items-center justify-between",children:[a,o]}),s[4]=o,s[5]=c):c=s[5];let m;s[6]!==n||s[7]!==e?(m=e.length===0?t.jsx("p",{className:"text-xs text-muted-foreground",children:"No sessions are shared."}):t.jsx("div",{className:"flex flex-col gap-1.5",children:e.map(r=>{const g=r.title||r.sessionId;return t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border px-3 py-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm text-foreground",children:g}),t.jsx("p",{className:"text-xs text-muted-foreground",children:Yt(r)})]}),t.jsx(Ie,{variant:"ghost",size:"xs","aria-label":`Revoke share of ${g}`,className:"text-destructive hover:text-destructive",onClick:()=>void n(r.sessionId),children:"Revoke"})]},r.sessionId)})}),s[6]=n,s[7]=e,s[8]=m):m=s[8];let u;return s[9]!==c||s[10]!==m?(u=t.jsxs("div",{className:"flex flex-col gap-2",children:[c,m]}),s[9]=c,s[10]=m,s[11]=u):u=s[11],u}function Jt(s){const e=oe.c(30),{networkAccess:n,setNetworkAccess:i,networkPassword:a,setNetworkPassword:o,showNetworkPassword:c,setShowNetworkPassword:m,hasExistingPassword:u,initialNetworkAccess:r,connectedDevices:g,minPasswordLength:b}=s;let $;e[0]!==n?($=n?t.jsx(Lt,{"data-icon":"inline-start",className:"size-4 text-success"}):t.jsx(Bt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[0]=n,e[1]=$):$=e[1];let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Network Access"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow other devices to connect"})]}),e[2]=S):S=e[2];let _;e[3]!==$?(_=t.jsxs("div",{className:"flex items-center gap-2",children:[$,S]}),e[3]=$,e[4]=_):_=e[4];let C;e[5]!==i?(C=E=>i(E),e[5]=i,e[6]=C):C=e[6];let h;e[7]!==n||e[8]!==C?(h=t.jsx(qt,{"aria-label":"Network Access",checked:n,onCheckedChange:C}),e[7]=n,e[8]=C,e[9]=h):h=e[9];let j;e[10]!==_||e[11]!==h?(j=t.jsxs("div",{className:"flex items-center justify-between",children:[_,h]}),e[10]=_,e[11]=h,e[12]=j):j=e[12];let p;e[13]!==u||e[14]!==b||e[15]!==n||e[16]!==a||e[17]!==o||e[18]!==m||e[19]!==c?(p=n&&t.jsxs(le,{"data-invalid":a.length>0&&a.length<b,children:[t.jsx(Ae,{htmlFor:"network-password",children:"Password"}),t.jsx(ne,{children:u&&a.length===0?"A password is already set. Leave blank to keep it.":`Use at least ${b} characters.`}),t.jsxs(nt,{children:[t.jsx(at,{id:"network-password",type:c?"text":"password",value:a,onChange:E=>o(E.target.value),placeholder:u?"Enter new password to change":"Set a password for remote access"}),t.jsx(it,{align:"inline-end",children:t.jsx(ut,{size:"icon-xs","aria-label":c?"Hide password":"Show password",onClick:()=>m(!c),children:c?t.jsx(It,{"data-icon":"inline-start"}):t.jsx(Tt,{"data-icon":"inline-start"})})})]}),a.length>0&&a.length<b&&t.jsxs(ft,{children:["Password must be at least ",b," characters (",a.length,"/",b,")"]}),t.jsx(ne,{children:"Requires app restart. Remote browsers need an HTTPS reverse proxy; port 19384 remains available to Cogpit hubs and device clients."})]}),e[13]=u,e[14]=b,e[15]=n,e[16]=a,e[17]=o,e[18]=m,e[19]=c,e[20]=p):p=e[20];let d;e[21]!==g||e[22]!==r||e[23]!==n?(d=n&&r&&g.length>0&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected devices"}),t.jsx("div",{className:"flex flex-col gap-1.5",children:g.map(Qt)})]}),e[21]=g,e[22]=r,e[23]=n,e[24]=d):d=e[24];let v;e[25]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(Zt,{}),e[25]=v):v=e[25];let f;return e[26]!==j||e[27]!==p||e[28]!==d?(f=t.jsxs("div",{className:"flex flex-col gap-4 border-t pt-5",children:[j,p,d,v]}),e[26]=j,e[27]=p,e[28]=d,e[29]=f):f=e[29],f}function Qt(s,e){return t.jsxs("div",{className:"flex items-center justify-between rounded-lg border px-3 py-2",children:[t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx(Kt,{name:s.deviceName}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-foreground",children:s.deviceName}),t.jsx("p",{className:"text-xs text-muted-foreground",children:s.ip})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"size-1.5 rounded-full bg-success"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:et(s.lastActivity)})]})]},`${s.ip}-${e}`)}const es=["auto","path","npm","bundled","custom"],Ze={source:"auto"},ts=["path","npm","bundled"];function ss(s){return es.includes(s)}function ns(s){if(!s||typeof s!="object")return;const{source:e,path:n}=s;if(!(!ss(e)||e==="auto"))return e==="custom"?typeof n=="string"&&n.trim()?{source:e,path:n.trim()}:void 0:{source:e}}const $e={auto:"Automatic",path:"Installed on PATH",npm:"Global npm install",bundled:"Bundled with Cogpit",custom:"Custom path"};function rt(s,e){return e?`v${e} · ${s}`:s}function as(s,e){return s===null?"Checking installed binaries…":e?e.version===null?`${e.path} did not report a version — check the path.`:`Now running: ${rt(e.path,e.version)}`:"No launchable binary for the saved choice — sessions cannot start."}function is(s){return s!==null&&s.version!==null}function ls(s){const e=oe.c(92),{kind:n,value:i,onChange:a,disabled:o,reportVersion:c}=s;let m;e[0]!==n?(m=ht(n),e[0]=n,e[1]=m):m=e[1];const{displayName:u}=m,[r,g]=x.useState(null),[b,$]=x.useState(!1),S=`agent-executable-${n}`;let _;e[2]!==n?(_=()=>{let y=!1;return Je(`/api/agent-executable/${n}`).then(cs).then(J=>{y||g(J)}).catch(rs),()=>{y=!0}},e[2]=n,e[3]=_):_=e[3];let C;e[4]!==n||e[5]!==c?(C=[n,c],e[4]=n,e[5]=c,e[6]=C):C=e[6],x.useEffect(_,C);let h,j,p,d,v,f,E,L,B,k,I,R,q;if(e[7]!==o||e[8]!==u||e[9]!==S||e[10]!==a||e[11]!==b||e[12]!==(r==null?void 0:r.active)||e[13]!==(r==null?void 0:r.candidates)||e[14]!==i.path||e[15]!==i.source){const y=new Map((r==null?void 0:r.candidates.map(os))??[]);d=(r==null?void 0:r.active)??null;let J;e[29]!==o||e[30]!==S||e[31]!==a||e[32]!==i.path||e[33]!==i.source?(J=(A,F,te,ie)=>{const tt=ie===void 0?!0:ie,W=`${S}-${A}`;return t.jsxs(le,{orientation:"horizontal",children:[t.jsx("input",{type:"radio",id:W,name:S,className:"mt-1 size-4 shrink-0 accent-primary",checked:i.source===A,disabled:o||!tt,onChange:()=>a(A==="custom"?{source:A,path:i.path??""}:{source:A})}),t.jsxs(lt,{children:[t.jsx(Ae,{htmlFor:W,children:F}),t.jsx(ne,{className:"break-all",children:te})]})]},A)},e[29]=o,e[30]=S,e[31]=a,e[32]=i.path,e[33]=i.source,e[34]=J):J=e[34],v=J;const Q=A=>{const F=y.get(A);return v(A,$e[A],F?rt(F.path,F.version):"Not found on this machine.",F!==void 0||i.source===A)},ze=d?`${$e[i.source]} · v${d.version??"?"}`:$e[i.source];p=pt,R=b,q=$,f="flex flex-col gap-2";let G;e[35]===Symbol.for("react.memo_cache_sentinel")?(G=t.jsx(Ie,{type:"button",variant:"ghost",className:"h-auto w-full justify-between px-0 font-medium hover:bg-transparent"}),e[35]=G):G=e[35];let ee;e[36]===Symbol.for("react.memo_cache_sentinel")?(ee=t.jsx(Rt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[36]=ee):ee=e[36];let H;e[37]!==u?(H=t.jsxs("span",{className:"flex items-center gap-2",children:[ee,u," executable"]}),e[37]=u,e[38]=H):H=e[38];let T;e[39]!==ze?(T=t.jsx("span",{className:"truncate",children:ze}),e[39]=ze,e[40]=T):T=e[40];let D;e[41]!==b?(D=b?t.jsx(Ut,{className:"size-4 shrink-0"}):t.jsx(Ot,{className:"size-4 shrink-0"}),e[41]=b,e[42]=D):D=e[42];let P;e[43]!==T||e[44]!==D?(P=t.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-xs font-normal text-muted-foreground",children:[T,D]}),e[43]=T,e[44]=D,e[45]=P):P=e[45],e[46]!==H||e[47]!==P?(E=t.jsxs(xt,{render:G,children:[H,P]}),e[46]=H,e[47]=P,e[48]=E):E=e[48],j=gt,h=le,e[49]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(ne,{children:"Which binary new sessions run. Automatic uses your installed CLI unless it is older than the copy bundled with Cogpit."}),e[49]=I):I=e[49],L="flex flex-col gap-2 pl-1",e[50]!==v?(B=v("auto",$e.auto,"Recommended."),e[50]=v,e[51]=B):B=e[51],k=ts.map(Q),e[7]=o,e[8]=u,e[9]=S,e[10]=a,e[11]=b,e[12]=r==null?void 0:r.active,e[13]=r==null?void 0:r.candidates,e[14]=i.path,e[15]=i.source,e[16]=h,e[17]=j,e[18]=p,e[19]=d,e[20]=v,e[21]=f,e[22]=E,e[23]=L,e[24]=B,e[25]=k,e[26]=I,e[27]=R,e[28]=q}else h=e[16],j=e[17],p=e[18],d=e[19],v=e[20],f=e[21],E=e[22],L=e[23],B=e[24],k=e[25],I=e[26],R=e[27],q=e[28];const z=`${u} executable path`,re=i.source==="custom"?i.path??"":"",ae=o||i.source!=="custom";let K;e[52]!==a?(K=y=>a({source:"custom",path:y.target.value}),e[52]=a,e[53]=K):K=e[53];let w;e[54]!==z||e[55]!==re||e[56]!==ae||e[57]!==K?(w=t.jsx(Qe,{"aria-label":z,value:re,placeholder:"/path/to/binary",disabled:ae,onChange:K,className:"mt-1"}),e[54]=z,e[55]=re,e[56]=ae,e[57]=K,e[58]=w):w=e[58];let M;e[59]!==v||e[60]!==w?(M=v("custom",$e.custom,w),e[59]=v,e[60]=w,e[61]=M):M=e[61];let U;e[62]!==M||e[63]!==L||e[64]!==B||e[65]!==k?(U=t.jsxs("div",{className:L,children:[B,k,M]}),e[62]=M,e[63]=L,e[64]=B,e[65]=k,e[66]=U):U=e[66];let Y;e[67]!==d?(Y=is(d)?"text-muted-foreground":"text-destructive",e[67]=d,e[68]=Y):Y=e[68];let N;e[69]!==Y?(N=st("text-xs",Y),e[69]=Y,e[70]=N):N=e[70];let X;e[71]!==d||e[72]!==r?(X=as(r,d),e[71]=d,e[72]=r,e[73]=X):X=e[73];let O;e[74]!==N||e[75]!==X?(O=t.jsx("p",{className:N,"aria-live":"polite",children:X}),e[74]=N,e[75]=X,e[76]=O):O=e[76];let Z;e[77]!==h||e[78]!==U||e[79]!==O||e[80]!==I?(Z=t.jsxs(h,{children:[I,U,O]}),e[77]=h,e[78]=U,e[79]=O,e[80]=I,e[81]=Z):Z=e[81];let V;e[82]!==j||e[83]!==Z?(V=t.jsx(j,{children:Z}),e[82]=j,e[83]=Z,e[84]=V):V=e[84];let ce;return e[85]!==p||e[86]!==f||e[87]!==E||e[88]!==V||e[89]!==R||e[90]!==q?(ce=t.jsxs(p,{open:R,onOpenChange:q,className:f,children:[E,V]}),e[85]=p,e[86]=f,e[87]=E,e[88]=V,e[89]=R,e[90]=q,e[91]=ce):ce=e[91],ce}function os(s){return[s.source,s]}function rs(){}function cs(s){return s.ok?s.json():null}const ds=wt().filter(s=>s.cli.bundledBySdk).map(s=>s.kind);function us(s,e){return s.source===e.source&&(s.source!=="custom"||s.path===e.path)}function fs(s){const e=oe.c(5),{status:n,error:i}=s;if(n==="validating"){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(ot,{"data-icon":"inline-start",className:"size-3.5 animate-spin"}),"Checking path..."]}),e[0]=a):a=e[0],a}if(n==="valid"){let a;return e[1]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsxs("div",{className:"flex items-center gap-2 text-sm text-success",children:[t.jsx(Ht,{"data-icon":"inline-start",className:"size-3.5"}),"Valid .claude directory found"]}),e[1]=a):a=e[1],a}if(n==="invalid"&&i){let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Wt,{"data-icon":"inline-start",className:"size-3.5"}),e[2]=a):a=e[2];let o;return e[3]!==i?(o=t.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive",children:[a,i]}),e[3]=i,e[4]=o):o=e[4],o}return null}function Ss(s){const e=oe.c(109),{open:n,currentPath:i,onClose:a,onSaved:o}=s,[c,m]=x.useState(i),[u,r]=x.useState(!1),{status:g,error:b,debouncedValidate:$,reset:S,save:_}=bt();let C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=jt(),e[0]=C):C=e[0];const h=C;let j;e[1]===Symbol.for("react.memo_cache_sentinel")?(j=vt("configWrite"),e[1]=j):j=e[1];const p=j,[d,v]=x.useState(!1),[f,E]=x.useState(""),[L,B]=x.useState(!1),[k,I]=x.useState(""),[R,q]=x.useState(""),[z,re]=x.useState(""),[ae,K]=x.useState(""),[w,M]=x.useState(!1),[U,Y]=x.useState(!1),[N,X]=x.useState(Ze),[O,Z]=x.useState(0),[V,ce]=x.useState(Ze),[y,J]=x.useState(!1),[Q,ze]=x.useState(!1);let G;e[2]===Symbol.for("react.memo_cache_sentinel")?(G=[],e[2]=G):G=e[2];const[ee,H]=x.useState(G);let T,D;e[3]!==i||e[4]!==n||e[5]!==S?(T=()=>{n&&(m(i),S(),Je("/api/config").then(gs).then(l=>{const se=(l==null?void 0:l.networkAccess)||!1;v(se),J(se),ze(!!(l!=null&&l.networkPassword)),E("");const Ge=(l==null?void 0:l.terminalApp)||"";I(Ge),q(Ge);const He=(l==null?void 0:l.editorApp)||"";re(He),K(He);const We=(l==null?void 0:l.useBuiltInEditor)===!0;M(We),Y(We);const qe=ns(l==null?void 0:l.agentExecutable)??Ze;X(qe),ce(qe),se&&(l!=null&&l.networkPassword)&&!h?Je("/api/connected-devices").then(xs).then(Ee=>H((Ee==null?void 0:Ee.devices)||[])).catch(ps):H([])}).catch(hs))},D=[n,i,S,h],e[3]=i,e[4]=n,e[5]=S,e[6]=T,e[7]=D):(T=e[6],D=e[7]),x.useEffect(T,D);let P;e[8]!==$?(P=l=>{const se=l.target.value;m(se),$(se)},e[8]=$,e[9]=P):P=e[9];const A=P;let F;e[10]!==N||e[11]!==z||e[12]!==y||e[13]!==d||e[14]!==f||e[15]!==o||e[16]!==c||e[17]!==_||e[18]!==k||e[19]!==w?(F=async()=>{r(!0);const l=await _(c,{networkAccess:h?y:d,networkPassword:!h&&d&&f.length>0?f:void 0,terminalApp:k.trim()||void 0,editorApp:z.trim()||void 0,useBuiltInEditor:w,agentExecutable:N});l.success&&l.claudeDir&&(Z(ms),o(l.claudeDir)),r(!1)},e[10]=N,e[11]=z,e[12]=y,e[13]=d,e[14]=f,e[15]=o,e[16]=c,e[17]=_,e[18]=k,e[19]=w,e[20]=F):F=e[20];const te=F;let ie;e[21]!==N||e[22]!==z||e[23]!==Q||e[24]!==V||e[25]!==ae||e[26]!==y||e[27]!==R||e[28]!==U||e[29]!==d||e[30]!==f||e[31]!==g||e[32]!==k||e[33]!==w?(ie=function(){var Ee;if(g==="validating"||g==="invalid")return!1;const se=g==="valid",Ge=!h&&(d!==y||d&&f.length>0),He=k!==R,We=z!==ae||w!==U,qe=!us(N,V);if(!se&&!Ge&&!He&&!We&&!qe||N.source==="custom"&&!((Ee=N.path)!=null&&Ee.trim()))return!1;if(!h&&d){const ct=f.length>0&&f.length<16,dt=!Q&&f.length===0;if(ct||dt)return!1}return!0},e[21]=N,e[22]=z,e[23]=Q,e[24]=V,e[25]=ae,e[26]=y,e[27]=R,e[28]=U,e[29]=d,e[30]=f,e[31]=g,e[32]=k,e[33]=w,e[34]=ie):ie=e[34];const W=ie();let de;e[35]!==a?(de=l=>{l||a()},e[35]=a,e[36]=de):de=e[36];let Te;e[37]===Symbol.for("react.memo_cache_sentinel")?(Te=t.jsxs(Nt,{children:[t.jsx(St,{className:"text-foreground",children:"Configuration"}),t.jsx(Ct,{className:"text-muted-foreground",children:"Manage local paths, preferred apps, and remote access."})]}),e[37]=Te):Te=e[37];let De,Pe;e[38]===Symbol.for("react.memo_cache_sentinel")?(De=t.jsx(Ae,{htmlFor:"claude-directory",children:"Claude directory"}),Pe=t.jsx(ne,{children:"The directory containing your Claude configuration."}),e[38]=De,e[39]=Pe):(De=e[38],Pe=e[39]);let Fe;e[40]===Symbol.for("react.memo_cache_sentinel")?(Fe=t.jsx(it,{children:t.jsx(Vt,{"data-icon":"inline-start"})}),e[40]=Fe):Fe=e[40];let ue;e[41]!==W||e[42]!==te||e[43]!==u?(ue=l=>{l.key==="Enter"&&W&&!u&&te()},e[41]=W,e[42]=te,e[43]=u,e[44]=ue):ue=e[44];let fe;e[45]!==A||e[46]!==c||e[47]!==ue?(fe=t.jsxs(nt,{children:[Fe,t.jsx(at,{id:"claude-directory",value:c,onChange:A,placeholder:"/Users/you/.claude",disabled:!p,onKeyDown:ue})]}),e[45]=A,e[46]=c,e[47]=ue,e[48]=fe):fe=e[48];let me;e[49]!==b||e[50]!==g?(me=t.jsx("div",{"aria-live":"polite",children:t.jsx(fs,{status:g,error:b})}),e[49]=b,e[50]=g,e[51]=me):me=e[51];let he;e[52]!==fe||e[53]!==me?(he=t.jsxs(le,{children:[De,Pe,fe,me]}),e[52]=fe,e[53]=me,e[54]=he):he=e[54];let Le,Be;e[55]===Symbol.for("react.memo_cache_sentinel")?(Le=t.jsxs(Ae,{htmlFor:"terminal-application",children:[t.jsx(Mt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Terminal application"]}),Be=t.jsx(ne,{children:"Leave blank to use the system default for Ctrl+Cmd+T."}),e[55]=Le,e[56]=Be):(Le=e[55],Be=e[56]);let Re;e[57]===Symbol.for("react.memo_cache_sentinel")?(Re=l=>I(l.target.value),e[57]=Re):Re=e[57];let pe;e[58]!==k?(pe=t.jsxs(le,{children:[Le,Be,t.jsx(Qe,{id:"terminal-application",value:k,onChange:Re,placeholder:"Ghostty, iTerm, or /path/to/binary",disabled:!p})]}),e[58]=k,e[59]=pe):pe=e[59];let Ue;e[60]===Symbol.for("react.memo_cache_sentinel")?(Ue=l=>M(l===!0),e[60]=Ue):Ue=e[60];let xe;e[61]!==w?(xe=t.jsx(kt,{id:"use-built-in-editor",checked:w,onCheckedChange:Ue,disabled:!p}),e[61]=w,e[62]=xe):xe=e[62];let Oe;e[63]===Symbol.for("react.memo_cache_sentinel")?(Oe=t.jsxs(lt,{children:[t.jsxs(Ae,{htmlFor:"use-built-in-editor",children:[t.jsx(Xt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Open files in Cogpit"]}),t.jsx(ne,{children:"Files and diffs open in Cogpit’s file workspace instead of launching an external editor."})]}),e[63]=Oe):Oe=e[63];let ge;e[64]!==xe?(ge=t.jsxs(le,{orientation:"horizontal",children:[xe,Oe]}),e[64]=xe,e[65]=ge):ge=e[65];let Ve;e[66]===Symbol.for("react.memo_cache_sentinel")?(Ve=t.jsxs(Ae,{htmlFor:"editor-application",children:[t.jsx(Gt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Editor application"]}),e[66]=Ve):Ve=e[66];const Ke=w?"Not used while files open in Cogpit.":"Leave blank to use $VISUAL or automatic detection.";let be;e[67]!==Ke?(be=t.jsx(ne,{children:Ke}),e[67]=Ke,e[68]=be):be=e[68];let Me;e[69]===Symbol.for("react.memo_cache_sentinel")?(Me=l=>re(l.target.value),e[69]=Me):Me=e[69];const Ye=!p||w;let je;e[70]!==z||e[71]!==Ye?(je=t.jsx(Qe,{id:"editor-application",value:z,onChange:Me,placeholder:"cursor, code, zed, or /path/to/binary",disabled:Ye}),e[70]=z,e[71]=Ye,e[72]=je):je=e[72];let ve;e[73]!==be||e[74]!==je?(ve=t.jsxs(le,{children:[Ve,be,je]}),e[73]=be,e[74]=je,e[75]=ve):ve=e[75];let we;e[76]!==N||e[77]!==O?(we=ds.map(l=>t.jsx(ls,{kind:l,value:N,onChange:X,disabled:!p,reportVersion:O},l)),e[76]=N,e[77]=O,e[78]=we):we=e[78];let Ne;e[79]!==ee||e[80]!==Q||e[81]!==y||e[82]!==d||e[83]!==f||e[84]!==L?(Ne=!h&&p&&t.jsx(Jt,{networkAccess:d,setNetworkAccess:v,networkPassword:f,setNetworkPassword:E,showNetworkPassword:L,setShowNetworkPassword:B,hasExistingPassword:Q,initialNetworkAccess:y,connectedDevices:ee,minPasswordLength:16}),e[79]=ee,e[80]=Q,e[81]=y,e[82]=d,e[83]=f,e[84]=L,e[85]=Ne):Ne=e[85];let Se;e[86]!==he||e[87]!==pe||e[88]!==ge||e[89]!==ve||e[90]!==we||e[91]!==Ne?(Se=t.jsxs(yt,{children:[he,pe,ge,ve,we,Ne]}),e[86]=he,e[87]=pe,e[88]=ge,e[89]=ve,e[90]=we,e[91]=Ne,e[92]=Se):Se=e[92];let Ce;e[93]!==a?(Ce=t.jsx(Ie,{variant:"outline",onClick:a,children:"Cancel"}),e[93]=a,e[94]=Ce):Ce=e[94];let ke;e[95]!==W||e[96]!==te||e[97]!==u?(ke=p&&t.jsx(Ie,{disabled:!W||u,onClick:te,children:u?t.jsxs(t.Fragment,{children:[t.jsx(ot,{"data-icon":"inline-start",className:"size-4 animate-spin"}),"Saving..."]}):"Save"}),e[95]=W,e[96]=te,e[97]=u,e[98]=ke):ke=e[98];let ye;e[99]!==Ce||e[100]!==ke?(ye=t.jsxs(_t,{children:[Ce,ke]}),e[99]=Ce,e[100]=ke,e[101]=ye):ye=e[101];let _e;e[102]!==Se||e[103]!==ye?(_e=t.jsxs(Et,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-lg",children:[Te,Se,ye]}),e[102]=Se,e[103]=ye,e[104]=_e):_e=e[104];let Xe;return e[105]!==n||e[106]!==_e||e[107]!==de?(Xe=t.jsx(At,{open:n,onOpenChange:de,children:_e}),e[105]=n,e[106]=_e,e[107]=de,e[108]=Xe):Xe=e[108],Xe}function ms(s){return s+1}function hs(){}function ps(){}function xs(s){return s.json()}function gs(s){return s.json()}export{Ss as ConfigDialog};