@staff0rd/assist 0.891.1 → 0.892.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -387,7 +387,6 @@ Rules are `- **<code>** — **<title>** — <text>` bullets, the title optional,
|
|
|
387
387
|
|
|
388
388
|
- `assist sessions` - Start the web dashboard (same as `sessions web`)
|
|
389
389
|
- `assist sessions web [-p, --port <number>] [--no-open]` - Start the web dashboard with Sessions, Backlog and News tabs (default port 3100)
|
|
390
|
-
- `assist sessions summarise [-f, --force] [-n, --limit <count>]` - Generate one-line summaries for unsummarised Claude sessions
|
|
391
390
|
- `assist sessions close` - End the current daemon-managed session
|
|
392
391
|
- `assist sessions rename <title>` - Retitle the current daemon-managed session's dashboard card
|
|
393
392
|
- `assist sessions output [session-id] [--server [group]] [-n, --lines <count>]` - Print the recent output of a session on this node, or with `--server [group]` the current repo's live server run
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
"assist@staff0rd.github.io": {
|
|
4
4
|
"updates": [
|
|
5
5
|
{
|
|
6
|
-
"version": "0.891.
|
|
7
|
-
"update_link": "https://github.com/staff0rd/assist/releases/download/v0.891.
|
|
6
|
+
"version": "0.891.1",
|
|
7
|
+
"update_link": "https://github.com/staff0rd/assist/releases/download/v0.891.1/assist-extension.xpi"
|
|
8
8
|
}
|
|
9
9
|
]
|
|
10
10
|
}
|
|
@@ -4013,7 +4013,7 @@ ${f.join(`
|
|
|
4013
4013
|
`)})}var m$=E(F(),1);function evr({entry:e,state:t,actions:r}){return(0,m$.jsxs)(ie,{sx:{px:2,pb:2,pl:{xs:2,sm:7.5},display:"grid",gap:1.5},children:[(0,m$.jsx)(Q1r,{entry:e,state:t,actions:r}),(0,m$.jsx)(Le,{variant:"caption",color:"text.secondary",children:"History \xB7 ~/.assist/watchers/"}),(0,m$.jsx)(J1r,{lines:e.status?.history??[]})]})}function g$(e){let t=e.status?.loop;return t!==void 0&&(t.phase!=="off"||t.paused===!0)}var y$=E(F(),1),ZXn={display:"flex",gap:.5,flexWrap:"wrap",justifyContent:{xs:"flex-start",sm:"flex-end"},gridColumn:{xs:"1 / -1",sm:"auto"}};function tvr({entry:e,state:t,actions:r}){let n=r.notices.busy[e.name],i=e.status?.loop.paused===!0;return(0,y$.jsxs)(ie,{sx:ZXn,children:[t.kind==="ready"&&(0,y$.jsx)(Cye,{entry:e,actions:r}),t.kind==="diverged"&&(0,y$.jsx)(xye,{entry:e,actions:r}),g$(e)&&(0,y$.jsx)(Dt,{size:"small",disabled:n!==void 0,onClick:()=>{r.control(e,i?"resume":"pause")},children:i?"Resume":"Pause"})]})}var QXn={ready:"warning",diverged:"error"},rvr=e=>t=>{let r=QXn[e];return{display:"grid",gridTemplateColumns:{xs:"28px minmax(0,1fr)",sm:"28px minmax(0,1.3fr) minmax(0,1fr) minmax(0,1.6fr) auto"},alignItems:"center",columnGap:1.5,rowGap:1,px:2,py:1.5,boxShadow:r?`inset 3px 0 0 ${t.palette[r].main}`:"none"}};var nvr=E(F(),1),ivr=st((0,nvr.jsx)("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8z"}),"ArrowUpward");var ovr=E(F(),1),avr=st((0,ovr.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4c-1.48 0-2.85.43-4.01 1.17l1.46 1.46C10.21 6.23 11.08 6 12 6c3.04 0 5.5 2.46 5.5 5.5v.5H19c1.66 0 3 1.34 3 3 0 1.13-.64 2.11-1.56 2.62l1.45 1.45C23.16 18.16 24 16.68 24 15c0-2.64-2.05-4.78-4.65-4.96M3 5.27l2.75 2.74C2.56 8.15 0 10.77 0 14c0 3.31 2.69 6 6 6h11.73l2 2L21 20.73 4.27 4zM7.73 10l8 8H6c-2.21 0-4-1.79-4-4s1.79-4 4-4z"}),"CloudOff");var svr=E(F(),1),lvr=st((0,svr.jsx)("path",{d:"M6 2v6h.01L6 8.01 10 12l-4 4 .01.01H6V22h12v-5.99h-.01L18 16l-4-4 4-3.99-.01-.01H18V2zm10 14.5V20H8v-3.5l4-4zm-4-5-4-4V4h8v3.5z"}),"HourglassEmpty");var cvr=E(F(),1),uvr=st((0,cvr.jsx)("path",{d:"M6 19h4V5H6zm8-14v14h4V5z"}),"Pause");var fvr=E(F(),1),dvr=st((0,fvr.jsx)("path",{d:"M13 3h-2v10h2zm4.83 2.17-1.42 1.42C17.99 7.86 19 9.81 19 12c0 3.87-3.13 7-7 7s-7-3.13-7-7c0-2.19 1.01-4.14 2.58-5.42L6.17 5.17C4.23 6.82 3 9.26 3 12c0 4.97 4.03 9 9 9s9-4.03 9-9c0-2.74-1.23-5.18-3.17-6.83"}),"PowerSettingsNew");var hvr=E(F(),1),pvr=st((0,hvr.jsx)("path",{d:"M1 21h22L12 2zm12-3h-2v-2h2zm0-4h-2v-4h2z"}),"Warning");var w0=E(F(),1),JXn={ok:{tone:"success",icon:(0,w0.jsx)(by,{})},ready:{tone:"warning",icon:(0,w0.jsx)(ivr,{})},diverged:{tone:"error",icon:(0,w0.jsx)(pvr,{})},retrying:{tone:"warning",icon:(0,w0.jsx)(lge,{})},paused:{tone:"neutral",icon:(0,w0.jsx)(uvr,{})},off:{tone:"neutral",icon:(0,w0.jsx)(dvr,{})},loading:{tone:"neutral",icon:(0,w0.jsx)(lvr,{})},unavailable:{tone:"neutral",icon:(0,w0.jsx)(avr,{})}};function eZn(e,t){return t==="neutral"?e.palette.text.secondary:e.palette[t].main}function mvr({state:e}){let{tone:t,icon:r}=JXn[e.kind];return(0,w0.jsxs)(ie,{component:"span",sx:n=>({alignSelf:"flex-start",display:"inline-flex",alignItems:"center",gap:.75,height:24,px:1.25,borderRadius:3,fontSize:12,fontWeight:500,whiteSpace:"nowrap",color:eZn(n,t),bgcolor:t==="neutral"?n.palette.action.hover:po(n.palette[t].main,.1),border:t==="neutral"?`1px solid ${n.palette.divider}`:0,"& svg":{fontSize:14}}),children:[r,e.label]})}var DK=E(F(),1);function gvr({state:e}){return(0,DK.jsxs)(ie,{sx:{...bye,gridColumn:{xs:"2",sm:"auto"},gap:.25},children:[(0,DK.jsx)(mvr,{state:e}),(0,DK.jsx)(Le,{variant:"caption",color:"text.secondary",noWrap:!0,children:e.line})]})}var hv=E(F(),1),yvr={gridColumn:{xs:"2",sm:"auto"}},tZn={fontFamily:"'Roboto Mono', ui-monospace, Menlo, monospace",fontSize:12,fontVariantNumeric:"tabular-nums"};function vvr({entry:e}){let t=e.status;if(!t)return(0,hv.jsx)(Le,{variant:"caption",color:"text.secondary",sx:yvr,children:"\u2014"});let r=t.running!==t.built;return(0,hv.jsxs)(ie,{sx:{...yvr,display:"flex",flexDirection:"column"},children:[(0,hv.jsxs)(ie,{component:"span",sx:tZn,children:["v",t.running,r&&(0,hv.jsxs)(hv.Fragment,{children:[" ",(0,hv.jsx)(ie,{component:"span",sx:{color:"warning.main"},children:"\u2192"})," ","v",t.built]})]}),(0,hv.jsx)(Le,{variant:"caption",color:"text.secondary",children:r?"running \u2192 built":"running"})]})}function v$(e){return(e.status?.restart.length??0)>0}function bvr(e,t){return e.paused?{kind:"paused",label:"Paused",line:"won't pull until resumed"}:e.phase==="off"?{kind:"off",label:"Off",line:e.reason??"not running"}:e.phase==="retrying"?{kind:"retrying",label:"Retrying",line:`${e.reason??"lap failed"} \xB7 ${t}`}:{kind:"ok",label:"Up to date",line:`watching origin since ${t}`}}function Qk(e){let{status:t}=e;if(e.loading)return{kind:"loading",label:"Checking",line:"waiting for node"};if(!t)return{kind:"unavailable",label:"Unavailable",line:e.error??"no update state"};let{loop:r}=t,n=_o(r.since);return r.phase==="diverged"?{kind:"diverged",label:"Diverged \xB7 fixing",line:`diverged ${n}${r.escalationId?` \xB7 session ${r.escalationId}`:""}`}:v$(e)?{kind:"ready",label:"Restart to update",line:`restart ${t.restart.map(h$).join(" + ")}${r.paused?" \xB7 paused":""}`}:bvr(r,n)}var pv=E(F(),1);function Svr({entry:e,actions:t}){let[r,n]=(0,xvr.useState)(!1),i=Qk(e);return(0,pv.jsxs)(ie,{component:"article",sx:{"& + &":{borderTop:1,borderColor:"divider"}},children:[(0,pv.jsxs)(ie,{sx:rvr(i.kind),children:[(0,pv.jsx)(q1r,{open:r,label:`${r?"Hide":"Show"} history for ${e.name}`,onToggle:()=>n(o=>!o)}),(0,pv.jsx)(j1r,{entry:e}),(0,pv.jsx)(vvr,{entry:e}),(0,pv.jsx)(gvr,{state:i}),(0,pv.jsx)(tvr,{entry:e,state:i,actions:t})]}),r&&(0,pv.jsx)(evr,{entry:e,state:i,actions:t})]})}var Tvr=E(F(),1),kye=st((0,Tvr.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");var MUe=E(de(),1);var b$=E(F(),1);function Cvr({entries:e,actions:t}){let[r,n]=(0,MUe.useState)(!1),[i,o]=(0,MUe.useState)(!1),a=e.filter(l=>Qk(l).kind==="ready").length,s=e.some(l=>g$(l)&&!l.status?.loop.paused);return(0,b$.jsxs)(ie,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:[(0,b$.jsx)(Dt,{variant:"outlined",size:"small",startIcon:(0,b$.jsx)(kye,{}),disabled:!s||r,onClick:()=>{n(!0),t.checkAll(e).finally(()=>n(!1))},children:"Check now"}),(0,b$.jsx)(Dt,{variant:"contained",size:"small",disabled:a===0||i,onClick:()=>{o(!0),t.restartReady(e).finally(()=>o(!1))},children:a?`Restart ready nodes (${a})`:"Restart ready nodes"})]})}function wvr(e){let t=e.map(o=>Qk(o).kind),r=o=>t.filter(a=>a===o).length,n=r("ready"),i=[`${e.length} node${e.length===1?"":"s"}`];return i.push(n?`${n} ready to restart`:"all running their latest build"),r("diverged")&&i.push(`${r("diverged")} diverged`),r("loading")&&i.push(`${r("loading")} checking`),r("unavailable")&&i.push(`${r("unavailable")} unavailable`),i.join(" \xB7 ")}var $vr=E(de(),1);function kvr(e,t){return`${e}:${t}`}var IUe=E(de(),1);async function x$(e){if(!e)return"web server unreachable";try{return(await e.json()).error??`HTTP ${e.status}`}catch{return`HTTP ${e.status}`}}async function _vr(e,t){let r;try{r=await fetch(qr(`/api/updates/control?action=${t}`,e.local?void 0:e.name),{method:"POST"})}catch{}return r?.ok?void 0:x$(r)}var rZn=5e3,Evr={pause:"Pausing",resume:"Resuming",check:"Checking"};function Rvr(e,t){let{mark:r,setError:n,setBack:i}=e,o=(0,IUe.useCallback)(async(s,l)=>{r(s.name,Evr[l]);let u=await _vr(s,l);return u&&n(`${Evr[l]} ${s.name} failed: ${u}`),r(s.name),t(),!u&&l==="check"&&setTimeout(t,rZn),!u},[r,n,t]),a=(0,IUe.useCallback)(async s=>{let l=s.filter(d=>g$(d)&&!d.status?.loop.paused),f=(await Promise.all(l.map(d=>o(d,"check")))).filter(Boolean).length;f&&i(`Checking ${f} node${f===1?"":"s"} against origin`)},[o,i]);return{control:o,checkAll:a}}var DUe=E(de(),1);var mv=E(de(),1);var S$={target:"both",label:"Restart daemon",message:"This restarts the sessions daemon and the web server, then reloads the page once the server is back."};function Jk(e,t){let r=t?`&node=${encodeURIComponent(t)}`:"";return fetch(`/api/restart?target=${e}${r}`,{method:"POST"})}var K2=E(de(),1);var nZn="/api/health";async function iZn(){try{return(await fetch(nZn,{cache:"no-store"})).ok}catch{return!1}}async function Avr(e){let t=0;for(;!e();){if(t=await iZn()?t+1:0,t>=2)return!e();await new Promise(r=>setTimeout(r,300))}return!1}function oZn(){return{sawDisconnect:!1,waiting:!1,abandoned:!0}}function Pvr(e,t,r){let n=(0,K2.useRef)(oZn()),i=(0,K2.useRef)(r);i.current=r,(0,K2.useEffect)(()=>{let s=n.current;if(!(!e||s.abandoned)){if(t){s.sawDisconnect=!0;return}!s.sawDisconnect||s.waiting||(s.waiting=!0,Avr(()=>s.abandoned).then(l=>{l&&i.current()}))}},[e,t]);let o=(0,K2.useCallback)(()=>{n.current.abandoned=!0},[]),a=(0,K2.useCallback)(()=>{n.current.abandoned=!0,n.current={sawDisconnect:!1,waiting:!1,abandoned:!1}},[]);return(0,K2.useEffect)(()=>o,[o]),{arm:a,abandon:o}}var aZn=15e3;function e_(e,t,r){let[n,i]=(0,mv.useState)(!1),[o,a]=(0,mv.useState)(null),s=(0,mv.useRef)(void 0),{arm:l,abandon:u}=Pvr(n,t,()=>{clearTimeout(s.current),r?.(),globalThis.location.reload()});(0,mv.useEffect)(()=>()=>clearTimeout(s.current),[]);let f=(0,mv.useCallback)(async h=>{i(!0),l(),s.current=setTimeout(()=>{u(),i(!1),a("Web server did not come back")},aZn);try{if(!(await Jk(h)).ok)throw new Error("restart failed")}catch{u(),clearTimeout(s.current),i(!1),a("Failed to restart web server")}},[l,u]),d=(0,mv.useCallback)(()=>f(e),[f,e]);return{pending:n,error:o,clearError:()=>a(null),restart:d,restartTo:f}}function _ye(e){return e.local&&v$(e)}var Lvr=15e3;async function Eye(e,t){try{let r=await fetch(qr("/api/updates",t?void 0:e),{signal:AbortSignal.timeout(Lvr)}),n=await r.json();if(!r.ok)throw new Error(n?.error??`HTTP ${r.status}`);return{name:e,local:t,status:n}}catch(r){return{name:e,local:t,error:sZn(r)}}}function sZn(e){return e instanceof DOMException&&e.name==="TimeoutError"?`No response after ${Lvr/1e3}s`:e instanceof Error?e.message:"Failed to load update state"}var lZn=2e3,cZn=9e4,uZn=e=>new Promise(t=>setTimeout(t,e));async function Mvr(e,t){let r=Date.now()+cZn;for(;Date.now()<r;){await uZn(lZn);let n=await Eye(e.name,e.local),i=n.status;if(i?.daemonReachable&&!t.some(o=>i.restart.includes(o)))return n}}async function Ivr(e,t,r){let n;try{n=await Jk(t,e.local?void 0:e.name)}catch{}if(!n?.ok)throw new Error(await x$(n));let i=await Mvr(e,r);if(!i?.status)throw new Error(`${e.name} did not come back`);return i.status.running}async function Dvr(e,t,r){try{let n=await Ivr(e,t,e.status?.restart??[]);r.setBack(`${e.name} is running v${n}`)}catch(n){r.setError(`Restart ${e.name} failed: ${n instanceof Error?n.message:String(n)}`)}}function Nvr(e){return e.length>1?"both":e[0]}function Ovr(e,t,r){let n=e_("webserver",e),i=(0,DUe.useCallback)(async a=>{let s=Nvr(a.status?.restart??[]);if(s){if(t.mark(a.name,"Restarting"),_ye(a))return n.restartTo(s==="daemon"?"both":s);await Dvr(a,s,t),t.mark(a.name),r()}},[n,t,r]),o=(0,DUe.useCallback)(async a=>{let s=a.filter(l=>Qk(l).kind==="ready");await Promise.all(s.filter(l=>!_ye(l)).map(l=>i(l)));for(let l of s.filter(_ye))await i(l)},[i]);return{restart:i,restartReady:o,localError:n.error,clearLocalError:n.clearError}}var T$=E(de(),1);function Bvr(){let[e,t]=(0,T$.useState)(null),[r,n]=(0,T$.useState)(null),[i,o]=(0,T$.useState)({}),a=(0,T$.useCallback)((s,l)=>{o(u=>{let f={...u};return l?f[s]=l:delete f[s],f})},[]);return{busy:i,mark:a,back:e,setBack:t,clearBack:()=>t(null),error:r,setError:n,clearError:()=>n(null)}}function Fvr(e,t){let{refresh:r}=f$(),n=Bvr(),i=Ovr(e,n,r),o=Rvr(n,r),a=gy(t),s=(0,$vr.useCallback)(l=>{let u=l.status?.loop.escalationId;u&&a(l.local?u:kvr(l.name,u))},[a]);return{...i,...o,openFix:s,notices:n}}var k0=E(F(),1);function zvr({reconnecting:e,selectSession:t}){let{entries:r,loading:n}=f$(),i=Fvr(e,t),{notices:o}=i;return(0,k0.jsxs)(Kl,{loading:n,header:(0,k0.jsxs)(ie,{sx:{display:"flex",alignItems:"flex-end",gap:2,flexWrap:"wrap",mb:3},children:[(0,k0.jsxs)(ie,{sx:{flex:"1 1 auto"},children:[(0,k0.jsx)(Le,{variant:"h5",component:"h1",children:"Updates"}),(0,k0.jsx)(Le,{variant:"body2",color:"text.secondary",children:wvr(r)})]}),(0,k0.jsx)(Cvr,{entries:r,actions:i})]}),children:[(0,k0.jsx)(un,{variant:"outlined",component:"section","aria-label":"Nodes",children:r.map(a=>(0,k0.jsx)(Svr,{entry:a,actions:i},a.name))}),(0,k0.jsx)(MK,{notices:{...o,error:o.error??i.localError,clearError:()=>{o.clearError(),i.clearLocalError()}}})]})}var Rbr=E(de(),1);var C$=E(de(),1);function Rye(e,t){let r=(0,C$.useRef)(null),[n,i]=(0,C$.useState)();return(0,C$.useLayoutEffect)(()=>{e===t&&r.current&&i(r.current.offsetHeight)},[e,t]),{ref:r,height:n}}var Uvr=E(de(),1);function Aye(e){if(e.startsWith("local:")){let n=e.slice(6).replace(/\/+$/,"").split("/").filter(Boolean);return n[n.length-1]??e}let t=e.indexOf("/");return t===-1?e:e.slice(t+1)}function Pye(e){let t=o=>o.startsWith("local:"),r=o=>{let a=Aye(o),s=a.split("/");return s[s.length-1]??a},n=new Map;for(let o of new Set(e)){if(t(o))continue;let a=r(o);n.set(a,(n.get(a)??0)+1)}let i=new Map;for(let o of e){if(t(o)){i.set(o,Aye(o));continue}let a=r(o),s=(n.get(a)??0)>1;i.set(o,s?Aye(o):a)}return i}var NK={field:"lastPhase",direction:"desc"};var OK="all",BK="all";async function Hvr(e,t,r){let n=new URLSearchParams({page:String(e),pageSize:String(t)});r.origin!==OK&&n.set("origin",r.origin),r.status!==BK&&n.set("status",r.status),r.sort.field!==NK.field&&n.set("sort",r.sort.field),r.sort.direction!==NK.direction&&n.set("direction",r.sort.direction);let i=await fetch(`/api/usage/items?${n}`);if(!i.ok)throw new Error(`Failed to load item usage (HTTP ${i.status}).`);return i.json()}var $K=E(F(),1);function Wvr({origins:e,origin:t,onChange:r}){let n=(0,Uvr.useMemo)(()=>Pye(e.map(o=>o.origin)),[e]),i=e.reduce((o,a)=>o+a.count,0);return(0,$K.jsxs)(Qn,{select:!0,size:"small",label:"Repo",value:t,onChange:o=>r(o.target.value),sx:{minWidth:220},children:[(0,$K.jsx)(pn,{value:OK,children:`All repos (${i})`}),e.map(o=>(0,$K.jsx)(pn,{value:o.origin,children:`${n.get(o.origin)??o.origin} (${o.count})`},o.origin))]})}var NUe=E(F(),1),fZn=[{value:BK,label:"All"},{value:"done",label:"Done"},{value:"running",label:"Running"}];function Gvr({status:e,onChange:t}){return(0,NUe.jsx)(Eu,{size:"small",exclusive:!0,value:e,onChange:(r,n)=>n&&t(n),"aria-label":"Filter items by status",children:fZn.map(r=>(0,NUe.jsx)(bs,{value:r.value,children:r.label},r.value))})}var w$=E(F(),1),dZn={display:"flex",alignItems:"center",gap:2,flexWrap:"wrap",mb:2},hZn="Repos show their bare name, or org/repo when two share one. Totals sum every phase's recorded usage.";function Vvr({origins:e,origin:t,onOriginChange:r,status:n,onStatusChange:i}){return(0,w$.jsxs)(ie,{sx:dZn,children:[(0,w$.jsx)(Gvr,{status:n,onChange:i}),(0,w$.jsx)(Wvr,{origins:e,origin:t,onChange:r}),(0,w$.jsx)(Le,{variant:"caption",color:"text.disabled",children:hZn})]})}var nbr=E(de(),1);function sh(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(1)}M`}function _0(e){let t=Math.round(e/1e3);if(t<60)return`${t}s`;let r=Math.floor(t/60);if(r<60){let o=t%60;return o>0?`${r}m ${o}s`:`${r}m`}let n=Math.floor(r/60),i=r%60;return i>0?`${n}h ${i}m`:`${n}h`}var Mye=E(F(),1),pZn={whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},qvr={display:"block",fontSize:"0.75rem",color:"text.disabled",whiteSpace:"nowrap"},mZn={...qvr,fontStyle:"italic"};function Lye({total:e,perPhase:t,partial:r}){return(0,Mye.jsxs)(Rn,{align:"right",sx:pZn,children:[e,t?(0,Mye.jsx)(Le,{component:"span",sx:r?mZn:qvr,children:t}):null]})}var FK=E(F(),1),gZn={width:"100%",maxWidth:0},yZn={display:"block",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},vZn={display:"block",mt:"2px",fontSize:"0.75rem",color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function jvr({id:e,name:t,type:r,repoLabel:n}){return(0,FK.jsxs)(Rn,{sx:gZn,children:[(0,FK.jsx)(Kr,{component:Cs,to:fT(e),underline:"hover",color:"text.primary",title:t,sx:yZn,children:t}),(0,FK.jsxs)(Le,{component:"span",sx:vZn,children:[Yi(e)," \xB7 ",r," \xB7 ",n]})]})}function Yvr(e){let t=Math.max(1,e.recordedPhases);return{active:`${_0(e.activeMs/t)} / phase`,tokens:`${sh(Math.round((e.tokensUp+e.tokensDown)/t))} / phase`}}function Kvr(e){if(!(e.status==="done"||e.recordedPhases>e.phaseCount))return`${e.recordedPhases} of ${e.phaseCount} phases`}var Iye={story:"info",bug:"error"},Dye={todo:"default","in-progress":"warning",done:"success",wontdo:"error"};var bZn=new Set(["done","wontdo"]);function Xvr(e){return bZn.has(e)?{label:e,color:Dye[e]}:{label:"running",color:"warning"}}var OUe=E(F(),1),xZn={height:20,fontSize:"0.6875rem"};function Zvr({status:e}){let t=Xvr(e);return(0,OUe.jsx)(Rn,{children:(0,OUe.jsx)(tn,{label:t.label,size:"small",variant:"outlined",color:t.color,sx:xZn})})}var E0=E(F(),1),Qvr={whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"};function Jvr({row:e,repoLabel:t}){let r=Yvr(e);return(0,E0.jsxs)(df,{hover:!0,children:[(0,E0.jsx)(jvr,{id:e.id,name:e.name,type:e.type,repoLabel:t}),(0,E0.jsx)(Zvr,{status:e.status}),(0,E0.jsx)(Lye,{total:String(e.phaseCount||e.recordedPhases),perPhase:Kvr(e),partial:!0}),(0,E0.jsx)(Lye,{total:_0(e.activeMs),perPhase:r.active}),(0,E0.jsx)(Lye,{total:`\u2191 ${sh(e.tokensUp)} \u2193 ${sh(e.tokensDown)}`,perPhase:r.tokens}),(0,E0.jsx)(Rn,{align:"right",sx:Qvr,children:(0,E0.jsxs)(ie,{component:"span",sx:{color:Bte(e.peakContextPct)},children:[Math.round(e.peakContextPct),"%"]})}),(0,E0.jsx)(Rn,{align:"right",sx:Qvr,children:e.lastPhaseAt?_o(e.lastPhaseAt):"\u2014"})]})}var ebr=[{label:"Item"},{label:"Status"},{label:"Phases",sort:"phases",numeric:!0},{label:"Active",sort:"active",numeric:!0,tooltip:"Accumulated active time across the item's phases \u2014 not wall clock."},{label:"Tokens",sort:"tokens",numeric:!0},{label:"Peak ctx",sort:"peakContext",numeric:!0,tooltip:"The highest context-window usage any one phase reached."},{label:"Last phase",sort:"lastPhase",numeric:!0,tooltip:"When the item's most recent phase session started."}];var og=E(F(),1),SZn={"& th":{whiteSpace:"nowrap"}};function tbr({column:e}){return e.tooltip?(0,og.jsx)(lr,{title:e.tooltip,describeChild:!0,children:(0,og.jsx)("span",{children:e.label})}):(0,og.jsx)(og.Fragment,{children:e.label})}function rbr({sort:e,onSort:t}){return(0,og.jsx)(x5,{sx:SZn,children:(0,og.jsx)(df,{children:ebr.map(r=>{let n=r.sort,i=n!==void 0&&e.field===n;return(0,og.jsx)(Rn,{align:r.numeric?"right":"left",sortDirection:i?e.direction:!1,children:n===void 0?(0,og.jsx)(tbr,{column:r}):(0,og.jsx)(Hxe,{active:i,direction:i?e.direction:"desc",onClick:()=>t(n),children:(0,og.jsx)(tbr,{column:r})})},r.label)})})})}var mA=E(F(),1),TZn={"& td, & th":{px:1.5}};function ibr({rows:e,origins:t,sort:r,onSort:n}){let i=(0,nbr.useMemo)(()=>Pye([...t,...e.map(o=>o.origin)]),[t,e]);return(0,mA.jsx)(b5,{component:un,children:(0,mA.jsxs)(Kv,{size:"small",sx:TZn,children:[(0,mA.jsx)(rbr,{sort:r,onSort:n}),(0,mA.jsx)(Xv,{children:e.map(o=>(0,mA.jsx)(Jvr,{row:o,repoLabel:i.get(o.origin)??o.origin},o.id))})]})})}function obr(e){let t=Math.max(1,e.medianPhases),r=e.repoCount===1?"repo":"repos";return{items:String(e.itemCount),itemsFoot:`across ${e.repoCount} ${r} \xB7 ${e.doneCount} done`,phases:String(Math.round(e.medianPhases*10)/10),active:_0(e.medianActiveMs),activeFoot:`${_0(e.medianActiveMs/t)} per phase`,tokens:sh(Math.round(e.medianTokens)),tokensFoot:`${sh(Math.round(e.medianTokens/t))} per phase`}}var k$=E(F(),1),abr={display:"block"},CZn={fontWeight:400,fontVariantNumeric:"tabular-nums"};function zK({label:e,value:t,foot:r}){return(0,k$.jsxs)(ie,{children:[(0,k$.jsx)(Le,{variant:"caption",color:"text.secondary",sx:abr,children:e}),(0,k$.jsx)(Le,{variant:"h5",sx:CZn,children:t}),r?(0,k$.jsx)(Le,{variant:"caption",color:"text.disabled",sx:abr,children:r}):null]})}var gA=E(F(),1),wZn={display:"flex",flexDirection:{xs:"column",sm:"row"},mb:3,"& > *":{flex:1,minWidth:0,p:2},"& > * + *":{borderColor:"divider",borderTop:{xs:1,sm:0},borderLeft:{xs:0,sm:1}}};function sbr({summary:e}){let t=obr(e);return(0,gA.jsxs)(un,{sx:wZn,children:[(0,gA.jsx)(zK,{label:"Items with recorded usage",value:t.items,foot:t.itemsFoot}),(0,gA.jsx)(zK,{label:"Median phases",value:t.phases}),(0,gA.jsx)(zK,{label:"Median active time",value:t.active,foot:t.activeFoot}),(0,gA.jsx)(zK,{label:"Median tokens",value:t.tokens,foot:t.tokensFoot})]})}var Tp=E(F(),1);function lbr({items:e,data:t}){let{rows:r,total:n,page:i,pageSize:o}=e,{ref:a,height:s}=Rye(r.length,o);return(0,Tp.jsxs)(Tp.Fragment,{children:[(0,Tp.jsx)(sbr,{summary:t.summary}),(0,Tp.jsx)(Vvr,{origins:t.origins,origin:e.origin,onOriginChange:e.selectOrigin,status:e.status,onStatusChange:e.selectStatus}),n===0?(0,Tp.jsx)(Le,{color:"text.secondary",align:"center",sx:{py:6},children:"No items match this filter."}):(0,Tp.jsxs)(Tp.Fragment,{children:[(0,Tp.jsx)(ie,{ref:a,sx:{minHeight:s},children:(0,Tp.jsx)(ibr,{rows:r,origins:t.origins.map(l=>l.origin),sort:e.sort,onSort:e.sortBy})}),(0,Tp.jsx)(Lz,{component:"div",count:n,page:i,rowsPerPage:o,rowsPerPageOptions:[o],onPageChange:(l,u)=>e.setPage(u)})]})]})}var X2=E(F(),1);function cbr({items:e}){let{data:t}=e;return(0,X2.jsxs)(X2.Fragment,{children:[(0,X2.jsx)(ie,{sx:{height:4,mb:1},children:e.fetching&&(0,X2.jsx)(v5,{})}),t?t.origins.length===0?(0,X2.jsx)(Le,{color:"text.secondary",align:"center",sx:{py:6},children:"No item usage recorded yet."}):(0,X2.jsx)(lbr,{items:e,data:t}):null]})}function BUe(e,t,r){if(e==null)return;let n=Math.max(0,e-r),i=Math.max(0,t-n)/t;if(!(i<.05))return i}function Nye(e,t){let r=Math.max(0,e-t),n=Math.floor(r/86400),i=Math.floor(r%86400/3600),o=Math.floor(r%3600/60);return n>0?`${n}d ${i}h`:i>0?`${i}h ${o}m`:`${o}m`}function kZn(e,t,r,n){let i=BUe(t,r,n);if(i!=null)return e/i}function t_(e,t,r,n){let i=kZn(e,t,r,n);return i==null?"ok":i>100?"over":i>75?"warn":"ok"}var _Zn=["five_hour","seven_day"],EZn=["claude","codex","pi"];function ubr(e){let[t,r]=e.includes(":")?e.split(":",2):["claude",e],n=EZn.find(o=>o===t),i=_Zn.find(o=>o===r);if(!(!n||!i)&&!(n==="claude"&&e.includes(":")))return{harness:n,window:i}}var fbr={five_hour:{label:"5h",seconds:18e3},seven_day:{label:"7d",seconds:604800,tint:{light:"rgba(0, 0, 0, 0.1)",dark:"rgba(255, 255, 255, 0.1)"}}};function _$(e){let t=ubr(e);if(!t)return fbr.five_hour;let r=fbr[t.window];return t.harness==="claude"?r:{...r,label:`${Lu(t.harness)} ${r.label}`}}var RZn={ok:"success.main",warn:"warning.main",over:"error.main"};function r_(e){return RZn[e]}var WK=E(F(),1),AZn={ok:"success",warn:"warning",over:"error"};function dbr({percentage:e,level:t}){return(0,WK.jsxs)(ie,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,WK.jsx)(v5,{variant:"determinate",value:Math.min(100,e),color:AZn[t],sx:{flexGrow:1,height:8,borderRadius:1}}),(0,WK.jsxs)(ie,{sx:{minWidth:40,textAlign:"right",color:r_(t)},children:[Math.round(e),"%"]})]})}function hbr(e){return e.avgContextPct==null?"\u2014":`${Math.round(e.avgContextPct)}%`}var PZn=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function $Ue(e){return PZn.format(e)}var Oye=E(F(),1);function pbr({peak:e}){return(0,Oye.jsx)(Rn,{align:"right",sx:{whiteSpace:"nowrap"},children:(0,Oye.jsx)(lr,{title:`Cycle started ${$Ue(new Date(e.createdAt))}`,children:(0,Oye.jsx)("span",{children:$Ue(new Date(e.resetsAt*1e3))})})})}var gbr=E(F(),1);function mbr(){return(0,gbr.jsx)(tn,{label:"reset",size:"small",color:"warning",variant:"outlined",title:"Quota reset mid-cycle \u2014 this is the peak reached before the reset.",sx:{ml:1}})}function ybr(e){return!e.tokensUp&&!e.tokensDown?"\u2014":`\u2191 ${sh(e.tokensUp)} \u2193 ${sh(e.tokensDown)}`}var R0=E(F(),1);function vbr({peak:e,now:t}){let{label:r,seconds:n,tint:i}=_$(e.window),o=t_(e.usedPercentage,e.resetsAt,n,t);return(0,R0.jsxs)(df,{sx:a=>({backgroundColor:i?a.palette.mode==="dark"?i.dark:i.light:void 0}),children:[(0,R0.jsxs)(Rn,{children:[r,e.resetDetected&&(0,R0.jsx)(mbr,{})]}),(0,R0.jsx)(Rn,{sx:{minWidth:160},children:(0,R0.jsx)(dbr,{percentage:e.usedPercentage,level:o})}),(0,R0.jsx)(Rn,{align:"right",sx:{whiteSpace:"nowrap"},children:hbr(e)}),(0,R0.jsx)(Rn,{align:"right",sx:{whiteSpace:"nowrap"},children:e.phaseCount??0}),(0,R0.jsx)(Rn,{align:"right",sx:{whiteSpace:"nowrap"},children:ybr(e)}),(0,R0.jsx)(pbr,{peak:e})]})}var Bye=E(de(),1);function n_(e){let[t,r]=(0,Bye.useState)(()=>Math.floor(Date.now()/1e3));return(0,Bye.useEffect)(()=>{let n=setInterval(()=>r(Math.floor(Date.now()/1e3)),e);return()=>clearInterval(n)},[e]),t}var _c=E(F(),1);function bbr({peaks:e}){let t=n_(3e4);return(0,_c.jsx)(b5,{component:un,children:(0,_c.jsxs)(Kv,{size:"small",children:[(0,_c.jsx)(x5,{sx:{"& th":{whiteSpace:"nowrap"}},children:(0,_c.jsxs)(df,{children:[(0,_c.jsx)(Rn,{children:"Window"}),(0,_c.jsx)(Rn,{children:"Peak usage"}),(0,_c.jsx)(Rn,{align:"right",children:(0,_c.jsx)(lr,{title:"Mean context-window usage across all readings in this rate-limit cycle \u2014 distinct from the Peak usage quota above.",children:(0,_c.jsx)("span",{children:"Avg context"})})}),(0,_c.jsx)(Rn,{align:"right",children:(0,_c.jsx)(lr,{title:"Number of phase readings behind the average.",children:(0,_c.jsx)("span",{children:"Phases"})})}),(0,_c.jsx)(Rn,{align:"right",children:"Tokens spent"}),(0,_c.jsx)(Rn,{align:"right",children:"Cycle reset"})]})}),(0,_c.jsx)(Xv,{children:e.map(r=>(0,_c.jsx)(vbr,{peak:r,now:t},`${r.window}-${r.resetsAt}-${r.segment}`))})]})})}var i_=E(F(),1);function xbr({rows:e,total:t,page:r,pageSize:n,onPageChange:i}){let{ref:o,height:a}=Rye(e.length,n);return(0,i_.jsxs)(i_.Fragment,{children:[(0,i_.jsx)(ie,{ref:o,sx:{minHeight:a},children:(0,i_.jsx)(bbr,{peaks:e})}),(0,i_.jsx)(Lz,{component:"div",count:t,page:r,rowsPerPage:n,rowsPerPageOptions:[n],onPageChange:(s,l)=>i(l)})]})}var GK=E(de(),1);function o_(){let[e,t]=(0,GK.useState)(!1),[r,n]=(0,GK.useState)(!1);return(0,GK.useEffect)(()=>{let i=!1;return(async()=>{try{let a=await(await fetch("/api/harness")).json();i||(t(!!a?.exposeCodexActions),n(!!a?.exposePiActions))}catch{t(!1),n(!1)}})(),()=>{i=!0}},[]),{exposeCodexActions:e,exposePiActions:r}}var FUe=E(F(),1),Sbr=["five_hour","seven_day"],LZn=["codex:five_hour","codex:seven_day"];function MZn(e){let t=e?[...Sbr,...LZn]:Sbr;return[{value:"all",label:"All"},...t.map(r=>({value:r,label:_$(r).label}))]}function Tbr({window:e,onChange:t}){let{exposeCodexActions:r}=o_();return(0,FUe.jsx)(Eu,{size:"small",exclusive:!0,value:e,onChange:(n,i)=>i&&t(i),"aria-label":"Filter peaks by rate-limit window",children:MZn(r).map(n=>(0,FUe.jsx)(bs,{value:n.value,children:n.label},n.value))})}var gv=E(F(),1);function Cbr({history:e}){let{window:t,total:r}=e;return(0,gv.jsxs)(gv.Fragment,{children:[(0,gv.jsx)(Tbr,{window:t,onChange:e.selectWindow}),(0,gv.jsx)(ie,{sx:{height:4,my:1},children:e.fetching&&(0,gv.jsx)(v5,{})}),r===0?(0,gv.jsx)(Le,{color:"text.secondary",align:"center",sx:{py:6},children:t==="all"?"No usage peaks recorded yet.":`No ${_$(t).label} usage peaks recorded yet.`}):(0,gv.jsx)(xbr,{rows:e.rows,total:r,page:e.page,pageSize:e.pageSize,onPageChange:e.setPage})]})}var Fye=E(de(),1);async function wbr(e,t,r){let n=new URLSearchParams({page:String(e),pageSize:String(t)});r!=="all"&&n.set("window",r);let i=await fetch(`/api/usage/history?${n}`);if(!i.ok)throw new Error(`Failed to load usage history (HTTP ${i.status}).`);return i.json()}var a_=E(de(),1);function $ye(e,t,r=!0){let[n,i]=(0,a_.useState)(0),[o,a]=(0,a_.useState)(null),[s,l]=(0,a_.useState)(!1),[u,f]=(0,a_.useState)(null);(0,a_.useEffect)(()=>{if(!r)return;let p=!1;return l(!0),e(n,t).then(m=>{p||(a(m),l(!1))},m=>{p||(f(m instanceof Error?m:new Error(String(m))),l(!1))}),()=>{p=!0}},[e,n,t,r]);let d=o?.total??0;(0,a_.useEffect)(()=>{if(d===0)return;let p=Math.ceil(d/t)-1;n>p&&i(p)},[n,t,d]);let h=o?.rows??[];return{data:o,rows:h,total:d,loaded:o!==null,fetching:s,error:u,page:n,setPage:i,pageSize:t}}var IZn=30;function kbr(){let[e,t]=(0,Fye.useState)("all"),r=(0,Fye.useCallback)((o,a)=>wbr(o,a,e),[e]),n=$ye(r,IZn);return{...n,window:e,selectWindow:o=>{t(o),n.setPage(0)}}}var E$=E(de(),1);function _br(e,t){return e.field!==t?{field:t,direction:"desc"}:{field:t,direction:e.direction==="desc"?"asc":"desc"}}var DZn=30;function Ebr(e){let[t,r]=(0,E$.useState)(OK),[n,i]=(0,E$.useState)(BK),[o,a]=(0,E$.useState)(NK),s=(0,E$.useCallback)((h,p)=>Hvr(h,p,{origin:t,status:n,sort:o}),[t,n,o]),l=$ye(s,DZn,e);return{...l,origin:t,selectOrigin:h=>{r(h),l.setPage(0)},status:n,selectStatus:h=>{i(h),l.setPage(0)},sort:o,sortBy:h=>{a(p=>_br(p,h)),l.setPage(0)}}}var s_=E(F(),1),NZn={borderBottom:1,borderColor:"divider",mb:2};function Abr(){let[e,t]=(0,Rbr.useState)("limits"),r=kbr(),n=Ebr(e==="items");if(r.error)throw r.error;if(n.error)throw n.error;return(0,s_.jsxs)(Kl,{loading:!r.loaded,title:"Usage history",maxWidth:"lg",children:[(0,s_.jsxs)(T5,{value:e,onChange:(i,o)=>t(o),textColor:"inherit",indicatorColor:"secondary",sx:NZn,"aria-label":"Usage history views",children:[(0,s_.jsx)(Yv,{label:"Rate limits",value:"limits"}),(0,s_.jsx)(Yv,{label:"Items",value:"items"})]}),e==="limits"?(0,s_.jsx)(Cbr,{history:r}):(0,s_.jsx)(cbr,{items:n})]})}var zye=E(de(),1),zUe=(0,zye.createContext)([]);function Hye(){return(0,zye.useContext)(zUe)}var Wxr=E(de(),1);function Pa(){let{selectedCwd:e}=$n();return e||void 0}var Z2=E(de(),1);var Lbr=E(de(),1);var OZn=new Set(["todo","done","all"]);function Pbr(e){return e&&OZn.has(e)?e:"todo"}var Mbr="backlog-filter",HUe=new Set,Ibr=BZn();function BZn(){try{return Pbr(localStorage.getItem(Mbr))}catch{return"todo"}}function $Zn(e){return HUe.add(e),()=>HUe.delete(e)}function FZn(){return Ibr}function zZn(e){Ibr=e;try{localStorage.setItem(Mbr,e)}catch{}for(let t of HUe)t()}function R$(){return[(0,Lbr.useSyncExternalStore)($Zn,FZn),zZn]}function Dbr(){let e=Pa(),t=yr(),[r]=R$(),[n,i]=(0,Z2.useState)(""),[o,a]=(0,Z2.useState)(null),[s,l]=(0,Z2.useState)(!1),[u,f]=(0,Z2.useState)(e),d=(0,Z2.useRef)(void 0);return e!==u&&(f(e),a(null),l(n.trim().length>0)),(0,Z2.useEffect)(()=>{if(d.current!==void 0&&clearTimeout(d.current),!n.trim()){a(null),l(!1);return}let h=new AbortController,{signal:p}=h;return l(!0),d.current=setTimeout(async()=>{try{let m=await dT({query:n,cwd:e,node:t,signal:p,filter:r});if(p.aborted)return;a(m),l(!1)}catch(m){if(!p.aborted)throw m}},250),()=>{d.current!==void 0&&clearTimeout(d.current),h.abort()}},[n,e,t,r]),{query:n,setQuery:i,results:o,loading:s}}var $br={position:"relative",display:"grid",gridTemplateColumns:"auto minmax(0, 1fr) auto",alignItems:"center",columnGap:1.5,width:"100%",p:2,mb:1,borderRadius:2,border:1,borderColor:"divider",bgcolor:"background.paper",transition:"box-shadow 0.2s","&:hover":{boxShadow:3}},HZn={"&::after":{content:'""',position:"absolute",inset:0,borderRadius:2,zIndex:1},"&:focus-visible":{outline:"none"},"&:focus-visible::after":{outline:"2px solid",outlineColor:"primary.main",outlineOffset:"2px"}},Nbr={position:"relative",zIndex:2},Obr=8,UUe=24,UZn=ho`
|
|
4014
4014
|
from { background-position: 0 0; }
|
|
4015
4015
|
to { background-position: 0 ${UUe}px; }
|
|
4016
|
-
`,Fbr={...$br,borderColor:"warning.main",borderLeft:4,borderLeftColor:"warning.main",bgcolor:e=>po(e.palette.warning.main,.08)},WZn={...Fbr,borderLeftColor:"transparent",backgroundImage:e=>`repeating-linear-gradient(to bottom, ${e.palette.warning.main} 0 ${Obr}px, transparent ${Obr}px ${UUe}px)`,backgroundOrigin:"border-box",backgroundRepeat:"repeat-y",backgroundSize:`4px ${UUe}px`,animation:`${UZn} 0.9s linear infinite`,"@media (prefers-reduced-motion: reduce)":{animation:"none"}},Bbr={"& .MuiButtonBase-root:focus-visible":{outline:"2px solid",outlineColor:"primary.main",outlineOffset:"2px"}},yv={card:$br,inProgressCard:Fbr,inProgressRunningCard:WZn,main:{minWidth:0,textAlign:"left"},stretchedNameLink:{display:"block",fontWeight:500,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",...HZn},meta:{display:"flex",alignItems:"center",gap:1,...Nbr,width:"fit-content",maxWidth:"100%",fontSize:"0.75rem",color:"text.secondary","& a, & p":{fontSize:"0.75rem"},...Bbr},id:{color:"text.disabled"},actions:{display:"flex",alignItems:"center",gap:1,flexShrink:0,...Nbr,...Bbr}};function Uye(e){let t=e.peakContextPct>0?` \xB7 \u2593 ${Math.round(e.peakContextPct)}%`:"";return`\u2191 ${sh(e.tokensUp)} \u2193 ${sh(e.tokensDown)} \xB7 \u23F1 ${_0(e.activeMs)}${t}`}var Hbr=E(F(),1),GZn={width:6,height:6,borderRadius:"50%",bgcolor:"currentColor",flexShrink:0};function zbr(){return(0,Hbr.jsx)(ie,{component:"span",sx:GZn})}var VK=E(F(),1),Ubr={display:"inline-flex",alignItems:"center",gap:.625,color:"warning.main",fontWeight:500,fontSize:"0.75rem",whiteSpace:"nowrap",borderRadius:1};function Wbr({item:e,openSession:t,onSelectSession:r}){let n=Ii();if(e.status!=="in-progress"||e.currentPhase==null)return null;let i=`phase ${e.currentPhase} of ${e.totalPhases??e.currentPhase}`,o=(0,VK.jsx)(zbr,{});if(!t)return(0,VK.jsxs)(ie,{component:"span",sx:Ubr,children:[o,i]});let a=()=>{r?.(t.id),n("/sessions")};return(0,VK.jsxs)(En,{sx:Ubr,title:`Open the ${t.status} session`,onClick:a,children:[o,i]})}var Cp=E(F(),1),VZn={display:"inline-flex",alignItems:"center",gap:.5},qZn={width:8,height:8,borderRadius:"50%",flexShrink:0},jZn={whiteSpace:"nowrap"};function YZn({type:e}){let t=Iye[e];return(0,Cp.jsxs)(ie,{component:"span",sx:VZn,children:[(0,Cp.jsx)(ie,{component:"span",sx:{...qZn,bgcolor:`${t}.main`}}),e]})}function KZn({item:e}){return e.usageTotal?(0,Cp.jsx)(lr,{title:Uye(e.usageTotal),children:(0,Cp.jsx)(ie,{component:"span",sx:jZn,children:`\u23F1 ${_0(e.usageTotal.activeMs)}`})}):null}function Gbr({item:e,openSession:t,onSelectSession:r}){return(0,Cp.jsxs)(ie,{sx:yv.meta,children:[(0,Cp.jsx)(ie,{component:"span",sx:yv.id,children:Yi(e.id)}),(0,Cp.jsx)(YZn,{type:e.type}),(0,Cp.jsx)(Wbr,{item:e,openSession:t,onSelectSession:r}),(0,Cp.jsx)(fL,{jiraKey:e.jiraKey}),(0,Cp.jsx)(uT,{githubIssue:e.githubIssue,variant:"icon"}),(0,Cp.jsx)(KZn,{item:e})]})}function Vbr(e,t){return e.filter(r=>vB(r)?.itemId===t).reduce((r,n)=>r&&r.startedAt>=n.startedAt?r:n,void 0)}var jbr=E(F(),1),XZn={todo:"\u25CB","in-progress":"\u25D4",done:"\u25CF",wontdo:"\u2715"},ZZn={todo:"text.disabled","in-progress":"warning.main",done:"success.main",wontdo:"error.main"};function QZn(e){return{fontSize:"1.125rem",flexShrink:0,color:ZZn[e]}}function qbr({status:e}){return(0,jbr.jsx)(Le,{sx:QZn(e),children:XZn[e]})}function Wye(e){return e.status==="todo"||e.status==="in-progress"}function JZn(e){if(e.status==="done")return e.totalPhases;if(e.status==="in-progress")return e.currentPhase}function eQn(e,t,r){return r?"complete":e<t?"done":e===t?"current":"remaining"}function Ybr(e){let t=e.totalPhases,r=JZn(e);if(!t||r==null)return;let n=e.status==="done";return{reached:r,total:t,segments:Array.from({length:t},(i,o)=>({phase:o+1,kind:eQn(o+1,r,n)}))}}var A$=E(F(),1),tQn={done:"text.secondary",current:"warning.main",remaining:"divider",complete:"success.main"},rQn={display:"inline-flex",alignItems:"center",gap:.5,flexShrink:0},nQn={fontSize:"0.6875rem",color:"text.secondary",fontVariantNumeric:"tabular-nums"},iQn={display:"inline-flex",alignItems:"center",gap:"2px"},oQn={width:6,height:12,borderRadius:"1px",flexShrink:0};function Kbr({item:e}){let t=Ybr(e);return t?(0,A$.jsxs)(ie,{sx:rQn,title:`Phase ${t.reached} of ${t.total}`,children:[(0,A$.jsx)(ie,{component:"span",sx:nQn,children:`${t.reached}/${t.total}`}),(0,A$.jsx)(ie,{component:"span",sx:iQn,"aria-hidden":!0,children:t.segments.map(r=>(0,A$.jsx)(ie,{component:"span","data-segment":r.kind,sx:{...oQn,bgcolor:tQn[r.kind]}},r.phase))})]}):null}var Txr=E(de(),1);var jye=E(de(),1);var yA=E(F(),1),aQn={minWidth:0,p:.5,borderRadius:"50%"};function Gye({tooltip:e,disabled:t,onClick:r,compact:n=!1}){return(0,yA.jsx)(lr,{title:e,children:(0,yA.jsx)(ie,{component:"span",sx:{display:"flex"},children:n?(0,yA.jsx)(Dt,{"aria-label":"Build",variant:"contained",color:"success",size:"small",disabled:t,sx:aQn,onClick:r,children:(0,yA.jsx)(Rg,{fontSize:"small"})}):(0,yA.jsx)(Dt,{startIcon:(0,yA.jsx)(Rg,{}),disabled:t,onClick:r,children:"Build"})})})}var WUe=E(F(),1);function Vye(e){let t=[];return e.exposeCodexActions&&t.push({kind:"codex",label:"with Codex"}),e.exposePiActions&&t.push({kind:"pi",label:"with pi"}),t}function qye({anchorEl:e,open:t,onClose:r,options:n,onSelect:i,stop:o}){return(0,WUe.jsx)(Os,{anchorEl:e,open:t,onClose:r,onClick:o,children:n.map(a=>(0,WUe.jsx)(pn,{onClick:s=>{o(s),i(a.kind)},children:a.label},a.kind))})}var vv=E(F(),1);function Xbr({tooltip:e,disabled:t,onBuild:r,onSelectHarness:n}){let i=Vye(o_()),o=(0,jye.useRef)(null),[a,s]=(0,jye.useState)(!1),l=u=>u.stopPropagation();return(0,vv.jsxs)(vv.Fragment,{children:[(0,vv.jsxs)(wS,{ref:o,variant:"contained",color:"success",size:"small",disabled:t,children:[(0,vv.jsx)(Gye,{tooltip:e,disabled:t,onClick:u=>{l(u),r()}}),i.length>0&&(0,vv.jsx)(Dt,{"aria-label":"Build with a different harness",onClick:u=>{l(u),s(!0)},children:(0,vv.jsx)(bd,{})})]}),(0,vv.jsx)(qye,{anchorEl:o.current,open:a,onClose:()=>s(!1),options:i,onSelect:u=>{s(!1),n(u)},stop:l})]})}var Zbr=E(F(),1),P$=st((0,Zbr.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96M19 18H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95C8.08 7.14 9.94 6 12 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11c1.56.1 2.78 1.41 2.78 2.96 0 1.65-1.35 3-3 3m-5.55-8h-2.9v3H8l4 4 4-4h-2.55z"}),"CloudDownloadOutlined");var l_=E(F(),1),sQn={vertical:"bottom",horizontal:"center"};function Yye({clone:e}){let{prompt:t,confirm:r,cancel:n,error:i,dismissError:o}=e;return(0,l_.jsxs)(l_.Fragment,{children:[t&&(0,l_.jsx)(Di,{title:"Clone repository",message:`Clone ${t.displayName} over SSH into ${t.cloneTarget}${t.node?` on ${t.node}`:""}?`,confirmLabel:"Clone",confirmColor:"primary",onConfirm:r,onCancel:n}),(0,l_.jsx)(pl,{open:!!i,autoHideDuration:8e3,onClose:o,anchorOrigin:sQn,children:(0,l_.jsx)(ai,{severity:"error",onClose:o,variant:"filled",children:i})})]})}var A0=E(de(),1);function GUe(e){return["backlog","clone",e]}function Kye(e,t){t(GUe(e.origin),void 0,{title:`Clone ${e.displayName}`,subtitle:e.origin,...e.node&&{node:e.node}})}function Qbr(e,t){return!!e&&e.length===t.length&&e.every((r,n)=>r===t[n])}function Jbr(e,t,r){let n=GUe(t.origin),i=new Set(e.filter(o=>Qbr(o.assistArgs,n)).map(o=>o.id));return Kye(t,r),{args:n,target:t.cloneTarget,node:t.node,preexisting:i}}function exr(e,t){if(!t.id){let n=e.find(i=>Qbr(i.assistArgs,t.args)&&!t.preexisting.has(i.id));return n?{type:"latch",id:n.id}:null}let r=e.find(n=>n.id===t.id);return r?r.status==="done"?{type:"done"}:r.status==="error"?{type:"error",message:r.error||"Clone failed."}:null:null}function Xye(e){let{setSelectedCwd:t}=$n(),{launchAssist:r}=il(),[n,i]=(0,A0.useState)(null),[o,a]=(0,A0.useState)(null),[s,l]=(0,A0.useState)(null),u=(0,A0.useCallback)(p=>{l(null),i(p)},[]),f=(0,A0.useCallback)(()=>i(null),[]),d=(0,A0.useCallback)(()=>l(null),[]),h=(0,A0.useCallback)(()=>{n&&(a(Jbr(e,n,r)),i(null))},[n,e,r]);return(0,A0.useEffect)(()=>{if(!o)return;let p=exr(e,o);p&&(p.type==="latch"?a(m=>m&&{...m,id:p.id}):p.type==="done"?(o.node?t(o.target,o.node):t(o.target),a(null)):(l(p.message),a(null)))},[e,o,t]),{prompt:n,requestClone:u,confirm:h,cancel:f,error:s,dismissError:d}}function L$(e,t){return`Not cloned ${e?`on ${e}`:"locally"} \u2014 click to clone into ${t}`}var Q2=E(F(),1),lQn={border:1,borderStyle:"dashed"};function txr({target:e}){let t=Xye(Hye());return(0,Q2.jsxs)(Q2.Fragment,{children:[(0,Q2.jsx)(lr,{title:L$(e.node,e.cloneTarget),children:(0,Q2.jsx)(ir,{"aria-label":"Clone",size:"small",sx:lQn,onClick:r=>{r.stopPropagation(),t.requestClone(e)},children:(0,Q2.jsx)(P$,{fontSize:"small"})})}),(0,Q2.jsx)(Yye,{clone:t})]})}var KK=E(de(),1);var qK=E(de(),1);function rxr(e,t,r,n){let i=Pa(),o=yr(),a=(0,qK.useRef)(!1),[s,l]=(0,qK.useState)(!1),[u,f]=(0,qK.useState)(null);return{busy:s,error:u,clearError:()=>f(null),confirm:async()=>{if(!a.current){a.current=!0,l(!0);try{await bL(e,t,i,o)}catch{f(r),a.current=!1,l(!1);return}await n()}}}}var jK=E(F(),1),cQn={done:{verb:"done",action:"Mark done"},wontdo:{verb:"won't do",action:"Won't do"}};function nxr({itemId:e,status:t,target:r,onClose:n}){let{verb:i,action:o}=cQn[t],a=Yi(e),{busy:s,error:l,clearError:u,confirm:f}=rxr(e,t,`Failed to mark item ${a} as ${i}`,async()=>{n(),await r.onClosed()});return(0,jK.jsxs)(ia,{children:[(0,jK.jsx)(Di,{title:`Mark ${a} ${i}`,message:`${r.currentPhase??0} of ${r.totalPhases??0} phases completed. Mark this backlog item as ${i}?`,confirmLabel:o,busy:s,onConfirm:f,onCancel:n}),(0,jK.jsx)(Zl,{error:l,onClose:u})]})}var VUe=E(F(),1),uQn=[{status:"done",label:"Mark done"},{status:"wontdo",label:"Won't do"}];function ixr({anchorEl:e,open:t,onClose:r,onSelect:n,stop:i}){return(0,VUe.jsx)(Os,{anchorEl:e,open:t,onClose:r,onClick:i,children:uQn.map(({status:o,label:a})=>(0,VUe.jsx)(pn,{onClick:s=>{i(s),n(o)},children:a},o))})}var oxr=E(F(),1),axr=st((0,oxr.jsx)("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"MoreVert");var qUe=E(F(),1);function sxr({anchorRef:e,onClick:t}){return(0,qUe.jsx)(ir,{ref:e,"aria-label":"More actions",size:"small",onClick:t,children:(0,qUe.jsx)(axr,{fontSize:"small"})})}var YK=E(F(),1);function lxr({anchorRef:e,tooltip:t,disabled:r,onBuild:n,onMore:i}){return(0,YK.jsxs)(ie,{sx:{display:"flex",alignItems:"center",gap:.5},children:[(0,YK.jsx)(Gye,{compact:!0,tooltip:t,disabled:r,onClick:n}),(0,YK.jsx)(sxr,{anchorRef:e,onClick:i})]})}var c_=E(F(),1);function cxr({itemId:e,tooltip:t,disabled:r,onBuild:n,closeTarget:i}){let o=(0,KK.useRef)(null),[a,s]=(0,KK.useState)(!1),[l,u]=(0,KK.useState)(null),f=d=>d.stopPropagation();return(0,c_.jsxs)(c_.Fragment,{children:[(0,c_.jsx)(lxr,{anchorRef:o,tooltip:t,disabled:r,onBuild:d=>{f(d),n()},onMore:d=>{f(d),s(!0)}}),(0,c_.jsx)(ixr,{anchorEl:o.current,open:a,onClose:()=>s(!1),onSelect:d=>{s(!1),u(d)},stop:f}),l&&(0,c_.jsx)(nxr,{itemId:e,status:l,target:i,onClose:()=>u(null)})]})}var Zye=E(de(),1),jUe=(0,Zye.createContext)(()=>{});function uxr(){return(0,Zye.useContext)(jUe)}var Qye=E(F(),1);function fxr({session:e}){let t=gy(uxr());return(0,Qye.jsxs)(Dt,{variant:"contained",size:"small",startIcon:(0,Qye.jsx)(Dme,{}),onClick:r=>{r.stopPropagation(),t(e.id)},children:["Session ",e.id]})}function dxr(e,t,r,n){let i=r.node?[{node:r.node}]:[];e(["backlog","run",Yi(t),...n],r.cwd,...i)}function fQn(e,t){let r=e.assistArgs;if(r?.[0]!=="backlog"||r[1]!=="run"||!r[2])return!1;try{return tte(r[2])===t}catch{return!1}}function hxr(e,t){return e.find(r=>r.status!=="done"&&r.status!=="error"&&(fQn(r,t)||vB(r)?.itemId===t))}var Jye=E(de(),1),YUe=(0,Jye.createContext)({nodes:null,names:[],visible:!1,selected:void 0,select:()=>{}});function ef(){return(0,Jye.useContext)(YUe)}function e1e(){let{nodes:e,selected:t}=ef();return t&&t!==e?.local?t:void 0}var gxr=E(de(),1);var t1e=E(de(),1);function pxr(e,t){return Promise.all(t.map(async r=>{let n=await dQn(e,r).catch(()=>({}));return[r,n]}))}async function dQn(e,t){let r=await fetch(qr(`/api/repo-location?origin=${encodeURIComponent(e)}`,t||void 0));return r.ok?r.json():{}}var KUe="\0";function mxr(e,t){let[r,n]=(0,t1e.useState)(null);return(0,t1e.useEffect)(()=>{if(!e||!t)return;let i=!1;return pxr(e,t.split(KUe)).then(o=>{i||n({origin:e,byNode:Object.fromEntries(o)})}),()=>{i=!0}},[e,t]),r}function r1e(e,t){let{cloneOn:r,originOf:n}=$n(),i=e?n(e):void 0,o=t.filter(s=>!e||!r(e,s)).map(s=>s??"").join(KUe),a=mxr(i,o);return(0,gxr.useCallback)(s=>{let l=e?r(e,s):void 0;if(l)return{kind:"cloned",cwd:l};let u=a&&a.origin===i?a.byNode[s??""]:void 0;return u?.cwd?{kind:"cloned",cwd:u.cwd}:i&&u?.cloneTarget?{kind:"clonable",origin:i,cloneTarget:u.cloneTarget}:{kind:"unavailable"}},[e,r,i,a])}var M$=E(de(),1);var n1e=E(de(),1);function i1e(e){let t=(0,n1e.useRef)(null);return(0,n1e.useEffect)(()=>{e&&t.current?.scrollIntoView({block:"nearest"})},[e]),t}var vxr=E(F(),1);function yxr({cwd:e,selected:t,highlighted:r,onHover:n,onSelect:i}){let o=i1e(r);return(0,vxr.jsx)(pn,{ref:o,selected:t,title:e,onClick:i,onMouseEnter:n,sx:{fontSize:12,display:"flex",justifyContent:"space-between",gap:1,...r&&{bgcolor:"action.hover"}},children:bv(e)})}var XUe=E(F(),1);function o1e({repos:e,selected:t,highlight:r,onHighlight:n,onSelect:i}){return(0,XUe.jsx)(Fp,{dense:!0,children:e.map((o,a)=>(0,XUe.jsx)(yxr,{cwd:o,selected:o===t,highlighted:a===r,onHover:()=>n(a),onSelect:()=>i(o)},o))})}var a1e=E(de(),1);function u_(e,t,r,n){let[i,o]=(0,a1e.useState)(0);return(0,a1e.useEffect)(()=>{o(0)},[t]),{highlight:i,setHighlight:o,onKeyDown:s=>{let l=e.length;if(s.key==="ArrowDown")s.preventDefault(),l>0&&o(u=>(u+1)%l);else if(s.key==="ArrowUp")s.preventDefault(),l>0&&o(u=>(u-1+l)%l);else if(s.key==="Enter"){s.preventDefault();let u=e[i];u!==void 0&&(r(u),n())}else s.key==="Escape"&&(s.preventDefault(),n())}}}var XK=E(F(),1);function bv(e){let t=e.includes("\\")?"\\":"/";return e.split(t).filter(Boolean).pop()??e}var hQn={...SB};function bxr({repos:e,selected:t,onSelect:r,close:n,initialFilter:i=""}){let[o,a]=(0,M$.useState)(i),s=(0,M$.useRef)(null);(0,M$.useEffect)(()=>{s.current?.focus()},[]);let l=o.trim().toLowerCase(),u=l?e.filter(m=>m.toLowerCase().includes(l)):e,{highlight:f,setHighlight:d,onKeyDown:h}=u_(u,l,r,n);return(0,XK.jsxs)(un,{elevation:4,sx:hQn,children:[(0,XK.jsx)(cT,{inputRef:s,value:o,onChange:a,onKeyDown:h,placeholder:"Filter repos..."}),(0,XK.jsx)(o1e,{repos:u,selected:t,highlight:f,onHighlight:d,onSelect:m=>{r(m),n()}})]})}function s1e(e,t){return{origin:e.origin,cloneTarget:e.cloneTarget,displayName:bv(e.origin),node:t}}function xxr(){let e=Pa(),t=e1e(),r=r1e(e??"",[t])(t);return e?r.kind==="cloned"?{kind:"ready",cwd:r.cwd,node:t}:r.kind==="clonable"?{kind:"clone",prompt:s1e(r,t)}:{kind:"unavailable",node:t??"this machine"}:{kind:"ready",node:t}}function Sxr(e){return e?`Not cloned on ${e}`:"Build"}var ZK=E(F(),1);function l1e({itemId:e,compact:t}){let{launchAssist:r}=il(),n=xxr(),i=hxr(Hye(),e),[o,a]=(0,Txr.useState)(!1);if(n.kind==="clone")return(0,ZK.jsx)(txr,{target:n.prompt});if(i)return(0,ZK.jsx)(fxr,{session:i});let s=n.kind==="unavailable"?n.node:void 0,l=o||!!s,u=d=>{l||n.kind!=="ready"||(a(!0),dxr(r,e,n,d))},f=Sxr(s);return t?(0,ZK.jsx)(cxr,{itemId:e,tooltip:f,disabled:l,onBuild:()=>u([]),closeTarget:t}):(0,ZK.jsx)(Xbr,{tooltip:f,disabled:l,onBuild:()=>u([]),onSelectHarness:d=>u(["--harness",d])})}var Cxr=E(de(),1);var I$=E(F(),1);function wxr({itemId:e,starred:t,onToggled:r}){let n=Pa(),i=yr(),[o,a]=(0,Cxr.useState)(!1);return(0,I$.jsx)(lr,{title:t?"Unstar":"Star",children:(0,I$.jsx)("span",{children:(0,I$.jsx)(ir,{"aria-label":t?"Unstar":"Star","aria-pressed":t,color:t?"warning":"default",size:"small",disabled:o,onClick:async l=>{if(l.stopPropagation(),!o){a(!0);try{await xte(e,!t,n,i),await r()}finally{a(!1)}}},children:t?(0,I$.jsx)(mge,{}):(0,I$.jsx)(gge,{})})})})}var kxr=E(F(),1),_xr=st((0,kxr.jsx)("path",{d:"M22 7h-9v2h9zm0 8h-9v2h9zM5.54 11 2 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41zm0 8L2 15.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41z"}),"Checklist");var QK=E(F(),1),pQn={display:"inline-flex",alignItems:"center",gap:.375,flexShrink:0,fontSize:"0.71875rem",color:"text.secondary","& svg":{fontSize:14}};function Exr({count:e}){return e<1?null:(0,QK.jsx)(lr,{title:`${e} incomplete subtask${e===1?"":"s"}`,children:(0,QK.jsxs)(ie,{component:"span",sx:pQn,children:[(0,QK.jsx)(_xr,{}),e]})})}var J2=E(F(),1);function Rxr({item:e,onReload:t}){return(0,J2.jsxs)(J2.Fragment,{children:[(0,J2.jsx)(Exr,{count:e.incompleteSubtasks}),(0,J2.jsx)(Kbr,{item:e}),(0,J2.jsx)(wxr,{itemId:e.id,starred:e.starred,onToggled:t}),Wye(e)&&(0,J2.jsx)(l1e,{itemId:e.id,compact:{currentPhase:e.currentPhase,totalPhases:e.totalPhases,onClosed:t}})]})}var eS=E(F(),1);function mQn(e,t){return e?t?yv.inProgressRunningCard:yv.inProgressCard:yv.card}function Axr({item:e,to:t,socket:r,onReload:n}){let i=Vbr(r.sessions,e.id),o=e.status==="in-progress",a=o&&i?.status==="running";return(0,eS.jsxs)(ie,{sx:mQn(o,a),children:[(0,eS.jsx)(qbr,{status:e.status}),(0,eS.jsxs)(ie,{sx:yv.main,children:[(0,eS.jsx)(Kr,{component:Cs,to:t,underline:"none",title:e.name,sx:yv.stretchedNameLink,children:e.name}),(0,eS.jsx)(Gbr,{item:e,openSession:i,onSelectSession:r.selectSession})]}),(0,eS.jsx)(ie,{sx:yv.actions,children:(0,eS.jsx)(Rxr,{item:e,onReload:n})})]})}var Lxr=E(F(),1),gQn={all:"items",story:"stories",bug:"bugs"},yQn={textAlign:"center",color:"text.disabled",py:6,px:2};function Pxr({query:e,typeFilter:t}){let r=gQn[t],n=e.trim()?`No ${r} match your search.`:`No ${r} in the backlog.`;return(0,Lxr.jsx)(ie,{sx:yQn,children:n})}var xv=E(F(),1),vQn={display:"flex",justifyContent:"center",py:6};function Mxr({loading:e,error:t,query:r,typeFilter:n,items:i,socket:o,itemPath:a,onReload:s}){if(e)return(0,xv.jsx)(ie,{sx:vQn,children:(0,xv.jsx)(oo,{})});let l=t&&(0,xv.jsx)(ai,{severity:"error",children:t});return i.length===0?l||(0,xv.jsx)(Pxr,{query:r,typeFilter:n}):(0,xv.jsxs)(xv.Fragment,{children:[l,i.map(u=>(0,xv.jsx)(Axr,{item:u,to:a(u),socket:o,onReload:s},u.id))]})}var D$=E(de(),1);function bQn(e){let t=new URLSearchParams;for(let n of e)t.append("knownCwd",n);let r=t.toString();return r?`/api/backlog/summary?${r}`:"/api/backlog/summary"}async function Ixr({cwd:e,node:t,knownCwds:r,signal:n}){return(await fetch(jl(bQn(r),e,t),{signal:n})).json()}function Dxr(){let{repos:e,selectedCwd:t,cloneOn:r}=$n(),n=e1e(),[i,o]=(0,D$.useState)([]),a=(0,D$.useMemo)(()=>e.map(l=>r(l,n)).filter(l=>!!l),[e,r,n]),s=t?r(t,n):void 0;return(0,D$.useEffect)(()=>{let l=new AbortController;return Ixr({cwd:s,node:n,knownCwds:a,signal:l.signal}).then(o).catch(()=>{}),()=>l.abort()},[a,s,n]),{summaries:i,node:n}}var c1e=E(F(),1),xQn={borderStyle:"dashed"};function Nxr({summary:e,node:t,onSelectCwd:r,onRequestClone:n}){let{origin:i,displayName:o,openCount:a,isCurrent:s,cwd:l,cloneTarget:u}=e,f=!l&&!!u,d=l?()=>r(l):f&&u?()=>n({origin:i,cloneTarget:u,displayName:o,node:t}):void 0,h=(0,c1e.jsx)(tn,{label:`${o} (${a})`,size:"small",color:s?"primary":"default",variant:s?"filled":"outlined",disabled:!l&&!f,onClick:d,icon:f?(0,c1e.jsx)(P$,{}):void 0,sx:f?xQn:void 0});return!f||!u?h:(0,c1e.jsx)(lr,{describeChild:!0,title:L$(t,u),children:h})}var JK=E(F(),1),SQn={flexWrap:"wrap",gap:1,mb:2};function Oxr({sessions:e}){let{summaries:t,node:r}=Dxr(),{setSelectedCwd:n}=$n(),i=Xye(e);return t.length===0?null:(0,JK.jsxs)(_t,{direction:"row",sx:SQn,children:[t.map(o=>(0,JK.jsx)(Nxr,{summary:o,node:r,onSelectCwd:a=>r?n(a,r):n(a),onRequestClone:i.requestClone},o.origin)),(0,JK.jsx)(Yye,{clone:i})]})}var $xr=E(F(),1);function Bxr({value:e,onChange:t}){return(0,$xr.jsx)(Qn,{"data-backlog-focus":"search",autoFocus:!0,fullWidth:!0,size:"small",placeholder:"Search backlog\u2026",value:e,onChange:r=>t(r.target.value),sx:{mb:2}})}var u1e=E(de(),1);var f1e=E(F(),1);async function TQn(){return(await(await fetch("/api/backups/list")).json())[0]}function Fxr(){let[e,t]=(0,u1e.useState)();return(0,u1e.useEffect)(()=>{TQn().then(t)},[]),e?(0,f1e.jsx)(lr,{title:new Date(e.createdAt).toLocaleString(),children:(0,f1e.jsxs)(Kr,{component:Cs,to:"/backups",underline:"hover",color:"text.secondary",variant:"body2",children:["Last backed up ",_o(String(e.createdAt))]})}):null}var N$=E(F(),1);function zxr(){let[e,t]=R$();return(0,N$.jsxs)(Eu,{value:e,exclusive:!0,size:"small","aria-label":"Status filter",onChange:(r,n)=>{n!==null&&t(n)},children:[(0,N$.jsx)(bs,{value:"todo",children:"Todo"}),(0,N$.jsx)(bs,{value:"done",children:"Done"}),(0,N$.jsx)(bs,{value:"all",children:"All"})]})}var O$=E(F(),1);function Hxr({value:e,onChange:t}){return(0,O$.jsxs)(Eu,{value:e,exclusive:!0,size:"small","aria-label":"Type filter",onChange:(r,n)=>{n!==null&&t(n)},children:[(0,O$.jsx)(bs,{value:"all",children:"All"}),(0,O$.jsx)(bs,{value:"story",children:"Stories"}),(0,O$.jsx)(bs,{value:"bug",children:"Bugs"})]})}var f_=E(F(),1),CQn={justifyContent:"space-between",alignItems:"center",mb:3},wQn={fontWeight:600},kQn={alignItems:"center"};function Uxr({typeFilter:e,onTypeFilterChange:t}){return(0,f_.jsxs)(_t,{direction:"row",sx:CQn,children:[(0,f_.jsx)(Le,{variant:"h5",sx:wQn,children:"Backlog"}),(0,f_.jsxs)(_t,{direction:"row",spacing:2,sx:kQn,children:[(0,f_.jsx)(Fxr,{}),(0,f_.jsx)(Hxr,{value:e,onChange:t}),(0,f_.jsx)(zxr,{})]})]})}var tS=E(F(),1);function Gxr({items:e,loading:t,error:r,socket:n,onReload:i}){let o=Pa(),a=yr(),{query:s,setQuery:l,results:u,loading:f}=Dbr(),[d,h]=(0,Wxr.useState)("all"),p=u??e,m=d==="all"?p:p.filter(g=>g.type===d);return(0,tS.jsxs)(tS.Fragment,{children:[(0,tS.jsx)(Uxr,{typeFilter:d,onTypeFilterChange:h}),(0,tS.jsx)(Bxr,{value:s,onChange:l}),(0,tS.jsx)(Oxr,{sessions:n.sessions}),(0,tS.jsx)(Mxr,{loading:t||f,error:u?null:r,query:s,typeFilter:d,items:m,socket:n,itemPath:g=>fT(g.id,o,a),onReload:i})]})}var b1e=E(de(),1);var vA=E(de(),1);async function ZUe(e,t,r){let n=await fetch(jl(`/api/items/${Yi(e)}`,t.cwd,t.node),{signal:r});return n.ok?n.json():null}function Vxr(e){let t=Pa(),r=yr(),[n,i]=(0,vA.useState)(null),[o,a]=(0,vA.useState)(!0),s=(0,vA.useCallback)(async()=>{i(await ZUe(e,{cwd:t,node:r}))},[e,t,r]);return(0,vA.useEffect)(()=>{let l=new AbortController,{signal:u}=l;return a(!0),(async()=>{try{let f=await ZUe(e,{cwd:t,node:r},u);if(u.aborted)return;i(f),a(!1)}catch(f){if(!u.aborted)throw f}})(),()=>l.abort()},[e,t,r]),{item:n,loading:o,reload:s}}var d_={description:"item-section-description",acceptanceCriteria:"item-section-acceptance-criteria",subtasks:"item-section-subtasks",plan:"item-section-plan",activity:"item-section-activity",comments:"item-section-comments"},eX=140,QUe="--pinned-header-height",d1e=`var(${QUe}, ${eX}px)`,qxr=`calc(${d1e} + 8px)`;function ag(e){return{id:d_[e],sx:{mb:2,scrollMarginTop:qxr}}}function h1e(e){return{id:`item-phase-${e}`,sx:{scrollMarginTop:qxr}}}var h_=E(F(),1);function jxr({criteria:e}){return e.length===0?null:(0,h_.jsxs)(ie,{...ag("acceptanceCriteria"),children:[(0,h_.jsx)(Le,{variant:"overline",sx:{color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"},children:"Acceptance Criteria"}),(0,h_.jsx)(Q0,{disablePadding:!0,sx:{maxWidth:"72ch"},children:e.map((t,r)=>(0,h_.jsxs)(ES,{disableGutters:!0,disablePadding:!0,sx:{py:.5,display:"flex",alignItems:"baseline"},children:[(0,h_.jsxs)(Le,{component:"span",sx:{color:"text.secondary",mr:1},children:[r+1,"."]}),(0,h_.jsx)(Nu,{component:"span",className:"markdown",html:U9(t)})]},t))})]})}var tX=E(F(),1),_Qn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function Yxr({description:e}){return e?(0,tX.jsxs)(ie,{...ag("description"),children:[(0,tX.jsx)(Le,{variant:"overline",sx:_Qn,children:"Description"}),(0,tX.jsx)(Yw,{content:e,renderMermaid:!0})]}):null}var n2r=E(de(),1);function Kxr(e,t=10){let r=i=>e.filter(o=>o.kind===i).reverse(),n=r("commit");return{branches:r("branch"),commits:n.slice(0,t),overflowCommits:n.slice(t),prs:r("pr"),slacks:r("slack"),sessions:r("session")}}var Zxr=E(F(),1),EQn={color:"text.secondary",alignSelf:"flex-start",textAlign:"left"};function Xxr({hiddenCount:e,expanded:t,onToggle:r}){return e===0?null:(0,Zxr.jsx)(Kr,{component:"button",type:"button",variant:"body2",underline:"hover",sx:EQn,onClick:n=>{n.stopPropagation(),r()},children:t?"Show fewer commits":`\u2026 and ${e} more commits`})}var bA=E(F(),1),RQn={display:"flex",alignItems:"center",gap:1},AQn={color:"text.secondary",fontFamily:"monospace"},PQn={flex:1,overflowWrap:"anywhere"},LQn={color:"text.disabled","&:hover":{color:"text.primary"}};function Qxr({conversation:e}){let{resumeSession:t}=il(),r=n=>{n.stopPropagation(),t(e.sessionId,e.cwd??"",e.title,e.harness)};return(0,bA.jsxs)(ie,{sx:RQn,children:[(0,bA.jsx)(Le,{variant:"body2",component:"span",sx:AQn,children:"session"}),(0,bA.jsx)(Le,{variant:"body2",component:"span",sx:PQn,children:e.title??e.sessionId}),(0,bA.jsx)(ir,{size:"small",title:"Resume",sx:LQn,onClick:r,children:(0,bA.jsx)(Rg,{sx:{fontSize:14}})})]})}var e2r=E(F(),1),MQn={color:"text.disabled",ml:1};function Jxr({gitRef:e}){return e.kind!=="commit"||!e.createdAt?null:(0,e2r.jsx)(ie,{component:"span",sx:MQn,children:IQn(e.createdAt)})}function IQn(e){return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function t2r(e){if(e.kind==="commit"){let t=e.title?` ${e.title}`:"";return`${e.ref.slice(0,8)}${t}`}if(e.kind==="pr"){let t=e.title?` ${e.title}`:"",r=e.state?` (${e.state.toLowerCase()})`:"";return`#${e.ref}${t}${r}`}return e.kind==="slack"||e.kind==="session"?e.title??e.ref:e.ref}var Sv=E(F(),1),DQn={color:"text.secondary",mr:1,fontFamily:"monospace"};function NQn({gitRef:e}){let t=t2r(e);return!e.url||e.kind==="session"?(0,Sv.jsx)(Sv.Fragment,{children:t}):(0,Sv.jsx)(Kr,{href:e.url,target:"_blank",rel:"noopener",onClick:r=>r.stopPropagation(),children:t})}function r2r({gitRef:e}){return(0,Sv.jsxs)(Le,{variant:"body2",children:[(0,Sv.jsx)(ie,{component:"span",sx:DQn,children:e.kind}),(0,Sv.jsx)(NQn,{gitRef:e}),(0,Sv.jsx)(Jxr,{gitRef:e})]})}var p_=E(F(),1),OQn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function i2r({gitRefs:e,conversations:t=[]}){let[r,n]=(0,n2r.useState)(!1),{branches:i,commits:o,overflowCommits:a,prs:s,slacks:l}=Kxr(e),u=[...i,...o,...r?a:[],...s,...l];return u.length===0&&t.length===0?null:(0,p_.jsxs)(ie,{...ag("activity"),children:[(0,p_.jsx)(Le,{variant:"overline",sx:OQn,children:"Activity"}),(0,p_.jsxs)(_t,{spacing:1,children:[u.map(f=>(0,p_.jsx)(r2r,{gitRef:f},`${f.kind}:${f.ref}`)),t.map(f=>(0,p_.jsx)(Qxr,{conversation:f},f.sessionId)),(0,p_.jsx)(Xxr,{hiddenCount:a.length,expanded:r,onToggle:()=>n(f=>!f)})]})]})}var xA=E(F(),1),BQn={alignItems:"center",fontSize:"0.75rem",color:"text.secondary",mb:.5},$Qn={color:"text.disabled"},FQn={fontWeight:500},zQn={summary:"Phase summary",comment:"Comment"};function o2r({comment:e}){return(0,xA.jsxs)(_t,{direction:"row",spacing:.5,sx:BQn,children:[e.id!==void 0&&(0,xA.jsxs)(Le,{variant:"caption",sx:$Qn,children:["#",e.id]}),(0,xA.jsx)(Le,{variant:"caption",sx:FQn,children:zQn[e.type]}),e.phase!==void 0&&(0,xA.jsxs)(Le,{variant:"caption",children:["\xB7 Phase ",e.phase]}),(0,xA.jsxs)(Le,{variant:"caption",children:["\xB7 ",HQn(e.timestamp)]})]})}function HQn(e){return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}var a2r=E(F(),1),s2r=st((0,a2r.jsx)("path",{d:"M16 9v10H8V9zm-1.5-6h-5l-1 1H5v2h14V4h-3.5zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2z"}),"DeleteOutlined");var JUe=E(de(),1);async function l2r(e,t,r,n){let i=await fetch(jl(`/api/items/${Yi(e)}/comments/${t}`,r,n),{method:"DELETE"});if(!i.ok){let o=await i.json().catch(()=>{});throw new Error(o?.error??`Failed to delete comment (${i.status})`)}}var Tv=E(F(),1),UQn={mt:-.5,mr:-.5,color:"text.secondary"};function c2r({itemId:e,commentId:t,onDeleted:r}){let n=Pa(),i=yr(),[o,a]=(0,JUe.useState)(!1),[s,l]=(0,JUe.useState)(),u=()=>l(void 0);return(0,Tv.jsxs)(Tv.Fragment,{children:[o&&(0,Tv.jsx)(Di,{message:"Are you sure you want to delete this comment?",onConfirm:async()=>{a(!1);try{await l2r(e,t,n,i),await r()}catch(f){l(f instanceof Error?f.message:"Failed to delete comment")}},onCancel:()=>a(!1)}),(0,Tv.jsx)(pl,{open:s!==void 0,autoHideDuration:6e3,onClose:u,children:(0,Tv.jsx)(ai,{severity:"error",variant:"filled",onClose:u,children:s})}),(0,Tv.jsx)(ir,{"aria-label":"Delete comment",size:"small",sx:UQn,onClick:()=>a(!0),children:(0,Tv.jsx)(s2r,{fontSize:"inherit"})})]})}var SA=E(F(),1),WQn={summary:{bgcolor:"warning.light",borderColor:"warning.dark"},comment:{bgcolor:"action.selected",borderColor:"divider"}},GQn={justifyContent:"space-between",alignItems:"flex-start"},VQn={color:"text.primary",whiteSpace:"pre-wrap"};function qQn(e){return{p:1.5,bgcolor:e.bgcolor,borderColor:e.borderColor}}function u2r({comment:e,itemId:t,onDeleted:r}){return(0,SA.jsxs)(un,{variant:"outlined",sx:qQn(WQn[e.type]),children:[(0,SA.jsxs)(_t,{direction:"row",sx:GQn,children:[(0,SA.jsx)(o2r,{comment:e}),e.id!==void 0&&t!==void 0&&r&&(0,SA.jsx)(c2r,{itemId:t,commentId:e.id,onDeleted:r})]}),(0,SA.jsx)(Le,{variant:"body2",sx:VQn,children:e.text})]})}var B$=E(F(),1),jQn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function f2r({comments:e,itemId:t,onCommentDeleted:r}){return e.length===0?null:(0,B$.jsxs)(ie,{...ag("comments"),children:[(0,B$.jsx)(Le,{variant:"overline",sx:jQn,children:"Comments"}),(0,B$.jsx)(_t,{spacing:1,children:e.map((n,i)=>(0,B$.jsx)(u2r,{comment:n,itemId:t,onDeleted:r},`${n.timestamp}-${i}`))})]})}var d2r=E(F(),1);function $$({total:e,sx:t}){return(0,d2r.jsx)(Le,{sx:t,children:Uye(e)})}var p2r=E(F(),1),YQn={color:"text.secondary",fontSize:"0.75rem"};function h2r({usage:e}){let t={tokensUp:e.reduce((r,n)=>r+n.tokensUp,0),tokensDown:e.reduce((r,n)=>r+n.tokensDown,0),activeMs:e.reduce((r,n)=>r+n.activeMs,0),peakContextPct:e.reduce((r,n)=>Math.max(r,n.peakContextPct),0)};return(0,p2r.jsx)($$,{total:t,sx:YQn})}var rS=E(F(),1);function m2r({checks:e}){return(0,rS.jsxs)(ie,{sx:{mt:1,pt:1},children:[(0,rS.jsx)(Vi,{sx:{mb:1}}),(0,rS.jsx)(Le,{variant:"overline",sx:{color:"text.disabled",letterSpacing:"0.08em"},children:"Manual Checks"}),(0,rS.jsx)(Q0,{disablePadding:!0,sx:{ml:.5,mt:.5},children:e.map(t=>(0,rS.jsxs)(ES,{disableGutters:!0,disablePadding:!0,sx:{py:.25,display:"flex",alignItems:"baseline"},children:[(0,rS.jsx)(Le,{component:"span",sx:{mr:1,fontSize:"0.875rem",color:"text.secondary"},children:"\u2610"}),(0,rS.jsx)(Nu,{component:"span",className:"markdown",sx:{fontSize:"0.875rem",color:"text.secondary"},html:U9(t)})]},t))})]})}var p1e={done:{borderColor:"success.light",bgcolor:"success.light"},current:{borderColor:"info.main",bgcolor:"info.light",ring:"info.light"},upcoming:{borderColor:"divider",bgcolor:"background.paper"}};function g2r(e){let t=p1e[e];return{p:2,borderColor:t.ring?"info.main":t.borderColor,bgcolor:t.bgcolor,...t.ring?{boxShadow:"0 0 0 2px"}:{}}}var y2r={done:"\u2713",current:"\u2022",upcoming:"\u2022"};var x2r=E(de(),1);var v2r=E(de(),1),Cv=E(F(),1);function b2r({phaseName:e,onConfirm:t,onCancel:r}){let[n,i]=(0,v2r.useState)("");return(0,Cv.jsxs)(Wl,{open:!0,onClose:r,maxWidth:"xs",fullWidth:!0,children:[(0,Cv.jsxs)(wu,{children:["Rewind to ",e,"?"]}),(0,Cv.jsxs)(Cu,{children:[(0,Cv.jsx)(Le,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"This will mark all later phases as incomplete."}),(0,Cv.jsx)(Qn,{fullWidth:!0,multiline:!0,rows:3,size:"small",placeholder:"Reason for rewinding...",value:n,onChange:o=>i(o.target.value)})]}),(0,Cv.jsxs)(cd,{children:[(0,Cv.jsx)(Dt,{onClick:r,children:"Cancel"}),(0,Cv.jsx)(Dt,{variant:"contained",color:"warning",disabled:n.trim().length===0,onClick:()=>t(n.trim()),children:"Rewind"})]})]})}var TA=E(F(),1);function S2r({itemId:e,phaseNumber:t,phaseName:r,onRewound:n}){let i=Pa(),o=yr(),[a,s]=(0,x2r.useState)(!1);return(0,TA.jsxs)(TA.Fragment,{children:[(0,TA.jsx)(Dt,{size:"small",color:"warning",variant:"outlined",onClick:()=>s(!0),sx:{ml:"auto",textTransform:"none",fontSize:"0.75rem"},children:"Rewind"}),a&&(0,TA.jsx)(b2r,{phaseName:r,onConfirm:async l=>{await tit(e,t,l,i,o),await n()},onCancel:()=>s(!1)})]})}var F$=E(F(),1),KQn={done:{label:"Done",color:"success"},current:{label:"In Progress",color:"info"},upcoming:{label:"Upcoming",color:"default"}},XQn={alignItems:"center",mb:1},ZQn={fontWeight:500},QQn={fontWeight:500,fontSize:"0.75rem"};function T2r({phase:e,index:t,status:r,itemId:n,onRewind:i}){let o=KQn[r],a=r==="done"&&n!==void 0&&i;return(0,F$.jsxs)(_t,{direction:"row",spacing:1,sx:XQn,children:[(0,F$.jsxs)(Le,{sx:ZQn,children:["Phase ",t+1,": ",e.name]}),(0,F$.jsx)(tn,{label:o.label,size:"small",color:o.color,sx:QQn}),a&&(0,F$.jsx)(S2r,{itemId:n,phaseNumber:t+1,phaseName:e.name,onRewound:i})]})}var rX=E(F(),1),JQn={color:"text.secondary",fontSize:"0.75rem",letterSpacing:"0.08em",display:"block"},eJn={color:"text.secondary",fontSize:"0.75rem",fontFamily:"monospace",display:"block"};function C2r({sessions:e}){return(0,rX.jsxs)(ie,{sx:{mb:1},children:[(0,rX.jsx)(Le,{variant:"overline",sx:JQn,children:"Sessions"}),e.map(t=>(0,rX.jsx)(Le,{sx:eJn,children:`${t.hostname} / ${t.osUser} / ${t.claudeSessionId}`},t.claudeSessionId))]})}var k2r=E(F(),1),tJn={color:"text.secondary",fontSize:"0.75rem",mb:1,display:"block"};function w2r({usage:e}){return(0,k2r.jsx)($$,{total:e,sx:tJn})}var z$=E(F(),1);function _2r({tasks:e,marker:t}){return(0,z$.jsx)(Q0,{disablePadding:!0,sx:{ml:.5},children:e.map(r=>(0,z$.jsxs)(ES,{disableGutters:!0,disablePadding:!0,sx:{py:.25,display:"flex",alignItems:"baseline"},children:[(0,z$.jsx)(Le,{component:"span",sx:{color:"text.secondary",mr:1},children:t}),(0,z$.jsx)(Nu,{component:"span",className:"markdown",html:U9(r.task)})]},r.task))})}var m_=E(F(),1);function E2r({phase:e,index:t,status:r,itemId:n,usage:i,sessions:o,onRewind:a}){let s=e.manualChecks??[],l=h1e(t);return(0,m_.jsxs)(un,{variant:"outlined",id:l.id,sx:{...g2r(r),...l.sx},children:[(0,m_.jsx)(T2r,{phase:e,index:t,status:r,itemId:n,onRewind:a}),i&&(0,m_.jsx)(w2r,{usage:i}),(0,m_.jsx)(_2r,{tasks:e.tasks,marker:y2r[r]}),s.length>0&&(0,m_.jsx)(m2r,{checks:s}),o&&o.length>0&&(0,m_.jsx)(C2r,{sessions:o})]})}var nX={name:"Review",tasks:[]};function m1e(e){return e.at(-1)?.name===nX.name?e.length-1:e.length}function g1e(e,t){if(t===void 0)return"upcoming";let r=e+1;return r<t?"done":r===t?"current":"upcoming"}function R2r(e=[]){return new Map(e.map(t=>[t.phaseIdx,t]))}function A2r(e=[]){let t=new Map;for(let r of e){let n=t.get(r.phaseIdx);n?n.push(r):t.set(r.phaseIdx,[r])}return t}var eWe=E(F(),1);function P2r({phases:e,currentPhase:t,itemId:r,usage:n,sessions:i,onRewind:o}){let a=R2r(n),s=A2r(i),l=m1e(e),u=(i??[]).filter(d=>d.phaseIdx>=l),f=l===e.length&&u.length>0?[...e,nX]:e;return(0,eWe.jsx)(_t,{spacing:1.5,children:f.map((d,h)=>(0,eWe.jsx)(E2r,{phase:d,index:h,status:g1e(h,t),itemId:r,usage:a.get(h),sessions:h===l?u:s.get(h),onRewind:h<e.length?o:void 0},d.name))})}var CA=E(F(),1),rJn={alignItems:"baseline",justifyContent:"space-between",mb:1},nJn={color:"text.secondary",display:"block",letterSpacing:"0.08em"};function L2r({phases:e,currentPhase:t,itemId:r,usage:n,sessions:i,onRewind:o}){return e.length===0?null:(0,CA.jsxs)(ie,{...ag("plan"),children:[(0,CA.jsxs)(_t,{direction:"row",sx:rJn,children:[(0,CA.jsx)(Le,{variant:"overline",sx:nJn,children:"Plan"}),n&&n.length>0&&(0,CA.jsx)(h2r,{usage:n})]}),(0,CA.jsx)(P2r,{phases:e,currentPhase:t,itemId:r,usage:n,sessions:i,onRewind:o})]})}var tWe=E(F(),1),y1e=e=>{let{value:t,options:r,colors:n,onChange:i}=e;return(0,tWe.jsx)(PS,{value:t,onChange:o=>i(o.target.value),size:"small",sx:{fontSize:"0.75rem",fontWeight:500,borderRadius:4,bgcolor:n[t].bg,color:n[t].text,"& .MuiSelect-select":{py:.5,px:1.5},"& .MuiSelect-icon":{color:"inherit"}},children:r.map(o=>(0,tWe.jsx)(pn,{value:o,children:o},o))})};var I2r=E(F(),1),iJn={todo:{bg:"action.selected",text:"text.primary"},"in-progress":{bg:"warning.main",text:"warning.contrastText"},done:{bg:"success.main",text:"success.contrastText"}},oJn=["todo","in-progress","done"];function M2r({current:e,onStatusChange:t}){return(0,I2r.jsx)(y1e,{value:e,options:oJn,colors:iJn,onChange:t})}var g_=E(F(),1);function D2r({subtask:e,onStatusChange:t}){let r=e.status==="done";return(0,g_.jsxs)(_t,{direction:"row",spacing:1,sx:{alignItems:"flex-start",justifyContent:"space-between"},children:[(0,g_.jsxs)(ie,{sx:{flex:1},children:[(0,g_.jsx)(Le,{variant:"body2",sx:{textDecoration:r?"line-through":"none",color:r?"text.disabled":"text.primary"},children:e.title}),e.description&&(0,g_.jsx)(ie,{sx:{mt:.5,fontSize:"0.8125rem",color:r?"text.disabled":"text.secondary"},children:(0,g_.jsx)(Yw,{content:e.description})})]}),(0,g_.jsx)(M2r,{current:e.status,onStatusChange:t})]})}var wA=E(F(),1),aJn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function N2r({subtasks:e,onStatusChange:t}){if(e.length===0)return null;let r=e.filter(n=>n.status!=="done").length;return(0,wA.jsxs)(ie,{...ag("subtasks"),children:[(0,wA.jsx)(Le,{variant:"overline",sx:aJn,children:"Sub-tasks"}),(0,wA.jsx)(_t,{spacing:1,children:e.map((n,i)=>(0,wA.jsx)(D2r,{subtask:n,onStatusChange:o=>t(i,o)},`${n.title}-${i}`))}),r>0&&(0,wA.jsxs)(ai,{severity:"warning",sx:{mt:1},children:[r," sub-task",r===1?"":"s"," not yet done."]})]})}var nS=E(F(),1);function O2r({item:e,onRewind:t,onCommentDeleted:r,onSubtaskStatusChange:n}){return(0,nS.jsxs)(nS.Fragment,{children:[e.subtasks&&n&&(0,nS.jsx)(N2r,{subtasks:e.subtasks,onStatusChange:n}),e.plan&&(0,nS.jsx)(L2r,{phases:e.plan,currentPhase:e.currentPhase,itemId:e.id,usage:e.phaseUsage,sessions:e.phaseSessions,onRewind:t}),(0,nS.jsx)(i2r,{gitRefs:e.gitRefs??[],conversations:e.conversations}),e.comments&&(0,nS.jsx)(f2r,{comments:e.comments,itemId:e.id,onCommentDeleted:r})]})}var H$=E(F(),1);function B2r({item:e,onRewind:t,onCommentDeleted:r,onSubtaskStatusChange:n}){return(0,H$.jsxs)(ie,{sx:{pt:2,flex:1,minWidth:0},children:[(0,H$.jsx)(Yxr,{description:e.description}),(0,H$.jsx)(jxr,{criteria:e.acceptanceCriteria}),(0,H$.jsx)(O2r,{item:e,onRewind:t,onCommentDeleted:r,onSubtaskStatusChange:n})]})}var $2r="item-detail";var iX={wideQuery:`@container ${$2r} (min-width: 760px)`,containerSx:{containerType:"inline-size",containerName:$2r},columnsSx:{display:"flex",columnGap:3}};function sJn(e){let t=e.plan??[];if(t.length===0)return[];let r=m1e(t),i=r===t.length&&(e.phaseSessions??[]).some(o=>o.phaseIdx>=r)?[...t,nX]:t;return[{id:d_.plan,label:"Phases"},...i.map((o,a)=>({id:h1e(a).id,label:`${a+1}`,title:o.name,status:g1e(a,e.currentPhase),nested:!0}))]}function F2r(e){let t=[];return e.description&&t.push({id:d_.description,label:"Description"}),e.acceptanceCriteria.length>0&&t.push({id:d_.acceptanceCriteria,label:"Acceptance Criteria"}),(e.subtasks?.length??0)>0&&t.push({id:d_.subtasks,label:"Sub-tasks"}),t.push(...sJn(e)),(e.gitRefs?.length??0)+(e.conversations?.length??0)>0&&t.push({id:d_.activity,label:"Activity"}),(e.comments?.length??0)>0&&t.push({id:d_.comments,label:"Comments"}),t}var z2r="1.3125rem",H2r={position:"relative",borderRadius:1,"&::after":{content:'""',position:"absolute",inset:0,borderRadius:"inherit",pointerEvents:"none"},"&:hover::after":{bgcolor:"action.hover"},"&:active::after":{bgcolor:"action.selected"}},lJn={...H2r,display:"block",flexShrink:0,maxWidth:"100%",px:1,py:.5,border:0,bgcolor:"transparent",fontSize:z2r,lineHeight:1.2,letterSpacing:"0.02em",textAlign:"left",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"text.secondary"},cJn={...H2r,display:"flex",alignItems:"center",justifyContent:"center",fontSize:z2r,width:"2em",height:"2em",flexShrink:0,lineHeight:1,borderRadius:"50%",border:1,color:"text.primary"},uJn={borderColor:"text.primary",borderWidth:3},fJn={color:"text.primary",fontWeight:700,"&::after":{bgcolor:"action.selected"}};function U2r(e,t){let r=e.status&&p1e[e.status];return r?{...cJn,ml:1.5,bgcolor:r.bgcolor,borderColor:r.borderColor,borderWidth:r.ring?3:1,...t&&uJn}:{...lJn,...t&&fJn}}var G2r=E(F(),1);function W2r({section:e,active:t,onSelect:r}){return(0,G2r.jsx)(En,{sx:U2r(e,t),onClick:()=>r(e.id),title:e.title??e.label,"aria-current":t?"true":void 0,children:e.label})}function V2r(e,t=eX){return mme(e,t)}var rWe=E(F(),1),dJn=48,hJn=260,pJn={display:"none",[iX.wideQuery]:{display:"flex"},position:"sticky",top:d1e,alignSelf:"flex-start",width:hJn,flexShrink:0,maxHeight:`calc(100vh - ${dJn}px - ${d1e})`,alignItems:"flex-start",overflowY:"auto",overflowX:"hidden",py:2};function mJn(e){document.getElementById(e)?.scrollIntoView({behavior:"smooth",block:"start"})}function q2r({item:e,headerHeight:t}){let r=F2r(e),n=V2r(r.map(i=>i.id),t);return r.length===0?null:(0,rWe.jsx)(_t,{component:"nav",spacing:1,sx:pJn,children:r.map(i=>(0,rWe.jsx)(W2r,{section:i,active:i.id===n,onSelect:mJn},i.id))})}var Y2r=E(F(),1);function j2r({to:e}){let t=Ii();return(0,Y2r.jsx)(Dt,{"data-backlog-focus":"back",variant:"text",size:"small",onClick:()=>t(e),sx:{mb:2,textTransform:"none"},children:"\u2190 Back"})}var K2r=E(de(),1);var kA=E(F(),1);function X2r({itemId:e,onDeleted:t}){let r=Pa(),n=yr(),[i,o]=(0,K2r.useState)(!1);return(0,kA.jsxs)(kA.Fragment,{children:[i&&(0,kA.jsx)(Di,{onConfirm:async()=>{await Jnt(e,r,n),await t()},onCancel:()=>o(!1)}),(0,kA.jsx)(Dt,{variant:"contained",color:"error",size:"small",onClick:()=>o(!0),children:"Delete"})]})}var nWe=E(F(),1),gJn={todo:{bg:"action.selected",text:"text.primary"},"in-progress":{bg:"warning.main",text:"warning.contrastText"},done:{bg:"success.main",text:"success.contrastText"},wontdo:{bg:"error.main",text:"error.contrastText"}},yJn=["todo","in-progress","done","wontdo"];function Z2r({current:e,onStatusChange:t}){return t?(0,nWe.jsx)(y1e,{value:e,options:yJn,colors:gJn,onChange:t}):(0,nWe.jsx)(tn,{label:e,size:"small",color:Dye[e],sx:{fontWeight:500,fontSize:"0.75rem"}})}var iS=E(F(),1),vJn={alignItems:"center",color:"text.disabled",fontSize:"0.875rem"},bJn={fontWeight:500,fontSize:"0.75rem"},xJn={color:"text.secondary",fontSize:"0.75rem"};function Q2r({item:e,onStatusChange:t}){let r=Iye[e.type];return(0,iS.jsxs)(_t,{direction:"row",spacing:1,sx:vJn,children:[(0,iS.jsx)(Le,{variant:"body2",color:"text.disabled",children:Yi(e.id)}),r&&(0,iS.jsx)(tn,{label:e.type,size:"small",color:r,sx:bJn}),(0,iS.jsx)(Z2r,{current:e.status,onStatusChange:t}),(0,iS.jsx)(fL,{jiraKey:e.jiraKey}),(0,iS.jsx)(uT,{githubIssue:e.githubIssue,origin:e.origin}),e.usageTotal&&(0,iS.jsx)($$,{total:e.usageTotal,sx:xJn})]})}var J2r=E(F(),1),eSr=st((0,J2r.jsx)("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"}),"Tune");var v1e=E(de(),1);var tSr=E(de(),1);function rSr(e){let{launchAssist:t}=il(),r=Ii(),n=Pa(),i=yr(),[o,a]=(0,tSr.useState)(!1);return{launched:o,launch:l=>{if(o)return;a(!0);let u=i?[{node:i}]:[];t(["refine","--once",...l,Yi(e)],n,...u),r("/sessions")}}}var P0=E(F(),1);function nSr({itemId:e}){let{launched:t,launch:r}=rSr(e),n=o_(),i=(0,v1e.useRef)(null),[o,a]=(0,v1e.useState)(!1),s=u=>u.stopPropagation(),l=Vye(n);return(0,P0.jsxs)(P0.Fragment,{children:[(0,P0.jsxs)(wS,{ref:i,variant:"outlined",size:"small",disabled:t,children:[(0,P0.jsx)(Dt,{startIcon:(0,P0.jsx)(eSr,{}),onClick:u=>{s(u),r([])},children:"Refine"}),l.length>0&&(0,P0.jsx)(Dt,{size:"small","aria-label":"Refine with a different harness",onClick:u=>{s(u),a(!0)},children:(0,P0.jsx)(bd,{})})]}),(0,P0.jsx)(qye,{anchorEl:i.current,open:o,onClose:()=>a(!1),options:l,onSelect:u=>{a(!1),r(["--harness",u])},stop:s})]})}var U$=E(de(),1);function iSr(){let e=(0,U$.useRef)(null),[t,r]=(0,U$.useState)(!1);return(0,U$.useEffect)(()=>{let n=e.current;if(!n)return;let i=new IntersectionObserver(([o])=>r(!o.isIntersecting),{threshold:0});return i.observe(n),()=>i.disconnect()},[]),{sentinelRef:e,stuck:t}}var id=E(F(),1),SJn={justifyContent:"space-between",alignItems:"center",mb:2};function TJn(e){return e.palette.mode==="dark"?"0 8px 8px -9px rgba(0, 0, 0, 0.8)":"0 6px 6px -7px rgba(0, 0, 0, 0.2)"}function CJn(e){return t=>({position:"sticky",top:0,zIndex:1,bgcolor:"background.default",mx:-2,px:2,pb:2,borderBottom:1,borderColor:"divider",boxShadow:e?TJn(t):"none",transition:t.transitions.create("box-shadow")})}function oSr({item:e,onDeleted:t,onStatusChange:r,ref:n}){let{sentinelRef:i,stuck:o}=iSr();return(0,id.jsxs)(id.Fragment,{children:[(0,id.jsx)(ie,{ref:i,sx:{height:0}}),(0,id.jsxs)(ie,{ref:n,sx:CJn(o),children:[(0,id.jsxs)(_t,{direction:"row",sx:SJn,children:[(0,id.jsx)(j2r,{to:"/backlog"}),(0,id.jsxs)(_t,{direction:"row",spacing:1,children:[Wye(e)&&(0,id.jsx)(l1e,{itemId:e.id}),(0,id.jsx)(nSr,{itemId:e.id}),(0,id.jsx)(X2r,{itemId:e.id,onDeleted:t})]})]}),(0,id.jsx)(Le,{variant:"h5",component:"h2",children:e.name}),(0,id.jsx)(Q2r,{item:e,onStatusChange:r})]})]})}var aSr=E(de(),1);function sSr(){let e=(0,aSr.useRef)(null),t=Kge(e,eX),r={[QUe]:`${t}px`};return{headerRef:e,headerHeight:t,style:r}}var y_=E(F(),1);function lSr({item:e,onReload:t}){let r=Ii(),n=Pa(),i=yr(),{headerRef:o,headerHeight:a,style:s}=sSr();wy("ItemDetail");let l=async()=>{await t(),r("/backlog")},u=async d=>{await bL(e.id,d,n,i),await t()},f=async(d,h)=>{await eit(e.id,d,h,n,i),await t()};return(0,y_.jsxs)(ie,{style:s,children:[(0,y_.jsx)(oSr,{ref:o,item:e,onDeleted:l,onStatusChange:u}),(0,y_.jsx)(ie,{sx:iX.containerSx,children:(0,y_.jsxs)(ie,{sx:iX.columnsSx,children:[(0,y_.jsx)(B2r,{item:e,onRewind:t,onCommentDeleted:t,onSubtaskStatusChange:f}),(0,y_.jsx)(q2r,{item:e,headerHeight:a})]})})]})}var _A=E(F(),1),wJn={display:"flex",justifyContent:"center",py:6};function cSr({onReload:e}){let[t]=Uc(),r=t.get("cwd")||void 0,n=t.get("node")||void 0,i=$n(),o=(0,b1e.useMemo)(()=>r?{...i,selectedCwd:r,selectedNode:n}:i,[i,r,n]);return wy("ItemRoute"),(0,_A.jsx)(YH.Provider,{value:o,children:(0,_A.jsx)(mf.Provider,{value:o.selectedNode,children:(0,_A.jsx)(kJn,{onReload:e})})})}function kJn({onReload:e}){let{id:t}=HTe(),r=Number.NaN;try{r=tte(t??"")}catch{r=Number.NaN}let{item:n,loading:i,reload:o}=Vxr(r),a=(0,b1e.useCallback)(async()=>{await Promise.all([o(),e()])},[o,e]);return i?(0,_A.jsx)(ie,{sx:wJn,children:(0,_A.jsx)(oo,{})}):n?(0,_A.jsx)(lSr,{item:n,onReload:a}):null}var EA=E(F(),1);function uSr({items:e,loading:t,error:r,socket:n,onReload:i}){return(0,EA.jsxs)(K5,{children:[(0,EA.jsx)(Ts,{index:!0,element:(0,EA.jsx)(Gxr,{items:e,loading:t,error:r,socket:n,onReload:i})}),(0,EA.jsx)(Ts,{path:"items/:id",element:(0,EA.jsx)(cSr,{onReload:i})})]})}var L0=E(de(),1);var fSr=new Map;function dSr(e,t,r){return JSON.stringify([e??null,t,r??null])}var oX={get(e,t,r){return fSr.get(dSr(e,t,r))},set(e,t,r,n){fSr.set(dSr(e,t,n),r)}};function _Jn(e,t){return e===t?!0:!e||!t?!1:e.tokensUp===t.tokensUp&&e.tokensDown===t.tokensDown&&e.activeMs===t.activeMs&&e.peakContextPct===t.peakContextPct}function hSr(e,t){return e===t?!0:e.length!==t.length?!1:e.every((r,n)=>{let i=t[n];return r.id===i.id&&r.type===i.type&&r.name===i.name&&r.status===i.status&&r.starred===i.starred&&r.incompleteSubtasks===i.incompleteSubtasks&&_Jn(r.usageTotal,i.usageTotal)})}function pSr({setItems:e,setLoading:t,setError:r}){return{onLoaded:n=>{e(i=>hSr(i,n)?i:n),t(!1),r(null)},onError:n=>{t(!1),r(n)}}}async function mSr(e,t,r,n){let i=await dT({cwd:e,node:n,signal:r,filter:t});return r.aborted||oX.set(e,t,i,n),i}function gSr(e,t,r,{onLoaded:n,onError:i},o){return(async()=>{try{let a=await mSr(e,t,r,o);r.aborted||n(a)}catch(a){r.aborted||i(a instanceof Error?a.message:"Failed to load.")}})()}var EJn=5e3;function ySr(e,t,r,n){let i=new AbortController,o=!1,a=()=>{o||(o=!0,gSr(e,t,i.signal,r,n).finally(()=>{o=!1}))};a();let s=setInterval(a,EJn);return()=>{i.abort(),clearInterval(s)}}function vSr(){let e=Pa(),t=yr(),[r]=R$(),n=oX.get(e,r,t),i=n??[],o=n===void 0,[a,s]=(0,L0.useState)(i),[l,u]=(0,L0.useState)(o),[f,d]=(0,L0.useState)(null),[h,p]=(0,L0.useState)(e),[m,g]=(0,L0.useState)(t),[y,v]=(0,L0.useState)(r);(e!==h||t!==m||r!==y)&&(p(e),g(t),v(r),s(i),u(o),d(null));let b=(0,L0.useCallback)(async()=>{let x=await dT({cwd:e,node:t,filter:r});s(x),oX.set(e,r,x,t),u(!1)},[e,t,r]);return(0,L0.useEffect)(()=>ySr(e,r,pSr({setItems:s,setLoading:u,setError:d}),t),[e,t,r]),{items:a,loading:l,error:f,reload:b}}var W$=E(F(),1);function bSr({socket:e}){let{items:t,loading:r,error:n,reload:i}=vSr();return yre(!r),(0,W$.jsx)(zUe.Provider,{value:e.sessions,children:(0,W$.jsx)(jUe.Provider,{value:e.selectSession,children:(0,W$.jsx)(K5,{children:(0,W$.jsx)(Ts,{path:"/*",element:(0,W$.jsx)(uSr,{items:t,loading:r,error:n,socket:e,onReload:i})})})})})}var iWe=E(F(),1);function xSr({socket:e}){return(0,iWe.jsx)(az,{maxWidth:"lg",sx:{py:3,px:2},children:(0,iWe.jsx)(bSr,{socket:e})})}var Pi=E(F(),1);function SSr({socket:e}){return wy("AppRoutes"),(0,Pi.jsxs)(Pi.Fragment,{children:[(0,Pi.jsx)(Nlr,{}),(0,Pi.jsx)(K5,{children:(0,Pi.jsxs)(Ts,{element:(0,Pi.jsx)(jat,{socket:e}),children:[(0,Pi.jsx)(Ts,{path:"sessions",element:(0,Pi.jsx)(V1r,{socket:e})}),(0,Pi.jsx)(Ts,{path:"backlog/*",element:(0,Pi.jsx)(xSr,{socket:e})}),(0,Pi.jsx)(Ts,{path:"next",element:(0,Pi.jsx)(Nsr,{sessions:e.sessions,selectSession:e.selectSession})}),(0,Pi.jsx)(Ts,{path:"news",element:(0,Pi.jsx)(War,{})}),(0,Pi.jsx)(Ts,{path:"releases",element:(0,Pi.jsx)(Llr,{})}),(0,Pi.jsx)(Ts,{path:"usage",element:(0,Pi.jsx)(Abr,{})}),(0,Pi.jsx)(Ts,{path:"backups",element:(0,Pi.jsx)(tst,{})}),(0,Pi.jsx)(Ts,{path:"config",element:(0,Pi.jsx)(ect,{})}),(0,Pi.jsx)(Ts,{path:"updates",element:(0,Pi.jsx)(zvr,{reconnecting:e.reconnecting,selectSession:e.selectSession})}),(0,Pi.jsx)(Ts,{path:"diff",element:(0,Pi.jsx)(sar,{socket:e})}),(0,Pi.jsx)(Ts,{path:"file",element:(0,Pi.jsx)($ar,{socket:e})}),(0,Pi.jsx)(Ts,{path:"*",element:(0,Pi.jsx)(jTe,{to:"/sessions",replace:!0})})]})})]})}var w1e=E(de(),1);var C1e=E(de(),1);function TSr(e,t,r){if(!e)return"Select a repo to search files.";if(r.error)return"Couldn't search files in this repo.";if(!(r.files.length>0||r.loading))return t?"No matching files.":"No files in this repo."}var v_=E(F(),1),RJn={display:"flex",gap:1,alignItems:"center",minWidth:0},AJn={display:"flex",gap:1,alignItems:"baseline",minWidth:0,overflow:"hidden"},PJn={fontFamily:"monospace",fontSize:13,whiteSpace:"nowrap"},LJn={fontFamily:"monospace",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function MJn(e){let t=e.lastIndexOf("/");return t===-1?{dir:"",basename:e}:{dir:e.slice(0,t),basename:e.slice(t+1)}}function CSr({files:e,highlight:t,onHighlight:r,onSelect:n}){return(0,v_.jsx)(Fp,{dense:!0,sx:{py:0},children:e.map((i,o)=>{let{dir:a,basename:s}=MJn(i);return(0,v_.jsxs)(pn,{selected:o===t,onMouseEnter:()=>r(o),onClick:()=>n(i),sx:RJn,children:[(0,v_.jsx)(K9,{path:i}),(0,v_.jsxs)(ie,{sx:AJn,children:[(0,v_.jsx)(Le,{component:"span",sx:PJn,children:s}),(0,v_.jsx)(Le,{component:"span",color:"text.secondary",sx:LJn,children:a})]})]},i)})})}var x1e=E(F(),1),IJn={maxHeight:420,overflowY:"auto"},DJn={px:2,py:2,fontSize:13};function wSr({message:e,files:t,highlight:r,onHighlight:n,onSelect:i}){return(0,x1e.jsx)(ie,{sx:IJn,children:e?(0,x1e.jsx)(Le,{color:"text.secondary",sx:DJn,children:e}):(0,x1e.jsx)(CSr,{files:t,highlight:r,onHighlight:n,onSelect:i})})}var kSr=E(F(),1),NJn={mt:6,alignSelf:"flex-start"};function S1e({onClose:e,onEntered:t,centered:r=!1,children:n}){return(0,kSr.jsx)(Wl,{open:!0,onClose:e,maxWidth:"sm",fullWidth:!0,slotProps:{paper:{sx:r?void 0:NJn},transition:{onEntered:t}},children:n})}var T1e=E(de(),1);var _Sr={files:[],loading:!1,error:!1};function ESr(e,t){let[r,n]=(0,T1e.useState)(_Sr),i=yr();return(0,T1e.useEffect)(()=>{if(!e){n(_Sr);return}let o=!1;return n(s=>({...s,loading:!0})),(async()=>{try{let s=await fetch(qr(`/api/files?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}`,i));if(!s.ok)throw new Error(`HTTP ${s.status}`);let l=await s.json();if(o)return;n({files:Array.isArray(l.files)?l.files:[],loading:!1,error:!1})}catch{o||n({files:[],loading:!1,error:!0})}})(),()=>{o=!0}},[e,t,i]),r}var RA=E(F(),1);function OJn(e,t,r){let n=new URLSearchParams({path:e});return t&&n.set("cwd",t),t&&r&&n.set("node",r),`/file?${n}`}function RSr({onClose:e}){let{worktreeNode:t}=$n();return(0,RA.jsx)(mf.Provider,{value:t,children:(0,RA.jsx)(BJn,{onClose:e})})}function BJn({onClose:e}){let{worktreeCwd:t,worktreeNode:r}=$n(),[n,i]=(0,C1e.useState)(""),o=ESr(t,n),a=Ii(),s=(0,C1e.useRef)(null),l=p=>a(OJn(p,t,r)),{highlight:u,setHighlight:f,onKeyDown:d}=u_(o.files,n,l,e),h=p=>{l(p),e()};return(0,RA.jsxs)(S1e,{onClose:e,onEntered:()=>s.current?.focus(),children:[(0,RA.jsx)(cT,{autoFocus:!0,inputRef:s,value:n,onChange:i,onKeyDown:d,placeholder:"Search files by name..."}),(0,RA.jsx)(wSr,{message:TSr(t,n,o),files:o.files,highlight:u,onHighlight:f,onSelect:h})]})}function ASr(e){Eo(qn("quickOpen").matches,e)}var LSr=E(F(),1);function PSr(){let[e,t]=(0,w1e.useState)(!1);return ASr((0,w1e.useCallback)(()=>t(!0),[])),e?(0,LSr.jsx)(RSr,{onClose:()=>t(!1)}):null}var k1e=E(F(),1);function MSr({notice:e,onClose:t,onView:r}){let n=e?.sessionId??null;return(0,k1e.jsx)(pl,{open:e!==null,autoHideDuration:6e3,onClose:t,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,k1e.jsx)(ai,{severity:"success",variant:"filled",onClose:t,action:n!==null?(0,k1e.jsx)(Dt,{color:"inherit",size:"small",onClick:()=>r(n),children:"View"}):void 0,children:e?.message})})}var L1e=E(de(),1);function ISr(e){let t=["claude"];return e.exposeCodexActions&&t.push("codex"),e.exposePiActions&&t.push("pi"),t}var qSr=E(de(),1);var DSr=E(F(),1),NSr=st((0,DSr.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2"}),"Circle");var b_="0.891.1";var $Jn={connected:"success.main",connecting:"warning.main",disconnected:"error.main","version-blocked":"error.main"};function OSr(e){return e?$Jn[e]:"success.main"}function BSr(e){return e.split("-")[0].split(".").map(Number)}function $Sr(e,t){if(!e||!t||e===t)return;let r=BSr(e),n=BSr(t);for(let i=0;i<Math.max(r.length,n.length);i++){let o=(r[i]??0)-(n[i]??0);if(Number.isNaN(o))return;if(o!==0)return o<0?"behind":"ahead"}}var _1e=E(de(),1),oWe=(0,_1e.createContext)(null);function E1e(){return(0,_1e.useContext)(oWe)}var AA=E(F(),1),FJn={height:16,fontSize:10},zJn={opacity:.6,fontSize:"0.85em"};function HJn(e,t){if(t===e.local)return"this machine";let r=e.links.find(n=>n.name===t);return r?r.error?`${r.state}: ${r.error}`:r.state:""}function aX({nodes:e,name:t,showVersion:r=!1}){let n=E1e()??b_,i=e.links.find(a=>a.name===t),o=$Sr(i?.peerVersion,n);return(0,AA.jsx)(lr,{title:HJn(e,t),placement:"right",children:(0,AA.jsxs)(ie,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:.75},children:[(0,AA.jsx)(NSr,{sx:{fontSize:8,color:OSr(i?.state)}}),t,r&&i?.peerVersion&&(0,AA.jsxs)(ie,{component:"span",sx:zJn,children:["v",i.peerVersion]}),o&&(0,AA.jsx)(tn,{label:o,size:"small",color:o==="behind"?"warning":"info",sx:FJn})]})})}var PA=E(F(),1),UJn={opacity:.6},WJn={display:"inline-flex",alignItems:"center",gap:.5,px:.5,border:1,borderStyle:"dashed",borderRadius:1};function FSr({nodes:e,name:t,clone:r}){let n=(0,PA.jsx)(aX,{nodes:e,name:t});return r.kind==="cloned"?n:r.kind==="unavailable"?(0,PA.jsx)(ie,{component:"span",sx:UJn,children:n}):(0,PA.jsx)(lr,{title:L$(t,r.cloneTarget),children:(0,PA.jsxs)(ie,{component:"span",sx:WJn,children:[(0,PA.jsx)(P$,{sx:{fontSize:14}}),n]})})}var HSr=E(F(),1),GJn={px:1.5,borderRadius:.75,fontSize:12,fontWeight:600,color:"text.secondary","&:hover":{color:"text.primary",bgcolor:"action.hover"},"&[aria-checked='true']":{color:"primary.main",bgcolor:"action.selected"},"&.Mui-focusVisible":{outline:2,outlineColor:"primary.main"}};function zSr({value:e,label:t,checked:r,autoFocus:n,onSelect:i}){return(0,HSr.jsx)(En,{role:"radio","aria-checked":r,"data-value":e,tabIndex:r?0:-1,autoFocus:n&&r,onClick:i,sx:GJn,children:t})}var USr={ArrowRight:1,ArrowLeft:-1};function VJn(e,t,r){if(e.key==="Tab"){let n=t+(e.shiftKey?-1:1);return n>=0&&n<r?n:void 0}return(t+USr[e.key]+r)%r}function WSr(e,t,r,n){return i=>{if(i.key==="ArrowUp"||i.key==="ArrowDown"){if(!n)return;i.preventDefault(),n();return}if(i.key!=="Tab"&&!USr[i.key]){C2(i);return}let o=VJn(i,e.indexOf(t),e.length);o!==void 0&&(i.preventDefault(),r(e[o]),i.currentTarget.querySelector(`[data-value="${e[o]}"]`)?.focus())}}var GSr=E(de(),1);function G$(e){return e?.querySelector('[aria-checked="true"]')}function VSr(e,t){(0,GSr.useEffect)(()=>{let r=e.current;if(!r?.contains(document.activeElement))return;let n=G$(r);n&&n!==document.activeElement&&n.focus()},[e,t])}var aWe=E(F(),1),qJn={border:1,borderColor:"divider",borderRadius:1,height:40,p:"2px",flexShrink:0};function R1e({label:e,options:t,value:r,onChange:n,optionLabel:i=u=>u,groupRef:o,autoFocus:a,onTrack:s,onToggleRow:l}){return VSr(o,r),(0,aWe.jsx)(_t,{ref:o,direction:"row",role:"radiogroup","aria-label":e,spacing:"2px",onFocus:s,onKeyDown:WSr(t,r,n,l),sx:qJn,children:t.map(u=>(0,aWe.jsx)(zSr,{value:u,label:i(u),checked:u===r,autoFocus:a,onSelect:()=>n(u)},u))})}var sWe=E(F(),1);function jSr({value:e,onChange:t,cloneState:r}){let{nodes:n,names:i,visible:o}=ef(),a=(0,qSr.useRef)(null);return!o||!n||!e?null:(0,sWe.jsx)(R1e,{label:"Machine",options:i,value:e,onChange:t,optionLabel:s=>(0,sWe.jsx)(FSr,{nodes:n,name:s,clone:r(s)}),groupRef:a,autoFocus:!1,onTrack:()=>{}})}var KSr=E(F(),1);function YSr({value:e,onChange:t,placeholder:r,inputRef:n,autoFocus:i,onTrack:o}){return(0,KSr.jsx)(Qn,{value:e,onChange:a=>t(a.target.value),onKeyDown:C2,onFocus:o,onSelect:o,inputRef:n,placeholder:r,autoFocus:i,fullWidth:!0,multiline:!0,minRows:3,maxRows:12,slotProps:{htmlInput:{"aria-label":"Prompt"},input:{sx:{fontSize:14}}}})}var JSr=E(de(),1);var oS={draft:{placeholder:"Describe the backlog item to draft...",submitLabel:"Start draft",sessionMode:"assist-draft"},bug:{placeholder:"Describe the bug: what happened, what you expected...",submitLabel:"File bug",sessionMode:"assist-bug"},prompt:{placeholder:vge,submitLabel:"Start session"},design:{placeholder:"Describe the design task...",submitLabel:"Start design"}},XSr=Object.keys(oS);var lWe=E(F(),1);function ZSr({anchor:e,harness:t,harnesses:r,onPick:n,onClose:i}){return(0,lWe.jsx)(Os,{open:e!==null,anchorEl:e,onClose:i,slotProps:{list:{dense:!0,"aria-label":"Harness"}},children:r.map(o=>(0,lWe.jsx)(pn,{role:"menuitemradio","aria-checked":o===t,selected:o===t,onClick:()=>{n(o),i()},sx:{fontSize:13},children:Lu(o)},o))})}var LA=E(F(),1);function QSr(e){return t=>t==="prompt"&&e?(0,LA.jsxs)(LA.Fragment,{children:["prompt",(0,LA.jsx)(ie,{component:"span",sx:{fontWeight:400,whiteSpace:"pre"},children:` \xB7 ${Lu(e)}`}),(0,LA.jsx)(bd,{sx:{fontSize:18,mr:-.75}})]}):t}var MA=E(F(),1);function eTr({draft:e,harness:t,harnesses:r,focus:n}){let[i,o]=(0,JSr.useState)(null),a=e.mode==="prompt"&&r.length>1,s=()=>o(G$(n.modeRef.current)??null),l=u=>{a&&u==="prompt"?s():e.setMode(u)};return(0,MA.jsxs)(MA.Fragment,{children:[(0,MA.jsx)(R1e,{label:"Mode",options:XSr,value:e.mode,onChange:l,optionLabel:QSr(r.length>1?t:void 0),groupRef:n.modeRef,autoFocus:n.autoFocus==="mode",onTrack:n.trackMode,onToggleRow:a?s:void 0}),(0,MA.jsx)(ZSr,{anchor:i,harness:t,harnesses:r,onPick:e.setHarness,onClose:()=>o(null)})]})}var fTr=E(de(),1);var cWe=E(F(),1),jJn={zIndex:e=>e.zIndex.modal+1};function tTr({open:e,anchor:t,children:r}){return(0,cWe.jsx)(F6,{open:e,anchorEl:t,placement:"bottom-start",sx:jJn,children:(0,cWe.jsx)(un,{sx:{maxHeight:240,overflowY:"auto",width:t?.clientWidth},onMouseDown:n=>n.preventDefault(),children:r})})}function rTr(e){return{htmlInput:{role:"combobox","aria-label":"Repo","aria-expanded":e},input:{sx:{fontSize:13,height:40}}}}var nTr=E(OF(),1);function iTr({open:e,highlighted:t,accept:r,close:n,navigate:i,openList:o}){return a=>{if(!e){if(a.key==="ArrowDown"){a.preventDefault(),o();return}C2(a);return}if(a.key!=="Escape"){if(a.key==="Enter"){if(a.preventDefault(),t===void 0)return;(0,nTr.flushSync)(()=>{r(t),n()}),C2(a);return}if(a.key!=="Tab"){i(a);return}t!==void 0&&r(t),n()}}}function oTr(e,t){let r=t.trim().toLowerCase();return r?e.filter(n=>bv(n).toLowerCase().includes(r)):e}var uWe=E(de(),1);function aTr(){let[e,t]=(0,uWe.useState)(!1),[r,n]=(0,uWe.useState)("");return{open:e,query:r,show:()=>t(!0),filterBy:i=>{n(i),t(!0)},close:()=>{t(!1),n("")}}}var lTr=E(de(),1);var sTr=e=>e?bv(e):"";function cTr(e){let[t,r]=(0,lTr.useState)(()=>sTr(e));return{text:t,setText:r,showRepo:n=>r(sTr(n))}}function uTr(e,t,r){let n=aTr(),i=cTr(t),o=oTr(e,n.query),a=f=>{r(f),i.showRepo(f)},s=u_(o,n.query,a,n.close),l=()=>s.setHighlight(Math.max(e.indexOf(t),0)),u=()=>{l(),n.show()};return{open:n.open,text:i.text,filtered:o,highlight:s.highlight,setHighlight:s.setHighlight,onKeyDown:iTr({open:n.open,highlighted:o[s.highlight],accept:a,close:n.close,navigate:s.onKeyDown,openList:u}),onClick:()=>{n.open||u()},onType:f=>{i.setText(f),n.filterBy(f)},onFocus:l,onBlur:()=>{n.close(),i.showRepo(t)},pick:f=>{a(f),n.close()}}}var V$=E(F(),1);function dTr({repos:e,value:t,onChange:r,inputRef:n,autoFocus:i,onTrack:o}){let a=uTr(e,t,r),s=(0,fTr.useRef)(null);return(0,V$.jsxs)(ie,{ref:s,sx:{flex:1,minWidth:0},children:[(0,V$.jsx)(Qn,{value:a.text,onChange:l=>a.onType(l.target.value),onFocus:l=>{l.target.select(),a.onFocus(),o()},inputRef:n,autoFocus:i,onClick:a.onClick,onBlur:a.onBlur,onKeyDown:a.onKeyDown,placeholder:"Repo",size:"small",fullWidth:!0,slotProps:rTr(a.open)}),(0,V$.jsx)(tTr,{open:a.open,anchor:s.current,children:(0,V$.jsx)(o1e,{repos:a.filtered,selected:t,highlight:a.highlight,onHighlight:a.setHighlight,onSelect:a.pick})})]})}var x_=E(F(),1);function hTr({cloneState:e,...t}){let{draft:r,focus:n}=t,{repos:i}=$n();return(0,x_.jsxs)(_t,{spacing:1,sx:{p:1},children:[(0,x_.jsx)(YSr,{value:r.prompt,onChange:r.setPrompt,placeholder:oS[r.mode].placeholder,inputRef:n.promptRef,autoFocus:n.autoFocus==="prompt",onTrack:n.trackPrompt}),(0,x_.jsxs)(_t,{direction:"row",spacing:1,sx:{alignItems:"flex-start"},children:[(0,x_.jsx)(dTr,{repos:i,value:r.cwd,onChange:r.setCwd,inputRef:n.repoRef,autoFocus:n.autoFocus==="repo",onTrack:n.trackRepo}),(0,x_.jsx)(eTr,{...t})]}),(0,x_.jsx)(jSr,{value:r.node,onChange:r.setNode,cloneState:e})]})}var q$=E(F(),1),YJn=["Enter start","Shift+Enter newline","Esc close"],KJn={alignItems:"center",px:1.5,py:1,borderTop:1,borderColor:"divider",bgcolor:"action.hover"};function pTr({submitLabel:e,disabled:t=!1}){return(0,q$.jsxs)(_t,{direction:"row",spacing:1.5,sx:KJn,children:[(0,q$.jsx)(_t,{direction:"row",spacing:1.5,sx:{mr:"auto"},children:YJn.map(r=>(0,q$.jsx)(Le,{variant:"caption",color:"text.secondary",children:r},r))}),(0,q$.jsx)(Dt,{type:"submit",variant:"contained",size:"small",disabled:t,children:e})]})}function mTr({mode:e,harness:t,prompt:r,cwd:n,node:i},o){let a=n||void 0,s=i?[i]:[];if(e==="prompt"){t==="claude"?o.onCreate(r,a,...s):o.onCreateHarness(t,r,a,...s);return}if(e==="design"){o.onCreateDesign(r,a,...s);return}let l=i?[{node:i}]:[];wcr(oS[e].sessionMode,n,(u,f)=>o.onCreateAssist(u,f,...l),()=>{},r)}function gTr(e,t,r,n){return r.kind==="blocked"||e.modePending?!1:r.kind==="clone"?(Kye(r.prompt,n.onCreateAssist),!0):(mTr({mode:e.mode,harness:t,prompt:e.prompt,cwd:r.cwd,node:e.node},n),e.clear(),!0)}var IA=E(de(),1);function yTr(e,t){let r=(0,IA.useRef)(e),n=(0,IA.useRef)(null),i=(0,IA.useRef)(null),o=(0,IA.useRef)(null),a=(0,IA.useCallback)(u=>{n.current=u;let{field:f,selectionStart:d,selectionEnd:h}=r.current;u&&f==="prompt"&&u.setSelectionRange(d,h)},[]),s=u=>{let f=u.target;t({field:"prompt",selectionStart:f.selectionStart,selectionEnd:f.selectionEnd})},l=()=>{if(o.current?.closest("form")?.contains(document.activeElement))return;let{field:u}=r.current;({repo:i.current,mode:G$(o.current),prompt:n.current}[u]??n.current)?.focus()};return{autoFocus:e.field,promptRef:a,repoRef:i,modeRef:o,trackPrompt:s,trackRepo:()=>t({...e,field:"repo"}),trackMode:()=>t({...e,field:"mode"}),restore:l}}function XJn(e,t,r){return e?r.kind==="cloned"?{kind:"launch",cwd:r.cwd}:r.kind==="clonable"?{kind:"clone",prompt:s1e(r,t)}:{kind:"blocked"}:{kind:"launch",cwd:e}}function vTr(e,t){let{names:r,visible:n}=ef(),i=r1e(t,n?r:[void 0]);return{cloneState:i,target:XJn(t,e,i(e))}}var A1e=E(de(),1);function bTr(e,t){let[r,n]=(0,A1e.useState)(!1);return(0,A1e.useEffect)(()=>{!r||e.modePending||(n(!1),!(e.mode==="prompt"&&!e.prompt.trim())&&t())},[r,e.modePending,e.mode,e.prompt,t]),()=>{e.modePending?n(!0):t()}}var j$=E(F(),1);function xTr({draft:e,launchers:t,onClose:r}){let n=yTr(e.focus,e.setFocus),i=ISr(o_()),o=i.includes(e.harness)?e.harness:"claude",{target:a,cloneState:s}=vTr(e.node,e.cwd),l=bTr(e,()=>{gTr(e,o,a,t)&&r()}),u=f=>{f.preventDefault(),l()};return(0,j$.jsx)(S1e,{onClose:r,onEntered:n.restore,centered:!0,children:(0,j$.jsxs)("form",{onSubmit:u,children:[(0,j$.jsx)(hTr,{draft:e,harness:o,harnesses:i,focus:n,cloneState:s}),(0,j$.jsx)(pTr,{submitLabel:a.kind==="clone"?"Clone":oS[e.mode].submitLabel,disabled:a.kind==="blocked"})]})})}var P1e=E(de(),1);function STr(e){let[t,r]=(0,P1e.useState)(null);return(0,P1e.useEffect)(()=>{let n=!1;return(async()=>{let i="draft";try{let o=e?`?cwd=${encodeURIComponent(e)}`:"",s=await(await fetch(`/api/new-session-defaults${o}`)).json();Object.hasOwn(oS,s?.mode)&&(i=s.mode)}catch{}n||r({cwd:e,mode:i})})(),()=>{n=!0}},[e]),t}function TTr(e,{visible:t,names:r,selected:n}){if(t)return e&&r.includes(e)?e:n}var aS=E(de(),1),CTr={field:"prompt",selectionStart:0,selectionEnd:0};function wTr(){let[e,t]=(0,aS.useState)(""),[r,n]=(0,aS.useState)(),[i,o]=(0,aS.useState)(),[a,s]=(0,aS.useState)("claude"),[l,u]=(0,aS.useState)(),[f,d]=(0,aS.useState)(CTr),h=(0,aS.useCallback)(()=>{t(""),n(void 0),o(void 0),u(void 0),d(CTr)},[]);return{prompt:e,cwd:r,mode:i,harness:a,node:l,focus:f,setPrompt:t,setNode:u,setCwd:n,setMode:o,setHarness:s,setFocus:d,clear:h}}function kTr(e=STr){let{selectedCwd:t}=$n(),r=ef(),n=wTr(),i=n.cwd??t,o=e(i);return o?{...n,cwd:i,mode:n.mode??o.mode,modePending:n.mode===void 0&&o.cwd!==i,node:TTr(n.node,r)}:null}function _Tr(e){Eo(qn("newSession").matches,e)}var ETr=E(de(),1);function RTr(e,t){let{selectedCwd:r}=$n(),[n,i]=Uc(),o=n.get("new"),a=n.get("newCwd")??r,{setPrompt:s,setCwd:l,setFocus:u}=e??{};(0,ETr.useEffect)(()=>{o===null||!s||!l||!u||(o&&(s(o),l(a),u({field:"prompt",selectionStart:o.length,selectionEnd:o.length})),t(),i(f=>(f.delete("new"),f.delete("newCwd"),f),{replace:!0}))},[o,a,s,l,u,t,i])}var PTr=E(F(),1);function ATr({launchers:e}){let[t,r]=(0,L1e.useState)(!1),n=kTr(),i=(0,L1e.useCallback)(()=>r(!0),[]);return _Tr(i),RTr(n,i),!t||!n?null:(0,PTr.jsx)(xTr,{draft:n,launchers:e,onClose:()=>r(!1)})}var M1e=E(F(),1);function LTr({reconnecting:e}){return(0,M1e.jsx)(pl,{open:e,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,M1e.jsx)(ai,{severity:"info",variant:"filled",icon:(0,M1e.jsx)(oo,{size:16,color:"inherit"}),children:"Reconnecting\u2026"})})}var wv=E(F(),1);function MTr({socket:e,onViewLaunchedSession:t}){return(0,wv.jsxs)(wv.Fragment,{children:[(0,wv.jsx)(PSr,{}),(0,wv.jsx)(ATr,{launchers:{onCreate:e.createSession,onCreateDesign:e.createDesignSession,onCreateHarness:e.createHarnessSession,onCreateAssist:e.createAssistSession}}),(0,wv.jsx)(LTr,{reconnecting:e.reconnecting}),(0,wv.jsx)(Zl,{error:e.error,onClose:e.clearError}),(0,wv.jsx)(MSr,{notice:e.success,onClose:e.clearSuccess,onView:t})]})}var kv=E(de(),1);var ZJn=6e4;function QJn(e,t,r){return t.map(n=>e.find(i=>i.name===n)??{name:n,local:n===r,loading:!0})}function ITr(e){let t=e.nodes?.local,r=e.names.join(`
|
|
4016
|
+
`,Fbr={...$br,borderColor:"warning.main",borderLeft:4,borderLeftColor:"warning.main",bgcolor:e=>po(e.palette.warning.main,.08)},WZn={...Fbr,borderLeftColor:"transparent",backgroundImage:e=>`repeating-linear-gradient(to bottom, ${e.palette.warning.main} 0 ${Obr}px, transparent ${Obr}px ${UUe}px)`,backgroundOrigin:"border-box",backgroundRepeat:"repeat-y",backgroundSize:`4px ${UUe}px`,animation:`${UZn} 0.9s linear infinite`,"@media (prefers-reduced-motion: reduce)":{animation:"none"}},Bbr={"& .MuiButtonBase-root:focus-visible":{outline:"2px solid",outlineColor:"primary.main",outlineOffset:"2px"}},yv={card:$br,inProgressCard:Fbr,inProgressRunningCard:WZn,main:{minWidth:0,textAlign:"left"},stretchedNameLink:{display:"block",fontWeight:500,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",...HZn},meta:{display:"flex",alignItems:"center",gap:1,...Nbr,width:"fit-content",maxWidth:"100%",fontSize:"0.75rem",color:"text.secondary","& a, & p":{fontSize:"0.75rem"},...Bbr},id:{color:"text.disabled"},actions:{display:"flex",alignItems:"center",gap:1,flexShrink:0,...Nbr,...Bbr}};function Uye(e){let t=e.peakContextPct>0?` \xB7 \u2593 ${Math.round(e.peakContextPct)}%`:"";return`\u2191 ${sh(e.tokensUp)} \u2193 ${sh(e.tokensDown)} \xB7 \u23F1 ${_0(e.activeMs)}${t}`}var Hbr=E(F(),1),GZn={width:6,height:6,borderRadius:"50%",bgcolor:"currentColor",flexShrink:0};function zbr(){return(0,Hbr.jsx)(ie,{component:"span",sx:GZn})}var VK=E(F(),1),Ubr={display:"inline-flex",alignItems:"center",gap:.625,color:"warning.main",fontWeight:500,fontSize:"0.75rem",whiteSpace:"nowrap",borderRadius:1};function Wbr({item:e,openSession:t,onSelectSession:r}){let n=Ii();if(e.status!=="in-progress"||e.currentPhase==null)return null;let i=`phase ${e.currentPhase} of ${e.totalPhases??e.currentPhase}`,o=(0,VK.jsx)(zbr,{});if(!t)return(0,VK.jsxs)(ie,{component:"span",sx:Ubr,children:[o,i]});let a=()=>{r?.(t.id),n("/sessions")};return(0,VK.jsxs)(En,{sx:Ubr,title:`Open the ${t.status} session`,onClick:a,children:[o,i]})}var Cp=E(F(),1),VZn={display:"inline-flex",alignItems:"center",gap:.5},qZn={width:8,height:8,borderRadius:"50%",flexShrink:0},jZn={whiteSpace:"nowrap"};function YZn({type:e}){let t=Iye[e];return(0,Cp.jsxs)(ie,{component:"span",sx:VZn,children:[(0,Cp.jsx)(ie,{component:"span",sx:{...qZn,bgcolor:`${t}.main`}}),e]})}function KZn({item:e}){return e.usageTotal?(0,Cp.jsx)(lr,{title:Uye(e.usageTotal),children:(0,Cp.jsx)(ie,{component:"span",sx:jZn,children:`\u23F1 ${_0(e.usageTotal.activeMs)}`})}):null}function Gbr({item:e,openSession:t,onSelectSession:r}){return(0,Cp.jsxs)(ie,{sx:yv.meta,children:[(0,Cp.jsx)(ie,{component:"span",sx:yv.id,children:Yi(e.id)}),(0,Cp.jsx)(YZn,{type:e.type}),(0,Cp.jsx)(Wbr,{item:e,openSession:t,onSelectSession:r}),(0,Cp.jsx)(fL,{jiraKey:e.jiraKey}),(0,Cp.jsx)(uT,{githubIssue:e.githubIssue,variant:"icon"}),(0,Cp.jsx)(KZn,{item:e})]})}function Vbr(e,t){return e.filter(r=>vB(r)?.itemId===t).reduce((r,n)=>r&&r.startedAt>=n.startedAt?r:n,void 0)}var jbr=E(F(),1),XZn={todo:"\u25CB","in-progress":"\u25D4",done:"\u25CF",wontdo:"\u2715"},ZZn={todo:"text.disabled","in-progress":"warning.main",done:"success.main",wontdo:"error.main"};function QZn(e){return{fontSize:"1.125rem",flexShrink:0,color:ZZn[e]}}function qbr({status:e}){return(0,jbr.jsx)(Le,{sx:QZn(e),children:XZn[e]})}function Wye(e){return e.status==="todo"||e.status==="in-progress"}function JZn(e){if(e.status==="done")return e.totalPhases;if(e.status==="in-progress")return e.currentPhase}function eQn(e,t,r){return r?"complete":e<t?"done":e===t?"current":"remaining"}function Ybr(e){let t=e.totalPhases,r=JZn(e);if(!t||r==null)return;let n=e.status==="done";return{reached:r,total:t,segments:Array.from({length:t},(i,o)=>({phase:o+1,kind:eQn(o+1,r,n)}))}}var A$=E(F(),1),tQn={done:"text.secondary",current:"warning.main",remaining:"divider",complete:"success.main"},rQn={display:"inline-flex",alignItems:"center",gap:.5,flexShrink:0},nQn={fontSize:"0.6875rem",color:"text.secondary",fontVariantNumeric:"tabular-nums"},iQn={display:"inline-flex",alignItems:"center",gap:"2px"},oQn={width:6,height:12,borderRadius:"1px",flexShrink:0};function Kbr({item:e}){let t=Ybr(e);return t?(0,A$.jsxs)(ie,{sx:rQn,title:`Phase ${t.reached} of ${t.total}`,children:[(0,A$.jsx)(ie,{component:"span",sx:nQn,children:`${t.reached}/${t.total}`}),(0,A$.jsx)(ie,{component:"span",sx:iQn,"aria-hidden":!0,children:t.segments.map(r=>(0,A$.jsx)(ie,{component:"span","data-segment":r.kind,sx:{...oQn,bgcolor:tQn[r.kind]}},r.phase))})]}):null}var Txr=E(de(),1);var jye=E(de(),1);var yA=E(F(),1),aQn={minWidth:0,p:.5,borderRadius:"50%"};function Gye({tooltip:e,disabled:t,onClick:r,compact:n=!1}){return(0,yA.jsx)(lr,{title:e,children:(0,yA.jsx)(ie,{component:"span",sx:{display:"flex"},children:n?(0,yA.jsx)(Dt,{"aria-label":"Build",variant:"contained",color:"success",size:"small",disabled:t,sx:aQn,onClick:r,children:(0,yA.jsx)(Rg,{fontSize:"small"})}):(0,yA.jsx)(Dt,{startIcon:(0,yA.jsx)(Rg,{}),disabled:t,onClick:r,children:"Build"})})})}var WUe=E(F(),1);function Vye(e){let t=[];return e.exposeCodexActions&&t.push({kind:"codex",label:"with Codex"}),e.exposePiActions&&t.push({kind:"pi",label:"with pi"}),t}function qye({anchorEl:e,open:t,onClose:r,options:n,onSelect:i,stop:o}){return(0,WUe.jsx)(Os,{anchorEl:e,open:t,onClose:r,onClick:o,children:n.map(a=>(0,WUe.jsx)(pn,{onClick:s=>{o(s),i(a.kind)},children:a.label},a.kind))})}var vv=E(F(),1);function Xbr({tooltip:e,disabled:t,onBuild:r,onSelectHarness:n}){let i=Vye(o_()),o=(0,jye.useRef)(null),[a,s]=(0,jye.useState)(!1),l=u=>u.stopPropagation();return(0,vv.jsxs)(vv.Fragment,{children:[(0,vv.jsxs)(wS,{ref:o,variant:"contained",color:"success",size:"small",disabled:t,children:[(0,vv.jsx)(Gye,{tooltip:e,disabled:t,onClick:u=>{l(u),r()}}),i.length>0&&(0,vv.jsx)(Dt,{"aria-label":"Build with a different harness",onClick:u=>{l(u),s(!0)},children:(0,vv.jsx)(bd,{})})]}),(0,vv.jsx)(qye,{anchorEl:o.current,open:a,onClose:()=>s(!1),options:i,onSelect:u=>{s(!1),n(u)},stop:l})]})}var Zbr=E(F(),1),P$=st((0,Zbr.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96M19 18H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95C8.08 7.14 9.94 6 12 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11c1.56.1 2.78 1.41 2.78 2.96 0 1.65-1.35 3-3 3m-5.55-8h-2.9v3H8l4 4 4-4h-2.55z"}),"CloudDownloadOutlined");var l_=E(F(),1),sQn={vertical:"bottom",horizontal:"center"};function Yye({clone:e}){let{prompt:t,confirm:r,cancel:n,error:i,dismissError:o}=e;return(0,l_.jsxs)(l_.Fragment,{children:[t&&(0,l_.jsx)(Di,{title:"Clone repository",message:`Clone ${t.displayName} over SSH into ${t.cloneTarget}${t.node?` on ${t.node}`:""}?`,confirmLabel:"Clone",confirmColor:"primary",onConfirm:r,onCancel:n}),(0,l_.jsx)(pl,{open:!!i,autoHideDuration:8e3,onClose:o,anchorOrigin:sQn,children:(0,l_.jsx)(ai,{severity:"error",onClose:o,variant:"filled",children:i})})]})}var A0=E(de(),1);function GUe(e){return["backlog","clone",e]}function Kye(e,t){t(GUe(e.origin),void 0,{title:`Clone ${e.displayName}`,subtitle:e.origin,...e.node&&{node:e.node}})}function Qbr(e,t){return!!e&&e.length===t.length&&e.every((r,n)=>r===t[n])}function Jbr(e,t,r){let n=GUe(t.origin),i=new Set(e.filter(o=>Qbr(o.assistArgs,n)).map(o=>o.id));return Kye(t,r),{args:n,target:t.cloneTarget,node:t.node,preexisting:i}}function exr(e,t){if(!t.id){let n=e.find(i=>Qbr(i.assistArgs,t.args)&&!t.preexisting.has(i.id));return n?{type:"latch",id:n.id}:null}let r=e.find(n=>n.id===t.id);return r?r.status==="done"?{type:"done"}:r.status==="error"?{type:"error",message:r.error||"Clone failed."}:null:null}function Xye(e){let{setSelectedCwd:t}=$n(),{launchAssist:r}=il(),[n,i]=(0,A0.useState)(null),[o,a]=(0,A0.useState)(null),[s,l]=(0,A0.useState)(null),u=(0,A0.useCallback)(p=>{l(null),i(p)},[]),f=(0,A0.useCallback)(()=>i(null),[]),d=(0,A0.useCallback)(()=>l(null),[]),h=(0,A0.useCallback)(()=>{n&&(a(Jbr(e,n,r)),i(null))},[n,e,r]);return(0,A0.useEffect)(()=>{if(!o)return;let p=exr(e,o);p&&(p.type==="latch"?a(m=>m&&{...m,id:p.id}):p.type==="done"?(o.node?t(o.target,o.node):t(o.target),a(null)):(l(p.message),a(null)))},[e,o,t]),{prompt:n,requestClone:u,confirm:h,cancel:f,error:s,dismissError:d}}function L$(e,t){return`Not cloned ${e?`on ${e}`:"locally"} \u2014 click to clone into ${t}`}var Q2=E(F(),1),lQn={border:1,borderStyle:"dashed"};function txr({target:e}){let t=Xye(Hye());return(0,Q2.jsxs)(Q2.Fragment,{children:[(0,Q2.jsx)(lr,{title:L$(e.node,e.cloneTarget),children:(0,Q2.jsx)(ir,{"aria-label":"Clone",size:"small",sx:lQn,onClick:r=>{r.stopPropagation(),t.requestClone(e)},children:(0,Q2.jsx)(P$,{fontSize:"small"})})}),(0,Q2.jsx)(Yye,{clone:t})]})}var KK=E(de(),1);var qK=E(de(),1);function rxr(e,t,r,n){let i=Pa(),o=yr(),a=(0,qK.useRef)(!1),[s,l]=(0,qK.useState)(!1),[u,f]=(0,qK.useState)(null);return{busy:s,error:u,clearError:()=>f(null),confirm:async()=>{if(!a.current){a.current=!0,l(!0);try{await bL(e,t,i,o)}catch{f(r),a.current=!1,l(!1);return}await n()}}}}var jK=E(F(),1),cQn={done:{verb:"done",action:"Mark done"},wontdo:{verb:"won't do",action:"Won't do"}};function nxr({itemId:e,status:t,target:r,onClose:n}){let{verb:i,action:o}=cQn[t],a=Yi(e),{busy:s,error:l,clearError:u,confirm:f}=rxr(e,t,`Failed to mark item ${a} as ${i}`,async()=>{n(),await r.onClosed()});return(0,jK.jsxs)(ia,{children:[(0,jK.jsx)(Di,{title:`Mark ${a} ${i}`,message:`${r.currentPhase??0} of ${r.totalPhases??0} phases completed. Mark this backlog item as ${i}?`,confirmLabel:o,busy:s,onConfirm:f,onCancel:n}),(0,jK.jsx)(Zl,{error:l,onClose:u})]})}var VUe=E(F(),1),uQn=[{status:"done",label:"Mark done"},{status:"wontdo",label:"Won't do"}];function ixr({anchorEl:e,open:t,onClose:r,onSelect:n,stop:i}){return(0,VUe.jsx)(Os,{anchorEl:e,open:t,onClose:r,onClick:i,children:uQn.map(({status:o,label:a})=>(0,VUe.jsx)(pn,{onClick:s=>{i(s),n(o)},children:a},o))})}var oxr=E(F(),1),axr=st((0,oxr.jsx)("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"MoreVert");var qUe=E(F(),1);function sxr({anchorRef:e,onClick:t}){return(0,qUe.jsx)(ir,{ref:e,"aria-label":"More actions",size:"small",onClick:t,children:(0,qUe.jsx)(axr,{fontSize:"small"})})}var YK=E(F(),1);function lxr({anchorRef:e,tooltip:t,disabled:r,onBuild:n,onMore:i}){return(0,YK.jsxs)(ie,{sx:{display:"flex",alignItems:"center",gap:.5},children:[(0,YK.jsx)(Gye,{compact:!0,tooltip:t,disabled:r,onClick:n}),(0,YK.jsx)(sxr,{anchorRef:e,onClick:i})]})}var c_=E(F(),1);function cxr({itemId:e,tooltip:t,disabled:r,onBuild:n,closeTarget:i}){let o=(0,KK.useRef)(null),[a,s]=(0,KK.useState)(!1),[l,u]=(0,KK.useState)(null),f=d=>d.stopPropagation();return(0,c_.jsxs)(c_.Fragment,{children:[(0,c_.jsx)(lxr,{anchorRef:o,tooltip:t,disabled:r,onBuild:d=>{f(d),n()},onMore:d=>{f(d),s(!0)}}),(0,c_.jsx)(ixr,{anchorEl:o.current,open:a,onClose:()=>s(!1),onSelect:d=>{s(!1),u(d)},stop:f}),l&&(0,c_.jsx)(nxr,{itemId:e,status:l,target:i,onClose:()=>u(null)})]})}var Zye=E(de(),1),jUe=(0,Zye.createContext)(()=>{});function uxr(){return(0,Zye.useContext)(jUe)}var Qye=E(F(),1);function fxr({session:e}){let t=gy(uxr());return(0,Qye.jsxs)(Dt,{variant:"contained",size:"small",startIcon:(0,Qye.jsx)(Dme,{}),onClick:r=>{r.stopPropagation(),t(e.id)},children:["Session ",e.id]})}function dxr(e,t,r,n){let i=r.node?[{node:r.node}]:[];e(["backlog","run",Yi(t),...n],r.cwd,...i)}function fQn(e,t){let r=e.assistArgs;if(r?.[0]!=="backlog"||r[1]!=="run"||!r[2])return!1;try{return tte(r[2])===t}catch{return!1}}function hxr(e,t){return e.find(r=>r.status!=="done"&&r.status!=="error"&&(fQn(r,t)||vB(r)?.itemId===t))}var Jye=E(de(),1),YUe=(0,Jye.createContext)({nodes:null,names:[],visible:!1,selected:void 0,select:()=>{}});function ef(){return(0,Jye.useContext)(YUe)}function e1e(){let{nodes:e,selected:t}=ef();return t&&t!==e?.local?t:void 0}var gxr=E(de(),1);var t1e=E(de(),1);function pxr(e,t){return Promise.all(t.map(async r=>{let n=await dQn(e,r).catch(()=>({}));return[r,n]}))}async function dQn(e,t){let r=await fetch(qr(`/api/repo-location?origin=${encodeURIComponent(e)}`,t||void 0));return r.ok?r.json():{}}var KUe="\0";function mxr(e,t){let[r,n]=(0,t1e.useState)(null);return(0,t1e.useEffect)(()=>{if(!e||!t)return;let i=!1;return pxr(e,t.split(KUe)).then(o=>{i||n({origin:e,byNode:Object.fromEntries(o)})}),()=>{i=!0}},[e,t]),r}function r1e(e,t){let{cloneOn:r,originOf:n}=$n(),i=e?n(e):void 0,o=t.filter(s=>!e||!r(e,s)).map(s=>s??"").join(KUe),a=mxr(i,o);return(0,gxr.useCallback)(s=>{let l=e?r(e,s):void 0;if(l)return{kind:"cloned",cwd:l};let u=a&&a.origin===i?a.byNode[s??""]:void 0;return u?.cwd?{kind:"cloned",cwd:u.cwd}:i&&u?.cloneTarget?{kind:"clonable",origin:i,cloneTarget:u.cloneTarget}:{kind:"unavailable"}},[e,r,i,a])}var M$=E(de(),1);var n1e=E(de(),1);function i1e(e){let t=(0,n1e.useRef)(null);return(0,n1e.useEffect)(()=>{e&&t.current?.scrollIntoView({block:"nearest"})},[e]),t}var vxr=E(F(),1);function yxr({cwd:e,selected:t,highlighted:r,onHover:n,onSelect:i}){let o=i1e(r);return(0,vxr.jsx)(pn,{ref:o,selected:t,title:e,onClick:i,onMouseEnter:n,sx:{fontSize:12,display:"flex",justifyContent:"space-between",gap:1,...r&&{bgcolor:"action.hover"}},children:bv(e)})}var XUe=E(F(),1);function o1e({repos:e,selected:t,highlight:r,onHighlight:n,onSelect:i}){return(0,XUe.jsx)(Fp,{dense:!0,children:e.map((o,a)=>(0,XUe.jsx)(yxr,{cwd:o,selected:o===t,highlighted:a===r,onHover:()=>n(a),onSelect:()=>i(o)},o))})}var a1e=E(de(),1);function u_(e,t,r,n){let[i,o]=(0,a1e.useState)(0);return(0,a1e.useEffect)(()=>{o(0)},[t]),{highlight:i,setHighlight:o,onKeyDown:s=>{let l=e.length;if(s.key==="ArrowDown")s.preventDefault(),l>0&&o(u=>(u+1)%l);else if(s.key==="ArrowUp")s.preventDefault(),l>0&&o(u=>(u-1+l)%l);else if(s.key==="Enter"){s.preventDefault();let u=e[i];u!==void 0&&(r(u),n())}else s.key==="Escape"&&(s.preventDefault(),n())}}}var XK=E(F(),1);function bv(e){let t=e.includes("\\")?"\\":"/";return e.split(t).filter(Boolean).pop()??e}var hQn={...SB};function bxr({repos:e,selected:t,onSelect:r,close:n,initialFilter:i=""}){let[o,a]=(0,M$.useState)(i),s=(0,M$.useRef)(null);(0,M$.useEffect)(()=>{s.current?.focus()},[]);let l=o.trim().toLowerCase(),u=l?e.filter(m=>m.toLowerCase().includes(l)):e,{highlight:f,setHighlight:d,onKeyDown:h}=u_(u,l,r,n);return(0,XK.jsxs)(un,{elevation:4,sx:hQn,children:[(0,XK.jsx)(cT,{inputRef:s,value:o,onChange:a,onKeyDown:h,placeholder:"Filter repos..."}),(0,XK.jsx)(o1e,{repos:u,selected:t,highlight:f,onHighlight:d,onSelect:m=>{r(m),n()}})]})}function s1e(e,t){return{origin:e.origin,cloneTarget:e.cloneTarget,displayName:bv(e.origin),node:t}}function xxr(){let e=Pa(),t=e1e(),r=r1e(e??"",[t])(t);return e?r.kind==="cloned"?{kind:"ready",cwd:r.cwd,node:t}:r.kind==="clonable"?{kind:"clone",prompt:s1e(r,t)}:{kind:"unavailable",node:t??"this machine"}:{kind:"ready",node:t}}function Sxr(e){return e?`Not cloned on ${e}`:"Build"}var ZK=E(F(),1);function l1e({itemId:e,compact:t}){let{launchAssist:r}=il(),n=xxr(),i=hxr(Hye(),e),[o,a]=(0,Txr.useState)(!1);if(n.kind==="clone")return(0,ZK.jsx)(txr,{target:n.prompt});if(i)return(0,ZK.jsx)(fxr,{session:i});let s=n.kind==="unavailable"?n.node:void 0,l=o||!!s,u=d=>{l||n.kind!=="ready"||(a(!0),dxr(r,e,n,d))},f=Sxr(s);return t?(0,ZK.jsx)(cxr,{itemId:e,tooltip:f,disabled:l,onBuild:()=>u([]),closeTarget:t}):(0,ZK.jsx)(Xbr,{tooltip:f,disabled:l,onBuild:()=>u([]),onSelectHarness:d=>u(["--harness",d])})}var Cxr=E(de(),1);var I$=E(F(),1);function wxr({itemId:e,starred:t,onToggled:r}){let n=Pa(),i=yr(),[o,a]=(0,Cxr.useState)(!1);return(0,I$.jsx)(lr,{title:t?"Unstar":"Star",children:(0,I$.jsx)("span",{children:(0,I$.jsx)(ir,{"aria-label":t?"Unstar":"Star","aria-pressed":t,color:t?"warning":"default",size:"small",disabled:o,onClick:async l=>{if(l.stopPropagation(),!o){a(!0);try{await xte(e,!t,n,i),await r()}finally{a(!1)}}},children:t?(0,I$.jsx)(mge,{}):(0,I$.jsx)(gge,{})})})})}var kxr=E(F(),1),_xr=st((0,kxr.jsx)("path",{d:"M22 7h-9v2h9zm0 8h-9v2h9zM5.54 11 2 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41zm0 8L2 15.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41z"}),"Checklist");var QK=E(F(),1),pQn={display:"inline-flex",alignItems:"center",gap:.375,flexShrink:0,fontSize:"0.71875rem",color:"text.secondary","& svg":{fontSize:14}};function Exr({count:e}){return e<1?null:(0,QK.jsx)(lr,{title:`${e} incomplete subtask${e===1?"":"s"}`,children:(0,QK.jsxs)(ie,{component:"span",sx:pQn,children:[(0,QK.jsx)(_xr,{}),e]})})}var J2=E(F(),1);function Rxr({item:e,onReload:t}){return(0,J2.jsxs)(J2.Fragment,{children:[(0,J2.jsx)(Exr,{count:e.incompleteSubtasks}),(0,J2.jsx)(Kbr,{item:e}),(0,J2.jsx)(wxr,{itemId:e.id,starred:e.starred,onToggled:t}),Wye(e)&&(0,J2.jsx)(l1e,{itemId:e.id,compact:{currentPhase:e.currentPhase,totalPhases:e.totalPhases,onClosed:t}})]})}var eS=E(F(),1);function mQn(e,t){return e?t?yv.inProgressRunningCard:yv.inProgressCard:yv.card}function Axr({item:e,to:t,socket:r,onReload:n}){let i=Vbr(r.sessions,e.id),o=e.status==="in-progress",a=o&&i?.status==="running";return(0,eS.jsxs)(ie,{sx:mQn(o,a),children:[(0,eS.jsx)(qbr,{status:e.status}),(0,eS.jsxs)(ie,{sx:yv.main,children:[(0,eS.jsx)(Kr,{component:Cs,to:t,underline:"none",title:e.name,sx:yv.stretchedNameLink,children:e.name}),(0,eS.jsx)(Gbr,{item:e,openSession:i,onSelectSession:r.selectSession})]}),(0,eS.jsx)(ie,{sx:yv.actions,children:(0,eS.jsx)(Rxr,{item:e,onReload:n})})]})}var Lxr=E(F(),1),gQn={all:"items",story:"stories",bug:"bugs"},yQn={textAlign:"center",color:"text.disabled",py:6,px:2};function Pxr({query:e,typeFilter:t}){let r=gQn[t],n=e.trim()?`No ${r} match your search.`:`No ${r} in the backlog.`;return(0,Lxr.jsx)(ie,{sx:yQn,children:n})}var xv=E(F(),1),vQn={display:"flex",justifyContent:"center",py:6};function Mxr({loading:e,error:t,query:r,typeFilter:n,items:i,socket:o,itemPath:a,onReload:s}){if(e)return(0,xv.jsx)(ie,{sx:vQn,children:(0,xv.jsx)(oo,{})});let l=t&&(0,xv.jsx)(ai,{severity:"error",children:t});return i.length===0?l||(0,xv.jsx)(Pxr,{query:r,typeFilter:n}):(0,xv.jsxs)(xv.Fragment,{children:[l,i.map(u=>(0,xv.jsx)(Axr,{item:u,to:a(u),socket:o,onReload:s},u.id))]})}var D$=E(de(),1);function bQn(e){let t=new URLSearchParams;for(let n of e)t.append("knownCwd",n);let r=t.toString();return r?`/api/backlog/summary?${r}`:"/api/backlog/summary"}async function Ixr({cwd:e,node:t,knownCwds:r,signal:n}){return(await fetch(jl(bQn(r),e,t),{signal:n})).json()}function Dxr(){let{repos:e,selectedCwd:t,cloneOn:r}=$n(),n=e1e(),[i,o]=(0,D$.useState)([]),a=(0,D$.useMemo)(()=>e.map(l=>r(l,n)).filter(l=>!!l),[e,r,n]),s=t?r(t,n):void 0;return(0,D$.useEffect)(()=>{let l=new AbortController;return Ixr({cwd:s,node:n,knownCwds:a,signal:l.signal}).then(o).catch(()=>{}),()=>l.abort()},[a,s,n]),{summaries:i,node:n}}var c1e=E(F(),1),xQn={borderStyle:"dashed"};function Nxr({summary:e,node:t,onSelectCwd:r,onRequestClone:n}){let{origin:i,displayName:o,openCount:a,isCurrent:s,cwd:l,cloneTarget:u}=e,f=!l&&!!u,d=l?()=>r(l):f&&u?()=>n({origin:i,cloneTarget:u,displayName:o,node:t}):void 0,h=(0,c1e.jsx)(tn,{label:`${o} (${a})`,size:"small",color:s?"primary":"default",variant:s?"filled":"outlined",disabled:!l&&!f,onClick:d,icon:f?(0,c1e.jsx)(P$,{}):void 0,sx:f?xQn:void 0});return!f||!u?h:(0,c1e.jsx)(lr,{describeChild:!0,title:L$(t,u),children:h})}var JK=E(F(),1),SQn={flexWrap:"wrap",gap:1,mb:2};function Oxr({sessions:e}){let{summaries:t,node:r}=Dxr(),{setSelectedCwd:n}=$n(),i=Xye(e);return t.length===0?null:(0,JK.jsxs)(_t,{direction:"row",sx:SQn,children:[t.map(o=>(0,JK.jsx)(Nxr,{summary:o,node:r,onSelectCwd:a=>r?n(a,r):n(a),onRequestClone:i.requestClone},o.origin)),(0,JK.jsx)(Yye,{clone:i})]})}var $xr=E(F(),1);function Bxr({value:e,onChange:t}){return(0,$xr.jsx)(Qn,{"data-backlog-focus":"search",autoFocus:!0,fullWidth:!0,size:"small",placeholder:"Search backlog\u2026",value:e,onChange:r=>t(r.target.value),sx:{mb:2}})}var u1e=E(de(),1);var f1e=E(F(),1);async function TQn(){return(await(await fetch("/api/backups/list")).json())[0]}function Fxr(){let[e,t]=(0,u1e.useState)();return(0,u1e.useEffect)(()=>{TQn().then(t)},[]),e?(0,f1e.jsx)(lr,{title:new Date(e.createdAt).toLocaleString(),children:(0,f1e.jsxs)(Kr,{component:Cs,to:"/backups",underline:"hover",color:"text.secondary",variant:"body2",children:["Last backed up ",_o(String(e.createdAt))]})}):null}var N$=E(F(),1);function zxr(){let[e,t]=R$();return(0,N$.jsxs)(Eu,{value:e,exclusive:!0,size:"small","aria-label":"Status filter",onChange:(r,n)=>{n!==null&&t(n)},children:[(0,N$.jsx)(bs,{value:"todo",children:"Todo"}),(0,N$.jsx)(bs,{value:"done",children:"Done"}),(0,N$.jsx)(bs,{value:"all",children:"All"})]})}var O$=E(F(),1);function Hxr({value:e,onChange:t}){return(0,O$.jsxs)(Eu,{value:e,exclusive:!0,size:"small","aria-label":"Type filter",onChange:(r,n)=>{n!==null&&t(n)},children:[(0,O$.jsx)(bs,{value:"all",children:"All"}),(0,O$.jsx)(bs,{value:"story",children:"Stories"}),(0,O$.jsx)(bs,{value:"bug",children:"Bugs"})]})}var f_=E(F(),1),CQn={justifyContent:"space-between",alignItems:"center",mb:3},wQn={fontWeight:600},kQn={alignItems:"center"};function Uxr({typeFilter:e,onTypeFilterChange:t}){return(0,f_.jsxs)(_t,{direction:"row",sx:CQn,children:[(0,f_.jsx)(Le,{variant:"h5",sx:wQn,children:"Backlog"}),(0,f_.jsxs)(_t,{direction:"row",spacing:2,sx:kQn,children:[(0,f_.jsx)(Fxr,{}),(0,f_.jsx)(Hxr,{value:e,onChange:t}),(0,f_.jsx)(zxr,{})]})]})}var tS=E(F(),1);function Gxr({items:e,loading:t,error:r,socket:n,onReload:i}){let o=Pa(),a=yr(),{query:s,setQuery:l,results:u,loading:f}=Dbr(),[d,h]=(0,Wxr.useState)("all"),p=u??e,m=d==="all"?p:p.filter(g=>g.type===d);return(0,tS.jsxs)(tS.Fragment,{children:[(0,tS.jsx)(Uxr,{typeFilter:d,onTypeFilterChange:h}),(0,tS.jsx)(Bxr,{value:s,onChange:l}),(0,tS.jsx)(Oxr,{sessions:n.sessions}),(0,tS.jsx)(Mxr,{loading:t||f,error:u?null:r,query:s,typeFilter:d,items:m,socket:n,itemPath:g=>fT(g.id,o,a),onReload:i})]})}var b1e=E(de(),1);var vA=E(de(),1);async function ZUe(e,t,r){let n=await fetch(jl(`/api/items/${Yi(e)}`,t.cwd,t.node),{signal:r});return n.ok?n.json():null}function Vxr(e){let t=Pa(),r=yr(),[n,i]=(0,vA.useState)(null),[o,a]=(0,vA.useState)(!0),s=(0,vA.useCallback)(async()=>{i(await ZUe(e,{cwd:t,node:r}))},[e,t,r]);return(0,vA.useEffect)(()=>{let l=new AbortController,{signal:u}=l;return a(!0),(async()=>{try{let f=await ZUe(e,{cwd:t,node:r},u);if(u.aborted)return;i(f),a(!1)}catch(f){if(!u.aborted)throw f}})(),()=>l.abort()},[e,t,r]),{item:n,loading:o,reload:s}}var d_={description:"item-section-description",acceptanceCriteria:"item-section-acceptance-criteria",subtasks:"item-section-subtasks",plan:"item-section-plan",activity:"item-section-activity",comments:"item-section-comments"},eX=140,QUe="--pinned-header-height",d1e=`var(${QUe}, ${eX}px)`,qxr=`calc(${d1e} + 8px)`;function ag(e){return{id:d_[e],sx:{mb:2,scrollMarginTop:qxr}}}function h1e(e){return{id:`item-phase-${e}`,sx:{scrollMarginTop:qxr}}}var h_=E(F(),1);function jxr({criteria:e}){return e.length===0?null:(0,h_.jsxs)(ie,{...ag("acceptanceCriteria"),children:[(0,h_.jsx)(Le,{variant:"overline",sx:{color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"},children:"Acceptance Criteria"}),(0,h_.jsx)(Q0,{disablePadding:!0,sx:{maxWidth:"72ch"},children:e.map((t,r)=>(0,h_.jsxs)(ES,{disableGutters:!0,disablePadding:!0,sx:{py:.5,display:"flex",alignItems:"baseline"},children:[(0,h_.jsxs)(Le,{component:"span",sx:{color:"text.secondary",mr:1},children:[r+1,"."]}),(0,h_.jsx)(Nu,{component:"span",className:"markdown",html:U9(t)})]},t))})]})}var tX=E(F(),1),_Qn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function Yxr({description:e}){return e?(0,tX.jsxs)(ie,{...ag("description"),children:[(0,tX.jsx)(Le,{variant:"overline",sx:_Qn,children:"Description"}),(0,tX.jsx)(Yw,{content:e,renderMermaid:!0})]}):null}var n2r=E(de(),1);function Kxr(e,t=10){let r=i=>e.filter(o=>o.kind===i).reverse(),n=r("commit");return{branches:r("branch"),commits:n.slice(0,t),overflowCommits:n.slice(t),prs:r("pr"),slacks:r("slack"),sessions:r("session")}}var Zxr=E(F(),1),EQn={color:"text.secondary",alignSelf:"flex-start",textAlign:"left"};function Xxr({hiddenCount:e,expanded:t,onToggle:r}){return e===0?null:(0,Zxr.jsx)(Kr,{component:"button",type:"button",variant:"body2",underline:"hover",sx:EQn,onClick:n=>{n.stopPropagation(),r()},children:t?"Show fewer commits":`\u2026 and ${e} more commits`})}var bA=E(F(),1),RQn={display:"flex",alignItems:"center",gap:1},AQn={color:"text.secondary",fontFamily:"monospace"},PQn={flex:1,overflowWrap:"anywhere"},LQn={color:"text.disabled","&:hover":{color:"text.primary"}};function Qxr({conversation:e}){let{resumeSession:t}=il(),r=n=>{n.stopPropagation(),t(e.sessionId,e.cwd??"",e.title,e.harness)};return(0,bA.jsxs)(ie,{sx:RQn,children:[(0,bA.jsx)(Le,{variant:"body2",component:"span",sx:AQn,children:"session"}),(0,bA.jsx)(Le,{variant:"body2",component:"span",sx:PQn,children:e.title??e.sessionId}),(0,bA.jsx)(ir,{size:"small",title:"Resume",sx:LQn,onClick:r,children:(0,bA.jsx)(Rg,{sx:{fontSize:14}})})]})}var e2r=E(F(),1),MQn={color:"text.disabled",ml:1};function Jxr({gitRef:e}){return e.kind!=="commit"||!e.createdAt?null:(0,e2r.jsx)(ie,{component:"span",sx:MQn,children:IQn(e.createdAt)})}function IQn(e){return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function t2r(e){if(e.kind==="commit"){let t=e.title?` ${e.title}`:"";return`${e.ref.slice(0,8)}${t}`}if(e.kind==="pr"){let t=e.title?` ${e.title}`:"",r=e.state?` (${e.state.toLowerCase()})`:"";return`#${e.ref}${t}${r}`}return e.kind==="slack"||e.kind==="session"?e.title??e.ref:e.ref}var Sv=E(F(),1),DQn={color:"text.secondary",mr:1,fontFamily:"monospace"};function NQn({gitRef:e}){let t=t2r(e);return!e.url||e.kind==="session"?(0,Sv.jsx)(Sv.Fragment,{children:t}):(0,Sv.jsx)(Kr,{href:e.url,target:"_blank",rel:"noopener",onClick:r=>r.stopPropagation(),children:t})}function r2r({gitRef:e}){return(0,Sv.jsxs)(Le,{variant:"body2",children:[(0,Sv.jsx)(ie,{component:"span",sx:DQn,children:e.kind}),(0,Sv.jsx)(NQn,{gitRef:e}),(0,Sv.jsx)(Jxr,{gitRef:e})]})}var p_=E(F(),1),OQn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function i2r({gitRefs:e,conversations:t=[]}){let[r,n]=(0,n2r.useState)(!1),{branches:i,commits:o,overflowCommits:a,prs:s,slacks:l}=Kxr(e),u=[...i,...o,...r?a:[],...s,...l];return u.length===0&&t.length===0?null:(0,p_.jsxs)(ie,{...ag("activity"),children:[(0,p_.jsx)(Le,{variant:"overline",sx:OQn,children:"Activity"}),(0,p_.jsxs)(_t,{spacing:1,children:[u.map(f=>(0,p_.jsx)(r2r,{gitRef:f},`${f.kind}:${f.ref}`)),t.map(f=>(0,p_.jsx)(Qxr,{conversation:f},f.sessionId)),(0,p_.jsx)(Xxr,{hiddenCount:a.length,expanded:r,onToggle:()=>n(f=>!f)})]})]})}var xA=E(F(),1),BQn={alignItems:"center",fontSize:"0.75rem",color:"text.secondary",mb:.5},$Qn={color:"text.disabled"},FQn={fontWeight:500},zQn={summary:"Phase summary",comment:"Comment"};function o2r({comment:e}){return(0,xA.jsxs)(_t,{direction:"row",spacing:.5,sx:BQn,children:[e.id!==void 0&&(0,xA.jsxs)(Le,{variant:"caption",sx:$Qn,children:["#",e.id]}),(0,xA.jsx)(Le,{variant:"caption",sx:FQn,children:zQn[e.type]}),e.phase!==void 0&&(0,xA.jsxs)(Le,{variant:"caption",children:["\xB7 Phase ",e.phase]}),(0,xA.jsxs)(Le,{variant:"caption",children:["\xB7 ",HQn(e.timestamp)]})]})}function HQn(e){return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}var a2r=E(F(),1),s2r=st((0,a2r.jsx)("path",{d:"M16 9v10H8V9zm-1.5-6h-5l-1 1H5v2h14V4h-3.5zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2z"}),"DeleteOutlined");var JUe=E(de(),1);async function l2r(e,t,r,n){let i=await fetch(jl(`/api/items/${Yi(e)}/comments/${t}`,r,n),{method:"DELETE"});if(!i.ok){let o=await i.json().catch(()=>{});throw new Error(o?.error??`Failed to delete comment (${i.status})`)}}var Tv=E(F(),1),UQn={mt:-.5,mr:-.5,color:"text.secondary"};function c2r({itemId:e,commentId:t,onDeleted:r}){let n=Pa(),i=yr(),[o,a]=(0,JUe.useState)(!1),[s,l]=(0,JUe.useState)(),u=()=>l(void 0);return(0,Tv.jsxs)(Tv.Fragment,{children:[o&&(0,Tv.jsx)(Di,{message:"Are you sure you want to delete this comment?",onConfirm:async()=>{a(!1);try{await l2r(e,t,n,i),await r()}catch(f){l(f instanceof Error?f.message:"Failed to delete comment")}},onCancel:()=>a(!1)}),(0,Tv.jsx)(pl,{open:s!==void 0,autoHideDuration:6e3,onClose:u,children:(0,Tv.jsx)(ai,{severity:"error",variant:"filled",onClose:u,children:s})}),(0,Tv.jsx)(ir,{"aria-label":"Delete comment",size:"small",sx:UQn,onClick:()=>a(!0),children:(0,Tv.jsx)(s2r,{fontSize:"inherit"})})]})}var SA=E(F(),1),WQn={summary:{bgcolor:"warning.light",borderColor:"warning.dark"},comment:{bgcolor:"action.selected",borderColor:"divider"}},GQn={justifyContent:"space-between",alignItems:"flex-start"},VQn={color:"text.primary",whiteSpace:"pre-wrap"};function qQn(e){return{p:1.5,bgcolor:e.bgcolor,borderColor:e.borderColor}}function u2r({comment:e,itemId:t,onDeleted:r}){return(0,SA.jsxs)(un,{variant:"outlined",sx:qQn(WQn[e.type]),children:[(0,SA.jsxs)(_t,{direction:"row",sx:GQn,children:[(0,SA.jsx)(o2r,{comment:e}),e.id!==void 0&&t!==void 0&&r&&(0,SA.jsx)(c2r,{itemId:t,commentId:e.id,onDeleted:r})]}),(0,SA.jsx)(Le,{variant:"body2",sx:VQn,children:e.text})]})}var B$=E(F(),1),jQn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function f2r({comments:e,itemId:t,onCommentDeleted:r}){return e.length===0?null:(0,B$.jsxs)(ie,{...ag("comments"),children:[(0,B$.jsx)(Le,{variant:"overline",sx:jQn,children:"Comments"}),(0,B$.jsx)(_t,{spacing:1,children:e.map((n,i)=>(0,B$.jsx)(u2r,{comment:n,itemId:t,onDeleted:r},`${n.timestamp}-${i}`))})]})}var d2r=E(F(),1);function $$({total:e,sx:t}){return(0,d2r.jsx)(Le,{sx:t,children:Uye(e)})}var p2r=E(F(),1),YQn={color:"text.secondary",fontSize:"0.75rem"};function h2r({usage:e}){let t={tokensUp:e.reduce((r,n)=>r+n.tokensUp,0),tokensDown:e.reduce((r,n)=>r+n.tokensDown,0),activeMs:e.reduce((r,n)=>r+n.activeMs,0),peakContextPct:e.reduce((r,n)=>Math.max(r,n.peakContextPct),0)};return(0,p2r.jsx)($$,{total:t,sx:YQn})}var rS=E(F(),1);function m2r({checks:e}){return(0,rS.jsxs)(ie,{sx:{mt:1,pt:1},children:[(0,rS.jsx)(Vi,{sx:{mb:1}}),(0,rS.jsx)(Le,{variant:"overline",sx:{color:"text.disabled",letterSpacing:"0.08em"},children:"Manual Checks"}),(0,rS.jsx)(Q0,{disablePadding:!0,sx:{ml:.5,mt:.5},children:e.map(t=>(0,rS.jsxs)(ES,{disableGutters:!0,disablePadding:!0,sx:{py:.25,display:"flex",alignItems:"baseline"},children:[(0,rS.jsx)(Le,{component:"span",sx:{mr:1,fontSize:"0.875rem",color:"text.secondary"},children:"\u2610"}),(0,rS.jsx)(Nu,{component:"span",className:"markdown",sx:{fontSize:"0.875rem",color:"text.secondary"},html:U9(t)})]},t))})]})}var p1e={done:{borderColor:"success.light",bgcolor:"success.light"},current:{borderColor:"info.main",bgcolor:"info.light",ring:"info.light"},upcoming:{borderColor:"divider",bgcolor:"background.paper"}};function g2r(e){let t=p1e[e];return{p:2,borderColor:t.ring?"info.main":t.borderColor,bgcolor:t.bgcolor,...t.ring?{boxShadow:"0 0 0 2px"}:{}}}var y2r={done:"\u2713",current:"\u2022",upcoming:"\u2022"};var x2r=E(de(),1);var v2r=E(de(),1),Cv=E(F(),1);function b2r({phaseName:e,onConfirm:t,onCancel:r}){let[n,i]=(0,v2r.useState)("");return(0,Cv.jsxs)(Wl,{open:!0,onClose:r,maxWidth:"xs",fullWidth:!0,children:[(0,Cv.jsxs)(wu,{children:["Rewind to ",e,"?"]}),(0,Cv.jsxs)(Cu,{children:[(0,Cv.jsx)(Le,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"This will mark all later phases as incomplete."}),(0,Cv.jsx)(Qn,{fullWidth:!0,multiline:!0,rows:3,size:"small",placeholder:"Reason for rewinding...",value:n,onChange:o=>i(o.target.value)})]}),(0,Cv.jsxs)(cd,{children:[(0,Cv.jsx)(Dt,{onClick:r,children:"Cancel"}),(0,Cv.jsx)(Dt,{variant:"contained",color:"warning",disabled:n.trim().length===0,onClick:()=>t(n.trim()),children:"Rewind"})]})]})}var TA=E(F(),1);function S2r({itemId:e,phaseNumber:t,phaseName:r,onRewound:n}){let i=Pa(),o=yr(),[a,s]=(0,x2r.useState)(!1);return(0,TA.jsxs)(TA.Fragment,{children:[(0,TA.jsx)(Dt,{size:"small",color:"warning",variant:"outlined",onClick:()=>s(!0),sx:{ml:"auto",textTransform:"none",fontSize:"0.75rem"},children:"Rewind"}),a&&(0,TA.jsx)(b2r,{phaseName:r,onConfirm:async l=>{await tit(e,t,l,i,o),await n()},onCancel:()=>s(!1)})]})}var F$=E(F(),1),KQn={done:{label:"Done",color:"success"},current:{label:"In Progress",color:"info"},upcoming:{label:"Upcoming",color:"default"}},XQn={alignItems:"center",mb:1},ZQn={fontWeight:500},QQn={fontWeight:500,fontSize:"0.75rem"};function T2r({phase:e,index:t,status:r,itemId:n,onRewind:i}){let o=KQn[r],a=r==="done"&&n!==void 0&&i;return(0,F$.jsxs)(_t,{direction:"row",spacing:1,sx:XQn,children:[(0,F$.jsxs)(Le,{sx:ZQn,children:["Phase ",t+1,": ",e.name]}),(0,F$.jsx)(tn,{label:o.label,size:"small",color:o.color,sx:QQn}),a&&(0,F$.jsx)(S2r,{itemId:n,phaseNumber:t+1,phaseName:e.name,onRewound:i})]})}var rX=E(F(),1),JQn={color:"text.secondary",fontSize:"0.75rem",letterSpacing:"0.08em",display:"block"},eJn={color:"text.secondary",fontSize:"0.75rem",fontFamily:"monospace",display:"block"};function C2r({sessions:e}){return(0,rX.jsxs)(ie,{sx:{mb:1},children:[(0,rX.jsx)(Le,{variant:"overline",sx:JQn,children:"Sessions"}),e.map(t=>(0,rX.jsx)(Le,{sx:eJn,children:`${t.hostname} / ${t.osUser} / ${t.claudeSessionId}`},t.claudeSessionId))]})}var k2r=E(F(),1),tJn={color:"text.secondary",fontSize:"0.75rem",mb:1,display:"block"};function w2r({usage:e}){return(0,k2r.jsx)($$,{total:e,sx:tJn})}var z$=E(F(),1);function _2r({tasks:e,marker:t}){return(0,z$.jsx)(Q0,{disablePadding:!0,sx:{ml:.5},children:e.map(r=>(0,z$.jsxs)(ES,{disableGutters:!0,disablePadding:!0,sx:{py:.25,display:"flex",alignItems:"baseline"},children:[(0,z$.jsx)(Le,{component:"span",sx:{color:"text.secondary",mr:1},children:t}),(0,z$.jsx)(Nu,{component:"span",className:"markdown",html:U9(r.task)})]},r.task))})}var m_=E(F(),1);function E2r({phase:e,index:t,status:r,itemId:n,usage:i,sessions:o,onRewind:a}){let s=e.manualChecks??[],l=h1e(t);return(0,m_.jsxs)(un,{variant:"outlined",id:l.id,sx:{...g2r(r),...l.sx},children:[(0,m_.jsx)(T2r,{phase:e,index:t,status:r,itemId:n,onRewind:a}),i&&(0,m_.jsx)(w2r,{usage:i}),(0,m_.jsx)(_2r,{tasks:e.tasks,marker:y2r[r]}),s.length>0&&(0,m_.jsx)(m2r,{checks:s}),o&&o.length>0&&(0,m_.jsx)(C2r,{sessions:o})]})}var nX={name:"Review",tasks:[]};function m1e(e){return e.at(-1)?.name===nX.name?e.length-1:e.length}function g1e(e,t){if(t===void 0)return"upcoming";let r=e+1;return r<t?"done":r===t?"current":"upcoming"}function R2r(e=[]){return new Map(e.map(t=>[t.phaseIdx,t]))}function A2r(e=[]){let t=new Map;for(let r of e){let n=t.get(r.phaseIdx);n?n.push(r):t.set(r.phaseIdx,[r])}return t}var eWe=E(F(),1);function P2r({phases:e,currentPhase:t,itemId:r,usage:n,sessions:i,onRewind:o}){let a=R2r(n),s=A2r(i),l=m1e(e),u=(i??[]).filter(d=>d.phaseIdx>=l),f=l===e.length&&u.length>0?[...e,nX]:e;return(0,eWe.jsx)(_t,{spacing:1.5,children:f.map((d,h)=>(0,eWe.jsx)(E2r,{phase:d,index:h,status:g1e(h,t),itemId:r,usage:a.get(h),sessions:h===l?u:s.get(h),onRewind:h<e.length?o:void 0},d.name))})}var CA=E(F(),1),rJn={alignItems:"baseline",justifyContent:"space-between",mb:1},nJn={color:"text.secondary",display:"block",letterSpacing:"0.08em"};function L2r({phases:e,currentPhase:t,itemId:r,usage:n,sessions:i,onRewind:o}){return e.length===0?null:(0,CA.jsxs)(ie,{...ag("plan"),children:[(0,CA.jsxs)(_t,{direction:"row",sx:rJn,children:[(0,CA.jsx)(Le,{variant:"overline",sx:nJn,children:"Plan"}),n&&n.length>0&&(0,CA.jsx)(h2r,{usage:n})]}),(0,CA.jsx)(P2r,{phases:e,currentPhase:t,itemId:r,usage:n,sessions:i,onRewind:o})]})}var tWe=E(F(),1),y1e=e=>{let{value:t,options:r,colors:n,onChange:i}=e;return(0,tWe.jsx)(PS,{value:t,onChange:o=>i(o.target.value),size:"small",sx:{fontSize:"0.75rem",fontWeight:500,borderRadius:4,bgcolor:n[t].bg,color:n[t].text,"& .MuiSelect-select":{py:.5,px:1.5},"& .MuiSelect-icon":{color:"inherit"}},children:r.map(o=>(0,tWe.jsx)(pn,{value:o,children:o},o))})};var I2r=E(F(),1),iJn={todo:{bg:"action.selected",text:"text.primary"},"in-progress":{bg:"warning.main",text:"warning.contrastText"},done:{bg:"success.main",text:"success.contrastText"}},oJn=["todo","in-progress","done"];function M2r({current:e,onStatusChange:t}){return(0,I2r.jsx)(y1e,{value:e,options:oJn,colors:iJn,onChange:t})}var g_=E(F(),1);function D2r({subtask:e,onStatusChange:t}){let r=e.status==="done";return(0,g_.jsxs)(_t,{direction:"row",spacing:1,sx:{alignItems:"flex-start",justifyContent:"space-between"},children:[(0,g_.jsxs)(ie,{sx:{flex:1},children:[(0,g_.jsx)(Le,{variant:"body2",sx:{textDecoration:r?"line-through":"none",color:r?"text.disabled":"text.primary"},children:e.title}),e.description&&(0,g_.jsx)(ie,{sx:{mt:.5,fontSize:"0.8125rem",color:r?"text.disabled":"text.secondary"},children:(0,g_.jsx)(Yw,{content:e.description})})]}),(0,g_.jsx)(M2r,{current:e.status,onStatusChange:t})]})}var wA=E(F(),1),aJn={color:"text.secondary",mb:1,display:"block",letterSpacing:"0.08em"};function N2r({subtasks:e,onStatusChange:t}){if(e.length===0)return null;let r=e.filter(n=>n.status!=="done").length;return(0,wA.jsxs)(ie,{...ag("subtasks"),children:[(0,wA.jsx)(Le,{variant:"overline",sx:aJn,children:"Sub-tasks"}),(0,wA.jsx)(_t,{spacing:1,children:e.map((n,i)=>(0,wA.jsx)(D2r,{subtask:n,onStatusChange:o=>t(i,o)},`${n.title}-${i}`))}),r>0&&(0,wA.jsxs)(ai,{severity:"warning",sx:{mt:1},children:[r," sub-task",r===1?"":"s"," not yet done."]})]})}var nS=E(F(),1);function O2r({item:e,onRewind:t,onCommentDeleted:r,onSubtaskStatusChange:n}){return(0,nS.jsxs)(nS.Fragment,{children:[e.subtasks&&n&&(0,nS.jsx)(N2r,{subtasks:e.subtasks,onStatusChange:n}),e.plan&&(0,nS.jsx)(L2r,{phases:e.plan,currentPhase:e.currentPhase,itemId:e.id,usage:e.phaseUsage,sessions:e.phaseSessions,onRewind:t}),(0,nS.jsx)(i2r,{gitRefs:e.gitRefs??[],conversations:e.conversations}),e.comments&&(0,nS.jsx)(f2r,{comments:e.comments,itemId:e.id,onCommentDeleted:r})]})}var H$=E(F(),1);function B2r({item:e,onRewind:t,onCommentDeleted:r,onSubtaskStatusChange:n}){return(0,H$.jsxs)(ie,{sx:{pt:2,flex:1,minWidth:0},children:[(0,H$.jsx)(Yxr,{description:e.description}),(0,H$.jsx)(jxr,{criteria:e.acceptanceCriteria}),(0,H$.jsx)(O2r,{item:e,onRewind:t,onCommentDeleted:r,onSubtaskStatusChange:n})]})}var $2r="item-detail";var iX={wideQuery:`@container ${$2r} (min-width: 760px)`,containerSx:{containerType:"inline-size",containerName:$2r},columnsSx:{display:"flex",columnGap:3}};function sJn(e){let t=e.plan??[];if(t.length===0)return[];let r=m1e(t),i=r===t.length&&(e.phaseSessions??[]).some(o=>o.phaseIdx>=r)?[...t,nX]:t;return[{id:d_.plan,label:"Phases"},...i.map((o,a)=>({id:h1e(a).id,label:`${a+1}`,title:o.name,status:g1e(a,e.currentPhase),nested:!0}))]}function F2r(e){let t=[];return e.description&&t.push({id:d_.description,label:"Description"}),e.acceptanceCriteria.length>0&&t.push({id:d_.acceptanceCriteria,label:"Acceptance Criteria"}),(e.subtasks?.length??0)>0&&t.push({id:d_.subtasks,label:"Sub-tasks"}),t.push(...sJn(e)),(e.gitRefs?.length??0)+(e.conversations?.length??0)>0&&t.push({id:d_.activity,label:"Activity"}),(e.comments?.length??0)>0&&t.push({id:d_.comments,label:"Comments"}),t}var z2r="1.3125rem",H2r={position:"relative",borderRadius:1,"&::after":{content:'""',position:"absolute",inset:0,borderRadius:"inherit",pointerEvents:"none"},"&:hover::after":{bgcolor:"action.hover"},"&:active::after":{bgcolor:"action.selected"}},lJn={...H2r,display:"block",flexShrink:0,maxWidth:"100%",px:1,py:.5,border:0,bgcolor:"transparent",fontSize:z2r,lineHeight:1.2,letterSpacing:"0.02em",textAlign:"left",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:"text.secondary"},cJn={...H2r,display:"flex",alignItems:"center",justifyContent:"center",fontSize:z2r,width:"2em",height:"2em",flexShrink:0,lineHeight:1,borderRadius:"50%",border:1,color:"text.primary"},uJn={borderColor:"text.primary",borderWidth:3},fJn={color:"text.primary",fontWeight:700,"&::after":{bgcolor:"action.selected"}};function U2r(e,t){let r=e.status&&p1e[e.status];return r?{...cJn,ml:1.5,bgcolor:r.bgcolor,borderColor:r.borderColor,borderWidth:r.ring?3:1,...t&&uJn}:{...lJn,...t&&fJn}}var G2r=E(F(),1);function W2r({section:e,active:t,onSelect:r}){return(0,G2r.jsx)(En,{sx:U2r(e,t),onClick:()=>r(e.id),title:e.title??e.label,"aria-current":t?"true":void 0,children:e.label})}function V2r(e,t=eX){return mme(e,t)}var rWe=E(F(),1),dJn=48,hJn=260,pJn={display:"none",[iX.wideQuery]:{display:"flex"},position:"sticky",top:d1e,alignSelf:"flex-start",width:hJn,flexShrink:0,maxHeight:`calc(100vh - ${dJn}px - ${d1e})`,alignItems:"flex-start",overflowY:"auto",overflowX:"hidden",py:2};function mJn(e){document.getElementById(e)?.scrollIntoView({behavior:"smooth",block:"start"})}function q2r({item:e,headerHeight:t}){let r=F2r(e),n=V2r(r.map(i=>i.id),t);return r.length===0?null:(0,rWe.jsx)(_t,{component:"nav",spacing:1,sx:pJn,children:r.map(i=>(0,rWe.jsx)(W2r,{section:i,active:i.id===n,onSelect:mJn},i.id))})}var Y2r=E(F(),1);function j2r({to:e}){let t=Ii();return(0,Y2r.jsx)(Dt,{"data-backlog-focus":"back",variant:"text",size:"small",onClick:()=>t(e),sx:{mb:2,textTransform:"none"},children:"\u2190 Back"})}var K2r=E(de(),1);var kA=E(F(),1);function X2r({itemId:e,onDeleted:t}){let r=Pa(),n=yr(),[i,o]=(0,K2r.useState)(!1);return(0,kA.jsxs)(kA.Fragment,{children:[i&&(0,kA.jsx)(Di,{onConfirm:async()=>{await Jnt(e,r,n),await t()},onCancel:()=>o(!1)}),(0,kA.jsx)(Dt,{variant:"contained",color:"error",size:"small",onClick:()=>o(!0),children:"Delete"})]})}var nWe=E(F(),1),gJn={todo:{bg:"action.selected",text:"text.primary"},"in-progress":{bg:"warning.main",text:"warning.contrastText"},done:{bg:"success.main",text:"success.contrastText"},wontdo:{bg:"error.main",text:"error.contrastText"}},yJn=["todo","in-progress","done","wontdo"];function Z2r({current:e,onStatusChange:t}){return t?(0,nWe.jsx)(y1e,{value:e,options:yJn,colors:gJn,onChange:t}):(0,nWe.jsx)(tn,{label:e,size:"small",color:Dye[e],sx:{fontWeight:500,fontSize:"0.75rem"}})}var iS=E(F(),1),vJn={alignItems:"center",color:"text.disabled",fontSize:"0.875rem"},bJn={fontWeight:500,fontSize:"0.75rem"},xJn={color:"text.secondary",fontSize:"0.75rem"};function Q2r({item:e,onStatusChange:t}){let r=Iye[e.type];return(0,iS.jsxs)(_t,{direction:"row",spacing:1,sx:vJn,children:[(0,iS.jsx)(Le,{variant:"body2",color:"text.disabled",children:Yi(e.id)}),r&&(0,iS.jsx)(tn,{label:e.type,size:"small",color:r,sx:bJn}),(0,iS.jsx)(Z2r,{current:e.status,onStatusChange:t}),(0,iS.jsx)(fL,{jiraKey:e.jiraKey}),(0,iS.jsx)(uT,{githubIssue:e.githubIssue,origin:e.origin}),e.usageTotal&&(0,iS.jsx)($$,{total:e.usageTotal,sx:xJn})]})}var J2r=E(F(),1),eSr=st((0,J2r.jsx)("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"}),"Tune");var v1e=E(de(),1);var tSr=E(de(),1);function rSr(e){let{launchAssist:t}=il(),r=Ii(),n=Pa(),i=yr(),[o,a]=(0,tSr.useState)(!1);return{launched:o,launch:l=>{if(o)return;a(!0);let u=i?[{node:i}]:[];t(["refine","--once",...l,Yi(e)],n,...u),r("/sessions")}}}var P0=E(F(),1);function nSr({itemId:e}){let{launched:t,launch:r}=rSr(e),n=o_(),i=(0,v1e.useRef)(null),[o,a]=(0,v1e.useState)(!1),s=u=>u.stopPropagation(),l=Vye(n);return(0,P0.jsxs)(P0.Fragment,{children:[(0,P0.jsxs)(wS,{ref:i,variant:"outlined",size:"small",disabled:t,children:[(0,P0.jsx)(Dt,{startIcon:(0,P0.jsx)(eSr,{}),onClick:u=>{s(u),r([])},children:"Refine"}),l.length>0&&(0,P0.jsx)(Dt,{size:"small","aria-label":"Refine with a different harness",onClick:u=>{s(u),a(!0)},children:(0,P0.jsx)(bd,{})})]}),(0,P0.jsx)(qye,{anchorEl:i.current,open:o,onClose:()=>a(!1),options:l,onSelect:u=>{a(!1),r(["--harness",u])},stop:s})]})}var U$=E(de(),1);function iSr(){let e=(0,U$.useRef)(null),[t,r]=(0,U$.useState)(!1);return(0,U$.useEffect)(()=>{let n=e.current;if(!n)return;let i=new IntersectionObserver(([o])=>r(!o.isIntersecting),{threshold:0});return i.observe(n),()=>i.disconnect()},[]),{sentinelRef:e,stuck:t}}var id=E(F(),1),SJn={justifyContent:"space-between",alignItems:"center",mb:2};function TJn(e){return e.palette.mode==="dark"?"0 8px 8px -9px rgba(0, 0, 0, 0.8)":"0 6px 6px -7px rgba(0, 0, 0, 0.2)"}function CJn(e){return t=>({position:"sticky",top:0,zIndex:1,bgcolor:"background.default",mx:-2,px:2,pb:2,borderBottom:1,borderColor:"divider",boxShadow:e?TJn(t):"none",transition:t.transitions.create("box-shadow")})}function oSr({item:e,onDeleted:t,onStatusChange:r,ref:n}){let{sentinelRef:i,stuck:o}=iSr();return(0,id.jsxs)(id.Fragment,{children:[(0,id.jsx)(ie,{ref:i,sx:{height:0}}),(0,id.jsxs)(ie,{ref:n,sx:CJn(o),children:[(0,id.jsxs)(_t,{direction:"row",sx:SJn,children:[(0,id.jsx)(j2r,{to:"/backlog"}),(0,id.jsxs)(_t,{direction:"row",spacing:1,children:[Wye(e)&&(0,id.jsx)(l1e,{itemId:e.id}),(0,id.jsx)(nSr,{itemId:e.id}),(0,id.jsx)(X2r,{itemId:e.id,onDeleted:t})]})]}),(0,id.jsx)(Le,{variant:"h5",component:"h2",children:e.name}),(0,id.jsx)(Q2r,{item:e,onStatusChange:r})]})]})}var aSr=E(de(),1);function sSr(){let e=(0,aSr.useRef)(null),t=Kge(e,eX),r={[QUe]:`${t}px`};return{headerRef:e,headerHeight:t,style:r}}var y_=E(F(),1);function lSr({item:e,onReload:t}){let r=Ii(),n=Pa(),i=yr(),{headerRef:o,headerHeight:a,style:s}=sSr();wy("ItemDetail");let l=async()=>{await t(),r("/backlog")},u=async d=>{await bL(e.id,d,n,i),await t()},f=async(d,h)=>{await eit(e.id,d,h,n,i),await t()};return(0,y_.jsxs)(ie,{style:s,children:[(0,y_.jsx)(oSr,{ref:o,item:e,onDeleted:l,onStatusChange:u}),(0,y_.jsx)(ie,{sx:iX.containerSx,children:(0,y_.jsxs)(ie,{sx:iX.columnsSx,children:[(0,y_.jsx)(B2r,{item:e,onRewind:t,onCommentDeleted:t,onSubtaskStatusChange:f}),(0,y_.jsx)(q2r,{item:e,headerHeight:a})]})})]})}var _A=E(F(),1),wJn={display:"flex",justifyContent:"center",py:6};function cSr({onReload:e}){let[t]=Uc(),r=t.get("cwd")||void 0,n=t.get("node")||void 0,i=$n(),o=(0,b1e.useMemo)(()=>r?{...i,selectedCwd:r,selectedNode:n}:i,[i,r,n]);return wy("ItemRoute"),(0,_A.jsx)(YH.Provider,{value:o,children:(0,_A.jsx)(mf.Provider,{value:o.selectedNode,children:(0,_A.jsx)(kJn,{onReload:e})})})}function kJn({onReload:e}){let{id:t}=HTe(),r=Number.NaN;try{r=tte(t??"")}catch{r=Number.NaN}let{item:n,loading:i,reload:o}=Vxr(r),a=(0,b1e.useCallback)(async()=>{await Promise.all([o(),e()])},[o,e]);return i?(0,_A.jsx)(ie,{sx:wJn,children:(0,_A.jsx)(oo,{})}):n?(0,_A.jsx)(lSr,{item:n,onReload:a}):null}var EA=E(F(),1);function uSr({items:e,loading:t,error:r,socket:n,onReload:i}){return(0,EA.jsxs)(K5,{children:[(0,EA.jsx)(Ts,{index:!0,element:(0,EA.jsx)(Gxr,{items:e,loading:t,error:r,socket:n,onReload:i})}),(0,EA.jsx)(Ts,{path:"items/:id",element:(0,EA.jsx)(cSr,{onReload:i})})]})}var L0=E(de(),1);var fSr=new Map;function dSr(e,t,r){return JSON.stringify([e??null,t,r??null])}var oX={get(e,t,r){return fSr.get(dSr(e,t,r))},set(e,t,r,n){fSr.set(dSr(e,t,n),r)}};function _Jn(e,t){return e===t?!0:!e||!t?!1:e.tokensUp===t.tokensUp&&e.tokensDown===t.tokensDown&&e.activeMs===t.activeMs&&e.peakContextPct===t.peakContextPct}function hSr(e,t){return e===t?!0:e.length!==t.length?!1:e.every((r,n)=>{let i=t[n];return r.id===i.id&&r.type===i.type&&r.name===i.name&&r.status===i.status&&r.starred===i.starred&&r.incompleteSubtasks===i.incompleteSubtasks&&_Jn(r.usageTotal,i.usageTotal)})}function pSr({setItems:e,setLoading:t,setError:r}){return{onLoaded:n=>{e(i=>hSr(i,n)?i:n),t(!1),r(null)},onError:n=>{t(!1),r(n)}}}async function mSr(e,t,r,n){let i=await dT({cwd:e,node:n,signal:r,filter:t});return r.aborted||oX.set(e,t,i,n),i}function gSr(e,t,r,{onLoaded:n,onError:i},o){return(async()=>{try{let a=await mSr(e,t,r,o);r.aborted||n(a)}catch(a){r.aborted||i(a instanceof Error?a.message:"Failed to load.")}})()}var EJn=5e3;function ySr(e,t,r,n){let i=new AbortController,o=!1,a=()=>{o||(o=!0,gSr(e,t,i.signal,r,n).finally(()=>{o=!1}))};a();let s=setInterval(a,EJn);return()=>{i.abort(),clearInterval(s)}}function vSr(){let e=Pa(),t=yr(),[r]=R$(),n=oX.get(e,r,t),i=n??[],o=n===void 0,[a,s]=(0,L0.useState)(i),[l,u]=(0,L0.useState)(o),[f,d]=(0,L0.useState)(null),[h,p]=(0,L0.useState)(e),[m,g]=(0,L0.useState)(t),[y,v]=(0,L0.useState)(r);(e!==h||t!==m||r!==y)&&(p(e),g(t),v(r),s(i),u(o),d(null));let b=(0,L0.useCallback)(async()=>{let x=await dT({cwd:e,node:t,filter:r});s(x),oX.set(e,r,x,t),u(!1)},[e,t,r]);return(0,L0.useEffect)(()=>ySr(e,r,pSr({setItems:s,setLoading:u,setError:d}),t),[e,t,r]),{items:a,loading:l,error:f,reload:b}}var W$=E(F(),1);function bSr({socket:e}){let{items:t,loading:r,error:n,reload:i}=vSr();return yre(!r),(0,W$.jsx)(zUe.Provider,{value:e.sessions,children:(0,W$.jsx)(jUe.Provider,{value:e.selectSession,children:(0,W$.jsx)(K5,{children:(0,W$.jsx)(Ts,{path:"/*",element:(0,W$.jsx)(uSr,{items:t,loading:r,error:n,socket:e,onReload:i})})})})})}var iWe=E(F(),1);function xSr({socket:e}){return(0,iWe.jsx)(az,{maxWidth:"lg",sx:{py:3,px:2},children:(0,iWe.jsx)(bSr,{socket:e})})}var Pi=E(F(),1);function SSr({socket:e}){return wy("AppRoutes"),(0,Pi.jsxs)(Pi.Fragment,{children:[(0,Pi.jsx)(Nlr,{}),(0,Pi.jsx)(K5,{children:(0,Pi.jsxs)(Ts,{element:(0,Pi.jsx)(jat,{socket:e}),children:[(0,Pi.jsx)(Ts,{path:"sessions",element:(0,Pi.jsx)(V1r,{socket:e})}),(0,Pi.jsx)(Ts,{path:"backlog/*",element:(0,Pi.jsx)(xSr,{socket:e})}),(0,Pi.jsx)(Ts,{path:"next",element:(0,Pi.jsx)(Nsr,{sessions:e.sessions,selectSession:e.selectSession})}),(0,Pi.jsx)(Ts,{path:"news",element:(0,Pi.jsx)(War,{})}),(0,Pi.jsx)(Ts,{path:"releases",element:(0,Pi.jsx)(Llr,{})}),(0,Pi.jsx)(Ts,{path:"usage",element:(0,Pi.jsx)(Abr,{})}),(0,Pi.jsx)(Ts,{path:"backups",element:(0,Pi.jsx)(tst,{})}),(0,Pi.jsx)(Ts,{path:"config",element:(0,Pi.jsx)(ect,{})}),(0,Pi.jsx)(Ts,{path:"updates",element:(0,Pi.jsx)(zvr,{reconnecting:e.reconnecting,selectSession:e.selectSession})}),(0,Pi.jsx)(Ts,{path:"diff",element:(0,Pi.jsx)(sar,{socket:e})}),(0,Pi.jsx)(Ts,{path:"file",element:(0,Pi.jsx)($ar,{socket:e})}),(0,Pi.jsx)(Ts,{path:"*",element:(0,Pi.jsx)(jTe,{to:"/sessions",replace:!0})})]})})]})}var w1e=E(de(),1);var C1e=E(de(),1);function TSr(e,t,r){if(!e)return"Select a repo to search files.";if(r.error)return"Couldn't search files in this repo.";if(!(r.files.length>0||r.loading))return t?"No matching files.":"No files in this repo."}var v_=E(F(),1),RJn={display:"flex",gap:1,alignItems:"center",minWidth:0},AJn={display:"flex",gap:1,alignItems:"baseline",minWidth:0,overflow:"hidden"},PJn={fontFamily:"monospace",fontSize:13,whiteSpace:"nowrap"},LJn={fontFamily:"monospace",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function MJn(e){let t=e.lastIndexOf("/");return t===-1?{dir:"",basename:e}:{dir:e.slice(0,t),basename:e.slice(t+1)}}function CSr({files:e,highlight:t,onHighlight:r,onSelect:n}){return(0,v_.jsx)(Fp,{dense:!0,sx:{py:0},children:e.map((i,o)=>{let{dir:a,basename:s}=MJn(i);return(0,v_.jsxs)(pn,{selected:o===t,onMouseEnter:()=>r(o),onClick:()=>n(i),sx:RJn,children:[(0,v_.jsx)(K9,{path:i}),(0,v_.jsxs)(ie,{sx:AJn,children:[(0,v_.jsx)(Le,{component:"span",sx:PJn,children:s}),(0,v_.jsx)(Le,{component:"span",color:"text.secondary",sx:LJn,children:a})]})]},i)})})}var x1e=E(F(),1),IJn={maxHeight:420,overflowY:"auto"},DJn={px:2,py:2,fontSize:13};function wSr({message:e,files:t,highlight:r,onHighlight:n,onSelect:i}){return(0,x1e.jsx)(ie,{sx:IJn,children:e?(0,x1e.jsx)(Le,{color:"text.secondary",sx:DJn,children:e}):(0,x1e.jsx)(CSr,{files:t,highlight:r,onHighlight:n,onSelect:i})})}var kSr=E(F(),1),NJn={mt:6,alignSelf:"flex-start"};function S1e({onClose:e,onEntered:t,centered:r=!1,children:n}){return(0,kSr.jsx)(Wl,{open:!0,onClose:e,maxWidth:"sm",fullWidth:!0,slotProps:{paper:{sx:r?void 0:NJn},transition:{onEntered:t}},children:n})}var T1e=E(de(),1);var _Sr={files:[],loading:!1,error:!1};function ESr(e,t){let[r,n]=(0,T1e.useState)(_Sr),i=yr();return(0,T1e.useEffect)(()=>{if(!e){n(_Sr);return}let o=!1;return n(s=>({...s,loading:!0})),(async()=>{try{let s=await fetch(qr(`/api/files?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}`,i));if(!s.ok)throw new Error(`HTTP ${s.status}`);let l=await s.json();if(o)return;n({files:Array.isArray(l.files)?l.files:[],loading:!1,error:!1})}catch{o||n({files:[],loading:!1,error:!0})}})(),()=>{o=!0}},[e,t,i]),r}var RA=E(F(),1);function OJn(e,t,r){let n=new URLSearchParams({path:e});return t&&n.set("cwd",t),t&&r&&n.set("node",r),`/file?${n}`}function RSr({onClose:e}){let{worktreeNode:t}=$n();return(0,RA.jsx)(mf.Provider,{value:t,children:(0,RA.jsx)(BJn,{onClose:e})})}function BJn({onClose:e}){let{worktreeCwd:t,worktreeNode:r}=$n(),[n,i]=(0,C1e.useState)(""),o=ESr(t,n),a=Ii(),s=(0,C1e.useRef)(null),l=p=>a(OJn(p,t,r)),{highlight:u,setHighlight:f,onKeyDown:d}=u_(o.files,n,l,e),h=p=>{l(p),e()};return(0,RA.jsxs)(S1e,{onClose:e,onEntered:()=>s.current?.focus(),children:[(0,RA.jsx)(cT,{autoFocus:!0,inputRef:s,value:n,onChange:i,onKeyDown:d,placeholder:"Search files by name..."}),(0,RA.jsx)(wSr,{message:TSr(t,n,o),files:o.files,highlight:u,onHighlight:f,onSelect:h})]})}function ASr(e){Eo(qn("quickOpen").matches,e)}var LSr=E(F(),1);function PSr(){let[e,t]=(0,w1e.useState)(!1);return ASr((0,w1e.useCallback)(()=>t(!0),[])),e?(0,LSr.jsx)(RSr,{onClose:()=>t(!1)}):null}var k1e=E(F(),1);function MSr({notice:e,onClose:t,onView:r}){let n=e?.sessionId??null;return(0,k1e.jsx)(pl,{open:e!==null,autoHideDuration:6e3,onClose:t,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,k1e.jsx)(ai,{severity:"success",variant:"filled",onClose:t,action:n!==null?(0,k1e.jsx)(Dt,{color:"inherit",size:"small",onClick:()=>r(n),children:"View"}):void 0,children:e?.message})})}var L1e=E(de(),1);function ISr(e){let t=["claude"];return e.exposeCodexActions&&t.push("codex"),e.exposePiActions&&t.push("pi"),t}var qSr=E(de(),1);var DSr=E(F(),1),NSr=st((0,DSr.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2"}),"Circle");var b_="0.892.0";var $Jn={connected:"success.main",connecting:"warning.main",disconnected:"error.main","version-blocked":"error.main"};function OSr(e){return e?$Jn[e]:"success.main"}function BSr(e){return e.split("-")[0].split(".").map(Number)}function $Sr(e,t){if(!e||!t||e===t)return;let r=BSr(e),n=BSr(t);for(let i=0;i<Math.max(r.length,n.length);i++){let o=(r[i]??0)-(n[i]??0);if(Number.isNaN(o))return;if(o!==0)return o<0?"behind":"ahead"}}var _1e=E(de(),1),oWe=(0,_1e.createContext)(null);function E1e(){return(0,_1e.useContext)(oWe)}var AA=E(F(),1),FJn={height:16,fontSize:10},zJn={opacity:.6,fontSize:"0.85em"};function HJn(e,t){if(t===e.local)return"this machine";let r=e.links.find(n=>n.name===t);return r?r.error?`${r.state}: ${r.error}`:r.state:""}function aX({nodes:e,name:t,showVersion:r=!1}){let n=E1e()??b_,i=e.links.find(a=>a.name===t),o=$Sr(i?.peerVersion,n);return(0,AA.jsx)(lr,{title:HJn(e,t),placement:"right",children:(0,AA.jsxs)(ie,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:.75},children:[(0,AA.jsx)(NSr,{sx:{fontSize:8,color:OSr(i?.state)}}),t,r&&i?.peerVersion&&(0,AA.jsxs)(ie,{component:"span",sx:zJn,children:["v",i.peerVersion]}),o&&(0,AA.jsx)(tn,{label:o,size:"small",color:o==="behind"?"warning":"info",sx:FJn})]})})}var PA=E(F(),1),UJn={opacity:.6},WJn={display:"inline-flex",alignItems:"center",gap:.5,px:.5,border:1,borderStyle:"dashed",borderRadius:1};function FSr({nodes:e,name:t,clone:r}){let n=(0,PA.jsx)(aX,{nodes:e,name:t});return r.kind==="cloned"?n:r.kind==="unavailable"?(0,PA.jsx)(ie,{component:"span",sx:UJn,children:n}):(0,PA.jsx)(lr,{title:L$(t,r.cloneTarget),children:(0,PA.jsxs)(ie,{component:"span",sx:WJn,children:[(0,PA.jsx)(P$,{sx:{fontSize:14}}),n]})})}var HSr=E(F(),1),GJn={px:1.5,borderRadius:.75,fontSize:12,fontWeight:600,color:"text.secondary","&:hover":{color:"text.primary",bgcolor:"action.hover"},"&[aria-checked='true']":{color:"primary.main",bgcolor:"action.selected"},"&.Mui-focusVisible":{outline:2,outlineColor:"primary.main"}};function zSr({value:e,label:t,checked:r,autoFocus:n,onSelect:i}){return(0,HSr.jsx)(En,{role:"radio","aria-checked":r,"data-value":e,tabIndex:r?0:-1,autoFocus:n&&r,onClick:i,sx:GJn,children:t})}var USr={ArrowRight:1,ArrowLeft:-1};function VJn(e,t,r){if(e.key==="Tab"){let n=t+(e.shiftKey?-1:1);return n>=0&&n<r?n:void 0}return(t+USr[e.key]+r)%r}function WSr(e,t,r,n){return i=>{if(i.key==="ArrowUp"||i.key==="ArrowDown"){if(!n)return;i.preventDefault(),n();return}if(i.key!=="Tab"&&!USr[i.key]){C2(i);return}let o=VJn(i,e.indexOf(t),e.length);o!==void 0&&(i.preventDefault(),r(e[o]),i.currentTarget.querySelector(`[data-value="${e[o]}"]`)?.focus())}}var GSr=E(de(),1);function G$(e){return e?.querySelector('[aria-checked="true"]')}function VSr(e,t){(0,GSr.useEffect)(()=>{let r=e.current;if(!r?.contains(document.activeElement))return;let n=G$(r);n&&n!==document.activeElement&&n.focus()},[e,t])}var aWe=E(F(),1),qJn={border:1,borderColor:"divider",borderRadius:1,height:40,p:"2px",flexShrink:0};function R1e({label:e,options:t,value:r,onChange:n,optionLabel:i=u=>u,groupRef:o,autoFocus:a,onTrack:s,onToggleRow:l}){return VSr(o,r),(0,aWe.jsx)(_t,{ref:o,direction:"row",role:"radiogroup","aria-label":e,spacing:"2px",onFocus:s,onKeyDown:WSr(t,r,n,l),sx:qJn,children:t.map(u=>(0,aWe.jsx)(zSr,{value:u,label:i(u),checked:u===r,autoFocus:a,onSelect:()=>n(u)},u))})}var sWe=E(F(),1);function jSr({value:e,onChange:t,cloneState:r}){let{nodes:n,names:i,visible:o}=ef(),a=(0,qSr.useRef)(null);return!o||!n||!e?null:(0,sWe.jsx)(R1e,{label:"Machine",options:i,value:e,onChange:t,optionLabel:s=>(0,sWe.jsx)(FSr,{nodes:n,name:s,clone:r(s)}),groupRef:a,autoFocus:!1,onTrack:()=>{}})}var KSr=E(F(),1);function YSr({value:e,onChange:t,placeholder:r,inputRef:n,autoFocus:i,onTrack:o}){return(0,KSr.jsx)(Qn,{value:e,onChange:a=>t(a.target.value),onKeyDown:C2,onFocus:o,onSelect:o,inputRef:n,placeholder:r,autoFocus:i,fullWidth:!0,multiline:!0,minRows:3,maxRows:12,slotProps:{htmlInput:{"aria-label":"Prompt"},input:{sx:{fontSize:14}}}})}var JSr=E(de(),1);var oS={draft:{placeholder:"Describe the backlog item to draft...",submitLabel:"Start draft",sessionMode:"assist-draft"},bug:{placeholder:"Describe the bug: what happened, what you expected...",submitLabel:"File bug",sessionMode:"assist-bug"},prompt:{placeholder:vge,submitLabel:"Start session"},design:{placeholder:"Describe the design task...",submitLabel:"Start design"}},XSr=Object.keys(oS);var lWe=E(F(),1);function ZSr({anchor:e,harness:t,harnesses:r,onPick:n,onClose:i}){return(0,lWe.jsx)(Os,{open:e!==null,anchorEl:e,onClose:i,slotProps:{list:{dense:!0,"aria-label":"Harness"}},children:r.map(o=>(0,lWe.jsx)(pn,{role:"menuitemradio","aria-checked":o===t,selected:o===t,onClick:()=>{n(o),i()},sx:{fontSize:13},children:Lu(o)},o))})}var LA=E(F(),1);function QSr(e){return t=>t==="prompt"&&e?(0,LA.jsxs)(LA.Fragment,{children:["prompt",(0,LA.jsx)(ie,{component:"span",sx:{fontWeight:400,whiteSpace:"pre"},children:` \xB7 ${Lu(e)}`}),(0,LA.jsx)(bd,{sx:{fontSize:18,mr:-.75}})]}):t}var MA=E(F(),1);function eTr({draft:e,harness:t,harnesses:r,focus:n}){let[i,o]=(0,JSr.useState)(null),a=e.mode==="prompt"&&r.length>1,s=()=>o(G$(n.modeRef.current)??null),l=u=>{a&&u==="prompt"?s():e.setMode(u)};return(0,MA.jsxs)(MA.Fragment,{children:[(0,MA.jsx)(R1e,{label:"Mode",options:XSr,value:e.mode,onChange:l,optionLabel:QSr(r.length>1?t:void 0),groupRef:n.modeRef,autoFocus:n.autoFocus==="mode",onTrack:n.trackMode,onToggleRow:a?s:void 0}),(0,MA.jsx)(ZSr,{anchor:i,harness:t,harnesses:r,onPick:e.setHarness,onClose:()=>o(null)})]})}var fTr=E(de(),1);var cWe=E(F(),1),jJn={zIndex:e=>e.zIndex.modal+1};function tTr({open:e,anchor:t,children:r}){return(0,cWe.jsx)(F6,{open:e,anchorEl:t,placement:"bottom-start",sx:jJn,children:(0,cWe.jsx)(un,{sx:{maxHeight:240,overflowY:"auto",width:t?.clientWidth},onMouseDown:n=>n.preventDefault(),children:r})})}function rTr(e){return{htmlInput:{role:"combobox","aria-label":"Repo","aria-expanded":e},input:{sx:{fontSize:13,height:40}}}}var nTr=E(OF(),1);function iTr({open:e,highlighted:t,accept:r,close:n,navigate:i,openList:o}){return a=>{if(!e){if(a.key==="ArrowDown"){a.preventDefault(),o();return}C2(a);return}if(a.key!=="Escape"){if(a.key==="Enter"){if(a.preventDefault(),t===void 0)return;(0,nTr.flushSync)(()=>{r(t),n()}),C2(a);return}if(a.key!=="Tab"){i(a);return}t!==void 0&&r(t),n()}}}function oTr(e,t){let r=t.trim().toLowerCase();return r?e.filter(n=>bv(n).toLowerCase().includes(r)):e}var uWe=E(de(),1);function aTr(){let[e,t]=(0,uWe.useState)(!1),[r,n]=(0,uWe.useState)("");return{open:e,query:r,show:()=>t(!0),filterBy:i=>{n(i),t(!0)},close:()=>{t(!1),n("")}}}var lTr=E(de(),1);var sTr=e=>e?bv(e):"";function cTr(e){let[t,r]=(0,lTr.useState)(()=>sTr(e));return{text:t,setText:r,showRepo:n=>r(sTr(n))}}function uTr(e,t,r){let n=aTr(),i=cTr(t),o=oTr(e,n.query),a=f=>{r(f),i.showRepo(f)},s=u_(o,n.query,a,n.close),l=()=>s.setHighlight(Math.max(e.indexOf(t),0)),u=()=>{l(),n.show()};return{open:n.open,text:i.text,filtered:o,highlight:s.highlight,setHighlight:s.setHighlight,onKeyDown:iTr({open:n.open,highlighted:o[s.highlight],accept:a,close:n.close,navigate:s.onKeyDown,openList:u}),onClick:()=>{n.open||u()},onType:f=>{i.setText(f),n.filterBy(f)},onFocus:l,onBlur:()=>{n.close(),i.showRepo(t)},pick:f=>{a(f),n.close()}}}var V$=E(F(),1);function dTr({repos:e,value:t,onChange:r,inputRef:n,autoFocus:i,onTrack:o}){let a=uTr(e,t,r),s=(0,fTr.useRef)(null);return(0,V$.jsxs)(ie,{ref:s,sx:{flex:1,minWidth:0},children:[(0,V$.jsx)(Qn,{value:a.text,onChange:l=>a.onType(l.target.value),onFocus:l=>{l.target.select(),a.onFocus(),o()},inputRef:n,autoFocus:i,onClick:a.onClick,onBlur:a.onBlur,onKeyDown:a.onKeyDown,placeholder:"Repo",size:"small",fullWidth:!0,slotProps:rTr(a.open)}),(0,V$.jsx)(tTr,{open:a.open,anchor:s.current,children:(0,V$.jsx)(o1e,{repos:a.filtered,selected:t,highlight:a.highlight,onHighlight:a.setHighlight,onSelect:a.pick})})]})}var x_=E(F(),1);function hTr({cloneState:e,...t}){let{draft:r,focus:n}=t,{repos:i}=$n();return(0,x_.jsxs)(_t,{spacing:1,sx:{p:1},children:[(0,x_.jsx)(YSr,{value:r.prompt,onChange:r.setPrompt,placeholder:oS[r.mode].placeholder,inputRef:n.promptRef,autoFocus:n.autoFocus==="prompt",onTrack:n.trackPrompt}),(0,x_.jsxs)(_t,{direction:"row",spacing:1,sx:{alignItems:"flex-start"},children:[(0,x_.jsx)(dTr,{repos:i,value:r.cwd,onChange:r.setCwd,inputRef:n.repoRef,autoFocus:n.autoFocus==="repo",onTrack:n.trackRepo}),(0,x_.jsx)(eTr,{...t})]}),(0,x_.jsx)(jSr,{value:r.node,onChange:r.setNode,cloneState:e})]})}var q$=E(F(),1),YJn=["Enter start","Shift+Enter newline","Esc close"],KJn={alignItems:"center",px:1.5,py:1,borderTop:1,borderColor:"divider",bgcolor:"action.hover"};function pTr({submitLabel:e,disabled:t=!1}){return(0,q$.jsxs)(_t,{direction:"row",spacing:1.5,sx:KJn,children:[(0,q$.jsx)(_t,{direction:"row",spacing:1.5,sx:{mr:"auto"},children:YJn.map(r=>(0,q$.jsx)(Le,{variant:"caption",color:"text.secondary",children:r},r))}),(0,q$.jsx)(Dt,{type:"submit",variant:"contained",size:"small",disabled:t,children:e})]})}function mTr({mode:e,harness:t,prompt:r,cwd:n,node:i},o){let a=n||void 0,s=i?[i]:[];if(e==="prompt"){t==="claude"?o.onCreate(r,a,...s):o.onCreateHarness(t,r,a,...s);return}if(e==="design"){o.onCreateDesign(r,a,...s);return}let l=i?[{node:i}]:[];wcr(oS[e].sessionMode,n,(u,f)=>o.onCreateAssist(u,f,...l),()=>{},r)}function gTr(e,t,r,n){return r.kind==="blocked"||e.modePending?!1:r.kind==="clone"?(Kye(r.prompt,n.onCreateAssist),!0):(mTr({mode:e.mode,harness:t,prompt:e.prompt,cwd:r.cwd,node:e.node},n),e.clear(),!0)}var IA=E(de(),1);function yTr(e,t){let r=(0,IA.useRef)(e),n=(0,IA.useRef)(null),i=(0,IA.useRef)(null),o=(0,IA.useRef)(null),a=(0,IA.useCallback)(u=>{n.current=u;let{field:f,selectionStart:d,selectionEnd:h}=r.current;u&&f==="prompt"&&u.setSelectionRange(d,h)},[]),s=u=>{let f=u.target;t({field:"prompt",selectionStart:f.selectionStart,selectionEnd:f.selectionEnd})},l=()=>{if(o.current?.closest("form")?.contains(document.activeElement))return;let{field:u}=r.current;({repo:i.current,mode:G$(o.current),prompt:n.current}[u]??n.current)?.focus()};return{autoFocus:e.field,promptRef:a,repoRef:i,modeRef:o,trackPrompt:s,trackRepo:()=>t({...e,field:"repo"}),trackMode:()=>t({...e,field:"mode"}),restore:l}}function XJn(e,t,r){return e?r.kind==="cloned"?{kind:"launch",cwd:r.cwd}:r.kind==="clonable"?{kind:"clone",prompt:s1e(r,t)}:{kind:"blocked"}:{kind:"launch",cwd:e}}function vTr(e,t){let{names:r,visible:n}=ef(),i=r1e(t,n?r:[void 0]);return{cloneState:i,target:XJn(t,e,i(e))}}var A1e=E(de(),1);function bTr(e,t){let[r,n]=(0,A1e.useState)(!1);return(0,A1e.useEffect)(()=>{!r||e.modePending||(n(!1),!(e.mode==="prompt"&&!e.prompt.trim())&&t())},[r,e.modePending,e.mode,e.prompt,t]),()=>{e.modePending?n(!0):t()}}var j$=E(F(),1);function xTr({draft:e,launchers:t,onClose:r}){let n=yTr(e.focus,e.setFocus),i=ISr(o_()),o=i.includes(e.harness)?e.harness:"claude",{target:a,cloneState:s}=vTr(e.node,e.cwd),l=bTr(e,()=>{gTr(e,o,a,t)&&r()}),u=f=>{f.preventDefault(),l()};return(0,j$.jsx)(S1e,{onClose:r,onEntered:n.restore,centered:!0,children:(0,j$.jsxs)("form",{onSubmit:u,children:[(0,j$.jsx)(hTr,{draft:e,harness:o,harnesses:i,focus:n,cloneState:s}),(0,j$.jsx)(pTr,{submitLabel:a.kind==="clone"?"Clone":oS[e.mode].submitLabel,disabled:a.kind==="blocked"})]})})}var P1e=E(de(),1);function STr(e){let[t,r]=(0,P1e.useState)(null);return(0,P1e.useEffect)(()=>{let n=!1;return(async()=>{let i="draft";try{let o=e?`?cwd=${encodeURIComponent(e)}`:"",s=await(await fetch(`/api/new-session-defaults${o}`)).json();Object.hasOwn(oS,s?.mode)&&(i=s.mode)}catch{}n||r({cwd:e,mode:i})})(),()=>{n=!0}},[e]),t}function TTr(e,{visible:t,names:r,selected:n}){if(t)return e&&r.includes(e)?e:n}var aS=E(de(),1),CTr={field:"prompt",selectionStart:0,selectionEnd:0};function wTr(){let[e,t]=(0,aS.useState)(""),[r,n]=(0,aS.useState)(),[i,o]=(0,aS.useState)(),[a,s]=(0,aS.useState)("claude"),[l,u]=(0,aS.useState)(),[f,d]=(0,aS.useState)(CTr),h=(0,aS.useCallback)(()=>{t(""),n(void 0),o(void 0),u(void 0),d(CTr)},[]);return{prompt:e,cwd:r,mode:i,harness:a,node:l,focus:f,setPrompt:t,setNode:u,setCwd:n,setMode:o,setHarness:s,setFocus:d,clear:h}}function kTr(e=STr){let{selectedCwd:t}=$n(),r=ef(),n=wTr(),i=n.cwd??t,o=e(i);return o?{...n,cwd:i,mode:n.mode??o.mode,modePending:n.mode===void 0&&o.cwd!==i,node:TTr(n.node,r)}:null}function _Tr(e){Eo(qn("newSession").matches,e)}var ETr=E(de(),1);function RTr(e,t){let{selectedCwd:r}=$n(),[n,i]=Uc(),o=n.get("new"),a=n.get("newCwd")??r,{setPrompt:s,setCwd:l,setFocus:u}=e??{};(0,ETr.useEffect)(()=>{o===null||!s||!l||!u||(o&&(s(o),l(a),u({field:"prompt",selectionStart:o.length,selectionEnd:o.length})),t(),i(f=>(f.delete("new"),f.delete("newCwd"),f),{replace:!0}))},[o,a,s,l,u,t,i])}var PTr=E(F(),1);function ATr({launchers:e}){let[t,r]=(0,L1e.useState)(!1),n=kTr(),i=(0,L1e.useCallback)(()=>r(!0),[]);return _Tr(i),RTr(n,i),!t||!n?null:(0,PTr.jsx)(xTr,{draft:n,launchers:e,onClose:()=>r(!1)})}var M1e=E(F(),1);function LTr({reconnecting:e}){return(0,M1e.jsx)(pl,{open:e,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,M1e.jsx)(ai,{severity:"info",variant:"filled",icon:(0,M1e.jsx)(oo,{size:16,color:"inherit"}),children:"Reconnecting\u2026"})})}var wv=E(F(),1);function MTr({socket:e,onViewLaunchedSession:t}){return(0,wv.jsxs)(wv.Fragment,{children:[(0,wv.jsx)(PSr,{}),(0,wv.jsx)(ATr,{launchers:{onCreate:e.createSession,onCreateDesign:e.createDesignSession,onCreateHarness:e.createHarnessSession,onCreateAssist:e.createAssistSession}}),(0,wv.jsx)(LTr,{reconnecting:e.reconnecting}),(0,wv.jsx)(Zl,{error:e.error,onClose:e.clearError}),(0,wv.jsx)(MSr,{notice:e.success,onClose:e.clearSuccess,onView:t})]})}var kv=E(de(),1);var ZJn=6e4;function QJn(e,t,r){return t.map(n=>e.find(i=>i.name===n)??{name:n,local:n===r,loading:!0})}function ITr(e){let t=e.nodes?.local,r=e.names.join(`
|
|
4017
4017
|
`),[n,i]=(0,kv.useState)([]),o=(0,kv.useRef)(0),a=(0,kv.useCallback)(()=>{let l=r?r.split(`
|
|
4018
4018
|
`):[];if(l.length===0)return;let u=++o.current;i(f=>QJn(f,l,t));for(let f of l)Eye(f,f===t).then(d=>{u===o.current&&i(h=>h.map(p=>p.name===f?d:p))})},[r,t]);(0,kv.useEffect)(()=>{a();let l=setInterval(a,ZJn);return()=>clearInterval(l)},[a]);let s=n.length===0;return(0,kv.useMemo)(()=>({entries:n,loading:s,refresh:a}),[n,s,a])}var S_=E(F(),1);function DTr({shell:e,children:t}){let{socket:r,selection:n,launch:i,sidebarCollapse:o}=e,a=ITr(r.nodeSelection);return(0,S_.jsx)(RUe.Provider,{value:a,children:(0,S_.jsx)(LCe.Provider,{value:o,children:(0,S_.jsx)(YH.Provider,{value:n,children:(0,S_.jsx)(YUe.Provider,{value:r.nodeSelection,children:(0,S_.jsx)(mf.Provider,{value:n.selectedNode,children:(0,S_.jsx)(gFe.Provider,{value:i,children:(0,S_.jsx)(pnt,{children:t})})})})})})})}var NTr=E(F(),1),OTr=st((0,NTr.jsx)("path",{d:"M20 18c1.1 0 1.99-.9 1.99-2L22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2zM4 6h16v10H4z"}),"Computer");var BTr=E(de(),1);var M0=E(F(),1),JJn={ml:1,textTransform:"none",fontSize:12};function $Tr(){let{nodes:e,names:t,visible:r,selected:n,select:i}=ef(),[o,a]=(0,BTr.useState)(null);return!r||!e||!n?null:(0,M0.jsxs)(M0.Fragment,{children:[(0,M0.jsx)(Dt,{size:"small",color:"inherit",startIcon:(0,M0.jsx)(OTr,{fontSize:"small"}),"aria-label":"Machine","aria-haspopup":"menu",onClick:s=>a(s.currentTarget),sx:JJn,children:(0,M0.jsx)(aX,{nodes:e,name:n})}),(0,M0.jsx)(Os,{anchorEl:o,open:!!o,onClose:()=>a(null),children:t.map(s=>(0,M0.jsx)(pn,{selected:s===n,onClick:()=>{i(s),a(null)},sx:{fontSize:13},children:(0,M0.jsx)(aX,{nodes:e,name:s,showVersion:!0})},s))})]})}var sX=E(de(),1);function FTr(e,t){return[...e[0].slice(0,-1),String(t+1)]}var I1e=E(F(),1);function zTr({index:e,label:t,...r}){let{chords:n}=qn("navTab");return(0,I1e.jsx)(lr,{describeChild:!0,title:(0,I1e.jsx)(Mu,{label:t,chords:[FTr(n,e)]}),children:(0,I1e.jsx)(Yv,{label:t,...r})})}var fWe=E(de(),1);function HTr(e,t){let{bound:r}=qn("navTab"),n=e.length,i=(0,fWe.useCallback)(a=>(tU(a,r)??n)<n,[r,n]),o=(0,fWe.useCallback)(a=>{let s=e[tU(a,r)??-1];s&&t(s)},[e,t,r]);Eo(i,o)}var D1e=E(de(),1);function UTr(){let[e,t]=(0,D1e.useState)(!1);return(0,D1e.useEffect)(()=>{let r=!1;return(async()=>{try{let i=await(await fetch("/api/news/nav")).json();r||t(i?.showInNav===!0)}catch{r||t(!1)}})(),()=>{r=!0}},[]),e}var N1e=E(de(),1);async function eei(e,t){let r=await fetch(qr(`/api/releases/configured?cwd=${encodeURIComponent(e)}`,t));return r.ok?(await r.json())?.configured===!0:void 0}function WTr(e){let[t,r]=(0,N1e.useState)(null),n=yr(),i=`${n??""}\0${e}`;return(0,N1e.useEffect)(()=>{if(!e)return;let o=!1;return eei(e,n).catch(()=>{}).then(a=>{o||r({key:i,configured:a})}),()=>{o=!0}},[e,n,i]),t?.key===i?t.configured:void 0}var GTr=E(de(),1);function VTr(e){let{pathname:t}=Uo(),r=Ii(),n=t==="/releases"||t.startsWith("/releases/");(0,GTr.useEffect)(()=>{e===!1&&n&&r("/sessions",{replace:!0})},[e,n,r])}var tei={path:"/sessions",label:"Sessions"},rei={path:"/backlog",label:"Backlog"},nei={path:"/next",label:"Next"},iei={path:"/releases",label:"Releases"},oei={path:"/news",label:"News"};function qTr(e,t){return[tei,rei,nei,...e?[iei]:[],...t?[oei]:[]]}var dWe=E(F(),1);function jTr({cwd:e}){let t=Uo(),r=Ii(),n=WTr(e),i=UTr();VTr(n);let o=n===!0,a=(0,sX.useMemo)(()=>qTr(o,i),[o,i]),s=(0,sX.useMemo)(()=>a.map(f=>f.path),[a]),l=a.findIndex(f=>t.pathname.startsWith(f.path)),u=(0,sX.useCallback)(f=>{t.pathname!==f&&r(f)},[t.pathname,r]);return HTr(s,u),(0,dWe.jsx)(T5,{value:l===-1?!1:l,textColor:"inherit",indicatorColor:"secondary",children:a.map((f,d)=>(0,dWe.jsx)(zTr,{index:d,label:f.label,onClick:()=>u(f.path)},f.path))})}var YTr=E(F(),1),KTr=st((0,YTr.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m5 11h-4v4h-2v-4H7v-2h4V7h2v4h4z"}),"AddCircle");var lX=E(F(),1),aei={color:"success.light"};function XTr(){let[,e]=Uc(),{label:t,chords:r}=qn("newSession");return(0,lX.jsx)(lr,{title:(0,lX.jsx)(Mu,{label:t,chords:r}),children:(0,lX.jsx)(ir,{size:"small",sx:aei,"aria-label":"New session",onClick:()=>e(i=>(i.set("new",""),i),{replace:!0}),children:(0,lX.jsx)(KTr,{})})})}var B1e=E(de(),1);var O1e=E(F(),1),sei={color:"inherit"};function ZTr({cwd:e}){let[t,r]=(0,B1e.useState)(null),n=yr();return(0,B1e.useEffect)(()=>{if(!e){r(null);return}let i=!1;return(async()=>{try{let a=await(await fetch(qr(`/api/github-url?cwd=${encodeURIComponent(e)}`,n))).json();i||r(a?.url??null)}catch{i||r(null)}})(),()=>{i=!0}},[e,n]),t?(0,O1e.jsx)(lr,{title:"Open in GitHub",children:(0,O1e.jsx)(ir,{sx:sei,onClick:()=>window.open(t,"_blank"),children:(0,O1e.jsx)(lL,{})})}):null}var iCr=E(de(),1);var nCr=E(de(),1);function $1e(e,t,r){return e!=null?Nye(e,r):t}var F1e=E(F(),1);function QTr({window:e,windowSeconds:t,fallbackLabel:r,now:n}){let i=e?.used_percentage;if(i==null)return null;let o=t_(i,e?.resets_at,t,n),a=$1e(e?.resets_at,r,n);return(0,F1e.jsxs)(ie,{component:"span",children:[(0,F1e.jsxs)(ie,{component:"span",sx:{color:r_(o)},children:[Math.round(i),"%"]})," ",(0,F1e.jsxs)(ie,{component:"span",sx:{color:"text.secondary"},children:["(",a,")"]})]})}var DA=E(F(),1),lei='@property --rainbow-pill-h { syntax: "<number>"; inherits: true; initial-value: 0; }',cei=ho`
|
|
4019
4019
|
from { --rainbow-pill-h: 0; }
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.892.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -21652,15 +21652,6 @@ function* iterateUserMessages(filePath, maxBytes = 65536) {
|
|
|
21652
21652
|
}
|
|
21653
21653
|
|
|
21654
21654
|
// src/commands/sessions/summarise/scanSessionBacklogRefs.ts
|
|
21655
|
-
function scanSessionBacklogRefs(filePath) {
|
|
21656
|
-
const ids = /* @__PURE__ */ new Set();
|
|
21657
|
-
for (const text18 of iterateUserMessages(filePath, Number.MAX_SAFE_INTEGER)) {
|
|
21658
|
-
for (const id of extractBacklogIds(text18)) {
|
|
21659
|
-
ids.add(id);
|
|
21660
|
-
}
|
|
21661
|
-
}
|
|
21662
|
-
return [...ids].sort((a, b) => a - b);
|
|
21663
|
-
}
|
|
21664
21655
|
function extractBacklogIds(text18) {
|
|
21665
21656
|
const ids = [];
|
|
21666
21657
|
for (const m of text18.matchAll(/backlog\s+run\s+a(\d+)/gi)) {
|
|
@@ -40140,17 +40131,29 @@ function registerShow(program) {
|
|
|
40140
40131
|
).option("--title <title>", "Pane title").requiredOption("--body <markdown|->", "Markdown to show, or - for stdin").action(show3);
|
|
40141
40132
|
}
|
|
40142
40133
|
|
|
40134
|
+
// src/shared/internalCommand.ts
|
|
40135
|
+
function internalCommand(command, calledBy) {
|
|
40136
|
+
command.internalCalledBy = calledBy;
|
|
40137
|
+
return command;
|
|
40138
|
+
}
|
|
40139
|
+
|
|
40143
40140
|
// src/commands/registerSignal.ts
|
|
40144
40141
|
function registerSignal(program) {
|
|
40145
40142
|
const signalCommand = program.command("signal").description("Write an assist signal file");
|
|
40146
|
-
|
|
40147
|
-
|
|
40148
|
-
|
|
40149
|
-
|
|
40150
|
-
|
|
40151
|
-
|
|
40152
|
-
|
|
40153
|
-
|
|
40143
|
+
internalCommand(
|
|
40144
|
+
signalCommand.command("next").argument("[id]", "Backlog item ID to run directly").description("Write a next signal to chain into assist next").action((id) => {
|
|
40145
|
+
writeSignal("next", id ? { id } : void 0);
|
|
40146
|
+
console.log("Signal written.");
|
|
40147
|
+
}),
|
|
40148
|
+
"/next"
|
|
40149
|
+
);
|
|
40150
|
+
internalCommand(
|
|
40151
|
+
signalCommand.command("done").argument("[id]", "Backlog item ID created by the session").description("Write a done signal to end a --once launch session").action((id) => {
|
|
40152
|
+
writeSignal("done", id ? { id } : void 0);
|
|
40153
|
+
console.log("Signal written.");
|
|
40154
|
+
}),
|
|
40155
|
+
"/draft, /bug, /refine"
|
|
40156
|
+
);
|
|
40154
40157
|
}
|
|
40155
40158
|
|
|
40156
40159
|
// src/commands/slack/parseSlackThreadRef.ts
|
|
@@ -49404,9 +49407,6 @@ async function discoverHistoryEntries() {
|
|
|
49404
49407
|
}
|
|
49405
49408
|
|
|
49406
49409
|
// src/commands/sessions/shared/discoverSessions.ts
|
|
49407
|
-
async function discoverSessionFiles() {
|
|
49408
|
-
return (await discoverSessionJsonlPaths()).map((p) => p.path);
|
|
49409
|
-
}
|
|
49410
49410
|
async function discoverSessions() {
|
|
49411
49411
|
return (await discoverHistoryEntries()).map((entry) => entry.session);
|
|
49412
49412
|
}
|
|
@@ -52131,26 +52131,32 @@ function fail8(message3) {
|
|
|
52131
52131
|
|
|
52132
52132
|
// src/commands/sessions/registerOutputCommand.ts
|
|
52133
52133
|
function registerOutputCommand(cmd) {
|
|
52134
|
-
|
|
52135
|
-
"
|
|
52136
|
-
|
|
52137
|
-
"--
|
|
52138
|
-
|
|
52139
|
-
|
|
52134
|
+
internalCommand(
|
|
52135
|
+
cmd.command("output [session-id]").description(
|
|
52136
|
+
"Print a snapshot of a session's output with ANSI codes stripped"
|
|
52137
|
+
).option("-n, --lines <count>", "Number of lines", "200").option(
|
|
52138
|
+
"--server [group]",
|
|
52139
|
+
"Read the live server run for this repo's remote and group (default: default)"
|
|
52140
|
+
).action(sessionOutput),
|
|
52141
|
+
"/run-logs"
|
|
52142
|
+
);
|
|
52140
52143
|
}
|
|
52141
52144
|
|
|
52142
52145
|
// src/commands/sessions/registerSetStatusCommand.ts
|
|
52143
52146
|
function registerSetStatusCommand(cmd) {
|
|
52144
|
-
|
|
52145
|
-
"
|
|
52146
|
-
|
|
52147
|
-
|
|
52148
|
-
|
|
52149
|
-
|
|
52150
|
-
|
|
52151
|
-
|
|
52152
|
-
|
|
52153
|
-
|
|
52147
|
+
internalCommand(
|
|
52148
|
+
cmd.command("set-status <status>").description(
|
|
52149
|
+
"Report the current session's status to the sessions daemon (used by Claude Code hooks)"
|
|
52150
|
+
).option(
|
|
52151
|
+
"--source <source>",
|
|
52152
|
+
"Originating hook (permission, stop, notification, prompt, pretool, posttool)"
|
|
52153
|
+
).option(
|
|
52154
|
+
"--ack",
|
|
52155
|
+
"Retry delivery until the daemon acknowledges it (without it, a single attempt)"
|
|
52156
|
+
).action(
|
|
52157
|
+
(status2, options2) => setSessionStatus(status2, { source: options2.source, ack: options2.ack })
|
|
52158
|
+
),
|
|
52159
|
+
"Claude hooks"
|
|
52154
52160
|
);
|
|
52155
52161
|
}
|
|
52156
52162
|
|
|
@@ -52170,118 +52176,6 @@ async function renameSession(title) {
|
|
|
52170
52176
|
}
|
|
52171
52177
|
}
|
|
52172
52178
|
|
|
52173
|
-
// src/commands/sessions/summarise.ts
|
|
52174
|
-
import * as fs59 from "fs";
|
|
52175
|
-
import chalk268 from "chalk";
|
|
52176
|
-
|
|
52177
|
-
// src/commands/sessions/summarise/shared.ts
|
|
52178
|
-
import * as fs58 from "fs";
|
|
52179
|
-
function writeSummary(jsonlPath2, summary) {
|
|
52180
|
-
fs58.writeFileSync(summaryPathFor(jsonlPath2), `${summary.trim()}
|
|
52181
|
-
`, "utf8");
|
|
52182
|
-
}
|
|
52183
|
-
function hasSummary(jsonlPath2) {
|
|
52184
|
-
return fs58.existsSync(summaryPathFor(jsonlPath2));
|
|
52185
|
-
}
|
|
52186
|
-
function summaryPathFor(jsonlPath2) {
|
|
52187
|
-
return jsonlPath2.replace(/\.jsonl$/, ".summary");
|
|
52188
|
-
}
|
|
52189
|
-
|
|
52190
|
-
// src/commands/sessions/summarise/summariseSession.ts
|
|
52191
|
-
import { execFileSync as execFileSync32 } from "child_process";
|
|
52192
|
-
function summariseSession(jsonlPath2) {
|
|
52193
|
-
const firstMessage = extractFirstUserMessage(jsonlPath2);
|
|
52194
|
-
const backlogIds = scanSessionBacklogRefs(jsonlPath2);
|
|
52195
|
-
if (!firstMessage && backlogIds.length === 0) {
|
|
52196
|
-
return void 0;
|
|
52197
|
-
}
|
|
52198
|
-
const prompt = buildPrompt6(firstMessage, backlogIds);
|
|
52199
|
-
try {
|
|
52200
|
-
const output = execFileSync32("claude", ["-p", "--model", "haiku", prompt], {
|
|
52201
|
-
encoding: "utf8",
|
|
52202
|
-
timeout: 3e4,
|
|
52203
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
52204
|
-
});
|
|
52205
|
-
const summary = output.trim();
|
|
52206
|
-
if (!summary) return void 0;
|
|
52207
|
-
return summary.split("\n")[0].replace(/^["']|["']$/g, "").trim();
|
|
52208
|
-
} catch {
|
|
52209
|
-
return void 0;
|
|
52210
|
-
}
|
|
52211
|
-
}
|
|
52212
|
-
function buildPrompt6(firstMessage, backlogIds) {
|
|
52213
|
-
const parts = [
|
|
52214
|
-
"Summarise this Claude Code session in ONE short sentence (under 100 chars).",
|
|
52215
|
-
"Return ONLY the summary, no quotes or explanation."
|
|
52216
|
-
];
|
|
52217
|
-
if (backlogIds.length > 0) {
|
|
52218
|
-
const refs = backlogIds.map((id) => formatItemId(id)).join(", ");
|
|
52219
|
-
parts.push(
|
|
52220
|
-
`The session references backlog item(s) ${refs}. Start the summary with "Backlog ${refs} \u2014" if relevant.`
|
|
52221
|
-
);
|
|
52222
|
-
}
|
|
52223
|
-
if (firstMessage) {
|
|
52224
|
-
parts.push(`First user message:
|
|
52225
|
-
${firstMessage}`);
|
|
52226
|
-
}
|
|
52227
|
-
return parts.join("\n");
|
|
52228
|
-
}
|
|
52229
|
-
|
|
52230
|
-
// src/commands/sessions/summarise.ts
|
|
52231
|
-
async function summarise2(options2) {
|
|
52232
|
-
const files = await discoverSessionFiles();
|
|
52233
|
-
if (files.length === 0) {
|
|
52234
|
-
console.log(chalk268.yellow("No sessions found."));
|
|
52235
|
-
return;
|
|
52236
|
-
}
|
|
52237
|
-
const toProcess = selectCandidates(files, options2);
|
|
52238
|
-
if (toProcess.length === 0) {
|
|
52239
|
-
console.log(chalk268.green("All sessions already summarised."));
|
|
52240
|
-
return;
|
|
52241
|
-
}
|
|
52242
|
-
console.log(
|
|
52243
|
-
chalk268.cyan(
|
|
52244
|
-
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
52245
|
-
)
|
|
52246
|
-
);
|
|
52247
|
-
const { succeeded, failed: failed3 } = processSessions(toProcess);
|
|
52248
|
-
console.log(
|
|
52249
|
-
chalk268.green(`Done: ${succeeded} summarised`) + (failed3 > 0 ? chalk268.yellow(`, ${failed3} skipped`) : "")
|
|
52250
|
-
);
|
|
52251
|
-
}
|
|
52252
|
-
function selectCandidates(files, options2) {
|
|
52253
|
-
const candidates = options2.force ? files : files.filter((f) => !hasSummary(f));
|
|
52254
|
-
candidates.sort((a, b) => {
|
|
52255
|
-
try {
|
|
52256
|
-
return fs59.statSync(b).mtimeMs - fs59.statSync(a).mtimeMs;
|
|
52257
|
-
} catch {
|
|
52258
|
-
return 0;
|
|
52259
|
-
}
|
|
52260
|
-
});
|
|
52261
|
-
const limit = options2.limit ? Number.parseInt(options2.limit, 10) : void 0;
|
|
52262
|
-
return limit && limit > 0 ? candidates.slice(0, limit) : candidates;
|
|
52263
|
-
}
|
|
52264
|
-
function processSessions(files) {
|
|
52265
|
-
let succeeded = 0;
|
|
52266
|
-
let failed3 = 0;
|
|
52267
|
-
for (let i = 0; i < files.length; i++) {
|
|
52268
|
-
const file = files[i];
|
|
52269
|
-
process.stdout.write(chalk268.dim(` [${i + 1}/${files.length}] `));
|
|
52270
|
-
const summary = summariseSession(file);
|
|
52271
|
-
if (summary) {
|
|
52272
|
-
writeSummary(file, summary);
|
|
52273
|
-
succeeded++;
|
|
52274
|
-
process.stdout.write(`${chalk268.green("\u2713")} ${summary}
|
|
52275
|
-
`);
|
|
52276
|
-
} else {
|
|
52277
|
-
failed3++;
|
|
52278
|
-
process.stdout.write(` ${chalk268.yellow("skip")}
|
|
52279
|
-
`);
|
|
52280
|
-
}
|
|
52281
|
-
}
|
|
52282
|
-
return { succeeded, failed: failed3 };
|
|
52283
|
-
}
|
|
52284
|
-
|
|
52285
52179
|
// src/commands/sessions/registerSessions.ts
|
|
52286
52180
|
function registerSessions(program) {
|
|
52287
52181
|
const cmd = program.command("sessions").description("Web dashboard for Claude Code sessions").option("--no-open", "Do not open a browser on startup").action(
|
|
@@ -52295,13 +52189,18 @@ function registerSessions(program) {
|
|
|
52295
52189
|
...webConfigHelp,
|
|
52296
52190
|
...hotkeysConfigHelp
|
|
52297
52191
|
]);
|
|
52298
|
-
|
|
52299
|
-
|
|
52300
|
-
|
|
52301
|
-
|
|
52302
|
-
|
|
52303
|
-
|
|
52304
|
-
|
|
52192
|
+
internalCommand(
|
|
52193
|
+
cmd.command("close").description(
|
|
52194
|
+
"Dismiss the current daemon-managed session, ending it and reaping its worktree"
|
|
52195
|
+
).action(closeSession),
|
|
52196
|
+
"/close"
|
|
52197
|
+
);
|
|
52198
|
+
internalCommand(
|
|
52199
|
+
cmd.command("rename <title>").description(
|
|
52200
|
+
"Retitle the current daemon-managed session, overriding the generated title for the rest of its life"
|
|
52201
|
+
).action(renameSession),
|
|
52202
|
+
"/rename"
|
|
52203
|
+
);
|
|
52305
52204
|
registerOutputCommand(cmd);
|
|
52306
52205
|
registerSetStatusCommand(cmd);
|
|
52307
52206
|
registerNodes(cmd);
|
|
@@ -52375,10 +52274,10 @@ function createProgram() {
|
|
|
52375
52274
|
}
|
|
52376
52275
|
|
|
52377
52276
|
// src/reportCliError.ts
|
|
52378
|
-
import
|
|
52277
|
+
import chalk268 from "chalk";
|
|
52379
52278
|
function reportCliError(error) {
|
|
52380
52279
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError) {
|
|
52381
|
-
console.error(
|
|
52280
|
+
console.error(chalk268.red(error.message));
|
|
52382
52281
|
} else {
|
|
52383
52282
|
console.error(error);
|
|
52384
52283
|
}
|