@wjarka/cezarion 0.14.3 → 0.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/core/cursor-acp-runner.d.ts +13 -0
  2. package/dist/core/cursor-acp-runner.js +118 -5
  3. package/dist/core/cursor-acp-runner.js.map +1 -1
  4. package/dist/core/cursor-provider-error.d.ts +30 -0
  5. package/dist/core/cursor-provider-error.js +53 -0
  6. package/dist/core/cursor-provider-error.js.map +1 -0
  7. package/dist/core/usage-limit.js +1 -1
  8. package/dist/core/usage-limit.js.map +1 -1
  9. package/dist/delegation/transport.d.ts +4 -4
  10. package/dist/runs/agent-tmpdir.d.ts +20 -11
  11. package/dist/runs/agent-tmpdir.js +109 -60
  12. package/dist/runs/agent-tmpdir.js.map +1 -1
  13. package/dist/runs/event-history.js +14 -1
  14. package/dist/runs/event-history.js.map +1 -1
  15. package/dist/server/server.d.ts +58 -58
  16. package/dist/skills-remote.d.ts +3 -2
  17. package/dist/skills-remote.js +5 -2
  18. package/dist/skills-remote.js.map +1 -1
  19. package/dist/workflows/run.js +6 -5
  20. package/dist/workflows/run.js.map +1 -1
  21. package/package.json +3 -3
  22. package/scripts/mock-cursor-acp.mjs +11 -1
  23. package/web/dist/assets/{commit-list-CEVhJoCF.js → commit-list-DOWYQ7G6.js} +1 -1
  24. package/web/dist/assets/{compare-variants-CZqdiqvW.js → compare-variants-B1XteHt-.js} +1 -1
  25. package/web/dist/assets/{github-BPfdr6aa.js → github-BhnijVvD.js} +1 -1
  26. package/web/dist/assets/index-DK0Mkv2m.css +1 -0
  27. package/web/dist/assets/{index-C4iEPAUV.js → index-DTsigc4h.js} +5 -5
  28. package/web/dist/assets/pill-BoBISMI9.js +1 -0
  29. package/web/dist/assets/{repo-git-C1Qv1JmM.js → repo-git-QEHH7y-w.js} +1 -1
  30. package/web/dist/assets/run-header-BKeByMek.js +1 -0
  31. package/web/dist/assets/{skills-_ZVZxmKz.js → skills-DOT1odMt.js} +1 -1
  32. package/web/dist/assets/{task-changes-BU9upwUw.js → task-changes-CUQTi97I.js} +1 -1
  33. package/web/dist/assets/{task-commits-CbJutMBx.js → task-commits-D_N8-awD.js} +1 -1
  34. package/web/dist/assets/{task-files-_hQyxAc7.js → task-files-CfYcMt07.js} +1 -1
  35. package/web/dist/assets/task-thread-Bnd_Pc07.js +9 -0
  36. package/web/dist/assets/thread-loading-B0WsjYr0.js +1 -0
  37. package/web/dist/assets/{workflows-B6Er16t0.js → workflows-C1I-xV9B.js} +1 -1
  38. package/web/dist/index.html +4 -4
  39. package/web/dist/assets/index-DPOGn7D5.css +0 -1
  40. package/web/dist/assets/pill-Dvvq0Otw.js +0 -1
  41. package/web/dist/assets/run-header-C9Aeh27u.js +0 -1
  42. package/web/dist/assets/task-thread-Yo52ML6l.js +0 -9
  43. package/web/dist/assets/thread-loading-B9uTF0dX.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$ as r,$r as i,B as a,Fn as o,Hn as s,Kr as c,Q as l,Qr as u,Rn as d,Xr as f,Yt as p,bt as m,d as h,da as g,dr as _,et as v,kt as y,mn as b,ni as x,nt as S,sa as C,tt as w,vt as T,xt as ee,yt as te}from"./alert-dialog-BOp2HnnL.js";import{n as E,t as D}from"./utils-GZNjgma4.js";import{c as ne,i as re,l as ie,r as ae,t as oe}from"./dropdown-menu-DAmCVaLJ.js";import{a as se,i as ce,r as le}from"./agent-accounts-BxBsIXGa.js";import{t as O}from"./createLucideIcon-BHp8sXmF.js";import{t as k}from"./external-link-BE6y205O.js";import{t as ue}from"./square-terminal-B6RYYieR.js";var de=O(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),A=O(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),fe=O(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),pe=O(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),me=O(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),he=O(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),ge=O(`diamond`,[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]),_e=O(`feather`,[[`path`,{d:`M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z`,key:`18jl4k`}],[`path`,{d:`M16 8 2 22`,key:`vp34q`}],[`path`,{d:`M17.5 15H9`,key:`1oz8nu`}]]),ve=O(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ye=O(`gem`,[[`path`,{d:`M10.5 3 8 9l4 13 4-13-2.5-6`,key:`b3dvk1`}],[`path`,{d:`M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z`,key:`7w4byz`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]]),j=O(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),be=O(`hammer`,[[`path`,{d:`m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9`,key:`1hayfq`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`15ts47`}]]),xe=O(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),Se=O(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),Ce=O(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),we=O(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),Te=O(`shapes`,[[`path`,{d:`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,key:`1bo67w`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`3.5`,key:`w3z12y`}]]),Ee=O(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),De=O(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),Oe=O(`waves-horizontal`,[[`path`,{d:`M2 12q2.5 2 5 0t5 0 5 0 5 0`,key:`8ddzzs`}],[`path`,{d:`M2 19q2.5 2 5 0t5 0 5 0 5 0`,key:`1wj4st`}],[`path`,{d:`M2 5q2.5 2 5 0t5 0 5 0 5 0`,key:`69x50u`}]]),ke=O(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),M=e(t(),1),N=n(),Ae=a(`inline-block size-[7px] shrink-0 rounded-full`,{variants:{tone:{success:`bg-success`,pending:`bg-pending-strong`,danger:`bg-danger`,accent:`bg-accent-strong`,running:`bg-running`,neutral:`bg-soft-foreground`},pulse:{true:`animate-pulse motion-reduce:animate-none`,false:``}},defaultVariants:{tone:`neutral`,pulse:!1}});function P({className:e,tone:t=`neutral`,pulse:n=!1,...r}){return(0,N.jsx)(`span`,{"data-slot":`status-dot`,"data-tone":t,className:D(Ae({tone:t,pulse:n,className:e})),...r})}var je=[`done`,`failed`,`cancelled`],Me=[`done`,`failed`];function Ne(e){return e.status===`failed`&&e.autoResumeAt!==void 0}function Pe(e){return je.includes(e)}function F(e){return e.archived||Ne(e)||!Me.includes(e.status)?!1:e.finishedAt!==void 0}function I(e){let t=e.finishedAt;return t===void 0||!F(e)?!1:e.seenAt===void 0||e.seenAt<t}function Fe(e){return!Ne(e)&&Pe(e.status)&&!I(e)}function Ie(e){return e.reduce((e,t)=>I(t)?e+1:e,0)}var L=(0,M.createContext)(null);function Le({children:e}){let[t,n]=(0,M.useState)(()=>new Map),r=(0,M.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,M.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=s((0,M.useMemo)(()=>[...t.values()].flat(),[t])),o=(0,M.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,N.jsx)(L.Provider,{value:o,children:e})}var R=(0,M.createContext)(null);function Re({projectId:e,requests:t,children:n}){let r=(0,M.useContext)(L),i=(0,M.useId)();(0,M.useEffect)(()=>{if(r)return r.publish(i,t),()=>r.retract(i)},[r,i,t.map(e=>`${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`)]);let a=s(r?ze:t),o=r?.lookup??a,c=(0,M.useMemo)(()=>({lookup:o,projectId:e}),[o,e]);return(0,N.jsx)(R.Provider,{value:c,children:n})}var ze=[];function Be(e,t,n){let r=(0,M.useContext)(R),i=n??r?.projectId;return!r||!i||t===void 0?Ve:r.lookup({projectId:i,kind:e,number:t})}var Ve=Object.freeze({state:`idle`}),He={success:`border-success/40 text-success`,danger:`border-danger/40 text-danger`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-pending-strong`,conflict:`border-conflict/45 text-conflict`},Ue={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},We={draft:m,"review-required":ee,"changes-requested":y,"checks-pending":null,"checks-failing":S,ready:l,merged:T,closed:te,open:r,completed:l,"not-planned":w};function z({reference:e,taskTitle:t,status:n,conflicting:r,conflictAction:a,projectId:o,className:s,compact:c=!1}){let{kind:l,number:d,url:f}=e,m=Be(l,d,o),h=n??m.status,g=i(h),_=l===`PR`&&(r??m.conflicting)===!0,v=_?u:g,y=D(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[10px] font-normal`,He[v?.tone??`accent`],s),b=Je(m,v,_?g:void 0),x=d?`${!c&&l===`Issue`?`Issue `:``}#${d}`:l,S=l===`PR`?`pull request`:`issue`,C=`Open the ${S} for ${t}${v?` — ${v.label}`:``}`,w=(0,N.jsxs)(N.Fragment,{children:[_?(0,N.jsx)(p,{className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,N.jsx)(Xe,{status:v?h:void 0}),x]}),T=!f||!E(f)?(0,N.jsx)(`span`,{"data-slot":l===`PR`?`pr-chip`:`issue-chip`,"data-status":h,..._?{"data-conflicting":`true`}:{},"aria-label":v?`${S} ${x} — ${v.label}`:void 0,className:y,children:w}):(0,N.jsx)(`a`,{"data-slot":l===`PR`?`pr-chip`:`issue-chip`,"data-status":h,..._?{"data-conflicting":`true`}:{},href:f,target:`_blank`,rel:`noopener noreferrer`,title:b?void 0:f,"aria-label":C,className:D(y,Ue[v?.tone??`accent`]),children:w});if(!b)return T;let ee=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`span`,{className:`block font-medium`,children:[l===`PR`?`Pull request`:`Issue`,d?` #${d}`:``,` · `,b.headline]}),(0,N.jsx)(`span`,{className:`block`,children:b.detail}),b.also?(0,N.jsx)(`span`,{className:`block opacity-70`,children:b.also}):null,f&&E(f)?(0,N.jsx)(`span`,{className:`block opacity-70`,children:f.replace(/^https?:\/\//,``)}):null]});return(0,N.jsx)(qe,{chip:T,action:_?a:void 0,state:m.state,children:ee})}var B=(0,M.createContext)(()=>{});function Ge(){return(0,M.useContext)(B)}var Ke=150,V=120;function qe({chip:e,action:t,state:n,children:r}){let[i,a]=(0,M.useState)(!1),o=(0,M.useRef)(null),s=(0,M.useRef)(null),c=(0,M.useRef)(void 0),l=(0,M.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,M.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,M.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,N.jsxs)(le,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,N.jsx)(ce,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,Ke)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,V)},onFocus:()=>a(!0),onBlur:e=>{d(e.relatedTarget)||u()},onKeyDown:e=>{if(e.key===`Escape`)return u();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,N.jsxs)(se,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),d(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,V)},children:[(0,N.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,N.jsx)(B.Provider,{value:u,children:t}):null]})]})}function Je(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${Ye(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function Ye(e){return e.charAt(0).toLowerCase()+e.slice(1)}function Xe({status:e}){if(!e)return null;if(e===`checks-pending`)return(0,N.jsx)(v,{"data-slot":`status-dot`,"data-tone":`pending`,className:`size-3 animate-pulse motion-reduce:animate-none`,"aria-hidden":`true`});let t=We[e];return t?(0,N.jsx)(t,{className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null}var H={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`pi`,cursor:`Cursor`};function U(e){let t=e.currentStepId?e.steps.find(t=>t.id===e.currentStepId):void 0;if(t?.backend)return t.backend;if(e.runner)return e.runner;for(let t=e.steps.length-1;t>=0;--t){let n=e.steps[t]?.backend;if(n)return n}return`claude`}function W(e){return e.runner??`claude`}function G(e,t){let n=g(t,e);return n?.enabled===!1?{provider:e,usable:!1,reason:`${H[e]} is disabled. Enable it in Settings → Agents → Providers.`}:n?.status===`connected`?{provider:e,usable:!0}:{provider:e,usable:!1,reason:`${H[e]} credentials are unavailable. Authorize it in Settings → Agents → Providers.`}}function Ze(e,t){return G(U(e),t)}function Qe(e,t){return G(W(e),t)}function K(e){let t=d(),n=U(e);return t.isSuccess&&t.data?Ze(e,t.data):{provider:n,usable:!0}}function $e(e){let t=d(),n=W(e);return t.isSuccess&&t.data?Qe(e,t.data):t.isError?{provider:n,usable:!1,reason:`Provider authentication could not be verified.`}:{provider:n,usable:!1,reason:`Checking agent providers…`}}var et={folder:ve,terminal:ue,vscode:me,cursor:Se,zed:ke,windsurf:Oe,sublime:_e,idea:ge,pycharm:xe,webstorm:j,goland:Te,rubymine:ye,phpstorm:pe,clion:he,rider:fe,"android-studio":Ee,xcode:be,warp:we,claude:A,codex:De,opencode:A,pi:A};function q(e){return e.icon&&et[e.icon]||k}function J(e){let t=/^cli:(claude|codex|opencode|pi|cursor)$/.exec(e);return t?t[1]:void 0}function tt({choices:e,onPick:t,label:n=`Open in…`,title:r,triggerVariant:i=`ghost`,disabled:a=!1,leading:o,trailing:s,slot:c}){return(0,N.jsxs)(oe,{children:[(0,N.jsx)(ie,{asChild:!0,children:(0,N.jsxs)(h,{variant:i,size:`sm`,title:r,disabled:a,"data-slot":c,children:[(0,N.jsx)(k,{"aria-hidden":`true`}),n]})}),(0,N.jsxs)(ae,{align:`end`,children:[o,o&&e.length>0?(0,N.jsx)(ne,{}):null,e.map(({target:e,suffix:n,title:r})=>{let i=q(e);return(0,N.jsxs)(re,{"data-target":e.id,title:r,onSelect:()=>t(e.id),children:[(0,N.jsx)(i,{"aria-hidden":`true`}),e.label,n??``]},e.id)}),s]})]})}function Y(e){return e===`running`||e===`queued`||e===`waiting`}function X(e){return[...e.steps].reverse().find(e=>e.sessionId)?.sessionId}function Z(e){return[...e.steps].reverse().find(e=>e.sessionId)?.backend??e.runner??`claude`}var nt=/^[A-Za-z0-9._][A-Za-z0-9._-]{0,199}$/;function rt(e,t){if(nt.test(t))switch(e){case`codex`:return`codex resume ${t}`;case`cursor`:return;case`opencode`:return`opencode --session ${t}`;default:return`claude --resume ${t}`}}function it(e){if(Y(e.status))return;let t=X(e);if(t===void 0||!nt.test(t))return;let n=Z(e),r=n===`cursor`?e.cliResumeCommand:rt(n,t);if(r!==void 0)return e.worktreePath?`cd ${e.worktreePath} && ${r}`:r}function at(e,t){let n=J(t);return!n||Y(e.status)?!1:n===Z(e)&&X(e)!==void 0}function ot(e){return e.status===`cancelled`&&e.startedAt===void 0&&e.workflowDef!==void 0&&e.steps.every(e=>e.status===`pending`&&e.startedAt===void 0&&!e.sessionId)}function Q(e){let t=Y(e.status),n=X(e)!==void 0;return{finish:e.status===`waiting`||e.status===`review`,continueRun:!t&&!e.stopping&&e.delegation?.role!==`invalid`&&!(e.delegation?.role===`worker`&&e.delegation.destroy)&&(n||ot(e)),terminal:!t&&n,notes:!0,archive:!t,pin:!e.archived,markUnread:F(e)&&!I(e),cancel:t,deleteRun:!t}}function st(e,t=!1){return!Q(e).finish||e.status!==`waiting`||e.delegation?.role===`root`?!1:f(e,t).bucket===`waiting`}function ct(e){return`Merge head branch and resolve conflicts in ${e?`PR number ${e}`:`this pull request`}`}function lt(e){return e===`review`?`Accept the changes without a PR`:`Close the session`}function ut(e,t){let n=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt)).findIndex(e=>e.id===t);return n>=0?n+1:void 0}var dt=[50,100,200,400,800,1e3,1e3,1e3,1e3],ft=e=>new Promise(t=>setTimeout(t,e));function pt(e){return e instanceof x&&e.status===409&&e.message===`run is still active`}async function mt(e,t=ft){for(let n=0;;n+=1)try{return await e()}catch(e){let r=dt[n];if(!pt(e)||r===void 0)throw e;await t(r)}}function ht(e){return Y(e.status)?`live`:Q(e).continueRun?`resume`:`unavailable`}function gt(e,t){let n=_(e.id,t),r=b(e.id,t),i=K(e),a=$e(e),[o,s]=(0,M.useState)(void 0),[c,l]=(0,M.useState)(!1),u=(0,M.useRef)(!1),d=ht(e),f=d===`resume`?!a.usable:d===`live`&&!i.usable,p=d===`unavailable`?`no-session`:f?`provider`:void 0,m=p===`no-session`?`This session has ended and no agent session was recorded, so the answer cannot be delivered.`:p===`provider`?d===`resume`?a.reason:i.reason:void 0,h=(e,t)=>a.usable?r.mutateAsync({text:e,...t===void 0?{}:{images:t}}):Promise.reject(Error(a.reason??`The run provider is unavailable.`));return{mode:d,blockedBy:p,reason:m,isPending:c||n.isPending||r.isPending,error:o,send:async(t,r)=>{if(p||u.current)return m;u.current=!0,l(!0),s(void 0);try{if(d===`resume`){await mt(()=>h(t,r));return}try{await n.mutateAsync({text:t,...r===void 0?{}:{images:r}})}catch(n){if(n instanceof x&&n.status===409&&X(e)!==void 0){try{await mt(()=>h(t,r))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Session closed. Retry to reopen the session. ${t}`)}return}throw n}return}catch(e){let t=e instanceof Error?e.message:String(e);return s(t),t}finally{u.current=!1,l(!1)}}}}function $({run:e,projectId:t,prNumber:n}){let r=gt(e,t),i=Ge(),[a,o]=(0,M.useState)(!1),s=a||r.isPending,c=!!r.blockedBy,l=async()=>{if(s||c)return;let e=r.mode===`resume`;o(!0);try{let t=await r.send(ct(n));t?C(t,{tone:`danger`}):(C(`${e?`Task reopened`:`Sent to the task`} — resolving conflicts${n?` in PR #${n}`:``}`),i())}finally{o(!1)}};return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(h,{type:`button`,size:`sm`,"data-slot":`reference-conflict-action`,disabled:c||s,onClick:()=>void l(),className:`h-7 w-full text-xs`,children:s?`Sending…`:`Resolve conflicts`}),c&&r.reason?(0,N.jsx)(`span`,{className:`block opacity-70`,children:r.reason}):null]})}function _t({projectId:e,runId:t,prNumber:n}){let r=o(e,t);return r.data?(0,N.jsx)($,{run:r.data,projectId:e,prNumber:n}):(0,N.jsx)(h,{type:`button`,size:`sm`,disabled:!0,className:`h-7 w-full text-xs`,children:r.isError?`Unavailable`:`Loading…`})}function vt({run:e,reference:t,className:n,compact:r=!1}){return(0,N.jsx)(z,{reference:t,taskTitle:c(e),conflictAction:(0,N.jsx)($,{run:e,prNumber:t.number}),className:n,compact:r})}function yt(e,t){let[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(``),o=(0,M.useRef)(!1);return{editing:n,draft:i,setDraft:a,begin:()=>{a(e),o.current=!1,r(!0)},commit:()=>{if(o.current)return;o.current=!0,r(!1);let n=i.trim();n.length===0||n===e||t(n)},cancel:()=>{o.current=!0,r(!1)}}}function bt({editor:e,className:t}){return(0,N.jsx)(`input`,{"data-slot":`title-input`,"aria-label":`Task title`,autoFocus:!0,value:e.draft,onChange:t=>e.setDraft(t.target.value),onBlur:e.commit,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),e.commit()):t.key===`Escape`&&(t.preventDefault(),e.cancel())},className:D(`w-full min-w-0 rounded-sm border border-border bg-card px-1.5 py-0.5 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,t)})}function xt({className:e,dot:t,pulse:n=!1,children:r,...i}){return(0,N.jsxs)(`span`,{"data-slot":`pill`,className:D(`inline-flex items-center gap-1.5 rounded-full bg-muted px-2.5 py-[3px] text-xs font-medium whitespace-nowrap text-muted-foreground`,e),...i,children:[t?(0,N.jsx)(P,{tone:t,pulse:n}):null,r]})}export{Ce as A,Re as C,I as D,Fe as E,ve as M,de as N,Ie as O,z as S,F as T,Q as _,_t as a,q as b,at as c,ot as d,Z as f,it as g,ut as h,$ as i,j,P as k,lt as l,st as m,bt as n,vt as o,X as p,yt as r,gt as s,xt as t,Y as u,tt as v,Le as w,K as x,J as y};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Aa as r,Ai as i,Ca as a,Ea as o,It as s,Jn as c,Ki as l,Rt as u,Ta as d,U as f,Wi as p,Xn as m,Yn as h,Yt as g,_t as _,a as ee,c as v,d as y,gt as b,hi as x,i as te,in as S,l as C,lt as w,n as T,ni as E,o as D,r as O,s as k,sa as A,t as ne,vn as j,wn as M,xt as N}from"./alert-dialog-BOp2HnnL.js";import{n as P,t as F}from"./utils-GZNjgma4.js";import{t as I}from"./createLucideIcon-BHp8sXmF.js";import{n as L}from"./diff-controls-DaO836o4.js";import{i as R,r as z,t as B}from"./git-toolbar-rk3doc2w.js";import{t as V,u as H}from"./project-router-CvFAMDcP.js";import{t as U}from"./search-x-I9Q8pgUa.js";import{t as W}from"./diff-stat-DpHwISUB.js";import{a as G,h as K}from"./index-C4iEPAUV.js";import{t as q}from"./diff-BjLZHKfD2.js";import{t as J}from"./tab-link-CkIV8ixq.js";import{t as Y}from"./use-desktop-BaYgO7YW.js";import{t as X}from"./commit-list-CEVhJoCF.js";var re=I(`git-pull-request-arrow`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v12`,key:`ih889a`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}]]),Z=e(t(),1),Q=n();function ie({repo:e,info:t}){let n=M(),i=r(),a=e=>A(e.message,{tone:`danger`}),o=d({mutationFn:e=>x({name:e}),onSuccess:async e=>{A(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([i.invalidateQueries({queryKey:S.repo}),i.invalidateQueries({queryKey:S.health})]),i.setQueryData(S.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),i.setQueryData(S.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:a}),c=d({mutationFn:e=>l({baseBranch:e}),onSuccess:e=>{A(e.baseBranch?`Agents now branch from ${e.baseBranch}`:`Agents now fork from the checked-out branch`),i.invalidateQueries({queryKey:S.repo})},onError:a}),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),g=m.trim().toLowerCase(),_=g?e.branches.filter(e=>e.toLowerCase().includes(g)):e.branches;return(0,Q.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 px-[18px] py-[22px] md:grid-cols-[minmax(0,1fr)_290px] md:px-9`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,Q.jsxs)(`label`,{className:`relative block`,children:[(0,Q.jsx)(u,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,Q.jsx)(K,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:m,onChange:e=>h(e.target.value),className:`h-11 pl-10`})]}),(0,Q.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-4 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[_.map(e=>{let n=e===t.branch;return(0,Q.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,className:`flex min-h-20 flex-col items-start justify-center gap-2 py-3 md:flex-row md:items-center md:justify-start md:py-2.5`,children:[(0,Q.jsx)(`span`,{className:F(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),n?(0,Q.jsx)(`span`,{"data-slot":`branch-current`,className:`md:ml-auto flex shrink-0 items-center rounded-md bg-accent-strong/10 px-2 py-1.5 text-[10px] font-medium text-accent-text`,children:`Current`}):(0,Q.jsxs)(y,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:o.isPending,onClick:()=>o.mutate(e),children:[(0,Q.jsx)(b,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),_.length===0?(0,Q.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,m.trim(),`”.`]}):null]})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,Q.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-7 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=f.trim();t&&o.mutate(t,{onSuccess:()=>p(``)})},children:[(0,Q.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,Q.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:`Create from the selected base.`}),(0,Q.jsx)(K,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:f,onChange:e=>p(e.target.value)}),(0,Q.jsxs)(y,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!f.trim()||o.isPending,children:[(0,Q.jsx)(s,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,Q.jsxs)(`div`,{className:`mt-5`,children:[(0,Q.jsx)(`label`,{htmlFor:`base-branch-picker`,className:`text-sm font-medium`,children:`Agents’ base branch`}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`New task worktrees branch from this.`}),(0,Q.jsxs)(`select`,{id:`base-branch-picker`,"data-slot":`base-branch-picker`,value:e.baseBranch??``,disabled:c.isPending,onChange:e=>c.mutate(e.target.value===``?null:e.target.value),className:`mt-1.5 block min-h-11 w-full rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,Q.jsx)(`option`,{value:``,children:`follow checked-out branch (default)`}),e.branches.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]})]}),(0,Q.jsx)(`p`,{className:`mt-3 border-t border-border pt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),n.data?.forge?.available?(0,Q.jsx)(ae,{}):null]})}function ae(){let e=j({limit:20});return(0,Q.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,Q.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,Q.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,Q.jsx)(oe,{pr:e},e.number))}):(0,Q.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function oe({pr:e}){let t=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(N,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,Q.jsx)(se,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,Q.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:P(e.url)?(0,Q.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:F(n,`hover:bg-muted`),children:t}):(0,Q.jsx)(`span`,{className:n,children:t})})}function se({checks:e}){return(0,Q.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:F(`shrink-0 text-[10px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}function ce(){let e=h(),t=Y(),[n,r]=(0,Z.useState)(`unified`),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),c=(0,Z.useRef)(null),l=e.isError&&e.error instanceof E&&e.error.status===409,u=e.data?.files??[],d=(0,Z.useMemo)(()=>z(u),[u]),f=t?n:`unified`,p=!t||i;return(0,Q.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 px-[18px] py-[22px] md:px-9`,children:[(0,Q.jsx)(`span`,{className:`text-sm`,children:e.data?`${e.data.stat.files} files changed ·`:`Uncommitted changes`}),e.data?(0,Q.jsx)(B,{stat:e.data.stat}):null,(0,Q.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,Q.jsx)(L,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})})]}),e.isPending?(0,Q.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,Q.jsx)(C,{icon:l?(0,Q.jsx)(w,{size:16}):(0,Q.jsx)(g,{size:16}),tone:l?`neutral`:`danger`,heading:`h2`,title:l?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):u.length===0?(0,Q.jsx)(C,{icon:(0,Q.jsx)(w,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:1rem] md:px-9`,children:[(0,Q.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[250px]`,children:[(0,Q.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,Q.jsx)(R,{root:d,selected:o,onSelect:e=>{s(e),c.current?.scrollToPath(e)}})]}),(0,Q.jsx)(q,{files:u,viewRef:c,mode:f,wrap:p,className:`min-w-0 flex-1`})]})]})}function $({log:e}){let{sha:t}=a();return t?(0,Q.jsx)(le,{sha:t}):e.length===0?(0,Q.jsx)(C,{icon:(0,Q.jsx)(_,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`}):(0,Q.jsx)(`div`,{className:`px-[18px] py-[22px] md:px-9`,children:(0,Q.jsx)(X,{slot:`repo-commits`,commits:e.map(e=>({sha:e.hash,shaLabel:e.hash,subject:e.subject,author:e.author,when:e.when,href:`/git/commits/${e.hash}`}))})})}function le({sha:e}){let t=m(e),n=Y(),[r,i]=(0,Z.useState)(`unified`),[a,o]=(0,Z.useState)(!1),s=t.isError&&t.error instanceof E&&t.error.status===409,c=n?r:`unified`,l=!n||a;return(0,Q.jsxs)(`section`,{"data-slot":`repo-commit`,"data-sha":e,className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[(0,Q.jsx)(y,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,Q.jsxs)(V,{to:`/git/commits`,children:[(0,Q.jsx)(f,{size:16,"aria-hidden":`true`}),`All commits`]})}),t.data?(0,Q.jsx)(W,{stat:t.data.stat}):null,(0,Q.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,Q.jsx)(L,{mode:r,wrap:a,onModeChange:i,onWrapChange:o})})]}),t.isPending?(0,Q.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commit…`}):t.isError?(0,Q.jsx)(C,{icon:s?(0,Q.jsx)(U,{}):(0,Q.jsx)(g,{size:16}),tone:s?`neutral`:`danger`,heading:`h2`,title:s?`Commit not found`:`Could not load the commit`,subtitle:t.error.message}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:t.data.subject}),(0,Q.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[t.data.author,` · `,t.data.when,` ·`,` `,(0,Q.jsx)(`span`,{className:`font-mono select-all`,children:t.data.sha})]})]}),t.data.files.length===0?(0,Q.jsx)(C,{icon:(0,Q.jsx)(_,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,Q.jsx)(`div`,{className:`px-4 py-4 [--diff-sticky-top:1rem] md:px-6`,children:(0,Q.jsx)(q,{files:t.data.files,mode:c,wrap:l,className:`min-w-0`})})]})]})}function ue({repo:e,info:t}){let n=r(),[a,s]=(0,Z.useState)(e.baseBranch??t.branch),[c,l]=(0,Z.useState)(null),u=(0,Z.useRef)(null),f=S.repo,m=S.health,h=[...f,`pull`],g=!!t.remote,_=o({queryKey:h,queryFn:({signal:e})=>i({signal:e}),enabled:g}),x=d({mutationFn:p}),C=()=>Promise.all([n.invalidateQueries({queryKey:f}),n.invalidateQueries({queryKey:m})]),w=async(e,t=!1)=>{try{let n=await x.mutateAsync(t?{branch:e,confirm:!0}:{branch:e});if(`risks`in n){l(n);return}l(null),A(n.summary),await C()}catch(e){l(null),A(e instanceof Error?e.message:String(e),{tone:`danger`}),await C()}},E=_.data?.branches??e.branches,j=_.data===void 0||E.includes(a),M=j?E:[a,...E],N=g&&_.isPending,P=g?_.isError?`Could not load local branches: ${_.error.message}`:j?null:`${a} is not a local branch. Choose a local branch to pull.`:`No remote configured. Add a Git remote before pulling.`,F=x.isPending||N||!g||_.isError,I=F||!j,L=a!==t.branch;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{"data-slot":`repo-pull`,className:`max-w-full md:w-auto`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`repo-pull-branch`,className:`sr-only`,children:`Branch to pull`}),(0,Q.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,Q.jsx)(b,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,Q.jsx)(`select`,{id:`repo-pull-branch`,value:a,disabled:F,onChange:e=>s(e.target.value),className:`h-11 max-w-full min-w-[88px] appearance-none rounded-lg border border-input bg-card pr-3 pl-9 text-[13px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,style:{width:`${Math.max(88,a.length*8+56)}px`},children:M.map(e=>(0,Q.jsx)(`option`,{value:e,disabled:!j&&e===a,children:e},e))})]}),(0,Q.jsxs)(y,{ref:u,type:`button`,"data-action":`repo-pull`,className:`h-11 px-4`,disabled:I,title:P??void 0,onClick:()=>void w(a),children:[x.isPending?(0,Q.jsx)(H,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,Q.jsx)(re,{"aria-hidden":`true`}),L?`Switch & pull`:`Pull`]})]}),P||L?(0,Q.jsx)(`p`,{"data-slot":`repo-pull-note`,className:`mt-1 break-all text-[11px] text-soft-foreground md:text-left`,children:P??`${a} stays checked out after the pull.`}):null]}),(0,Q.jsx)(ne,{open:c!==null,onOpenChange:e=>{!e&&!x.isPending&&l(null)},children:(0,Q.jsxs)(te,{onCloseAutoFocus:e=>{e.preventDefault(),u.current?.focus()},children:[(0,Q.jsxs)(k,{children:[(0,Q.jsxs)(v,{children:[`Pull `,c?.branch,` anyway?`]}),(0,Q.jsx)(ee,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[c?.risks.includes(`active_runs`)?(0,Q.jsx)(`p`,{children:`An active session is using this repository. Pulling can change files while it works.`}):null,c?.risks.includes(`dirty_tree`)?(0,Q.jsx)(`p`,{children:`The checkout has dirty files. Git may refuse the switch or pull to protect them.`}):null,(0,Q.jsxs)(`p`,{children:[c?.branch,` will stay checked out after this attempt.`]})]})})]}),(0,Q.jsxs)(D,{children:[(0,Q.jsx)(O,{className:`h-11`,disabled:x.isPending,children:`Cancel`}),(0,Q.jsx)(T,{className:`h-11`,disabled:x.isPending||c===null,onClick:e=>{e.preventDefault(),c&&w(c.branch,!0)},children:x.isPending?`Pulling…`:`Pull anyway`})]})]})})]})}function de({tab:e}){let t=c();if(t.isPending)return(0,Q.jsx)(G,{});if(t.isError)return(0,Q.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(C,{icon:(0,Q.jsx)(g,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:t.error.message})});let n=t.data.info;return n?(0,Q.jsx)(fe,{repo:t.data,info:n,tab:e}):(0,Q.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(C,{icon:(0,Q.jsx)(b,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`cezar is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function fe({repo:e,info:t,tab:n}){return(0,Q.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,Q.jsxs)(`header`,{"data-slot":`repo-header`,className:`px-[18px] pt-[18px] md:px-9 md:pt-9`,children:[(0,Q.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight md:text-[30px]`,children:[`Git · `,n===`changes`?`Changes`:n===`commits`?`Commits`:`Branches`]}),(0,Q.jsxs)(`p`,{"data-slot":`repo-remote`,className:`mt-2 break-all text-[13px] text-muted-foreground`,children:[t.root.split(`/`).filter(Boolean).at(-1),t.remote?` · ${t.remote}`:``,` · `,(0,Q.jsx)(`span`,{"data-slot":`branch-chip`,children:t.branch})]}),(0,Q.jsx)(`div`,{className:`my-[22px] flex min-w-0 items-start gap-2.5`,children:(0,Q.jsx)(ue,{repo:e,info:t})}),(0,Q.jsxs)(`div`,{"data-slot":`repo-tabs`,className:`flex items-end gap-6 border-b border-border [&>a]:min-h-11`,children:[(0,Q.jsx)(J,{to:`/git`,active:n===`changes`,children:`Changes`}),(0,Q.jsx)(J,{to:`/git/commits`,active:n===`commits`,children:`Commits`}),(0,Q.jsx)(J,{to:`/git/branches`,active:n===`branches`,children:`Branches`})]})]}),n===`changes`?(0,Q.jsx)(ce,{}):n===`commits`?(0,Q.jsx)($,{log:e.log}):(0,Q.jsx)(ie,{repo:e,info:t})]})}export{de as RepoGitRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Aa as r,Ai as i,Ca as a,Ea as o,It as s,Jn as c,Ki as l,Rt as u,Ta as d,U as f,Wi as p,Xn as m,Yn as h,Yt as g,_t as _,a as ee,c as v,d as y,gt as b,hi as x,i as te,in as S,l as C,lt as w,n as T,ni as E,o as D,r as O,s as k,sa as A,t as ne,vn as j,wn as M,xt as N}from"./alert-dialog-BOp2HnnL.js";import{n as P,t as F}from"./utils-GZNjgma4.js";import{t as I}from"./createLucideIcon-BHp8sXmF.js";import{n as L}from"./diff-controls-DaO836o4.js";import{i as R,r as z,t as B}from"./git-toolbar-rk3doc2w.js";import{t as V,u as H}from"./project-router-CvFAMDcP.js";import{t as U}from"./search-x-I9Q8pgUa.js";import{t as W}from"./diff-stat-DpHwISUB.js";import{a as G,h as K}from"./index-DTsigc4h.js";import{t as q}from"./diff-BjLZHKfD2.js";import{t as J}from"./tab-link-CkIV8ixq.js";import{t as Y}from"./use-desktop-BaYgO7YW.js";import{t as X}from"./commit-list-DOWYQ7G6.js";var re=I(`git-pull-request-arrow`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v12`,key:`ih889a`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}]]),Z=e(t(),1),Q=n();function ie({repo:e,info:t}){let n=M(),i=r(),a=e=>A(e.message,{tone:`danger`}),o=d({mutationFn:e=>x({name:e}),onSuccess:async e=>{A(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([i.invalidateQueries({queryKey:S.repo}),i.invalidateQueries({queryKey:S.health})]),i.setQueryData(S.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),i.setQueryData(S.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:a}),c=d({mutationFn:e=>l({baseBranch:e}),onSuccess:e=>{A(e.baseBranch?`Agents now branch from ${e.baseBranch}`:`Agents now fork from the checked-out branch`),i.invalidateQueries({queryKey:S.repo})},onError:a}),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),g=m.trim().toLowerCase(),_=g?e.branches.filter(e=>e.toLowerCase().includes(g)):e.branches;return(0,Q.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 px-[18px] py-[22px] md:grid-cols-[minmax(0,1fr)_290px] md:px-9`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,Q.jsxs)(`label`,{className:`relative block`,children:[(0,Q.jsx)(u,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,Q.jsx)(K,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:m,onChange:e=>h(e.target.value),className:`h-11 pl-10`})]}),(0,Q.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-4 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[_.map(e=>{let n=e===t.branch;return(0,Q.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,className:`flex min-h-20 flex-col items-start justify-center gap-2 py-3 md:flex-row md:items-center md:justify-start md:py-2.5`,children:[(0,Q.jsx)(`span`,{className:F(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),n?(0,Q.jsx)(`span`,{"data-slot":`branch-current`,className:`md:ml-auto flex shrink-0 items-center rounded-md bg-accent-strong/10 px-2 py-1.5 text-[10px] font-medium text-accent-text`,children:`Current`}):(0,Q.jsxs)(y,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:o.isPending,onClick:()=>o.mutate(e),children:[(0,Q.jsx)(b,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),_.length===0?(0,Q.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,m.trim(),`”.`]}):null]})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,Q.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-7 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=f.trim();t&&o.mutate(t,{onSuccess:()=>p(``)})},children:[(0,Q.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,Q.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:`Create from the selected base.`}),(0,Q.jsx)(K,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:f,onChange:e=>p(e.target.value)}),(0,Q.jsxs)(y,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!f.trim()||o.isPending,children:[(0,Q.jsx)(s,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,Q.jsxs)(`div`,{className:`mt-5`,children:[(0,Q.jsx)(`label`,{htmlFor:`base-branch-picker`,className:`text-sm font-medium`,children:`Agents’ base branch`}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`New task worktrees branch from this.`}),(0,Q.jsxs)(`select`,{id:`base-branch-picker`,"data-slot":`base-branch-picker`,value:e.baseBranch??``,disabled:c.isPending,onChange:e=>c.mutate(e.target.value===``?null:e.target.value),className:`mt-1.5 block min-h-11 w-full rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,Q.jsx)(`option`,{value:``,children:`follow checked-out branch (default)`}),e.branches.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]})]}),(0,Q.jsx)(`p`,{className:`mt-3 border-t border-border pt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),n.data?.forge?.available?(0,Q.jsx)(ae,{}):null]})}function ae(){let e=j({limit:20});return(0,Q.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,Q.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,Q.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,Q.jsx)(oe,{pr:e},e.number))}):(0,Q.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function oe({pr:e}){let t=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(N,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,Q.jsx)(se,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,Q.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:P(e.url)?(0,Q.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:F(n,`hover:bg-muted`),children:t}):(0,Q.jsx)(`span`,{className:n,children:t})})}function se({checks:e}){return(0,Q.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:F(`shrink-0 text-[10px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}function ce(){let e=h(),t=Y(),[n,r]=(0,Z.useState)(`unified`),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),c=(0,Z.useRef)(null),l=e.isError&&e.error instanceof E&&e.error.status===409,u=e.data?.files??[],d=(0,Z.useMemo)(()=>z(u),[u]),f=t?n:`unified`,p=!t||i;return(0,Q.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 px-[18px] py-[22px] md:px-9`,children:[(0,Q.jsx)(`span`,{className:`text-sm`,children:e.data?`${e.data.stat.files} files changed ·`:`Uncommitted changes`}),e.data?(0,Q.jsx)(B,{stat:e.data.stat}):null,(0,Q.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,Q.jsx)(L,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})})]}),e.isPending?(0,Q.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,Q.jsx)(C,{icon:l?(0,Q.jsx)(w,{size:16}):(0,Q.jsx)(g,{size:16}),tone:l?`neutral`:`danger`,heading:`h2`,title:l?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):u.length===0?(0,Q.jsx)(C,{icon:(0,Q.jsx)(w,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:1rem] md:px-9`,children:[(0,Q.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[250px]`,children:[(0,Q.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,Q.jsx)(R,{root:d,selected:o,onSelect:e=>{s(e),c.current?.scrollToPath(e)}})]}),(0,Q.jsx)(q,{files:u,viewRef:c,mode:f,wrap:p,className:`min-w-0 flex-1`})]})]})}function $({log:e}){let{sha:t}=a();return t?(0,Q.jsx)(le,{sha:t}):e.length===0?(0,Q.jsx)(C,{icon:(0,Q.jsx)(_,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`}):(0,Q.jsx)(`div`,{className:`px-[18px] py-[22px] md:px-9`,children:(0,Q.jsx)(X,{slot:`repo-commits`,commits:e.map(e=>({sha:e.hash,shaLabel:e.hash,subject:e.subject,author:e.author,when:e.when,href:`/git/commits/${e.hash}`}))})})}function le({sha:e}){let t=m(e),n=Y(),[r,i]=(0,Z.useState)(`unified`),[a,o]=(0,Z.useState)(!1),s=t.isError&&t.error instanceof E&&t.error.status===409,c=n?r:`unified`,l=!n||a;return(0,Q.jsxs)(`section`,{"data-slot":`repo-commit`,"data-sha":e,className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[(0,Q.jsx)(y,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,Q.jsxs)(V,{to:`/git/commits`,children:[(0,Q.jsx)(f,{size:16,"aria-hidden":`true`}),`All commits`]})}),t.data?(0,Q.jsx)(W,{stat:t.data.stat}):null,(0,Q.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,Q.jsx)(L,{mode:r,wrap:a,onModeChange:i,onWrapChange:o})})]}),t.isPending?(0,Q.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commit…`}):t.isError?(0,Q.jsx)(C,{icon:s?(0,Q.jsx)(U,{}):(0,Q.jsx)(g,{size:16}),tone:s?`neutral`:`danger`,heading:`h2`,title:s?`Commit not found`:`Could not load the commit`,subtitle:t.error.message}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold`,children:t.data.subject}),(0,Q.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[t.data.author,` · `,t.data.when,` ·`,` `,(0,Q.jsx)(`span`,{className:`font-mono select-all`,children:t.data.sha})]})]}),t.data.files.length===0?(0,Q.jsx)(C,{icon:(0,Q.jsx)(_,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,Q.jsx)(`div`,{className:`px-4 py-4 [--diff-sticky-top:1rem] md:px-6`,children:(0,Q.jsx)(q,{files:t.data.files,mode:c,wrap:l,className:`min-w-0`})})]})]})}function ue({repo:e,info:t}){let n=r(),[a,s]=(0,Z.useState)(e.baseBranch??t.branch),[c,l]=(0,Z.useState)(null),u=(0,Z.useRef)(null),f=S.repo,m=S.health,h=[...f,`pull`],g=!!t.remote,_=o({queryKey:h,queryFn:({signal:e})=>i({signal:e}),enabled:g}),x=d({mutationFn:p}),C=()=>Promise.all([n.invalidateQueries({queryKey:f}),n.invalidateQueries({queryKey:m})]),w=async(e,t=!1)=>{try{let n=await x.mutateAsync(t?{branch:e,confirm:!0}:{branch:e});if(`risks`in n){l(n);return}l(null),A(n.summary),await C()}catch(e){l(null),A(e instanceof Error?e.message:String(e),{tone:`danger`}),await C()}},E=_.data?.branches??e.branches,j=_.data===void 0||E.includes(a),M=j?E:[a,...E],N=g&&_.isPending,P=g?_.isError?`Could not load local branches: ${_.error.message}`:j?null:`${a} is not a local branch. Choose a local branch to pull.`:`No remote configured. Add a Git remote before pulling.`,F=x.isPending||N||!g||_.isError,I=F||!j,L=a!==t.branch;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{"data-slot":`repo-pull`,className:`max-w-full md:w-auto`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`repo-pull-branch`,className:`sr-only`,children:`Branch to pull`}),(0,Q.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,Q.jsx)(b,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,Q.jsx)(`select`,{id:`repo-pull-branch`,value:a,disabled:F,onChange:e=>s(e.target.value),className:`h-11 max-w-full min-w-[88px] appearance-none rounded-lg border border-input bg-card pr-3 pl-9 text-[13px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,style:{width:`${Math.max(88,a.length*8+56)}px`},children:M.map(e=>(0,Q.jsx)(`option`,{value:e,disabled:!j&&e===a,children:e},e))})]}),(0,Q.jsxs)(y,{ref:u,type:`button`,"data-action":`repo-pull`,className:`h-11 px-4`,disabled:I,title:P??void 0,onClick:()=>void w(a),children:[x.isPending?(0,Q.jsx)(H,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,Q.jsx)(re,{"aria-hidden":`true`}),L?`Switch & pull`:`Pull`]})]}),P||L?(0,Q.jsx)(`p`,{"data-slot":`repo-pull-note`,className:`mt-1 break-all text-[11px] text-soft-foreground md:text-left`,children:P??`${a} stays checked out after the pull.`}):null]}),(0,Q.jsx)(ne,{open:c!==null,onOpenChange:e=>{!e&&!x.isPending&&l(null)},children:(0,Q.jsxs)(te,{onCloseAutoFocus:e=>{e.preventDefault(),u.current?.focus()},children:[(0,Q.jsxs)(k,{children:[(0,Q.jsxs)(v,{children:[`Pull `,c?.branch,` anyway?`]}),(0,Q.jsx)(ee,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[c?.risks.includes(`active_runs`)?(0,Q.jsx)(`p`,{children:`An active session is using this repository. Pulling can change files while it works.`}):null,c?.risks.includes(`dirty_tree`)?(0,Q.jsx)(`p`,{children:`The checkout has dirty files. Git may refuse the switch or pull to protect them.`}):null,(0,Q.jsxs)(`p`,{children:[c?.branch,` will stay checked out after this attempt.`]})]})})]}),(0,Q.jsxs)(D,{children:[(0,Q.jsx)(O,{className:`h-11`,disabled:x.isPending,children:`Cancel`}),(0,Q.jsx)(T,{className:`h-11`,disabled:x.isPending||c===null,onClick:e=>{e.preventDefault(),c&&w(c.branch,!0)},children:x.isPending?`Pulling…`:`Pull anyway`})]})]})})]})}function de({tab:e}){let t=c();if(t.isPending)return(0,Q.jsx)(G,{});if(t.isError)return(0,Q.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(C,{icon:(0,Q.jsx)(g,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:t.error.message})});let n=t.data.info;return n?(0,Q.jsx)(fe,{repo:t.data,info:n,tab:e}):(0,Q.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(C,{icon:(0,Q.jsx)(b,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`cezar is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function fe({repo:e,info:t,tab:n}){return(0,Q.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,Q.jsxs)(`header`,{"data-slot":`repo-header`,className:`px-[18px] pt-[18px] md:px-9 md:pt-9`,children:[(0,Q.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight md:text-[30px]`,children:[`Git · `,n===`changes`?`Changes`:n===`commits`?`Commits`:`Branches`]}),(0,Q.jsxs)(`p`,{"data-slot":`repo-remote`,className:`mt-2 break-all text-[13px] text-muted-foreground`,children:[t.root.split(`/`).filter(Boolean).at(-1),t.remote?` · ${t.remote}`:``,` · `,(0,Q.jsx)(`span`,{"data-slot":`branch-chip`,children:t.branch})]}),(0,Q.jsx)(`div`,{className:`my-[22px] flex min-w-0 items-start gap-2.5`,children:(0,Q.jsx)(ue,{repo:e,info:t})}),(0,Q.jsxs)(`div`,{"data-slot":`repo-tabs`,className:`flex items-end gap-6 border-b border-border [&>a]:min-h-11`,children:[(0,Q.jsx)(J,{to:`/git`,active:n===`changes`,children:`Changes`}),(0,Q.jsx)(J,{to:`/git/commits`,active:n===`commits`,children:`Commits`}),(0,Q.jsx)(J,{to:`/git/branches`,active:n===`branches`,children:`Branches`})]})]}),n===`changes`?(0,Q.jsx)(ce,{}):n===`commits`?(0,Q.jsx)($,{log:e.log}):(0,Q.jsx)(ie,{repo:e,info:t})]})}export{de as RepoGitRoute};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Aa as r,Fr as i,Ft as a,J as o,Jt as s,K as c,Kr as l,Lr as u,Mn as d,Mr as f,Nn as p,Pn as m,Pr as h,Q as g,Qn as _,Ri as v,Rn as y,Ta as b,V as x,Vn as ee,Wr as te,X as S,Xr as ne,Y as re,Yr as ie,a as C,ar as w,c as ae,cr as T,d as E,et as oe,fa as se,fn as ce,gt as le,i as ue,in as D,ir as de,it as O,jn as fe,kn as pe,kr as me,n as he,ni as ge,nt as k,o as A,oi as _e,r as j,s as M,sa as N,st as ve,t as P,tn as F,tt as ye,un as be,wn as xe,xi as Se,yi as Ce,zi as we,zr as Te}from"./alert-dialog-BOp2HnnL.js";import{n as I,t as L}from"./utils-GZNjgma4.js";import{a as R,c as Ee,i as z,l as B,n as De,r as V,t as Oe}from"./dropdown-menu-DAmCVaLJ.js";import{n as ke,r as Ae,t as je}from"./collapsible-bb0csfMs.js";import{n as Me,t as Ne}from"./agent-accounts-BxBsIXGa.js";import{t as H}from"./createLucideIcon-BHp8sXmF.js";import{A as Pe,C as Fe,N as Ie,S as U,_ as W,b as Le,c as Re,f as ze,g as Be,i as Ve,m as He,n as Ue,r as We,t as Ge,y as Ke}from"./pill-BoBISMI9.js";import{c as qe,s as Je,t as G,u as Ye}from"./project-router-CvFAMDcP.js";import{t as Xe}from"./square-terminal-B6RYYieR.js";import{t as Ze}from"./markdown-Ir62-VMS.js";import{t as Qe}from"./diff-stat-DpHwISUB.js";import{n as $e,t as et}from"./token-metrics-BLzFUb8F.js";import{t as K}from"./tab-link-CkIV8ixq.js";import{t as tt}from"./use-desktop-BaYgO7YW.js";var nt=H(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),rt=H(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),it=H(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),q=e(t(),1),J=n();function at(e){let t=r();return b({mutationFn:t=>_e(e,t),onSuccess:()=>t.invalidateQueries({queryKey:D.runs.all}),onError:e=>N(e.message,{tone:`danger`})})}function ot(e){return e.archived?`Unarchive`:`Archive task`}function st({run:e,open:t,onOpenChange:n,onConfirm:r}){return(0,J.jsx)(P,{open:t,onOpenChange:n,children:(0,J.jsxs)(ue,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,J.jsxs)(M,{children:[(0,J.jsx)(ae,{children:`Archive task?`}),(0,J.jsxs)(C,{children:[`Move “`,(0,J.jsx)(`span`,{className:`font-medium text-foreground`,title:l(e),children:l(e)}),`” out of Active tasks. You can restore it from Archived.`]})]}),(0,J.jsxs)(A,{children:[(0,J.jsx)(j,{children:`Cancel`}),(0,J.jsx)(he,{className:`bg-accent-strong text-accent-strong-foreground hover:brightness-[0.96]`,onClick:r,children:`Archive task`})]})]})})}function ct({run:e,className:t}){let[n,r]=(0,q.useState)(!1),i=at(e.id),a=ot(e);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(E,{type:`button`,variant:`outline`,"data-slot":`archive-action`,"aria-label":a,title:e.archived?`Put this task back in Active tasks`:`Move this task out of Active tasks`,disabled:i.isPending,className:L(`h-11 gap-[7px] px-3`,t),onClick:()=>e.archived?i.mutate(!1):r(!0),children:[e.archived?(0,J.jsx)(Ie,{"aria-hidden":`true`}):(0,J.jsx)(x,{"aria-hidden":`true`}),a]}),(0,J.jsx)(st,{run:e,open:n,onOpenChange:r,onConfirm:()=>{i.mutate(!0),r(!1)}})]})}function lt(e,t,n,r){return n?r===`step`?`Step ${e} of ${t}`:`${e} of ${t} complete`:`${e} / ${t}`}function ut({slot:e,icon:t,title:n,meta:r,open:i,onToggle:a,children:o}){return(0,J.jsxs)(`div`,{"data-slot":`run-activity-${e}`,"data-state":i?`open`:`collapsed`,className:`min-w-0 border-t border-border first:border-t-0`,children:[(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":i,onClick:a,className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2 text-left hover:bg-muted/40`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center text-accent-text`,children:t}),(0,J.jsx)(`span`,{className:`min-w-0 shrink truncate text-[13.5px] font-semibold text-foreground`,children:n}),(0,J.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`min-w-0 shrink-[2] truncate text-[12.5px] text-muted-foreground tabular-nums`,children:r}),(0,J.jsx)(S,{"aria-hidden":!0,className:L(`ml-auto size-4 shrink-0 text-soft-foreground transition-transform`,i&&`rotate-180`)})]}),i?(0,J.jsx)(`div`,{"data-slot":`run-activity-body`,className:`min-w-0 border-t border-border/60 bg-muted/30 px-3.5 py-2.5`,children:o}):null]})}var dt=`flex min-h-11 min-w-0 items-center rounded-md px-2 text-sm text-foreground hover:bg-muted break-words focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;function ft({run:e}){return!e.delegation||e.delegation.role===`invalid`?null:(0,J.jsx)(mt,{run:e})}function Y(e,t){let n=e?.role===`root`?e.receipts.map(e=>e.workerId):[];return[...new Set([...n,...(t?.workers??[]).map(e=>e.workerId)])].slice(0,32)}function pt(e){let t=e.delegation,n=t!==void 0&&t.role!==`invalid`,r=w(e.id,{enabled:n});if(!n||!t)return`complete`;if(!r.isSuccess)return r.isError||r.fetchStatus===`paused`?`unknown`:`pending`;let i=new Map(r.data.workers.map(e=>[e.workerId,e])),a=Y(t,r.data).map(e=>{let t=i.get(e)?.status;return t===`done`||t===`cancelled`?`complete`:t===void 0||t===`failed`?`issue`:`pending`});return a.includes(`pending`)?`pending`:a.includes(`issue`)?`issue`:`complete`}function mt({run:e}){let t=w(e.id),n=tt(),[r,i]=(0,q.useState)(null),a=n||r===e.id,s=(0,q.useId)(),c=T(),u=e.delegation,d=u?.role===`worker`?u.parentRunId:t.data?.parentRunId,f=new Map(t.data?.workers.map(e=>[e.workerId,e])),p=Y(u,t.data),m=u&&u.role!==`invalid`?u.wait:void 0,h=ie(u);return(0,J.jsxs)(`section`,{"aria-label":`Task relationships`,className:`min-w-0 border-t border-border py-2 text-sm text-muted-foreground`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full items-center gap-2 text-left text-xs md:hidden`,"aria-expanded":a,"aria-controls":s,onClick:()=>i(r===e.id?null:e.id),children:[(0,J.jsx)(le,{"aria-hidden":`true`,className:`size-4 text-accent-text`}),u?.role===`worker`?`Worker session`:`Parent`,(0,J.jsx)(o,{"aria-hidden":`true`,className:`ml-1 size-4`}),u?.role===`worker`?`Parent & workers`:p.length>0?`Workers ${p.length}`:t.isSuccess?`Workers 0`:t.isError?`Workers unavailable`:`Workers…`,(0,J.jsx)(S,{"aria-hidden":`true`,className:`ml-auto size-4 ${a?`rotate-180`:``}`})]}),u?.role===`worker`&&u.destroy?(0,J.jsx)(X,{state:u.destroy}):null,m?(0,J.jsx)(bt,{wait:m,dependencyLabel:h}):null,(0,J.jsxs)(`div`,{id:s,hidden:!a,children:[d?(0,J.jsx)(xt,{id:d}):null,p.length>0?(0,J.jsx)(`ul`,{className:`grid max-h-64 min-w-0 gap-1 overflow-y-auto`,children:p.map(e=>{let n=f.get(e),r=c.data?.find(t=>t.id===e);return(0,J.jsxs)(`li`,{className:`min-w-0 rounded-md bg-muted/40 px-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2`,children:[(0,J.jsx)(G,{to:`/tasks/${e}`,"aria-label":`Worker task ${e}`,className:dt,children:r?l(r):`Worker ${e.slice(0,8)}`}),(0,J.jsx)(`span`,{className:`px-2 text-xs`,children:n?.status??(t.isSuccess?`Record unavailable or deleted`:`Status unavailable`)})]}),n?.destroy?(0,J.jsx)(X,{state:n.destroy}):null]},e)})}):u?.role===`root`&&t.isSuccess?(0,J.jsx)(`p`,{className:`px-2`,children:`No workers`}):null,t.fetchStatus===`paused`?(0,J.jsx)(`p`,{role:`status`,className:`px-2`,children:`Offline — relationship details will refresh when connected.`}):t.isPending?(0,J.jsx)(`p`,{role:`status`,className:`px-2`,children:`Loading relationships…`}):null,t.isError?(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-2`,children:[(0,J.jsx)(`p`,{role:`status`,children:`Could not load relationships. Known task links are retained.`}),(0,J.jsx)(E,{variant:`outline`,className:`min-h-11`,onClick:()=>void t.refetch(),children:`Retry relationships`})]}):null]})]})}function ht({run:e,open:t,onToggle:n}){let r=w(e.id),i=T(),a=tt(),o=e.delegation,s=o?.role===`worker`?o.parentRunId:r.data?.parentRunId,u=new Map(r.data?.workers.map(e=>[e.workerId,e])),d=Y(o,r.data),f=o&&o.role!==`invalid`?o.wait:void 0,p=ie(o);return(0,J.jsx)(ut,{slot:`workers`,icon:(0,J.jsx)(le,{className:`size-4`}),title:`Workers`,meta:gt({ids:d,workers:u,parentId:s,desktop:a,query:r}),open:t,onToggle:n,children:(0,J.jsxs)(`div`,{"aria-label":`Task relationships`,className:`min-w-0 text-[13px] text-muted-foreground`,role:`group`,children:[o?.role===`worker`&&o.destroy?(0,J.jsx)(X,{state:o.destroy}):null,f?(0,J.jsx)(bt,{wait:f,dependencyLabel:p}):null,s?(0,J.jsx)(xt,{id:s}):null,d.length>0?(0,J.jsx)(`ul`,{className:`grid max-h-64 min-w-0 gap-0.5 overflow-y-auto`,children:d.map(e=>{let t=u.get(e),n=i.data?.find(t=>t.id===e),a=t?vt(t.status):r.isSuccess?`Record unavailable or deleted`:`Status unavailable`;return(0,J.jsxs)(`li`,{"data-slot":`worker-item`,"data-status":t?.status,className:`min-w-0`,children:[(0,J.jsxs)(G,{to:`/tasks/${e}`,"aria-label":`Worker task ${e}`,className:`group flex min-h-11 min-w-0 items-center gap-2.5 rounded-md px-1 text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,J.jsx)(_t,{status:t?.status}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n?l(n):`Worker ${e.slice(0,8)}`}),(0,J.jsx)(`span`,{className:L(`max-w-[45%] shrink-0 truncate text-xs`,yt(t?.status)),children:a}),(0,J.jsx)(c,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`})]}),t?.destroy?(0,J.jsx)(X,{state:t.destroy}):null]},e)})}):o?.role===`root`&&r.isSuccess?(0,J.jsx)(`p`,{className:`px-1 py-1`,children:`No workers`}):null,r.fetchStatus===`paused`?(0,J.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Offline — relationship details will refresh when connected.`}):r.isPending?(0,J.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Loading relationships…`}):null,r.isError?(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1`,children:[(0,J.jsx)(`p`,{role:`status`,children:`Could not load relationships. Known task links are retained.`}),(0,J.jsx)(E,{variant:`outline`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry relationships`})]}):null]})})}function gt({ids:e,workers:t,parentId:n,desktop:r,query:i}){if(e.length===0)return i.isError?`Unavailable`:i.isPending?`Linking…`:n?`Parent linked`:`No workers`;let a=`${e.length} linked`;if(!r)return a;let o=new Map;for(let n of e){let e=t.get(n)?.status;e!==void 0&&o.set(e,(o.get(e)??0)+1)}return[a,...[...o.entries()].map(([e,t])=>`${t} ${e}`)].join(` · `)}function _t({status:e}){let t=`size-[15px] shrink-0`;return e===`done`?(0,J.jsx)(g,{"aria-hidden":!0,className:L(t,`text-success`)}):e===`failed`?(0,J.jsx)(k,{"aria-hidden":!0,className:L(t,`text-danger`)}):e===`cancelled`?(0,J.jsx)(ye,{"aria-hidden":!0,className:L(t,`text-soft-foreground`)}):e===`running`||e===`waiting`||e===`review`?(0,J.jsx)(Ye,{role:`status`,"aria-label":`Worker running`,className:L(t,`animate-spin stroke-pending motion-reduce:animate-none`)}):(0,J.jsx)(oe,{"aria-hidden":!0,className:L(t,`text-soft-foreground`)})}function vt(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function yt(e){return e===`done`?`text-success`:e===`failed`?`text-danger`:`text-muted-foreground`}function bt({wait:e,dependencyLabel:t}){return(0,J.jsxs)(`p`,{className:`px-2 break-words`,children:[e.phase===`parked`&&t?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:e.requestIds?e.phase===`parked`?`Waiting on request replies`:e.phase===`wake-pending`?`Conversation update queued for this task`:`Request wait registered — the agent is finishing its turn`:e.phase===`parked`?`Waiting on workers`:e.phase===`wake-pending`?`Worker update queued for the parent`:`Worker wait registered — the agent is finishing its turn`,`.`,` `,`Deadline: `,(0,J.jsx)(`time`,{dateTime:e.deadline,children:e.deadline})]})}function xt({id:e}){let t=_(e);return(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2`,children:[(0,J.jsx)(G,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,className:dt,children:t.data?`Parent · ${l(t.data)}`:`Parent task ${e}`}),t.isError?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`px-2 text-xs`,children:`Parent record unavailable or deleted`}),(0,J.jsx)(E,{variant:`outline`,className:`min-h-11`,onClick:()=>void t.refetch(),children:`Retry parent task`})]}):null]})}function X({state:e}){return e.phase===`complete`&&e.remaining.length===0&&e.error===void 0?null:(0,J.jsxs)(`p`,{className:`px-2 pb-2 break-words`,children:[e.phase===`incomplete`?`Cleanup incomplete`:e.phase===`complete`?`Cleanup complete`:`Cleanup ${e.phase}`,e.remaining.length?` — remaining: ${e.remaining.join(`, `)}`:``,e.error?` — ${e.error}`:``]})}function Z(e){switch(e){case`done`:return`done`;case`running`:case`waiting`:case`review`:return`active`;case`failed`:case`cancelled`:return`failed`;case`pending`:case`skipped`:return`pending`}}function St(e){if(e.length===0)return 0;let t=new Set([`done`,`failed`,`cancelled`,`skipped`]),n=new Set([`running`,`waiting`,`review`]),r=0;for(let i of e)t.has(i.status)?r+=1:n.has(i.status)&&(r+=.5);return r/e.length}function Ct({steps:e}){if(e.length===0)return null;let t=St(e)*100;return(0,J.jsxs)(`div`,{"data-slot":`step-rail`,className:`flex min-w-0 flex-col gap-1`,children:[e.map((t,n)=>(0,J.jsxs)(`div`,{"data-slot":`step-row`,"data-visual":Z(t.status),className:`flex min-h-[22px] min-w-0 items-center gap-2 text-[13px] text-muted-foreground`,children:[(0,J.jsx)(wt,{visual:Z(t.status)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:t.name}),t.iterations>1?(0,J.jsxs)(`span`,{"data-slot":`step-iterations`,className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:[`×`,t.iterations]}):null,(0,J.jsxs)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11.5px] text-soft-foreground tabular-nums`,children:[t.kind,` · step `,n+1,` of `,e.length]})]},t.id)),(0,J.jsx)(`div`,{"data-slot":`step-progress`,className:`mt-1 h-0.5 overflow-hidden rounded-full bg-muted`,children:(0,J.jsx)(`div`,{className:`h-full rounded-full bg-pending`,style:{width:`${t}%`}})})]})}function wt({visual:e}){let t=`size-[13px] shrink-0`;switch(e){case`done`:return(0,J.jsx)(g,{"aria-hidden":!0,className:L(t,`text-success`)});case`active`:return(0,J.jsx)(Ye,{role:`status`,"aria-label":`Step running`,className:L(t,`animate-spin stroke-pending motion-reduce:animate-none`)});case`failed`:return(0,J.jsx)(k,{"aria-hidden":!0,className:L(t,`text-danger`)});case`pending`:return(0,J.jsx)(oe,{"aria-hidden":!0,className:L(t,`text-soft-foreground`)})}}function Tt(e){let t=e.findIndex(e=>Z(e.status)===`active`);if(t>=0)return t;let n=e.findIndex(e=>Z(e.status)===`pending`);return n>=0?n:Math.max(0,e.length-1)}function Et({visual:e}){return(0,J.jsx)(`span`,{"aria-hidden":!0,"data-slot":`step-dot`,"data-visual":e,className:L(`size-1.5 rounded-full`,e===`done`?`bg-success`:e===`failed`?`bg-danger`:e===`active`?`bg-pending`:`bg-soft-foreground`,e===`active`&&`animate-pulse motion-reduce:animate-none`)})}var Dt=new Map;function Ot({runId:e,steps:t}){let[n,r]=(0,q.useState)(()=>Dt.get(e)??!1);if(t.length===0)return null;let i=t=>{Dt.set(e,t),r(t)},a=Tt(t),o=t[a],s=St(t)*100;return(0,J.jsxs)(je,{"data-slot":`workflow-steps`,open:n,onOpenChange:i,className:`min-w-0`,children:[(0,J.jsxs)(Ae,{"aria-label":`Workflow: ${o.name}, step ${a+1} of ${t.length}`,className:`group flex min-h-11 w-full items-center gap-2 text-left text-xs text-muted-foreground hover:text-foreground md:min-h-[30px] md:gap-2.5`,children:[(0,J.jsx)(`span`,{"data-slot":`step-dots`,className:`flex shrink-0 items-center gap-1`,children:t.map(e=>(0,J.jsx)(Et,{visual:Z(e.status)},e.id))}),(0,J.jsx)(`span`,{className:`min-w-0 max-w-[45%] shrink truncate font-semibold text-foreground`,children:o.name}),(0,J.jsxs)(`span`,{className:`shrink-0 text-soft-foreground tabular-nums`,children:[`step `,a+1,` of `,t.length]}),(0,J.jsx)(`span`,{"data-slot":`step-summary-progress`,className:`h-0.5 min-w-[36px] flex-1 overflow-hidden rounded-full bg-muted`,children:(0,J.jsx)(`span`,{className:`block h-full rounded-full bg-pending`,style:{width:`${s}%`}})}),(0,J.jsx)(S,{"aria-hidden":!0,className:`size-4 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-180`})]}),(0,J.jsx)(ke,{children:(0,J.jsx)(`div`,{className:`pt-2`,children:(0,J.jsx)(Ct,{steps:t})})})]})}function kt(e){let t=r();return b({mutationFn:()=>Se(e),onSuccess:()=>t.invalidateQueries({queryKey:D.runs.all}),onError:e=>N(e.message,{tone:`danger`})})}var At=new Map;function jt({run:e,tab:t=`session`,hasPendingHumanAsk:n=!1,onMarkedUnread:r}){let i=ne(e,n),a=W(e),o=t===`session`&&He(e,n),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),d=Mt(e,r),[,f]=(0,q.useReducer)(e=>e+1,0),p=(0,q.useId)(),m=Je(),h=JSON.stringify([m,e.id]),g=At.get(h)??!1,_=()=>{At.set(h,!g),f()},v=T(),y=xe(),b=et(y.data),x=e.status===`queued`?te(v.data??[]).get(e.id):void 0;return(0,J.jsxs)(`header`,{"data-slot":`run-header`,className:L(`relative z-20 bg-background px-[18px] pt-[18px] md:px-9 md:pt-7`,t===`session`&&`md:sticky md:top-0`),children:[(0,J.jsxs)(`div`,{className:`w-full`,children:[(0,J.jsxs)(`div`,{"data-slot":`run-title-row`,className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 md:flex-nowrap`,children:[(0,J.jsx)(`p`,{"data-slot":`session-kind`,className:`text-[10px] font-semibold tracking-[0.14em] text-muted-foreground uppercase md:hidden`,children:e.delegation?.role===`worker`?`Worker session`:e.delegation?.role===`root`?`Parent session`:`Task session`}),(0,J.jsx)(Nt,{run:e}),(0,J.jsxs)(Ge,{dot:i.tone,pulse:i.pulse,children:[i.label,x===void 0?``:` #${x}`]}),(0,J.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 md:gap-2.5`,children:[(0,J.jsx)(E,{variant:`ghost`,size:`icon-sm`,className:`size-11 md:hidden`,"aria-label":g?`Hide run details`:`Show run details`,"aria-controls":p,"aria-expanded":g,onClick:_,children:(0,J.jsx)(S,{"aria-hidden":`true`,className:L(`transition-transform motion-reduce:transition-none`,g&&`rotate-180`)})}),t!==`session`&&a.archive?(0,J.jsx)(ct,{run:e}):null,(0,J.jsx)(Lt,{run:e,actions:d,finishPromoted:o,onOpenChooser:()=>u(!0),onToggleNotes:()=>c(e=>!e)})]})]}),(0,J.jsx)(`div`,{id:p,"data-slot":`run-details`,className:L(g?`block`:`hidden`,`md:block`),children:(0,J.jsx)(Pt,{run:e,showTokens:b.tokens,showCost:b.cost,automationsAvailable:y.data?.capabilities?.automations===!0})}),(0,J.jsx)(Ft,{run:e}),(0,J.jsxs)(`div`,{"data-slot":`run-tabs`,className:`mt-3 flex flex-wrap items-end gap-1 border-b border-border md:mt-5 max-md:[&>a]:min-h-11`,children:[(0,J.jsx)(K,{to:`/tasks/${e.id}`,active:t===`session`,children:`Session`}),(0,J.jsx)(K,{to:`/tasks/${e.id}/changes`,active:t===`changes`,children:`Changes`}),(0,J.jsx)(K,{to:`/tasks/${e.id}/commits`,active:t===`commits`,children:`Commits`}),(0,J.jsx)(K,{to:`/tasks/${e.id}/files`,active:t===`files`,children:`Files`})]}),t===`session`?null:(0,J.jsx)(ft,{run:e}),t!==`session`&&e.steps.length>0?(0,J.jsx)(`div`,{className:`border-t border-border pt-1 pb-0 md:pt-2 md:pb-1`,children:(0,J.jsx)(Ot,{runId:e.id,steps:e.steps})}):null,s?(0,J.jsx)(zt,{runId:e.id,onClose:()=>c(!1)}):null,l?(0,J.jsx)(Q,{run:e,canResume:W(e).terminal,onResume:()=>d.terminal.mutate(),onClose:()=>u(!1)}):null]}),(0,J.jsx)(Rt,{run:e,actions:d})]})}function Q({run:e,canResume:t,onResume:n,onOpen:r,onClose:i}){let a=fe(),o=y(),s=b({mutationFn:t=>v(e.id,t),onError:e=>N(e.message,{tone:`danger`})}),c=se(o.data),l=e=>!o.isSuccess||c.includes(e??`claude`),u=t&&l(ze(e)),d=e.worktreePath?(a.data?.targets??[]).filter(e=>{let t=Ke(e.id);return t===void 0||l(t)}).map(t=>({target:t,...Re(e,t.id)?{suffix:` (resume)`,title:`Resume this run's session`}:{}})):[];if(!u&&d.length===0)return null;let f=()=>{let t=e.worktreePath;t&&navigator.clipboard.writeText(t).then(()=>N(`Worktree path copied`)).catch(()=>N(`Path: ${t}`))};if(r)return(0,J.jsx)(z,{onSelect:r,children:`Open in…`});let p=Be(e);return(0,J.jsxs)(`section`,{"aria-label":`Open task worktree in…`,className:`task-action-panel my-5 rounded-xl border border-border bg-card p-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`h2`,{className:`text-lg font-medium`,children:`Open task worktree in…`}),(0,J.jsx)(E,{variant:`ghost`,size:`icon`,"aria-label":`Close worktree chooser`,onClick:i,children:(0,J.jsx)(F,{})})]}),e.worktreePath?(0,J.jsx)(`p`,{className:`my-4 break-all text-xs text-muted-foreground`,children:e.worktreePath}):null,(0,J.jsxs)(`div`,{className:`task-open-targets mt-4 flex flex-wrap gap-3`,children:[u?(0,J.jsxs)(E,{variant:`outline`,"data-target":`terminal-resume`,onClick:n,children:[(0,J.jsx)(Xe,{}),`Terminal (resume session)`]}):null,d.map(({target:e,suffix:t,title:n})=>{let r=Le(e);return(0,J.jsxs)(E,{variant:`outline`,"data-target":e.id,title:n,disabled:s.isPending,onClick:()=>s.mutate(e.id),children:[(0,J.jsx)(r,{"aria-hidden":`true`}),e.label,t??``]},e.id)}),e.worktreePath?(0,J.jsxs)(E,{variant:`outline`,onClick:f,children:[(0,J.jsx)(O,{}),`Copy worktree path`]}):null]}),p?(0,J.jsxs)(`div`,{className:`mt-5 border-t border-border pt-5`,children:[(0,J.jsx)(`h3`,{className:`text-base font-medium`,children:`Resume in a terminal`}),(0,J.jsx)(`pre`,{className:`my-4 whitespace-pre-wrap break-all rounded-lg border border-border bg-background p-4 text-xs`,children:p}),(0,J.jsxs)(E,{variant:`outline`,onClick:()=>void $(p,`Command copied to clipboard.`),children:[(0,J.jsx)(O,{}),`Copy resume command`]})]}):null]})}function Mt(e,t){let n=r(),i=qe(),[a,o]=(0,q.useState)(null),s=()=>n.invalidateQueries({queryKey:D.runs.all}),c=e=>N(e.message,{tone:`danger`}),l=kt(e.id),u=p(),d={isPending:u.isPending,mutate:()=>u.mutate({id:e.id,pinned:!e.pinned})},f=pe();return{finish:l,pin:d,markUnread:{isPending:f.isPending,mutate:()=>{t?.(),f.mutate(e.id,{onError:c})}},delete:b({mutationFn:()=>Ce(e.id),onSuccess:()=>{s(),i(`/`)},onError:c}),terminal:b({mutationFn:()=>we(e.id),onError:e=>{if(e instanceof ge&&e.command){$(e.command,`No terminal found — command copied to clipboard.`);return}c(e)}}),confirming:a,setConfirming:o}}async function $(e,t){try{await navigator.clipboard.writeText(e),N(t)}catch{N(`Run manually: ${e}`)}}function Nt({run:e}){let t=d(e.id),n=l(e),r=We(n,e=>t.mutate({title:e},{onError:e=>N(e.message,{tone:`danger`})}));return r.editing?(0,J.jsx)(Ue,{editor:r,className:`flex-1 text-[15px] font-semibold`}):(0,J.jsxs)(`span`,{className:`group flex min-w-0 items-center gap-1`,children:[(0,J.jsx)(`h1`,{className:`line-clamp-2 min-w-0 break-words text-2xl font-semibold tracking-tight`,title:e.task,children:n}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,onClick:r.begin,className:`shrink-0 rounded-sm p-1 text-soft-foreground opacity-0 transition-opacity group-hover:opacity-100 hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,J.jsx)(Pe,{className:`size-3.5`,"aria-hidden":`true`})})]})}function Pt({run:e,showTokens:t,showCost:n,automationsAvailable:r}){let a=m(),o=ee(),s=(0,q.useMemo)(()=>u(e,a),[e,a]),c=(0,q.useMemo)(()=>o===void 0?[]:s.map(e=>({projectId:o,kind:e.kind,number:e.number})),[s,o]),d=[(0,J.jsx)(`span`,{className:`max-md:max-w-full max-md:break-all`,children:Te(e)},`workflow`)];e.branch&&d.push((0,J.jsx)(`span`,{"data-slot":`branch-chip`,className:`rounded-sm border border-border bg-card px-1.5 py-px font-mono text-[11px] font-medium max-md:max-w-full max-md:break-all`,children:e.branch},`branch`));let p=s.filter(e=>e.kind===`PR`);for(let t of p)d.push((0,J.jsx)(U,{reference:t,taskTitle:l(e),className:`h-5`,conflictAction:(0,J.jsx)(Ve,{run:e,prNumber:t.number})},`pr-${t.number}`));let g=i(e);g&&I(g)&&!p.some(e=>e.url===g)&&d.push((0,J.jsx)(U,{reference:{kind:`PR`,url:g},taskTitle:l(e),className:`h-5`},`pr`));let _=h(e,a);if(_&&I(_)){let t=f(_);d.push((0,J.jsx)(U,{reference:{kind:`Issue`,...t?{number:Number(t)}:{},url:_},taskTitle:l(e),className:`h-5`},`issue`))}e.diffStat&&d.push((0,J.jsx)(Qe,{stat:e.diffStat},`diff`)),e.automation&&d.push(r?(0,J.jsx)(G,{to:`/automations/${encodeURIComponent(e.automation.automationId)}/log`,className:`rounded-sm border border-border bg-card px-1.5 py-px text-[11px] font-medium hover:text-foreground`,children:`Automation`},`automation`):(0,J.jsx)(`span`,{"data-slot":`automation-origin`,title:`Automations are off on this server (CEZ_AUTOMATIONS)`,className:`rounded-sm border border-border bg-card px-1.5 py-px text-[11px] font-medium`,children:`Automation`},`automation`));let v=[];return t&&(e.inputTokens!==void 0||e.outputTokens!==void 0)&&v.push((0,J.jsx)($e,{inputTokens:e.inputTokens,outputTokens:e.outputTokens},`tokens`)),n&&e.costUsd&&v.push((0,J.jsx)(`span`,{className:`tabular-nums`,children:me(e.costUsd)},`cost`)),(0,J.jsx)(Fe,{projectId:o,requests:c,children:(0,J.jsxs)(`div`,{"data-slot":`run-meta`,className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground md:mt-1.5 md:gap-y-1`,children:[d.map((e,t)=>(0,J.jsxs)(q.Fragment,{children:[t>0?(0,J.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:`·`}):null,e]},t)),(0,J.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5 max-md:min-w-0 max-md:max-w-full`,children:[v.map((e,t)=>(0,J.jsxs)(q.Fragment,{children:[t>0?(0,J.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:`·`}):null,e]},t)),(0,J.jsx)(It,{run:e})]})]})})}function Ft({run:e}){if(e.status!==`running`||e.activity!==`monitoring`)return null;if(e.monitoringWakeCapReached)return(0,J.jsx)(`p`,{"data-slot":`monitoring-schedule`,role:`status`,className:`mt-1 text-xs text-muted-foreground`,children:`Automatic checks paused — 40/40 reached`});let t=e.monitoringWakeAt?new Date(e.monitoringWakeAt):null,n=t&&Number.isFinite(t.getTime())?t:null;if(!n)return(0,J.jsx)(`p`,{"data-slot":`monitoring-schedule`,role:`status`,className:`mt-1 text-xs text-muted-foreground`,children:`Parked — no automatic check scheduled`});let r=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(n);return(0,J.jsxs)(`p`,{"data-slot":`monitoring-schedule`,role:`status`,className:`mt-1 text-xs text-muted-foreground`,children:[`Next automatic check`,` `,(0,J.jsx)(`time`,{dateTime:e.monitoringWakeAt,className:`font-medium text-foreground`,children:r})]})}function It({run:e}){let t=ce(),n=be(),{accounts:r}=Me(),i=e.runner??t.data?.defaultRunner??`claude`,a=e.model??`auto`,s=e.effort||void 0,c=[...e.steps].reverse().find(e=>e.profileId),l=c?.profileId,u=c?.backend??i,d=n.data?.profiles.find(e=>e.id===l),f=l===void 0||n.isPending?void 0:n.isError?l:d?Ne(r,u)?l==="default"?`default`:d.label:void 0:`${l} (removed)`,p=e.modelIdentity&&e.modelIdentity!==a?e.modelIdentity:void 0,m=[i,f,a,s].filter(Boolean).join(` · `);return(0,J.jsxs)(Oe,{children:[(0,J.jsx)(B,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,"data-slot":`agent-badge`,title:m,"aria-label":`Agent: ${i}, ${f?`account ${f}, `:``}model ${a}${s?`, effort ${s}`:``}`,className:`flex min-w-0 shrink items-center max-md:min-h-11 gap-1.5 rounded-sm px-1 py-1 text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,J.jsx)(o,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{"data-slot":`agent-badge-summary`,className:`truncate font-mono text-[11px]`,children:m})]})}),(0,J.jsxs)(V,{align:`end`,className:`min-w-[9rem] max-md:max-w-[calc(100vw-2rem)] max-md:break-all`,children:[(0,J.jsxs)(R,{className:`font-mono text-[11px] font-normal text-muted-foreground`,children:[`runner: `,i]}),f?(0,J.jsxs)(R,{"data-slot":`agent-badge-account`,className:`font-mono text-[11px] font-normal text-muted-foreground`,children:[`account: `,f]}):null,(0,J.jsxs)(R,{className:`font-mono text-[11px] font-normal text-muted-foreground`,children:[`model: `,a]}),s?(0,J.jsxs)(R,{"data-slot":`agent-badge-effort`,className:`font-mono text-[11px] font-normal text-muted-foreground`,children:[`effort: `,s]}):null,p?(0,J.jsxs)(R,{"data-slot":`agent-badge-identity`,className:`font-mono text-[11px] font-normal text-muted-foreground`,children:[`identity: `,p]}):null]})]})}function Lt({run:e,actions:t,finishPromoted:n,onToggleNotes:r,onOpenChooser:i}){let o=W(e),c=Be(e);return(0,J.jsxs)(Oe,{children:[(0,J.jsx)(B,{asChild:!0,children:(0,J.jsx)(E,{variant:`ghost`,size:`icon-sm`,className:`size-11`,"aria-label":`Run actions`,children:(0,J.jsx)(ve,{"aria-hidden":`true`})})}),(0,J.jsxs)(V,{align:`end`,"data-slot":`run-actions-menu`,className:`w-[270px] max-w-[calc(100vw-2rem)] p-3`,children:[(0,J.jsx)(R,{className:`px-2 py-3 text-[10px] font-normal text-muted-foreground`,children:`TASK ACTIONS`}),(0,J.jsxs)(z,{onSelect:r,children:[(0,J.jsx)(nt,{"aria-hidden":`true`}),` Notes / handoff`]}),(0,J.jsx)(Q,{run:e,canResume:o.terminal,onResume:()=>t.terminal.mutate(),onOpen:i}),c?(0,J.jsxs)(z,{onSelect:()=>void $(c,`Command copied to clipboard.`),children:[(0,J.jsx)(O,{"aria-hidden":`true`}),` Copy resume command`]}):null,o.finish&&!n?(0,J.jsxs)(z,{disabled:t.finish.isPending,onSelect:()=>t.setConfirming(`finish`),children:[(0,J.jsx)(re,{"aria-hidden":`true`}),` Finish`]}):null,o.markUnread?(0,J.jsxs)(z,{disabled:t.markUnread.isPending,onSelect:()=>t.markUnread.mutate(),children:[(0,J.jsx)(rt,{"aria-hidden":`true`}),` Mark unread`]}):null,o.pin?(0,J.jsxs)(De,{"data-slot":`pin-run`,className:`min-h-11`,checked:!!e.pinned,disabled:t.pin.isPending,onCheckedChange:()=>t.pin.mutate(),children:[e.pinned?(0,J.jsx)(it,{"aria-hidden":`true`}):(0,J.jsx)(a,{"aria-hidden":`true`}),e.pinned?`Unpin task`:`Pin task`]}):null,o.deleteRun?(0,J.jsx)(Ee,{}):null,o.deleteRun?(0,J.jsxs)(z,{variant:`destructive`,onSelect:()=>t.setConfirming(`delete`),children:[(0,J.jsx)(s,{"aria-hidden":`true`}),` Delete task…`]}):null]})]})}function Rt({run:e,actions:t}){let n=t.confirming,r=(0,q.useRef)(n);n!==null&&(r.current=n);let i=n??r.current,a=i===`finish`?`Finish task?`:`Delete task permanently?`,o=i===`finish`?`Review and finish`:`Delete task`;return(0,J.jsx)(P,{open:n!==null,onOpenChange:e=>!e&&t.setConfirming(null),children:(0,J.jsxs)(ue,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,J.jsxs)(M,{children:[(0,J.jsx)(ae,{className:i===`delete`?`text-danger`:void 0,children:a}),(0,J.jsx)(C,{children:(0,J.jsxs)(J.Fragment,{children:[i===`finish`?`Finish “`:`Delete “`,(0,J.jsx)(`span`,{className:`font-medium text-foreground`,title:l(e),children:l(e)}),i===`finish`?`”. Continue through the existing change-review gate before finalizing.`:`” and its transcript, worktree and branch. This cannot be undone.`]})})]}),(0,J.jsxs)(A,{children:[(0,J.jsx)(j,{children:`Cancel`}),(0,J.jsx)(he,{className:i===`delete`?`bg-danger text-danger-foreground hover:brightness-[0.96]`:`bg-accent-strong text-accent-strong-foreground hover:brightness-[0.96]`,onClick:()=>{i===`finish`?t.finish.mutate():t.delete.mutate(),t.setConfirming(null)},children:o})]})]})})}function zt({runId:e,onClose:t}){let n=de(e);return(0,J.jsxs)(`div`,{"data-slot":`notes-panel`,className:`my-5 rounded-xl border border-border bg-card p-6`,children:[(0,J.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,J.jsx)(`h2`,{className:`text-lg font-medium`,children:`Notes / handoff`}),(0,J.jsx)(E,{variant:`ghost`,size:`icon`,"aria-label":`Close notes`,onClick:t,children:(0,J.jsx)(F,{})})]}),n.isPending?(0,J.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`Loading notes…`}):n.isError?(0,J.jsx)(`p`,{className:`text-xs text-danger`,children:n.error.message}):n.data.trim().length>0?(0,J.jsx)(Ze,{children:n.data}):(0,J.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`No notes yet — the handoff file is seeded when the task starts.`}),(0,J.jsxs)(`div`,{className:`mt-4 flex gap-3`,children:[(0,J.jsx)(E,{variant:`outline`,disabled:!n.data?.trim(),onClick:()=>void $(n.data??``,`Notes copied`),children:`Copy notes`}),(0,J.jsx)(E,{variant:`outline`,onClick:t,children:`Close`})]})]})}export{Z as a,ut as c,nt as d,Tt as i,lt as l,kt as n,ht as o,Ct as r,pt as s,jt as t,ct as u};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Aa as r,En as i,Gt as a,It as o,Ln as s,Lt as c,Q as l,Rt as u,Sr as d,Ta as f,U as p,Ut as m,Wt as h,Yi as g,Yt as _,Zi as v,br as y,d as b,fr as x,gi as S,in as C,jt as w,l as T,nn as E,ot as D,pr as O,ri as k,sa as A,ti as j,ui as M,vr as N,wa as P}from"./alert-dialog-BOp2HnnL.js";import{t as F}from"./utils-GZNjgma4.js";import{a as ee,i as te,n as ne,o as re,r as ie,s as ae}from"./textarea-DfvlPIgO.js";import{T as oe}from"./prompt-templates-BGGpAIzb.js";import{c as I,t as L}from"./project-router-CvFAMDcP.js";import{i as R,l as z,n as B,o as V,p as H}from"./skills-DFBiAuJG.js";import{c as U,h as W,o as G,t as K}from"./index-C4iEPAUV.js";import{t as se}from"./skill-empty-hint-oOtzR3v0.js";var q=e(t(),1),J=n(),ce=`https://github.com/open-mercato/skills`;function le(e){let t=e?.importedSkills;if(Array.isArray(t))return t.filter(e=>typeof e==`string`&&!!e)}function Y(e,t){return le(e)??[...t]}function X({projectId:e}){let t=r(),n=y(),s=i(),[c,l]=(0,q.useState)(``),f=O(e,!!e),p=s.data??[],m=(0,q.useMemo)(()=>p.map(e=>e.name),[p]),v=(0,q.useRef)([]);v.current=m;let b=(0,q.useMemo)(()=>new Set(Y(n.data,m)),[n.data,m]),x=(0,q.useRef)(Promise.resolve()),S=(0,q.useRef)(0),E=(0,q.useCallback)(e=>{let n=d.uiState,r=t.getQueryData(n),i=e(Y(r,v.current));t.setQueryData(n,{...r,importedSkills:i});let a=++S.current;x.current=x.current.then(async()=>{try{let e=await g({importedSkills:i});a===S.current&&(t.setQueryData(n,e),t.invalidateQueries({queryKey:C.skills}))}catch(e){A(e instanceof Error?e.message:String(e),{tone:`danger`}),a===S.current&&t.invalidateQueries({queryKey:n})}})},[t]),D=(0,q.useCallback)(e=>{E(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[E]),k=m.length>0&&m.every(e=>b.has(e)),j=(0,q.useCallback)(()=>{if(k){let e=new Set(v.current);E(t=>t.filter(t=>!e.has(t)))}else E(e=>[...new Set([...e,...v.current])])},[k,E]);if(s.isError)return(0,J.jsx)(T,{icon:(0,J.jsx)(_,{}),tone:`danger`,heading:`h2`,title:`Could not load importable skills`,subtitle:s.error.message});let M=z(p,c);return(0,J.jsxs)(`div`,{"data-slot":`skills-import-panel`,className:`w-full min-w-0 [&_button]:min-h-11`,children:[(0,J.jsx)(`p`,{className:`mb-4 text-[10px] font-medium tracking-wide text-link-foreground`,children:`OPEN-MERCATO / SKILLS`}),(0,J.jsx)(`h2`,{className:`text-2xl font-medium`,children:`Manage skills`}),(0,J.jsxs)(`p`,{className:`mt-2 text-[13px] leading-relaxed text-muted-foreground`,children:[`Choose which `,(0,J.jsx)(`a`,{href:ce,target:`_blank`,rel:`noreferrer`,children:`open-mercato`}),` skills appear in your catalog and composer picker. All are enabled by default; uncheck any you don’t want.`]}),(0,J.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Applies across projects · saved automatically`}),(0,J.jsx)(ue,{projectId:e,state:f.data,loadError:f.error}),(0,J.jsx)(`p`,{className:`mt-4 text-xs text-soft-foreground`,children:`Checkboxes control visibility. Updating refreshes installed skill files; it does not change your selection.`}),(0,J.jsxs)(`div`,{className:`sw-import-controls mt-4 flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`sw-search relative min-w-0 flex-1`,children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,J.jsx)(W,{"data-slot":`import-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:c,onChange:e=>l(e.target.value),className:`h-11 min-w-0 pl-9 text-xs`})]}),(0,J.jsxs)(`button`,{type:`button`,"data-slot":`import-all`,disabled:m.length===0||n.isPending,onClick:j,className:`h-11 shrink-0 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[k?(0,J.jsx)(w,{"aria-hidden":`true`,className:`size-4`}):(0,J.jsx)(o,{"aria-hidden":`true`,className:`size-4`}),k?`Remove all`:`Enable all`]})]}),(0,J.jsx)(`div`,{"data-slot":`import-list`,className:`mt-3 flex flex-col gap-1.5`,children:s.isPending?(0,J.jsx)(`p`,{className:`px-1 py-2 text-[13px] text-soft-foreground`,children:`Loading…`}):M.length>0?M.map(e=>{let t=b.has(e.name);return(0,J.jsxs)(`label`,{"data-slot":`import-row`,"data-skill":e.name,"data-imported":t?`true`:void 0,className:F(`flex min-h-16 cursor-pointer items-start gap-3 rounded-lg border border-border p-4 transition-colors hover:bg-muted`,t&&`bg-background`),children:[(0,J.jsxs)(`span`,{className:`relative size-5 shrink-0`,children:[(0,J.jsx)(`input`,{type:`checkbox`,"data-slot":`import-toggle`,checked:t,onChange:()=>D(e.name),className:`peer absolute inset-0 m-0 size-5 opacity-0`}),t?(0,J.jsx)(h,{"aria-hidden":`true`,className:`pointer-events-none size-5 text-link-foreground peer-focus-visible:outline-2 peer-focus-visible:outline-ring`}):(0,J.jsx)(a,{"aria-hidden":`true`,className:`pointer-events-none size-5 text-link-foreground peer-focus-visible:outline-2 peer-focus-visible:outline-ring`})]}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,J.jsx)(`span`,{className:`min-w-0 break-words text-[13px] font-medium text-foreground`,children:e.name})}),e.description?(0,J.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-soft-foreground`,children:e.description}):null]})]},e.name)}):(0,J.jsx)(`p`,{className:`px-1 py-2 text-xs text-soft-foreground`,children:p.length>0?`(no skills match)`:`(no skills available — the repo may still be cloning)`})})]})}function Z(e){return e===`project`?`Project installation`:`Global installation`}function ue({projectId:e,state:t,loadError:n}){let i=r(),a=I(),o=(0,q.useRef)(0),[s,u]=(0,q.useState)(!1),p=f({mutationFn:()=>S({task:`Apply the upgrade notes after updating the installed Open Mercato skills.`,steps:[{id:`apply-upgrade-notes`,name:`Apply upgrade notes`,skill:`om-apply-upgrade-notes`,prompt:`{{task}}`}]}),onSuccess:e=>{u(!1),a(oe(e))},onError:e=>A(e.message,{tone:`danger`})}),m=(t,n)=>{n.seq===o.current&&(i.setQueryData(d.skillsUpdate(e),t),n.action===`apply`&&t.updatedAt&&t.updatedAt!==n.previousUpdatedAt&&(i.invalidateQueries({queryKey:C.skills}),A(t.status===`error`?`Some skill updates failed.`:`Open Mercato skills updated.`),u(!0)))},h=(e,t)=>{t.seq===o.current&&A(e.message,{tone:`danger`})},g=f({mutationFn:t=>M(e).then(e=>({result:e,request:t})),onSuccess:({result:e,request:t})=>m(e,t),onError:(e,t)=>h(e,t)}),_=f({mutationFn:t=>k(e).then(e=>({result:e,request:t})),onSuccess:({result:e,request:t})=>m(e,t),onError:(e,t)=>h(e,t)}),v=e=>{let n=++o.current;e===`apply`?_.mutate({action:e,seq:n,previousUpdatedAt:t?.updatedAt??null}):g.mutate({action:e,seq:n})},y=t?.scopes.some(e=>e.skills.length>0)??!1,x=t?.status===`error`,w=y&&(t?.available||x),T=_.isPending||t?.status===`updating`,E=t?.scopes.filter(e=>e.status===`error`||e.status===`unavailable`)??[],D=t?.scopes.filter(e=>e.updatedAt&&!E.includes(e))??[],O=`Checking installed Open Mercato skills…`;return n?O=`Update status is unavailable right now.`:t?.status===`available`?O=`An update is available for your installed Open Mercato skills.`:t?.status===`updating`?O=`Updating installed Open Mercato skills…`:t?.status===`current`?O=`Installed Open Mercato skills are up to date.`:t?.status===`unavailable`?O=t.scopes.find(e=>e.reason)?.reason??`Automatic updates are unavailable.`:t?.status===`error`&&(O=`The update did not finish for every installation.`),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`section`,{"data-slot":`skills-update-card`,"aria-live":`polite`,className:`mt-4 rounded-lg border border-border bg-background p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:O}),(0,J.jsx)(`p`,{className:`mt-4 text-xs text-soft-foreground`,children:`Project and global installations are checked separately.`}),t?.checkedAt?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:[`Last checked `,new Date(t.checkedAt).toLocaleString(),`.`]}):null,t?.scopes.some(e=>e.skills.length>0)?(0,J.jsx)(`ul`,{className:`mt-1 text-xs text-soft-foreground`,children:t.scopes.filter(e=>e.skills.length>0).map(e=>(0,J.jsxs)(`li`,{children:[Z(e.scope),` · `,e.skills.length,` tracked`]},e.scope))}):null,E.length>0?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-destructive`,children:[`Failed: `,E.map(e=>Z(e.scope)).join(`, `),D.length?`; updated: ${D.map(e=>Z(e.scope)).join(`, `)}`:``,`.`]}):null]}),w?(0,J.jsxs)(b,{"data-action":`skills-update-apply`,size:`sm`,disabled:T,onClick:()=>v(`apply`),children:[(0,J.jsx)(c,{"aria-hidden":`true`,className:F(`size-3.5`,T&&`motion-safe:animate-spin`)}),T?`Updating…`:x?`Retry`:`Update now`]}):t?.status===`current`?(0,J.jsxs)(b,{"data-action":`skills-update-check`,variant:`outline`,size:`sm`,disabled:g.isPending,onClick:()=>v(`check`),children:[(0,J.jsx)(c,{"aria-hidden":`true`,className:`size-4`}),`Check again`]}):t?.status===`unavailable`||n?(0,J.jsx)(b,{"data-action":`skills-update-check`,variant:`outline`,size:`sm`,disabled:g.isPending,onClick:()=>v(`check`),children:`Retry check`}):null]}),t?.status===`unavailable`||n?(0,J.jsxs)(`div`,{className:`mt-2 text-xs text-soft-foreground`,children:[`Manual examples: `,(0,J.jsx)(`code`,{children:`npx skills update -p`}),` · `,(0,J.jsx)(`code`,{children:`npx skills update -g`}),`. These broad commands may update other tracked sources.`]}):null,t?.needsUpgradeNotes?(0,J.jsxs)(`div`,{"data-slot":`skills-upgrade-notes`,className:`mt-3 flex gap-2 rounded-md border border-accent-strong/30 bg-background p-2.5 text-xs text-foreground`,children:[(0,J.jsx)(l,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-link-foreground`}),(0,J.jsxs)(`span`,{children:[`Skill files were updated. Run `,(0,J.jsx)(`code`,{children:`/om-apply-upgrade-notes`}),` in each configured repository to apply descriptor migrations while preserving local edits.`]})]}):null]}),(0,J.jsx)(ne,{open:s,onOpenChange:e=>p.isPending?void 0:u(e),children:(0,J.jsxs)(ie,{"data-slot":`skills-upgrade-notes-dialog`,showCloseButton:!1,children:[(0,J.jsxs)(re,{children:[(0,J.jsx)(ae,{children:`Apply the upgrade notes now?`}),(0,J.jsxs)(te,{children:[`The skill files were updated successfully. Start a new session with`,` `,(0,J.jsx)(`code`,{children:`/om-apply-upgrade-notes`}),` to sync repository descriptors while preserving local edits?`]})]}),(0,J.jsxs)(ee,{children:[(0,J.jsx)(b,{type:`button`,variant:`outline`,disabled:p.isPending,onClick:()=>u(!1),children:`No`}),(0,J.jsx)(b,{type:`button`,disabled:p.isPending,onClick:()=>p.mutate(),children:p.isPending?`Starting…`:`Yes, start session`})]})]})})]})}var Q=`__bm`,$=`__import`;function de(){return(0,J.jsx)(`div`,{"data-route":`skills`,className:`mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:(0,J.jsx)(fe,{})})}function fe(){let e=x(),t=N(),n=i(),[a]=P(),[o,l]=(0,q.useState)(``),d=r(),h=s(),g=j().projectId??h.data?.bootProject??``,y=f({mutationFn:()=>v(),onSuccess:e=>{d.setQueryData(C.skills,e),A(`Team skills refreshed.`)},onError:e=>A(e.message,{tone:`danger`})});if(e.isError)return(0,J.jsx)(T,{icon:(0,J.jsx)(_,{}),tone:`danger`,heading:`h2`,title:`Could not load skills`,subtitle:e.error.message});let b=V(e.data??[]),S=(n.data?.length??0)>0,w=a.get(`skill`),O=w===Q||w===$||w!==null&&b.some(e=>e.name===w)?w:b[0]?.name??(S?$:Q),k=b.find(e=>e.name===O)??null,M=B(b,o);return(0,J.jsxs)(`div`,{"data-slot":`skills-section`,className:`@container flex min-w-0 flex-col gap-[22px]`,children:[(0,J.jsxs)(`header`,{className:`flex flex-col gap-4 @min-[700px]:flex-row @min-[700px]:items-center @min-[700px]:justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{className:`text-[25px] font-semibold md:text-[30px]`,children:`Skills`}),(0,J.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground md:text-[13px]`,children:`Markdown playbooks your agents can follow.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[S?(0,J.jsxs)(L,{to:`/skills?skill=${$}`,"data-slot":`import-skills-row`,"aria-current":O===$?`page`:void 0,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium aria-[current=page]:bg-accent-strong/10 hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,J.jsx)(D,{"aria-hidden":`true`,className:`size-4 text-link-foreground`}),`Manage skills`]}):null,(0,J.jsxs)(L,{to:`/skills?skill=${Q}`,"data-slot":`bookmarklets-row`,"aria-current":O===Q?`page`:void 0,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium aria-[current=page]:bg-accent-strong/10 hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,J.jsx)(E,{"aria-hidden":`true`,className:`size-4 text-link-foreground`}),`Run from GitHub`]})]})]}),(0,J.jsxs)(`div`,{className:F(`flex-col items-start gap-2 sm:flex-row sm:items-center md:flex`,w===null?`flex`:`hidden`),children:[(0,J.jsxs)(`div`,{className:`sw-search relative w-full min-w-0 flex-1`,children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,J.jsx)(W,{"data-slot":`skills-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:o,onChange:e=>l(e.target.value),className:`h-11 min-w-0 bg-card pl-9 text-xs`})]}),(0,J.jsxs)(`button`,{type:`button`,"data-slot":`skills-refresh`,title:`git fetch the team skills repos`,disabled:y.isPending,onClick:()=>y.mutate(),className:`flex h-11 shrink-0 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[(0,J.jsx)(c,{"aria-hidden":`true`,className:F(`size-3`,y.isPending&&`motion-safe:animate-spin`)}),`Refresh`]})]}),(0,J.jsxs)(`div`,{className:`grid min-w-0 items-start gap-[22px] md:grid-cols-[minmax(220px,310px)_minmax(0,1fr)]`,children:[(0,J.jsx)(`section`,{"data-slot":`skills-list`,className:F(`min-w-0 flex-col rounded-xl border border-border bg-card p-3 md:flex`,w===null?`flex`:`hidden`),children:(0,J.jsx)(`ul`,{"data-slot":`skill-rows`,className:`flex min-h-0 flex-col gap-1 overflow-y-auto md:max-h-[calc(100dvh-280px)]`,children:e.isPending?(0,J.jsx)(`li`,{role:`status`,"aria-busy":`true`,className:`min-h-72 p-3 text-[13px] text-soft-foreground`,children:`Loading skills…`}):M.length>0?M.map(e=>(0,J.jsx)(pe,{skill:e,active:O===e.name,highlighted:O===$&&e===b[0]},e.path)):(0,J.jsx)(`li`,{className:`px-2.5 py-2 text-xs leading-relaxed text-soft-foreground`,children:b.length>0?`(no skills match)`:(0,J.jsx)(se,{})})})}),(0,J.jsx)(`section`,{"data-slot":`skills-detail`,className:F(`min-w-0 flex-col rounded-xl border border-border bg-card md:flex`,w===null?`hidden`:`flex`),children:(0,J.jsxs)(`div`,{className:`min-w-0 p-5`,children:[(0,J.jsxs)(L,{to:`/skills`,"data-slot":`skills-back`,className:`mb-4 inline-flex min-h-11 items-center gap-2 rounded-lg border border-border px-3 text-xs font-medium hover:bg-muted md:hidden`,children:[(0,J.jsx)(p,{"aria-hidden":`true`,className:`size-3.5`}),`Back to skills`]}),O===$?(0,J.jsx)(X,{projectId:g}):O===Q?(0,J.jsx)(K,{skills:b}):k?(0,J.jsx)(G,{skill:k,usedBy:H(t.data?.workflows??[],k.name)}):e.isPending?(0,J.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`min-h-72 text-xs text-muted-foreground`,children:`Loading skill…`}):(0,J.jsx)(T,{icon:(0,J.jsx)(m,{}),tone:`neutral`,heading:`h2`,title:`No skill selected`,subtitle:`Pick a skill from the catalog.`})]})})]})]})}function pe({skill:e,active:t,highlighted:n}){let r=R(e);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(L,{to:`/skills?skill=${encodeURIComponent(e.name)}`,"data-slot":`skill-row`,"data-skill":e.name,"data-highlighted":n||void 0,"data-project":r?`true`:void 0,"aria-current":t?`page`:void 0,className:F(`selection-row flex min-h-24 flex-col gap-2 rounded-lg border-b border-border p-3 transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,(t||n)&&`border-transparent bg-accent-strong/10`),children:[(0,J.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,J.jsx)(`span`,{className:F(`min-w-0 break-words text-[13px]`,r?`font-semibold text-foreground`:`font-normal text-muted-foreground`),children:e.name})}),e.description?(0,J.jsx)(`span`,{className:`line-clamp-2 text-xs leading-relaxed text-supporting-foreground`,children:e.description}):null,(0,J.jsx)(U,{source:e.source,className:`self-start border-0 bg-transparent p-0 text-link-foreground`})]})})}export{de as SkillsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Aa as r,En as i,Gt as a,It as o,Ln as s,Lt as c,Q as l,Rt as u,Sr as d,Ta as f,U as p,Ut as m,Wt as h,Yi as g,Yt as _,Zi as v,br as y,d as b,fr as x,gi as S,in as C,jt as w,l as T,nn as E,ot as D,pr as O,ri as k,sa as A,ti as j,ui as M,vr as N,wa as P}from"./alert-dialog-BOp2HnnL.js";import{t as F}from"./utils-GZNjgma4.js";import{a as ee,i as te,n as ne,o as re,r as ie,s as ae}from"./textarea-DfvlPIgO.js";import{T as oe}from"./prompt-templates-BGGpAIzb.js";import{c as I,t as L}from"./project-router-CvFAMDcP.js";import{i as R,l as z,n as B,o as V,p as H}from"./skills-DFBiAuJG.js";import{c as U,h as W,o as G,t as K}from"./index-DTsigc4h.js";import{t as se}from"./skill-empty-hint-oOtzR3v0.js";var q=e(t(),1),J=n(),ce=`https://github.com/open-mercato/skills`;function le(e){let t=e?.importedSkills;if(Array.isArray(t))return t.filter(e=>typeof e==`string`&&!!e)}function Y(e,t){return le(e)??[...t]}function X({projectId:e}){let t=r(),n=y(),s=i(),[c,l]=(0,q.useState)(``),f=O(e,!!e),p=s.data??[],m=(0,q.useMemo)(()=>p.map(e=>e.name),[p]),v=(0,q.useRef)([]);v.current=m;let b=(0,q.useMemo)(()=>new Set(Y(n.data,m)),[n.data,m]),x=(0,q.useRef)(Promise.resolve()),S=(0,q.useRef)(0),E=(0,q.useCallback)(e=>{let n=d.uiState,r=t.getQueryData(n),i=e(Y(r,v.current));t.setQueryData(n,{...r,importedSkills:i});let a=++S.current;x.current=x.current.then(async()=>{try{let e=await g({importedSkills:i});a===S.current&&(t.setQueryData(n,e),t.invalidateQueries({queryKey:C.skills}))}catch(e){A(e instanceof Error?e.message:String(e),{tone:`danger`}),a===S.current&&t.invalidateQueries({queryKey:n})}})},[t]),D=(0,q.useCallback)(e=>{E(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[E]),k=m.length>0&&m.every(e=>b.has(e)),j=(0,q.useCallback)(()=>{if(k){let e=new Set(v.current);E(t=>t.filter(t=>!e.has(t)))}else E(e=>[...new Set([...e,...v.current])])},[k,E]);if(s.isError)return(0,J.jsx)(T,{icon:(0,J.jsx)(_,{}),tone:`danger`,heading:`h2`,title:`Could not load importable skills`,subtitle:s.error.message});let M=z(p,c);return(0,J.jsxs)(`div`,{"data-slot":`skills-import-panel`,className:`w-full min-w-0 [&_button]:min-h-11`,children:[(0,J.jsx)(`p`,{className:`mb-4 text-[10px] font-medium tracking-wide text-link-foreground`,children:`OPEN-MERCATO / SKILLS`}),(0,J.jsx)(`h2`,{className:`text-2xl font-medium`,children:`Manage skills`}),(0,J.jsxs)(`p`,{className:`mt-2 text-[13px] leading-relaxed text-muted-foreground`,children:[`Choose which `,(0,J.jsx)(`a`,{href:ce,target:`_blank`,rel:`noreferrer`,children:`open-mercato`}),` skills appear in your catalog and composer picker. All are enabled by default; uncheck any you don’t want.`]}),(0,J.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Applies across projects · saved automatically`}),(0,J.jsx)(ue,{projectId:e,state:f.data,loadError:f.error}),(0,J.jsx)(`p`,{className:`mt-4 text-xs text-soft-foreground`,children:`Checkboxes control visibility. Updating refreshes installed skill files; it does not change your selection.`}),(0,J.jsxs)(`div`,{className:`sw-import-controls mt-4 flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`sw-search relative min-w-0 flex-1`,children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,J.jsx)(W,{"data-slot":`import-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:c,onChange:e=>l(e.target.value),className:`h-11 min-w-0 pl-9 text-xs`})]}),(0,J.jsxs)(`button`,{type:`button`,"data-slot":`import-all`,disabled:m.length===0||n.isPending,onClick:j,className:`h-11 shrink-0 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[k?(0,J.jsx)(w,{"aria-hidden":`true`,className:`size-4`}):(0,J.jsx)(o,{"aria-hidden":`true`,className:`size-4`}),k?`Remove all`:`Enable all`]})]}),(0,J.jsx)(`div`,{"data-slot":`import-list`,className:`mt-3 flex flex-col gap-1.5`,children:s.isPending?(0,J.jsx)(`p`,{className:`px-1 py-2 text-[13px] text-soft-foreground`,children:`Loading…`}):M.length>0?M.map(e=>{let t=b.has(e.name);return(0,J.jsxs)(`label`,{"data-slot":`import-row`,"data-skill":e.name,"data-imported":t?`true`:void 0,className:F(`flex min-h-16 cursor-pointer items-start gap-3 rounded-lg border border-border p-4 transition-colors hover:bg-muted`,t&&`bg-background`),children:[(0,J.jsxs)(`span`,{className:`relative size-5 shrink-0`,children:[(0,J.jsx)(`input`,{type:`checkbox`,"data-slot":`import-toggle`,checked:t,onChange:()=>D(e.name),className:`peer absolute inset-0 m-0 size-5 opacity-0`}),t?(0,J.jsx)(h,{"aria-hidden":`true`,className:`pointer-events-none size-5 text-link-foreground peer-focus-visible:outline-2 peer-focus-visible:outline-ring`}):(0,J.jsx)(a,{"aria-hidden":`true`,className:`pointer-events-none size-5 text-link-foreground peer-focus-visible:outline-2 peer-focus-visible:outline-ring`})]}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,J.jsx)(`span`,{className:`min-w-0 break-words text-[13px] font-medium text-foreground`,children:e.name})}),e.description?(0,J.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-soft-foreground`,children:e.description}):null]})]},e.name)}):(0,J.jsx)(`p`,{className:`px-1 py-2 text-xs text-soft-foreground`,children:p.length>0?`(no skills match)`:`(no skills available — the repo may still be cloning)`})})]})}function Z(e){return e===`project`?`Project installation`:`Global installation`}function ue({projectId:e,state:t,loadError:n}){let i=r(),a=I(),o=(0,q.useRef)(0),[s,u]=(0,q.useState)(!1),p=f({mutationFn:()=>S({task:`Apply the upgrade notes after updating the installed Open Mercato skills.`,steps:[{id:`apply-upgrade-notes`,name:`Apply upgrade notes`,skill:`om-apply-upgrade-notes`,prompt:`{{task}}`}]}),onSuccess:e=>{u(!1),a(oe(e))},onError:e=>A(e.message,{tone:`danger`})}),m=(t,n)=>{n.seq===o.current&&(i.setQueryData(d.skillsUpdate(e),t),n.action===`apply`&&t.updatedAt&&t.updatedAt!==n.previousUpdatedAt&&(i.invalidateQueries({queryKey:C.skills}),A(t.status===`error`?`Some skill updates failed.`:`Open Mercato skills updated.`),u(!0)))},h=(e,t)=>{t.seq===o.current&&A(e.message,{tone:`danger`})},g=f({mutationFn:t=>M(e).then(e=>({result:e,request:t})),onSuccess:({result:e,request:t})=>m(e,t),onError:(e,t)=>h(e,t)}),_=f({mutationFn:t=>k(e).then(e=>({result:e,request:t})),onSuccess:({result:e,request:t})=>m(e,t),onError:(e,t)=>h(e,t)}),v=e=>{let n=++o.current;e===`apply`?_.mutate({action:e,seq:n,previousUpdatedAt:t?.updatedAt??null}):g.mutate({action:e,seq:n})},y=t?.scopes.some(e=>e.skills.length>0)??!1,x=t?.status===`error`,w=y&&(t?.available||x),T=_.isPending||t?.status===`updating`,E=t?.scopes.filter(e=>e.status===`error`||e.status===`unavailable`)??[],D=t?.scopes.filter(e=>e.updatedAt&&!E.includes(e))??[],O=`Checking installed Open Mercato skills…`;return n?O=`Update status is unavailable right now.`:t?.status===`available`?O=`An update is available for your installed Open Mercato skills.`:t?.status===`updating`?O=`Updating installed Open Mercato skills…`:t?.status===`current`?O=`Installed Open Mercato skills are up to date.`:t?.status===`unavailable`?O=t.scopes.find(e=>e.reason)?.reason??`Automatic updates are unavailable.`:t?.status===`error`&&(O=`The update did not finish for every installation.`),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`section`,{"data-slot":`skills-update-card`,"aria-live":`polite`,className:`mt-4 rounded-lg border border-border bg-background p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:O}),(0,J.jsx)(`p`,{className:`mt-4 text-xs text-soft-foreground`,children:`Project and global installations are checked separately.`}),t?.checkedAt?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:[`Last checked `,new Date(t.checkedAt).toLocaleString(),`.`]}):null,t?.scopes.some(e=>e.skills.length>0)?(0,J.jsx)(`ul`,{className:`mt-1 text-xs text-soft-foreground`,children:t.scopes.filter(e=>e.skills.length>0).map(e=>(0,J.jsxs)(`li`,{children:[Z(e.scope),` · `,e.skills.length,` tracked`]},e.scope))}):null,E.length>0?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-destructive`,children:[`Failed: `,E.map(e=>Z(e.scope)).join(`, `),D.length?`; updated: ${D.map(e=>Z(e.scope)).join(`, `)}`:``,`.`]}):null]}),w?(0,J.jsxs)(b,{"data-action":`skills-update-apply`,size:`sm`,disabled:T,onClick:()=>v(`apply`),children:[(0,J.jsx)(c,{"aria-hidden":`true`,className:F(`size-3.5`,T&&`motion-safe:animate-spin`)}),T?`Updating…`:x?`Retry`:`Update now`]}):t?.status===`current`?(0,J.jsxs)(b,{"data-action":`skills-update-check`,variant:`outline`,size:`sm`,disabled:g.isPending,onClick:()=>v(`check`),children:[(0,J.jsx)(c,{"aria-hidden":`true`,className:`size-4`}),`Check again`]}):t?.status===`unavailable`||n?(0,J.jsx)(b,{"data-action":`skills-update-check`,variant:`outline`,size:`sm`,disabled:g.isPending,onClick:()=>v(`check`),children:`Retry check`}):null]}),t?.status===`unavailable`||n?(0,J.jsxs)(`div`,{className:`mt-2 text-xs text-soft-foreground`,children:[`Manual examples: `,(0,J.jsx)(`code`,{children:`npx skills update -p`}),` · `,(0,J.jsx)(`code`,{children:`npx skills update -g`}),`. These broad commands may update other tracked sources.`]}):null,t?.needsUpgradeNotes?(0,J.jsxs)(`div`,{"data-slot":`skills-upgrade-notes`,className:`mt-3 flex gap-2 rounded-md border border-accent-strong/30 bg-background p-2.5 text-xs text-foreground`,children:[(0,J.jsx)(l,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-link-foreground`}),(0,J.jsxs)(`span`,{children:[`Skill files were updated. Run `,(0,J.jsx)(`code`,{children:`/om-apply-upgrade-notes`}),` in each configured repository to apply descriptor migrations while preserving local edits.`]})]}):null]}),(0,J.jsx)(ne,{open:s,onOpenChange:e=>p.isPending?void 0:u(e),children:(0,J.jsxs)(ie,{"data-slot":`skills-upgrade-notes-dialog`,showCloseButton:!1,children:[(0,J.jsxs)(re,{children:[(0,J.jsx)(ae,{children:`Apply the upgrade notes now?`}),(0,J.jsxs)(te,{children:[`The skill files were updated successfully. Start a new session with`,` `,(0,J.jsx)(`code`,{children:`/om-apply-upgrade-notes`}),` to sync repository descriptors while preserving local edits?`]})]}),(0,J.jsxs)(ee,{children:[(0,J.jsx)(b,{type:`button`,variant:`outline`,disabled:p.isPending,onClick:()=>u(!1),children:`No`}),(0,J.jsx)(b,{type:`button`,disabled:p.isPending,onClick:()=>p.mutate(),children:p.isPending?`Starting…`:`Yes, start session`})]})]})})]})}var Q=`__bm`,$=`__import`;function de(){return(0,J.jsx)(`div`,{"data-route":`skills`,className:`mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:(0,J.jsx)(fe,{})})}function fe(){let e=x(),t=N(),n=i(),[a]=P(),[o,l]=(0,q.useState)(``),d=r(),h=s(),g=j().projectId??h.data?.bootProject??``,y=f({mutationFn:()=>v(),onSuccess:e=>{d.setQueryData(C.skills,e),A(`Team skills refreshed.`)},onError:e=>A(e.message,{tone:`danger`})});if(e.isError)return(0,J.jsx)(T,{icon:(0,J.jsx)(_,{}),tone:`danger`,heading:`h2`,title:`Could not load skills`,subtitle:e.error.message});let b=V(e.data??[]),S=(n.data?.length??0)>0,w=a.get(`skill`),O=w===Q||w===$||w!==null&&b.some(e=>e.name===w)?w:b[0]?.name??(S?$:Q),k=b.find(e=>e.name===O)??null,M=B(b,o);return(0,J.jsxs)(`div`,{"data-slot":`skills-section`,className:`@container flex min-w-0 flex-col gap-[22px]`,children:[(0,J.jsxs)(`header`,{className:`flex flex-col gap-4 @min-[700px]:flex-row @min-[700px]:items-center @min-[700px]:justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{className:`text-[25px] font-semibold md:text-[30px]`,children:`Skills`}),(0,J.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground md:text-[13px]`,children:`Markdown playbooks your agents can follow.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[S?(0,J.jsxs)(L,{to:`/skills?skill=${$}`,"data-slot":`import-skills-row`,"aria-current":O===$?`page`:void 0,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium aria-[current=page]:bg-accent-strong/10 hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,J.jsx)(D,{"aria-hidden":`true`,className:`size-4 text-link-foreground`}),`Manage skills`]}):null,(0,J.jsxs)(L,{to:`/skills?skill=${Q}`,"data-slot":`bookmarklets-row`,"aria-current":O===Q?`page`:void 0,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium aria-[current=page]:bg-accent-strong/10 hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,J.jsx)(E,{"aria-hidden":`true`,className:`size-4 text-link-foreground`}),`Run from GitHub`]})]})]}),(0,J.jsxs)(`div`,{className:F(`flex-col items-start gap-2 sm:flex-row sm:items-center md:flex`,w===null?`flex`:`hidden`),children:[(0,J.jsxs)(`div`,{className:`sw-search relative w-full min-w-0 flex-1`,children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,J.jsx)(W,{"data-slot":`skills-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:o,onChange:e=>l(e.target.value),className:`h-11 min-w-0 bg-card pl-9 text-xs`})]}),(0,J.jsxs)(`button`,{type:`button`,"data-slot":`skills-refresh`,title:`git fetch the team skills repos`,disabled:y.isPending,onClick:()=>y.mutate(),className:`flex h-11 shrink-0 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[(0,J.jsx)(c,{"aria-hidden":`true`,className:F(`size-3`,y.isPending&&`motion-safe:animate-spin`)}),`Refresh`]})]}),(0,J.jsxs)(`div`,{className:`grid min-w-0 items-start gap-[22px] md:grid-cols-[minmax(220px,310px)_minmax(0,1fr)]`,children:[(0,J.jsx)(`section`,{"data-slot":`skills-list`,className:F(`min-w-0 flex-col rounded-xl border border-border bg-card p-3 md:flex`,w===null?`flex`:`hidden`),children:(0,J.jsx)(`ul`,{"data-slot":`skill-rows`,className:`flex min-h-0 flex-col gap-1 overflow-y-auto md:max-h-[calc(100dvh-280px)]`,children:e.isPending?(0,J.jsx)(`li`,{role:`status`,"aria-busy":`true`,className:`min-h-72 p-3 text-[13px] text-soft-foreground`,children:`Loading skills…`}):M.length>0?M.map(e=>(0,J.jsx)(pe,{skill:e,active:O===e.name,highlighted:O===$&&e===b[0]},e.path)):(0,J.jsx)(`li`,{className:`px-2.5 py-2 text-xs leading-relaxed text-soft-foreground`,children:b.length>0?`(no skills match)`:(0,J.jsx)(se,{})})})}),(0,J.jsx)(`section`,{"data-slot":`skills-detail`,className:F(`min-w-0 flex-col rounded-xl border border-border bg-card md:flex`,w===null?`hidden`:`flex`),children:(0,J.jsxs)(`div`,{className:`min-w-0 p-5`,children:[(0,J.jsxs)(L,{to:`/skills`,"data-slot":`skills-back`,className:`mb-4 inline-flex min-h-11 items-center gap-2 rounded-lg border border-border px-3 text-xs font-medium hover:bg-muted md:hidden`,children:[(0,J.jsx)(p,{"aria-hidden":`true`,className:`size-3.5`}),`Back to skills`]}),O===$?(0,J.jsx)(X,{projectId:g}):O===Q?(0,J.jsx)(K,{skills:b}):k?(0,J.jsx)(G,{skill:k,usedBy:H(t.data?.workflows??[],k.name)}):e.isPending?(0,J.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`min-h-72 text-xs text-muted-foreground`,children:`Loading skill…`}):(0,J.jsx)(T,{icon:(0,J.jsx)(m,{}),tone:`neutral`,heading:`h2`,title:`No skill selected`,subtitle:`Pick a skill from the catalog.`})]})})]})]})}function pe({skill:e,active:t,highlighted:n}){let r=R(e);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(L,{to:`/skills?skill=${encodeURIComponent(e.name)}`,"data-slot":`skill-row`,"data-skill":e.name,"data-highlighted":n||void 0,"data-project":r?`true`:void 0,"aria-current":t?`page`:void 0,className:F(`selection-row flex min-h-24 flex-col gap-2 rounded-lg border-b border-border p-3 transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,(t||n)&&`border-transparent bg-accent-strong/10`),children:[(0,J.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,J.jsx)(`span`,{className:F(`min-w-0 break-words text-[13px]`,r?`font-semibold text-foreground`:`font-normal text-muted-foreground`),children:e.name})}),e.description?(0,J.jsx)(`span`,{className:`line-clamp-2 text-xs leading-relaxed text-supporting-foreground`,children:e.description}):null,(0,J.jsx)(U,{source:e.source,className:`self-start border-0 bg-transparent p-0 text-link-foreground`})]})})}export{de as SkillsRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$n as r,Aa as i,Ca as a,Gi as o,Jn as s,Kr as c,Li as l,Qn as u,Ta as d,_i as f,_t as p,d as m,di as h,ea as g,in as _,ji as v,l as y,lt as b,ni as x,sa as S,wn as C,zi as w}from"./alert-dialog-BOp2HnnL.js";import{a as T,i as E,n as D,o as O,r as k,s as A,t as j}from"./textarea-DfvlPIgO.js";import{p as M,u as ee}from"./pill-Dvvq0Otw.js";import{i as N,n as P,r as F}from"./git-toolbar-rk3doc2w.js";import{t as I}from"./run-header-C9Aeh27u.js";import{t as L}from"./use-submit-shortcut-KWJsC906.js";import{n as R,r as z}from"./index-C4iEPAUV.js";import{t as B}from"./diff-BjLZHKfD2.js";import{t as te}from"./use-desktop-BaYgO7YW.js";var V=e(t(),1),H=e=>e===`running`||e===`queued`||e===`waiting`,U=`no worktree — this task ran directly in the repo working tree`;function W(e){let t=e=>({id:`commit`,label:`Commit`,enabled:!1,reason:e});return e.hasWorktree?e.status===`running`?t(`Commit unavailable — the agent is still working in this worktree`):e.changedFiles===void 0?t(`Commit unavailable — changes are still loading`):e.changedFiles===0?t(`Commit unavailable — no changes to commit`):{id:`commit`,label:`Commit`,enabled:!0}:t(`Commit unavailable — ${U}`)}function G(e){let t=e=>({id:`push`,label:`Push`,enabled:!1,reason:e});return e.hasWorktree?e.remote===void 0?t(`Push unavailable — no remote configured`):e.branch===void 0?t(`Push unavailable — the run has no branch to push`):e.status===`running`?t(`Push unavailable — the agent is still working in this worktree`):{id:`push`,label:`Push`,enabled:!0}:t(`Push unavailable — ${U}`)}function K(e){let t=e=>({id:`create-pr`,label:`Create PR`,enabled:!1,reason:e});return!e.hasWorktree||e.branch===void 0?t(`Create PR unavailable — ${U}`):e.forge===null?t(`Create PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?H(e.status)?t(`Create PR unavailable — the run is still active; wait for the review gate`):{id:`create-pr`,label:`Create PR`,enabled:!0}:t(`Create PR unavailable — ${e.forge.reason??`the forge is unreachable`}`)}function q(e){let t=e.prUrl?{id:`view-pr`,label:`View PR`,enabled:!0,href:e.prUrl}:W(e),n=e.prUrl?[W(e),G(e)]:[G(e),K(e)],r=[];if(e.localHandoff){let t=e.hasSession?H(e.status)?{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — the session is still active in the engine`}:{id:`open-terminal`,label:`Open in terminal`,enabled:!0}:{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — no agent session to resume`};r.push(t)}return{primary:t,secondary:n,menu:r}}var J=n();function Y({run:e,open:t,onOpenChange:n}){let r=i(),[a,o]=(0,V.useState)(``),s=c(e),l=(0,V.useRef)(s);l.current=s,(0,V.useEffect)(()=>{t&&o(l.current)},[t]);let u=d({mutationFn:t=>h(e.id,t),onSuccess:t=>{S(`Committed ${t.sha.slice(0,7)}`),n(!1),r.invalidateQueries({queryKey:_.runs.changes(e.id)}),r.invalidateQueries({queryKey:_.runs.all})},onError:e=>S(e.message,{tone:`danger`})}),f=()=>{let e=a.trim();e.length===0||u.isPending||u.mutate(e)};return(0,J.jsx)(D,{open:t,onOpenChange:n,children:(0,J.jsxs)(k,{"data-slot":`commit-dialog`,children:[(0,J.jsxs)(O,{children:[(0,J.jsx)(A,{children:`Commit changes`}),(0,J.jsxs)(E,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,J.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,`.`]})]}),(0,J.jsx)(j,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{L({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),f())}}),(0,J.jsxs)(T,{children:[(0,J.jsx)(m,{variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,J.jsx)(m,{"data-slot":`commit-confirm`,disabled:a.trim().length===0||u.isPending,onClick:f,children:u.isPending?`Committing…`:`Commit`})]})]})})}function X(){let{id:e}=a(),t=u(e);return t.isPending?(0,J.jsx)(z,{tab:`changes`}):t.isError?(0,J.jsx)(R,{tab:`changes`,error:t.error}):(0,J.jsx)(Z,{run:t.data})}function Z({run:e}){let t=C(),n=s(),a=r(e.id,ee(e.status)),c=te(),[u,m]=(0,V.useState)(`unified`),[h,v]=(0,V.useState)(!1),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(!1),k=(0,V.useRef)(null),A=i(),j=()=>A.invalidateQueries({queryKey:_.runs.all}),L=e=>S(e.message,{tone:`danger`}),R=d({mutationFn:()=>o(e.id),onSuccess:e=>S(e.upstreamSet?`Pushed ${e.branch} to ${e.remote} (upstream set)`:`Pushed ${e.branch} to ${e.remote}`),onError:L}),z=d({mutationFn:()=>f(e.id),onSuccess:e=>{S(`Draft PR created — ${e.url}`),j()},onError:L}),H=d({mutationFn:()=>w(e.id),onError:e=>{if(e instanceof x&&e.command){navigator.clipboard.writeText(e.command).then(()=>S(`No terminal found — command copied to clipboard.`)).catch(()=>S(`Run manually: ${e.command}`));return}L(e)}}),U=d({mutationFn:t=>l(e.id,t),onError:L}),W=a.isError&&a.error instanceof x&&a.error.status===409,G=q({status:e.status,hasWorktree:!!e.worktreePath&&!W,branch:e.branch,changedFiles:a.data?.stat.files,remote:n.data?.info?.remote,forge:t.data?.forge??null,localHandoff:t.data?.capabilities.localHandoff??!1,hasSession:M(e)!==void 0,prUrl:e.pullRequestUrl}),K=e=>{switch(e){case`commit`:O(!0);break;case`push`:R.mutate();break;case`create-pr`:z.mutate();break;case`open-terminal`:H.mutate();break;case`view-pr`:break}},X=a.data?.files??[],Z=(0,V.useMemo)(()=>F(X),[X]),Q=c?u:`unified`,$=!c||h;return(0,J.jsxs)(`div`,{"data-route":`task-changes`,className:`flex min-h-full flex-col`,children:[(0,J.jsx)(I,{run:e,tab:`changes`}),(0,J.jsx)(P,{bar:G,branch:e.branch,stat:a.data?.stat,mode:Q,wrap:$,onModeChange:m,onWrapChange:v,onAction:K}),a.data?.repointedHead?(0,J.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-9`,children:[`HEAD is on `,(0,J.jsx)(`code`,{children:a.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,J.jsx)(`code`,{children:a.data.repointedHead.taskBranch}),` — showing only what this task changed there.`]}):null,a.isPending?(0,J.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):a.isError?(0,J.jsx)(y,{icon:W?(0,J.jsx)(b,{size:16}):(0,J.jsx)(p,{size:16}),tone:W?`neutral`:`danger`,heading:`h2`,title:W?`No changes to show`:`Could not load the changes`,subtitle:a.error.message}):X.length===0?(0,J.jsx)(y,{icon:(0,J.jsx)(b,{size:16}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-9`,children:[(0,J.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:block lg:w-[250px]`,children:[(0,J.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,J.jsx)(N,{root:Z,selected:T,onSelect:e=>{E(e),k.current?.scrollToPath(e)}})]}),(0,J.jsx)(B,{files:X,viewRef:k,mode:Q,wrap:$,loadFileText:t=>ne(e.id,t),imageSrc:t=>g(e.id,t),onOpenInApp:t.data?.capabilities.localHandoff?e=>U.mutate(e):void 0,className:`min-w-0 flex-1`})]}),(0,J.jsx)(Y,{run:e,open:D,onOpenChange:O})]})}async function ne(e,t){try{let n=await v(e,t);return n.type!==`file`||n.binary||n.tooLarge?null:n.content??null}catch{return null}}export{X as TaskChangesRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$n as r,Aa as i,Ca as a,Gi as o,Jn as s,Kr as c,Li as l,Qn as u,Ta as d,_i as f,_t as p,d as m,di as h,ea as g,in as _,ji as v,l as y,lt as b,ni as x,sa as S,wn as C,zi as w}from"./alert-dialog-BOp2HnnL.js";import{a as T,i as E,n as D,o as O,r as k,s as A,t as j}from"./textarea-DfvlPIgO.js";import{p as M,u as ee}from"./pill-BoBISMI9.js";import{i as N,n as P,r as F}from"./git-toolbar-rk3doc2w.js";import{t as I}from"./run-header-BKeByMek.js";import{t as L}from"./use-submit-shortcut-KWJsC906.js";import{n as R,r as z}from"./index-DTsigc4h.js";import{t as B}from"./diff-BjLZHKfD2.js";import{t as te}from"./use-desktop-BaYgO7YW.js";var V=e(t(),1),H=e=>e===`running`||e===`queued`||e===`waiting`,U=`no worktree — this task ran directly in the repo working tree`;function W(e){let t=e=>({id:`commit`,label:`Commit`,enabled:!1,reason:e});return e.hasWorktree?e.status===`running`?t(`Commit unavailable — the agent is still working in this worktree`):e.changedFiles===void 0?t(`Commit unavailable — changes are still loading`):e.changedFiles===0?t(`Commit unavailable — no changes to commit`):{id:`commit`,label:`Commit`,enabled:!0}:t(`Commit unavailable — ${U}`)}function G(e){let t=e=>({id:`push`,label:`Push`,enabled:!1,reason:e});return e.hasWorktree?e.remote===void 0?t(`Push unavailable — no remote configured`):e.branch===void 0?t(`Push unavailable — the run has no branch to push`):e.status===`running`?t(`Push unavailable — the agent is still working in this worktree`):{id:`push`,label:`Push`,enabled:!0}:t(`Push unavailable — ${U}`)}function K(e){let t=e=>({id:`create-pr`,label:`Create PR`,enabled:!1,reason:e});return!e.hasWorktree||e.branch===void 0?t(`Create PR unavailable — ${U}`):e.forge===null?t(`Create PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?H(e.status)?t(`Create PR unavailable — the run is still active; wait for the review gate`):{id:`create-pr`,label:`Create PR`,enabled:!0}:t(`Create PR unavailable — ${e.forge.reason??`the forge is unreachable`}`)}function q(e){let t=e.prUrl?{id:`view-pr`,label:`View PR`,enabled:!0,href:e.prUrl}:W(e),n=e.prUrl?[W(e),G(e)]:[G(e),K(e)],r=[];if(e.localHandoff){let t=e.hasSession?H(e.status)?{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — the session is still active in the engine`}:{id:`open-terminal`,label:`Open in terminal`,enabled:!0}:{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — no agent session to resume`};r.push(t)}return{primary:t,secondary:n,menu:r}}var J=n();function Y({run:e,open:t,onOpenChange:n}){let r=i(),[a,o]=(0,V.useState)(``),s=c(e),l=(0,V.useRef)(s);l.current=s,(0,V.useEffect)(()=>{t&&o(l.current)},[t]);let u=d({mutationFn:t=>h(e.id,t),onSuccess:t=>{S(`Committed ${t.sha.slice(0,7)}`),n(!1),r.invalidateQueries({queryKey:_.runs.changes(e.id)}),r.invalidateQueries({queryKey:_.runs.all})},onError:e=>S(e.message,{tone:`danger`})}),f=()=>{let e=a.trim();e.length===0||u.isPending||u.mutate(e)};return(0,J.jsx)(D,{open:t,onOpenChange:n,children:(0,J.jsxs)(k,{"data-slot":`commit-dialog`,children:[(0,J.jsxs)(O,{children:[(0,J.jsx)(A,{children:`Commit changes`}),(0,J.jsxs)(E,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,J.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,`.`]})]}),(0,J.jsx)(j,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{L({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),f())}}),(0,J.jsxs)(T,{children:[(0,J.jsx)(m,{variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,J.jsx)(m,{"data-slot":`commit-confirm`,disabled:a.trim().length===0||u.isPending,onClick:f,children:u.isPending?`Committing…`:`Commit`})]})]})})}function X(){let{id:e}=a(),t=u(e);return t.isPending?(0,J.jsx)(z,{tab:`changes`}):t.isError?(0,J.jsx)(R,{tab:`changes`,error:t.error}):(0,J.jsx)(Z,{run:t.data})}function Z({run:e}){let t=C(),n=s(),a=r(e.id,ee(e.status)),c=te(),[u,m]=(0,V.useState)(`unified`),[h,v]=(0,V.useState)(!1),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(!1),k=(0,V.useRef)(null),A=i(),j=()=>A.invalidateQueries({queryKey:_.runs.all}),L=e=>S(e.message,{tone:`danger`}),R=d({mutationFn:()=>o(e.id),onSuccess:e=>S(e.upstreamSet?`Pushed ${e.branch} to ${e.remote} (upstream set)`:`Pushed ${e.branch} to ${e.remote}`),onError:L}),z=d({mutationFn:()=>f(e.id),onSuccess:e=>{S(`Draft PR created — ${e.url}`),j()},onError:L}),H=d({mutationFn:()=>w(e.id),onError:e=>{if(e instanceof x&&e.command){navigator.clipboard.writeText(e.command).then(()=>S(`No terminal found — command copied to clipboard.`)).catch(()=>S(`Run manually: ${e.command}`));return}L(e)}}),U=d({mutationFn:t=>l(e.id,t),onError:L}),W=a.isError&&a.error instanceof x&&a.error.status===409,G=q({status:e.status,hasWorktree:!!e.worktreePath&&!W,branch:e.branch,changedFiles:a.data?.stat.files,remote:n.data?.info?.remote,forge:t.data?.forge??null,localHandoff:t.data?.capabilities.localHandoff??!1,hasSession:M(e)!==void 0,prUrl:e.pullRequestUrl}),K=e=>{switch(e){case`commit`:O(!0);break;case`push`:R.mutate();break;case`create-pr`:z.mutate();break;case`open-terminal`:H.mutate();break;case`view-pr`:break}},X=a.data?.files??[],Z=(0,V.useMemo)(()=>F(X),[X]),Q=c?u:`unified`,$=!c||h;return(0,J.jsxs)(`div`,{"data-route":`task-changes`,className:`flex min-h-full flex-col`,children:[(0,J.jsx)(I,{run:e,tab:`changes`}),(0,J.jsx)(P,{bar:G,branch:e.branch,stat:a.data?.stat,mode:Q,wrap:$,onModeChange:m,onWrapChange:v,onAction:K}),a.data?.repointedHead?(0,J.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-9`,children:[`HEAD is on `,(0,J.jsx)(`code`,{children:a.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,J.jsx)(`code`,{children:a.data.repointedHead.taskBranch}),` — showing only what this task changed there.`]}):null,a.isPending?(0,J.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):a.isError?(0,J.jsx)(y,{icon:W?(0,J.jsx)(b,{size:16}):(0,J.jsx)(p,{size:16}),tone:W?`neutral`:`danger`,heading:`h2`,title:W?`No changes to show`:`Could not load the changes`,subtitle:a.error.message}):X.length===0?(0,J.jsx)(y,{icon:(0,J.jsx)(b,{size:16}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-9`,children:[(0,J.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:block lg:w-[250px]`,children:[(0,J.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,J.jsx)(N,{root:Z,selected:T,onSelect:e=>{E(e),k.current?.scrollToPath(e)}})]}),(0,J.jsx)(B,{files:X,viewRef:k,mode:Q,wrap:$,loadFileText:t=>ne(e.id,t),imageSrc:t=>g(e.id,t),onOpenInApp:t.data?.capabilities.localHandoff?e=>U.mutate(e):void 0,className:`min-w-0 flex-1`})]}),(0,J.jsx)(Y,{run:e,open:D,onOpenChange:O})]})}async function ne(e,t){try{let n=await v(e,t);return n.type!==`file`||n.binary||n.tooLarge?null:n.content??null}catch{return null}}export{X as TaskChangesRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$n as r,Ca as i,Qn as a,U as o,Yt as s,_t as c,ct as l,d as u,er as d,l as f,ni as p,tr as m}from"./alert-dialog-BOp2HnnL.js";import{u as h}from"./pill-Dvvq0Otw.js";import{n as g}from"./diff-controls-DaO836o4.js";import{t as _}from"./run-header-C9Aeh27u.js";import{t as v}from"./project-router-CvFAMDcP.js";import{t as y}from"./search-x-I9Q8pgUa.js";import{t as b}from"./diff-stat-DpHwISUB.js";import{n as x,r as S}from"./index-C4iEPAUV.js";import{t as C}from"./diff-BjLZHKfD2.js";import{t as w}from"./use-desktop-BaYgO7YW.js";import{t as T}from"./commit-list-CEVhJoCF.js";var E=e(t(),1),D=n();function O(){let{id:e}=i(),t=a(e);return t.isPending?(0,D.jsx)(S,{tab:`changes`}):t.isError?(0,D.jsx)(x,{tab:`changes`,error:t.error}):(0,D.jsx)(k,{run:t.data})}function k({run:e}){let{sha:t}=i(),n=m(e.id,h(e.status));return(0,D.jsxs)(`div`,{"data-route":`task-commits`,className:`flex min-h-full flex-col`,children:[(0,D.jsx)(_,{run:e,tab:`commits`}),t?(0,D.jsx)(A,{runId:e.id,sha:t}):n.isPending?(0,D.jsx)(`p`,{"data-slot":`commits-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commits…`}):n.isError?(0,D.jsx)(f,{icon:(0,D.jsx)(c,{size:16}),tone:n.error instanceof p&&n.error.status===409?`neutral`:`danger`,heading:`h2`,title:n.error instanceof p&&n.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:n.error.message}):n.data.commits.length===0?(0,D.jsx)(f,{icon:(0,D.jsx)(c,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`This task hasn't committed anything on its branch. Autosave commits and any the agent makes appear here.`}):(0,D.jsxs)(`div`,{className:`px-[18px] py-[22px] md:px-9`,children:[(0,D.jsx)(T,{slot:`task-commits`,heading:(0,D.jsxs)(`h2`,{className:`text-base font-semibold`,children:[n.data.commits.length,` `,n.data.commits.length===1?`commit`:`commits`,` in this task`]}),className:`w-full`,commits:n.data.commits.map(t=>({...t,shaLabel:t.sha.slice(0,8),href:`/tasks/${e.id}/commits/${t.sha}`}))}),(0,D.jsx)(j,{run:e})]})]})}function A({runId:e,sha:t}){let n=d(e,t),r=w(),[i,a]=(0,E.useState)(`unified`),[l,m]=(0,E.useState)(!1),h=n.isError&&n.error instanceof p&&n.error.status===409,_=r?i:`unified`,x=!r||l;return(0,D.jsxs)(`section`,{"data-slot":`task-commit`,"data-sha":t,className:`mx-auto flex min-h-0 w-full max-w-[var(--measure)] flex-1 flex-col`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[(0,D.jsx)(u,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,D.jsxs)(v,{to:`/tasks/${e}/commits`,children:[(0,D.jsx)(o,{size:16,"aria-hidden":`true`}),`All commits`]})}),n.data?(0,D.jsx)(b,{stat:n.data.stat}):null,(0,D.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,D.jsx)(g,{mode:i,wrap:l,onModeChange:a,onWrapChange:m})})]}),n.isPending?(0,D.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commit…`}):n.isError?(0,D.jsx)(f,{icon:h?(0,D.jsx)(y,{}):(0,D.jsx)(s,{size:16}),tone:h?`neutral`:`danger`,heading:`h2`,title:h?`Commit not found`:`Could not load the commit`,subtitle:n.error.message}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold`,children:n.data.subject}),(0,D.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[n.data.author,` · `,n.data.when,` ·`,` `,(0,D.jsx)(`span`,{className:`font-mono select-all`,children:n.data.sha})]})]}),n.data.files.length===0?(0,D.jsx)(f,{icon:(0,D.jsx)(c,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,D.jsx)(`div`,{className:`px-4 py-4 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-6`,children:(0,D.jsx)(C,{files:n.data.files,mode:_,wrap:x,className:`min-w-0`})})]})]})}function j({run:e}){let t=r(e.id,h(e.status));return t.isPending?(0,D.jsx)(`p`,{className:`mt-[22px] text-xs text-muted-foreground`,children:`Loading changed files…`}):t.isError?(0,D.jsxs)(`p`,{role:`status`,className:`mt-[22px] text-xs text-danger`,children:[`Could not load changed files: `,t.error.message]}):t.data.files.length===0?null:(0,D.jsxs)(`section`,{"data-slot":`task-commit-files`,className:`mt-[22px] rounded-[10px] border border-border bg-card p-5`,children:[(0,D.jsxs)(`h2`,{className:`mb-4 text-[15px] font-semibold`,children:[t.data.files.length,` changed files`]}),(0,D.jsx)(`ul`,{className:`space-y-4`,children:t.data.files.map(t=>(0,D.jsx)(`li`,{children:(0,D.jsxs)(v,{to:`/tasks/${e.id}/changes`,className:`flex min-h-11 items-center gap-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,D.jsx)(l,{size:16,"aria-hidden":`true`,className:`size-[15px] shrink-0`}),(0,D.jsx)(`span`,{className:`break-all`,children:t.path})]})},t.path))})]})}export{O as TaskCommitsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$n as r,Ca as i,Qn as a,U as o,Yt as s,_t as c,ct as l,d as u,er as d,l as f,ni as p,tr as m}from"./alert-dialog-BOp2HnnL.js";import{u as h}from"./pill-BoBISMI9.js";import{n as g}from"./diff-controls-DaO836o4.js";import{t as _}from"./run-header-BKeByMek.js";import{t as v}from"./project-router-CvFAMDcP.js";import{t as y}from"./search-x-I9Q8pgUa.js";import{t as b}from"./diff-stat-DpHwISUB.js";import{n as x,r as S}from"./index-DTsigc4h.js";import{t as C}from"./diff-BjLZHKfD2.js";import{t as w}from"./use-desktop-BaYgO7YW.js";import{t as T}from"./commit-list-DOWYQ7G6.js";var E=e(t(),1),D=n();function O(){let{id:e}=i(),t=a(e);return t.isPending?(0,D.jsx)(S,{tab:`changes`}):t.isError?(0,D.jsx)(x,{tab:`changes`,error:t.error}):(0,D.jsx)(k,{run:t.data})}function k({run:e}){let{sha:t}=i(),n=m(e.id,h(e.status));return(0,D.jsxs)(`div`,{"data-route":`task-commits`,className:`flex min-h-full flex-col`,children:[(0,D.jsx)(_,{run:e,tab:`commits`}),t?(0,D.jsx)(A,{runId:e.id,sha:t}):n.isPending?(0,D.jsx)(`p`,{"data-slot":`commits-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commits…`}):n.isError?(0,D.jsx)(f,{icon:(0,D.jsx)(c,{size:16}),tone:n.error instanceof p&&n.error.status===409?`neutral`:`danger`,heading:`h2`,title:n.error instanceof p&&n.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:n.error.message}):n.data.commits.length===0?(0,D.jsx)(f,{icon:(0,D.jsx)(c,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`This task hasn't committed anything on its branch. Autosave commits and any the agent makes appear here.`}):(0,D.jsxs)(`div`,{className:`px-[18px] py-[22px] md:px-9`,children:[(0,D.jsx)(T,{slot:`task-commits`,heading:(0,D.jsxs)(`h2`,{className:`text-base font-semibold`,children:[n.data.commits.length,` `,n.data.commits.length===1?`commit`:`commits`,` in this task`]}),className:`w-full`,commits:n.data.commits.map(t=>({...t,shaLabel:t.sha.slice(0,8),href:`/tasks/${e.id}/commits/${t.sha}`}))}),(0,D.jsx)(j,{run:e})]})]})}function A({runId:e,sha:t}){let n=d(e,t),r=w(),[i,a]=(0,E.useState)(`unified`),[l,m]=(0,E.useState)(!1),h=n.isError&&n.error instanceof p&&n.error.status===409,_=r?i:`unified`,x=!r||l;return(0,D.jsxs)(`section`,{"data-slot":`task-commit`,"data-sha":t,className:`mx-auto flex min-h-0 w-full max-w-[var(--measure)] flex-1 flex-col`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[(0,D.jsx)(u,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,D.jsxs)(v,{to:`/tasks/${e}/commits`,children:[(0,D.jsx)(o,{size:16,"aria-hidden":`true`}),`All commits`]})}),n.data?(0,D.jsx)(b,{stat:n.data.stat}):null,(0,D.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,D.jsx)(g,{mode:i,wrap:l,onModeChange:a,onWrapChange:m})})]}),n.isPending?(0,D.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commit…`}):n.isError?(0,D.jsx)(f,{icon:h?(0,D.jsx)(y,{}):(0,D.jsx)(s,{size:16}),tone:h?`neutral`:`danger`,heading:`h2`,title:h?`Commit not found`:`Could not load the commit`,subtitle:n.error.message}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold`,children:n.data.subject}),(0,D.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[n.data.author,` · `,n.data.when,` ·`,` `,(0,D.jsx)(`span`,{className:`font-mono select-all`,children:n.data.sha})]})]}),n.data.files.length===0?(0,D.jsx)(f,{icon:(0,D.jsx)(c,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,D.jsx)(`div`,{className:`px-4 py-4 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-6`,children:(0,D.jsx)(C,{files:n.data.files,mode:_,wrap:x,className:`min-w-0`})})]})]})}function j({run:e}){let t=r(e.id,h(e.status));return t.isPending?(0,D.jsx)(`p`,{className:`mt-[22px] text-xs text-muted-foreground`,children:`Loading changed files…`}):t.isError?(0,D.jsxs)(`p`,{role:`status`,className:`mt-[22px] text-xs text-danger`,children:[`Could not load changed files: `,t.error.message]}):t.data.files.length===0?null:(0,D.jsxs)(`section`,{"data-slot":`task-commit-files`,className:`mt-[22px] rounded-[10px] border border-border bg-card p-5`,children:[(0,D.jsxs)(`h2`,{className:`mb-4 text-[15px] font-semibold`,children:[t.data.files.length,` changed files`]}),(0,D.jsx)(`ul`,{className:`space-y-4`,children:t.data.files.map(t=>(0,D.jsx)(`li`,{children:(0,D.jsxs)(v,{to:`/tasks/${e.id}/changes`,className:`flex min-h-11 items-center gap-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,D.jsx)(l,{size:16,"aria-hidden":`true`,className:`size-[15px] shrink-0`}),(0,D.jsx)(`span`,{className:`break-all`,children:t.path})]})},t.path))})]})}export{O as TaskCommitsRoute};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ca as r,Qn as i,Rt as a,Yt as o,Z as s,ct as c,d as l,dt as u,ea as d,l as f,ni as p,rr as m,ut as h}from"./alert-dialog-BOp2HnnL.js";import{t as g}from"./utils-GZNjgma4.js";import{t as _}from"./createLucideIcon-BHp8sXmF.js";import{t as v}from"./run-header-C9Aeh27u.js";import{a as y,i as b,r as x}from"./highlighter-CdHqIwFr.js";import{h as S,n as C,r as w}from"./index-C4iEPAUV.js";var T=_(`file-exclamation-point`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),E=_(`file-question-mark`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),D=_(`file-x`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14.5 12.5-5 5`,key:`b62r18`}],[`path`,{d:`m9.5 12.5 5 5`,key:`1rk7el`}]]),O=_(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),k=_(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),A=e(t(),1),j=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`,`avif`]);function M(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?!1:j.has(t.slice(n+1).toLowerCase())}function N(e){return e.tooLarge?`too-large`:M(e.path)?`image`:e.binary?`binary`:`text`}function P(e){return e>=1024**2?`${(e/1024**2).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} kB`:`${e} B`}var F=n();function I({runId:e,path:t,className:n}){let r=m(e,t??void 0);if(t===null)return(0,F.jsx)(R,{className:n,children:(0,F.jsx)(f,{icon:(0,F.jsx)(h,{size:16}),tone:`neutral`,heading:`h2`,title:`Select a file`,subtitle:`Pick a file from this task’s worktree to inspect its contents.`,className:`[&_[data-slot=centered-state-tile]]:size-10 [&_[data-slot=centered-state-tile]]:border-0 [&_[data-slot=centered-state-tile]]:bg-transparent [&_[data-slot=centered-state-tile]]:text-accent-text [&_[data-slot=centered-state-tile]]:shadow-none [&_h2]:text-xl`})});if(r.isPending)return(0,F.jsx)(R,{className:n,children:(0,F.jsxs)(`p`,{"data-slot":`file-preview-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground`,children:[`Loading `,t,`…`]})});if(r.isError){let e=r.error instanceof p&&r.error.status===409;return(0,F.jsx)(R,{className:n,children:(0,F.jsx)(f,{icon:e?(0,F.jsx)(D,{}):(0,F.jsx)(o,{size:16}),tone:e?`neutral`:`danger`,heading:`h2`,title:e?`Cannot preview this file`:`Could not load this file`,subtitle:r.error.message})})}return r.data.type===`file`?(0,F.jsx)(L,{runId:e,entry:r.data,className:n}):(0,F.jsx)(R,{className:n,children:(0,F.jsx)(f,{icon:(0,F.jsx)(E,{}),tone:`neutral`,heading:`h2`,title:`Choose a file inside this directory`,subtitle:`Expand the folder in the tree, or enter the full path to a file.`})})}function L({runId:e,entry:t,className:n}){let r=N(t);return(0,F.jsxs)(R,{className:n,children:[(0,F.jsxs)(`header`,{"data-slot":`file-preview-head`,className:`flex items-center gap-2 border-b border-border bg-muted/40 px-4 py-2 text-xs`,children:[(0,F.jsx)(`span`,{className:`min-w-0 truncate font-mono font-medium`,children:t.path}),(0,F.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-soft-foreground`,children:P(t.size)})]}),r===`image`?(0,F.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,F.jsx)(`img`,{"data-slot":`file-preview-image`,src:d(e,t.path),alt:t.path,className:`max-h-[70vh] max-w-full rounded-sm`})}):r===`too-large`?(0,F.jsx)(f,{icon:(0,F.jsx)(T,{}),tone:`neutral`,heading:`h2`,title:`Too large to preview`,subtitle:`${P(t.size)} — past the preview cap. Open it in your editor instead.`}):r===`binary`?(0,F.jsx)(f,{icon:(0,F.jsx)(E,{}),tone:`neutral`,heading:`h2`,title:`Binary file`,subtitle:`${P(t.size)} of binary data — no text preview.`}):(0,F.jsx)(V,{path:t.path,text:t.content??``})]})}function R({className:e,children:t}){return(0,F.jsx)(`section`,{"data-slot":`file-preview`,className:g(`flex flex-col overflow-hidden rounded-lg border border-border bg-card`,e),children:t})}var z=1500;function B(e,t){let n=(0,A.useMemo)(()=>t.split(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ca as r,Qn as i,Rt as a,Yt as o,Z as s,ct as c,d as l,dt as u,ea as d,l as f,ni as p,rr as m,ut as h}from"./alert-dialog-BOp2HnnL.js";import{t as g}from"./utils-GZNjgma4.js";import{t as _}from"./createLucideIcon-BHp8sXmF.js";import{t as v}from"./run-header-BKeByMek.js";import{a as y,i as b,r as x}from"./highlighter-CdHqIwFr.js";import{h as S,n as C,r as w}from"./index-DTsigc4h.js";var T=_(`file-exclamation-point`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),E=_(`file-question-mark`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),D=_(`file-x`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14.5 12.5-5 5`,key:`b62r18`}],[`path`,{d:`m9.5 12.5 5 5`,key:`1rk7el`}]]),O=_(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),k=_(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),A=e(t(),1),j=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`,`avif`]);function M(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?!1:j.has(t.slice(n+1).toLowerCase())}function N(e){return e.tooLarge?`too-large`:M(e.path)?`image`:e.binary?`binary`:`text`}function P(e){return e>=1024**2?`${(e/1024**2).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} kB`:`${e} B`}var F=n();function I({runId:e,path:t,className:n}){let r=m(e,t??void 0);if(t===null)return(0,F.jsx)(R,{className:n,children:(0,F.jsx)(f,{icon:(0,F.jsx)(h,{size:16}),tone:`neutral`,heading:`h2`,title:`Select a file`,subtitle:`Pick a file from this task’s worktree to inspect its contents.`,className:`[&_[data-slot=centered-state-tile]]:size-10 [&_[data-slot=centered-state-tile]]:border-0 [&_[data-slot=centered-state-tile]]:bg-transparent [&_[data-slot=centered-state-tile]]:text-accent-text [&_[data-slot=centered-state-tile]]:shadow-none [&_h2]:text-xl`})});if(r.isPending)return(0,F.jsx)(R,{className:n,children:(0,F.jsxs)(`p`,{"data-slot":`file-preview-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground`,children:[`Loading `,t,`…`]})});if(r.isError){let e=r.error instanceof p&&r.error.status===409;return(0,F.jsx)(R,{className:n,children:(0,F.jsx)(f,{icon:e?(0,F.jsx)(D,{}):(0,F.jsx)(o,{size:16}),tone:e?`neutral`:`danger`,heading:`h2`,title:e?`Cannot preview this file`:`Could not load this file`,subtitle:r.error.message})})}return r.data.type===`file`?(0,F.jsx)(L,{runId:e,entry:r.data,className:n}):(0,F.jsx)(R,{className:n,children:(0,F.jsx)(f,{icon:(0,F.jsx)(E,{}),tone:`neutral`,heading:`h2`,title:`Choose a file inside this directory`,subtitle:`Expand the folder in the tree, or enter the full path to a file.`})})}function L({runId:e,entry:t,className:n}){let r=N(t);return(0,F.jsxs)(R,{className:n,children:[(0,F.jsxs)(`header`,{"data-slot":`file-preview-head`,className:`flex items-center gap-2 border-b border-border bg-muted/40 px-4 py-2 text-xs`,children:[(0,F.jsx)(`span`,{className:`min-w-0 truncate font-mono font-medium`,children:t.path}),(0,F.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-soft-foreground`,children:P(t.size)})]}),r===`image`?(0,F.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,F.jsx)(`img`,{"data-slot":`file-preview-image`,src:d(e,t.path),alt:t.path,className:`max-h-[70vh] max-w-full rounded-sm`})}):r===`too-large`?(0,F.jsx)(f,{icon:(0,F.jsx)(T,{}),tone:`neutral`,heading:`h2`,title:`Too large to preview`,subtitle:`${P(t.size)} — past the preview cap. Open it in your editor instead.`}):r===`binary`?(0,F.jsx)(f,{icon:(0,F.jsx)(E,{}),tone:`neutral`,heading:`h2`,title:`Binary file`,subtitle:`${P(t.size)} of binary data — no text preview.`}):(0,F.jsx)(V,{path:t.path,text:t.content??``})]})}function R({className:e,children:t}){return(0,F.jsx)(`section`,{"data-slot":`file-preview`,className:g(`flex flex-col overflow-hidden rounded-lg border border-border bg-card`,e),children:t})}var z=1500;function B(e,t){let n=(0,A.useMemo)(()=>t.split(`
2
2
  `).map(e=>[{content:e}]),[t]),r=(0,A.useMemo)(()=>y(e),[e]),i=n.length>z,[a,o]=(0,A.useState)(null);return(0,A.useEffect)(()=>{if(r===null||i)return;let n=!1;return x(t,r).then(r=>{n||o({key:`${e}\0${t}`,tokens:r.tokens})}),()=>{n=!0}},[e,t,r,i]),r===null||i?n:a?.key===`${e}\0${t}`?a.tokens:b(t,r)?.tokens??n}function V({path:e,text:t}){let n=B(e,t);return(0,F.jsx)(`div`,{"data-slot":`file-preview-code`,"data-lang":y(e)??`plaintext`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7]`,children:n.map((e,t)=>(0,F.jsxs)(`div`,{className:`flex px-4`,children:[(0,F.jsx)(`span`,{className:`w-10 shrink-0 select-none pr-3 text-right tabular-nums text-soft-foreground`,children:t+1}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre pr-4`,children:e.map((e,t)=>(0,F.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t))})]},t))})}function H({runId:e,selected:t,onSelect:n}){return(0,F.jsx)(`nav`,{"data-slot":`files-tree`,"aria-label":`Worktree files`,className:`min-w-0 text-[13px]`,children:(0,F.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,F.jsx)(U,{runId:e,path:``,depth:0,selected:t,onSelect:n})})})}function U({runId:e,path:t,depth:n,selected:r,onSelect:i}){let a=m(e,t);return a.isPending?(0,F.jsx)(`li`,{"data-slot":`files-tree-loading`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Loading…`}):a.isError?(0,F.jsx)(`li`,{"data-slot":`files-tree-error`,className:`px-1.5 py-1 text-xs text-danger`,style:{paddingLeft:`${6+n*14}px`},children:a.error.message}):a.data.type===`dir`?a.data.entries.length===0?(0,F.jsx)(`li`,{"data-slot":`files-tree-empty`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Empty directory`}):(0,F.jsx)(F.Fragment,{children:a.data.entries.map(a=>a.type===`dir`?(0,F.jsx)(W,{runId:e,name:a.name,path:t===``?a.name:`${t}/${a.name}`,depth:n,selected:r,onSelect:i},a.name):(0,F.jsx)(G,{name:a.name,path:t===``?a.name:`${t}/${a.name}`,size:a.size,depth:n,selected:r,onSelect:i},a.name))}):null}function W({runId:e,name:t,path:n,depth:r,selected:i,onSelect:a}){let[o,c]=(0,A.useState)(!1);return(0,F.jsxs)(`li`,{children:[(0,F.jsxs)(`button`,{type:`button`,"data-slot":`files-dir`,"data-path":n,"data-state":o?`open`:`closed`,"aria-expanded":o,onClick:()=>c(e=>!e),className:`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+r*14}px`},children:[(0,F.jsx)(s,{size:16,"aria-hidden":`true`,className:g(`order-last ml-auto size-3.5 shrink-0 transition-transform motion-reduce:transition-none`,o&&`rotate-90`)}),(0,F.jsx)(u,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,F.jsx)(`span`,{className:`min-w-0 truncate font-normal`,children:t})]}),o?(0,F.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,F.jsx)(U,{runId:e,path:n,depth:r+1,selected:i,onSelect:a})}):null]})}function G({name:e,path:t,size:n,depth:r,selected:i,onSelect:a}){let o=i===t,s=M(t)?k:c;return(0,F.jsx)(`li`,{children:(0,F.jsxs)(`button`,{type:`button`,"data-slot":`files-file`,"data-path":t,"aria-current":o?`true`:void 0,onClick:()=>a(t),className:g(`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,o?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${6+r*14}px`},children:[(0,F.jsx)(s,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,F.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),n===void 0?null:(0,F.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[11px] tabular-nums text-soft-foreground`,children:P(n)})]})})}function K(){let{id:e}=r(),t=i(e);return t.isPending?(0,F.jsx)(w,{tab:`files`}):t.isError?(0,F.jsx)(C,{tab:`files`,error:t.error}):(0,F.jsx)(q,{run:t.data})}function q({run:e}){let t=m(e.id,``),[n,r]=(0,A.useState)(null),[i,s]=(0,A.useState)(``),c=t.isError&&t.error instanceof p&&t.error.status===409;return(0,F.jsxs)(`div`,{"data-route":`task-files`,className:`flex min-h-full flex-col`,children:[(0,F.jsx)(v,{run:e,tab:`files`}),t.isSuccess?(0,F.jsxs)(`form`,{className:`flex min-w-0 gap-2 px-[18px] pt-[22px] md:px-9`,onSubmit:e=>{e.preventDefault(),i.trim()&&r(i.trim())},children:[(0,F.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,F.jsx)(a,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,F.jsx)(S,{"aria-label":`File path in the worktree`,placeholder:`Open a file by path…`,value:i,onChange:e=>s(e.target.value),className:`h-11 min-w-0 bg-card pl-10`})]}),(0,F.jsx)(l,{type:`submit`,variant:`outline`,className:`h-11 shrink-0`,disabled:!i.trim(),children:`Open file`})]}):null,t.isPending?(0,F.jsx)(`p`,{"data-slot":`files-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading files…`}):t.isError?(0,F.jsx)(f,{icon:c?(0,F.jsx)(O,{}):(0,F.jsx)(o,{size:16}),tone:c?`neutral`:`danger`,heading:`h2`,title:c?`No files to browse`:`Could not load the files`,subtitle:t.error.message}):(0,F.jsxs)(`div`,{className:`flex min-h-0 flex-col items-stretch gap-5 px-[18px] py-[22px] [--diff-sticky-top:1rem] md:flex-row md:items-start md:px-9`,children:[(0,F.jsxs)(`aside`,{"data-slot":`files-tree-pane`,className:`w-full shrink-0 rounded-xl border border-border bg-card p-3.5 md:sticky md:top-[var(--diff-sticky-top)] md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] md:w-60 md:overflow-y-auto md:overscroll-contain lg:w-72`,children:[(0,F.jsx)(`h2`,{className:`sr-only`,children:`Worktree files`}),(0,F.jsx)(H,{runId:e.id,selected:n,onSelect:r})]}),(0,F.jsx)(I,{runId:e.id,path:n,className:`min-h-[200px] min-w-0 flex-1 bg-card md:min-h-[400px]`})]}),(0,F.jsx)(`p`,{className:`px-[18px] pb-6 text-xs text-muted-foreground md:px-9`,children:`Browsing files is read-only. Worktree contents may differ from your main checkout.`})]})}export{K as TaskFilesRoute};