cogpit 3.3.3 → 3.3.6

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 (34) hide show
  1. package/dist/cli-runtime.js +6320 -5138
  2. package/dist/instance-worker.js +5663 -5143
  3. package/dist/web/assets/{CogpitBlock-wGqNs0O4.js → CogpitBlock-DTcsvTF0.js} +1 -1
  4. package/dist/web/assets/{CommandPaletteHost-CmYWiZ7B.js → CommandPaletteHost-DnjXwwFv.js} +1 -1
  5. package/dist/web/assets/{ConfigBrowser-CytfmqPO.js → ConfigBrowser-C6-RV3dj.js} +1 -1
  6. package/dist/web/assets/CrewPanel-CdPeA3WX.js +1 -0
  7. package/dist/web/assets/{HighlightedEditor-DxjHIbls.js → HighlightedEditor-ptPSiZXt.js} +1 -1
  8. package/dist/web/assets/{KeyboardShortcutsDialog-C80JLjM1.js → KeyboardShortcutsDialog-CNsqP3xD.js} +1 -1
  9. package/dist/web/assets/{MissionHome-D99esiPz.js → MissionHome-CJ8aY60N.js} +2 -2
  10. package/dist/web/assets/{MobileFileChanges-BVQ33Ask.js → MobileFileChanges-xDTu0VVe.js} +1 -1
  11. package/dist/web/assets/{PluginsDialog-CvkHGbUm.js → PluginsDialog-U4WQVeyc.js} +1 -1
  12. package/dist/web/assets/{PreviewPanel-qO4KW6kE.js → PreviewPanel-CXZkRGUI.js} +1 -1
  13. package/dist/web/assets/{ProjectFilesPanel-B0x7DBNN.js → ProjectFilesPanel-DxTA4CcL.js} +1 -1
  14. package/dist/web/assets/{ProjectSwitcherModal-Do6cTEA1.js → ProjectSwitcherModal-DVRB-R0l.js} +1 -1
  15. package/dist/web/assets/{TerminalOutput-tARkD49T.js → TerminalOutput-D_7Mor6c.js} +1 -1
  16. package/dist/web/assets/{ThemeSelectorModal-Dpj_3aEi.js → ThemeSelectorModal-Bhkx5ikh.js} +1 -1
  17. package/dist/web/assets/{WorkflowsPanel-BHW1lAj9.js → WorkflowsPanel-Dexz6c1y.js} +1 -1
  18. package/dist/web/assets/WorktreePanel-DS4svy6H.js +1 -0
  19. package/dist/web/assets/{edition-ui-uRoClaTy.js → edition-ui-D6tmWJW3.js} +1 -1
  20. package/dist/web/assets/{index-3o4W_DIX.js → index-BKROBJD1.js} +1 -1
  21. package/dist/web/assets/{index-Dvo0JdAM.js → index-BZiOTcnb.js} +1 -1
  22. package/dist/web/assets/index-C6tWmbrY.css +1 -0
  23. package/dist/web/assets/index-COB3e1_W.js +496 -0
  24. package/dist/web/assets/{index-CiUDHF56.js → index-DUyWfgZU.js} +3 -3
  25. package/dist/web/assets/session-parser.worker-DqoBsPjk.js +30 -0
  26. package/dist/web/assets/{switch-85f85r6I.js → switch-Bm0VDZET.js} +1 -1
  27. package/dist/web/assets/{vendor-ui-Dfr2Rf5Q.js → vendor-ui-DKYSMrjf.js} +207 -187
  28. package/dist/web/index.html +3 -3
  29. package/package.json +1 -1
  30. package/dist/web/assets/CrewPanel-CQZnoKsK.js +0 -6
  31. package/dist/web/assets/WorktreePanel-VWeRB-Ta.js +0 -1
  32. package/dist/web/assets/index-BVrmKCdP.js +0 -483
  33. package/dist/web/assets/index-BcQTD79n.css +0 -1
  34. package/dist/web/assets/session-parser.worker-DFMK_2Iu.js +0 -30
@@ -14,12 +14,12 @@
14
14
  .dark body { background: var(--canvas, #09090b); color: var(--foreground, #fafafa); }
15
15
  body { background: var(--canvas, #fafafa); color: var(--foreground, #09090b); }
16
16
  </style>
17
- <script type="module" crossorigin src="/assets/index-BVrmKCdP.js"></script>
17
+ <script type="module" crossorigin src="/assets/index-COB3e1_W.js"></script>
18
18
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-gGw_S5I_.js">
19
- <link rel="modulepreload" crossorigin href="/assets/vendor-ui-Dfr2Rf5Q.js">
19
+ <link rel="modulepreload" crossorigin href="/assets/vendor-ui-DKYSMrjf.js">
20
20
  <link rel="modulepreload" crossorigin href="/assets/vendor-markdown-BE1gYnO9.js">
21
21
  <link rel="modulepreload" crossorigin href="/assets/vendor-shiki-DOn6sF-i.js">
22
- <link rel="stylesheet" crossorigin href="/assets/index-BcQTD79n.css">
22
+ <link rel="stylesheet" crossorigin href="/assets/index-C6tWmbrY.css">
23
23
  <script src="/theme-bootstrap.js"></script>
24
24
  </head>
25
25
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogpit",
3
- "version": "3.3.3",
3
+ "version": "3.3.6",
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,6 +0,0 @@
1
- import{r as N,c as z,j as a}from"./vendor-react-gGw_S5I_.js";import{U as Ie,bZ as We,b_ as me,aE as Je,J as D,b$ as ot,l as ct,c0 as ut,B as ae,L as dt,M as ft,N as mt,O as pt,Q as ht,C as Pe,b5 as Fe,z as qe,q as Xe,aJ as xt,b6 as gt,c1 as wt,bz as bt,c2 as yt,bw as jt,bV as vt,bW as Nt,bX as _e,bY as Ue,bh as kt,$ as Qe,Z as Ct,c3 as St,c4 as It,c5 as Rt,c6 as $t,bE as Et}from"./index-BVrmKCdP.js";import{S as Mt}from"./switch-85f85r6I.js";import{ar as At,as as Ot,j as Lt,at as Tt,a5 as zt,au as Dt,av as Pt,a7 as Ft,m as qt,aw as _t,ak as Ut,$ as Ht,C as He,ax as Bt,ay as Yt,az as Gt,X as Kt}from"./vendor-ui-Dfr2Rf5Q.js";import{r as Vt,M as Wt}from"./vendor-markdown-BE1gYnO9.js";import"./vendor-shiki-DOn6sF-i.js";async function be(s){if(s.ok)return s;const e=await s.json().catch(()=>null);throw new Error((e==null?void 0:e.error)||"Couldn't update crew chat.")}function ke(s,e){return[...new Map([...s,...e].map(t=>[t.sequence,t])).values()].sort((t,n)=>t.sequence-n.sequence)}function Jt(s){const[e,t]=N.useState(null),[n,r]=N.useState([]),[i,c]=N.useState(null),[l,d]=N.useState(!1),[o,u]=N.useState(!1),[m,g]=N.useState(!1),[b,p]=N.useState(new Set),h=N.useRef(0),f=N.useRef(null),x=N.useRef(!1),w=N.useRef(!1),j=N.useRef(new Set),C=N.useRef(!1),E=N.useRef(null),A=N.useCallback(async v=>{const S=++h.current;try{const y=E.current,M=await(await be(await Ie(`/api/crew-chat/${encodeURIComponent(s)}${y===null?"":`?after=${y}&limit=100`}`))).json();if(!v()||S!==h.current)return;t(I=>I&&JSON.stringify(I.members)===JSON.stringify(M.members)?{...M,members:I.members}:M),r(I=>ke(I,M.messages)),E.current=M.nextCursor,C.current||(C.current=!0,g(M.hasMore)),c(null)}catch(y){v()&&S===h.current&&c(y instanceof Error?y.message:"Couldn't load crew chat.")}},[s]);We(A,2e3);const L=N.useCallback(async v=>{var S;if(x.current)return!1;x.current=!0,d(!0),((S=f.current)==null?void 0:S.text)!==v&&(f.current={text:v,id:crypto.randomUUID()});try{const k=await(await be(await me(`/api/crew-chat/${encodeURIComponent(s)}`,{text:v,commandId:f.current.id}))).json();return h.current++,r(M=>ke(M,[k.message])),f.current=null,c(k.pending.length?"Message saved. Some members are unavailable; delivery will retry.":null),!0}catch(y){return c(y instanceof Error?y.message:"Couldn't send the message."),!1}finally{x.current=!1,d(!1)}},[s]),O=N.useCallback(async(v,S)=>{if(!j.current.has(v)){j.current.add(v),p(y=>new Set(y).add(v));try{await be(await me(`/api/crew-chat/${encodeURIComponent(s)}`,{sessionId:v,listening:S},{method:"PATCH"})),h.current++,t(y=>y&&{...y,members:y.members.map(k=>k.sessionId===v?{...k,listening:S}:k)}),c(null)}catch(y){c(y instanceof Error?y.message:"Couldn't change listening.")}finally{j.current.delete(v),p(y=>{const k=new Set(y);return k.delete(v),k})}}},[s]),T=N.useCallback(async()=>{if(!(!n.length||w.current)){w.current=!0,u(!0);try{const S=await(await be(await Ie(`/api/crew-chat/${encodeURIComponent(s)}?before=${n[0].sequence}`))).json();r(y=>ke(y,S.messages)),g(S.hasMore)}catch(v){c(v instanceof Error?v.message:"Couldn't load older messages.")}finally{w.current=!1,u(!1)}}},[n,s]);return{page:e,messages:n,error:i,posting:l,busyMembers:b,hasOlder:m,loadingOlder:o,post:L,setListening:O,older:T}}const Xt=8e3,Ze={PASS:"success",PASSED:"success",APPROVE:"success",APPROVED:"success",MERGED:"success",READY:"success",GREEN:"success",DONE:"success",FAIL:"destructive",FAILS:"destructive",FAILED:"destructive",ERROR:"destructive",RED:"destructive",CHANGES_REQUESTED:"destructive",BLOCKED:"warning",BLOCKER:"warning",URGENT:"warning",WAITING:"warning","DECISION NEEDED":"warning"},Qt=new RegExp([String.raw`(?<mention>(?<=^|[\s(])@[a-z0-9_-]+\b)`,String.raw`(?<status>\b(?:${Object.keys(Ze).sort((s,e)=>e.length-s.length).join("|")})\b)`,String.raw`(?<sha>\b(?:[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}|(?=[0-9a-f]*[a-f])(?=[0-9a-f]*\d)[0-9a-f]{7,40})\b)`,String.raw`(?<path>(?<=^|[\s(“"'=])(?:(?:~|\.{1,2})?\/[\w.@%+=-]+(?:\/[\w.@%+=-]*)*|[\w.-]+\/[\w.@/-]*\.[a-z][a-z0-9]{0,5}\b))`].join("|"),"gi"),Zt=new RegExp("(?<=^|[\\s:;,.])\\((\\d{1,2}|[a-z])\\)(?=\\s)","g"),et=/^\((\d{1,2}|[a-z])\)\s+/;function es(s){return new Map(s.flatMap(e=>[[e.handle.toLowerCase(),e.sessionId],[e.sessionId.toLowerCase(),e.sessionId]]))}function ts({handles:s}){return e=>{tt(e,s)}}function tt(s,e){if(!s.children||s.type==="link"||s.type==="linkReference")return;const t=n=>s.type==="listItem"?Be(ns(n)):ss(n).flatMap(Be);s.children=as(s.children.flatMap(n=>n.type==="paragraph"?t(n):[n])),s.children=s.children.flatMap(n=>n.type==="text"?ls(n.value??"",e):[n]);for(const n of s.children)tt(n,e)}function ss(s){var t;const e=[[]];for(const n of s.children??[]){if(n.type!=="text"||!((t=n.value)!=null&&t.includes(`
2
- `))){e.at(-1).push(n);continue}n.value.split(`
3
- `).forEach((r,i)=>{i>0&&e.push([]),r&&e.at(-1).push({type:"text",value:r})})}return e.filter(n=>n.some(r=>r.type!=="text"||r.value.trim())).map(n=>({type:"paragraph",children:Re(n)}))}function ns(s){return{...s,children:(s.children??[]).flatMap(e=>{var t;return e.type==="text"&&((t=e.value)!=null&&t.includes(`
4
- `))?e.value.split(`
5
- `).flatMap((n,r)=>[...r>0?[{type:"break"}]:[],...n?[{type:"text",value:n}]:[]]):[e]})}}function st(s,e){return e?s===e:s==="1"||s==="a"}function nt(s){return/\d/.test(s)?String(Number(s)+1):String.fromCharCode(s.charCodeAt(0)+1)}function Be(s){const e=s.children??[],t=[];let n=null;if(e.forEach((l,d)=>{if(l.type==="text")for(const o of l.value.matchAll(Zt)){const u=o[1];st(u,n)&&(t.push({child:d,start:o.index,end:o.index+o[0].length,label:u}),n=nt(u))}}),t.length<2)return[s];const r=[[]];e.forEach((l,d)=>{if(l.type!=="text"){r.at(-1).push(l);return}let o=0;for(const u of t.filter(m=>m.child===d))u.start>o&&r.at(-1).push({type:"text",value:l.value.slice(o,u.start)}),r.push([]),o=u.end;o<l.value.length&&r.at(-1).push({type:"text",value:l.value.slice(o)})});const[i,...c]=r.map(Re);return[...i.length?[{type:"paragraph",children:i}]:[],at(c,t[0].label)]}function as(s){const e=[];for(let t=0;t<s.length;){const n=[];let r=null;for(let i=t;i<s.length;i++){const c=Ye(s[i]);if(!c||!st(c,r))break;n.push(rs(s[i])),r=nt(c)}n.length>=2?(e.push(at(n,Ye(s[t]))),t+=n.length):e.push(s[t++])}return e}function Ye(s){var t,n;const e=s.type==="paragraph"?(t=s.children)==null?void 0:t[0]:void 0;return(e==null?void 0:e.type)==="text"?((n=e.value.match(et))==null?void 0:n[1])??null:null}function rs(s){const[e,...t]=s.children;return Re([{type:"text",value:e.value.replace(et,"")},...t])}function at(s,e){return{type:"list",ordered:!0,start:1,spread:!1,.../[a-z]/.test(e)&&{data:{hProperties:{type:"a"}}},children:s.map(t=>({type:"listItem",spread:!1,checked:null,children:[{type:"paragraph",children:t}]}))}}function Re(s){const e=s.map(r=>({...r})),t=e[0],n=e.at(-1);return(t==null?void 0:t.type)==="text"&&(t.value=t.value.trimStart()),(n==null?void 0:n.type)==="text"&&(n.value=n.value.trimEnd()),e.filter(r=>r.type!=="text"||r.value)}function ls(s,e){const t=[];let n=0;for(const r of s.matchAll(Qt)){const i=r.groups.path?r[0].replace(/[.,;:)]+$/,""):r[0],c=is(r.groups,i,e);c&&(r.index>n&&t.push({type:"text",value:s.slice(n,r.index)}),t.push(c),n=r.index+i.length)}return n<s.length&&t.push({type:"text",value:s.slice(n)}),t}function is(s,e,t){if(s.mention){const n=t.get(e.slice(1).toLowerCase());return Ce(e,"mention",n?{dataSessionId:n}:{})}return s.status?e===e.toUpperCase()?Ce(e,"status",{dataTone:Ze[e]}):null:s.sha?e===e.toLowerCase()?Ce(e,"sha"):null:e.length>1?{type:"inlineCode",value:e}:null}function Ce(s,e,t={}){return{type:"text",value:s,data:{hName:"span",hProperties:{dataCrewToken:e,...t}}}}function os(s,e,t){const n=s.match(/^(?:[ \t]*@[a-z0-9_-]+[,:]?)+(?:[ \t]+|[ \t]*\n)/i);if(!n||[...n[0].matchAll(/@([a-z0-9_-]+)/gi)].map(c=>t.get(c[1].toLowerCase())).some(c=>!c||!e.includes(c)))return s;const i=s.slice(n[0].length);return i.trim()?i:s}const ye=[255,330,185,290,210,350,232,310];function rt(s){const e=`oklch(0.64 0.14 ${s})`;return{color:`color-mix(in oklch, ${e} 78%, var(--foreground))`,backgroundColor:`color-mix(in oklch, ${e} 16%, transparent)`}}function cs(s,e){return new Map(s.filter(t=>t.sessionId!==e).map((t,n)=>[t.sessionId,rt(ye[n%ye.length])]))}function lt(s,e){const t=e.get(s);if(t)return t;let n=2166136261;for(let r=0;r<s.length;r++)n=Math.imul(n^s.charCodeAt(r),16777619);return rt(ye[(n>>>0)%ye.length])}const us=5*6e4;function ds(s,e){const t=[];let n=null;for(const r of s){const i=r.author.kind==="user"?`user:${r.author.name}`:`agent:${r.author.sessionId??r.author.name}`,c=[...r.mentions].sort().join(","),l=new Date(r.createdAt).setHours(0,0,0,0);n&&n.author===i&&n.recipients===c&&n.day===l&&r.createdAt-n.at<us?t.at(-1).messages.push(r):t.push({role:r.author.kind==="user"?"user":r.author.sessionId===e?"lead":"agent",recipients:r.mentions,...(n==null?void 0:n.day)!==l&&{day:l},messages:[r]}),n={author:i,recipients:c,day:l,at:r.createdAt}}return t}function fs(s){const e=s.match(/^https?:\/\/github\.com\/[^/\s]+\/([^/\s]+)\/(pull|issues|commit)\/([0-9a-f]+)(?:[/?#].*)?$/i);if(!e)return null;const[,t,n,r]=e;return n==="commit"?{kind:"commit",label:`${t}@${r.slice(0,7)}`}:/^\d+$/.test(r)?{kind:n==="pull"?"pull":"issue",label:`${t}#${r}`}:null}function Se(s){return s.replace(/^https?:\/\/(www\.)?/i,"").replace(/\/$/,"")}function it(s){const e=z.c(18),{role:t,sessionId:n,kinds:r,tints:i,className:c}=s;let l;if(e[0]!==r||e[1]!==t||e[2]!==n){const h=n?r.get(n):void 0;l=t==="user"?Pt:h?ut(h):Ft,e[0]=r,e[1]=t,e[2]=n,e[3]=l}else l=e[3];const d=l,o=t==="lead"?"bg-foreground/[0.08] text-foreground/80":"bg-muted text-muted-foreground";let u;e[4]!==c||e[5]!==o?(u=D("flex size-6 shrink-0 items-center justify-center rounded-full",o,c),e[4]=c,e[5]=o,e[6]=u):u=e[6];let m;e[7]!==t||e[8]!==n||e[9]!==i?(m=t==="agent"&&n?lt(n,i):void 0,e[7]=t,e[8]=n,e[9]=i,e[10]=m):m=e[10];const g=t==="user"?"size-3.5":"size-3";let b;e[11]!==d||e[12]!==g?(b=a.jsx(d,{className:g}),e[11]=d,e[12]=g,e[13]=b):b=e[13];let p;return e[14]!==u||e[15]!==m||e[16]!==b?(p=a.jsx("span",{"aria-hidden":"true",className:u,style:m,children:b}),e[14]=u,e[15]=m,e[16]=b,e[17]=p):p=e[17],p}function ms(s){const e=new Date().setHours(0,0,0,0);if(s===e)return"Today";const t=new Date(e);if(s===t.setDate(t.getDate()-1))return"Yesterday";const n=new Date(s);return n.toLocaleDateString([],{weekday:"short",month:"short",day:"numeric",...n.getFullYear()!==new Date().getFullYear()&&{year:"numeric"}})}function ps(s){const e=z.c(6),{day:t}=s;let n;e[0]!==t?(n=ms(t),e[0]=t,e[1]=n):n=e[1];const r=n;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx("span",{className:"h-px flex-1 bg-border"}),e[2]=i):i=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx("span",{className:"h-px flex-1 bg-border"}),e[3]=c):c=e[3];let l;return e[4]!==r?(l=a.jsxs("div",{role:"separator","aria-label":r,className:"flex items-center gap-3 text-[11px] text-muted-foreground",children:[i,r,c]}),e[4]=r,e[5]=l):l=e[5],l}function hs(s){const e=z.c(18),{run:t,members:n,handles:r,kinds:i,tints:c,rootId:l}=s,d=t.messages[0].author;let o,u;if(e[0]!==d||e[1]!==r||e[2]!==i||e[3]!==n||e[4]!==l||e[5]!==t.messages||e[6]!==t.recipients||e[7]!==t.role||e[8]!==c){let g;e[11]!==n?(g=h=>{var f;return((f=n.get(h))==null?void 0:f.name)??[]},e[11]=n,e[12]=g):g=e[12];const b=t.recipients.flatMap(g),p=t.role==="user"&&"-mx-2 rounded-lg bg-muted/50 px-2 py-2";e[13]!==p?(o=D("flex flex-col gap-2.5",p),e[13]=p,e[14]=o):o=e[14],u=t.messages.map((h,f)=>a.jsxs("article",{"aria-label":`Message from ${d.name}`,className:"group/message grid grid-cols-[1.5rem_minmax(0,1fr)] gap-x-2.5",children:[f===0?a.jsxs(a.Fragment,{children:[a.jsx(it,{role:t.role,sessionId:d.sessionId,kinds:i,tints:c,className:"row-span-2 mt-px"}),a.jsxs("header",{className:"flex min-w-0 items-baseline gap-1.5 leading-6",children:[a.jsx("span",{className:"truncate text-[13px] font-medium",children:d.name}),b.length>0&&a.jsxs("span",{className:"flex min-w-0 items-baseline gap-1 text-xs text-muted-foreground",title:`To ${b.join(", ")}`,children:[a.jsx(Dt,{"aria-hidden":"true",className:"size-3 shrink-0 translate-y-0.5"}),a.jsx("span",{className:"sr-only",children:"To"}),a.jsx("span",{className:"truncate",children:b.join(", ")})]}),a.jsx(Ge,{at:h.createdAt,className:"ml-auto pl-2 text-[11px]"})]})]}):a.jsx(Ge,{at:h.createdAt,short:!0,className:"pt-[3px] text-center text-[10px] opacity-0 group-hover/message:opacity-100 group-focus-within/message:opacity-100"}),a.jsx("div",{className:"col-start-2 min-w-0",children:a.jsx(ws,{message:h,handles:r,tints:c,rootId:l})})]},h.sequence)),e[0]=d,e[1]=r,e[2]=i,e[3]=n,e[4]=l,e[5]=t.messages,e[6]=t.recipients,e[7]=t.role,e[8]=c,e[9]=o,e[10]=u}else o=e[9],u=e[10];let m;return e[15]!==o||e[16]!==u?(m=a.jsx("div",{className:o,children:u}),e[15]=o,e[16]=u,e[17]=m):m=e[17],m}function Ge(s){const e=z.c(12),{at:t,short:n,className:r}=s;let i,c,l;if(e[0]!==t||e[1]!==n){const u=new Date(t);i=n?new Intl.DateTimeFormat([],{hour:"numeric",minute:"2-digit"}).formatToParts(u).filter(gs).map(xs).join(""):u.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),c=u.toISOString(),l=u.toLocaleString(),e[0]=t,e[1]=n,e[2]=i,e[3]=c,e[4]=l}else i=e[2],c=e[3],l=e[4];let d;e[5]!==r?(d=D("shrink-0 tabular-nums text-muted-foreground",r),e[5]=r,e[6]=d):d=e[6];let o;return e[7]!==i||e[8]!==c||e[9]!==l||e[10]!==d?(o=a.jsx("time",{dateTime:c,title:l,className:d,children:i}),e[7]=i,e[8]=c,e[9]=l,e[10]=d,e[11]=o):o=e[11],o}function xs(s){return s.value}function gs(s){return s.type==="hour"||s.type==="minute"||s.type==="literal"&&s.value.trim()}const ws=N.memo(function(e){const t=z.c(13),{message:n,handles:r,tints:i,rootId:c}=e;let l;t[0]!==r||t[1]!==n.mentions||t[2]!==n.text?(l=os(n.text,n.mentions,r),t[0]=r,t[1]=n.mentions,t[2]=n.text,t[3]=l):l=t[3];const d=l;let o;t[4]!==r?(o=[Vt,[ts,{handles:r}]],t[4]=r,t[5]=o):o=t[5];const u=o;let m;t[6]!==c||t[7]!==i?(m=vs(c,i),t[6]=c,t[7]=i,t[8]=m):m=t[8];const g=m;let b;return t[9]!==g||t[10]!==u||t[11]!==d?(b=a.jsx(bs,{children:a.jsx("div",{className:"text-[13px] leading-relaxed text-foreground/90 [overflow-wrap:anywhere]",children:a.jsx(Wt,{remarkPlugins:u,components:g,children:d})})}),t[9]=g,t[10]=u,t[11]=d,t[12]=b):b=t[12],b});function bs(s){const e=z.c(16),{children:t}=s,n=N.useRef(null),[r,i]=N.useState(!1),[c,l]=N.useState(!1);let d,o;e[0]!==c?(d=()=>{const x=n.current;if(!x||c)return;const w=()=>i(x.scrollHeight>x.clientHeight+1);if(w(),typeof ResizeObserver>"u")return;const j=new ResizeObserver(w);return j.observe(x),()=>j.disconnect()},o=[c],e[0]=c,e[1]=d,e[2]=o):(d=e[1],o=e[2]),N.useLayoutEffect(d,o);const u=c?Tt:zt,m=!c&&"max-h-72 overflow-hidden",g=!c&&r&&"[mask-image:linear-gradient(to_bottom,black_calc(100%-3rem),transparent)]";let b;e[3]!==m||e[4]!==g?(b=D(m,g),e[3]=m,e[4]=g,e[5]=b):b=e[5];let p;e[6]!==t||e[7]!==b?(p=a.jsx("div",{ref:n,className:b,children:t}),e[6]=t,e[7]=b,e[8]=p):p=e[8];let h;e[9]!==u||e[10]!==c||e[11]!==r?(h=r&&a.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>l(!c),className:"mt-1 inline-flex items-center gap-1 rounded-sm text-xs text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[a.jsx(u,{"aria-hidden":"true",className:"size-3"}),c?"Show less":"Show more"]}),e[9]=u,e[10]=c,e[11]=r,e[12]=h):h=e[12];let f;return e[13]!==p||e[14]!==h?(f=a.jsxs(a.Fragment,{children:[p,h]}),e[13]=p,e[14]=h,e[15]=f):f=e[15],f}const ys={success:"bg-success/10 text-success",warning:"bg-warning/12 text-warning",destructive:"bg-destructive/10 text-destructive"},js={pull:Lt,issue:Ot,commit:At},Ke=Je.a;function vs(s,e){return{...Je,p:({children:t})=>a.jsx("p",{className:"my-1.5 first:mt-0 last:mb-0",children:t}),ul:({children:t})=>a.jsx("ul",{className:"my-1.5 flex list-disc flex-col gap-1 pl-4 marker:text-muted-foreground/60 first:mt-0 last:mb-0",children:t}),ol:({children:t,type:n,start:r})=>a.jsx("ol",{start:r,className:D("my-1.5 flex flex-col gap-1 pl-5 marker:text-muted-foreground/70 first:mt-0 last:mb-0",n==="a"?"list-[lower-alpha]":"list-decimal"),children:t}),li:({children:t})=>a.jsx("li",{className:"pl-0.5",children:t}),h1:fe,h2:fe,h3:fe,h4:fe,h5:fe,h6:fe,blockquote:({children:t})=>a.jsx("blockquote",{className:"my-1.5 border-l-2 pl-2.5 text-muted-foreground",children:t}),hr:()=>a.jsx(ct,{className:"my-2.5"}),code:t=>{const{children:n,className:r}=t;return r||typeof n!="string"||n.includes(`
6
- `)?a.jsx(ot,{...t}):a.jsx("code",{className:"rounded-[4px] bg-muted px-1 py-px font-mono text-[0.88em] text-foreground/85",children:n})},a:({href:t,children:n})=>{const r=typeof n=="string"&&t!==void 0&&Se(t)===Se(n),i=r?fs(t):null;if(i){const c=js[i.kind];return a.jsxs(Ke,{href:t,className:"inline-flex items-baseline gap-1 rounded-[4px] bg-muted px-1 font-medium text-foreground/85 no-underline hover:bg-accent",children:[a.jsx(c,{"aria-hidden":"true",className:"size-3 shrink-0 translate-y-0.5 text-muted-foreground"}),i.label]})}return a.jsx(Ke,{href:t,className:"cursor-pointer text-foreground underline decoration-foreground/25 underline-offset-2 hover:decoration-foreground/60",children:r?Se(t):n})},span:({children:t,...n})=>{const r=n,i=r["data-crew-token"];return i==="mention"?a.jsx(Ns,{sessionId:r["data-session-id"],rootId:s,tints:e,children:t}):i==="status"?a.jsx("span",{className:D("rounded-[4px] px-1 py-px text-[0.85em] font-medium",ys[r["data-tone"]]),children:t}):i==="sha"?a.jsx("span",{className:"font-mono text-[0.88em] text-muted-foreground",children:t}):a.jsx("span",{children:t})}}}function fe(s){const e=z.c(2),{children:t}=s;let n;return e[0]!==t?(n=a.jsx("p",{className:"mb-1 mt-3 font-semibold text-foreground first:mt-0",children:t}),e[0]=t,e[1]=n):n=e[1],n}function Ns(s){const e=z.c(10),{sessionId:t,rootId:n,tints:r,children:i}=s;let c;e[0]!==n||e[1]!==t||e[2]!==r?(c=t&&t!==n?lt(t,r):void 0,e[0]=n,e[1]=t,e[2]=r,e[3]=c):c=e[3];const l=c,d=!l&&(t?"bg-foreground/[0.08] text-foreground":"bg-muted text-muted-foreground");let o;e[4]!==d?(o=D("rounded-[4px] px-0.5 font-medium",d),e[4]=d,e[5]=o):o=e[5];let u;return e[6]!==i||e[7]!==l||e[8]!==o?(u=a.jsx("span",{style:l,className:o,children:i}),e[6]=i,e[7]=l,e[8]=o,e[9]=u):u=e[9],u}const ks=[],Cs=new Map;function Ss(s){var Ee,Me,Ae,Oe,Le,Te,ze;const e=z.c(111),{rootId:t,kinds:n,active:r}=s,i=n===void 0?Cs:n,c=r===void 0?!0:r,l=Jt(t),[d,o]=N.useState(""),u=N.useRef(null),m=N.useRef(!0);let g;e[0]!==l.messages?(g=(Ee=l.messages.at(-1))==null?void 0:Ee.sequence,e[0]=l.messages,e[1]=g):g=e[1];const b=g,p=((Me=l.page)==null?void 0:Me.members)??ks;let h;e[2]!==p?(h=es(p),e[2]=p,e[3]=h):h=e[3];const f=h;let x;e[4]!==p||e[5]!==t?(x=cs(p,t),e[4]=p,e[5]=t,e[6]=x):x=e[6];const w=x;let j;e[7]!==p?(j=new Map(p.map(Rs)),e[7]=p,e[8]=j):j=e[8];const C=j;let E;e[9]!==l.messages||e[10]!==t?(E=ds(l.messages,t),e[9]=l.messages,e[10]=t,e[11]=E):E=e[11];const A=E;let L;e[12]!==c?(L=()=>{var $,R;c&&m.current&&((R=($=u.current)==null?void 0:$.scrollIntoView)==null||R.call($,{block:"end"}))},e[12]=c,e[13]=L):L=e[13];let O;e[14]!==c||e[15]!==b?(O=[c,b],e[14]=c,e[15]=b,e[16]=O):O=e[16],N.useEffect(L,O);let T;e[17]!==l||e[18]!==d?(T=async()=>{const $=d.trim();!$||l.posting||await l.post($)&&(o(R=>R.trim()===$?"":R),m.current=!0)},e[17]=l,e[18]=d,e[19]=T):T=e[19];const v=T;let S;e[20]!==l.page||e[21]!==p?(S=l.page?`${p.filter(Is).length} listening · Members & mentions`:"Loading chat…",e[20]=l.page,e[21]=p,e[22]=S):S=e[22];let y;e[23]!==S?(y=a.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:S}),e[23]=S,e[24]=y):y=e[24];let k;if(e[25]!==l||e[26]!==i||e[27]!==p||e[28]!==t||e[29]!==w){let $;e[31]!==l||e[32]!==i||e[33]!==t||e[34]!==w?($=R=>{var De;return a.jsxs(Pe,{orientation:"horizontal",className:"items-center gap-2",children:[a.jsx(it,{role:R.sessionId===t?"lead":"agent",sessionId:R.sessionId,kinds:i,tints:w,className:"size-5"}),a.jsxs(Fe,{className:"min-w-0 flex-1 items-baseline gap-1.5",htmlFor:`listen-${R.sessionId}`,"aria-label":`Listen for ${R.name}`,children:[a.jsx("span",{className:"truncate",children:R.name}),a.jsxs("span",{className:"truncate text-xs font-normal text-muted-foreground",children:["@",R.handle]})]}),a.jsx(ae,{variant:"ghost",size:"icon-xs",disabled:!((De=l.page)!=null&&De.canPost)||!R.canInteract,onClick:()=>o(pe=>`${pe}${pe&&!/\s$/.test(pe)?" ":""}@${R.handle} `),"aria-label":`Mention ${R.name}`,title:`Mention @${R.handle}`,className:"text-muted-foreground",children:a.jsx(_t,{"data-icon":"inline-start"})}),a.jsx(Mt,{id:`listen-${R.sessionId}`,size:"sm",checked:R.listening,disabled:!R.canInteract||l.busyMembers.has(R.sessionId),onCheckedChange:pe=>void l.setListening(R.sessionId,pe)})]},R.sessionId)},e[31]=l,e[32]=i,e[33]=t,e[34]=w,e[35]=$):$=e[35],k=p.map($),e[25]=l,e[26]=i,e[27]=p,e[28]=t,e[29]=w,e[30]=k}else k=e[30];let M;e[36]!==k?(M=a.jsx(qe,{className:"max-h-48 gap-2 overflow-y-auto py-2",children:k}),e[36]=k,e[37]=M):M=e[37];let I;e[38]===Symbol.for("react.memo_cache_sentinel")?(I=a.jsx("p",{className:"pb-1 text-xs text-muted-foreground",children:"Listening sends short notices while an agent works. @mentions send the full message, even when listening is off."}),e[38]=I):I=e[38];let P;e[39]!==y||e[40]!==M?(P=a.jsxs("details",{className:"shrink-0 border-b px-3 py-2",children:[y,M,I]}),e[39]=y,e[40]=M,e[41]=P):P=e[41];let Y;e[42]===Symbol.for("react.memo_cache_sentinel")?(Y=$=>{const R=$.target;m.current=R.scrollHeight-R.scrollTop-R.clientHeight<80},e[42]=Y):Y=e[42];let F;e[43]!==l?(F=l.hasOlder&&a.jsx("div",{className:"flex justify-center py-2",children:a.jsx(ae,{variant:"ghost",size:"xs",disabled:l.loadingOlder,onClick:()=>void l.older(),children:l.loadingOlder?"Loading…":"Load earlier messages"})}),e[43]=l,e[44]=F):F=e[44];let q;e[45]!==l.messages.length||e[46]!==l.page?(q=l.page&&l.messages.length===0&&a.jsx(dt,{children:a.jsxs(ft,{children:[a.jsx(mt,{variant:"icon",children:a.jsx(qt,{})}),a.jsx(pt,{children:"Talk to the crew"}),a.jsx(ht,{children:"Share a discovery, ask a question, or tag someone for their input."})]})}),e[45]=l.messages.length,e[46]=l.page,e[47]=q):q=e[47];let _;if(e[48]!==C||e[49]!==f||e[50]!==i||e[51]!==t||e[52]!==A||e[53]!==w){let $;e[55]!==C||e[56]!==f||e[57]!==i||e[58]!==t||e[59]!==w?($=R=>a.jsxs(N.Fragment,{children:[R.day!==void 0&&a.jsx(ps,{day:R.day}),a.jsx(hs,{run:R,members:C,handles:f,kinds:i,tints:w,rootId:t})]},R.messages[0].sequence),e[55]=C,e[56]=f,e[57]=i,e[58]=t,e[59]=w,e[60]=$):$=e[60],_=A.map($),e[48]=C,e[49]=f,e[50]=i,e[51]=t,e[52]=A,e[53]=w,e[54]=_}else _=e[54];let G;e[61]===Symbol.for("react.memo_cache_sentinel")?(G=a.jsx("div",{ref:u}),e[61]=G):G=e[61];let W;e[62]!==_?(W=a.jsxs("div",{role:"log","aria-label":"Shared messages","aria-live":"polite","aria-relevant":"additions",className:"flex flex-col gap-4 px-3 py-3",children:[_,G]}),e[62]=_,e[63]=W):W=e[63];let J;e[64]!==F||e[65]!==q||e[66]!==W?(J=a.jsxs(Xe,{className:"min-h-0 flex-1",onScrollCapture:Y,children:[F,q,W]}),e[64]=F,e[65]=q,e[66]=W,e[67]=J):J=e[67];let U;e[68]!==v?(U=$=>{$.preventDefault(),v()},e[68]=v,e[69]=U):U=e[69];const X=!!l.error,Q=`crew-chat-${t}`;let H;e[70]!==Q?(H=a.jsx(Fe,{htmlFor:Q,className:"sr-only",children:"Message the crew"}),e[70]=Q,e[71]=H):H=e[71];const Z=`crew-chat-${t}`,ee=!((Ae=l.page)!=null&&Ae.canPost),te=!!l.error;let K;e[72]===Symbol.for("react.memo_cache_sentinel")?(K=$=>o($.target.value),e[72]=K):K=e[72];let B;e[73]!==v?(B=$=>{$.key==="Enter"&&($.metaKey||$.ctrlKey)&&!$.nativeEvent.isComposing&&($.preventDefault(),v())},e[73]=v,e[74]=B):B=e[74];let V;e[75]!==d||e[76]!==Z||e[77]!==ee||e[78]!==te||e[79]!==B?(V=a.jsx(xt,{id:Z,value:d,rows:3,maxLength:Xt,placeholder:"Message the crew… use @ to tag an agent",disabled:ee,"aria-invalid":te,onChange:K,onKeyDown:B}),e[75]=d,e[76]=Z,e[77]=ee,e[78]=te,e[79]=B,e[80]=V):V=e[80];let se;e[81]!==l.error?(se=l.error&&a.jsx("p",{role:"alert",className:"text-xs text-destructive",children:l.error}),e[81]=l.error,e[82]=se):se=e[82];let ne;e[83]!==X||e[84]!==H||e[85]!==V||e[86]!==se?(ne=a.jsxs(Pe,{"data-invalid":X,children:[H,V,se]}),e[83]=X,e[84]=H,e[85]=V,e[86]=se,e[87]=ne):ne=e[87];const ve=((Oe=l.page)==null?void 0:Oe.canPost)===!1?"You have read access to this crew.":"⌘ / Ctrl + Enter to send";let le;e[88]!==ve?(le=a.jsx(gt,{className:"flex-1",children:ve}),e[88]=ve,e[89]=le):le=e[89];let ie;e[90]!==((Le=l.page)==null?void 0:Le.canPost)||e[91]!==l.posting||e[92]!==d?(ie=!((Te=l.page)!=null&&Te.canPost)||!d.trim()||l.posting,e[90]=(ze=l.page)==null?void 0:ze.canPost,e[91]=l.posting,e[92]=d,e[93]=ie):ie=e[93];let ge;e[94]===Symbol.for("react.memo_cache_sentinel")?(ge=a.jsx(Ut,{"data-icon":"inline-start"}),e[94]=ge):ge=e[94];const Ne=l.posting?"Sending…":"Send";let oe;e[95]!==ie||e[96]!==Ne?(oe=a.jsxs(ae,{type:"submit",size:"sm",disabled:ie,children:[ge,Ne]}),e[95]=ie,e[96]=Ne,e[97]=oe):oe=e[97];let ce;e[98]!==le||e[99]!==oe?(ce=a.jsxs("div",{className:"flex items-center gap-2",children:[le,oe]}),e[98]=le,e[99]=oe,e[100]=ce):ce=e[100];let ue;e[101]!==ne||e[102]!==ce?(ue=a.jsxs(qe,{className:"gap-2",children:[ne,ce]}),e[101]=ne,e[102]=ce,e[103]=ue):ue=e[103];let de;e[104]!==U||e[105]!==ue?(de=a.jsx("form",{className:"shrink-0 border-t p-3",onSubmit:U,children:ue}),e[104]=U,e[105]=ue,e[106]=de):de=e[106];let we;return e[107]!==P||e[108]!==J||e[109]!==de?(we=a.jsxs("section",{"aria-label":"Crew chat",className:"flex h-full min-h-0 flex-col",children:[P,J,de]}),e[107]=P,e[108]=J,e[109]=de,e[110]=we):we=e[110],we}function Is(s){return s.listening}function Rs(s){return[s.sessionId,s]}const $s=4e3;function Es(s){var h;const[e,t]=N.useState(null),[n,r]=N.useState(null),[i,c]=N.useState(new Set),l=(h=wt())==null?void 0:h.refresh,d=N.useRef(s),o=N.useRef(new Set);N.useLayoutEffect(()=>(d.current=s,()=>{d.current=null}),[s]);const u=N.useCallback(async f=>{if(s)try{const x=await Ie(`/api/session-crew/${encodeURIComponent(s)}`);if(!f())return;if(!x.ok){r(x.status===404?"This session is no longer available.":"Couldn't load the crew.");return}const w=await x.json();if(!f())return;t(j=>JSON.stringify(j)===JSON.stringify(w)?j:w),r(null)}catch{f()&&r("Couldn't load the crew.")}},[s]);We(s?u:null,$s),N.useEffect(()=>{t(f=>f!=null&&f.members.some(x=>x.sessionId===s)?f:null),r(null),c(new Set)},[s]);const m=N.useCallback(async(f,x,w)=>{const j=`${s}:${f}`;if(o.current.has(j))return;const C=()=>d.current===s;o.current.add(j),c(E=>new Set(E).add(f));try{const E=await x();if(!C())return;if(!E.ok&&E.status!==404){r(w);return}l==null||l(),await u(C)}catch{C()&&r(w)}finally{o.current.delete(j),C()&&c(E=>{const A=new Set(E);return A.delete(f),A})}},[u,l,s]),g=N.useCallback((f,x,w)=>m(x,()=>me("/api/session-respond",{sessionId:f,requestId:x,...w}),"Couldn't send the answer."),[m]),b=N.useCallback((f,x)=>m(x,()=>me("/api/delegated-tasks",{sessionId:f,taskId:x,action:"ack"}),"Couldn't mark the result read."),[m]),p=N.useCallback(f=>m(f.sessionId,()=>{var x;return((x=f.result)==null?void 0:x.state)==="running"&&f.parentId?me("/api/delegated-tasks",{sessionId:f.parentId,taskId:f.result.taskId,action:"cancel"}):me("/api/stop-session",{sessionId:f.sessionId})},"Couldn't stop the session."),[m]);return{crew:e,error:n,busy:i,respond:g,markRead:b,stop:p}}function xe(s){switch(s.outcome){case"needs_input":return"needs-you";case"running":return"working";case"error":return"failed";case"unreachable":case"not_found":return"unreachable";default:return"done"}}function Ve(s,e){var t,n;return{sessionId:s.sessionId,dirName:((t=s.address)==null?void 0:t.dirName)??"",fileName:((n=s.address)==null?void 0:n.fileName)??"",projectShortName:"",lastModified:s.lastActivityAt??"",lastActivityAt:s.lastActivityAt,size:0,cwd:s.cwd,customTitle:s.customTitle,aiTitle:s.aiTitle,firstUserMessage:s.firstUserMessage,...s.parentId&&{crew:{rootId:e,parentId:s.parentId,startedAt:s.startedAt??0,...s.name&&{name:s.name}}}}}function Ms(s,e,t){var l;const n=((l=[...e.values()].find(d=>d.parentId===null))==null?void 0:l.sessionId)??s.sessionId,r=t[s.sessionId],i=Ve(s,n);if(!s.parentId)return bt(i,r);const c=e.get(s.parentId);return yt(i,{customName:r,parent:c&&Ve(c,n)})}function As(s){const e=new Map;for(const i of s.members){if(!i.parentId)continue;const c=e.get(i.parentId);c?c.push(i):e.set(i.parentId,[i])}const t=[],n=new Set,r=(i,c)=>{var d;const l=[...e.get(i)??[]].sort((o,u)=>(o.startedAt??0)-(u.startedAt??0));for(const o of l)n.has(o.sessionId)||(n.add(o.sessionId),t.push({member:o,depth:c,children:((d=e.get(o.sessionId))==null?void 0:d.length)??0}),r(o.sessionId,c+1))};r(s.rootId,0);for(const i of s.members)i.parentId&&!n.has(i.sessionId)&&(n.add(i.sessionId),t.push({member:i,depth:0,children:0}));return t}function Os(s){const e=({member:t,pending:n})=>n.askedAt??(Date.parse(t.lastActivityAt??"")||0);return s.members.flatMap(t=>t.waiting.map(n=>({member:t,pending:n}))).sort((t,n)=>e(t)-e(n))}function Ls(s){const e={size:0,working:0,needsYou:0,done:0,failed:0,unreachable:0,unreadResults:0};for(const t of s.members){if(!t.parentId)continue;e.size++;const n=xe(t);n==="working"?e.working++:n==="needs-you"?e.needsYou++:n==="failed"?e.failed++:n==="unreachable"?e.unreachable++:e.done++,$e(t)&&e.unreadResults++}return e}function $e(s){return!!(s.result&&s.result.state!=="running"&&!s.result.acknowledged)}function je(s){const[e]=s.waiting;switch(xe(s)){case"needs-you":return(e==null?void 0:e.kind)==="permission"?`Waiting on a permission · ${e.toolName}`:(e==null?void 0:e.kind)==="question"?"Asked a question":"Plan to review";case"working":return s.status==="tool_use"&&s.toolName?s.toolName:s.status==="thinking"?"Thinking":s.status==="compacting"?"Compacting":s.status==="awaiting_agents"?"Waiting on its agents":"Working";case"failed":return s.error?`Failed · ${s.error}`:"Failed";case"unreachable":return s.device?`${s.device.name} is not answering`:"Not found";default:return $e(s)?"Finished · result unread":"Finished"}}const Ts=[{id:"all",label:"All"},{id:"working",label:"Working"},{id:"needs-you",label:"Need you"},{id:"done",label:"Done"}],zs={working:"bg-success shadow-[0_0_0_2px_color-mix(in_oklch,var(--success)_25%,transparent)]","needs-you":"bg-warning",done:"bg-muted-foreground/40",failed:"bg-destructive",unreachable:"border border-muted-foreground/50"},re={working:"bg-success ring-2 ring-success/30","needs-you":"bg-warning",done:"bg-muted-foreground/50",failed:"bg-destructive",unreachable:"border border-muted-foreground/60"};function Xs(s){var M;const e=z.c(33),{context:t,closePanel:n}=s,r=((M=t.session)==null?void 0:M.sessionId)??null,{crew:i,error:c,busy:l,respond:d,markRead:o,stop:u}=Es(r),{names:m}=jt(),[g,b]=N.useState("overview");let p;e[0]!==(i==null?void 0:i.members)?(p=new Map(((i==null?void 0:i.members)??[]).map(Ps)),e[0]=i==null?void 0:i.members,e[1]=p):p=e[1];const h=p;let f;e[2]!==(i==null?void 0:i.members)?(f=new Map(((i==null?void 0:i.members)??[]).flatMap(Ds)),e[2]=i==null?void 0:i.members,e[3]=f):f=e[3];const x=f;let w;e[4]!==h||e[5]!==m?(w=I=>Ms(I,h,m),e[4]=h,e[5]=m,e[6]=w):w=e[6];const j=w;let C;e[7]!==t?(C=I=>{I.address&&I.device?Rt($t(I.address.dirName,I.address.fileName,I.device.id)):I.address&&t.openSession?t.openSession(I.address.dirName,I.address.fileName):Et(I.sessionId)},e[7]=t,e[8]=C):C=e[8];const E=C;let A,L,O;e[9]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx(Gt,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),L=a.jsx("h2",{className:"text-sm font-medium",children:"Crew"}),O=a.jsx("div",{className:"flex-1"}),e[9]=A,e[10]=L,e[11]=O):(A=e[9],L=e[10],O=e[11]);let T;e[12]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(Kt,{"data-icon":"inline-start"}),e[12]=T):T=e[12];let v;e[13]!==n?(v=a.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[A,L,O,a.jsx(ae,{variant:"ghost",size:"icon-sm",onClick:n,"aria-label":"Close crew",children:T})]}),e[13]=n,e[14]=v):v=e[14];let S;e[15]!==c?(S=c&&a.jsx("p",{role:"alert",className:"px-3 pb-2 text-xs text-destructive",children:c}),e[15]=c,e[16]=S):S=e[16];let y;e[17]!==l||e[18]!==i||e[19]!==c||e[20]!==x||e[21]!==o||e[22]!==j||e[23]!==E||e[24]!==d||e[25]!==r||e[26]!==u||e[27]!==g?(y=i?a.jsxs(vt,{value:g,onValueChange:b,className:"min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]",children:[a.jsxs(Nt,{variant:"line",className:"mx-3 mb-1",children:[a.jsx(_e,{value:"overview",children:"Overview"}),a.jsx(_e,{value:"chat",children:"Chat"})]}),a.jsx(Ue,{value:"overview",className:"min-h-0",children:a.jsxs(Xe,{className:"h-full min-h-0",children:[a.jsx(Fs,{crew:i,hereId:r,nameOf:j,onOpen:E}),a.jsx(Us,{crew:i,busy:l,nameOf:j,onOpen:E,onRespond:d}),a.jsx(Hs,{crew:i,hereId:r,busy:l,nameOf:j,onOpen:E,onMarkRead:o,onStop:u})]})}),a.jsx(Ue,{value:"chat",keepMounted:!0,className:"min-h-0",children:a.jsx(Ss,{rootId:i.rootId,kinds:x,active:g==="chat"},i.rootId)})]}):!c&&a.jsx("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"Loading the crew…"}),e[17]=l,e[18]=i,e[19]=c,e[20]=x,e[21]=o,e[22]=j,e[23]=E,e[24]=d,e[25]=r,e[26]=u,e[27]=g,e[28]=y):y=e[28];let k;return e[29]!==S||e[30]!==y||e[31]!==v?(k=a.jsxs("aside",{"aria-label":"Crew",className:"flex size-full min-h-0 flex-col bg-canvas",children:[v,S,y]}),e[29]=S,e[30]=y,e[31]=v,e[32]=k):k=e[32],k}function Ds(s){return s.address?[[s.sessionId,kt(s.address.dirName)]]:[]}function Ps(s){return[s.sessionId,s]}function Fs(s){var j;const e=z.c(45),{crew:t,hereId:n,nameOf:r,onOpen:i}=s;let c,l,d,o,u;if(e[0]!==t||e[1]!==n||e[2]!==r||e[3]!==i){let C;e[9]!==t.rootId?(C=k=>k.sessionId===t.rootId,e[9]=t.rootId,e[10]=C):C=e[10];const E=t.members.find(C),A=t.members.filter(qs);let L;e[11]!==t?(L=Ls(t),e[11]=t,e[12]=L):L=e[12],u=L;const O=(j=A[0])==null?void 0:j.startedAt;c="Crew summary",l="border-b px-3 pb-3 pt-1";const T=E&&a.jsx("button",{type:"button",onClick:()=>i(E),"aria-current":E.sessionId===n?"true":void 0,className:"min-w-0 flex-1 truncate rounded-sm text-left text-sm font-medium outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:r(E)}),v=u.size===1?"session":"sessions",S=O?` · since ${_s(O)}`:"";let y;e[13]!==v||e[14]!==S||e[15]!==u.size?(y=a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[u.size," ",v,S]}),e[13]=v,e[14]=S,e[15]=u.size,e[16]=y):y=e[16],e[17]!==y||e[18]!==T?(d=a.jsxs("div",{className:"flex items-baseline gap-2",children:[T,y]}),e[17]=y,e[18]=T,e[19]=d):d=e[19],o=A.length>0&&a.jsx("div",{"data-crew-strip":!0,className:"mt-2.5 flex gap-[3px]",role:"list","aria-label":"One cell per session, in the order they were started",children:A.map(k=>{const M=xe(k);return a.jsx("button",{type:"button",role:"listitem","data-crew-cell":M,title:`${r(k)}: ${je(k)}`,"aria-label":`${r(k)}: ${je(k)}`,onClick:()=>{var I;return(I=document.querySelector(`[data-crew-row="${k.sessionId}"]`))==null?void 0:I.scrollIntoView({block:"nearest",behavior:"smooth"})},className:D("h-2.5 min-w-[3px] flex-1 rounded-[2px] outline-none focus-visible:ring-2 focus-visible:ring-ring",zs[M],k.sessionId===n&&"outline outline-[1.5px] outline-offset-2 outline-foreground")},k.sessionId)})}),e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=c,e[5]=l,e[6]=d,e[7]=o,e[8]=u}else c=e[4],l=e[5],d=e[6],o=e[7],u=e[8];let m;e[20]!==u.working?(m=u.working>0&&a.jsx(he,{dot:re.working,value:u.working,label:"working"}),e[20]=u.working,e[21]=m):m=e[21];let g;e[22]!==u.needsYou?(g=u.needsYou>0&&a.jsx(he,{dot:re["needs-you"],value:u.needsYou,label:u.needsYou===1?"needs you":"need you"}),e[22]=u.needsYou,e[23]=g):g=e[23];let b;e[24]!==u.done?(b=u.done>0&&a.jsx(he,{dot:re.done,value:u.done,label:"done"}),e[24]=u.done,e[25]=b):b=e[25];let p;e[26]!==u.failed?(p=u.failed>0&&a.jsx(he,{dot:re.failed,value:u.failed,label:"failed"}),e[26]=u.failed,e[27]=p):p=e[27];let h;e[28]!==u.unreachable?(h=u.unreachable>0&&a.jsx(he,{dot:re.unreachable,value:u.unreachable,label:"away"}),e[28]=u.unreachable,e[29]=h):h=e[29];let f;e[30]!==u.unreadResults?(f=u.unreadResults>0&&a.jsxs("span",{className:"ml-auto text-warning",children:[a.jsx("span",{className:"font-medium tabular-nums",children:u.unreadResults})," ",u.unreadResults===1?"result":"results"," unread"]}),e[30]=u.unreadResults,e[31]=f):f=e[31];let x;e[32]!==f||e[33]!==m||e[34]!==g||e[35]!==b||e[36]!==p||e[37]!==h?(x=a.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3.5 gap-y-1 text-xs text-muted-foreground",children:[m,g,b,p,h,f]}),e[32]=f,e[33]=m,e[34]=g,e[35]=b,e[36]=p,e[37]=h,e[38]=x):x=e[38];let w;return e[39]!==c||e[40]!==x||e[41]!==l||e[42]!==d||e[43]!==o?(w=a.jsxs("section",{"aria-label":c,className:l,children:[d,o,x]}),e[39]=c,e[40]=x,e[41]=l,e[42]=d,e[43]=o,e[44]=w):w=e[44],w}function qs(s){return s.parentId!==null}function _s(s){const e=new Date(s),t=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.toDateString()===new Date().toDateString()?t:`${e.toLocaleDateString([],{month:"short",day:"numeric"})}, ${t}`}function he(s){const e=z.c(10),{dot:t,value:n,label:r}=s;let i;e[0]!==t?(i=D("size-1.5 rounded-full",t),e[0]=t,e[1]=i):i=e[1];let c;e[2]!==i?(c=a.jsx("span",{className:i,"aria-hidden":"true"}),e[2]=i,e[3]=c):c=e[3];let l;e[4]!==n?(l=a.jsx("span",{className:"font-medium tabular-nums text-foreground",children:n}),e[4]=n,e[5]=l):l=e[5];let d;return e[6]!==r||e[7]!==c||e[8]!==l?(d=a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[c,l," ",r]}),e[6]=r,e[7]=c,e[8]=l,e[9]=d):d=e[9],d}function Us(s){const e=z.c(6),{crew:t,busy:n,nameOf:r,onOpen:i,onRespond:c}=s,l=Os(t),[d,o]=N.useState(0);if(l.length===0)return null;const u=Math.min(d,l.length-1),{member:m,pending:g}=l[u],b=l[u+1];let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Needs you"}),e[0]=p):p=e[0];let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx("span",{className:"flex-1"}),e[1]=h):h=e[1];let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx("span",{className:D("size-1.5 shrink-0 rounded-full",re["needs-you"]),"aria-hidden":"true"}),e[2]=f):f=e[2];const x=g.askedAt?`waiting ${Qe(new Date(g.askedAt).toISOString())}`:"waiting";let w;e[3]!==x?(w=a.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-warning",children:x}),e[3]=x,e[4]=w):w=e[4];let j;return e[5]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(He,{"data-icon":"inline-end"}),e[5]=j):j=e[5],a.jsxs("section",{"aria-label":"Needs you",className:"border-b px-3 py-2.5",children:[a.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",children:[p,a.jsx("span",{className:"tabular-nums",children:l.length}),h,l.length>1&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"tabular-nums",children:[u+1," of ",l.length]}),a.jsx(ae,{variant:"ghost",size:"icon-xs","aria-label":"Previous request",disabled:u===0,onClick:()=>o(u-1),children:a.jsx(Ht,{"data-icon":"inline-start"})}),a.jsx(ae,{variant:"ghost",size:"icon-xs","aria-label":"Next request",disabled:u===l.length-1,onClick:()=>o(u+1),children:a.jsx(He,{"data-icon":"inline-start"})})]})]}),a.jsxs("div",{className:"flex flex-col gap-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2 px-0.5 text-xs",children:[f,a.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:r(m)}),m.device&&a.jsx(Ct,{variant:"outline",children:m.device.name}),w]}),a.jsx(St,{sessionId:m.sessionId,pending:g,queued:0,responding:n.has(g.requestId),onRespond:(C,E)=>void c(m.sessionId,C,E),onOpen:()=>i(m)},g.requestId),a.jsxs(ae,{variant:"ghost",size:"xs",className:"self-end text-muted-foreground",onClick:()=>i(m),children:["Open session",j]})]}),b&&a.jsxs("p",{className:"mt-2 truncate text-xs text-muted-foreground",children:["Next: ",a.jsx("span",{className:"font-medium text-foreground",children:r(b.member)})," ",je(b.member).toLowerCase()]})]})}function Hs(s){const e=z.c(17),{crew:t,hereId:n,busy:r,nameOf:i,onOpen:c,onMarkRead:l,onStop:d}=s,[o,u]=N.useState("all");let m;if(e[0]!==r||e[1]!==t||e[2]!==o||e[3]!==n||e[4]!==i||e[5]!==l||e[6]!==c||e[7]!==d){let g;e[9]!==o?(g=w=>{const{member:j}=w;if(o==="all")return!0;const C=xe(j);return o==="done"?C!=="working"&&C!=="needs-you":C===o},e[9]=o,e[10]=g):g=e[10];const b=As(t).filter(g);let p,h;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx("h3",{className:"text-sm font-medium",children:"Sessions"}),h=a.jsx("span",{className:"flex-1"}),e[11]=p,e[12]=h):(p=e[11],h=e[12]);let f;e[13]!==o?(f=Ts.map(w=>{const{id:j,label:C}=w;return a.jsx("button",{type:"button",role:"radio","aria-checked":o===j,onClick:()=>u(j),className:D("rounded-full px-2 py-0.5 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",o===j&&"bg-accent text-foreground"),children:C},j)}),e[13]=o,e[14]=f):f=e[14];let x;e[15]!==f?(x=a.jsxs("div",{className:"mb-1.5 flex items-center gap-2 px-1.5",children:[p,h,a.jsx("div",{role:"radiogroup","aria-label":"Show sessions",className:"flex gap-0.5",children:f})]}),e[15]=f,e[16]=x):x=e[16],m=a.jsxs("section",{"aria-label":"Sessions",className:"px-1.5 py-2.5",children:[x,b.length===0?a.jsx("p",{className:"px-1.5 py-4 text-center text-xs text-muted-foreground",children:"No sessions here."}):a.jsx("ul",{className:"flex flex-col",children:b.map(w=>a.jsx(Bs,{row:w,here:w.member.sessionId===n,busy:r,name:i(w.member),onOpen:c,onMarkRead:l,onStop:d},w.member.sessionId))})]}),e[0]=r,e[1]=t,e[2]=o,e[3]=n,e[4]=i,e[5]=l,e[6]=c,e[7]=d,e[8]=m}else m=e[8];return m}function Bs(s){var se,ne;const e=z.c(73),{row:t,here:n,busy:r,name:i,onOpen:c,onMarkRead:l,onStop:d}=s,{member:o,depth:u,children:m}=t;let g;e[0]!==o?(g=xe(o),e[0]=o,e[1]=g):g=e[1];const b=g;let p;e[2]!==o?(p=je(o),e[2]=o,e[3]=p):p=e[3];const h=p;let f;e[4]!==o.pullRequests?(f=(se=o.pullRequests)==null?void 0:se.at(-1),e[4]=o.pullRequests,e[5]=f):f=e[5];const x=f;let w;e[6]!==o?(w=$e(o)&&o.result&&o.parentId,e[6]=o,e[7]=w):w=e[7];const j=w,C=(b==="working"||b==="needs-you")&&(!o.device||((ne=o.result)==null?void 0:ne.state)==="running"&&o.parentId!==null),E=o.sessionId,A=n?"bg-accent":"hover:bg-accent/60",L=u>0&&"border-l border-border/70";let O;e[8]!==A||e[9]!==L?(O=D("group/crew relative rounded-md",A,L),e[8]=A,e[9]=L,e[10]=O):O=e[10];const T=u>0?6+(u-1)*14:0;let v;e[11]!==T?(v={marginLeft:T},e[11]=T,e[12]=v):v=e[12];let S;e[13]!==o||e[14]!==c?(S=()=>c(o),e[13]=o,e[14]=c,e[15]=S):S=e[15];const y=n?"true":void 0,k=`${i}, ${h}`,M=re[b];let I;e[16]!==M?(I=D("size-1.5 justify-self-center rounded-full",M),e[16]=M,e[17]=I):I=e[17];let P;e[18]!==I?(P=a.jsx("span",{className:I,"aria-hidden":"true"}),e[18]=I,e[19]=P):P=e[19];let Y;e[20]!==i?(Y=a.jsx("span",{className:"truncate",children:i}),e[20]=i,e[21]=Y):Y=e[21];let F;e[22]!==n?(F=n&&a.jsx("span",{className:"shrink-0 rounded-full border px-1.5 text-[10.5px] font-normal text-muted-foreground",children:"you are here"}),e[22]=n,e[23]=F):F=e[23];let q;e[24]!==Y||e[25]!==F?(q=a.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[12.5px] font-medium",children:[Y,F]}),e[24]=Y,e[25]=F,e[26]=q):q=e[26];let _;e[27]!==o.lastActivityAt?(_=o.lastActivityAt?Qe(o.lastActivityAt):"",e[27]=o.lastActivityAt,e[28]=_):_=e[28];let G;e[29]!==_?(G=a.jsx("span",{className:"text-[11px] tabular-nums text-muted-foreground/80",children:_}),e[29]=_,e[30]=G):G=e[30];const W=(b==="needs-you"||j)&&"text-warning",J=b==="failed"&&"text-destructive";let U;e[31]!==W||e[32]!==J?(U=D("min-w-0 flex-1 truncate",W,J),e[31]=W,e[32]=J,e[33]=U):U=e[33];let X;e[34]!==h||e[35]!==U?(X=a.jsx("span",{className:U,children:h}),e[34]=h,e[35]=U,e[36]=X):X=e[36];let Q;e[37]!==x?(Q=x&&a.jsxs("span",{className:"shrink-0 rounded-full border px-1.5 text-[11px]",children:["#",x.number]}),e[37]=x,e[38]=Q):Q=e[38];let H;e[39]!==o.device?(H=o.device&&a.jsx("span",{className:"shrink-0",children:o.device.name}),e[39]=o.device,e[40]=H):H=e[40];let Z;e[41]!==m?(Z=m>0&&a.jsxs("span",{className:"shrink-0",children:[m," ",m===1?"session":"sessions"]}),e[41]=m,e[42]=Z):Z=e[42];let ee;e[43]!==o.model?(ee=o.model&&a.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:It(o.model)}),e[43]=o.model,e[44]=ee):ee=e[44];let te;e[45]!==X||e[46]!==Q||e[47]!==H||e[48]!==Z||e[49]!==ee?(te=a.jsxs("span",{className:"col-start-2 col-end-4 flex min-w-0 items-center gap-2 text-[11.5px] text-muted-foreground",children:[X,Q,H,Z,ee]}),e[45]=X,e[46]=Q,e[47]=H,e[48]=Z,e[49]=ee,e[50]=te):te=e[50];let K;e[51]!==S||e[52]!==y||e[53]!==k||e[54]!==P||e[55]!==q||e[56]!==G||e[57]!==te?(K=a.jsxs("button",{type:"button",onClick:S,"aria-current":y,"aria-label":k,className:"grid w-full grid-cols-[14px_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-0.5 rounded-md px-2 py-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[P,q,G,te]}),e[51]=S,e[52]=y,e[53]=k,e[54]=P,e[55]=q,e[56]=G,e[57]=te,e[58]=K):K=e[58];let B;e[59]!==r||e[60]!==C||e[61]!==o||e[62]!==i||e[63]!==l||e[64]!==d||e[65]!==j?(B=(j||C)&&a.jsxs("div",{className:"absolute right-1.5 top-1 hidden gap-1 group-focus-within/crew:flex group-hover/crew:flex",children:[j&&o.result&&o.parentId&&a.jsx(ae,{variant:"outline",size:"icon-xs",className:"bg-popover","aria-label":`Mark ${i}'s result read`,title:"Mark the result read",disabled:r.has(o.result.taskId),onClick:()=>void l(o.parentId,o.result.taskId),children:a.jsx(Bt,{"data-icon":"inline-start"})}),C&&a.jsx(ae,{variant:"outline",size:"icon-xs",className:"bg-popover text-destructive","aria-label":`Stop ${i}`,title:"Stop this session",disabled:r.has(o.sessionId),onClick:()=>void d(o),children:a.jsx(Yt,{"data-icon":"inline-start"})})]}),e[59]=r,e[60]=C,e[61]=o,e[62]=i,e[63]=l,e[64]=d,e[65]=j,e[66]=B):B=e[66];let V;return e[67]!==o.sessionId||e[68]!==v||e[69]!==K||e[70]!==B||e[71]!==O?(V=a.jsxs("li",{"data-crew-row":E,className:O,style:v,children:[K,B]}),e[67]=o.sessionId,e[68]=v,e[69]=K,e[70]=B,e[71]=O,e[72]=V):V=e[72],V}export{Xs as CrewPanel};
@@ -1 +0,0 @@
1
- import{r as x,j as e}from"./vendor-react-gGw_S5I_.js";import{Y as K,B as h,J as E,l as V,L as _,M as ee,N as se,O as ne,Q as ae,Z as re,_ as C,$ as te,a0 as ie,a1 as oe,a2 as S,a3 as le,a4 as U,a5 as T,a6 as $,a7 as ce,a8 as F,a9 as P,aa as O,ab as I,ac as M,U as p,ad as d}from"./index-BVrmKCdP.js";import{G as y,i as de,a as he,X as me,b as xe,j as ue,k as B,C as pe,F as ge}from"./vendor-ui-Dfr2Rf5Q.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function b(l){return l.commitsAhead>0&&(!l.branch||C(l.name,l.branch))}const je={M:"text-warning",A:"text-success",D:"text-destructive",R:"text-info"};function Ce({worktrees:l,loading:g,dirName:t,onRefetch:j,onOpenSession:J,onClose:L}){const c=K("hostFiles"),[W,N]=x.useState(null),[G,w]=x.useState(null),[H,u]=x.useState(!1),[a,m]=x.useState(null),[r,f]=x.useState(null),D=async s=>{if(!(!c||!t)){N(s.name);try{const n=await p(`/api/worktrees/${encodeURIComponent(t)}/${encodeURIComponent(s.name)}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:s.isDirty})});if(!n.ok){const{error:i}=await n.json().catch(()=>({error:void 0}));throw new Error(i??`HTTP ${n.status}`)}j()}catch(n){d.error(`Failed to delete worktree: ${n instanceof Error?n.message:"Unknown error"}`)}finally{N(null)}}},q=s=>{if(!(!c||!t)){if(s.isDirty){m({worktree:s,reason:"dirty"});return}if(b(s)){m({worktree:s,reason:"unpushed"});return}D(s)}},Q=()=>{if(!a)return;const{worktree:s,reason:n}=a;if(n==="dirty"&&b(s)){m({worktree:s,reason:"unpushed"});return}m(null),D(s)},X=async s=>{if(!(!c||!t)){w(s.name);try{const n=await p(`/api/worktrees/${encodeURIComponent(t)}/create-pr`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeName:s.name,title:s.name.replace(/-/g," ")})});if(n.ok){const i=await n.json();i.url?window.open(i.url,"_blank","noopener,noreferrer"):d.warning("PR created but no URL was returned")}else{const i=await n.json().catch(()=>({error:"Unknown error"}));d.error(`Failed to create PR: ${i.error||"Unknown error"}`)}}catch(n){d.error(`Error creating PR: ${n instanceof Error?n.message:"Unknown error"}`)}finally{w(null)}}},Y=async()=>{if(!(!c||!t)){u(!0);try{const s=await p(`/api/worktrees/${encodeURIComponent(t)}/cleanup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(s.ok){const{stale:n}=await s.json();n.length===0?d.info("No stale worktrees found"):f(n.map(i=>i.name))}}catch(s){d.error(`Cleanup failed: ${s instanceof Error?s.message:"Unknown error"}`)}finally{u(!1)}}},Z=async()=>{if(!c||!t||!r)return;const s=r;f(null),u(!0);try{await p(`/api/worktrees/${encodeURIComponent(t)}/cleanup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0,names:s})}),j()}catch(n){d.error(`Cleanup failed: ${n instanceof Error?n.message:"Unknown error"}`)}finally{u(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{"aria-label":"Worktrees",className:"flex size-full min-h-0 flex-col bg-canvas",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[e.jsx(y,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 text-muted-foreground"}),e.jsx("h2",{className:"text-sm font-medium",children:"Worktrees"}),e.jsx("div",{className:"flex-1"}),c&&e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:Y,disabled:H,"aria-label":"Cleanup stale worktrees",children:e.jsx(de,{"data-icon":"inline-start"})}),e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:j,disabled:g,"aria-label":"Refresh worktrees",children:e.jsx(he,{"data-icon":"inline-start",className:E(g&&"animate-spin")})}),e.jsx(h,{variant:"ghost",size:"icon-sm",onClick:L,"aria-label":"Close worktrees",children:e.jsx(me,{"data-icon":"inline-start"})})]}),e.jsx(V,{}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto p-3",children:[!t&&e.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Select a project to view worktrees"}),t&&l.length===0&&!g&&e.jsx(_,{className:"border-0 py-16",children:e.jsxs(ee,{children:[e.jsx(se,{variant:"icon",children:e.jsx(y,{})}),e.jsx(ne,{children:"No worktrees"}),e.jsx(ae,{children:"Create a new session with “Isolate in worktree” enabled"})]})}),l.map(s=>{var A,R,z;const n=((A=s.changedFiles)==null?void 0:A.reduce((o,v)=>o+v.additions,0))??0,i=((R=s.changedFiles)==null?void 0:R.reduce((o,v)=>o+v.deletions,0))??0,k=((z=s.changedFiles)==null?void 0:z.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:"mb-1.5 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-foreground",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(re,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-xs",children:[s.commitsAhead," ahead"]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[s.linkedSessions.length>0&&e.jsx(h,{variant:"ghost",size:"icon-xs",onClick:()=>J(s.linkedSessions[0]),"aria-label":"Open session",children:e.jsx(xe,{"data-icon":"inline-start"})}),c&&e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"ghost",size:"icon-xs",onClick:()=>X(s),disabled:G===s.name||s.commitsAhead===0,"aria-label":"Create PR",children:e.jsx(ue,{"data-icon":"inline-start"})}),e.jsx(h,{variant:"ghost",size:"icon-xs",onClick:()=>q(s),disabled:W===s.name,className:"text-destructive hover:bg-destructive/10 hover:text-destructive","aria-label":"Delete worktree",children:e.jsx(B,{"data-icon":"inline-start"})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"shrink-0 font-mono",children:s.head}),e.jsx("span",{className:"truncate",children:s.headMessage})]}),(s.createdAt||!C(s.name,s.branch))&&e.jsxs("div",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[!C(s.name,s.branch)&&e.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(y,{className:"size-3 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:s.branch||"detached"})]}),s.createdAt&&e.jsx("span",{className:"shrink-0",children:te(s.createdAt)})]}),k>0&&e.jsxs(ie,{className:"mt-2",children:[e.jsxs(oe,{className:"group flex w-full items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(pe,{"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:[k," file",k!==1?"s":""," changed"]}),e.jsx(S,{add:n,del:i,className:"ml-1"})]}),e.jsx(le,{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(o=>e.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5 font-mono text-xs",children:[e.jsx("span",{className:E("shrink-0 w-3 text-center",je[o.status]??"text-muted-foreground"),children:o.status}),e.jsx("span",{className:"truncate text-foreground/80",children:o.path}),e.jsx(S,{add:o.additions,del:o.deletions,className:"ml-auto text-muted-foreground"})]},o.path))})})]})]},s.name)})]})]}),e.jsx(U,{open:a!==null,onOpenChange:s=>{s||m(null)},children:e.jsxs(T,{size:"sm",children:[e.jsxs($,{children:[e.jsx(ce,{className:"bg-destructive/10 text-destructive",children:e.jsx(B,{})}),e.jsx(F,{children:(a==null?void 0:a.reason)==="dirty"?"Delete worktree with uncommitted changes?":"Delete worktree with unpushed commits?"}),e.jsxs(P,{children:[(a==null?void 0:a.reason)==="dirty"?`"${a.worktree.name}" has uncommitted changes.`:`"${a==null?void 0:a.worktree.name}" has ${a==null?void 0:a.worktree.commitsAhead} unpushed commit(s).`," "," ","Deleting it cannot be undone."]})]}),e.jsxs(O,{children:[e.jsx(I,{size:"sm",children:"Cancel"}),e.jsx(M,{variant:"destructive",size:"sm",onClick:Q,children:(a==null?void 0:a.reason)==="dirty"&&b(a.worktree)?"Continue":"Delete worktree"})]})]})}),e.jsx(U,{open:r!==null,onOpenChange:s=>{s||f(null)},children:e.jsxs(T,{children:[e.jsxs($,{children:[e.jsx(F,{children:"Remove stale worktrees?"}),e.jsxs(P,{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(O,{children:[e.jsx(I,{size:"sm",children:"Cancel"}),e.jsx(M,{variant:"destructive",size:"sm",onClick:()=>void Z(),children:"Remove worktrees"})]})]})})]})}export{Ce as WorktreePanel};